Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- }`
- `@Override
- protected void configure(HttpSecurity http) throws Exception {
- System.out.println("Http scurity called");
- http.httpBasic().
- and().
- authorizeRequests()
- .antMatchers("/").permitAll()
- .antMatchers("/login").permitAll()
- .antMatchers("/registration").permitAll()
- .antMatchers("/admin/**").hasAuthority("ADMIN")
- .antMatchers("/db").hasAuthority("DBA")
- .antMatchers("/user").hasAuthority("USER").anyRequest()
- .authenticated().and().csrf().disable().formLogin()
- .loginPage("/login").failureUrl("/login?error=true")
- .successHandler(customSuccessHandler)
- .usernameParameter("username")
- .passwordParameter("password")
- .and().logout()
- .logoutRequestMatcher(new AntPathRequestMatcher("/logout"))
- .logoutSuccessUrl("/").and().exceptionHandling()
- .accessDeniedPage("/access-denied");
- }`
- `@RequestMapping(value = { "/", "/login" }, method = RequestMethod.GET)
- public ModelAndView login() {
- System.out.println("/login called");
- ModelAndView modelAndView = new ModelAndView();
- modelAndView.setViewName("login");
- return modelAndView;
- }`
- Authentication auth = SecurityContextHolder.getContext().getAuthentication();
- String currentUser = null;
- if (!(auth instanceof AnonymousAuthenticationToken)) {
- currentUser = auth.getName();
- }
- User user1 = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
- user1.getAuthorities();
- System.out.println("++++++++++++++++++++++++++++++");
- System.out.println(request == null);
- Users u = (Users) request.getSession(false).getAttribute("user");
- Uniconnect uni = (Uniconnect) request.getSession(false).getAttribute("uniconnect");
- UserUniconnect uu = new UserUniconnect();
- uu.setUser(u);
- uu.setUniconnect(uni);
- return uu;
- }`
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement