本文整理匯總了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