类org.springframework.security.authentication.dao.DaoAuthenticationProvider源码实例Demo

下面列出了怎么用org.springframework.security.authentication.dao.DaoAuthenticationProvider的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: blackduck-alert   文件: LoginActionsTestIT.java
@Test
public void testAuthenticationLDAPExceptionIT() throws Exception {
    Authentication authentication = Mockito.mock(Authentication.class);
    Mockito.when(authentication.isAuthenticated()).thenReturn(true);
    LdapAuthenticationProvider ldapAuthenticationProvider = Mockito.mock(LdapAuthenticationProvider.class);
    Mockito.when(ldapAuthenticationProvider.authenticate(Mockito.any(Authentication.class))).thenReturn(authentication);
    LdapManager mockLdapManager = Mockito.mock(LdapManager.class);
    Mockito.when(mockLdapManager.isLdapEnabled()).thenReturn(true);
    Mockito.when(mockLdapManager.getAuthenticationProvider()).thenThrow(new AlertConfigurationException("LDAP CONFIG EXCEPTION"));
    DaoAuthenticationProvider databaseProvider = Mockito.mock(DaoAuthenticationProvider.class);
    Mockito.when(databaseProvider.authenticate(Mockito.any(Authentication.class))).thenReturn(authentication);
    AuthenticationEventManager authenticationEventManager = Mockito.mock(AuthenticationEventManager.class);
    Mockito.doNothing().when(authenticationEventManager).sendAuthenticationEvent(Mockito.any(), Mockito.eq(AuthenticationType.LDAP));
    AuthorizationUtility authorizationUtility = Mockito.mock(AuthorizationUtility.class);

    AlertDatabaseAuthenticationPerformer alertDatabaseAuthenticationPerformer = new AlertDatabaseAuthenticationPerformer(authenticationEventManager, authorizationUtility, databaseProvider);

    AlertAuthenticationProvider authenticationProvider = new AlertAuthenticationProvider(List.of(alertDatabaseAuthenticationPerformer));
    LoginActions loginActions = new LoginActions(authenticationProvider);
    boolean authenticated = loginActions.authenticateUser(mockLoginRestModel.createRestModel());
    assertFalse(authenticated);
    Mockito.verify(databaseProvider).authenticate(Mockito.any(Authentication.class));
}
 
源代码2 项目: konker-platform   文件: SecurityConfig.java
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
    authenticationProvider.setUserDetailsService(detailsService);
    authenticationProvider.setPasswordEncoder(new PlaintextPasswordEncoder() {
        @Override
        public boolean isPasswordValid(String encPass, String rawPass, Object salt) {
            try {
                return new PasswordManager().validatePassword(rawPass, encPass);
            } catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
                LOGGER.error(e.getMessage(), e);
                return false;
            }
        }
    });
    auth.authenticationProvider(authenticationProvider);
}
 
源代码3 项目: WeBASE-Node-Manager   文件: SecurityConfig.java
@Bean
public DaoAuthenticationProvider userAuthenticationProvider(){
    DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider();
    daoAuthenticationProvider.setUserDetailsService(userDetailService);
    daoAuthenticationProvider.setHideUserNotFoundExceptions(false);
    daoAuthenticationProvider.setPasswordEncoder(passwordEncoder());
    return daoAuthenticationProvider;
}
 
源代码4 项目: ChengFeng1.5   文件: SecurityConfig.java
@Bean("daoAuthenticationProvider")
protected AuthenticationProvider daoAuthenticationProvider() throws Exception{
    DaoAuthenticationProvider daoProvider = new DaoAuthenticationProvider();
    daoProvider.setPasswordEncoder(passwordEncoder());
    daoProvider.setUserDetailsService(userInfoService());
    return daoProvider;
}
 
@Bean
public DaoAuthenticationProvider daoAuthenticationProvider() {

    DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
    provider.setHideUserNotFoundExceptions(false);
    provider.setPasswordEncoder(passwordEncoder());
    provider.setUserDetailsService(new CustomUserDetailsService());
    return provider;
}
 
源代码6 项目: torrssen2   文件: SecurityConfig.java
@Bean
public DaoAuthenticationProvider authenticationProvider() { 
    DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
    authProvider.setUserDetailsService(userDetailsService);
    authProvider.setPasswordEncoder(encoder());
    return authProvider;
}
 
@Bean
public AuthenticationProvider authenticationProviderBean() {
    DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
    authenticationProvider.setPasswordEncoder(passwordEncoder);
    authenticationProvider.setUserCache(userCache);
    authenticationProvider.setUserDetailsService(userDetailsService());
    
    return authenticationProvider;
}
 
@Bean
public AuthenticationProvider authenticationProviderBean() {
    DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
    authenticationProvider.setPasswordEncoder(passwordEncoder);
    authenticationProvider.setUserDetailsService(userDetailsService());
    
    return authenticationProvider;
}
 
