public class

GSSNameImpl

extends Object
implements GSSName
java.lang.Object
   ↳ sun.security.jgss.GSSNameImpl

Class Overview

This is the implementation class for GSSName. Conceptually the GSSName is a container with mechanism specific name elements. Each name element is a representation of how that particular mechanism would canonicalize this principal. Generally a GSSName is created by an application when it supplies a sequence of bytes and a nametype that helps each mechanism decide how to interpret those bytes. It is not necessary to create name elements for each available mechanism at the time the application creates the GSSName. This implementation does this lazily, as and when name elements for mechanisms are required to be handed out. (Generally, other GSS classes like GSSContext and GSSCredential request specific elements depending on the mechanisms that they are dealing with.) Assume that getting a mechanism to parse the applciation specified bytes is an expensive call. When a GSSName is canonicalized wrt some mechanism, it is supposed to discard all elements of other mechanisms and retain only the element for this mechanism. In GSS terminology this is called a Mechanism Name or MN. This implementation tries to retain the application provided bytes and name type just in case the MN is asked to produce an element for a mechanism that is different. When a GSSName is to be exported, the name element for the desired mechanism is converted to a byte representation and written out. It might happen that a name element for that mechanism cannot be obtained. This happens when the mechanism is just not supported in this GSS-API or when the mechanism is supported but bytes corresponding to the nametypes that it understands are not available in this GSSName. This class is safe for sharing. Each retrieval of a name element from getElement() might potentially add a new element to the hashmap of elements, but getElement() is synchronized.

Summary

[Expand]
Inherited Fields
From interface org.ietf.jgss.GSSName
Public Methods
GSSName canonicalize(Oid mech)
Creates a name that is canonicalized for some mechanism.
boolean equals(Object another)
Indicates whether some other object is "equal to" this one.
boolean equals(GSSName other)
This method may return false negatives.
byte[] export()
Returns a flat name representation for this object.
synchronized GSSNameSpi getElement(Oid mechOid)
Oid getStringNameType()
Returns the name type of the printable representation of this name that can be obtained from the toString method.
int hashCode()
Returns a hashcode value for this GSSName.
boolean isAnonymous()
Tests if this name object represents an anonymous entity.
boolean isMN()
Tests if this name object represents a Mechanism Name (MN).
String toString()
Returns a string representation of the object.
[Expand]
Inherited Methods
From class java.lang.Object
From interface org.ietf.jgss.GSSName

Public Methods

public GSSName canonicalize (Oid mech)

Creates a name that is canonicalized for some mechanism.

Parameters
mech the oid for the mechanism for which the canonical form of the name is requested.
Returns
  • a GSSName that contains just one primitive element representing this name in a canonicalized form for the desired mechanism.
Throws
GSSException

public boolean equals (Object another)

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

Parameters
another the reference object with which to compare.
Returns
  • true if this object is the same as the obj argument; false otherwise.

public boolean equals (GSSName other)

This method may return false negatives. But if it says two names are equals, then there is some mechanism that authenticates them as the same principal.

Parameters
other the GSSName to compare this name with
Returns
  • true if the two names contain at least one primitive element in common. If either of the names represents an anonymous entity, the method will return false.
Throws
GSSException

public byte[] export ()

Returns a flat name representation for this object. The name format is defined in RFC 2743:

 Length           Name          Description
 2               TOK_ID          Token Identifier
                                 For exported name objects, this
                                 must be hex 04 01.
 2               MECH_OID_LEN    Length of the Mechanism OID
 MECH_OID_LEN    MECH_OID        Mechanism OID, in DER
 4               NAME_LEN        Length of name
 NAME_LEN        NAME            Exported name; format defined in
                                 applicable mechanism draft.
Note that it is not required to canonicalize a name before calling export(). i.e., the name need not be an MN. If it is not an MN, an implementation defined algorithm can be used for choosing the mechanism which should export this name.

Returns
  • the flat name representation for this object
Throws
GSSException with major codes NAME_NOT_MN, BAD_NAME, BAD_NAME, FAILURE.

public synchronized GSSNameSpi getElement (Oid mechOid)

Throws
GSSException

public Oid getStringNameType ()

Returns the name type of the printable representation of this name that can be obtained from the toString method.

Returns
  • an Oid representing the namespace of the name returned from the toString method.
Throws
GSSException

public int hashCode ()

Returns a hashcode value for this GSSName.

Returns
  • a hashCode value

public boolean isAnonymous ()

Tests if this name object represents an anonymous entity.

Returns
  • true if this is an anonymous name, false otherwise.

public boolean isMN ()

Tests if this name object represents a Mechanism Name (MN). An MN is a GSSName the contains exactly one mechanism's primitive name element.

Returns
  • true if this is an MN, false otherwise.

public String toString ()

Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Returns
  • a string representation of the object.