001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: /**
019: * @author Aleksei Y. Semenov
020: * @version $Revision$
021: */package java.security;
022:
023: import java.util.Enumeration;
024:
025: /**
026: * @com.intel.drl.spec_ref
027: * @deprecated
028: */
029: @Deprecated
030: public abstract class IdentityScope extends Identity {
031:
032: /**
033: * @com.intel.drl.spec_ref
034: */
035: private static final long serialVersionUID = -2337346281189773310L;
036:
037: // systemScope holds reference to the current system scope
038: private static IdentityScope systemScope;
039:
040: /**
041: * @com.intel.drl.spec_ref
042: */
043: protected IdentityScope() {
044: super ();
045: }
046:
047: /**
048: * @com.intel.drl.spec_ref
049: */
050: public IdentityScope(String name) {
051: super (name);
052: }
053:
054: /**
055: * @com.intel.drl.spec_ref
056: */
057: public IdentityScope(String name, IdentityScope scope)
058: throws KeyManagementException {
059: super (name, scope);
060: }
061:
062: /**
063: * @com.intel.drl.spec_ref
064: */
065: public static IdentityScope getSystemScope() {
066: /*
067: * Test shows that the implementation class name is read from security property
068: * "system.scope", and the class is only loaded from boot classpath. No default
069: * implementation as fallback, i.e., return null if fails to init an instance.
070: */
071: if (systemScope == null) {
072: String className = AccessController
073: .doPrivileged(new PrivilegedAction<String>() {
074: public String run() {
075: return Security.getProperty("system.scope"); //$NON-NLS-1$
076: }
077: });
078: if (className != null) {
079: try {
080: systemScope = (IdentityScope) Class.forName(
081: className).newInstance();
082: } catch (Exception e) {
083: e.printStackTrace();
084: }
085: }
086: }
087: return systemScope;
088: }
089:
090: /**
091: * @com.intel.drl.spec_ref
092: */
093: protected static void setSystemScope(IdentityScope scope) {
094: SecurityManager sm = System.getSecurityManager();
095: if (sm != null) {
096: sm.checkSecurityAccess("setSystemScope"); //$NON-NLS-1$
097: }
098: systemScope = scope;
099: }
100:
101: /**
102: * @com.intel.drl.spec_ref
103: */
104: public abstract int size();
105:
106: /**
107: * @com.intel.drl.spec_ref
108: */
109: public abstract Identity getIdentity(String name);
110:
111: /**
112: * @com.intel.drl.spec_ref
113: */
114: public Identity getIdentity(Principal principal) {
115: return getIdentity(principal.getName());
116: }
117:
118: /**
119: * @com.intel.drl.spec_ref
120: */
121: public abstract Identity getIdentity(PublicKey key);
122:
123: /**
124: * @com.intel.drl.spec_ref
125: */
126: public abstract void addIdentity(Identity identity)
127: throws KeyManagementException;
128:
129: /**
130: * @com.intel.drl.spec_ref
131: */
132: public abstract void removeIdentity(Identity identity)
133: throws KeyManagementException;
134:
135: /**
136: * @com.intel.drl.spec_ref
137: */
138: public abstract Enumeration<Identity> identities();
139:
140: /**
141: * @com.intel.drl.spec_ref
142: */
143: public String toString() {
144: return new StringBuffer(super .toString())
145: .append("[").append(size()).append("]").toString(); //$NON-NLS-1$ //$NON-NLS-2$
146: }
147: }
|