src/jdk.security.jgss/share/classes/com/sun/security/jgss/ExtendedGSSContext.java
author eosterlund
Thu, 07 Nov 2019 10:28:29 +0000
changeset 58961 5d462d4b7a8b
parent 47216 71c04702a3d5
permissions -rw-r--r--
8233073: Make BitMap accessors more memory ordering friendly Reviewed-by: kbarrett, pliden
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3482
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 20742
diff changeset
     2
 * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
3482
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
     4
 *
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
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: 4336
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
3482
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4336
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
3482
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    10
 *
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    15
 * accompanied this code).
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    16
 *
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4336
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4336
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4336
diff changeset
    23
 * questions.
3482
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    24
 */
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    25
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    26
package com.sun.security.jgss;
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    27
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    28
import org.ietf.jgss.*;
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    29
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    30
/**
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    31
 * The extended GSSContext interface for supporting additional
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    32
 * functionalities not defined by {@code org.ietf.jgss.GSSContext},
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    33
 * such as querying context-specific attributes.
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    34
 */
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    35
public interface ExtendedGSSContext extends GSSContext {
26629
3b9ed8175488 8042900: Allow com.sun.security.jgss to be in different module than org.ietf.jgss
weijun
parents: 25859
diff changeset
    36
3482
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    37
    /**
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    38
     * Return the mechanism-specific attribute associated with {@code type}.
25661
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23010
diff changeset
    39
     * <p>
3482
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    40
     * If there is a security manager, an {@link InquireSecContextPermission}
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    41
     * with the name {@code type.mech} must be granted. Otherwise, this could
26629
3b9ed8175488 8042900: Allow com.sun.security.jgss to be in different module than org.ietf.jgss
weijun
parents: 25859
diff changeset
    42
     * result in a {@link SecurityException}.
3b9ed8175488 8042900: Allow com.sun.security.jgss to be in different module than org.ietf.jgss
weijun
parents: 25859
diff changeset
    43
     * <p>
3482
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    44
     * Example:
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    45
     * <pre>
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    46
     *      GSSContext ctxt = m.createContext(...)
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    47
     *      // Establishing the context
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    48
     *      if (ctxt instanceof ExtendedGSSContext) {
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    49
     *          ExtendedGSSContext ex = (ExtendedGSSContext)ctxt;
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    50
     *          try {
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    51
     *              Key key = (key)ex.inquireSecContext(
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    52
     *                      InquireType.KRB5_GET_SESSION_KEY);
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    53
     *              // read key info
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    54
     *          } catch (GSSException gsse) {
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    55
     *              // deal with exception
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    56
     *          }
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    57
     *      }
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    58
     * </pre>
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    59
     * @param type the type of the attribute requested
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    60
     * @return the attribute, see the method documentation for details.
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    61
     * @throws GSSException containing  the following
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    62
     * major error codes:
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    63
     *   {@link GSSException#BAD_MECH GSSException.BAD_MECH} if the mechanism
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    64
     *   does not support this method,
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    65
     *   {@link GSSException#UNAVAILABLE GSSException.UNAVAILABLE} if the
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    66
     *   type specified is not supported,
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    67
     *   {@link GSSException#NO_CONTEXT GSSException.NO_CONTEXT} if the
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    68
     *   security context is invalid,
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    69
     *   {@link GSSException#FAILURE GSSException.FAILURE} for other
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    70
     *   unspecified failures.
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    71
     * @throws SecurityException if a security manager exists and a proper
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    72
     *   {@link InquireSecContextPermission} is not granted.
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    73
     * @see InquireSecContextPermission
25661
929c829a8400 8043071: Expose session key and KRB_CRED through extended GSS-API
weijun
parents: 23010
diff changeset
    74
     * @see InquireType
3482
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    75
     */
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    76
    public Object inquireSecContext(InquireType type)
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
    77
            throws GSSException;
4336
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
    78
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
    79
    /**
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
    80
     * Requests that the delegation policy be respected. When a true value is
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
    81
     * requested, the underlying context would use the delegation policy
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
    82
     * defined by the environment as a hint to determine whether credentials
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
    83
     * delegation should be performed. This request can only be made on the
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
    84
     * context initiator's side and it has to be done prior to the first
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
    85
     * call to <code>initSecContext</code>.
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
    86
     * <p>
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
    87
     * When this flag is false, delegation will only be tried when the
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
    88
     * {@link GSSContext#requestCredDeleg(boolean) credentials delegation flag}
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
    89
     * is true.
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
    90
     * <p>
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
    91
     * When this flag is true but the
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
    92
     * {@link GSSContext#requestCredDeleg(boolean) credentials delegation flag}
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
    93
     * is false, delegation will be only tried if the delegation policy permits
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
    94
     * delegation.
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
    95
     * <p>
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
    96
     * When both this flag and the
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
    97
     * {@link GSSContext#requestCredDeleg(boolean) credentials delegation flag}
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
    98
     * are true, delegation will be always tried. However, if the delegation
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
    99
     * policy does not permit delegation, the value of
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   100
     * {@link #getDelegPolicyState} will be false, even
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   101
     * if delegation is performed successfully.
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   102
     * <p>
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   103
     * In any case, if the delegation is not successful, the value returned
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   104
     * by {@link GSSContext#getCredDelegState()} is false, and the value
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   105
     * returned by {@link #getDelegPolicyState()} is also false.
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   106
     * <p>
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   107
     * Not all mechanisms support delegation policy. Therefore, the
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   108
     * application should check to see if the request was honored with the
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   109
     * {@link #getDelegPolicyState() getDelegPolicyState} method. When
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   110
     * delegation policy is not supported, <code>requestDelegPolicy</code>
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   111
     * should return silently without throwing an exception.
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   112
     * <p>
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   113
     * Note: for the Kerberos 5 mechanism, the delegation policy is expressed
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   114
     * through the OK-AS-DELEGATE flag in the service ticket. When it's true,
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   115
     * the KDC permits delegation to the target server. In a cross-realm
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   116
     * environment, in order for delegation be permitted, all cross-realm TGTs
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   117
     * on the authentication path must also have the OK-AS-DELAGATE flags set.
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   118
     * @param state true if the policy should be respected
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   119
     * @throws GSSException containing the following
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   120
     * major error codes:
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   121
     *   {@link GSSException#FAILURE GSSException.FAILURE}
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   122
     */
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   123
    public void requestDelegPolicy(boolean state) throws GSSException;
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   124
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   125
    /**
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   126
     * Returns the delegation policy response. Called after a security context
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   127
     * is established. This method can be only called on the initiator's side.
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   128
     * See {@link ExtendedGSSContext#requestDelegPolicy}.
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   129
     * @return the delegation policy response
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   130
     */
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 3483
diff changeset
   131
    public boolean getDelegPolicyState();
3482
4aaa66ce712d 6710360: export Kerberos session key to applications
weijun
parents:
diff changeset
   132
}