jdk/src/java.security.jgss/share/classes/sun/security/jgss/JgssExtender.java
changeset 26629 3b9ed8175488
equal deleted inserted replaced
26628:47c021955197 26629:3b9ed8175488
       
     1 /*
       
     2  * Copyright (c) 2014, Oracle and/or its affiliates. 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.  Oracle designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22  * or visit www.oracle.com if you need additional information or have any
       
    23  * questions.
       
    24  */
       
    25 
       
    26 package sun.security.jgss;
       
    27 
       
    28 import org.ietf.jgss.GSSContext;
       
    29 import org.ietf.jgss.GSSCredential;
       
    30 
       
    31 /**
       
    32  * The extending point of basic JGSS-API.
       
    33  * <p>
       
    34  * If a module wants to extend basic JGSS-API classes, it should extends this
       
    35  * class and register itself as "the extender" using the setExtender method.
       
    36  * When various GSSManager.createXXX methods are called, they will call
       
    37  * "the extender"'s wrap methods to create objects of extended types
       
    38  * instead of basic types.
       
    39  * <p>
       
    40  * We have only one extension now defined in com.sun.security.jgss, and the
       
    41  * registering process is triggered in {@link GSSManagerImpl} by calling
       
    42  * Class.forName("com.sun.security.jgss.Extender"). Only GSSContext
       
    43  * and GSSCredential are extended now.
       
    44  * <p>
       
    45  * The setExtender method should be called before any JGSS call.
       
    46  */
       
    47 public class JgssExtender {
       
    48 
       
    49     // "The extender"
       
    50     private static volatile JgssExtender theOne = new JgssExtender();
       
    51 
       
    52     /**
       
    53      * Gets "the extender". GSSManager calls this method so that it can
       
    54      * wrap basic objects into extended objects.
       
    55      * @return the extender
       
    56      */
       
    57     public static JgssExtender getExtender() {
       
    58         return theOne;
       
    59     }
       
    60 
       
    61     /**
       
    62      * Set "the extender" so that GSSManager can create extended objects.
       
    63      */
       
    64     protected static void setExtender(JgssExtender theOne) {
       
    65         JgssExtender.theOne = theOne;
       
    66     }
       
    67 
       
    68     /**
       
    69      * Wraps a plain GSSCredential object into an extended type.
       
    70      */
       
    71     public GSSCredential wrap(GSSCredential cred) {
       
    72         return cred;
       
    73     }
       
    74 
       
    75     /**
       
    76      * Wraps a plain GSSContext object into an extended type.
       
    77      */
       
    78     public GSSContext wrap(GSSContext ctxt) {
       
    79         return ctxt;
       
    80     }
       
    81 }