FSF GCC merge 02/23/03
[official-gcc.git] / libjava / java / security / IdentityScope.java
blob8df5b938b62c74a785a0d60dfaa22e4fc6ec35a9
1 /* IdentityScope.java --- IdentityScope Class
2 Copyright (C) 1999 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
38 package java.security;
39 import java.util.Enumeration;
41 /**
42 IdentityScope represents a scope of an identity. IdentityScope
43 is also an Identity and can have a name and scope along with
44 the other qualitites identities posses.
46 An IdentityScope contains other Identity objects. All Identity
47 objects are manipulated in the scope the same way. The scope
48 is suppose to apply different scope to different type of
49 Identities.
51 No identity within the same scope can have the same public key.
53 @since JDK 1.1
55 @deprecated Use java.security.KeyStore, the java.security.cert
56 package, and java.security.Principal.
58 @author Mark Benvenuto
60 public abstract class IdentityScope extends Identity
62 private static IdentityScope systemScope = null;
64 /**
65 Creates a new instance of IdentityScope from Serialized Data
67 protected IdentityScope()
69 super();
72 /**
73 Creates a new instance of IdentityScope with the specified name
74 and no scope.
76 @param name the name to use
78 public IdentityScope(String name)
80 super(name);
83 /**
84 Creates a new instance of IdentityScope with the specified name
85 and IdentityScope.
87 @param name the name to use
88 @param scope the scope to use
90 @throws KeyManagementException if the identity scope is already
91 present
93 public IdentityScope(String name, IdentityScope scope)
94 throws KeyManagementException
96 super(name, scope);
99 /**
100 Gets the system's Scope.
102 public static IdentityScope getSystemScope()
104 if (systemScope == null)
106 //Load it
107 //systemScope;
109 return systemScope;
113 Sets the scope of the system.
115 This class checks the security manager with the call
116 checkSecurityAccess with "setSystemScope".
118 @param scope the new sustem scope
120 @throws SecurityException - if the security manager denies
121 access to "setSystemScope"
123 protected static void setSystemScope(IdentityScope scope)
125 SecurityManager sm = System.getSecurityManager();
126 if (sm != null)
127 sm.checkSecurityAccess("setSystemScope");
129 systemScope = scope;
133 Gets the number of entries within this IdentityScope.
135 @returns the number of entries
137 public abstract int size();
140 Gets the specified Identity within this scope
141 by specified name.
143 @param name name of Identity to get
145 @returns an identity representing the name or null if it
146 cannot be found
148 public abstract Identity getIdentity(String name);
151 Gets the specified Identity within this scope
152 by the specified Principal.
154 @param principal The Principal of the Identity to get
156 @returns an identity representing the principal or null if it
157 cannot be found
159 public Identity getIdentity(Principal principal)
161 return getIdentity(principal.getName());
165 Gets the specified Identity within this scope
166 by the specified public key.
168 @param key the PublicKey of the Identity to get
170 @returns an identity representing the public key or null if it
171 cannot be found
173 public abstract Identity getIdentity(PublicKey key);
176 Adds an identity to his scope.
178 @param identity the identity to add
180 @throws KeyManagementException if it is an invalid identity,
181 an identity with the same key exists, or another error
182 occurs.
184 public abstract void addIdentity(Identity identity)
185 throws KeyManagementException;
188 Removes an identity to his scope.
190 @param identity the identity to remove
192 @throws KeyManagementException if it is a missing identity,
193 or another error occurs.
195 public abstract void removeIdentity(Identity identity)
196 throws KeyManagementException;
199 Returns an Enumeration of identities.
201 @returns an enumeration of the identities.
203 public abstract Enumeration identities();
206 Returns a string representing this IdentityScope.
207 It includes the name, the scope name, and number of identities.
209 @returns a string representing this IdentityScope.
211 public String toString()
213 return (super.getName() + " " + super.getScope().getName()
214 + " " + size());