src/java.base/share/classes/java/security/IdentityScope.java
author jboes
Fri, 20 Sep 2019 11:07:52 +0100
changeset 58242 94bb65cb37d3
parent 57950 4612a3cfb927
child 58679 9c3209ff7550
permissions -rw-r--r--
8230648: Replace @exception tag with @throws in java.base Summary: Minor coding style update of javadoc tag in any file in java.base Reviewed-by: prappo, lancea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
57950
4612a3cfb927 8229999: Apply java.io.Serial annotations to security types in java.base
darcy
parents: 48080
diff changeset
     2
 * Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4983
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4983
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4983
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4983
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4983
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.security;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.Serializable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.Enumeration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.Properties;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * <p>This class represents a scope for identities. It is an Identity
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * itself, and therefore has a name and can have a scope. It can also
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * optionally have a public key and associated certificates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * <p>An IdentityScope can contain Identity objects of all kinds, including
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * Signers. All types of Identity objects can be retrieved, added, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * removed using the same methods. Note that it is possible, and in fact
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * expected, that different types of identity scopes will
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * apply different policies for their various operations on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * various types of Identities.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * <p>There is a one-to-one mapping between keys and identities, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * there can only be one copy of one key per scope. For example, suppose
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * <b>Acme Software, Inc</b> is a software publisher known to a user.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * Suppose it is an Identity, that is, it has a public key, and a set of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * associated certificates. It is named in the scope using the name
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * "Acme Software". No other named Identity in the scope has the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * public  key. Of course, none has the same name as well.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * @see Identity
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * @see Signer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * @see Principal
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * @see Key
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * @author Benjamin Renaud
45434
4582657c7260 8181082: class-level since tag issues in java.base & java.datatransfer module
mli
parents: 43541
diff changeset
    58
 * @since 1.1
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *
47742
28096878fae5 8175091: Mark the deprecated java.security.{Certificate,Identity,IdentityScope,Signer} APIs with forRemoval=true
mullan
parents: 47216
diff changeset
    60
 * @deprecated This class is deprecated and subject to removal in a future
28096878fae5 8175091: Mark the deprecated java.security.{Certificate,Identity,IdentityScope,Signer} APIs with forRemoval=true
mullan
parents: 47216
diff changeset
    61
 *     version of Java SE. It has been replaced by
28096878fae5 8175091: Mark the deprecated java.security.{Certificate,Identity,IdentityScope,Signer} APIs with forRemoval=true
mullan
parents: 47216
diff changeset
    62
 *     {@code java.security.KeyStore}, the {@code java.security.cert} package,
28096878fae5 8175091: Mark the deprecated java.security.{Certificate,Identity,IdentityScope,Signer} APIs with forRemoval=true
mullan
parents: 47216
diff changeset
    63
 *     and {@code java.security.Principal}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 */
47742
28096878fae5 8175091: Mark the deprecated java.security.{Certificate,Identity,IdentityScope,Signer} APIs with forRemoval=true
mullan
parents: 47216
diff changeset
    65
@Deprecated(since="1.2", forRemoval=true)
28096878fae5 8175091: Mark the deprecated java.security.{Certificate,Identity,IdentityScope,Signer} APIs with forRemoval=true
mullan
parents: 47216
diff changeset
    66