源代码9 项目: inception   文件: InceptionSecurity.java
@Bean(name = "authenticationProvider")
@Profile("auto-mode-builtin")
public DaoAuthenticationProvider internalAuthenticationProvider()
{
    DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
    authProvider.setUserDetailsService(userDetailsService());
    authProvider.setPasswordEncoder(passwordEncoder);
    return authProvider;
}
 
源代码10 项目: spring-glee-o-meter   文件: ServerSecurityConfig.java
@Bean
public DaoAuthenticationProvider authenticationProvider() {
    DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
    provider.setPasswordEncoder(passwordEncoder());
    provider.setUserDetailsService(userDetailsService);
    return provider;
}
 
源代码11 项目: heimdall   文件: SecurityConfiguration.java
/**
 * Returns a configured {@link DaoAuthenticationProvider}.
 *
 * @return {@link DaoAuthenticationProvider}
 */
@Bean
public DaoAuthenticationProvider jdbcProvider() {
    DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
    authProvider.setUserDetailsService(userDetailsService);
    authProvider.setPasswordEncoder(passwordEncoder);
    return authProvider;
}
 
源代码12 项目: Spring-5.0-Cookbook   文件: AppSecurityModelG.java
@Bean
public DaoAuthenticationProvider authProvider() {
 DaoAuthenticationProvider daoProvider = new DaoAuthenticationProvider();
	daoProvider.setPasswordEncoder(md5PasswordEncoder());
	daoProvider.setUserDetailsService(userDetailsService);
	ReflectionSaltSource saltHash = new ReflectionSaltSource();
	saltHash.setUserPropertyToUse("username");
	daoProvider.setSaltSource(saltHash);
    return daoProvider;
}
 
源代码13 项目: Spring-5.0-Cookbook   文件: AppSecurityModelE2.java
@Bean
public DaoAuthenticationProvider authProvider() {
 DaoAuthenticationProvider daoProvider = new DaoAuthenticationProvider();
	daoProvider.setPasswordEncoder(md5PasswordEncoder());
	daoProvider.setUserDetailsService(userDetailsService);
	ReflectionSaltSource saltHash = new ReflectionSaltSource();
	saltHash.setUserPropertyToUse("username");
	daoProvider.setSaltSource(saltHash);
    return daoProvider;
}
 
源代码14 项目: Spring-5.0-Cookbook   文件: AppSecurityModelJ.java
@Bean
public DaoAuthenticationProvider authProvider() {
 DaoAuthenticationProvider daoProvider = new DaoAuthenticationProvider();
	daoProvider.setPasswordEncoder(md5PasswordEncoder());
	daoProvider.setUserDetailsService(userDetailsService);
	ReflectionSaltSource saltHash = new ReflectionSaltSource();
	saltHash.setUserPropertyToUse("username");
	daoProvider.setSaltSource(saltHash);
    return daoProvider;
}
 
源代码15 项目: Spring-5.0-Cookbook   文件: AppSecurityModelE.java
@Bean
public DaoAuthenticationProvider authProvider() {
 DaoAuthenticationProvider daoProvider = new DaoAuthenticationProvider();
	daoProvider.setPasswordEncoder(md5PasswordEncoder());
	daoProvider.setUserDetailsService(userDetailsService);
	ReflectionSaltSource saltHash = new ReflectionSaltSource();
	saltHash.setUserPropertyToUse("username");
	daoProvider.setSaltSource(saltHash);
    return daoProvider;
}
 
源代码16 项目: Spring-5.0-Cookbook   文件: AppSecurityModelF.java
@Bean
public DaoAuthenticationProvider authProvider() {
 DaoAuthenticationProvider daoProvider = new DaoAuthenticationProvider();
	daoProvider.setPasswordEncoder(md5PasswordEncoder());
	daoProvider.setUserDetailsService(userDetailsService);
	ReflectionSaltSource saltHash = new ReflectionSaltSource();
	saltHash.setUserPropertyToUse("username");
	daoProvider.setSaltSource(saltHash);
    return daoProvider;
}
 
源代码17 项目: Spring-5.0-Cookbook   文件: AppSecurityModelG.java
@Bean
public DaoAuthenticationProvider authProvider() {
 DaoAuthenticationProvider daoProvider = new DaoAuthenticationProvider();
	daoProvider.setPasswordEncoder(md5PasswordEncoder());
	daoProvider.setUserDetailsService(userDetailsService);
	ReflectionSaltSource saltHash = new ReflectionSaltSource();
	saltHash.setUserPropertyToUse("username");
	daoProvider.setSaltSource(saltHash);
    return daoProvider;
}
 
