1 7 8 package java.security; 9 10 import java.io.Serializable ; 11 import java.util.Enumeration ; 12 import java.util.Properties ; 13 14 47 @Deprecated 48 public abstract 49 class IdentityScope extends Identity { 50 51 private static final long serialVersionUID = -2337346281189773310L; 52 53 54 private static IdentityScope scope; 55 56 private static void initializeSystemScope() { 58 59 String classname = (String ) AccessController.doPrivileged( 60 new PrivilegedAction () { 61 public Object run() { 62 return Security.getProperty("system.scope"); 63 } 64 }); 65 66 if (classname == null) { 67 return; 68 69 } else { 70 71 try { 72 Class.forName(classname); 73 } catch (ClassNotFoundException e) { 74 e.printStackTrace(); 77 } 78 } 79 } 80 81 85 protected IdentityScope() { 86 this("restoring..."); 87 } 88 89 94 public IdentityScope(String name) { 95 super(name); 96 } 97 98 107 public IdentityScope(String name, IdentityScope scope) 108 throws KeyManagementException { 109 super(name, scope); 110 } 111 112 119 public static IdentityScope getSystemScope() { 120 if (scope == null) { 121 initializeSystemScope(); 122 } 123 return scope; 124 } 125 126 127 144 protected static void setSystemScope(IdentityScope scope) { 145 check("setSystemScope"); 146 IdentityScope.scope = scope; 147 } 148 149 154 public abstract int size(); 155 156 164 public abstract Identity getIdentity(String name); 165 166 177 public Identity getIdentity(Principal principal) { 178 return getIdentity(principal.getName()); 179 } 180 181 189 public abstract Identity getIdentity(PublicKey key); 190 191 200 public abstract void addIdentity(Identity identity) 201 throws KeyManagementException ; 202 203 211 public abstract void removeIdentity(Identity identity) 212 throws KeyManagementException ; 213 214 219 public abstract Enumeration <Identity > identities(); 220 221 228 public String toString() { 229 return super.toString() + "[" + size() + "]"; 230 } 231 232 private static void check(String directive) { 233 SecurityManager security = System.getSecurityManager(); 234 if (security != null) { 235 security.checkSecurityAccess(directive); 236 } 237 } 238 239 } 240 | Popular Tags |