be.cardon.cryptoapi
Class CAPIPrivateKey

java.lang.Object
  extended by be.cardon.cryptoapi.CAPIPrivateKey

public class CAPIPrivateKey
extends java.lang.Object


Constructor Summary
CAPIPrivateKey(CAPICertificate cert, char[] password)
          Creates a new instance of CAPIPrivateKey, with the given Certificate Context handle, and no flag.
CAPIPrivateKey(CAPICertificate cert, int dwFlags, char[] password)
          Creates a new instance of CAPIPrivateKey, with the given Certificate Context handle, and the given flags.
 
Method Summary
 CAPIHash createHash(int alg)
          Create hash with the given algorithm
 int dwKeySpec()
           
 void finalize()
           
 java.lang.String getPasswordEncoding()
          Returns the encoding used to convert char[] password to byte.
 int hCryptProv()
           
 void setPasswordEncoding(java.lang.String encoding)
          Set the encoding used to convert char[] password to byte.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CAPIPrivateKey

public CAPIPrivateKey(CAPICertificate cert,
                      int dwFlags,
                      char[] password)
               throws CryptoAPIException
Creates a new instance of CAPIPrivateKey, with the given Certificate Context handle, and the given flags.

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.

CAPIPrivateKey

public CAPIPrivateKey(CAPICertificate cert,
                      char[] password)
               throws CryptoAPIException
Creates a new instance of CAPIPrivateKey, with the given Certificate Context handle, and no flag.

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

createHash

public CAPIHash createHash(int alg)
                    throws CryptoAPIException
Create hash with the given algorithm

Throws:
CryptoAPIException

finalize

public void finalize()
              throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

hCryptProv

public int hCryptProv()

dwKeySpec

public int dwKeySpec()

getPasswordEncoding

public java.lang.String getPasswordEncoding()
Returns the encoding used to convert char[] password to byte.


setPasswordEncoding

public void setPasswordEncoding(java.lang.String encoding)
Set the encoding used to convert char[] password to byte.