源代码18 项目: Spring-5.0-Cookbook   文件: AppSecurityModelE2.java
@Bean
public DaoAuthenticationProvider authProvider() {
 DaoAuthenticationProvider daoProvider = new DaoAuthenticationProvider();
	daoProvider.setPasswordEncoder(md5PasswordEncoder());
	daoProvider.setUserDetailsService(userDetailsService);
	ReflectionSaltSource saltHash = new ReflectionSaltSource();
	saltHash.setUserPropertyToUse("username");
	daoProvider.setSaltSource(saltHash);
    return daoProvider;
}
 
源代码19 项目: Spring-5.0-Cookbook   文件: AppSecurityModelJ.java
@Bean
public DaoAuthenticationProvider authProvider() {
 DaoAuthenticationProvider daoProvider = new DaoAuthenticationProvider();
	daoProvider.setPasswordEncoder(md5PasswordEncoder());
	daoProvider.setUserDetailsService(userDetailsService);
	ReflectionSaltSource saltHash = new ReflectionSaltSource();
	saltHash.setUserPropertyToUse("username");
	daoProvider.setSaltSource(saltHash);
    return daoProvider;
}
 
源代码20 项目: Spring-5.0-Cookbook   文件: AppSecurityModelE.java
@Bean
public DaoAuthenticationProvider authProvider() {
 DaoAuthenticationProvider daoProvider = new DaoAuthenticationProvider();
	daoProvider.setPasswordEncoder(md5PasswordEncoder());
	daoProvider.setUserDetailsService(userDetailsService);
	ReflectionSaltSource saltHash = new ReflectionSaltSource();
	saltHash.setUserPropertyToUse("username");
	daoProvider.setSaltSource(saltHash);
    return daoProvider;
}
 
源代码21 项目: Spring-5.0-Cookbook   文件: AppSecurityModelF.java
@Bean
public DaoAuthenticationProvider authProvider() {
 DaoAuthenticationProvider daoProvider = new DaoAuthenticationProvider();
	daoProvider.setPasswordEncoder(md5PasswordEncoder());
	daoProvider.setUserDetailsService(userDetailsService);
	ReflectionSaltSource saltHash = new ReflectionSaltSource();
	saltHash.setUserPropertyToUse("username");
	daoProvider.setSaltSource(saltHash);
    return daoProvider;
}
 
@Bean
// One of your authentication providers.
// They ensure that the credentials are valid and populate the user's authorities.
DaoAuthenticationProvider daoAuthenticationProvider() {
    final DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
    provider.setUserDetailsService(userDetailsService());
    provider.setPasswordEncoder(passwordEncoder());
    return provider;
}
 
@Bean
DaoAuthenticationProvider daoAuthenticationProvider() {
    final DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
    provider.setUserDetailsService(userDetailsService());
    provider.setPasswordEncoder(passwordEncoder());
    return provider;
}
 
@Bean
public DaoAuthenticationProvider authenticationProvider() {
    DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
    provider.setPasswordEncoder( passwordEncoder );
    provider.setUserDetailsService( userDetailsService() );
    return provider;
}
 
@Bean
public DaoAuthenticationProvider authenticationProvider() {
    DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
    provider.setPasswordEncoder( passwordEncoder );
    provider.setUserDetailsService(userDetailsService());
    return provider;
}
 
源代码26 项目: blackduck-alert   文件: Application.java
@Bean
public DaoAuthenticationProvider alertDatabaseAuthProvider(final PasswordEncoder defaultPasswordEncoder) {
    final DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
    provider.setUserDetailsService(userDatabaseService);
    provider.setPasswordEncoder(defaultPasswordEncoder);
    return provider;
}
 
源代码27 项目: springboot-vue.js-bbs   文件: SecurityConfig.java
@Bean
public DaoAuthenticationProvider authenticationProvider() {
    DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider();
    authProvider.setUserDetailsService(userDetailsService);
    authProvider.setPasswordEncoder(passwordEncoder());
    return authProvider;
}
 
源代码28 项目: code-examples   文件: SecurityConfiguration.java
@Bean
public AuthenticationProvider daoAuthenticationProvider() {
  DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
  provider.setPasswordEncoder(passwordEncoder());
  provider.setUserDetailsPasswordService(this.databaseUserDetailPasswordService);
  provider.setUserDetailsService(this.databaseUserDetailsService);
  return provider;
}
 
源代码29 项目: docs-manage   文件: WebSecurityConfig.java
@Bean
public DaoAuthenticationProvider authenticationProvider() {
    DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
    provider.setPasswordEncoder(passwordEncoder());
    provider.setUserDetailsService(userDetailsService);
    provider.setSaltSource(user -> ((User) user).getCredential());
    return provider;
}
 
@Bean
// One of your authentication providers.
// They ensure that the credentials are valid and populate the user's authorities.
DaoAuthenticationProvider daoAuthenticationProvider() {
    final DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
    provider.setUserDetailsService(userDetailsService());
    provider.setPasswordEncoder(passwordEncoder());
    return provider;
}
 
 同包方法