Advertisement
Guest User

Untitled

a guest
Aug 17th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. public class UserPrincipal implements UserDetails {
  2.  
  3. private final User user;
  4.  
  5. public UserPrincipal(User user) {
  6. this.user = user;
  7. }
  8.  
  9. @Override
  10. public String getUsername() {
  11. return user.getUsername();
  12. }
  13.  
  14. @Override
  15. public String getPassword() {
  16. return user.getPassword();
  17. }
  18.  
  19. @Override
  20. public boolean isAccountNonExpired() {
  21. return true;
  22. }
  23.  
  24. @Override
  25. public boolean isCredentialsNonExpired() {
  26. return true;
  27. }
  28.  
  29. @Override
  30. public boolean isEnabled() {
  31. return true;
  32. }
  33.  
  34. @Override
  35. public boolean isAccountNonLocked() {
  36. return true;
  37. }
  38.  
  39. @Override
  40. public Collection<? extends GrantedAuthority> getAuthorities() {
  41. // TODO
  42. return null;
  43. }
  44. }
  45.  
  46.  
  47.  
  48. // WebSecurityConfig
  49. http.csrf().disable()
  50. .authorizeRequests()
  51. .antMatchers("blog/**")
  52. .authenticated()
  53. .and()
  54. .authorizeRequests()
  55. .anyRequest()
  56. .permitAll()
  57. .and()
  58. .formLogin().loginPage("/user/login").permitAll()
  59. .and()
  60. .logout()
  61. .permitAll();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement