org.opensc.pkcs11.wrap
Class PKCS11Exception

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.io.IOException
              extended by org.opensc.pkcs11.wrap.PKCS11Exception
All Implemented Interfaces:
Serializable

public class PKCS11Exception
extends IOException

An excpetion thrown upon wvarious PKCS errors.

Author:
wglas
See Also:
Serialized Form

Field Summary
static int CKR_ARGUMENTS_BAD
           
static int CKR_ATTRIBUTE_READ_ONLY
           
static int CKR_ATTRIBUTE_SENSITIVE
           
static int CKR_ATTRIBUTE_TYPE_INVALID
           
static int CKR_ATTRIBUTE_VALUE_INVALID
           
static int CKR_BUFFER_TOO_SMALL
           
static int CKR_CANCEL
           
static int CKR_CANT_LOCK
           
static int CKR_CRYPTOKI_ALREADY_INITIALIZED
           
static int CKR_CRYPTOKI_NOT_INITIALIZED
           
static int CKR_DATA_INVALID
           
static int CKR_DATA_LEN_RANGE
           
static int CKR_DEVICE_ERROR
           
static int CKR_DEVICE_MEMORY
           
static int CKR_DEVICE_REMOVED
           
static int CKR_DOMAIN_PARAMS_INVALID
           
static int CKR_ENCRYPTED_DATA_INVALID
           
static int CKR_ENCRYPTED_DATA_LEN_RANGE
           
static int CKR_FUNCTION_CANCELED
           
static int CKR_FUNCTION_FAILED
           
static int CKR_FUNCTION_NOT_PARALLEL
           
static int CKR_FUNCTION_NOT_SUPPORTED
           
static int CKR_FUNCTION_REJECTED
           
static int CKR_GENERAL_ERROR
           
static int CKR_HOST_MEMORY
           
static int CKR_INFORMATION_SENSITIVE
           
static int CKR_KEY_CHANGED
           
static int CKR_KEY_FUNCTION_NOT_PERMITTED
           
static int CKR_KEY_HANDLE_INVALID
           
static int CKR_KEY_INDIGESTIBLE
           
static int CKR_KEY_NEEDED
           
static int CKR_KEY_NOT_NEEDED
           
static int CKR_KEY_NOT_WRAPPABLE
           
static int CKR_KEY_SIZE_RANGE
           
static int CKR_KEY_TYPE_INCONSISTENT
           
static int CKR_KEY_UNEXTRACTABLE
           
static int CKR_MECHANISM_INVALID
           
static int CKR_MECHANISM_PARAM_INVALID
           
static int CKR_MUTEX_BAD
           
static int CKR_MUTEX_NOT_LOCKED
           
static int CKR_NEED_TO_CREATE_THREADS
           
static int CKR_NO_EVENT
           
static int CKR_OBJECT_HANDLE_INVALID
           
static int CKR_OK
           
static int CKR_OPERATION_ACTIVE
           
static int CKR_OPERATION_NOT_INITIALIZED
           
static int CKR_PIN_EXPIRED
           
static int CKR_PIN_INCORRECT
           
static int CKR_PIN_INVALID
           
static int CKR_PIN_LEN_RANGE
           
static int CKR_PIN_LOCKED
           
static int CKR_RANDOM_NO_RNG
           
static int CKR_RANDOM_SEED_NOT_SUPPORTED
           
static int CKR_SAVED_STATE_INVALID
           
static int CKR_SESSION_CLOSED
           
static int CKR_SESSION_COUNT
           
static int CKR_SESSION_EXISTS
           
static int CKR_SESSION_HANDLE_INVALID
           
static int CKR_SESSION_PARALLEL_NOT_SUPPORTED
           
static int CKR_SESSION_READ_ONLY
           
static int CKR_SESSION_READ_ONLY_EXISTS
           
static int CKR_SESSION_READ_WRITE_SO_EXISTS
           
static int CKR_SIGNATURE_INVALID
           
static int CKR_SIGNATURE_LEN_RANGE
           
static int CKR_SLOT_ID_INVALID
           
static int CKR_STATE_UNSAVEABLE
           
static int CKR_TEMPLATE_INCOMPLETE
           
static int CKR_TEMPLATE_INCONSISTENT
           
static int CKR_TOKEN_NOT_PRESENT
           
static int CKR_TOKEN_NOT_RECOGNIZED
           
static int CKR_TOKEN_WRITE_PROTECTED
           
static int CKR_UNWRAPPING_KEY_HANDLE_INVALID
           
static int CKR_UNWRAPPING_KEY_SIZE_RANGE
           
static int CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT
           
static int CKR_USER_ALREADY_LOGGED_IN
           
static int CKR_USER_ANOTHER_ALREADY_LOGGED_IN
           
static int CKR_USER_NOT_LOGGED_IN
           
