sun.security.mule.krb5
Class PrincipalName

java.lang.Object
  extended by sun.security.mule.krb5.PrincipalName
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
ServiceName

public class PrincipalName
extends Object
implements Cloneable

This class encapsulates a Kerberos principal.


Field Summary
static int KRB_NT_PRINCIPAL
          Just the name of the principal as in DCE, or for users
static int KRB_NT_SRV_HST
          Service with host name as instance (telnet, rcommands)
static int KRB_NT_SRV_INST
          Service and other unique instance (krbtgt)
static int KRB_NT_SRV_XHST
          Service with host as remaining components
static int KRB_NT_UID
          Unique ID
static int KRB_NT_UNKNOWN
          Name type not known
static char NAME_COMPONENT_SEPARATOR
           
static String NAME_COMPONENT_SEPARATOR_STR
           
static char NAME_REALM_SEPARATOR
           
static String NAME_REALM_SEPARATOR_STR
           
static char REALM_COMPONENT_SEPARATOR
           
static String REALM_COMPONENT_SEPARATOR_STR
           
static int TGS_DEFAULT_NT
           
static String TGS_DEFAULT_SRV_NAME
          TGS Name
 
Constructor Summary
protected PrincipalName()
           
  PrincipalName(sun.security.util.DerValue encoding)
          Returns the ASN.1 encoding of the PrincipalName ::= SEQUENCE { name-type [0] Int32, name-string [1] SEQUENCE OF KerberosString } KerberosString ::= GeneralString (IA5String)
  PrincipalName(String[] nameParts)
           
  PrincipalName(String[] nameParts, int type)
           
  PrincipalName(String name, Config kerberosConfig)
           
  PrincipalName(String name, int type, Config kerberosConfig)
           
  PrincipalName(String name, String realm, Config kerberosConfig)
           
protected PrincipalName(String primary, String instance, String realm, int type)
          Creates a KRB_NT_SRV_INST name from the supplied name components and realm.
 
Method Summary
 byte[] asn1Encode()
          Encodes a PrincipalName object.
 Object clone()
           
 boolean equals(Object o)
           
 boolean equals(PrincipalName other)
           
 String getInstanceComponent()
          Returns the instance component of a name.
 String getName()
           
 String getNameString()
           
 String[] getNameStrings()
           
 int getNameType()
           
 String getPrincipalNameAsString()
           
 Realm getRealm()
           
 String getRealmAsString()
           
 String getRealmString()
           
 String getSalt()
           
 int hashCode()
           
 boolean match(PrincipalName pname)
          Checks if two PrincipalName objects have identical values in their corresponding data fields.
static PrincipalName parse(sun.security.util.DerInputStream data, byte explicitTag, boolean optional)
          Parse (unmarshal) a PrincipalName from a DER input stream.
protected static String[] parseName(String name)
           
 void setRealm(Realm new_nameRealm)
           
 void setRealm(String realmsString)
           
 void setSalt(String salt)
           
 byte[][] toByteArray()
           
 String toString()
           
 void writePrincipal(CCacheOutputStream cos)
          Writes data field values of PrincipalName in FCC format to an output stream.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

KRB_NT_UNKNOWN

public static final int KRB_NT_UNKNOWN
Name type not known

See Also:
Constant Field Values

KRB_NT_PRINCIPAL

public static final int KRB_NT_PRINCIPAL
Just the name of the principal as in DCE, or for users

See Also:
Constant Field Values

KRB_NT_SRV_INST

public static final int KRB_NT_SRV_INST
Service and other unique instance (krbtgt)

See Also:
Constant Field Values

KRB_NT_SRV_HST

public static final int KRB_NT_SRV_HST
Service with host name as instance (telnet, rcommands)

See Also:
Constant Field Values

KRB_NT_SRV_XHST

public static final int KRB_NT_SRV_XHST
Service with host as remaining components

See Also:
Constant Field Values

KRB_NT_UID

public static final int KRB_NT_UID
Unique ID

See Also:
Constant Field Values

TGS_DEFAULT_SRV_NAME

public static final String TGS_DEFAULT_SRV_NAME
TGS Name

See Also:
Constant Field Values

TGS_DEFAULT_NT

public static final int TGS_DEFAULT_NT
See Also:
Constant Field Values

NAME_COMPONENT_SEPARATOR

public static final char NAME_COMPONENT_SEPARATOR
See Also:
Constant Field Values

NAME_REALM_SEPARATOR

