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
-
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 throwsSecurityException
if 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 throwsSecurityException
if it can not be extracted or is not found.- Specified by:
get
in interfacePkcs11ObjectAccessor<PrivateKey>
- Specified by:
get
in 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
null
if 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
PrivateKey
ornull
if no key is found - Throws:
KeyStoreException
- for errors accessing the key
-