jdk/src/share/classes/org/ietf/jgss/GSSCredential.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2000-2006 Sun Microsystems, Inc.  All Rights Reserved.
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * This interface encapsulates the GSS-API credentials for an entity.  A
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * credential contains all the necessary cryptographic information to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * enable the creation of a context on behalf of the entity that it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * represents.  It may contain multiple, distinct, mechanism specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * credential elements, each containing information for a specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * security mechanism, but all referring to the same entity. A credential
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * may be used to perform context initiation, acceptance, or both.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * Credentials are instantiated using one of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * <code>createCredential</code> methods in the {@link GSSManager
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * GSSManager} class. GSS-API credential creation is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * intended to provide a "login to the network" function, as such a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * function would involve the creation of new credentials rather than
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * merely acquiring a handle to existing credentials. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * <a href=package-summary.html#useSubjectCredsOnly>section on credential
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * acquisition</a> in the package level description describes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * how existing credentials are acquired in the Java platform. GSS-API
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * implementations must impose a local access-control policy on callers to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * prevent unauthorized callers from acquiring credentials to which they
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * are not entitled. <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * Applications will create a credential object passing the desired
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * parameters.  The application can then use the query methods to obtain
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * specific information about the instantiated credential object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * When the credential is no longer needed, the application should call
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * the {@link #dispose() dispose} method to release any resources held by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * the credential object and to destroy any cryptographically sensitive
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * information.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * This example code demonstrates the creation of a GSSCredential
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 * implementation for a specific entity, querying of its fields, and its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * release when it is no longer needed:<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *    GSSManager manager = GSSManager.getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *    // start by creating a name object for the entity
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *    GSSName name = manager.createName("myusername", GSSName.NT_USER_NAME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *    // now acquire credentials for the entity
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *    GSSCredential cred = manager.createCredential(name,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 *                    GSSCredential.ACCEPT_ONLY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 *    // display credential information - name, remaining lifetime,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 *    // and the mechanisms it has been acquired over
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 *    System.out.println(cred.getName().toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 *    System.out.println(cred.getRemainingLifetime());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *    Oid [] mechs = cred.getMechs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 *    if (mechs != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 *            for (int i = 0; i < mechs.length; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 *                    System.out.println(mechs[i].toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 *    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 *    // release system resources held by the credential
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 *    cred.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * @see GSSManager#createCredential(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * @see GSSManager#createCredential(GSSName, int, Oid, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * @see GSSManager#createCredential(GSSName, int, Oid[], int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * @see #dispose()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * @author Mayank Upadhyay
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
public interface GSSCredential extends Cloneable{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * Credential usage flag requesting that it be usable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * for both context initiation and acceptance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    public static final int INITIATE_AND_ACCEPT = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * Credential usage flag requesting that it be usable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * for context initiation only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    public static final int INITIATE_ONLY = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * Credential usage flag requesting that it be usable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * for context acceptance only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    public static final int ACCEPT_ONLY = 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * A lifetime constant representing the default credential lifetime. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * value it set to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    public static final int DEFAULT_LIFETIME = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     * A lifetime constant representing indefinite credential lifetime.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * This value must is set to the maximum integer value in Java -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * {@link java.lang.Integer#MAX_VALUE Integer.MAX_VALUE}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    public static final int INDEFINITE_LIFETIME = Integer.MAX_VALUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * Releases any sensitive information that the GSSCredential object may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * be containing.  Applications should call this method as soon as the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * credential is no longer needed to minimize the time any sensitive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * information is maintained.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     *         {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    public void dispose() throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     *  Retrieves the name of the entity that the credential asserts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * @return a GSSName representing the entity
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     *         {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    public GSSName getName() throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * Retrieves a Mechanism Name of the entity that the credential
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * asserts. This is equivalent to calling {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * GSSName#canonicalize(Oid) canonicalize} on the value returned by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * the other form of {@link #getName() getName}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     * @param mech the Oid of the mechanism for which the Mechanism Name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * should be returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
     * @return a GSSName representing the entity canonicalized for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * desired mechanism
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     *         {@link GSSException#BAD_MECH GSSException.BAD_MECH},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     *         {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    public GSSName getName(Oid mech) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * Returns the remaining lifetime in seconds for a credential.  The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * remaining lifetime is the minimum lifetime amongst all of the underlying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * mechanism specific credential elements.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * @return the minimum remaining lifetime in seconds for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     * credential. A return value of {@link #INDEFINITE_LIFETIME
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
     * INDEFINITE_LIFETIME} indicates that the credential does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
     * not expire. A return value of 0 indicates that the credential is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * already expired.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * @see #getRemainingInitLifetime(Oid)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * @see #getRemainingAcceptLifetime(Oid)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     *         {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    public int getRemainingLifetime() throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * Returns the lifetime in seconds for the credential to remain capable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * of initiating security contexts using the specified mechanism. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     * method queries the initiator credential element that belongs to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * specified mechanism.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * @return the number of seconds remaining in the life of this credential
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * element. A return value of {@link #INDEFINITE_LIFETIME
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * INDEFINITE_LIFETIME} indicates that the credential element does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * expire.  A return value of 0 indicates that the credential element is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * already expired.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * @param mech the Oid of the mechanism whose intiator credential element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * should be queried.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     *         {@link GSSException#BAD_MECH GSSException.BAD_MECH},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     *         {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    public int getRemainingInitLifetime(Oid mech) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * Returns the lifetime in seconds for the credential to remain capable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * of accepting security contexts using the specified mechanism. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * method queries the acceptor credential element that belongs to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * specified mechanism.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * @return the number of seconds remaining in the life of this credential
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * element. A return value of {@link #INDEFINITE_LIFETIME
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * INDEFINITE_LIFETIME} indicates that the credential element does not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * expire.  A return value of 0 indicates that the credential element is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * already expired.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * @param mech the Oid of the mechanism whose acceptor credential element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * should be queried.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     *         {@link GSSException#BAD_MECH GSSException.BAD_MECH},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     *         {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    public int getRemainingAcceptLifetime(Oid mech) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * Returns the credential usage mode. In other words, it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * tells us if this credential can be used for initiating or accepting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * security contexts. It does not tell us which mechanism(s) has to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * used in order to do so. It is expected that an application will allow
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * the GSS-API to pick a default mechanism after calling this method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * @return The return value will be one of {@link #INITIATE_ONLY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * INITIATE_ONLY}, {@link #ACCEPT_ONLY ACCEPT_ONLY}, and {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * #INITIATE_AND_ACCEPT INITIATE_AND_ACCEPT}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     *         {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    public int getUsage() throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * Returns the credential usage mode for a specific mechanism. In other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * words, it tells us if this credential can be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * for initiating or accepting security contexts with a given underlying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * mechanism.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * @return The return value will be one of {@link #INITIATE_ONLY
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * INITIATE_ONLY}, {@link #ACCEPT_ONLY ACCEPT_ONLY}, and {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * #INITIATE_AND_ACCEPT INITIATE_AND_ACCEPT}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     * @param mech the Oid of the mechanism whose credentials usage mode is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * to be determined.
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_MECH GSSException.BAD_MECH},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     *         {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    public int getUsage(Oid mech) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * Returns a list of mechanisms supported by this credential. It does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * not tell us which ones can be used to initiate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * contexts and which ones can be used to accept contexts. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     * application must call the {@link #getUsage(Oid) getUsage} method with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * each of the returned Oid's to determine the possible modes of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * usage.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * @return an array of Oid's corresponding to the supported mechanisms.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     *         {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    public Oid[] getMechs() throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * Adds a mechanism specific credential-element to an existing
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * credential.  This method allows the construction of credentials, one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * mechanism at a time.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * This routine is envisioned to be used mainly by context acceptors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * during the creation of acceptor credentials which are to be used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * with a variety of clients using different security mechanisms.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * This routine adds the new credential element "in-place".  To add the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * element in a new credential, first call <code>clone</code> to obtain a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * copy of this credential, then call its <code>add</code> method.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * As always, GSS-API implementations must impose a local access-control
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * policy on callers to prevent unauthorized callers from acquiring
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     * credentials to which they are not entitled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * Non-default values for initLifetime and acceptLifetime cannot always
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * be honored by the underlying mechanisms, thus callers should be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * prepared to call {@link #getRemainingInitLifetime(Oid)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * getRemainingInitLifetime} and {@link #getRemainingAcceptLifetime(Oid)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * getRemainingAcceptLifetime} on the credential.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * @param name the name of the principal for whom this credential is to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * be acquired.  Use <code>null</code> to specify the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * principal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * @param initLifetime the number of seconds that the credential element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     * should remain valid for initiating of security contexts. Use {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * GSSCredential#INDEFINITE_LIFETIME GSSCredential.INDEFINITE_LIFETIME}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
     * to request that the credentials have the maximum permitted lifetime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * for this.  Use {@link GSSCredential#DEFAULT_LIFETIME
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     * GSSCredential.DEFAULT_LIFETIME} to request default credential lifetime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     * for this.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * @param acceptLifetime the number of seconds that the credential
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * element should remain valid for accepting security contexts. Use {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * GSSCredential#INDEFINITE_LIFETIME GSSCredential.INDEFINITE_LIFETIME}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     * to request that the credentials have the maximum permitted lifetime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     * for this.  Use {@link GSSCredential#DEFAULT_LIFETIME
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     * GSSCredential.DEFAULT_LIFETIME} to request default credential lifetime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     * for this.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * @param mech the mechanism over which the credential is to be acquired.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     * @param usage the usage mode that this credential
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     * element should add to the credential. The value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     * of this parameter must be one of:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * {@link #INITIATE_AND_ACCEPT INITIATE_AND_ACCEPT},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * {@link #ACCEPT_ONLY ACCEPT_ONLY}, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     * {@link #INITIATE_ONLY INITIATE_ONLY}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     *         {@link GSSException#DUPLICATE_ELEMENT
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     *                          GSSException.DUPLICATE_ELEMENT},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     *         {@link GSSException#BAD_MECH GSSException.BAD_MECH},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     *         {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     *         {@link GSSException#NO_CRED GSSException.NO_CRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     *         {@link GSSException#CREDENTIALS_EXPIRED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     *                                  GSSException.CREDENTIALS_EXPIRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     *         {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    public void add(GSSName name, int initLifetime, int acceptLifetime,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                    Oid mech, int usage) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * Tests if this GSSCredential asserts the same entity as the supplied
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     * object.  The two credentials must be acquired over the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     * mechanisms and must refer to the same principal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * @return <code>true</code> if the two GSSCredentials assert the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     * entity; <code>false</code> otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * @param another another GSSCredential for comparison to this one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    public boolean equals(Object another);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * Returns a hashcode value for this GSSCredential.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
     * @return a hashCode value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    public int hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
}