JDBC-basedUser Store Example: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 22: Line 22:
           dataSource(dataSource).
           dataSource(dataSource).
           passwordEncoder(NoOpPasswordEncoder.getInstance()); // apparently it needs a password encoder otherwise it throws  
           passwordEncoder(NoOpPasswordEncoder.getInstance()); // apparently it needs a password encoder otherwise it throws  
                                                        // java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id
                                                            // java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id
                                                                      
                                                                      
     }
     }
}
}
</syntaxhighlight>
</syntaxhighlight>

Revision as of 03:12, 26 October 2018

Internal

Example

@Configuration
@EnableWebSecurity
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

    private DataSource dataSource;

    public SecurityConfiguration(@Autowired DataSource dataSource) {
        this.dataSource = dataSource;
    }

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.
          jdbcAuthentication().
           dataSource(dataSource).
           passwordEncoder(NoOpPasswordEncoder.getInstance()); // apparently it needs a password encoder otherwise it throws 
                                                            // java.lang.IllegalArgumentException: There is no PasswordEncoder mapped for the id
                                                                     
    }
}