本文整理汇总了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;
}