1 24 package javax.jcr; 25 26 import java.io.Serializable ; 27 import java.util.HashMap ; 28 29 35 public final class SimpleCredentials implements Credentials, Serializable { 36 37 private final String userId; 38 private final char[] password; 39 private final HashMap attributes = new HashMap (); 40 41 54 public SimpleCredentials(String userId, char[] password) { 55 this.userId = userId; 56 this.password = (char[]) password.clone(); 57 } 58 59 68 public char[] getPassword() { 69 return password; 70 } 71 72 77 public String getUserId() { 78 return userId; 79 } 80 81 87 public void setAttribute(String name, Object value) { 88 if (name == null) { 90 throw new IllegalArgumentException ("name cannot be null"); 91 } 92 93 if (value == null) { 95 removeAttribute(name); 96 return; 97 } 98 99 synchronized (attributes) { 100 attributes.put(name, value); 101 } 102 } 103 104 112 public Object getAttribute(String name) { 113 synchronized (attributes) { 114 return (attributes.get(name)); 115 } 116 } 117 118 124 public void removeAttribute(String name) { 125 synchronized (attributes) { 126 attributes.remove(name); 127 } 128 } 129 130 140 public String [] getAttributeNames() { 141 synchronized (attributes) { 142 return (String []) attributes.keySet().toArray(new String [attributes.keySet().size()]); 143 } 144 } 145 } 146
| Popular Tags
|