Package net.shibboleth.shared.spring.security.factory

# Class PKCS11PrivateKeyFactoryBean

java.lang.Object
net.shibboleth.shared.spring.security.factory.PKCS11PrivateKeyFactoryBean

All Implemented Interfaces:
  `FactoryBean<PrivateKey>`

public class PKCS11PrivateKeyFactoryBean extends Object implements FactoryBean<PrivateKey>
Spring bean factory for extracting a `PrivateKey` from a PKCS#11 keystore. This relies on the SunPKCS11 provider.

## Field Summary

Fields
Modifier and Type
Field
Description
`private PrivateKey`
`key`
The singleton instance of the private key produced by this factory.
`private String`
`keyAlias`
Alias for the private key.
`private String`
`keyPassword`
Password for the private key.
`private final org.slf4j.Logger`
`log`
Class logger.
`private String`
`pkcs11Config`
PKCS#11 provider parameter string.
`private static Provider`
`provider`
Singleton `Provider` for all instances of this factory.
`private static final String`
`UNCONFIGURED_PROVIDER_NAME`
The name for the base PKCS#11 provider.

### Fields inherited from interface org.springframework.beans.factory.FactoryBean

`OBJECT_TYPE_ATTRIBUTE`

## Constructor Summary

Constructors
Constructor
Description
`PKCS11PrivateKeyFactoryBean()`

## Method Summary

Modifier and Type
Method
Description
`String`
`getKeyAlias()`
Gets the key alias in use.
`String`
`getKeyPassword()`
Gets the key password in use.
`private KeyStore`
`getKeyStore()`
Gets a PKCS#11 `KeyStore` from the `Provider`.
`PrivateKey`
`getObject()`
`Class<?>`
`getObjectType()`
`String`
`getPkcs11Config()`
Returns the PKCS#11 configuration.
`private Provider`
`getProvider()`
Gets the singleton PKCS#11 `Provider`.
`boolean`
`isSingleton()`
`void`
`setKeyAlias(String alias)`
Sets the key alias to use.
`void`
`setKeyPassword(String password)`
Set the key password to use.
`void`
`setPkcs11Config(String config)`
Sets the PKCS#11 configuration to use.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### UNCONFIGURED_PROVIDER_NAME

@Nonnull @NotEmpty private static final String UNCONFIGURED_PROVIDER_NAME
The name for the base PKCS#11 provider.

See Also:
  - Constant Field Values

### provider

@Nullable private static Provider provider
Singleton `Provider` for all instances of this factory.

### log

@Nonnull private final org.slf4j.Logger log
Class logger.

### pkcs11Config

@Nullable private String pkcs11Config
PKCS#11 provider parameter string.

### keyAlias

@Nullable private String keyAlias
Alias for the private key.

### keyPassword

@Nullable private String keyPassword
Password for the private key.

### key

@Nullable private PrivateKey key
The singleton instance of the private key produced by this factory.

## Constructor Details

### PKCS11PrivateKeyFactoryBean

public PKCS11PrivateKeyFactoryBean()

## Method Details

### getPkcs11Config

@Nullable public String getPkcs11Config()
Returns the PKCS#11 configuration.

Returns:
  returns the PKCS#11 configuration.

### setPkcs11Config

public void setPkcs11Config(@Nullable String config)
Sets the PKCS#11 configuration to use.

Parameters:
  `config` - the PKCS#11 configuration to use

### getKeyAlias

@Nullable public String getKeyAlias()
Gets the key alias in use.

Returns:
  returns the key alias in use

### setKeyAlias

public void setKeyAlias(@Nullable String alias)
Sets the key alias to use.

Parameters:
  `alias` - the key alias to use

### getKeyPassword

@Nullable public String getKeyPassword()
Gets the key password in use.

Returns:
  returns the key password in use

### setKeyPassword

public void setKeyPassword(@Nullable String password)
Set the key password to use.

Parameters:
  `password` - the key password to use

### getProvider

@Nonnull private Provider getProvider() throws Exception
Gets the singleton PKCS#11 `Provider`. The constructed `Provider` is also added to the system's list of providers.

Returns:
  the singleton `Provider`
Throws:
  `Exception` - if something goes wrong building the `Provider`

### getKeyStore

@Nonnull private KeyStore getKeyStore() throws Exception
Gets a PKCS#11 `KeyStore` from the `Provider`.

Returns:
  the `KeyStore`
Throws:
  `Exception` - if something goes wrong building the keystore

### getObject

@Nonnull public PrivateKey getObject() throws Exception

Specified by:
  `getObject` in interface `FactoryBean<PrivateKey>`
Throws:
  `Exception`

### getObjectType

@Nonnull public Class<?> getObjectType()

Specified by:
  `getObjectType` in interface `FactoryBean<PrivateKey>`

### isSingleton

public boolean isSingleton()

Specified by:
  `isSingleton` in interface `FactoryBean<PrivateKey>`