当前位置: 首页>>代码示例>>Java>>正文


Java AuthenticationProvider类代码示例

本文整理汇总了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;
}
 
开发者ID:PatternFM,项目名称:tokamak,代码行数:8,代码来源:AuthorizationServerConfiguration.java

示例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");
    }
}
 
开发者ID:anand1st,项目名称:sshd-shell-spring-boot,代码行数:20,代码来源:SshdServerConfiguration.java

示例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);
}
 
开发者ID:upcrob,项目名称:spring-security-otp,代码行数:21,代码来源:OtpGeneratingAuthenticationProvider.java

示例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))
    ));
}
 
开发者ID:hpe-idol,项目名称:java-hod-sso-spring-security,代码行数:17,代码来源:HodAuthenticationProviderTest.java

示例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"));
}
 
开发者ID:hpe-idol,项目名称:java-hod-sso-spring-security,代码行数:27,代码来源:HodAuthenticationProviderTest.java

示例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
    );
}
 
开发者ID:hpe-idol,项目名称:find,代码行数:24,代码来源:IdolSecurityCustomizerImpl.java

示例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;
}
 
开发者ID:1and1,项目名称:cosmo,代码行数:18,代码来源:AuthenticationProviderDelegatorFactoryBean.java

示例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;
}
 
开发者ID:nextreports,项目名称:nextreports-server,代码行数:19,代码来源:NextServerSession.java

示例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;
}
 
开发者ID:telstra,项目名称:open-kilda,代码行数:8,代码来源:SecurityConfig.java

示例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;
}
 
开发者ID:AlexIvchenko,项目名称:markdown-redactor,代码行数:8,代码来源:RootSecurityConfig.java

示例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);
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:10,代码来源:BaseSecurityInitializer.java

示例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;
}
 
开发者ID:PatternFM,项目名称:tokamak,代码行数:8,代码来源:AuthorizationServerConfiguration.java

示例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;
}
 
开发者ID:PacktPublishing,项目名称:Spring-Security-Third-Edition,代码行数:9,代码来源:SecurityConfig.java

示例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;
}
 
开发者ID:reportportal,项目名称:service-authorization,代码行数:14,代码来源:ActiveDirectoryAuthProvider.java


注:本文中的org.springframework.security.authentication.AuthenticationProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。