static int CKR_USER_PIN_NOT_INITIALIZED
           
static int CKR_USER_TOO_MANY_TYPES
           
static int CKR_USER_TYPE_INVALID
           
static int CKR_WRAPPED_KEY_INVALID
           
static int CKR_WRAPPED_KEY_LEN_RANGE
           
static int CKR_WRAPPING_KEY_HANDLE_INVALID
           
static int CKR_WRAPPING_KEY_SIZE_RANGE
           
static int CKR_WRAPPING_KEY_TYPE_INCONSISTENT
           
 
Constructor Summary
PKCS11Exception()
          Construct a PKCS11 exception with no error message and an error code with the value CKR_GENERAL_ERROR.
PKCS11Exception(int errorCode, String msg)
          Construct a PKCS11 exception with the given error code and error message.
PKCS11Exception(String msg)
          Construct a PKCS11 exception with the given error message and an error code with the value CKR_GENERAL_ERROR.
PKCS11Exception(String msg, Exception e)
          Construct a PKCS11 exception with the given error message and originating exception.
 
Method Summary
 int getErrorCode()
           
 String getErrorCodeName()
           
static String getErrorCodeName(int errorCode)
           
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CKR_OK

public static final int CKR_OK
See Also:
Constant Field Values

CKR_CANCEL

public static final int CKR_CANCEL
See Also:
Constant Field Values

CKR_HOST_MEMORY

public static final int CKR_HOST_MEMORY
See Also:
Constant Field Values

CKR_SLOT_ID_INVALID

public static final int CKR_SLOT_ID_INVALID
See Also:
Constant Field Values

CKR_GENERAL_ERROR

public static final int CKR_GENERAL_ERROR
See Also:
Constant Field Values

CKR_FUNCTION_FAILED

public static final int CKR_FUNCTION_FAILED
See Also:
Constant Field Values

CKR_ARGUMENTS_BAD

public static final int CKR_ARGUMENTS_BAD
See Also:
Constant Field Values

CKR_NO_EVENT

public static final int CKR_NO_EVENT
See Also:
Constant Field Values

CKR_NEED_TO_CREATE_THREADS

public static final int CKR_NEED_TO_CREATE_THREADS
See Also:
Constant Field Values

CKR_CANT_LOCK

public static final int CKR_CANT_LOCK
See Also:
Constant Field Values

CKR_ATTRIBUTE_READ_ONLY

public static final int CKR_ATTRIBUTE_READ_ONLY
See Also:
Constant Field Values

CKR_ATTRIBUTE_SENSITIVE

public static final int CKR_ATTRIBUTE_SENSITIVE
See Also:
Constant Field Values

CKR_ATTRIBUTE_TYPE_INVALID

public static final int CKR_ATTRIBUTE_TYPE_INVALID
See Also:
Constant Field Values

CKR_ATTRIBUTE_VALUE_INVALID

public static final int CKR_ATTRIBUTE_VALUE_INVALID
See Also:
Constant Field Values

CKR_DATA_INVALID

public static final int CKR_DATA_INVALID
See Also:
Constant Field Values

CKR_DATA_LEN_RANGE

public static final int CKR_DATA_LEN_RANGE
See Also:
Constant Field Values

CKR_DEVICE_ERROR

public static final int CKR_DEVICE_ERROR
See Also:
Constant Field Values

CKR_DEVICE_MEMORY

public static final int CKR_DEVICE_MEMORY
See Also:
Constant Field Values

CKR_DEVICE_REMOVED

public static final int CKR_DEVICE_REMOVED
See Also:
Constant Field Values

CKR_ENCRYPTED_DATA_INVALID

public static final int CKR_ENCRYPTED_DATA_INVALID
See Also:
Constant Field Values

CKR_ENCRYPTED_DATA_LEN_RANGE

public static final int CKR_ENCRYPTED_DATA_LEN_RANGE
See Also:
Constant Field Values

CKR_FUNCTION_CANCELED

public static final int CKR_FUNCTION_CANCELED
See Also:
Constant Field Values

CKR_FUNCTION_NOT_PARALLEL

public static final int CKR_FUNCTION_NOT_PARALLEL
See Also:
Constant Field Values

CKR_FUNCTION_NOT_SUPPORTED

public static final int CKR_FUNCTION_NOT_SUPPORTED
See Also:
Constant Field Values

CKR_KEY_HANDLE_INVALID

public static final int CKR_KEY_HANDLE_INVALID
See Also:
Constant Field Values

CKR_KEY_SIZE_RANGE

public static final int CKR_KEY_SIZE_RANGE
See Also:
Constant Field Values

CKR_KEY_TYPE_INCONSISTENT

public static final int CKR_KEY_TYPE_INCONSISTENT
See Also:
Constant Field Values