public static final char NAME_REALM_SEPARATOR
See Also:
Constant Field Values

REALM_COMPONENT_SEPARATOR

public static final char REALM_COMPONENT_SEPARATOR
See Also:
Constant Field Values

NAME_COMPONENT_SEPARATOR_STR

public static final String NAME_COMPONENT_SEPARATOR_STR
See Also:
Constant Field Values

NAME_REALM_SEPARATOR_STR

public static final String NAME_REALM_SEPARATOR_STR
See Also:
Constant Field Values

REALM_COMPONENT_SEPARATOR_STR

public static final String REALM_COMPONENT_SEPARATOR_STR
See Also:
Constant Field Values
Constructor Detail

PrincipalName

protected PrincipalName()

PrincipalName

public PrincipalName(String[] nameParts,
                     int type)
              throws IllegalArgumentException,
                     IOException
Throws:
IllegalArgumentException
IOException

PrincipalName

public PrincipalName(String[] nameParts)
              throws IOException
Throws:
IOException

PrincipalName

public PrincipalName(sun.security.util.DerValue encoding)
              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 - a Der-encoded data.
Throws:
Asn1Exception - if an error occurs while decoding an ASN1 encoded data.
Asn1Exception - if there is an ASN1 encoding error
IOException - if an I/O error occurs
IllegalArgumentException - if encoding is null reading encoded data.

PrincipalName

public PrincipalName(String name,
                     int type,
                     Config kerberosConfig)
              throws RealmException
Throws:
RealmException

PrincipalName

public PrincipalName(String name,
                     Config kerberosConfig)
              throws RealmException
Throws:
RealmException

PrincipalName

public PrincipalName(String name,
                     String realm,
                     Config kerberosConfig)
              throws RealmException
Throws:
RealmException

PrincipalName

protected PrincipalName(String primary,
                        String instance,
                        String realm,
                        int type)
                 throws KrbException
Creates a KRB_NT_SRV_INST name from the supplied name components and realm.

Parameters:
primary - the primary component of the name
instance - the instance component of the name
realm - the realm
Throws:
KrbException
Method Detail

clone

public Object clone()
Overrides:
clone in class Object

equals

public boolean equals(Object o)
Overrides:
equals in class Object

equals

public boolean equals(PrincipalName other)

parse

public static PrincipalName parse(sun.security.util.DerInputStream data,
                                  byte explicitTag,
                                  boolean optional)
                           throws Asn1Exception,
                                  IOException
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 - the Der input stream value, which contains one or more marshaled value.
explicitTag - tag number.
optional - indicate if this data field is optional
Returns:
an instance of PrincipalName.
Throws:
Asn1Exception - on error.
IOException

parseName

protected static String[] parseName(String name)

getRealmAsString

public String getRealmAsString()

getPrincipalNameAsString

public String getPrincipalNameAsString()

hashCode

public int hashCode()
Overrides:
hashCode in class Object

getName

public String getName()

getNameType

public int getNameType()

getNameStrings

public String[] getNameStrings()

toByteArray

public byte[][] toByteArray()

getRealmString

public String getRealmString()

getRealm

public Realm getRealm()

setRealm

public void setRealm(Realm new_nameRealm)
              throws RealmException
Throws:
RealmException

setRealm

public void setRealm(String realmsString)
              throws RealmException
Throws:
RealmException

getSalt

public String getSalt()

setSalt

public void setSalt(String salt)

toString

public String toString()
Overrides:
toString in class Object

getNameString

public String getNameString()

asn1Encode

public byte[] asn1Encode()
                  throws Asn1Exception,
                         IOException
Encodes a PrincipalName object.

Returns:
the byte array of the encoded PrncipalName object.
Throws:
Asn1Exception - if an error occurs while decoding an ASN1 encoded data.
IOException - if an I/O error occurs while reading encoded data.

match

public boolean match(PrincipalName pname)
Checks if two PrincipalName objects have identical values in their corresponding data fields.

Parameters:
pname - the other PrincipalName object.
Returns:
true if two have identical values, otherwise, return false.

writePrincipal

public void writePrincipal(CCacheOutputStream cos)
                    throws IOException
Writes data field values of PrincipalName in FCC format to an output stream.

Parameters:
cos - a CCacheOutputStream for writing data.
Throws:
IOException - if an I/O exception occurs.
See Also:
CCacheOutputStream

getInstanceComponent

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.



Copyright © 2013. All Rights Reserved.