A KerberosKey object includes an EncryptionKey, a
KerberosPrincipal as its owner, and the version number
of the key.
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 a KerberosKey is defined as the value
of the keyValue above.
All Kerberos JAAS login modules that obtain a principal's password and
generate the secret key from it should use this class.
Sometimes, such as when authenticating a server in
the absence of user-to-user authentication, the login module will store
an instance of this class in the private credential set of a
Subject during the commit phase of the
authentication process.
A Kerberos service using a keytab to read secret keys should use
the KeyTab class, where latest keys can be read when needed.
When creating a KerberosKey using the
KerberosKey(KerberosPrincipal, char[], String) constructor,
an implementation may accept non-IANA algorithm names (For example,
"ArcFourMac" for "rc4-hmac"), but the getAlgorithm method
must always return the IANA algorithm name.
Implementation Note
Old algorithm names used before JDK 9 are supported in the
KerberosKey(KerberosPrincipal, char[], String) constructor in this
implementation for compatibility reasons, which are "DES" (and null) for
"des-cbc-md5", "DESede" for "des3-cbc-sha1-kd", "ArcFourHmac" for "rc4-hmac",
"AES128" for "aes128-cts-hmac-sha1-96", and "AES256" for
"aes256-cts-hmac-sha1-96".
| Modifier and Type | Field and Description |
|---|---|
| private transient boolean | |
| private final KeyImpl | key
|
| private KerberosPrincipal | principal
The principal that this secret key belongs to. |
| private static final long | |
| private final int | versionNum
the version number of this secret key |
| Access | Constructor and Description |
|---|---|
| public | KerberosKey(KerberosPrincipal
the principal that this secret key belongs to principal, byte[] the key material for the secret key keyBytes, int the key type for the secret key as defined by the
Kerberos protocol specification. keyType, int the version number of this secret key versionNum)Constructs a |
| public | KerberosKey(KerberosPrincipal
the principal that this password belongs to principal, char[] the password that should be used to compute the key password, String the name for the algorithm that this key will be
used for algorithm)Constructs a |
| Modifier and Type | Method and Description |
|---|---|
| public void | destroy()
Overrides default javax. Destroys this key by clearing out the key material of this secret key. |
| public boolean | Returns: true if the specified object is equal to thisKerberosKey,
false otherwise.the object to compare to other)Overrides java. Compares the specified object with this |
| public final String | Returns: the name of the algorithm associated with this key.Implements java. Returns the standard algorithm name for this key. |
| public final byte[] | Returns: the key materialImplements java. Returns the key material of this secret key. |
| public final String | Returns: the String "RAW"Implements java. Returns the name of the encoding format for this secret key. |
| public final int | |
| public final KerberosPrincipal | Returns: the principal this key belongs to.Returns the principal that this key belongs to. |
| public final int | |
| public int | Returns: a hash code for thisKerberosKeyOverrides java. Returns a hash code for this |
| public boolean | isDestroyed()
Overrides default javax. Determines if this key has been destroyed. |
| public String | Returns: an informative textual representation of thisKerberosKey.Overrides java. Returns an informative textual representation of this |
| destroyed | back to summary |
|---|---|
| private transient boolean destroyed | |
| key | back to summary |
|---|---|
| private final KeyImpl key
| |
| principal | back to summary |
|---|---|
| private KerberosPrincipal principal The principal that this secret key belongs to. | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides javax. | |
| versionNum | back to summary |
|---|---|
| private final int versionNum the version number of this secret key | |
| KerberosKey | back to summary |
|---|---|
| public KerberosKey(KerberosPrincipal principal, byte[] keyBytes, int keyType, int versionNum) Constructs a
| |
| KerberosKey | back to summary |
|---|---|
| public KerberosKey(KerberosPrincipal principal, char[] password, String algorithm) Constructs a
| |
| destroy | back to summary |
|---|---|
| public void destroy() throws DestroyFailedException Overrides default javax. Destroys this key by clearing out the key material of this secret key.
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Compares the specified object with this | |
| getAlgorithm | back to summary |
|---|---|
| public final String getAlgorithm() Implements java. 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:
| |
| getEncoded | back to summary |
|---|---|
| public final byte[] getEncoded() Implements java. Returns the key material of this secret key.
| |
| getFormat | back to summary |
|---|---|
| public final String getFormat() Implements java. Returns the name of the encoding format for this secret key.
| |
| getKeyType | back to summary |
|---|---|
| public final int getKeyType() Returns the key type for this long-term key.
| |
| getPrincipal | back to summary |
|---|---|
| public final KerberosPrincipal getPrincipal() Returns the principal that this key belongs to.
| |
| getVersionNumber | back to summary |
|---|---|
| public final int getVersionNumber() Returns the key version number.
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Returns a hash code for this
| |
| isDestroyed | back to summary |
|---|---|
| public boolean isDestroyed() Overrides default javax. Determines if this key has been destroyed. | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Returns an informative textual representation of this
| |