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

public Class PrincipalName

extends Object
implements Cloneable
Class Inheritance
All Implemented Interfaces
java.lang.Cloneable
Imports
sun.security.krb5.internal.*, sun.security.util.*, java.net.*, java.util.ArrayList, .Locale, .Arrays, java.io.IOException, java.math.BigInteger, sun.security.krb5.internal.ccache.CCacheOutputStream, sun.security.krb5.internal.util.KerberosString

Implements the ASN.1 PrincipalName type and its realm in a single class.
Realm           ::= KerberosString

   PrincipalName   ::= SEQUENCE {
           name-type       [0] Int32,
           name-string     [1] SEQUENCE OF KerberosString
   }
This class is immutable.
See Also
Realm

Field Summary

Modifier and TypeField and Description
public static final int
KRB_NT_ENTERPRISE

Enterprise name (alias)

public static final int
KRB_NT_PRINCIPAL

Just the name of the principal as in DCE, or for users

public static final int
KRB_NT_SRV_HST

Service with host name as instance (telnet, rcommands)

public static final int
KRB_NT_SRV_INST

Service and other unique instance (krbtgt)

public static final int
KRB_NT_SRV_XHST

Service with host as remaining components

public static final int
KRB_NT_UID

Unique ID

public static final int
KRB_NT_UNKNOWN

Name type not known

private static final boolean
public static final char
public static final String
public static final char
public static final String
private static final long
private final Realm
nameRealm

The realm this principal belongs to.

private final String[]
nameStrings

The name strings, from PrincipalName's name-strings field.

private final int
nameType

The name type, from PrincipalName's name-type field.

public static final char
private transient String
public static final String
private static final Unsafe

Constructor Summary

AccessConstructor and Description
public
PrincipalName(int nameType, String[] nameStrings, Realm nameRealm)

Creates a PrincipalName.

public
PrincipalName(String[] nameParts, String realm)

public
PrincipalName(DerValue
DER-encoded PrincipalName (without Realm)
encoding
,
Realm
the realm for this name
realm
)

Returns the ASN.1 encoding of the

PrincipalName    ::= SEQUENCE {
         name-type       [0] Int32,
         name-string     [1] SEQUENCE OF KerberosString
}

KerberosString   ::= GeneralString (IA5String)
public
PrincipalName(String
the name
name
,
int
the type
type
,
String
the realm, null if not known. Note that when realm is not null, it will be always used even if there is a realm part in name. When realm is null, will read realm part from name, or try to map a realm (for KRB_NT_SRV_HST), or use the default realm, or fail
realm
)

Constructs a PrincipalName from a string.

public
PrincipalName(String name, int type)

public
public

Method Summary

Modifier and TypeMethod and Description
public byte[]

Returns:

the byte array of the encoded PrncipalName object.
asn1Encode
()

Encodes a PrincipalName object.

public Object
clone()

Overrides java.lang.Object.clone.

Creates and returns a copy of this object.

public boolean
equals(Object o)

Overrides java.lang.Object.equals.

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

public String

Returns:

instance component of a multi-component name.
getInstanceComponent
()

Returns the instance component of a name.

public String
public String
public String[]
public int
public String
public Realm
public String
public String
public String
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

pack-priv static String
public boolean

Returns:

true if two have identical values, otherwise, return false.
match
(PrincipalName
the other PrincipalName object.
pname
)

Checks if two PrincipalName objects have identical values in their corresponding data fields.

public static PrincipalName

Returns:

an instance of PrincipalName, or null if the field is optional and missing.
parse
(DerInputStream
the Der input stream value, which contains one or more marshaled value.
data
,
byte
tag number.
explicitTag
,
boolean
indicate if this data field is optional
optional
,
Realm
the realm for the name
realm
)

Parse (unmarshal) a PrincipalName from a DER input stream.

private static String[]
public static PrincipalName
public byte[][]
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

private static void
public void
writePrincipal(CCacheOutputStream
a CCacheOutputStream for writing data.
cos
)

Writes data field values of PrincipalName in FCC format to an output stream.

Inherited from java.lang.Object:
finalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

