Class EncryptionKey
java.lang.Object
javax.security.auth.kerberos.EncryptionKey
- All Implemented Interfaces:
Serializable
,Key
,SecretKey
,Destroyable
This class encapsulates an EncryptionKey used in Kerberos.
An EncryptionKey is defined in Section 4.2.9 of the Kerberos Protocol Specification (RFC 4120) as:
EncryptionKey ::= SEQUENCE { keytype [0] Int32 -- actually encryption type --, keyvalue [1] OCTET STRING }The key material of an
EncryptionKey
is defined as the value
of the keyValue
above.- Since:
- 9
- See Also:
-
Constructor Summary
ConstructorDescriptionEncryptionKey
(byte[] keyBytes, int keyType) Constructs anEncryptionKey
from the given bytes and the key type. -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
Destroys this key by clearing out the key material of this key.boolean
Compares the specified object with this key for equality.Returns the standard algorithm name for this key.byte[]
Returns the key material of this key.Returns the name of the encoding format for this key.int
Returns the key type for this key.int
hashCode()
Returns a hash code for thisEncryptionKey
.toString()
Returns an informative textual representation of thisEncryptionKey
.Methods declared in class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods declared in interface javax.security.auth.Destroyable
isDestroyed
-
Constructor Details
-
EncryptionKey
public EncryptionKey(byte[] keyBytes, int keyType) Constructs anEncryptionKey
from the given bytes and the key type.The contents of the byte array are copied; subsequent modification of the byte array does not affect the newly created key.
- Parameters:
keyBytes
- the key material for the keykeyType
- the key type for the key as defined by the Kerberos protocol specification.- Throws:
NullPointerException
- if keyBytes is null
-
-
Method Details
-
getKeyType
public int getKeyType()Returns the key type for this key.- Returns:
- the key type.
- Throws:
IllegalStateException
- if the key is destroyed
-
getAlgorithm
Returns the standard algorithm name for this key. The algorithm names are the encryption type string defined on the IANA Kerberos Encryption Type Numbers page.This method can return the following value not defined on the IANA page:
- none: for etype equal to 0
- unknown: for etype greater than 0 but unsupported by the implementation
- private: for etype smaller than 0
- Specified by:
getAlgorithm
in interfaceKey
- Returns:
- the name of the algorithm associated with this key.
- Throws:
IllegalStateException
- if the key is destroyed- External Specifications
-
getFormat
Returns the name of the encoding format for this key.- Specified by:
getFormat
in interfaceKey
- Returns:
- the String "RAW"
- Throws:
IllegalStateException
- if the key is destroyed
-
getEncoded
public byte[] getEncoded()Returns the key material of this key.- Specified by:
getEncoded
in interfaceKey
- Returns:
- a newly allocated byte array that contains the key material
- Throws:
IllegalStateException
- if the key is destroyed
-
destroy
Destroys this key by clearing out the key material of this key.- Specified by:
destroy
in interfaceDestroyable
- Throws:
DestroyFailedException
- if some error occurs while destroying this key.
-
toString
-
hashCode
-
equals
Compares the specified object with this key for equality. Returns true if the given object is also anEncryptionKey
and the twoEncryptionKey
instances are equivalent. More formally twoEncryptionKey
instances are equal if they have equal key types and key material. A destroyedEncryptionKey
object is only equal to itself.
-