org.springframework.security.authentication.dao.DaoAuthenticationProvider Java Examples
The following examples show how to use
org.springframework.security.authentication.dao.DaoAuthenticationProvider.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoginActionsTestIT.java From blackduck-alert with Apache License 2.0 | 6 votes |
@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)); }
Example #2
Source File: SecurityConfig.java From konker-platform with Apache License 2.0 | 6 votes |
@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); }
Example #3
Source File: Oauth20AutoConfiguration.java From MaxKey with Apache License 2.0 | 5 votes |
/** * ProviderManager. * @return oauth20ClientAuthenticationManager */ @Bean(name = "oauth20ClientAuthenticationManager") public ProviderManager oauth20ClientAuthenticationManager( ClientDetailsUserDetailsService oauth20ClientDetailsUserService ) { DaoAuthenticationProvider daoAuthenticationProvider= new DaoAuthenticationProvider(); PasswordEncoder passwordEncoder = NoOpPasswordEncoder.getInstance(); daoAuthenticationProvider.setPasswordEncoder(passwordEncoder); daoAuthenticationProvider.setUserDetailsService(oauth20ClientDetailsUserService); ProviderManager clientAuthenticationManager = new ProviderManager(daoAuthenticationProvider); return clientAuthenticationManager; }
Example #4
Source File: WithBasicAuthSecurityConfiguration.java From grpc-spring-boot-starter with MIT License | 5 votes |
@Bean DaoAuthenticationProvider daoAuthenticationProvider() { final DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); provider.setUserDetailsService(userDetailsService()); provider.setPasswordEncoder(passwordEncoder()); return provider; }
Example #5
Source File: SecurityConfig.java From WeBASE-Node-Manager with Apache License 2.0 | 5 votes |
@Bean public DaoAuthenticationProvider userAuthenticationProvider(){ DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider(); daoAuthenticationProvider.setUserDetailsService(userDetailService); daoAuthenticationProvider.setHideUserNotFoundExceptions(false); daoAuthenticationProvider.setPasswordEncoder(passwordEncoder()); return daoAuthenticationProvider; }
Example #6
Source File: SecurityConfig.java From Oauth2-Stateless-Authentication-with-Spring-and-JWT-Token with MIT License | 5 votes |
@Bean public DaoAuthenticationProvider authenticationProvider() { DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); provider.setPasswordEncoder( passwordEncoder ); provider.setUserDetailsService(userDetailsService()); return provider; }
Example #7
Source File: Application.java From blackduck-alert with Apache License 2.0 | 5 votes |
@Bean public DaoAuthenticationProvider alertDatabaseAuthProvider(final PasswordEncoder defaultPasswordEncoder) { final DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); provider.setUserDetailsService(userDatabaseService); provider.setPasswordEncoder(defaultPasswordEncoder); return provider; }
Example #8
Source File: SecurityConfig.java From springboot-vue.js-bbs with Apache License 2.0 | 5 votes |
@Bean public DaoAuthenticationProvider authenticationProvider() { DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); authProvider.setUserDetailsService(userDetailsService); authProvider.setPasswordEncoder(passwordEncoder()); return authProvider; }
Example #9
Source File: SecurityConfiguration.java From code-examples with MIT License | 5 votes |
@Bean public AuthenticationProvider daoAuthenticationProvider() { DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); provider.setPasswordEncoder(passwordEncoder()); provider.setUserDetailsPasswordService(this.databaseUserDetailPasswordService); provider.setUserDetailsService(this.databaseUserDetailsService); return provider; }
Example #10
Source File: WebSecurityConfig.java From docs-manage with MIT License | 5 votes |
@Bean public DaoAuthenticationProvider authenticationProvider() { DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); provider.setPasswordEncoder(passwordEncoder()); provider.setUserDetailsService(userDetailsService); provider.setSaltSource(user -> ((User) user).getCredential()); return provider; }
Example #11
Source File: SecurityConfiguration.java From grpc-spring-boot-starter with MIT License | 5 votes |
@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; }
Example #12
Source File: WithBasicAuthSecurityConfiguration.java From grpc-spring-boot-starter with MIT License | 5 votes |
@Bean DaoAuthenticationProvider daoAuthenticationProvider() { final DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); provider.setUserDetailsService(userDetailsService()); provider.setPasswordEncoder(passwordEncoder()); return provider; }
Example #13
Source File: SecurityConfig.java From Using-Spring-Oauth2-to-secure-REST with MIT License | 5 votes |
@Bean public DaoAuthenticationProvider authenticationProvider() { DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); provider.setPasswordEncoder( passwordEncoder ); provider.setUserDetailsService( userDetailsService() ); return provider; }
Example #14
Source File: RbacBaseSecurityConfigurerAdapter.java From onetwo with Apache License 2.0 | 5 votes |
@Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { // .jdbcAuthentication().authoritiesByUsernameQuery(query) // .authenticationProvider(authenticationProvider) DaoAuthenticationProvider daoProvider = new DaoAuthenticationProvider(); daoProvider.setUserDetailsService(userDetailsService); daoProvider.afterPropertiesSet(); auth.authenticationProvider(daoProvider); }
Example #15
Source File: WebAnnoSecurity.java From webanno with Apache License 2.0 | 5 votes |
@Bean(name = "authenticationProvider") @Profile("auto-mode-builtin") public DaoAuthenticationProvider internalAuthenticationProvider() { DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); authProvider.setUserDetailsService(userDetailsService()); authProvider.setPasswordEncoder(passwordEncoder); return authProvider; }
Example #16
Source File: WebSecurityConfiguration.java From Parrit with MIT License | 5 votes |
@Bean public AuthenticationProvider authenticationProvider(UserDetailsService userDetailsService, PasswordEncoder passwordEncoder) { DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider(); daoAuthenticationProvider.setUserDetailsService(userDetailsService); daoAuthenticationProvider.setPasswordEncoder(passwordEncoder); daoAuthenticationProvider.setHideUserNotFoundExceptions(false); return daoAuthenticationProvider; }
Example #17
Source File: WebSecurityConfigurer.java From spring-oauth-server with GNU General Public License v2.0 | 5 votes |
@Bean public AuthenticationProvider authenticationProvider() { DaoAuthenticationProvider daoAuthenticationProvider = new DaoAuthenticationProvider(); daoAuthenticationProvider.setUserDetailsService(userService); daoAuthenticationProvider.setPasswordEncoder(passwordEncoder()); return daoAuthenticationProvider; }
Example #18
Source File: SecurityConfig.java From market with MIT License | 5 votes |
@Bean public DaoAuthenticationProvider daoAuthenticationProvider( UserDetailsServiceImpl customUserDetailsService, PasswordEncoder passwordEncoder) { DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); provider.setUserDetailsService(customUserDetailsService); provider.setPasswordEncoder(passwordEncoder); return provider; }
Example #19
Source File: MockServerConfig.java From bearchoke with Apache License 2.0 | 5 votes |
@Bean(name = "authenticationProvider") public AuthenticationProvider authenticationProvider() { DaoAuthenticationProvider result = new DaoAuthenticationProvider(); result.setUserDetailsService(inMemoryUserDetailsManager()); return result; }
Example #20
Source File: MolgenisWebAppSecurityConfig.java From molgenis with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void configure(AuthenticationManagerBuilder auth) { try { DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider(); authenticationProvider.setPasswordEncoder(passwordEncoder()); authenticationProvider.setUserDetailsService(userDetailsServiceBean()); authenticationProvider.setPreAuthenticationChecks(userDetailsChecker()); auth.authenticationProvider(authenticationProvider); } catch (Exception e) { throw new WebAppSecurityConfigException(e); } }
Example #21
Source File: SecurityConfig.java From tutorials with MIT License | 5 votes |
@Bean public DaoAuthenticationProvider authenticationProvider() { final DaoAuthenticationProvider bean = new CustomDaoAuthenticationProvider(); bean.setUserDetailsService(customUserDetailsService); bean.setPasswordEncoder(encoder()); return bean; }
Example #22
Source File: SpringSecurityConfig.java From tutorials with MIT License | 5 votes |
@Bean public DaoAuthenticationProvider authenticationProvider() { final DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); authProvider.setUserDetailsService(userDetailsService); authProvider.setPasswordEncoder(encoder()); return authProvider; }
Example #23
Source File: DatabaseAuthenticationProvider.java From nextreports-server with Apache License 2.0 | 5 votes |
@Override public void afterPropertiesSet() throws Exception { super.afterPropertiesSet(); target = new DaoAuthenticationProvider(); target.setUserDetailsService(new UserDetailsService() { public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { return externalUsersService.getUser(username); } }); }
Example #24
Source File: AppSecurityModelG.java From Spring-5.0-Cookbook with MIT License | 5 votes |
@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; }
Example #25
Source File: SecurityConfig.java From ChengFeng1.5 with MIT License | 5 votes |
@Bean("daoAuthenticationProvider") protected AuthenticationProvider daoAuthenticationProvider() throws Exception{ DaoAuthenticationProvider daoProvider = new DaoAuthenticationProvider(); daoProvider.setPasswordEncoder(passwordEncoder()); daoProvider.setUserDetailsService(userInfoService()); return daoProvider; }
Example #26
Source File: WebSecurityConfig.java From SpringSecurity-JWT-Vue-Deom with MIT License | 5 votes |
@Bean public DaoAuthenticationProvider daoAuthenticationProvider() { DaoAuthenticationProvider provider = new DaoAuthenticationProvider(); provider.setHideUserNotFoundExceptions(false); provider.setPasswordEncoder(passwordEncoder()); provider.setUserDetailsService(new CustomUserDetailsService()); return provider; }
Example #27
Source File: SecurityConfig.java From torrssen2 with MIT License | 5 votes |
@Bean public DaoAuthenticationProvider authenticationProvider() { DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); authProvider.setUserDetailsService(userDetailsService); authProvider.setPasswordEncoder(encoder()); return authProvider; }
Example #28
Source File: SpringMvcSecurityConfig.java From Hands-On-High-Performance-with-Spring-5 with MIT License | 5 votes |
@Bean public AuthenticationProvider authenticationProviderBean() { DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider(); authenticationProvider.setPasswordEncoder(passwordEncoder); authenticationProvider.setUserCache(userCache); authenticationProvider.setUserDetailsService(userDetailsService()); return authenticationProvider; }
Example #29
Source File: SpringMvcSecurityConfig.java From Hands-On-High-Performance-with-Spring-5 with MIT License | 5 votes |
@Bean public AuthenticationProvider authenticationProviderBean() { DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider(); authenticationProvider.setPasswordEncoder(passwordEncoder); authenticationProvider.setUserDetailsService(userDetailsService()); return authenticationProvider; }
Example #30
Source File: InceptionSecurity.java From inception with Apache License 2.0 | 5 votes |
@Bean(name = "authenticationProvider") @Profile("auto-mode-builtin") public DaoAuthenticationProvider internalAuthenticationProvider() { DaoAuthenticationProvider authProvider = new DaoAuthenticationProvider(); authProvider.setUserDetailsService(userDetailsService()); authProvider.setPasswordEncoder(passwordEncoder); return authProvider; }