KRB_NT_ENTERPRISEback to summary
public static final int KRB_NT_ENTERPRISE

Enterprise name (alias)

KRB_NT_PRINCIPALback to summary
public static final int KRB_NT_PRINCIPAL

Just the name of the principal as in DCE, or for users

KRB_NT_SRV_HSTback to summary
public static final int KRB_NT_SRV_HST

Service with host name as instance (telnet, rcommands)

KRB_NT_SRV_INSTback to summary
public static final int KRB_NT_SRV_INST

Service and other unique instance (krbtgt)

KRB_NT_SRV_XHSTback to summary
public static final int KRB_NT_SRV_XHST

Service with host as remaining components

KRB_NT_UIDback to summary
public static final int KRB_NT_UID

Unique ID

KRB_NT_UNKNOWNback to summary
public static final int KRB_NT_UNKNOWN

Name type not known

NAME_CASE_SENSITIVE_IN_MATCHback to summary
private static final boolean NAME_CASE_SENSITIVE_IN_MATCH
NAME_COMPONENT_SEPARATORback to summary
public static final char NAME_COMPONENT_SEPARATOR
NAME_COMPONENT_SEPARATOR_STRback to summary
public static final String NAME_COMPONENT_SEPARATOR_STR
NAME_REALM_SEPARATORback to summary
public static final char NAME_REALM_SEPARATOR
NAME_REALM_SEPARATOR_STRback to summary
public static final String NAME_REALM_SEPARATOR_STR
NAME_STRINGS_OFFSETback to summary
private static final long NAME_STRINGS_OFFSET
nameRealmback to summary
private final Realm nameRealm

The realm this principal belongs to.

nameStringsback to summary
private final String[] nameStrings

The name strings, from PrincipalName's name-strings field. This field must be neither null nor empty. Each entry of it must also be neither null nor empty. Make sure to clone the field when it's passed in or out.

nameTypeback to summary
private final int nameType

The name type, from PrincipalName's name-type field.

REALM_COMPONENT_SEPARATORback to summary
public static final char REALM_COMPONENT_SEPARATOR
saltback to summary
private transient String salt
TGS_DEFAULT_SRV_NAMEback to summary
public static final String TGS_DEFAULT_SRV_NAME

TGS Name

UNSAFEback to summary
private static final Unsafe UNSAFE

Constructor Detail

PrincipalNameback to summary
public PrincipalName(int nameType, String[] nameStrings, Realm nameRealm)

Creates a PrincipalName.

PrincipalNameback to summary
public PrincipalName(String[] nameParts, String realm) throws RealmException
PrincipalNameback to summary
public PrincipalName(DerValue encoding, Realm realm) throws Asn1Exception, IOException

Returns the ASN.1 encoding of the

PrincipalName    ::= SEQUENCE {
         name-type       [0] Int32,
         name-string     [1] SEQUENCE OF KerberosString
}

KerberosString   ::= GeneralString (IA5String)

This definition reflects the Network Working Group RFC 4120 specification available at http://www.ietf.org/rfc/rfc4120.txt.

Parameters
encoding:DerValue

DER-encoded PrincipalName (without Realm)

realm:Realm

the realm for this name

Exceptions
Asn1Exception:
  • if an error occurs while decoding an ASN1 encoded data.
  • if there is an ASN1 encoding error
IOException:
if an I/O error occurs
IllegalArgumentException:
if encoding is null reading encoded data.
PrincipalNameback to summary
public PrincipalName(String name, int type, String realm) throws RealmException

Constructs a PrincipalName from a string.

Parameters
name:String

the name

type:int

the type

realm:String

the realm, null if not known. Note that when realm is not null, it will be always used even if there is a realm part in name. When realm is null, will read realm part from name, or try to map a realm (for KRB_NT_SRV_HST), or use the default realm, or fail

PrincipalNameback to summary
public PrincipalName(String name, int type) throws RealmException
PrincipalNameback to summary
public PrincipalName(String name) throws RealmException
PrincipalNameback to summary
public PrincipalName(String name, String realm) throws RealmException

Method Detail

asn1Encodeback to summary
public byte[] asn1Encode() throws Asn1Exception, IOException

