org.hardtokenmgmt.core.token
Class SetCos431InstantEIDToken

java.lang.Object
  extended by org.hardtokenmgmt.core.token.BaseToken
      extended by org.hardtokenmgmt.core.token.SetCos431InstantEIDToken
All Implemented Interfaces:
IToken
Direct Known Subclasses:
NetIdSetCos431Token

public class SetCos431InstantEIDToken
extends BaseToken

A Base Token implementation that contains generic operations on token that can be reused by most token implementations

Version:
$Id$
Author:
Philip Vendil 2006-aug-30

Field Summary
 
Fields inherited from class org.hardtokenmgmt.core.token.BaseToken
MAXNUMOBJECTS, tokens
 
Fields inherited from interface org.hardtokenmgmt.core.token.IToken
KEYALG_RSA, KEYTYPE_ALL, KEYTYPE_AUTH, KEYTYPE_ENC, KEYTYPE_SIGN, OBJECTTYPE_DATA, PINTYPE_BASIC, PINTYPE_SIGN
 
Constructor Summary
SetCos431InstantEIDToken()
           
 
Method Summary
 void clearToken(java.lang.String[] pintypes, java.lang.String[] puks)
          Method to use with the Setec 431 cards.
 void downloadKeyStore(java.lang.String keytype, java.lang.String pintype, java.lang.String pin, java.lang.String certLabel, java.security.KeyStore keyStore, java.lang.String keyStorePasswd)
          Method that downloads a keystores key and certificate on the token.
 java.lang.String generatePUK(java.lang.String pintype)
          Method that should generate the PUK code placed on the card for the specified PIN.
 void genKey(java.lang.String pintype, java.lang.String pin, java.lang.String basicpin, java.lang.String keytype, java.lang.String algorithm, int keysize, java.lang.String label)
          Method that should generate a key on the card with the specified algorithm.
protected  java.lang.String getPINLabel(iaik.pkcs.pkcs11.Token token, java.lang.String pintype)
          Method that should return the label of the tokens virtual slot that is associated with the given pintype.
protected  java.lang.String getPrivateKeyLabel(java.lang.String keytype)
          Method that should find the right key label given the keytype.
 java.lang.String[] getSupportedPINTypes()
          Method that should return the tokens supported PIN types Either PINTYPE_ constants or customdefined labels
 void initToken(java.lang.String tokenlabel, java.lang.String tokenserial, java.lang.String[] pintypes, java.lang.String[] pins, java.lang.String[] puks)
          The Setcos 431 cards are not ereasable so the have to be cleared in the same way as the clear method.
protected  boolean isInitialized(iaik.pkcs.pkcs11.Token token)
          Method that should return true if the token is currently initialized.
 boolean isTokenSupported(iaik.pkcs.pkcs11.Token token)
          Method used for knowing if an implementation supports the current token in process.
 void removeKey(java.lang.String pintype, java.lang.String pin, java.lang.String basicpin, java.lang.String label)
          Method removing a specified key from a card
 boolean requirePUKInDB()
          Method determining if the token requires the PUK to be uploaded to DB prior to initialization This is mainly for tokens that cannot be reformatted.
 
Methods inherited from class org.hardtokenmgmt.core.token.BaseToken
addObject, blockPIN, changePIN, checkPIN, clearCertificateCache, downloadCert, genPKCS10, getCertificate, getCertificates, getHardTokenSN, getKeyLabels, getObjects, getPINInfo, getSlotId, init, reInitToken, removeAllKeys, removeCertificate, removeObject, unblockPIN, unlockPIN
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SetCos431InstantEIDToken

public SetCos431InstantEIDToken()
Method Detail

isTokenSupported

public boolean isTokenSupported(iaik.pkcs.pkcs11.Token token)
                         throws iaik.pkcs.pkcs11.TokenException
Description copied from interface: IToken
Method used for knowing if an implementation supports the current token in process.

Parameters:
token - the current token inserted into the slot.
Returns:
true if the current IToken implementation supports this token.
Throws:
iaik.pkcs.pkcs11.TokenException - if a pkcs11 related problem occurs

getSupportedPINTypes

public java.lang.String[] getSupportedPINTypes()
Description copied from interface: IToken
Method that should return the tokens supported PIN types Either PINTYPE_ constants or customdefined labels


initToken

public void initToken(java.lang.String tokenlabel,
                      java.lang.String tokenserial,
                      java.lang.String[] pintypes,
                      java.lang.String[] pins,
                      java.lang.String[] puks)
               throws OperationNotSupportedException,
                      iaik.pkcs.pkcs11.TokenException
The Setcos 431 cards are not ereasable so the have to be cleared in the same way as the clear method.

Parameters:
tokenlabel - the label of the token, can be null if no token label should be set.
tokenserial - the serial number that should be written to the card, only used if the card supports the serial number to be set during initialization otherwise could null be used.
pintypes - an array of PINTYPE_contants or custom label strings. Indicates which key that should have which PIN and PUK
pins - an array of pin codes used in the initialization, should be used with the keytype array get hold of key to use. be defined in the getKeyIndex type.
puks - an array of puk codes for each PIN
Throws:
OperationNotSupportedException - if this operation or some of it's parameters isn't supported
iaik.pkcs.pkcs11.TokenException - for other token related failures.

clearToken

public void clearToken(java.lang.String[] pintypes,
                       java.lang.String[] puks)
                throws OperationNotSupportedException,
                       iaik.pkcs.pkcs11.TokenException
Method to use with the Setec 431 cards. It removes all dataobjects, then removes all Certificates then sets all pins to a default value defined in global.properties.

