當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。