CKR_KEY_NOT_NEEDED

public static final int CKR_KEY_NOT_NEEDED
See Also:
Constant Field Values

CKR_KEY_CHANGED

public static final int CKR_KEY_CHANGED
See Also:
Constant Field Values

CKR_KEY_NEEDED

public static final int CKR_KEY_NEEDED
See Also:
Constant Field Values

CKR_KEY_INDIGESTIBLE

public static final int CKR_KEY_INDIGESTIBLE
See Also:
Constant Field Values

CKR_KEY_FUNCTION_NOT_PERMITTED

public static final int CKR_KEY_FUNCTION_NOT_PERMITTED
See Also:
Constant Field Values

CKR_KEY_NOT_WRAPPABLE

public static final int CKR_KEY_NOT_WRAPPABLE
See Also:
Constant Field Values

CKR_KEY_UNEXTRACTABLE

public static final int CKR_KEY_UNEXTRACTABLE
See Also:
Constant Field Values

CKR_MECHANISM_INVALID

public static final int CKR_MECHANISM_INVALID
See Also:
Constant Field Values

CKR_MECHANISM_PARAM_INVALID

public static final int CKR_MECHANISM_PARAM_INVALID
See Also:
Constant Field Values

CKR_OBJECT_HANDLE_INVALID

public static final int CKR_OBJECT_HANDLE_INVALID
See Also:
Constant Field Values

CKR_OPERATION_ACTIVE

public static final int CKR_OPERATION_ACTIVE
See Also:
Constant Field Values

CKR_OPERATION_NOT_INITIALIZED

public static final int CKR_OPERATION_NOT_INITIALIZED
See Also:
Constant Field Values

CKR_PIN_INCORRECT

public static final int CKR_PIN_INCORRECT
See Also:
Constant Field Values

CKR_PIN_INVALID

public static final int CKR_PIN_INVALID
See Also:
Constant Field Values

CKR_PIN_LEN_RANGE

public static final int CKR_PIN_LEN_RANGE
See Also:
Constant Field Values

CKR_PIN_EXPIRED

public static final int CKR_PIN_EXPIRED
See Also:
Constant Field Values

CKR_PIN_LOCKED

public static final int CKR_PIN_LOCKED
See Also:
Constant Field Values

CKR_SESSION_CLOSED

public static final int CKR_SESSION_CLOSED
See Also:
Constant Field Values

CKR_SESSION_COUNT

public static final int CKR_SESSION_COUNT
See Also:
Constant Field Values

CKR_SESSION_HANDLE_INVALID

public static final int CKR_SESSION_HANDLE_INVALID
See Also:
Constant Field Values

CKR_SESSION_PARALLEL_NOT_SUPPORTED

public static final int CKR_SESSION_PARALLEL_NOT_SUPPORTED
See Also:
Constant Field Values

CKR_SESSION_READ_ONLY

public static final int CKR_SESSION_READ_ONLY
See Also:
Constant Field Values

CKR_SESSION_EXISTS

public static final int CKR_SESSION_EXISTS
See Also:
Constant Field Values

CKR_SESSION_READ_ONLY_EXISTS

public static final int CKR_SESSION_READ_ONLY_EXISTS
See Also:
Constant Field Values

CKR_SESSION_READ_WRITE_SO_EXISTS

public static final int CKR_SESSION_READ_WRITE_SO_EXISTS
See Also:
Constant Field Values

CKR_SIGNATURE_INVALID

public static final int CKR_SIGNATURE_INVALID
See Also:
Constant Field Values

CKR_SIGNATURE_LEN_RANGE

public static final int CKR_SIGNATURE_LEN_RANGE
See Also:
Constant Field Values

CKR_TEMPLATE_INCOMPLETE

public static final int CKR_TEMPLATE_INCOMPLETE
See Also:
Constant Field Values

CKR_TEMPLATE_INCONSISTENT

public static final int CKR_TEMPLATE_INCONSISTENT
See Also:
Constant Field Values

CKR_TOKEN_NOT_PRESENT

public static final int CKR_TOKEN_NOT_PRESENT
See Also:
Constant Field Values

CKR_TOKEN_NOT_RECOGNIZED

public static final int CKR_TOKEN_NOT_RECOGNIZED
See Also:
Constant Field Values

CKR_TOKEN_WRITE_PROTECTED

public static final int CKR_TOKEN_WRITE_PROTECTED
See Also:
Constant Field Values

CKR_UNWRAPPING_KEY_HANDLE_INVALID

public static final int CKR_UNWRAPPING_KEY_HANDLE_INVALID
See Also:
Constant Field Values

CKR_UNWRAPPING_KEY_SIZE_RANGE

public static final int CKR_UNWRAPPING_KEY_SIZE_RANGE
See Also:
Constant Field Values

CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT

