org.apache.directory.shared.kerberos.components
Class EncryptedData

java.lang.Object
  extended by org.apache.directory.shared.asn1.AbstractAsn1Object
      extended by org.apache.directory.shared.kerberos.components.EncryptedData
All Implemented Interfaces:
org.apache.directory.shared.asn1.Asn1Object
Direct Known Subclasses:
PaEncTimestamp

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

A structure storing an encrypted data element. The ASN.1 grammar is :

 EncryptedData   ::= SEQUENCE {
        etype   [0] Int32 -- EncryptionType --,
        kvno    [1] UInt32 OPTIONAL,
        cipher  [2] OCTET STRING -- ciphertext
 }

Author:
Apache Directory Project

Field Summary
static boolean HAS_KVNO
          A constant used when the key is not present
 
Constructor Summary
EncryptedData()
          Creates a new instance of EncryptedData.
EncryptedData(EncryptionType eType, byte[] cipher)
          Creates a new instance of EncryptedData.
EncryptedData(EncryptionType eType, int kvno, byte[] cipher)
          Creates a new instance of EncryptedData.
 
Method Summary
 int computeLength()
          Compute the EncryptedData length
 ByteBuffer encode(ByteBuffer buffer)
          Encode the EncryptedData message to a PDU.
 boolean equals(Object obj)
          
 byte[] getCipher()
          Returns the raw cipher text.
 EncryptionType getEType()
          Returns the EncryptionType.
 int getKvno()
          Returns the key version.
 int hashCode()
          
 boolean hasKvno()
          Tells if there is a key version.
 void setCipher(byte[] cipher)
          Set the cipher text
 void setEType(EncryptionType eType)
          Set the EncryptionType
 void setKvno(int kvno)
          Set the key version
 String toString()
           
 String toString(String tabs)
           
 
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, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

HAS_KVNO

public static final boolean HAS_KVNO
A constant used when the key is not present

See Also:
Constant Field Values
Constructor Detail

EncryptedData

public EncryptedData()
Creates a new instance of EncryptedData.


EncryptedData

public EncryptedData(EncryptionType eType,
                     int kvno,
                     byte[] cipher)
Creates a new instance of EncryptedData.

Parameters:
eType - The encription algorithm
kvno - The key version
cipher - the encrypted text

EncryptedData

public EncryptedData(EncryptionType eType,
                     byte[] cipher)
Creates a new instance of EncryptedData.

Parameters:
eType - The encription algorithm
cipher - the encrypted text
Method Detail

getEType

public EncryptionType getEType()
Returns the EncryptionType.

Returns:
The EncryptionType.

setEType

public void setEType(EncryptionType eType)
Set the EncryptionType

Parameters:
eType - the EncryptionType

getKvno

public int getKvno()
Returns the key version.

Returns:
The key version.

setKvno

public void setKvno(int kvno)
Set the key version

Parameters:
kvno - The key version

hasKvno

public boolean hasKvno()
Tells if there is a key version.

Returns:
true if there is a key version.

getCipher

public byte[] getCipher()
Returns the raw cipher text.

Returns:
The raw cipher text.

setCipher

public void setCipher(byte[] cipher)
Set the cipher text

Parameters:
cipher - The cipher text

computeLength

public int computeLength()
Compute the EncryptedData length
 EncryptedData :
 
 0x30 L1 EncryptedData sequence
  |
  +--> 0xA1 L2 etype tag
  |     |
  |     +--> 0x02 L2-1 etype (int)
  |
  +--> [0xA2 L3 kvno tag
  |     |
  |     +--> 0x30 L3-1 kvno (int)] (optional)
  |
  +--> 0xA2 L4 cipher tag
        |
        +--> 0x04 L4-1 cipher (OCTET STRING)
 


encode

public ByteBuffer encode(ByteBuffer buffer)
                  throws org.apache.directory.shared.asn1.EncoderException
Encode the EncryptedData message to a PDU.
 EncryptedData :
 
 0x30 LL
   0xA0 LL 
     0x02 0x01 etype (integer)
   [0xA1 LL 
     0x02 0x01 kvno (integer)] (optional)
   0xA2 LL 
     0x04 LL cipher (OCTET STRING)
 

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.EncoderException

hashCode

public int hashCode()

Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)

Overrides:
equals in class Object

toString

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

toString

public String toString(String tabs)
See Also:
Object.toString()


Copyright © 2003-2012 The Apache Software Foundation. All Rights Reserved.