Parameters:
pintypes - optional parameter used by some cards with non-erasable filesystem and needs the PUK code to erease some areas. Should contain an array of PINTYPE_contants or custom label strings
puks - optional parameter used by some cards with non-erasable filesystem and needs the PUK code to erease some areas.
Throws:
OperationNotSupportedException - if this operation or some of it's parameters isn't supported
iaik.pkcs.pkcs11.TokenException - for other token related failures.

getPrivateKeyLabel

protected java.lang.String getPrivateKeyLabel(java.lang.String keytype)
                                       throws OperationNotSupportedException
Description copied from class: BaseToken
Method that should find the right key label given the keytype.

Specified by:
getPrivateKeyLabel in class BaseToken
Parameters:
keytype - the keytype to find
Throws:
OperationNotSupportedException

getPINLabel

protected java.lang.String getPINLabel(iaik.pkcs.pkcs11.Token token,
                                       java.lang.String pintype)
                                throws OperationNotSupportedException,
                                       iaik.pkcs.pkcs11.TokenException
Description copied from class: BaseToken
Method that should return the label of the tokens virtual slot that is associated with the given pintype.

Specified by:
getPINLabel in class BaseToken
Returns:
The label of the token in the slot
Throws:
OperationNotSupportedException
iaik.pkcs.pkcs11.TokenException

downloadKeyStore

public void downloadKeyStore(java.lang.String keytype,
                             java.lang.String pintype,
                             java.lang.String pin,
                             java.lang.String certLabel,
                             java.security.KeyStore keyStore,
                             java.lang.String keyStorePasswd)
                      throws ObjectAlreadyExistsException,
                             OperationNotSupportedException,
                             iaik.pkcs.pkcs11.TokenException
Description copied from interface: IToken
Method that downloads a keystores key and certificate on the token.

Specified by:
downloadKeyStore in interface IToken
Overrides:
downloadKeyStore in class BaseToken
Parameters:
keytype - one of the KEYTYPE_ constants or the label of the object for custom keys
pintype - of the PIN needed to unlock the token
pin - the pin to unlock (May not be required, then can null be used)
certLabel - label the label used to mark the object on the token.
keyStore - the java keystore to extract the keystore from
keyStorePasswd - the passwordused to lock the keystore
Throws:
ObjectAlreadyExistsException - if a certificate or key with the label already exists.
OperationNotSupportedException - if this operation or some of it's parameters isn't supported
iaik.pkcs.pkcs11.TokenException - for other token related failures.
See Also:
IToken.downloadKeyStore(String, String, String, String, KeyStore, String)

genKey

public void genKey(java.lang.String pintype,
                   java.lang.String pin,
                   java.lang.String basicpin,
                   java.lang.String keytype,
                   java.lang.String algorithm,
                   int keysize,
                   java.lang.String label)
            throws ObjectAlreadyExistsException,
                   OperationNotSupportedException,
                   iaik.pkcs.pkcs11.TokenException
Description copied from interface: IToken
Method that should generate a key on the card with the specified algorithm.

Specified by:
genKey in interface IToken
Overrides:
genKey in class BaseToken
Parameters:
pintype - one of the PINTYPE_ indicating the PIN that should protect the key
pin - the pin to unlock (May not be required, then can null be used)
basicpin - pin to unlock the basic area, might be used for signature keys
keytype - one of the KEYTYPE_ constants or the label of the object for custom keys
algorithm - one of the KEYALG_ constants
keysize - the size of the key
label - a reference to the key to use.
Throws:
ObjectAlreadyExistsException - if the keytype already exists.
OperationNotSupportedException - if this operation or some of it's parameters isn't supported
iaik.pkcs.pkcs11.TokenException - for other token related failures.
See Also:
IToken.genKey(String, String, String, String, String, int, String)

removeKey

public void removeKey(java.lang.String pintype,
                      java.lang.String pin,
                      java.lang.String basicpin,
                      java.lang.String label)
               throws OperationNotSupportedException,
                      iaik.pkcs.pkcs11.TokenException
Description copied from interface: IToken
Method removing a specified key from a card

Specified by:
removeKey in interface IToken
Overrides:
removeKey in class BaseToken
Parameters:
pintype - of the PIN needed to unlock the token
pin - the pin to unlock (May not be required, then can null be used)
basicpin - pin to unlock the basic area, might be used for signature certificates
label - of the key
Throws:
OperationNotSupportedException - if this operation or some of it's parameters isn't supported
iaik.pkcs.pkcs11.TokenException - for other token related failures.
See Also:
IToken.removeKey(String, String, String, String)

requirePUKInDB

public boolean requirePUKInDB()
Description copied from interface: IToken
Method determining if the token requires the PUK to be uploaded to DB prior to initialization This is mainly for tokens that cannot be reformatted.

Returns:
'true' if PUK data must exist in database before card is managed. 'false' othervise.
See Also:
IToken.requirePUKInDB()

generatePUK

public java.lang.String generatePUK(java.lang.String pintype)
                             throws OperationNotSupportedException
Description copied from interface: IToken
Method that should generate the PUK code placed on the card for the specified PIN. Should only be used in the case requirePUKInDB is false and PUK codes should be generated during token initialization. This is mainly for tokens that cannot be reformatted.

Returns:
a valid PUK supported by the token
Throws:
OperationNotSupportedException - if this method isn't supported by this token.
See Also:
IToken.generatePUK(String)

isInitialized

protected boolean isInitialized(iaik.pkcs.pkcs11.Token token)
Description copied from class: BaseToken
Method that should return true if the token is currently initialized.

Specified by:
isInitialized in class BaseToken
Returns:
method that should return true if the token is currently initialized.