List of usage examples for org.springframework.security.config.annotation.authentication.builders AuthenticationManagerBuilder jdbcAuthentication
public JdbcUserDetailsManagerConfigurer<AuthenticationManagerBuilder> jdbcAuthentication() throws Exception
From source file:no.ntnu.okse.web.WebSecurityConfig.java
/** * Connects to the dataSource and validates a user log in * * @param auth An AuthenticationManagerBuilder instance * @throws Exception general exception//www . j av a 2s . com */ @Autowired public void configAuthentication(AuthenticationManagerBuilder auth) throws Exception { auth.jdbcAuthentication().dataSource(dataSource) .usersByUsernameQuery("select username, password, enabled from users where username=?") .authoritiesByUsernameQuery("select username, authority from authorities where username=?") .passwordEncoder(passwordEncoder()); }
From source file:org.drugis.addis.config.SecurityConfig.java
@Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { auth.jdbcAuthentication().dataSource(dataSource) .usersByUsernameQuery("SELECT username, password, TRUE FROM Account WHERE username = ?") .authoritiesByUsernameQuery( "SELECT Account.username, COALESCE(AccountRoles.role, 'ROLE_USER') FROM Account" + " LEFT OUTER JOIN AccountRoles ON Account.id = AccountRoles.accountId WHERE Account.username = ?") .passwordEncoder(passwordEncoder()); auth.authenticationProvider(tokenAuthenticationProvider()); }
From source file:reconf.server.ApplicationSecurity.java
@Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth.userDetailsService(userDetailsManager); auth.jdbcAuthentication().dataSource(userDetailsManager.getDataSource()); if (userDetailsManager.userExists(ReConfConstants.SERVER_ROOT_USER)) { userDetailsManager.deleteUser(ReConfConstants.SERVER_ROOT_USER); }/*from w w w .jav a2 s . com*/ List<GrantedAuthority> authorities = new ArrayList<>(); authorities.add(new SimpleGrantedAuthority("ROOT")); authorities.add(new SimpleGrantedAuthority("USER")); User user = new User(ReConfConstants.SERVER_ROOT_USER, rootUserPassword, authorities); userDetailsManager.createUser(user); }
From source file:de.dominikschadow.duke.encounters.config.WebSecurityConfig.java
@Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { // @formatter:off auth.jdbcAuthentication().dataSource(dataSource).passwordEncoder(passwordEncoder()); // @formatter:on }
From source file:cn.org.once.cstack.config.SecurityConfiguration.java
@Override public void configure(AuthenticationManagerBuilder auth) throws Exception { auth.jdbcAuthentication().passwordEncoder(passwordEncoder()).dataSource(dataSource) .usersByUsernameQuery(//from ww w .ja v a2 s .c o m "Select login, password, 'true' as enabled from User where login=? and status!=0") .authoritiesByUsernameQuery( "Select u.login, r.description From Role r join User u on u.role_id=r.id where u.login=?"); // auth.inMemoryAuthentication().withUser("john").password("doe").roles("ADMIN, // USER"); }
From source file:fr.treeptik.cloudunit.config.SecurityConfiguration.java
@Override public void configure(AuthenticationManagerBuilder auth) throws Exception { auth.jdbcAuthentication().passwordEncoder(passwordEncoder()).dataSource(dataSource) .usersByUsernameQuery(//from w w w . java 2 s . c o m "Select login, password, 'true' as enabled from User where login=? and status!=0") .authoritiesByUsernameQuery( "Select u.login, r.description From Role r join User u on u.role_id=r.id where u.login=?"); //auth.inMemoryAuthentication().withUser("john").password("doe").roles("ADMIN, USER"); }
From source file:pl.ething.config.SecurityConfiguration.java
@Autowired public void configureAuth(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception { //authenticationManagerBuilder.inMemoryAuthentication() //.withUser("admin").password("admin").roles("ADMIN"); authenticationManagerBuilder.jdbcAuthentication().dataSource(dataSource).passwordEncoder(passwordEncoder()) .usersByUsernameQuery(/*from w ww. j av a 2 s . c om*/ "select login,password, true from ething_user where login=? and activation='1'") .authoritiesByUsernameQuery("select login, role from ething_user where login=?"); }
From source file:org.createnet.raptor.auth.service.Application.java
@Autowired public void init(AuthenticationManagerBuilder auth) throws Exception { auth.jdbcAuthentication().dataSource(dataSource); createDefaultUser();//from ww w . j a va 2s . c om }
From source file:org.schedoscope.metascope.config.ProductionSpringConfiguration.java
@Override protected void configure(AuthenticationManagerBuilder auth) throws Exception { MetascopeConfig config = metascopeConfig(); if (config.getAuthenticationMethod().equalsIgnoreCase("ldap")) { auth.ldapAuthentication().userDnPatterns(config.getUserDnPattern()) .groupSearchBase(config.getGroupSearchBase()).contextSource(ldapContextSource()); } else {/*from ww w . ja va 2 s . c o m*/ auth.jdbcAuthentication().passwordEncoder(new ShaPasswordEncoder(256)).dataSource(dataSource()) .usersByUsernameQuery( "select username,password_hash,'true' from metascope_user where username = ?") .authoritiesByUsernameQuery("select username,userrole from metascope_user where username = ?"); metascopeUserService.createAdminAccount(); } }
From source file:runtheshow.frontend.config.SecurityConfiguration.java
@Override protected void configure(AuthenticationManagerBuilder registry) throws Exception { // l'authentification est faite par jdbc authentication en attendant de pouvoir utiliser appUserDetailservice // le mot de passe est crypt par l'algorithme de hachage BCrypt AppConfiguration uneConfiguration = new AppConfiguration(); DataSource ds = uneConfiguration.dataSource(); final String findUserQuery = "select user_login,user_password,user_enabled " + "from users " + "where user_login = ?"; final String findRoles = "select u.user_login,r.role_name " + "from roles r, users u, users_roles ur " + "where u.user_login = ? and u.id = ur.user_id and ur.role_id = r.id"; registry.jdbcAuthentication().dataSource(ds).usersByUsernameQuery(findUserQuery) .authoritiesByUsernameQuery(findRoles).passwordEncoder(new BCryptPasswordEncoder(12)); //registry.userDetailsService(appUserDetailsService); }