APIdia Launch Partner
Top Description Fields Constructors Methods
sun.security.jgss

public final Class GSSNameImpl

extends Object
implements GSSName
Class Inheritance
All Implemented Interfaces
org.ietf.jgss.GSSName
Imports
org.ietf.jgss.*, sun.security.jgss.spi.*, java.util.Set, .HashMap, .HashSet, .Arrays, java.io.IOException, sun.security.util.ObjectIdentifier, .DerInputStream, .DerOutputStream

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 application 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.
Author
Mayank Upadhyay
Since
1.4

Field Summary

Modifier and TypeField and Description
private byte[]
private String
private Oid
private HashMap<Oid, GSSNameSpi>
private GSSManagerImpl
private GSSNameSpi
pack-priv static final Oid
oldHostbasedServiceName

The old Oid used in RFC 2853.

private String
private Oid

Constructor Summary

AccessConstructor and Description
pack-priv
GSSNameImpl(GSSManagerImpl gssManager, GSSNameSpi mechElement)

pack-priv
GSSNameImpl(GSSManagerImpl gssManager, Object appName, Oid appNameType)

pack-priv
GSSNameImpl(GSSManagerImpl gssManager, Object appName, Oid appNameType, Oid mech)

Method Summary

Modifier and TypeMethod and Description
public GSSName
canonicalize(Oid mech)

Implements org.ietf.jgss.GSSName.canonicalize.

Creates a name that is canonicalized for some mechanism.

public boolean
equals(GSSName other)

Implements org.ietf.jgss.GSSName.equals.

This method may return false negatives.

public boolean
equals(Object another)

Overrides java.lang.Object.equals.

Implements org.ietf.jgss.GSSName.equals.

Compares this GSSName object to another Object that might be a GSSName.

public byte[]

Returns:

the flat name representation for this object
export
()

Implements org.ietf.jgss.GSSName.export.

Returns a flat name representation for this object.

public synchronized GSSNameSpi
getElement(Oid mechOid)

pack-priv Set<GSSNameSpi>
private static String
getNameTypeStr(Oid nameTypeOid)

public Oid
getStringNameType()

Implements org.ietf.jgss.GSSName.getStringNameType.

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

public int

Returns:

a hashcode value for this GSSName
hashCode
()

Overrides java.lang.Object.hashCode.

Implements org.ietf.jgss.GSSName.hashCode.

Returns a hashcode value for this GSSName.

private void
importName(GSSManagerImpl gssManager, Object appName)

private void
init(GSSManagerImpl gssManager, Object appName, Oid appNameType, Oid mech)

public boolean
isAnonymous()

Implements org.ietf.jgss.GSSName.isAnonymous.

Tests if this name object represents an anonymous entity.

public boolean
isMN()

Implements org.ietf.jgss.GSSName.isMN.

Tests if this name object represents a Mechanism Name (MN).

public String
toString()

Overrides java.lang.Object.toString.

Implements org.ietf.jgss.GSSName.toString.

Returns a textual representation of the GSSName object.

pack-priv static GSSNameImpl
wrapElement(GSSManagerImpl gssManager, GSSNameSpi mechElement)

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

appNameBytesback to summary
private byte[] appNameBytes
appNameStrback to summary
private String appNameStr
appNameTypeback to summary
private Oid appNameType
elementsback to summary
private HashMap<Oid, GSSNameSpi> elements
gssManagerback to summary
private GSSManagerImpl gssManager
mechElementback to summary
private GSSNameSpi mechElement
oldHostbasedServiceNameback to summary
pack-priv static final Oid oldHostbasedServiceName

The old Oid used in RFC 2853. Now supported as input parameters in: 1. The four overloaded GSSManager.createName(*) methods 2. GSSManager.getMechsForName(Oid) Note that even if a GSSName is created with this old Oid, its internal name type and getStringNameType() output are always the new value.

printableNameback to summary
private String printableName
printableNameTypeback to summary
private Oid printableNameType

Constructor Detail

GSSNameImplback to summary
pack-priv GSSNameImpl(GSSManagerImpl gssManager, GSSNameSpi mechElement)
GSSNameImplback to summary
pack-priv GSSNameImpl(GSSManagerImpl gssManager, Object appName, Oid appNameType) throws GSSException
GSSNameImplback to summary
pack-priv GSSNameImpl(GSSManagerImpl gssManager, Object appName, Oid appNameType, Oid mech) throws GSSException

Method Detail

canonicalizeback to summary
public GSSName canonicalize(Oid mech) throws GSSException

Implements org.ietf.jgss.GSSName.canonicalize.

Doc from org.ietf.jgss.GSSName.canonicalize.

Creates a name that is canonicalized for some mechanism.

Exceptions
GSSException:
containing the following major error codes: GSSException.BAD_MECH, GSSException.BAD_NAMETYPE, GSSException.BAD_NAME, GSSException.FAILURE
equalsback to summary
public boolean equals(GSSName other) throws GSSException

Implements org.ietf.jgss.GSSName.equals.

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.

Exceptions
GSSException:

Doc from org.ietf.jgss.GSSName.equals.

when the names cannot be compared, containing the following major error codes: GSSException.BAD_NAMETYPE, GSSException.FAILURE

equalsback to summary
public boolean equals(Object another)

Overrides java.lang.Object.equals.

Implements org.ietf.jgss.GSSName.equals.

Doc from org.ietf.jgss.GSSName.equals.

Compares this GSSName object to another Object that might be a GSSName. The behaviour is exactly the same as in equals except that no GSSException is thrown; instead, false will be returned in the situation where an error occurs.

Annotations
@Override
exportback to summary
public byte[] export() throws GSSException

Implements org.ietf.jgss.GSSName.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:byte[]

the flat name representation for this object

Exceptions
GSSException:
with major codes NAME_NOT_MN, BAD_NAME, BAD_NAME, FAILURE.
getElementback to summary
public synchronized GSSNameSpi getElement(Oid mechOid) throws GSSException
getElementsback to summary
pack-priv Set<GSSNameSpi> getElements()
getNameTypeStrback to summary
private static String getNameTypeStr(Oid nameTypeOid)
getStringNameTypeback to summary
public Oid getStringNameType() throws GSSException

Implements org.ietf.jgss.GSSName.getStringNameType.

Doc from org.ietf.jgss.GSSName.getStringNameType.

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

Exceptions
GSSException:
containing the following major error codes: GSSException.FAILURE
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Implements org.ietf.jgss.GSSName.hashCode.

Returns a hashcode value for this GSSName.

Returns:int

a hashcode value for this GSSName

Annotations
@Override
importNameback to summary
private void importName(GSSManagerImpl gssManager, Object appName) throws GSSException
initback to summary
private void init(GSSManagerImpl gssManager, Object appName, Oid appNameType, Oid mech) throws GSSException
isAnonymousback to summary
public boolean isAnonymous()

Implements org.ietf.jgss.GSSName.isAnonymous.

Doc from org.ietf.jgss.GSSName.isAnonymous.

Tests if this name object represents an anonymous entity.

isMNback to summary
public boolean isMN()

Implements org.ietf.jgss.GSSName.isMN.

Doc from org.ietf.jgss.GSSName.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.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Implements org.ietf.jgss.GSSName.toString.

Doc from org.ietf.jgss.GSSName.toString.

Returns a textual representation of the GSSName object. To retrieve the printed name format, which determines the syntax of the returned string, use the getStringNameType method.

wrapElementback to summary
pack-priv static GSSNameImpl wrapElement(GSSManagerImpl gssManager, GSSNameSpi mechElement) throws GSSException