src/java.security.jgss/share/classes/org/ietf/jgss/GSSManager.java
author weijun
Thu, 04 Jul 2019 07:25:47 +0800
changeset 55599 e6c430d4d217
parent 47216 71c04702a3d5
permissions -rw-r--r--
8226963: More clarification on possible sequencing error in GSSContext::unwrap Reviewed-by: mullan
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 25859
diff changeset
     2
 * Copyright (c) 2000, 2015, 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: 2
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: 2
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: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
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 org.ietf.jgss;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.security.Provider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * This class serves as a factory for other important
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * GSS-API classes and also provides information about the mechanisms that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * are supported. It can create instances of classes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * implementing the following three GSS-API interfaces: {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * GSSName GSSName}, {@link GSSCredential GSSCredential}, and {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * GSSContext GSSContext}. It also has methods to query for the list
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * of available mechanisms and the nametypes that each mechanism
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * supports.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * An instance of the default <code>GSSManager</code> subclass
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * may be obtained through the static method {@link #getInstance()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * getInstance}, but applications are free to instantiate other subclasses
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * of <code>GSSManager</code>. The default <code>GSSManager</code> instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * will support the Kerberos v5 GSS-API mechanism in addition to any
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * others. This mechanism is identified by the Oid "1.2.840.113554.1.2.2"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * and is defined in RFC 1964.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * A subclass extending the <code>GSSManager</code> abstract class may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * implemented  as a modular provider based layer that utilizes some well
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * known  service provider specification. The <code>GSSManager</code> API
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * allows the application to set provider preferences on
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * such an implementation. These methods also allow the implementation to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * throw a well-defined exception in case provider based configuration is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * not supported. Applications that expect to be portable should be aware
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * of this and recover cleanly by catching the exception.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * It is envisioned that there will be three most common ways in which
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 25859
diff changeset
    58
 * providers will be used:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * <ol>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * <li> The application does not care about what provider is used (the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * default case).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * <li> The application wants a particular provider to be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * preferentially, either for a particular mechanism or all the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * time, irrespective of mechanism.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * <li> The application wants to use the locally configured providers
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * as far as possible but if support is missing for one or more
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * mechanisms then it wants to fall back on its own provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *</ol><p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * The <code>GSSManager</code> class has two methods that enable these modes of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * usage:  {@link #addProviderAtFront(Provider, Oid) addProviderAtFront} and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * {@link #addProviderAtEnd(Provider, Oid) addProviderAtEnd}. These methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * have the effect of creating an ordered list of <i>&lt;provider,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * oid&gt;</i> pairs  where each pair indicates a preference of provider
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * for a given oid.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * It is important to note that there are certain interactions
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * between the different GSS-API objects that are created by a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * GSSManager, where the provider that is used for a particular mechanism
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * might need to be consistent across all objects. For instance, if a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * GSSCredential contains elements from a provider <i>p</i> for a mechanism
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * <i>m</i>, it should generally be passed in to a GSSContext that will use
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * provider <i>p</i> for the mechanism <i>m</i>. A simple rule of thumb
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * that will maximize portability is that objects created from different
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * GSSManager's should not be mixed, and if possible, a different
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * GSSManager instance should be created if the application wants to invoke
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * the <code>addProviderAtFront</code> method on a GSSManager that has
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * already created an object.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 *
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 25859
diff changeset
    90
 *  Here is some sample code showing how the GSSManager might be used:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 *     GSSManager manager = GSSManager.getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 *     Oid krb5Mechanism = new Oid("1.2.840.113554.1.2.2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 *     Oid krb5PrincipalNameType = new Oid("1.2.840.113554.1.2.2.1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 *     // Identify who the client wishes to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 *     GSSName userName = manager.createName("duke", GSSName.NT_USER_NAME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 *     // Identify the name of the server. This uses a Kerberos specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 *     // name format.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 *     GSSName serverName = manager.createName("nfs/foo.sun.com",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 *                                             krb5PrincipalNameType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 *     // Acquire credentials for the user
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 *     GSSCredential userCreds = manager.createCredential(userName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 *                                             GSSCredential.DEFAULT_LIFETIME,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 *                                             krb5Mechanism,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 *                                             GSSCredential.INITIATE_ONLY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 *     // Instantiate and initialize a security context that will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 *     // established with the server
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 *     GSSContext context = manager.createContext(serverName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
 *                                                krb5Mechanism,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 *                                                userCreds,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 *                                                GSSContext.DEFAULT_LIFETIME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 * </pre><p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 *
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 25859
diff changeset
   119
 * The server side might use the following variation of this source:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 *     // Acquire credentials for the server
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 *     GSSCredential serverCreds = manager.createCredential(serverName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 *                                             GSSCredential.DEFAULT_LIFETIME,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 *                                             krb5Mechanism,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
 *                                             GSSCredential.ACCEPT_ONLY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 *     // Instantiate and initialize a security context that will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 *     // wait for an establishment request token from the client
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 *     GSSContext context = manager.createContext(serverCreds);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 * @author Mayank Upadhyay
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 * @see GSSName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 * @see GSSCredential
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
 * @see GSSContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
 * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
public abstract class GSSManager {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * Returns the default GSSManager implementation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * @return a GSSManager implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    public static GSSManager getInstance() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        return new sun.security.jgss.GSSManagerImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * Returns a list of mechanisms that are available to GSS-API callers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     * through this GSSManager. The default GSSManager obtained from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     * {@link #getInstance() getInstance()} method includes the Oid
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
     * "1.2.840.113554.1.2.2" in its list. This Oid identifies the Kerberos
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
     * v5 GSS-API mechanism that is defined in RFC 1964.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * @return an array of Oid objects corresponding to the mechanisms that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * are available. A <code>null</code> value is returned when no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * mechanism are available (an example of this would be when mechanism
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * are dynamically configured, and currently no mechanisms are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * installed).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    public  abstract Oid[] getMechs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * Returns then name types supported by the indicated mechanism.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * The default GSSManager instance includes support for the Kerberos v5
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * mechanism. When this mechanism ("1.2.840.113554.1.2.2") is indicated,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * the returned list will contain at least the following nametypes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * {@link GSSName#NT_HOSTBASED_SERVICE GSSName.NT_HOSTBASED_SERVICE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * {@link GSSName#NT_EXPORT_NAME GSSName.NT_EXPORT_NAME}, and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * Kerberos v5 specific Oid "1.2.840.113554.1.2.2.1". The namespace for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     * the Oid "1.2.840.113554.1.2.2.1" is defined in RFC 1964.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * @return an array of Oid objects corresponding to the name types that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * the mechanism supports.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * @param mech the Oid of the mechanism to query
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * @see #getMechsForName(Oid)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     *    {@link GSSException#BAD_MECH GSSException.BAD_MECH}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     *    {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    public abstract  Oid[] getNamesForMech(Oid mech)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * Returns a list of mechanisms that support the indicated name type.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * The Kerberos v5 mechanism ("1.2.840.113554.1.2.2") will always be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * returned in this list when the indicated nametype is one of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * {@link GSSName#NT_HOSTBASED_SERVICE GSSName.NT_HOSTBASED_SERVICE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * {@link GSSName#NT_EXPORT_NAME GSSName.NT_EXPORT_NAME}, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * "1.2.840.113554.1.2.2.1".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * @return an array of Oid objects corresponding to the mechanisms that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * support the specified name type.  <code>null</code> is returned when no
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * mechanisms are found to support the specified name type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * @param nameType the Oid of the name type to look for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * @see #getNamesForMech(Oid)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    public abstract  Oid[] getMechsForName(Oid nameType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * Factory method to convert a string name from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * specified namespace to a GSSName object. In general, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * <code>GSSName</code> object created  will contain multiple
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * representations of the name, one for each mechanism that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * supported; two examples that are exceptions to this are when
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * the namespace type parameter indicates NT_EXPORT_NAME or when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * GSS-API implementation is not multi-mechanism. It is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * not recommended to use this method with a NT_EXPORT_NAME type because
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 5506
diff changeset
   217
     * representing a previously exported name consisting of arbitrary bytes
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * as a String might cause problems with character encoding schemes. In
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * such cases it is recommended that the bytes be passed in directly to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * the overloaded form of this method {@link #createName(byte[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * Oid) createName}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * @param nameStr the string representing a printable form of the name to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * create.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * @param nameType the Oid specifying the namespace of the printable name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * supplied. <code>null</code> can be used to specify
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * that a mechanism specific default printable syntax should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * be assumed by each mechanism that examines nameStr.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * It is not advisable to use the nametype NT_EXPORT_NAME with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * @return a GSSName representing the indicated principal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * @see GSSName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * @see GSSName#NT_EXPORT_NAME
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     *    {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     *    {@link GSSException#BAD_NAME GSSException.BAD_NAME},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     *    {@link GSSException#BAD_MECH GSSException.BAD_MECH},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     *    {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    public abstract GSSName createName(String nameStr, Oid nameType)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * Factory method to convert a byte array containing a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * name from the specified namespace to a GSSName object. In general,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * the <code>GSSName</code> object created  will contain multiple
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * representations of the name, one for each mechanism that is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * supported; two examples that are exceptions to this are when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * namespace type parameter indicates NT_EXPORT_NAME or when the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * GSS-API implementation is not multi-mechanism. The bytes that are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * passed in are interpreted by each underlying mechanism according to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * some encoding scheme of its choice for the given nametype.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * @param name the byte array containing the name to create
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * @param nameType the Oid specifying the namespace of the name supplied
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * in the byte array. <code>null</code> can be used to specify that a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     * mechanism specific default syntax should be assumed by each mechanism
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * that examines the byte array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * @return a GSSName representing the indicated principal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * @see GSSName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * @see GSSName#NT_EXPORT_NAME
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     *    {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     *    {@link GSSException#BAD_NAME GSSException.BAD_NAME},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     *    {@link GSSException#BAD_MECH GSSException.BAD_MECH},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     *    {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    public abstract GSSName createName(byte name[], Oid nameType)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     *  Factory method to convert a string name from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * specified namespace to a GSSName object and canonicalize it at the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * same time for a mechanism. In other words, this method is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * a utility that does the equivalent of two steps: the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * #createName(String, Oid) createName} and then also the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * GSSName#canonicalize(Oid) GSSName.canonicalize}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * @param nameStr the string representing a printable form of the name to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * create.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * @param nameType the Oid specifying the namespace of the printable name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * supplied. <code>null</code> can be used to specify
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * that a mechanism specific default printable syntax should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * be assumed by each mechanism that examines nameStr.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * It is not advisable to use the nametype NT_EXPORT_NAME with this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * @param mech Oid specifying the mechanism for which the name should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * canonicalized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * @return a GSSName representing the indicated principal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * @see GSSName#canonicalize(Oid)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * @see GSSName#NT_EXPORT_NAME
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     *    {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     *    {@link GSSException#BAD_NAME GSSException.BAD_NAME},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     *    {@link GSSException#BAD_MECH GSSException.BAD_MECH},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     *    {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    public abstract GSSName createName(String nameStr, Oid nameType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
                                       Oid mech) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     *  Factory method to convert a byte array containing a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * name from the specified namespace to a GSSName object and canonicalize
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * it at the same time for a mechanism. In other words, this method is a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * utility that does the equivalent of two steps: the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * #createName(byte[], Oid) createName} and then also {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * GSSName#canonicalize(Oid) GSSName.canonicalize}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * @param name the byte array containing the name to create
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * @param nameType the Oid specifying the namespace of the name supplied
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * in the byte array. <code>null</code> can be used to specify that a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * mechanism specific default syntax should be assumed by each mechanism
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * that examines the byte array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * @param mech Oid specifying the mechanism for which the name should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * canonicalized
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * @return a GSSName representing the indicated principal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * @see GSSName#canonicalize(Oid)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * @see GSSName#NT_EXPORT_NAME
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     *    {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     *    {@link GSSException#BAD_NAME GSSException.BAD_NAME},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     *    {@link GSSException#BAD_MECH GSSException.BAD_MECH},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     *    {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    public abstract GSSName createName(byte name[], Oid nameType, Oid mech)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * Factory method for acquiring default credentials.  This will cause
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * the GSS-API to use system specific defaults for the set of mechanisms,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * name, and lifetime.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * GSS-API mechanism providers must impose a local access-control
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * policy on callers to prevent unauthorized callers from acquiring
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * credentials to which they are not entitled. The kinds of permissions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * needed by different mechanism providers will be documented on a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     * per-mechanism basis. A failed permission check might cause a {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     * java.lang.SecurityException SecurityException} to be thrown from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * @param usage The intended usage for this credential object. The value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * of this parameter must be one of:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * {@link GSSCredential#INITIATE_AND_ACCEPT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * GSSCredential.INITIATE_AND_ACCEPT},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * {@link GSSCredential#ACCEPT_ONLY GSSCredential.ACCEPT_ONLY}, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * {@link GSSCredential#INITIATE_ONLY GSSCredential.INITIATE_ONLY}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * @return a GSSCredential of the requested type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     * @see GSSCredential
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     *    {@link GSSException#BAD_MECH GSSException.BAD_MECH},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     *    {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     *    {@link GSSException#BAD_NAME GSSException.BAD_NAME},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     *    {@link GSSException#CREDENTIALS_EXPIRED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     *                                   GSSException.CREDENTIALS_EXPIRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     *    {@link GSSException#NO_CRED GSSException.NO_CRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     *    {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    public abstract GSSCredential createCredential (int usage)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * Factory method for acquiring a single mechanism credential.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     * GSS-API mechanism providers must impose a local access-control
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * policy on callers to prevent unauthorized callers from acquiring
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * credentials to which they are not entitled. The kinds of permissions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     * needed by different mechanism providers will be documented on a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     * per-mechanism basis. A failed permission check might cause a {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * java.lang.SecurityException SecurityException} to be thrown from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     * this method. <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * Non-default values for lifetime cannot always be honored by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * underlying mechanisms, thus applications should be prepared to call
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * {@link GSSCredential#getRemainingLifetime() getRemainingLifetime}
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 25859
diff changeset
   390
     * on the returned credential.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
     * @param name the name of the principal for whom this credential is to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * acquired.  Use <code>null</code> to specify the default principal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     * @param lifetime The number of seconds that credentials should remain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     * valid.  Use {@link GSSCredential#INDEFINITE_LIFETIME
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     * GSSCredential.INDEFINITE_LIFETIME} to request that the credentials
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * have the maximum permitted lifetime.  Use {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * GSSCredential#DEFAULT_LIFETIME GSSCredential.DEFAULT_LIFETIME} to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * request default credential lifetime.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     * @param mech the Oid of the desired mechanism.  Use <code>(Oid) null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     * </code> to request the default mechanism.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     * @param usage The intended usage for this credential object. The value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * of this parameter must be one of:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * {@link GSSCredential#INITIATE_AND_ACCEPT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * GSSCredential.INITIATE_AND_ACCEPT},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * {@link GSSCredential#ACCEPT_ONLY GSSCredential.ACCEPT_ONLY}, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * {@link GSSCredential#INITIATE_ONLY GSSCredential.INITIATE_ONLY}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * @return a GSSCredential of the requested type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     * @see GSSCredential
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     *    {@link GSSException#BAD_MECH GSSException.BAD_MECH},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     *    {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     *    {@link GSSException#BAD_NAME GSSException.BAD_NAME},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     *    {@link GSSException#CREDENTIALS_EXPIRED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     *                                   GSSException.CREDENTIALS_EXPIRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     *    {@link GSSException#NO_CRED GSSException.NO_CRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     *    {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    public abstract GSSCredential createCredential (GSSName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
                                  int lifetime, Oid mech, int usage)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     * Factory method for acquiring credentials over a set of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     * mechanisms. This method attempts to acquire credentials for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     * each of the mechanisms specified in the array called mechs.  To
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
     * determine the list of mechanisms for which the acquisition of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
     * credentials succeeded, the caller should use the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
     * GSSCredential#getMechs() GSSCredential.getMechs} method.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * GSS-API mechanism providers must impose a local access-control
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * policy on callers to prevent unauthorized callers from acquiring
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * credentials to which they are not entitled. The kinds of permissions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * needed by different mechanism providers will be documented on a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * per-mechanism basis. A failed permission check might cause a {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * java.lang.SecurityException SecurityException} to be thrown from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * this method.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * Non-default values for lifetime cannot always be honored by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * underlying mechanisms, thus applications should be prepared to call
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * {@link GSSCredential#getRemainingLifetime() getRemainingLifetime}
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 25859
diff changeset
   445
     * on the returned credential.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * @param name the name of the principal for whom this credential is to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * be acquired.  Use <code>null</code> to specify the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     * principal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * @param lifetime The number of seconds that credentials should remain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * valid.  Use {@link GSSCredential#INDEFINITE_LIFETIME
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * GSSCredential.INDEFINITE_LIFETIME} to request that the credentials
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * have the maximum permitted lifetime.  Use {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * GSSCredential#DEFAULT_LIFETIME GSSCredential.DEFAULT_LIFETIME} to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * request default credential lifetime.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * @param mechs an array of Oid's indicating the mechanisms over which
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * the credential is to be acquired.  Use <code>(Oid[]) null</code> for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * requesting a system specific default set of mechanisms.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * @param usage The intended usage for this credential object. The value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * of this parameter must be one of:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * {@link GSSCredential#INITIATE_AND_ACCEPT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     * GSSCredential.INITIATE_AND_ACCEPT},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * {@link GSSCredential#ACCEPT_ONLY GSSCredential.ACCEPT_ONLY}, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * {@link GSSCredential#INITIATE_ONLY GSSCredential.INITIATE_ONLY}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * @return a GSSCredential of the requested type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     * @see GSSCredential
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     *    {@link GSSException#BAD_MECH GSSException.BAD_MECH},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     *    {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     *    {@link GSSException#BAD_NAME GSSException.BAD_NAME},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     *    {@link GSSException#CREDENTIALS_EXPIRED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     *                                   GSSException.CREDENTIALS_EXPIRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     *    {@link GSSException#NO_CRED GSSException.NO_CRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     *    {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    public abstract GSSCredential createCredential(GSSName name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
                                      int lifetime, Oid mechs[], int usage)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
        throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * Factory method for creating a context on the initiator's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * side.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * Some mechanism providers might require that the caller be granted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * permission to initiate a security context. A failed permission check
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * might cause a {@link java.lang.SecurityException SecurityException}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * to be thrown from this method.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     * Non-default values for lifetime cannot always be honored by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * underlying mechanism, thus applications should be prepared to call
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * {@link GSSContext#getLifetime() getLifetime} on the returned
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 25859
diff changeset
   495
     * context.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     * @param peer the name of the target peer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     * @param mech the Oid of the desired mechanism.  Use <code>null</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     * to request the default mechanism.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     * @param myCred the credentials of the initiator.  Use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * <code>null</code> to act as the default initiator principal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * @param lifetime the lifetime, in seconds, requested for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * context. Use {@link GSSContext#INDEFINITE_LIFETIME
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * GSSContext.INDEFINITE_LIFETIME} to request that the context have the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * maximum permitted lifetime. Use {@link GSSContext#DEFAULT_LIFETIME
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * GSSContext.DEFAULT_LIFETIME} to request a default lifetime for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     * @return an unestablished GSSContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * @see GSSContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     *    {@link GSSException#NO_CRED GSSException.NO_CRED}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     *    {@link GSSException#CREDENTIALS_EXPIRED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     *                      GSSException.CREDENTIALS_EXPIRED}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     *    {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     *    {@link GSSException#BAD_MECH GSSException.BAD_MECH}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     *    {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    public abstract GSSContext createContext(GSSName peer, Oid mech,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
                                        GSSCredential myCred, int lifetime)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
   /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    * Factory method for creating a context on the acceptor' side.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    * context's properties will be determined from the input token supplied
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    * to the accept method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    * Some mechanism providers might require that the caller be granted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    * permission to accept a security context. A failed permission check
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    * might cause a {@link java.lang.SecurityException SecurityException}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    * to be thrown from this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    * @param myCred the credentials for the acceptor.  Use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    * <code>null</code> to act as a default acceptor principal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    * @return an unestablished GSSContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    * @see GSSContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    *    {@link GSSException#NO_CRED GSSException.NO_CRED}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    *    {@link GSSException#CREDENTIALS_EXPIRED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    *                        GSSException.CREDENTIALS_EXPIRED}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    *    {@link GSSException#BAD_MECH GSSException.BAD_MECH}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
    *    {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
    public abstract GSSContext createContext(GSSCredential myCred)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * Factory method for creating a previously exported context.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * context properties will be determined from the input token and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * cannot be modified through the set methods.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * Implementations are not required to support the inter-process
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     * transfer of security contexts.  Before exporting a context, calling
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     * the {@link GSSContext#isTransferable() GSSContext.isTransferable}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     * will indicate if the context is transferable. Calling this method in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     * an implementation that does not support it will result in a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     * <code>GSSException</code> with the error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     * code {@link GSSException#UNAVAILABLE GSSException.UNAVAILABLE}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * Some mechanism providers might require that the caller be granted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     * permission to initiate or accept a security context. A failed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     * permission check might cause a {@link java.lang.SecurityException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * SecurityException} to be thrown from this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     * @param interProcessToken the token previously emitted from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * export method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     * @return the previously established GSSContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     * @see GSSContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
     *    {@link GSSException#NO_CONTEXT GSSException.NO_CONTEXT},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
     *    {@link GSSException#DEFECTIVE_TOKEN GSSException.DEFECTIVE_TOKEN},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     *    {@link GSSException#UNAVAILABLE GSSException.UNAVAILABLE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     *    {@link GSSException#UNAUTHORIZED GSSException.UNAUTHORIZED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     *    {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
    public abstract GSSContext createContext(byte [] interProcessToken)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     * This method is used to indicate to the GSSManager that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * application would like a particular provider to be used ahead of all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     * others when support is desired for the given mechanism. When a value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
     * of null is used instead of an <code>Oid</code> for the mechanism,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     * the GSSManager must use the indicated provider ahead of all others
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * no matter what the mechanism is. Only when the indicated provider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     * does not support the needed mechanism should the GSSManager move on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * to a different provider.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     * Calling this method repeatedly preserves the older settings but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * lowers them in preference thus forming an ordered list of provider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * and <code>Oid</code> pairs that grows at the top.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * Calling addProviderAtFront with a null <code>Oid</code> will remove
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     * all previous preferences that were set for this provider in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     * GSSManager instance. Calling addProviderAtFront with a non-null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     * <code>Oid</code> will remove any previous preference that was set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     * using this mechanism and this provider together.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     * If the GSSManager implementation does not support an SPI with a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     * pluggable provider architecture it should throw a GSSException with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     * the status code GSSException.UNAVAILABLE to indicate that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     * operation is unavailable.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     * Suppose an application desired that the provider A always be checked
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 25859
diff changeset
   613
     * first when any mechanism is needed, it would call:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     *         GSSManager mgr = GSSManager.getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     *         // mgr may at this point have its own pre-configured list
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
     *         // of provider preferences. The following will prepend to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
     *         // any such list:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     *         mgr.addProviderAtFront(A, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     * Now if it also desired that the mechanism of Oid m1 always be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     * obtained from the provider B before the previously set A was checked,
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 25859
diff changeset
   624
     * it would call:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     *         mgr.addProviderAtFront(B, m1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     * The GSSManager would then first check with B if m1 was needed. In
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     * case B did not provide support for m1, the GSSManager would continue
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * on to check with A.  If any mechanism m2 is needed where m2 is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     * different from m1 then the GSSManager would skip B and check with A
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     * directly.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * Suppose at a later time the following call is made to the same
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 25859
diff changeset
   635
     * GSSManager instance:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     *         mgr.addProviderAtFront(B, null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     * then the previous setting with the pair (B, m1) is subsumed by this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     * and should be removed. Effectively the list of preferences now
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     * becomes {(B, null), (A, null),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     *         ... //followed by the pre-configured list.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     * Please note, however, that the following call:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     *         mgr.addProviderAtFront(A, m3)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
     * does not subsume the previous setting of (A, null) and the list will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     * effectively become {(A, m3), (B, null), (A, null), ...}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     * @param p the provider instance that should be used whenever support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
     * is needed for mech.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
     * @param mech the mechanism for which the provider is being set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     *    {@link GSSException#UNAVAILABLE GSSException.UNAVAILABLE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     *    {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    public abstract void addProviderAtFront(Provider p, Oid mech)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
     * This method is used to indicate to the GSSManager that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
     * application would like a particular provider to be used if no other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
     * provider can be found that supports the given mechanism. When a value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
     * of null is used instead of an Oid for the mechanism, the GSSManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
     * must use the indicated provider for any mechanism.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
     * Calling this method repeatedly preserves the older settings but
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
     * raises them above newer ones in preference thus forming an ordered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
     * list of providers and Oid pairs that grows at the bottom. Thus the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     * older provider settings will be utilized first before this one is.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     * If there are any previously existing preferences that conflict with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     * the preference being set here, then the GSSManager should ignore this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     * request.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     * If the GSSManager implementation does not support an SPI with a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     * pluggable provider architecture it should throw a GSSException with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     * the status code GSSException.UNAVAILABLE to indicate that the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     * operation is unavailable.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
     * Suppose an application desired that when a mechanism of Oid m1 is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     * needed the system default providers always be checked first, and only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     * when they do not support m1 should a provider A be checked. It would
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 25859
diff changeset
   687
     * then make the call:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     *         GSSManager mgr = GSSManager.getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     *         mgr.addProviderAtEnd(A, m1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     * Now, if it also desired that for all mechanisms the provider B be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
     * checked after all configured providers have been checked, it would
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 25859
diff changeset
   694
     * then call:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
     *         mgr.addProviderAtEnd(B, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     * Effectively the list of preferences now becomes {..., (A, m1), (B,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     * null)}.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     * Suppose at a later time the following call is made to the same
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 25859
diff changeset
   702
     * GSSManager instance:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
     *         mgr.addProviderAtEnd(B, m2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
     * then the previous setting with the pair (B, null) subsumes this and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
     * therefore this request should be ignored. The same would happen if a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     * request is made for the already existing pairs of (A, m1) or (B,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     * null).<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     *
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 25859
diff changeset
   711
     * Please note, however, that the following call:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
     *         mgr.addProviderAtEnd(A, null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
     * is not subsumed by the previous setting of (A, m1) and the list will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     * effectively become {..., (A, m1), (B, null), (A, null)}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     * @param p the provider instance that should be used whenever support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     * is needed for mech.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     * @param mech the mechanism for which the provider is being set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     *    {@link GSSException#UNAVAILABLE GSSException.UNAVAILABLE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     *    {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
    public abstract void addProviderAtEnd(Provider p, Oid mech)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
        throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
}