Class SunPkcs11PrivateKeyAccessor
java.lang.Object
se.swedenconnect.security.credential.pkcs11.SunPkcs11PrivateKeyAccessor
- All Implemented Interfaces:
Pkcs11ObjectAccessor<PrivateKey>,Pkcs11PrivateKeyAccessor
An implementation of the
Pkcs11PrivateKeyAccessor interface for the SunPKCS11 security provider and other
providers that implement the Java KeyStoreSpi.- Author:
- Martin Lindström
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the private key from the given entry (identified byalias).Gets a reference to the private key from the PKCS#11 device, and throwsSecurityExceptionif it can not be extracted or is not found.
-
Constructor Details
-
SunPkcs11PrivateKeyAccessor
public SunPkcs11PrivateKeyAccessor()
-
-
Method Details
-
get
@Nonnull public PrivateKey get(@Nonnull Provider provider, @Nonnull String alias, @Nonnull char[] pin) throws SecurityException Gets a reference to the private key from the PKCS#11 device, and throwsSecurityExceptionif it can not be extracted or is not found.- Specified by:
getin interfacePkcs11ObjectAccessor<PrivateKey>- Specified by:
getin interfacePkcs11PrivateKeyAccessor- Parameters:
provider- the security provider to usealias- the alias to the entry holding the objectpin- the PIN needed to access the entry- Returns:
- an object reference or
nullif the object is not available - Throws:
SecurityException- if the operation is not successful
-
get
@Nullable public PrivateKey get(@Nonnull KeyStore keyStore, @Nonnull String alias, @Nonnull char[] pin) throws KeyStoreException Gets the private key from the given entry (identified byalias).- Parameters:
keyStore- the keystorealias- the entry aliaspin- the PIN to unlock the key- Returns:
- a
PrivateKeyornullif no key is found - Throws:
KeyStoreException- for errors accessing the key
-