be.cardon.cryptoapi.provider
Class CryptoAPIPrivateKey

java.lang.Object
  extended by be.cardon.cryptoapi.provider.CryptoAPIPrivateKey
All Implemented Interfaces:
java.io.Serializable, java.security.Key, java.security.PrivateKey

public class CryptoAPIPrivateKey
extends java.lang.Object
implements java.security.PrivateKey

CrypoAPI Private Key

See Also:
Serialized Form

Field Summary
static java.lang.String CryptoAPIKeyFormat
          Constant String to indentify a cryptoAPI Key.
 
Fields inherited from interface java.security.PrivateKey
serialVersionUID
 
Constructor Summary
CryptoAPIPrivateKey(CAPICertificate CAPIcert, char[] password)
          Creates a new instance of CryptoAPIPrivateKey WARNING !
 
Method Summary
 java.lang.String getAlgorithm()
          Returns the standard algorithm name for this key.
 CAPIPrivateKey getCAPIPrivateKey()
           
 byte[] getEncoded()
          NOT EXCTRACTIBLE : Returns null.
 java.lang.String getFormat()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CryptoAPIKeyFormat

public static java.lang.String CryptoAPIKeyFormat
Constant String to indentify a cryptoAPI Key.

Constructor Detail

CryptoAPIPrivateKey

public CryptoAPIPrivateKey(CAPICertificate CAPIcert,
                           char[] password)
                    throws CryptoAPIException
Creates a new instance of CryptoAPIPrivateKey

WARNING !

The password should be null. This is the default case. The CSP (cryptographic service provider) will display a window (PIN, or other) to the user if needed.

You can also give a password (PIN) programatically. The CSP MUST support the function CryptoAPI function CryptSetProvParam with PP_SIGNATURE_PIN or PP_KEYEXCHANGE_PIN. Most CSP like the Microsoft Basic CSP or the Belgian eid middleware doesn't support this function. The CSP from 'Nexus Personal' has been tested with that. All CSP supporting Smard Card Windows logon should support this function.

.

The password doesn't support Unicode (CryptoAPI use byte[], not char[]). In the future, we will create a property to choose the encoding for password.

Throws:
CryptoAPIException - if the CryptSetProvParam function is not supported for PIN (PINNotSupportedException), or other error.
Method Detail

getAlgorithm

public java.lang.String getAlgorithm()
Returns the standard algorithm name for this key.

Specified by:
getAlgorithm in interface java.security.Key

getEncoded

public byte[] getEncoded()
NOT EXCTRACTIBLE : Returns null. Returns the key in its primary encoding format, or null if this key does not support encoding.

Specified by:
getEncoded in interface java.security.Key

getFormat

public java.lang.String getFormat()
Specified by:
getFormat in interface java.security.Key

getCAPIPrivateKey

public CAPIPrivateKey getCAPIPrivateKey()