1 23 24 25 package com.sun.enterprise.security.auth.realm.file; 26 27 import java.util.*; 28 29 import com.sun.enterprise.deployment.PrincipalImpl; 30 import com.sun.enterprise.security.auth.realm.NoSuchRealmException; 31 import com.sun.enterprise.security.auth.realm.Realm; 32 import com.sun.enterprise.security.auth.realm.User; 33 34 35 40 public class FileRealmUser extends PrincipalImpl implements User 41 { 42 private static final String GROUP_KEY = "Groups"; private String [] groups; 44 private String realm; 45 private Hashtable attributes; 46 47 private byte[] salt; 48 private byte[] hash; 49 50 54 public FileRealmUser(String name) 55 { 56 super(name); 57 attributes = new Hashtable(1); } 59 60 61 71 public FileRealmUser(String name, String [] groups, String realm, 72 byte[] salt, byte[] hash) 73 { 74 super(name); 75 this.groups = groups; 76 this.realm = realm; 77 this.hash = hash; 78 this.salt = salt; 79 80 attributes = new Hashtable(1); attributes.put(GROUP_KEY, groups); 82 } 83 84 85 89 public byte[] getSalt() 90 { 91 return salt; 92 } 93 94 95 99 public void setSalt(byte[] salt) 100 { 101 this.salt = salt; 102 } 103 104 105 109 public byte[] getHash() 110 { 111 return hash; 112 } 113 114 115 119 public void setHash(byte[] hash) 120 { 121 this.hash = hash; 122 } 123 124 125 133 public Realm getRealm() throws NoSuchRealmException 134 { 135 return Realm.getInstance(realm); 136 } 137 138 139 145 public String [] getGroups() 146 { 147 return groups; 148 } 149 150 151 155 public void setGroups(Vector grp) 156 { 157 String [] g = new String [grp.size()]; 158 grp.toArray(g); 159 this.groups = g; 160 attributes.put(GROUP_KEY, groups); 161 } 162 163 164 168 public void setGroups(String [] grp) 169 { 170 this.groups = grp; 171 } 172 173 174 180 public Object getAttribute (String key) 181 { 182 return attributes.get(key); 183 } 184 185 186 190 public Enumeration getAttributeNames () { 191 return attributes.keys(); 192 } 193 194 195 196 } 197 | Popular Tags |