| Total Complexity | 7 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | package unicon.matthews.admin; |
||
| 8 | public class AdminUserAuthenticationToken extends AbstractAuthenticationToken { |
||
|
|
|||
| 9 | |||
| 10 | private static final long serialVersionUID = 1L; |
||
| 11 | private final Object principal; |
||
| 12 | private Object credentials; |
||
| 13 | |||
| 14 | public AdminUserAuthenticationToken(Object principal, Object credentials) { |
||
| 15 | super(null); |
||
| 16 | this.principal = principal; |
||
| 17 | this.credentials = credentials; |
||
| 18 | setAuthenticated(false); |
||
| 19 | } |
||
| 20 | |||
| 21 | public AdminUserAuthenticationToken(Object principal, Object credentials, |
||
| 22 | Collection<? extends GrantedAuthority> authorities) { |
||
| 23 | super(authorities); |
||
| 24 | this.principal = principal; |
||
| 25 | this.credentials = credentials; |
||
| 26 | super.setAuthenticated(true); // must use super, as we override |
||
| 27 | } |
||
| 28 | |||
| 29 | |||
| 30 | @Override |
||
| 31 | public Object getCredentials() { |
||
| 32 | return this.credentials; |
||
| 33 | } |
||
| 34 | |||
| 35 | @Override |
||
| 36 | public Object getPrincipal() { |
||
| 37 | return this.principal; |
||
| 38 | } |
||
| 39 | |||
| 40 | public void setAuthenticated(boolean isAuthenticated) throws IllegalArgumentException { |
||
| 41 | if (isAuthenticated) { |
||
| 42 | throw new IllegalArgumentException( |
||
| 43 | "Cannot set this token to trusted - use constructor which takes a GrantedAuthority list instead"); |
||
| 44 | } |
||
| 45 | |||
| 46 | super.setAuthenticated(false); |
||
| 47 | } |
||
| 48 | |||
| 49 | @Override |
||
| 50 | public void eraseCredentials() { |
||
| 51 | super.eraseCredentials(); |
||
| 52 | credentials = null; |
||
| 53 | } |
||
| 56 |