public static final int CKR_UNWRAPPING_KEY_TYPE_INCONSISTENT
See Also:
Constant Field Values

CKR_USER_ALREADY_LOGGED_IN

public static final int CKR_USER_ALREADY_LOGGED_IN
See Also:
Constant Field Values

CKR_USER_NOT_LOGGED_IN

public static final int CKR_USER_NOT_LOGGED_IN
See Also:
Constant Field Values

CKR_USER_PIN_NOT_INITIALIZED

public static final int CKR_USER_PIN_NOT_INITIALIZED
See Also:
Constant Field Values

CKR_USER_TYPE_INVALID

public static final int CKR_USER_TYPE_INVALID
See Also:
Constant Field Values

CKR_USER_ANOTHER_ALREADY_LOGGED_IN

public static final int CKR_USER_ANOTHER_ALREADY_LOGGED_IN
See Also:
Constant Field Values

CKR_USER_TOO_MANY_TYPES

public static final int CKR_USER_TOO_MANY_TYPES
See Also:
Constant Field Values

CKR_WRAPPED_KEY_INVALID

public static final int CKR_WRAPPED_KEY_INVALID
See Also:
Constant Field Values

CKR_WRAPPED_KEY_LEN_RANGE

public static final int CKR_WRAPPED_KEY_LEN_RANGE
See Also:
Constant Field Values

CKR_WRAPPING_KEY_HANDLE_INVALID

public static final int CKR_WRAPPING_KEY_HANDLE_INVALID
See Also:
Constant Field Values

CKR_WRAPPING_KEY_SIZE_RANGE

public static final int CKR_WRAPPING_KEY_SIZE_RANGE
See Also:
Constant Field Values

CKR_WRAPPING_KEY_TYPE_INCONSISTENT

public static final int CKR_WRAPPING_KEY_TYPE_INCONSISTENT
See Also:
Constant Field Values

CKR_RANDOM_SEED_NOT_SUPPORTED

public static final int CKR_RANDOM_SEED_NOT_SUPPORTED
See Also:
Constant Field Values

CKR_RANDOM_NO_RNG

public static final int CKR_RANDOM_NO_RNG
See Also:
Constant Field Values

CKR_DOMAIN_PARAMS_INVALID

public static final int CKR_DOMAIN_PARAMS_INVALID
See Also:
Constant Field Values

CKR_BUFFER_TOO_SMALL

public static final int CKR_BUFFER_TOO_SMALL
See Also:
Constant Field Values

CKR_SAVED_STATE_INVALID

public static final int CKR_SAVED_STATE_INVALID
See Also:
Constant Field Values

CKR_INFORMATION_SENSITIVE

public static final int CKR_INFORMATION_SENSITIVE
See Also:
Constant Field Values

CKR_STATE_UNSAVEABLE

public static final int CKR_STATE_UNSAVEABLE
See Also:
Constant Field Values

CKR_CRYPTOKI_NOT_INITIALIZED

public static final int CKR_CRYPTOKI_NOT_INITIALIZED
See Also:
Constant Field Values

CKR_CRYPTOKI_ALREADY_INITIALIZED

public static final int CKR_CRYPTOKI_ALREADY_INITIALIZED
See Also:
Constant Field Values

CKR_MUTEX_BAD

public static final int CKR_MUTEX_BAD
See Also:
Constant Field Values

CKR_MUTEX_NOT_LOCKED

public static final int CKR_MUTEX_NOT_LOCKED
See Also:
Constant Field Values

CKR_FUNCTION_REJECTED

public static final int CKR_FUNCTION_REJECTED
See Also:
Constant Field Values
Constructor Detail

PKCS11Exception

public PKCS11Exception()
Construct a PKCS11 exception with no error message and an error code with the value CKR_GENERAL_ERROR.


PKCS11Exception

public PKCS11Exception(String msg)
Construct a PKCS11 exception with the given error message and an error code with the value CKR_GENERAL_ERROR.

Parameters:
msg - The error message to set.

PKCS11Exception

public PKCS11Exception(int errorCode,
                       String msg)
Construct a PKCS11 exception with the given error code and error message.

Parameters:
errorCode - The PKCS#11 error code to set.
msg - The error message to set.

PKCS11Exception

public PKCS11Exception(String msg,
                       Exception e)
Construct a PKCS11 exception with the given error message and originating exception. The error codeis set to the value CKR_GENERAL_ERROR.

Parameters:
msg - The error message to set.
e - The originating exception.
Method Detail

getErrorCodeName

public static String getErrorCodeName(int errorCode)

getErrorCode

public int getErrorCode()
Returns:
Returns the PKCS#11 error code, which is one of the CKR_* constants.

getErrorCodeName

public String getErrorCodeName()
Returns:
The name of the PKCS#11 error code, which usually start with CKR_.