Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- `create database universityapp DEFAULT CHARACTER SET utf8
- DEFAULT COLLATE utf8_general_ci;`
- FilterRegistration.Dynamic filterEncoding = container.addFilter("characterEncodingFilter", CharacterEncodingFilter.class);
- filterEncoding.setInitParameter("encoding", "UTF-8");
- filterEncoding.setInitParameter("forceEncoding", "true");
- filterEncoding.addMappingForServletNames(null, true, "dispatcher");
- jdbc.url = jdbc:mysql://localhost:3306/app?useUnicode=yes&characterEncoding=UTF-8
- <Connector port="8080" protocol="HTTP/1.1"
- connectionTimeout="20000"
- redirectPort="8443"
- URIEncoding="UTF-8"/>
- <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" URIEncoding="UTF-8" />
- @Configuration
- @Autowired
- @Qualifier("customUserDetailsService")
- UserDetailsService userDetailsService;
- @Bean
- public PasswordEncoder passwordEncoder(){
- return new BCryptPasswordEncoder(11);
- }
- @Bean
- public DaoAuthenticationProvider authenticationProvider() {
- DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider();
- authenticationProvider.setUserDetailsService(userDetailsService);
- authenticationProvider.setPasswordEncoder(passwordEncoder());
- return authenticationProvider;
- }
- @Autowired
- public void configureGlobalSecurity(AuthenticationManagerBuilder auth) throws Exception {
- auth.userDetailsService(userDetailsService);
- auth.authenticationProvider(authenticationProvider());
- }
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- http.authorizeRequests()
- .antMatchers("/", "/students", "/subjects").permitAll()
- .antMatchers("/student/**").hasAnyRole("USER", "ADMIN")
- .and().formLogin().loginPage("/login")
- .usernameParameter("username").passwordParameter("password")
- .and().csrf()
- .and().exceptionHandling().accessDeniedPage("/AccessDenied");
- }
Add Comment
Please, Sign In to add comment