jdk/src/share/classes/com/sun/security/jgss/ExtendedGSSContext.java
changeset 3482 4aaa66ce712d
child 3483 a16fce1820ef
equal deleted inserted replaced
3481:6ae7a2a6c956 3482:4aaa66ce712d
       
     1 /*
       
     2  * Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Sun designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Sun in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    22  * CA 95054 USA or visit www.sun.com if you need additional information or
       
    23  * have any questions.
       
    24  */
       
    25 
       
    26 package com.sun.security.jgss;
       
    27 
       
    28 import org.ietf.jgss.*;
       
    29 
       
    30 /**
       
    31  * The extended GSSContext interface for supporting additional
       
    32  * functionalities not defined by {@code org.ietf.jgss.GSSContext},
       
    33  * such as querying context-specific attributes.
       
    34  */
       
    35 public 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 are
       
    40      * defined below.
       
    41      * <ol>
       
    42      * <li>{@code KRB5_GET_SESSION_KEY}:
       
    43      * the returned object is an instance of {@link java.security.Key},
       
    44      * which has the following properties:
       
    45      *    <ul>
       
    46      *    <li>Algorithm: enctype as a string, where
       
    47      *        enctype is defined in RFC 3961, section 8.
       
    48      *    <li>Format: "RAW"
       
    49      *    <li>Encoded form: the raw key bytes, not in any ASN.1 encoding
       
    50      *    </ul>
       
    51      * </ol>
       
    52      *
       
    53      * If there is a security manager, an {@link InquireSecContextPermission}
       
    54      * with the name {@code type.mech} must be granted. Otherwise, this could
       
    55      * result in a {@link SecurityException}.<p>
       
    56      *
       
    57      * Example:
       
    58      * <pre>
       
    59      *      GSSContext ctxt = m.createContext(...)
       
    60      *      // Establishing the context
       
    61      *      if (ctxt instanceof ExtendedGSSContext) {
       
    62      *          ExtendedGSSContext ex = (ExtendedGSSContext)ctxt;
       
    63      *          try {
       
    64      *              Key key = (key)ex.inquireSecContext(
       
    65      *                      InquireType.KRB5_GET_SESSION_KEY);
       
    66      *              // read key info
       
    67      *          } catch (GSSException gsse) {
       
    68      *              // deal with exception
       
    69      *          }
       
    70      *      }
       
    71      * </pre>
       
    72      * @param type the type of the attribute requested
       
    73      * @return the attribute, see the method documentation for details.
       
    74      * @throws GSSException containing  the following
       
    75      * major error codes:
       
    76      *   {@link GSSException#BAD_MECH GSSException.BAD_MECH} if the mechanism
       
    77      *   does not support this method,
       
    78      *   {@link GSSException#UNAVAILABLE GSSException.UNAVAILABLE} if the
       
    79      *   type specified is not supported,
       
    80      *   {@link GSSException#NO_CONTEXT GSSException.NO_CONTEXT} if the
       
    81      *   security context is invalid,
       
    82      *   {@link GSSException#FAILURE GSSException.FAILURE} for other
       
    83      *   unspecified failures.
       
    84      * @throws SecurityException if a security manager exists and a proper
       
    85      *   {@link InquireSecContextPermission} is not granted.
       
    86      * @see InquireSecContextPermission
       
    87      */
       
    88     public Object inquireSecContext(InquireType type)
       
    89             throws GSSException;
       
    90 }