org.ietf.jgss

Class GSSManager

  • java.lang.Object
    • org.ietf.jgss.GSSManager


  • public abstract class GSSManager
    extends java.lang.Object
    The GSSManager class is an abstract class that serves as a factory for three GSS interfaces: GSSName, GSSCredential, and GSSContext. It also provides methods for applications to determine what mechanisms are available from the GSS implementation and what nametypes these mechanisms support. An instance of the default GSSManager subclass may be obtained through the static method getInstance(), but applications are free to instantiate other subclasses of GSSManager.

    All but one method in this class are declared abstract. This means that subclasses have to provide the complete implementation for those methods. The only exception to this is the static method getInstance() which will have platform specific code to return an instance of the default subclass.

    Platform providers of GSS are required not to add any constructors to this class, private, public, or protected. This will ensure that all subclasses invoke only the default constructor provided to the base class by the compiler.

    A subclass extending the GSSManager abstract class may be implemented as a modular provider based layer that utilizes some well known service provider specification. The GSSManager API provides the application with methods to set provider preferences on such an implementation. These methods also allow the implementation to throw a well-defined exception in case provider based configuration is not supported. Applications that expect to be portable should be aware of this and recover cleanly by catching the exception.

    It is envisioned that there will be three most common ways in which providers will be used:

    1) The application does not care about what provider is used (the default case).

    2) The application wants a particular provider to be used preferentially, either for a particular mechanism or all the time, irrespective of mechanism.

    3) The application wants to use the locally configured providers as far as possible but if support is missing for one or more mechanisms then it wants to fall back on its own provider.

    The GSSManager class has two methods that enable these modes of usage: addProviderAtFront() and addProviderAtEnd(). These methods have the effect of creating an ordered list of pairs where each pair indicates a preference of provider for a given oid.

    The use of these methods does not require any knowledge of whatever service provider specification the GSSManager subclass follows. It is hoped that these methods will serve the needs of most applications. Additional methods may be added to an extended GSSManager that could be part of a service provider specification that is standardized later.

    Based on the IETF RFC-2853. The only supported mechanism is Kerberos V5.

    Version:
    1.1 5/7/07
    • Constructor Summary

      Constructors 
      Constructor and Description
      GSSManager() 
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method and Description
      abstract void addProviderAtEnd(java.security.Provider p, Oid mech)
      This method is used to indicate to the GSSManager that the application would like a particular provider to be used if no other provider can be found that supports the given mechanism.
      abstract void addProviderAtFront(java.security.Provider p, Oid mech)
      This method is used to indicate to the GSSManager that the application would like a particular provider to be used ahead of all others when support is desired for the given mechanism.
      abstract GSSContext createContext(byte[] interProcessToken)
      Factory method for creating a previously exported context.
      abstract GSSContext createContext(GSSCredential cred)
      Factory method for creating a context on the acceptor' side.
      abstract GSSContext createContext(GSSName peer, Oid mech, GSSCredential cred, int lifetime)
      Factory method for creating a context on the initiator's side.
      abstract GSSCredential createCredential(GSSName aName, int lifeTime, Oid[] mechs, int usage)
      Factory method for acquiring credentials over a set of mechanisms.
      abstract GSSCredential createCredential(GSSName aName, int lifeTime, Oid mech, int usage)
      Factory method for acquiring a single mechanism credential.
      abstract GSSCredential createCredential(int usage)
      Factory method for acquiring default credentials.
      abstract GSSName createName(byte[] name, Oid nameType)
      Factory method to convert a contiguous byte array containing a name from the specified namespace to an GSSName object.
      abstract GSSName createName(byte[] name, Oid nameType, Oid mechType)
      Factory method to convert a contiguous byte array containing a name from the specified namespace to an GSSName object that is an MN.
      abstract GSSName createName(java.lang.String nameStr, Oid nameType)
      Factory method to convert a contiguous string name from the specified namespace to an GSSName object.
      abstract GSSName createName(java.lang.String nameStr, Oid nameType, Oid mechType)
      Factory method to convert a contiguous string name from the specified namespace to an GSSName object that is a mechanism name (MN).
      static GSSManager getInstance()
      Returns the default GSSManager implementation.
      abstract Oid[] getMechs()
      Returns an array of Oid objects indicating mechanisms available to GSS-API callers.
      abstract Oid[] getMechsForName(Oid nameType)
      Returns an array of Oid objects corresponding to the mechanisms that support the specific name type.
      abstract Oid[] getNamesForMech(Oid mech)
      Returns name type Oid's supported by the specified mechanism.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GSSManager

        public GSSManager()
    • Method Detail

      • getInstance

        public static GSSManager getInstance()
        Returns the default GSSManager implementation.
        Returns:
        The default GSSManager implementation.
      • getMechs

        public abstract Oid[] getMechs()
        Returns an array of Oid objects indicating mechanisms available to GSS-API callers. A "null" value is returned when no mechanism are available (an example of this would be when mechanism are dynamically configured, and currently no mechanisms are installed).
        Returns:
        A list of supported mechanisms.
      • getNamesForMech

        public abstract Oid[] getNamesForMech(Oid mech)
                                       throws GSSException
        Returns name type Oid's supported by the specified mechanism.
        Parameters:
        mech - The Oid object for the mechanism to query.
        Returns:
        A list of name types supported for the specified mechanism.
        Throws:
        GSSException
      • getMechsForName

        public abstract Oid[] getMechsForName(Oid nameType)
        Returns an array of Oid objects corresponding to the mechanisms that support the specific name type. "null" is returned when no mechanisms are found to support the specified name type.
        Parameters:
        nameType - The Oid object for the name type.
        Returns:
        A list of mechanisms that support the specified name type.
      • createName

        public abstract GSSName createName(java.lang.String nameStr,
                                           Oid nameType)
                                    throws GSSException
        Factory method to convert a contiguous string name from the specified namespace to an GSSName object. In general, the GSSName object created will not be an MN; two examples that are exceptions to this are when the namespace type parameter indicates NT_EXPORT_NAME or when the GSS-API implementation is not multi-mechanism.
        Parameters:
        nameStr - The string representing a printable form of the name to create.
        nameType - The Oid specifying the namespace of the printable name qualify the interpretation of the input nameStr, it does not necessarily imply a type for the output GSSName implementation. "null" value can be used to specify that a mechanism specific default printable syntax should be assumed by each mechanism that examines nameStr.
        Returns:
        A GSSName representing the specified name string and type.
        Throws:
        GSSException
      • createName

        public abstract GSSName createName(byte[] name,
                                           Oid nameType)
                                    throws GSSException
        Factory method to convert a contiguous byte array containing a name from the specified namespace to an GSSName object. In general, the GSSName object created will not be an MN; two examples that are exceptions to this are when the namespace type parameter indicates NT_EXPORT_NAME or when the GSS-API implementation is not multi-mechanism.
        Parameters:
        name - The byte array containing the name to create.
        nameType - The Oid specifying the namespace of the name supplied in the byte array. Note that nameType serves to describe and qualify the interpretation of the input name byte array, it does not necessarily imply a type for the output GSSName implementation. "null" value can be used to specify that a mechanism specific default syntax should be assumed by each mechanism that examines the byte array.
        Returns:
        A GSSName representing the specified name string and type.
        Throws:
        GSSException
      • createName

        public abstract GSSName createName(java.lang.String nameStr,
                                           Oid nameType,
                                           Oid mechType)
                                    throws GSSException
        Factory method to convert a contiguous string name from the specified namespace to an GSSName object that is a mechanism name (MN). In other words, this method is a utility that does the equivalent of two steps: the createName(String, Oid) method and then also the canonicalize method.
        Parameters:
        nameStr - The string representing a printable form of the name to create.
        nameType - The Oid specifying the namespace of the printable name supplied. Note that nameType serves to describe and qualify the interpretation of the input nameStr, it does not necessarily imply a type for the output GSSName implementation. "null" value can be used to specify that a mechanism specific default printable syntax should be assumed when the mechanism examines nameStr.
        mechType - Oid specifying the mechanism for which this name should be created.
        Returns:
        A GSSName representing the given name string, name type and mechanism.
        Throws:
        GSSException
      • createName

        public abstract GSSName createName(byte[] name,
                                           Oid nameType,
                                           Oid mechType)
                                    throws GSSException
        Factory method to convert a contiguous byte array containing a name from the specified namespace to an GSSName object that is an MN. In other words, this method is a utility that does the equivalent of two steps: the createName(byte[], Oid) method followed by the canonicalize method.
        Parameters:
        name - The byte array representing the name to create.
        nameType - The Oid specifying the namespace of the name supplied in the byte array. Note that nameType serves to describe and qualify the interpretation of the input name byte array, it does not necessarily imply a type for the output GSSName implementation. "null" value can be used to specify that a mechanism specific default syntax should be assumed by each mechanism that examines the byte array.
        mechType - Oid specifying the mechanism for which this name should be created.
        Returns:
        A GSSName representing the given name, name type and mechanism.
        Throws:
        GSSException
      • createCredential

        public abstract GSSCredential createCredential(int usage)
                                                throws GSSException
        Factory method for acquiring default credentials. This will cause the GSS-API to use system specific defaults for the set of mechanisms, name, and an INDEFINITE_LIFETIME.
        Parameters:
        usage - The intended usage for this credential object. The value of this parameter must be one of: GSSCredential.ACCEPT_AND_INITIATE, GSSCredential.ACCEPT_ONLY, GSSCredential.INITIATE_ONLY
        Returns:
        A GSSCredential for the specified usage.
        Throws:
        GSSException
      • createCredential

        public abstract GSSCredential createCredential(GSSName aName,
                                                       int lifeTime,
                                                       Oid mech,
                                                       int usage)
                                                throws GSSException
        Factory method for acquiring a single mechanism credential.
        Parameters:
        aName - Name of the principal for whom this credential is to be acquired. Use "null" to specify the default principal.
        lifetime - The number of seconds that credentials should remain valid. Use GSSCredential.INDEFINITE_LIFETIME to request that the credentials have the maximum permitted lifetime.
        mechOid - The oid of the desired mechanism. Use "(Oid) null" to request the default mechanism(s).
        usage - The intended usage for this credential object. The value of this parameter must be one of: GSSCredential.ACCEPT_AND_INITIATE, GSSCredential.ACCEPT_ONLY, GSSCredential.INITIATE_ONLY
        Returns:
        A GSSCredential for the specified parameters.
        Throws:
        GSSException
      • createCredential

        public abstract GSSCredential createCredential(GSSName aName,
                                                       int lifeTime,
                                                       Oid[] mechs,
                                                       int usage)
                                                throws GSSException
        Factory method for acquiring credentials over a set of mechanisms. Acquires credentials for each of the mechanisms specified in the array called mechs. To determine the list of mechanisms' for which the acquisition of credentials succeeded, the caller should use the getMechs method.
        Parameters:
        aName - Name of the principal for whom this credential is to be acquired. Use "null" to specify the default principal.
        lifetime - The number of seconds that credentials should remain valid. Use GSSCredential.INDEFINITE_LIFETIME to request that the credentials have the maximum permitted lifetime.
        mechOid - The array of mechanisms over which the credential is to be acquired. Use "(Oid[]) null" for requesting a system specific default set of mechanisms.
        usage - The intended usage for this credential object. The value of this parameter must be one of: GSSCredential.ACCEPT_AND_INITIATE, GSSCredential.ACCEPT_ONLY, GSSCredential.INITIATE_ONLY
        Returns:
        A GSSCredential for the specified parameters.
        Throws:
        GSSException
      • createContext

        public abstract GSSContext createContext(GSSName peer,
                                                 Oid mech,
                                                 GSSCredential cred,
                                                 int lifetime)
                                          throws GSSException
        Factory method for creating a context on the initiator's side. Context flags may be modified through the mutator methods prior to calling GSSContext.initSecContext().
        Parameters:
        peer - Name of the target peer.
        mechOid - Oid of the desired mechanism. Use "(Oid) null" to request default mechanism.
        myCred - Credentials of the initiator. Use "null" to act as a default initiator principal.
        lifetime - The request lifetime, in seconds, for the credential.
        Returns:
        A GSSContext for the specified parameters.
        Throws:
        GSSException
      • createContext

        public abstract GSSContext createContext(GSSCredential cred)
                                          throws GSSException
        Factory method for creating a context on the acceptor' side. The context's properties will be determined from the input token supplied to the accept method.
        Parameters:
        myCred - Credentials of the acceptor. Use "null" to act as a default acceptor principal.
        Returns:
        A GSSContext for the specified parameters.
        Throws:
        GSSException
      • createContext

        public abstract GSSContext createContext(byte[] interProcessToken)
                                          throws GSSException
        Factory method for creating a previously exported context. The context properties will be determined from the input token and can't be modified through the set methods.
        Parameters:
        interProcessToken - The token previously emitted from the export method.
        Returns:
        A imported GSSContext.
        Throws:
        GSSException
      • addProviderAtFront

        public abstract void addProviderAtFront(java.security.Provider p,
                                                Oid mech)
                                         throws GSSException
        This method is used to indicate to the GSSManager that the application would like a particular provider to be used ahead of all others when support is desired for the given mechanism. When a value of null is used instead of an Oid for the mechanism, the GSSManager must use the indicated provider ahead of all others no matter what the mechanism is. Only when the indicated provider does not support the needed mechanism should the GSSManager move on to a different provider.

        Calling this method repeatedly preserves the older settings but lowers them in preference thus forming an ordered list of provider and Oid pairs that grows at the top.

        Calling addProviderAtFront with a null Oid will remove all previous preferences that were set for this provider in the GSSManager instance. Calling addProviderAtFront with a non-null Oid will remove any previous preference that was set using this mechanism and this provider together.

        If the GSSManager implementation does not support an SPI with a pluggable provider architecture it should throw a GSSException with the status code GSSException.UNAVAILABLE to indicate that the operation is unavailable.

        Here are some examples:

        Suppose an application desired that the provider A always be checked first when any mechanism is needed, it would call:

             GSSManager mgr = GSSManager.getInstance();
             // mgr may at this point have its own pre-configured list
             // of provider preferences. The following will prepend to
             // any such list:
        
             mgr.addProviderAtFront(A, null);
         
        Now if it also desired that the mechanism of Oid m1 always be obtained from the provider B before the previously set A was checked, it would call:
             mgr.addProviderAtFront(B, m1);
         
        The GSSManager would then first check with B if m1 was needed. In case B did not provide support for m1, the GSSManager would continue on to check with A. If any mechanism m2 is needed where m2 is different from m1 then the GSSManager would skip B and check with A directly.

        Suppose at a later time the following call is made to the same GSSManager instance:

             mgr.addProviderAtFront(B, null)
         
        then the previous setting with the pair (B, m1) is subsumed by this and should be removed. Effectively the list of preferences now becomes {(B, null), (A, null), ... //followed by the pre-configured list.

        Please note, however, that the following call:

             mgr.addProviderAtFront(A, m3)
         
        does not subsume the previous setting of (A, null) and the list will effectively become {(A, m3), (B, null), (A, null), ...}
        Parameters:
        p - The provider instance that should be used whenever support is needed for mech.
        mech - The mechanism for which the provider is being set
        Throws:
        GSSException
      • addProviderAtEnd

        public abstract void addProviderAtEnd(java.security.Provider p,
                                              Oid mech)
                                       throws GSSException
        This method is used to indicate to the GSSManager that the application would like a particular provider to be used if no other provider can be found that supports the given mechanism. When a value of null is used instead of an Oid for the mechanism, the GSSManager must use the indicated provider for any mechanism.

        Calling this method repeatedly preserves the older settings but raises them above newer ones in preference thus forming an ordered list of providers and Oid pairs that grows at the bottom. Thus the older provider settings will be utilized first before this one is.

        If there are any previously existing preferences that conflict with the preference being set here, then the GSSManager should ignore this request.

        If the GSSManager implementation does not support an SPI with a pluggable provider architecture it should throw a GSSException with the status code GSSException.UNAVAILABLE to indicate that the operation is unavailable.

        Example Code

        Suppose an application desired that when a mechanism of Oid m1 is needed the system default providers always be checked first, and only when they do not support m1 should a provider A be checked. It would then make the call:

                 GSSManager mgr = GSSManager.getInstance();
        
                 mgr.addProviderAtEnd(A, m1);
         
        Now, if it also desired that for all mechanisms the provider B be checked after all configured providers have been checked, it would then call:
                 mgr.addProviderAtEnd(B, null);
         
        Effectively the list of preferences now becomes {..., (A, m1), (B, null)}.

        Suppose at a later time the following call is made to the same GSSManager instance:

                 mgr.addProviderAtEnd(B, m2)
         
        then the previous setting with the pair (B, null) subsumes this and therefore this request should be ignored. The same would happen if a request is made for the already existing pairs of (A, m1) or (B, null).

        Please note, however, that the following call:

                 mgr.addProviderAtEnd(A, null)
         
        is not subsumed by the previous setting of (A, m1) and the list will effectively become {..., (A, m1), (B, null), (A, null)}
        Parameters:
        p - The provider instance that should be used whenever support is needed for mech.
        mech - The mechanism for which the provider is being set
        Throws:
        GSSException

© Portions Copyright 2003, 2015 IBM Corporation. All rights reserved.
© Portions Copyright 2003, 2015, Oracle and/or its affiliates. All rights reserved.