Class GSSName


  • public class GSSName
    extends java.lang.Object
    An object of this class encapsulates a single GSS-API principal entity. Different name formats and their definitions are identified with universal Object Identifiers (Oids). The format of the names can be derived based on the unique oid of each name type.

    JGSS distinguishes between the following name representations:

    • Internal Form - A name representation which may contain name elements from different mechanisms.
    • Mechanism Name (MN) - A name representation containing one and only one mechanism name element.
    • Flat Name - A contiguous octet stream representation of a MN.
    RFC 2078
    This class implements the following RFC 2078 functions:
    • gss_compare_name
    • gss_display_name
    • gss_import_name
    • gss_release_name
    See Also:
    Oid
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Oid NT_ANONYMOUS
      Name type used to represent an Anonymous identity.
      static Oid NT_EXPORT_NAME
      Name type used to indicate an exported name produced by the export method.
      static Oid NT_HOSTBASED_SERVICE
      Name type used to indicate a host-based service name form.
      static Oid NT_MACHINE_UID_NAME
      Name type used to indicate a numeric user identifier corresponding to a user on a local system.
      static Oid NT_STRING_UID_NAME
      Name type used to indicate a string of digits representing the numeric user identifier of a user on a local system.
      static Oid NT_USER_NAME
      Name type used to indicate a named user on a local system.
    • Constructor Summary

      Constructors 
      Constructor Description
      GSSName​(byte[] name, Oid type)
      Creates a new GSSName object from the specified type.
      GSSName​(byte[] name, Oid nameType, Oid mechType)
      Creates a new GSSName object from the specified type.
      GSSName​(java.lang.String nameStr, Oid type)
      Converts a contiguous string name to a GSSName object of the specified type.
      GSSName​(java.lang.String nameStr, Oid nameType, Oid mechType)
      Creates a new GSSName object of the specified type.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      GSSName canonicalize​(Oid mechOid)
      Creates a new name which is guaranteed to be mechanism specific (MN).
      java.lang.Object clone()
      Creates a duplicate of this object.
      boolean equals​(GSSName another)
      A variation of equals method which may throw a GSSException when the names cannot be compared.
      boolean equals​(java.lang.Object another)
      Compares this name with the specified GSSName for equality.
      byte[] export()
      Returns a flat name representation for this GSSName object.
      Oid getStringNameType()
      Returns the name type for the printed name.
      boolean isAnonymousName()
      Tests if this is an Anonymous name object.
      java.lang.String toString()
      Returns a string representation of the GSSName object.
      • Methods inherited from class java.lang.Object

        finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • NT_HOSTBASED_SERVICE

        public static final Oid NT_HOSTBASED_SERVICE
        Name type used to indicate a host-based service name form. It is used to represent services associated with host computers. This name form is constructed using two elements, "service" and "hostname", as follows: service@hostname
        Values for the "service" element are registered with the IANA. It represents the following value:

        { 1(iso), 3(org), 6(dod), 1(internet), 5(security), 6(nametypes), 2(gss-host-based-services) }

      • NT_USER_NAME

        public static final Oid NT_USER_NAME
        Name type used to indicate a named user on a local system. It represents the following value:

        { iso(1) member-body(2) United States(840) mit(113554) infosys(1) gssapi(2) generic(1) user_name(1) }

      • NT_MACHINE_UID_NAME

        public static final Oid NT_MACHINE_UID_NAME
        Name type used to indicate a numeric user identifier corresponding to a user on a local system. (e.g. Uid). It represents the following value:

        { iso(1) member-body(2) United States(840) mit(113554) infosys(1) gssapi(2) generic(1) machine_uid_name(2) }

      • NT_STRING_UID_NAME

        public static final Oid NT_STRING_UID_NAME
        Name type used to indicate a string of digits representing the numeric user identifier of a user on a local system. It represents the following value:

        { iso(1) member-body(2) United States(840) mit(113554) infosys(1) gssapi(2) generic(1) string_uid_name(3) }

      • NT_ANONYMOUS

        public static final Oid NT_ANONYMOUS
        Name type used to represent an Anonymous identity. It represents the following value:

        { 1(iso), 3(org), 6(dod), 1(internet), 5(security), 6(nametypes), 3(gss-anonymous-name) }

      • NT_EXPORT_NAME

        public static final Oid NT_EXPORT_NAME
        Name type used to indicate an exported name produced by the export method. It represents the following value:

        { 1(iso), 3(org), 6(dod), 1(internet), 5(security), 6(nametypes), 4(gss-api-exported-name) }

    • Constructor Detail

      • GSSName

        public GSSName​(java.lang.String nameStr,
                       Oid type)
        Converts a contiguous string name to a GSSName object of the specified type. The nameStr parameter is interpreted based on the type specified. In general, the GSSName object created will not be an MN; the exception to this is if the type parameter indicates NT_EXPORT_NAME.

        RFC 2078
        equivalent to gss_import_name
        Parameters:
        nameStr - the name to create
        type - an oid specifying the name type
      • GSSName

        public GSSName​(byte[] name,
                       Oid type)
                throws GSSException
        Creates a new GSSName object from the specified type. It is envisioned that this constructor will be called with buffers returned from GSSName.export() or for name types that aren't represented by printable strings.
        RFC 2078
        equivalent to gss_import_name
        Parameters:
        name - buffer containing name
        type - an Oid specifying the name type
        Throws:
        GSSException - with possible major codes of BAD_NAMETYPE, BAD_NAME, or FAILURE.
        See Also:
        GSSName(String,Oid), GSSName(byte[],Oid,Oid), export()
      • GSSName

        public GSSName​(java.lang.String nameStr,
                       Oid nameType,
                       Oid mechType)
                throws GSSException
        Creates a new GSSName object of the specified type. This constructor takes an additional mechanism oid parameter which allows the creation of a mechanism name in one step.

        RFC 2078
        equivalent to gss_import_name followed by gss_canonicalize_name
        Parameters:
        nameStr - the name to create
        nameType - an oid specifying the name type
        mechType - the oid of the mechanism to create this name for
        Throws:
        GSSException - with possible major codes of BAD_NAMETYPE, BAD_NAME, or FAILURE.
        See Also:
        GSSName(String,Oid)
      • GSSName

        public GSSName​(byte[] name,
                       Oid nameType,
                       Oid mechType)
                throws GSSException
        Creates a new GSSName object from the specified type. It is envisioned that this constructor will be called with buffers returned from GSSName.export() or for name types that aren't represented by printable strings. This constructor takes an additional parameter for the mechanism oid.
        RFC 2078
        equivalent to gss_import_name followed by gss_canonicalize_name
        Parameters:
        name - buffer containing name
        nameType - an Oid specifying the name type
        mechType - an Oid for the mechanism to create this name for
        Throws:
        GSSException - with possible major codes of BAD_NAMETYPE, BAD_NAME, or FAILURE.
        See Also:
        GSSName(String,Oid), GSSName#GSSName(name,Oid), export()
    • Method Detail

      • equals

        public boolean equals​(java.lang.Object another)
        Compares this name with the specified GSSName for equality. If either of the names has type NT_ANONYMOUS, this call will return false.
        RFC 2078
        equivalent to gss_compare_name
        Overrides:
        equals in class java.lang.Object
        Parameters:
        another - the GSSName object to be compared
        Returns:
        true if they both names refer to the same entity, false otherwise
      • equals

        public boolean equals​(GSSName another)
                       throws GSSException
        A variation of equals method which may throw a GSSException when the names cannot be compared. If either of the names represents an anonymous entity, the method will return false.
        RFC 2078
        equivalent to gss_compare_name
        Parameters:
        another - GSSName object to be compared
        Returns:
        true if they both names refer to the same entity, false otherwise
        Throws:
        GSSException - with possible major codes of BAD_NAMETYPE, BAD_NAME, FAILURE
      • canonicalize

        public GSSName canonicalize​(Oid mechOid)
                             throws GSSException
        Creates a new name which is guaranteed to be mechanism specific (MN).
        RFC 2078
        equivalent to gss_canonicalize_name
        Parameters:
        mechOid - oid of the mechanism for which the name should be canonicalized
        Returns:
        a mechanism specific internal name (MN)
        Throws:
        GSSException - with possible major codes of BAD_MECH, BAD_NAMETYPE.
      • export

        public byte[] export()
                      throws GSSException
        Returns a flat name representation for this GSSName object. The name must be in MN format before making this call. The name is prefixed with a mechanism independent header as specified in RFC 2078. The returned buffer can be passed into a GSSName constructor with GSSName.EXPORT_NAME as the name type.
        RFC 2078
        equivalent to gss_export_name
        Returns:
        a byte array representing the name
        Throws:
        GSSException - with possible major codes of NAME_NOT_MN, BAD_NAME, BAD_NAMETYPE, FAILURE.
        See Also:
        canonicalize(com.sun.gssapi.Oid)
      • toString

        public java.lang.String toString()
        Returns a string representation of the GSSName object. To retrieve the printed name format call getStringNameType.
        Overrides:
        toString in class java.lang.Object
        Returns:
        a String representation for this GSSName
        See Also:
        getStringNameType()
      • getStringNameType

        public Oid getStringNameType()
                              throws GSSException
        Returns the name type for the printed name.
        RFC 2078
        equivalent to name_type parameter in gss_display_name
        Returns:
        Oid for the name type as printed with toString()
        Throws:
        GSSException - when the name can't be printed
        See Also:
        toString()
      • clone

        public java.lang.Object clone()
                               throws java.lang.CloneNotSupportedException
        Creates a duplicate of this object.
        RFC 2078
        equivalent to gss_duplicate_name
        Overrides:
        clone in class java.lang.Object
        Returns:
        a copy of this object
        Throws:
        java.lang.CloneNotSupportedException - may be thrown
      • isAnonymousName

        public boolean isAnonymousName()
        Tests if this is an Anonymous name object.
        Returns:
        boolean indicating if this in an anonymous name