org.opensc.pkcs11.wrap
Class PKCS11PrivateKey

java.lang.Object
  extended by org.opensc.util.DestroyableChild
      extended by org.opensc.pkcs11.wrap.PKCS11Object
          extended by org.opensc.pkcs11.wrap.PKCS11Key
              extended by org.opensc.pkcs11.wrap.PKCS11PrivateKey
All Implemented Interfaces:
Serializable, Key, PrivateKey, Destroyable, PKCS11SessionChild
Direct Known Subclasses:
PKCS11DSAPrivateKey, PKCS11NeDSAPrivateKey, PKCS11NeRSAPrivateKey, PKCS11RSAPrivateKey

public class PKCS11PrivateKey
extends PKCS11Key
implements PrivateKey

Author:
wglas This class represents a private key stored on a hardware token.
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.opensc.pkcs11.wrap.PKCS11Object
CKA_AC_ISSUER, CKA_ALWAYS_SENSITIVE, CKA_APPLICATION, CKA_ATTR_TYPES, CKA_BASE, CKA_CERTIFICATE_CATEGORY, CKA_CERTIFICATE_TYPE, CKA_CHECK_VALUE, CKA_CLASS, CKA_COEFFICIENT, CKA_DECRYPT, CKA_DERIVE, CKA_ENCRYPT, CKA_END_DATE, CKA_EXPONENT_1, CKA_EXPONENT_2, CKA_EXTRACTABLE, CKA_HASH_OF_ISSUER_PUBLIC_KEY, CKA_HASH_OF_SUBJECT_PUBLIC_KEY, CKA_ID, CKA_ISSUER, CKA_JAVA_MIDP_SECURITY_DOMAIN, CKA_KEY_TYPE, CKA_LABEL, CKA_LOCAL, CKA_MODULUS, CKA_MODULUS_BITS, CKA_NEVER_EXTRACTABLE, CKA_OBJECT_ID, CKA_OWNER, CKA_PRIME, CKA_PRIME_1, CKA_PRIME_2, CKA_PRIME_BITS, CKA_PRIVATE, CKA_PRIVATE_EXPONENT, CKA_PUBLIC_EXPONENT, CKA_SENSITIVE, CKA_SERIAL_NUMBER, CKA_SIGN, CKA_SIGN_RECOVER, CKA_START_DATE, CKA_SUB_PRIME_BITS, CKA_SUBJECT, CKA_SUBPRIME, CKA_TOKEN, CKA_TRUSTED, CKA_UNWRAP, CKA_URL, CKA_VALUE, CKA_VALUE_BITS, CKA_VALUE_LEN, CKA_VERIFY, CKA_VERIFY_RECOVER, CKA_WRAP, CKO_CERTIFICATE, CKO_PRIVATE_KEY, CKO_PUBLIC_KEY, CKO_SECRET_KEY, handle, hsession, pvh, shandle
 
Constructor Summary
protected PKCS11PrivateKey(PKCS11Session session, int type, boolean extractable, long handle)
           
 
Method Summary
 String getFormat()
           
static List<PKCS11PrivateKey> getPrivateKeys(PKCS11Session session)
          Fetches all private keys stored in the specified slot.
 boolean isExtractable()
           
 boolean isSensitive()
           
 
Methods inherited from class org.opensc.pkcs11.wrap.PKCS11Key
getAlgorithm, getEncoded, getKeyBits, getKeyType
 
Methods inherited from class org.opensc.pkcs11.wrap.PKCS11Object
destroy, enumRawObjects, getAllowedMechanisms, getBooleanAttribute, getBooleanAttribute, getHandle, getId, getLabel, getProvider, getPvh, getRawAttribute, getSessionHandle, getSlotHandle, getULongAttribute, getULongAttribute
 
Methods inherited from class org.opensc.util.DestroyableChild
getParent, isDestroyed, unlink
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.security.Key
getAlgorithm, getEncoded
 
Methods inherited from interface javax.security.auth.Destroyable
isDestroyed
 

Constructor Detail

PKCS11PrivateKey

protected PKCS11PrivateKey(PKCS11Session session,
                           int type,
                           boolean extractable,
                           long handle)
                    throws PKCS11Exception
Parameters:
session - The session to which this key belongs.
handle - The handle as returned by @see PKCS11Object#enumRawObjects(PKCS11Session, int).
Throws:
PKCS11Exception
Method Detail

getPrivateKeys

public static List<PKCS11PrivateKey> getPrivateKeys(PKCS11Session session)
                                             throws PKCS11Exception
Fetches all private keys stored in the specified slot.

Parameters:
session - The session of which to find the certificates.
Returns:
The list of all private keys found in this slot.
Throws:
PKCS11Exception - Upon errors from the underlying PKCS11 module.

getFormat

public String getFormat()
Specified by:
getFormat in interface Key
Overrides:
getFormat in class PKCS11Key

isExtractable

public boolean isExtractable()
Returns:
Returns whether the key is extractable.

isSensitive

public boolean isSensitive()
Returns:
Returns whether the key is extractable.