net.ninthtest.crypto.provider.helix
Class HelixSecretKeyFactory

java.lang.Object
  extended by javax.crypto.SecretKeyFactorySpi
      extended by net.ninthtest.crypto.provider.helix.HelixSecretKeyFactory

public final class HelixSecretKeyFactory
extends SecretKeyFactorySpi

A factory for building or retrieving Helix secret keys..

Version:
1.0
Author:
Matthew Zipay (mattz@ninthtest.info)

Constructor Summary
HelixSecretKeyFactory()
          Creates a new HelixSecretKeyFactory and performs the provider self-integrity check.
 
Method Summary
protected  SecretKey engineGenerateSecret(KeySpec keySpec)
          Generates a SecretKey object from the provided key specification (key material).
protected  KeySpec engineGetKeySpec(SecretKey key, Class keySpec)
          Returns a specification (key material) of the given key object in the requested format.
protected  SecretKey engineTranslateKey(SecretKey key)
          Translates a key object, whose provider may be unknown or potentially untrusted, into a corresponding key object of this secret-key factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HelixSecretKeyFactory

public HelixSecretKeyFactory()
Creates a new HelixSecretKeyFactory and performs the provider self-integrity check.

Method Detail

engineGenerateSecret

protected SecretKey engineGenerateSecret(KeySpec keySpec)
                                  throws InvalidKeySpecException
Generates a SecretKey object from the provided key specification (key material).

Specified by:
engineGenerateSecret in class SecretKeyFactorySpi
Parameters:
keySpec - the Helix secret key material (must be a HelixKeySpec )
Returns:
a Helix secret key
Throws:
InvalidKeySpecException - if keySpec is null or not a HelixKeySpec
See Also:
SecretKeyFactorySpi.engineGenerateSecret(java.security.spec.KeySpec)

engineGetKeySpec

protected KeySpec engineGetKeySpec(SecretKey key,
                                   Class keySpec)
                            throws InvalidKeySpecException
Returns a specification (key material) of the given key object in the requested format.

Specified by:
engineGetKeySpec in class SecretKeyFactorySpi
Parameters:
key - a Helix secret key
keySpec - specifies the format for the secret key material
Returns:
the key material for the Helix secret key
Throws:
InvalidKeySpecException - if key is null or not a Helix secret key in "RAW" format; or if keySpec is null or not the class of HelixKeySpec); or if an error occurs while creating the HelixKeySpec from the secret key
See Also:
SecretKeyFactorySpi.engineGetKeySpec(javax.crypto.SecretKey, java.lang.Class)

engineTranslateKey

protected SecretKey engineTranslateKey(SecretKey key)
                                throws InvalidKeyException
Translates a key object, whose provider may be unknown or potentially untrusted, into a corresponding key object of this secret-key factory.

Only the first 32 bytes from key are used in the translation.

Specified by:
engineTranslateKey in class SecretKeyFactorySpi
Parameters:
key - a secret key (presumably not a Helix secret key)
Returns:
a Helix secret key
Throws:
InvalidKeyException - if key is null; or if key cannot be used to create a Helix secret key
See Also:
SecretKeyFactorySpi.engineTranslateKey(javax.crypto.SecretKey)


Copyright © 2010-2014 Matthew Zipay. All Rights Reserved.