org.apache.directory.server.kerberos.shared.messages.value
Class PrincipalName

java.lang.Object
  extended by org.apache.directory.shared.asn1.AbstractAsn1Object
      extended by org.apache.directory.server.kerberos.shared.messages.value.PrincipalName
All Implemented Interfaces:
org.apache.directory.shared.asn1.Asn1Object

public class PrincipalName
extends org.apache.directory.shared.asn1.AbstractAsn1Object

A principal Name, composed of a type and N names. PrincipalName ::= SEQUENCE { name-type [0] Int32, name-string [1] SEQUENCE OF KerberosString }

Version:
$Rev: 642496 $, $Date: 2008-03-29 04:09:22 +0100 (Sa, 29 M??r 2008) $
Author:
Apache Directory Project

Field Summary
 
Fields inherited from class org.apache.directory.shared.asn1.AbstractAsn1Object
parent
 
Constructor Summary
PrincipalName()
          Creates a new empty instance of PrincipalName.
PrincipalName(javax.security.auth.kerberos.KerberosPrincipal principal)
          Creates a new instance of PrincipalName, given a KerberosPrincipal.
PrincipalName(java.lang.String nameString, int nameType)
          Creates a new instance of PrincipalName.
PrincipalName(java.lang.String nameString, PrincipalNameType nameType)
          Creates a new instance of PrincipalName given a String and an prinipal type.
 
Method Summary
 void addName(java.lang.String name)
          Add a new name to the PrincipalName
 int computeLength()
          Compute the PrincipalName length PrincipalName : 0x30 L1 PrincipalName sequence | +--> 0xA1 L2 name-type tag | | | +--> 0x02 L2-1 addressType (int) | +--> 0xA2 L3 name-string tag | +--> 0x30 L3-1 name-string (SEQUENCE OF KerberosString) | +--> 0x1B L4[1] value (KerberosString) | +--> 0x1B L4[2] value (KerberosString) | ...
 java.nio.ByteBuffer encode(java.nio.ByteBuffer buffer)
          Encode the PrincipalName message to a PDU.
 java.util.List<java.lang.String> getNames()
          Returns the name components.
 java.lang.String getNameString()
           
 PrincipalNameType getNameType()
          Returns the type of the PrincipalName.
 void setNameType(int nameType)
          Set the Principal name Type
 void setNameType(PrincipalNameType nameType)
          Set the Principal name Type
 java.lang.String toString()
           
 
Methods inherited from class org.apache.directory.shared.asn1.AbstractAsn1Object
addLength, getCurrentLength, getExpectedLength, getParent, getTlvId, setCurrentLength, setExpectedLength, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PrincipalName

public PrincipalName()
Creates a new empty instance of PrincipalName.


PrincipalName

public PrincipalName(javax.security.auth.kerberos.KerberosPrincipal principal)
Creates a new instance of PrincipalName, given a KerberosPrincipal. We assume that a principal has only one type, even if there are more than one name component.

Parameters:
principal - A Sun kerberosPrincipal instance

PrincipalName

public PrincipalName(java.lang.String nameString,
                     PrincipalNameType nameType)
              throws java.text.ParseException
Creates a new instance of PrincipalName given a String and an prinipal type.

Parameters:
nameString - The name string, which can contains more than one nameComponent
nameType - The principal name
Throws:
java.text.ParseException

PrincipalName

public PrincipalName(java.lang.String nameString,
                     int nameType)
              throws java.text.ParseException
Creates a new instance of PrincipalName.

Parameters:
nameString -
nameType -
Throws:
java.text.ParseException
Method Detail

getNameType

public PrincipalNameType getNameType()
Returns the type of the PrincipalName.

Returns:
The type of the PrincipalName.

setNameType

public void setNameType(PrincipalNameType nameType)
Set the Principal name Type

Parameters:
nameType - the Principal name Type

setNameType

public void setNameType(int nameType)
Set the Principal name Type

Parameters:
nameType - the Principal name Type

getNames

public java.util.List<java.lang.String> getNames()
Returns the name components.

Returns:
The name components.

getNameString

public java.lang.String getNameString()
Returns:
A String representing the principal names as a String

addName

public void addName(java.lang.String name)
Add a new name to the PrincipalName

Parameters:
name - The name to add

computeLength

public int computeLength()
Compute the PrincipalName length PrincipalName : 0x30 L1 PrincipalName sequence | +--> 0xA1 L2 name-type tag | | | +--> 0x02 L2-1 addressType (int) | +--> 0xA2 L3 name-string tag | +--> 0x30 L3-1 name-string (SEQUENCE OF KerberosString) | +--> 0x1B L4[1] value (KerberosString) | +--> 0x1B L4[2] value (KerberosString) | ... | +--> 0x1B L4[n] value (KerberosString)

Specified by:
computeLength in interface org.apache.directory.shared.asn1.Asn1Object
Specified by:
computeLength in class org.apache.directory.shared.asn1.AbstractAsn1Object

encode

public java.nio.ByteBuffer encode(java.nio.ByteBuffer buffer)
                           throws org.apache.directory.shared.asn1.codec.EncoderException
Encode the PrincipalName message to a PDU. PrincipalName : 0x30 LL 0xA0 LL 0x02 0x01 name-type (integer) 0xA1 LL 0x30 LL name-string (SEQUENCE OF KerberosString) 0x1B LL name-string[1] 0x1B LL name-string[2] ... 0x1B LL name-string[n]

Specified by:
encode in interface org.apache.directory.shared.asn1.Asn1Object
Overrides:
encode in class org.apache.directory.shared.asn1.AbstractAsn1Object
Parameters:
buffer - The buffer where to put the PDU. It should have been allocated before, with the right size.
Returns:
The constructed PDU.
Throws:
org.apache.directory.shared.asn1.codec.EncoderException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()


Copyright © 2003-2009 Apache Software Foundation. All Rights Reserved.