Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/security/jgss/ExtendedGSSContext.java
38924 views
/*1* Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.security.jgss;2627import org.ietf.jgss.*;2829/**30* The extended GSSContext interface for supporting additional31* functionalities not defined by {@code org.ietf.jgss.GSSContext},32* such as querying context-specific attributes.33*/34@jdk.Exported35public interface ExtendedGSSContext extends GSSContext {36/**37* Return the mechanism-specific attribute associated with {@code type}.38* <br><br>39* For each supported attribute type, the type for the output are40* defined below.41* <ol>42* <li>{@code KRB5_GET_TKT_FLAGS}:43* the returned object is a boolean array for the service ticket flags,44* which is long enough to contain all true bits. This means if45* the user wants to get the <em>n</em>'th bit but the length of the46* returned array is less than <em>n</em>, it is regarded as false.47* <li>{@code KRB5_GET_SESSION_KEY}:48* the returned object is an instance of {@link java.security.Key},49* which has the following properties:50* <ul>51* <li>Algorithm: enctype as a string, where52* enctype is defined in RFC 3961, section 8.53* <li>Format: "RAW"54* <li>Encoded form: the raw key bytes, not in any ASN.1 encoding55* </ul>56* <li>{@code KRB5_GET_AUTHZ_DATA}:57* the returned object is an array of58* {@link com.sun.security.jgss.AuthorizationDataEntry}, or null if the59* optional field is missing in the service ticket.60* <li>{@code KRB5_GET_AUTHTIME}:61* the returned object is a String object in the standard KerberosTime62* format defined in RFC 4120 5.2.363* </ol>64*65* If there is a security manager, an {@link InquireSecContextPermission}66* with the name {@code type.mech} must be granted. Otherwise, this could67* result in a {@link SecurityException}.<p>68*69* Example:70* <pre>71* GSSContext ctxt = m.createContext(...)72* // Establishing the context73* if (ctxt instanceof ExtendedGSSContext) {74* ExtendedGSSContext ex = (ExtendedGSSContext)ctxt;75* try {76* Key key = (key)ex.inquireSecContext(77* InquireType.KRB5_GET_SESSION_KEY);78* // read key info79* } catch (GSSException gsse) {80* // deal with exception81* }82* }83* </pre>84* @param type the type of the attribute requested85* @return the attribute, see the method documentation for details.86* @throws GSSException containing the following87* major error codes:88* {@link GSSException#BAD_MECH GSSException.BAD_MECH} if the mechanism89* does not support this method,90* {@link GSSException#UNAVAILABLE GSSException.UNAVAILABLE} if the91* type specified is not supported,92* {@link GSSException#NO_CONTEXT GSSException.NO_CONTEXT} if the93* security context is invalid,94* {@link GSSException#FAILURE GSSException.FAILURE} for other95* unspecified failures.96* @throws SecurityException if a security manager exists and a proper97* {@link InquireSecContextPermission} is not granted.98* @see InquireSecContextPermission99*/100public Object inquireSecContext(InquireType type)101throws GSSException;102103/**104* Requests that the delegation policy be respected. When a true value is105* requested, the underlying context would use the delegation policy106* defined by the environment as a hint to determine whether credentials107* delegation should be performed. This request can only be made on the108* context initiator's side and it has to be done prior to the first109* call to <code>initSecContext</code>.110* <p>111* When this flag is false, delegation will only be tried when the112* {@link GSSContext#requestCredDeleg(boolean) credentials delegation flag}113* is true.114* <p>115* When this flag is true but the116* {@link GSSContext#requestCredDeleg(boolean) credentials delegation flag}117* is false, delegation will be only tried if the delegation policy permits118* delegation.119* <p>120* When both this flag and the121* {@link GSSContext#requestCredDeleg(boolean) credentials delegation flag}122* are true, delegation will be always tried. However, if the delegation123* policy does not permit delegation, the value of124* {@link #getDelegPolicyState} will be false, even125* if delegation is performed successfully.126* <p>127* In any case, if the delegation is not successful, the value returned128* by {@link GSSContext#getCredDelegState()} is false, and the value129* returned by {@link #getDelegPolicyState()} is also false.130* <p>131* Not all mechanisms support delegation policy. Therefore, the132* application should check to see if the request was honored with the133* {@link #getDelegPolicyState() getDelegPolicyState} method. When134* delegation policy is not supported, <code>requestDelegPolicy</code>135* should return silently without throwing an exception.136* <p>137* Note: for the Kerberos 5 mechanism, the delegation policy is expressed138* through the OK-AS-DELEGATE flag in the service ticket. When it's true,139* the KDC permits delegation to the target server. In a cross-realm140* environment, in order for delegation be permitted, all cross-realm TGTs141* on the authentication path must also have the OK-AS-DELAGATE flags set.142* @param state true if the policy should be respected143* @throws GSSException containing the following144* major error codes:145* {@link GSSException#FAILURE GSSException.FAILURE}146*/147public void requestDelegPolicy(boolean state) throws GSSException;148149/**150* Returns the delegation policy response. Called after a security context151* is established. This method can be only called on the initiator's side.152* See {@link ExtendedGSSContext#requestDelegPolicy}.153* @return the delegation policy response154*/155public boolean getDelegPolicyState();156}157158159