1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.acegisecurity.adapters;
17
18 import org.acegisecurity.GrantedAuthority;
19
20 import java.security.Principal;
21
22
23 /***
24 * A {@link Principal} compatible {@link org.acegisecurity.Authentication}
25 * object.
26 *
27 * @author Ben Alex
28 * @version $Id: PrincipalAcegiUserToken.java,v 1.6 2005/11/25 00:26:30 benalex Exp $
29 */
30 public class PrincipalAcegiUserToken extends AbstractAdapterAuthenticationToken
31 implements Principal {
32
33
34 private Object principal;
35 private String password;
36 private String username;
37
38
39
40 public PrincipalAcegiUserToken(String key, String username,
41 String password, GrantedAuthority[] authorities, Object principal) {
42 super(key, authorities);
43 this.username = username;
44 this.password = password;
45 this.principal = principal;
46 }
47
48 protected PrincipalAcegiUserToken() {
49 throw new IllegalArgumentException("Cannot use default constructor");
50 }
51
52
53
54 public Object getCredentials() {
55 return this.password;
56 }
57
58 public String getName() {
59 return this.username;
60 }
61
62 public Object getPrincipal() {
63 if (this.principal == null) {
64 return this.username;
65 }
66
67 return this.principal;
68 }
69 }