Encodes a PrincipalName object. Note that only the type and names are encoded. To encode the realm, call getRealm().asn1Encode().

Returns:byte[]

the byte array of the encoded PrncipalName object.

Exceptions
Asn1Exception:
if an error occurs while decoding an ASN1 encoded data.
IOException:
if an I/O error occurs while reading encoded data.
cloneback to summary
public Object clone()

Overrides java.lang.Object.clone.

Doc from java.lang.Object.clone.

Creates and returns a copy of this object. The precise meaning of "copy" may depend on the class of the object. The general intent is that, for any object x, the expression:

x.clone() != x
will be true, and that the expression:
x.clone().getClass() == x.getClass()
will be true, but these are not absolute requirements. While it is typically the case that:
x.clone().equals(x)
will be true, this is not an absolute requirement.

By convention, the returned object should be obtained by calling super.clone. If a class and all of its superclasses (except Object) obey this convention, it will be the case that x.clone().getClass() == x.getClass().

By convention, the object returned by this method should be independent of this object (which is being cloned). To achieve this independence, it may be necessary to modify one or more fields of the object returned by super.clone before returning it. Typically, this means copying any mutable objects that comprise the internal "deep structure" of the object being cloned and replacing the references to these objects with references to the copies. If a class contains only primitive fields or references to immutable objects, then it is usually the case that no fields in the object returned by super.clone need to be modified.

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

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.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
getInstanceComponentback to summary
public String getInstanceComponent()

Returns the instance component of a name. In a multi-component name such as a KRB_NT_SRV_INST name, the second component is returned. Null is returned if there are not two or more components in the name.

Returns:String

instance component of a multi-component name.

getNameback to summary
public String getName()
getNameStringback to summary
public String getNameString()
getNameStringsback to summary
public String[] getNameStrings()
getNameTypeback to summary
public int getNameType()
getPrincipalNameAsStringback to summary
public String getPrincipalNameAsString()
getRealmback to summary
public Realm getRealm()
getRealmAsStringback to summary
public String getRealmAsString()
getRealmStringback to summary
public String getRealmString()
getSaltback to summary
public String getSalt()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
mapHostToRealmback to summary
pack-priv static String mapHostToRealm(String name)
matchback to summary
public boolean match(PrincipalName pname)

Checks if two PrincipalName objects have identical values in their corresponding data fields.

If jdk.security.krb5.name.case.sensitive is set to true, the name comparison is case-sensitive. Otherwise, it's case-insensitive.

It is used in sun.security.krb5.internal.ccache.FileCredentialsCache and sun.security.krb5.internal.ktab.KeyTab to retrieve ccache or keytab entry for a principal.

Parameters
pname:PrincipalName

the other PrincipalName object.

Returns:boolean

true if two have identical values, otherwise, return false.

parseback to summary
public static PrincipalName parse(DerInputStream data, byte explicitTag, boolean optional, Realm realm) throws Asn1Exception, IOException, RealmException

Parse (unmarshal) a PrincipalName from a DER input stream. This form parsing might be used when expanding a value which is part of a constructed sequence and uses explicitly tagged type.

Parameters
data:DerInputStream

the Der input stream value, which contains one or more marshaled value.

explicitTag:byte

tag number.

optional:boolean

indicate if this data field is optional

realm:Realm

the realm for the name

Returns:PrincipalName

an instance of PrincipalName, or null if the field is optional and missing.

Exceptions
Asn1Exception:
on error.
parseNameback to summary
private static String[] parseName(String name)
tgsServiceback to summary
public static PrincipalName tgsService(String r1, String r2) throws KrbException
toByteArrayback to summary
public byte[][] toByteArray()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

validateNameStringsback to summary
private static void validateNameStrings(String[] ns)
writePrincipalback to summary
public void writePrincipal(CCacheOutputStream cos) throws IOException

Writes data field values of PrincipalName in FCC format to an output stream.

Parameters
cos:CCacheOutputStream

a CCacheOutputStream for writing data.

Exceptions
IOException:
if an I/O exception occurs.
See Also
sun.security.krb5.internal.ccache.CCacheOutputStream