1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.acegisecurity.userdetails.memory;
17
18 import java.util.List;
19 import java.util.Vector;
20
21 import org.acegisecurity.GrantedAuthority;
22 import org.acegisecurity.GrantedAuthorityImpl;
23
24
25 /***
26 * Used by {@link InMemoryDaoImpl} to temporarily store the attributes
27 * associated with a user.
28 *
29 * @author Ben Alex
30 * @version $Id: UserAttribute.java,v 1.3 2005/11/29 13:10:09 benalex Exp $
31 */
32 public class UserAttribute {
33
34
35 private List authorities = new Vector();
36 private String password;
37 private boolean enabled = true;
38
39
40
41 public UserAttribute() {
42 super();
43 }
44
45
46
47 public GrantedAuthority[] getAuthorities() {
48 GrantedAuthority[] toReturn = {new GrantedAuthorityImpl("demo")};
49
50 return (GrantedAuthority[]) this.authorities.toArray(toReturn);
51 }
52
53 public void setEnabled(boolean enabled) {
54 this.enabled = enabled;
55 }
56
57 public boolean isEnabled() {
58 return enabled;
59 }
60
61 public void setPassword(String password) {
62 this.password = password;
63 }
64
65 public String getPassword() {
66 return password;
67 }
68
69 public boolean isValid() {
70 if ((this.password != null) && (authorities.size() > 0)) {
71 return true;
72 } else {
73 return false;
74 }
75 }
76
77 public void addAuthority(GrantedAuthority newAuthority) {
78 this.authorities.add(newAuthority);
79 }
80 }