javax.security.auth.kerberos
Class KerberosKey

java.lang.Object
  extended by javax.security.auth.kerberos.KerberosKey
All Implemented Interfaces:
Serializable, Key, SecretKey, Destroyable

public class KerberosKey
extends Object
implements Serializable, SecretKey, Destroyable

This class represents a Kerberos key. See the Kerberos authentication RFC for more information: RFC 1510.

Since:
1.4
See Also:
Serialized Form

Constructor Summary
KerberosKey(KerberosPrincipal principal, byte[] key, int type, int version)
          Construct a new key with the indicated principal and key.
KerberosKey(KerberosPrincipal principal, char[] passwd, String algo)
          Construct a new key with the indicated principal and a password.
 
Method Summary
 void destroy()
          Destroy this key.
 String getAlgorithm()
          Return the name of the algorithm used to create this key.
 byte[] getEncoded()
          Return the encoded form of this key.
 String getFormat()
          Return the format of this key.
 int getKeyType()
          Return the type of this key.
 KerberosPrincipal getPrincipal()
          Return the principal associated with this key.
 int getVersionNumber()
          Return the version number of this key.
 boolean isDestroyed()
          Return true if this key has been destroyed.
 String toString()
          Convert this Object to a human-readable String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

KerberosKey

public KerberosKey(KerberosPrincipal principal,
                   byte[] key,
                   int type,
                   int version)
Construct a new key with the indicated principal and key.

Parameters:
principal - the principal
key - the key's data
type - the key's type
version - the key's version number

KerberosKey

public KerberosKey(KerberosPrincipal principal,
                   char[] passwd,
                   String algo)
            throws NotImplementedException
Construct a new key with the indicated principal and a password.

Parameters:
principal - the principal
passwd - the password to use
algo - the algorithm; if null the "DES" algorithm is used
Throws:
NotImplementedException
Method Detail

getAlgorithm

public final String getAlgorithm()
Return the name of the algorithm used to create this key.

Specified by:
getAlgorithm in interface Key
Returns:
the name of the algorithm in use

getFormat

public final String getFormat()
Return the format of this key. This implementation always returns "RAW".

Specified by:
getFormat in interface Key
Returns:
the name of the encoding format for this key, or null

getPrincipal

public final KerberosPrincipal getPrincipal()
Return the principal associated with this key.


getKeyType

public final int getKeyType()
Return the type of this key.


getVersionNumber

public final int getVersionNumber()
Return the version number of this key.


getEncoded

public final byte[] getEncoded()
Return the encoded form of this key.

Specified by:
getEncoded in interface Key
Returns:
the encoded form of the key, or null

destroy

public void destroy()
             throws DestroyFailedException
Destroy this key.

Specified by:
destroy in interface Destroyable
Throws:
DestroyFailedException - If this object could not be destroyed.

isDestroyed

public boolean isDestroyed()
Return true if this key has been destroyed. After this has been called, other methods on this object will throw IllegalStateException.

Specified by:
isDestroyed in interface Destroyable
Returns:
True if this object has been destroyed.

toString

public String toString()
Description copied from class: Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() and such.

It is typical, but not required, to ensure that this method never completes abruptly with a RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).

Overrides:
toString in class Object
Returns:
the String representing this Object, which may be null
See Also:
Object.getClass(), Object.hashCode(), Class.getName(), Integer.toHexString(int)