本文整理汇总了Java中org.springframework.security.authentication.AuthenticationProvider.authenticate方法的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationProvider.authenticate方法的具体用法?Java AuthenticationProvider.authenticate怎么用?Java AuthenticationProvider.authenticate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.security.authentication.AuthenticationProvider
的用法示例。
在下文中一共展示了AuthenticationProvider.authenticate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: authenticatesWithAuthoritiesResolver
import org.springframework.security.authentication.AuthenticationProvider; //导入方法依赖的package包/类
@Test
public void authenticatesWithAuthoritiesResolver() throws HodErrorException {
final GrantedAuthoritiesResolver resolver = (tokenProxy1, combinedTokenInformation) -> ImmutableList.<GrantedAuthority>builder()
.add(new SimpleGrantedAuthority("ROLE_1"))
.add(new SimpleGrantedAuthority("ROLE_2"))
.build();
final AuthenticationProvider provider = new HodAuthenticationProvider(tokenRepository, resolver, authenticationService, unboundTokenService);
final Authentication authentication = provider.authenticate(new HodTokenAuthentication<>(combinedSsoToken));
assertThat(authentication.getAuthorities(), containsInAnyOrder(
new SimpleGrantedAuthority("ROLE_1"),
new SimpleGrantedAuthority("ROLE_2"),
new HodApplicationGrantedAuthority(new ResourceName(APPLICATION_DOMAIN, APPLICATION_NAME))
));
}
示例2: authenticatesWithUsernameResolver
import org.springframework.security.authentication.AuthenticationProvider; //导入方法依赖的package包/类
@Test
public void authenticatesWithUsernameResolver() throws HodErrorException {
final Map<String, JsonNode> hodMetadata = ImmutableMap.<String, JsonNode>builder()
.put("username", mock(JsonNode.class))
.put("manager", mock(JsonNode.class))
.build();
final Map<String, Serializable> outputMetadata = ImmutableMap.<String, Serializable>builder()
.put("username", "fred")
.put("manager", "penny")
.build();
final AuthenticationProvider provider = new HodAuthenticationProvider(
tokenRepository,
USER_ROLE,
authenticationService,
unboundTokenService,
userStoreUsersService,
metadata -> new HodUserMetadata("fred", outputMetadata)
);
when(userStoreUsersService.getUserMetadata(tokenProxy, new ResourceName(USERSTORE_DOMAIN, USERSTORE_NAME), USER_UUID))
.thenReturn(hodMetadata);
final Authentication authentication = provider.authenticate(new HodTokenAuthentication<>(combinedSsoToken));
assertThat(authentication.getName(), is("fred"));
}
示例3: authenticatesWithAuthoritiesResolver
import org.springframework.security.authentication.AuthenticationProvider; //导入方法依赖的package包/类
@Test
public void authenticatesWithAuthoritiesResolver() throws HodErrorException {
when(authenticationService.getCombinedTokenInformation(combinedToken)).thenReturn(createCombinedTokenInformation(applicationAuthenticationUuid));
final GrantedAuthoritiesResolver resolver = (proxy, combinedTokenInformation) -> ImmutableList.<GrantedAuthority>builder()
.add(new SimpleGrantedAuthority("ROLE_1"))
.add(new SimpleGrantedAuthority("ROLE_2"))
.build();
final AuthenticationProvider provider = new CookieHodAuthenticationProvider(tokenRepository, resolver, authenticationService, unboundTokenService);
final Authentication authentication = provider.authenticate(new HodTokenAuthentication<>(combinedToken));
assertThat(authentication.getAuthorities(), containsInAnyOrder(
new SimpleGrantedAuthority("ROLE_1"),
new SimpleGrantedAuthority("ROLE_2"),
new HodApplicationGrantedAuthority(new ResourceName(APPLICATION_DOMAIN, APPLICATION_NAME))
));
}
开发者ID:hpe-idol,项目名称:java-hod-sso-spring-security,代码行数:19,代码来源:CookieHodAuthenticationProviderTest.java
示例4: authenticate
import org.springframework.security.authentication.AuthenticationProvider; //导入方法依赖的package包/类
/**
* Authenticate against the given external providers.
*
* @see edu.ur.ir.security.ExternalAuthenticationProvider#authenticate(org.springframework.security.Authentication)
*/
public Authentication authenticate(Authentication authentication)
throws AuthenticationException {
AuthenticationException ae = null;
for( AuthenticationProvider provider : authenticationProviders)
{
try
{
// return out of loop as soon as authentication occurs
if( provider.supports(authentication.getClass()))
{
Authentication auth = provider.authenticate(authentication);
return auth;
}
}
catch(AuthenticationException exception)
{
ae = exception;
}
}
if( ae != null )
{
throw ae;
}
else
{
throw new BadCredentialsException(messages.getMessage("ProviderManager.providerNotFound",
authentication.getClass().getName()));
}
}
示例5: authenticate
import org.springframework.security.authentication.AuthenticationProvider; //导入方法依赖的package包/类
@Override
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
Authentication result = null;
for(AuthenticationProvider delegate : delegates){
if(delegate.supports(authentication.getClass()) && (result = delegate.authenticate(authentication)) != null){
break;
}
}
return result;
}
示例6: arbitraryCasedNameReturnsValidAuthentication
import org.springframework.security.authentication.AuthenticationProvider; //导入方法依赖的package包/类
@Test
public void arbitraryCasedNameReturnsValidAuthentication() {
AuthenticationProvider provider = createProvider();
Authentication authentication = provider.authenticate(createAuthenticationTokenWithUserAndPw("AdMiN", "adm1n"));
Assert.assertNotNull(authentication);
}
开发者ID:AndreasKl,项目名称:springboot-angular-atmosphere-quickstart,代码行数:7,代码来源:FakeAuthenticationProviderTest.java
示例7: validPasswordReturnsValidAuthentication
import org.springframework.security.authentication.AuthenticationProvider; //导入方法依赖的package包/类
@Test
public void validPasswordReturnsValidAuthentication() {
AuthenticationProvider provider = createProvider();
Authentication authentication = provider.authenticate(createAuthenticationTokenWithUserAndPw("admin", "adm1n"));
Assert.assertNotNull(authentication);
}
开发者ID:AndreasKl,项目名称:springboot-angular-atmosphere-quickstart,代码行数:7,代码来源:FakeAuthenticationProviderTest.java
示例8: invalidPasswordRaises
import org.springframework.security.authentication.AuthenticationProvider; //导入方法依赖的package包/类
@Test(expected = BadCredentialsException.class)
public void invalidPasswordRaises() {
AuthenticationProvider provider = createProvider();
provider.authenticate(createAuthenticationTokenWithUserAndPw("admin", "admin"));
}
开发者ID:AndreasKl,项目名称:springboot-angular-atmosphere-quickstart,代码行数:6,代码来源:FakeAuthenticationProviderTest.java
示例9: invalidUserRaises
import org.springframework.security.authentication.AuthenticationProvider; //导入方法依赖的package包/类
@Test(expected = BadCredentialsException.class)
public void invalidUserRaises() {
AuthenticationProvider provider = createProvider();
provider.authenticate(createAuthenticationTokenWithUserAndPw("admon", "adm1n"));
}
开发者ID:AndreasKl,项目名称:springboot-angular-atmosphere-quickstart,代码行数:6,代码来源:FakeAuthenticationProviderTest.java