@SuppressWarnings("removal")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
public abstract
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
class IdentityScope extends Identity {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
57950
4612a3cfb927 8229999: Apply java.io.Serial annotations to security types in java.base
darcy
parents: 48080
diff changeset
    70
    @java.io.Serial
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    private static final long serialVersionUID = -2337346281189773310L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    /* The system's scope */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    private static IdentityScope scope;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    // initialize the system scope
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    private static void initializeSystemScope() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
        String classname = AccessController.doPrivileged(
30033
b9c86c17164a 8078468: Update security libraries to use diamond with anonymous classes
darcy
parents: 25859
diff changeset
    80
                                new PrivilegedAction<>() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
            public String run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                return Security.getProperty("system.scope");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        if (classname == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
                Class.forName(classname);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            } catch (ClassNotFoundException e) {
48080
18a4438eb690 8185855: Debug exception stacks should be clearer
coffeys
parents: 47742
diff changeset
    94
                System.err.println("unable to establish a system scope from " +
18a4438eb690 8185855: Debug exception stacks should be clearer
coffeys
parents: 47742
diff changeset
    95
                             classname);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                e.printStackTrace();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * This constructor is used for serialization only and should not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * be used by subclasses.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    protected IdentityScope() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        this("restoring...");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * Constructs a new identity scope with the specified name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @param name the scope name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    public IdentityScope(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        super(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * Constructs a new identity scope with the specified name and scope.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * @param name the scope name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * @param scope the scope for the new identity scope.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     *
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 57950
diff changeset
   124
     * @throws    KeyManagementException if there is already an identity
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * with the same name in the scope.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    public IdentityScope(String name, IdentityScope scope)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    throws KeyManagementException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        super(name, scope);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * Returns the system's identity scope.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     *
4983
91e752cf5bb1 6921001: api/java_security/IdentityScope/IdentityScopeTests.html#getSystemScope fails starting from b78 JDK7
vinnie
parents: 2
diff changeset
   135
     * @return the system's identity scope, or {@code null} if none has been
91e752cf5bb1 6921001: api/java_security/IdentityScope/IdentityScopeTests.html#getSystemScope fails starting from b78 JDK7
vinnie
parents: 2
diff changeset
   136
     *         set.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * @see #setSystemScope
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    public static IdentityScope getSystemScope() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        if (scope == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            initializeSystemScope();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        return scope;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * Sets the system's identity scope.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * <p>First, if there is a security manager, its
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 7668
diff changeset
   152
     * {@code checkSecurityAccess}
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 7668
diff changeset
   153
     * method is called with {@code "setSystemScope"}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * as its argument to see if it's ok to set the identity scope.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * @param scope the scope to set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     *
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 57950
diff changeset
   158
     * @throws     SecurityException  if a security manager exists and its
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 7668
diff changeset
   159
     * {@code checkSecurityAccess} method doesn't allow
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * setting the identity scope.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * @see #getSystemScope
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * @see SecurityManager#checkSecurityAccess
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    protected static void setSystemScope(IdentityScope scope) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        check("setSystemScope");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        IdentityScope.scope = scope;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * Returns the number of identities within this identity scope.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * @return the number of identities within this identity scope.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    public abstract int size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * Returns the identity in this scope with the specified name (if any).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * @param name the name of the identity to be retrieved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     *
18579
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 7668
diff changeset
   182
     * @return the identity named {@code name}, or null if there are
b678846778ad 8019360: Cleanup of the javadoc <code> tag in java.security.*
juh
parents: 7668
diff changeset
   183
     * no identities named {@code name} in this scope.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    public abstract Identity getIdentity(String name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * Retrieves the identity whose name is the same as that of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * specified principal. (Note: Identity implements Principal.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @param principal the principal corresponding to the identity
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * to be retrieved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * @return the identity whose name is the same as that of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * principal, or null if there are no identities of the same name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * in this scope.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    public Identity getIdentity(Principal principal) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        return getIdentity(principal.getName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * Retrieves the identity with the specified public key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * @param key the public key for the identity to be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * @return the identity with the given key, or null if there are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * no identities in this scope with that key.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    public abstract Identity getIdentity(PublicKey key);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * Adds an identity to this identity scope.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * @param identity the identity to be added.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     *
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 57950
diff changeset
   217
     * @throws    KeyManagementException if the identity is not
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * valid, a name conflict occurs, another identity has the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * public key as the identity being added, or another exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * occurs. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    public abstract void addIdentity(Identity identity)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    throws KeyManagementException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * Removes an identity from this identity scope.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * @param identity the identity to be removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     *
58242
94bb65cb37d3 8230648: Replace @exception tag with @throws in java.base
jboes
parents: 57950
diff changeset
   229
     * @throws    KeyManagementException if the identity is missing,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * or another exception occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    public abstract void removeIdentity(Identity identity)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    throws KeyManagementException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * Returns an enumeration of all identities in this identity scope.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * @return an enumeration of all identities in this identity scope.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    public abstract Enumeration<Identity> identities();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * Returns a string representation of this identity scope, including
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * its name, its scope name, and the number of identities in this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * identity scope.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * @return a string representation of this identity scope.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        return super.toString() + "[" + size() + "]";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    private static void check(String directive) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        SecurityManager security = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        if (security != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            security.checkSecurityAccess(directive);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
}