本文整理匯總了Java中org.springframework.security.authentication.AuthenticationProvider類的典型用法代碼示例。如果您正苦於以下問題:Java AuthenticationProvider類的具體用法?Java AuthenticationProvider怎麽用?Java AuthenticationProvider使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
AuthenticationProvider類屬於org.springframework.security.authentication包,在下文中一共展示了AuthenticationProvider類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: clientAuthenticationProvider
import org.springframework.security.authentication.AuthenticationProvider; //導入依賴的package包/類
@Bean(name = "clientAuthenticationProvider")
public AuthenticationProvider clientAuthenticationProvider() {
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setPasswordEncoder(new BCryptPasswordEncoder());
provider.setUserDetailsService(new ClientDetailsUserDetailsService(clientAuthenticationService));
return provider;
}
示例2: passwordAuthenticator
import org.springframework.security.authentication.AuthenticationProvider; //導入依賴的package包/類
@Bean
PasswordAuthenticator passwordAuthenticator() {
SshdShellProperties.Shell.Auth props = properties.getShell().getAuth();
switch (props.getAuthType()) {
case SIMPLE:
return new SimpleSshdPasswordAuthenticator(properties);
case AUTH_PROVIDER:
try {
AuthenticationProvider authProvider = Objects.isNull(props.getAuthProviderBeanName())
? appContext.getBean(AuthenticationProvider.class)
: appContext.getBean(props.getAuthProviderBeanName(), AuthenticationProvider.class);
return new AuthProviderSshdPasswordAuthenticator(authProvider);
} catch (BeansException ex) {
throw new IllegalArgumentException("Expected a default or valid AuthenticationProvider bean", ex);
}
default:
throw new IllegalArgumentException("Invalid/Unsupported auth type");
}
}
示例3: OtpGeneratingAuthenticationProvider
import org.springframework.security.authentication.AuthenticationProvider; //導入依賴的package包/類
public OtpGeneratingAuthenticationProvider(AuthenticationProvider provider,
Tokenstore tokenstore, LookupStrategy lookupStrategy, SendStrategy sendStrategy) {
if (provider == null) {
throw new IllegalArgumentException("Embedded authentication provider must not be null.");
}
if (tokenstore == null) {
throw new IllegalArgumentException("Tokenstore must not be null.");
}
if (lookupStrategy == null) {
throw new IllegalArgumentException("LookupStrategy must not be null.");
}
if (sendStrategy == null) {
throw new IllegalArgumentException("SendStrategy must not be null.");
}
this.provider = provider;
this.tokenstore = tokenstore;
this.lookupStrategy = lookupStrategy;
this.sendStrategy = sendStrategy;
this.gen = new DefaultOtpGenerator(DEFAULT_OTP_LENGTH);
}
示例4: 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))
));
}
示例5: 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"));
}
示例6: 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
示例7: communityAuthenticationProvider
import org.springframework.security.authentication.AuthenticationProvider; //導入依賴的package包/類
private AuthenticationProvider communityAuthenticationProvider() {
final Role user = new Role.Builder()
.setName(FindCommunityRole.USER.value())
.setPrivileges(Collections.singleton("login"))
.build();
final Set<String> defaultRoles;
if (defaultRolesProperty.isEmpty()) {
defaultRoles = Collections.emptySet();
} else {
defaultRoles = new HashSet<>(Arrays.asList(defaultRolesProperty.split(",")));
}
return new CommunityAuthenticationProvider(
configService,
userService,
new Roles(Collections.singletonList(user)),
Collections.singleton("login"),
grantedAuthoritiesMapper,
defaultRoles
);
}
示例8: getProviders
import org.springframework.security.authentication.AuthenticationProvider; //導入依賴的package包/類
private Collection<? extends AuthenticationProvider> getProviders(){
Collection<? extends AuthenticationProvider> authenticationProviders = externalComponentInstanceProvider.getImplInstancesAnnotatedWith(CalendarSecurity.class, AuthenticationProvider.class);
checkAuthenticationProviders(authenticationProviders);
LOGGER.info("Found [{}] authentication provider implementations", authenticationProviders.size());
Collection<? extends SuccessfulAuthenticationListener> successfulAuthenticationListeners = getSuccessfulAuthenticationListeners();
LOGGER.info("Found [{}] successful authentication listener implementations", authenticationProviders.size());
List<AuthenticationProvider> result = new ArrayList<>(1);
for(AuthenticationProvider authenticationProvider : authenticationProviders){
AuthenticationProvider authenticationProviderProxy = authenticationProviderProxyFactory.createProxyFor(authenticationProvider, successfulAuthenticationListeners);
result.add(authenticationProviderProxy);
}
return result;
}
示例9: getRealms
import org.springframework.security.authentication.AuthenticationProvider; //導入依賴的package包/類
public List<String> getRealms() {
List<AuthenticationProvider> providers = authenticationManager.getProviders();
if (LOG.isDebugEnabled()) {
LOG.debug("Found " + providers.size() + " authentication providers");
}
List<String> realms = new ArrayList<String>();
for (AuthenticationProvider provider : providers) {
if (provider instanceof ExternalAuthenticationProvider) {
ExternalAuthenticationProvider externalProvider = (ExternalAuthenticationProvider) provider;
realms.add(externalProvider.getRealm());
} else if (provider instanceof NextServerAuthenticationProvider) {
realms.add(""); // default provider
}
}
return realms;
}
示例10: authenticationManager
import org.springframework.security.authentication.AuthenticationProvider; //導入依賴的package包/類
@Bean("authenticationManager")
public ProviderManager authenticationManager() {
List<AuthenticationProvider> authProviderList = new ArrayList<AuthenticationProvider>();
authProviderList.add(authProvider());
ProviderManager providerManager = new ProviderManager(authProviderList);
return providerManager;
}
示例11: authenticationProvider
import org.springframework.security.authentication.AuthenticationProvider; //導入依賴的package包/類
@Bean
public AuthenticationProvider authenticationProvider(UserRepository repository) {
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setUserDetailsService(userDetailsService(repository));
provider.setPasswordEncoder(passwordEncoder());
return provider;
}
示例12: configure
import org.springframework.security.authentication.AuthenticationProvider; //導入依賴的package包/類
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
AuthenticationProvider[] providers = primaryAuthProviders();
for (AuthenticationProvider provider : providers) {
auth = auth.authenticationProvider(provider);
}
auth.authenticationProvider(tokenProvider);
}
示例13: userAuthenticationProvider
import org.springframework.security.authentication.AuthenticationProvider; //導入依賴的package包/類
@Bean
public AuthenticationProvider userAuthenticationProvider() {
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setPasswordEncoder(new BCryptPasswordEncoder());
provider.setUserDetailsService(accountAuthenticationService);
return provider;
}
示例14: authenticationProvider
import org.springframework.security.authentication.AuthenticationProvider; //導入依賴的package包/類
@Bean
public AuthenticationProvider authenticationProvider(){
ActiveDirectoryLdapAuthenticationProvider ap = new ActiveDirectoryLdapAuthenticationProvider(
"corp.jbcpcalendar.com",
"ldap://corp.jbcpcalendar.com/");
ap.setConvertSubErrorCodesToExceptions(true);
return ap;
}
示例15: getDelegate
import org.springframework.security.authentication.AuthenticationProvider; //導入依賴的package包/類
@Override
protected AuthenticationProvider getDelegate() {
ActiveDirectoryConfig adConfig = authConfigRepository.findActiveDirectory(true)
.orElseThrow(() -> new BadCredentialsException("Active Directory is not configured"));
ActiveDirectoryLdapAuthenticationProvider adAuth = new ActiveDirectoryLdapAuthenticationProvider(adConfig.getDomain(),
adConfig.getUrl(), adConfig.getBaseDn());
adAuth.setAuthoritiesMapper(new NullAuthoritiesMapper());
adAuth.setUserDetailsContextMapper(new DetailsContextMapper(ldapUserReplicator, adConfig.getSynchronizationAttributes()));
return adAuth;
}