Package com.caplin.keymaster
Class PEMPKCS8KeyMasterConfiguration
- java.lang.Object
-
- com.caplin.keymaster.PEMPKCS8KeyMasterConfiguration
-
- All Implemented Interfaces:
IKeyMasterConfiguration
public class PEMPKCS8KeyMasterConfiguration extends java.lang.Object implements IKeyMasterConfiguration
The
PEMPKCS8KeyMasterConfiguration
class creates a configuration for KeyMaster using a private key stored in a pkcs#8 PEM format file. The private key must not be password protected.Use the following openssl command to convert an openssl generated PEM file to a pkcs8 encoded PEM file
openssl pkcs8 -topk8 -inform PEM -outform PEM -in privatekey_openssl.pem -out privatekey.pem -nocrypt
-
-
Constructor Summary
Constructors Constructor Description PEMPKCS8KeyMasterConfiguration(java.io.InputStream pemKeyInputStream, KeyMasterHashingAlgorithm hashingAlgorithm, java.lang.String securityProviderName)
Initializes a new instance of thePEMPKCS8KeyMasterConfiguration
class that uses the private key in the supplied PKCS#8 PEM format file.PEMPKCS8KeyMasterConfiguration(java.lang.String pemKeyFile, KeyMasterHashingAlgorithm hashingAlgorithm, java.lang.String securityProviderName)
Initializes a new instance of thePEMPKCS8KeyMasterConfiguration
class that uses the private key in the supplied PKCS#8 PEM format file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description KeyMasterHashingAlgorithm
getHashingAlgorithm()
Gets the hashing algorithm that is used to generate the KeyMaster token.java.security.PrivateKey
getPrivateKey()
Gets a private key object.java.lang.String
getSecurityProviderName()
The name of the Java Security provider to be used to generate the token.java.lang.String
toString()
-
-
-
Constructor Detail
-
PEMPKCS8KeyMasterConfiguration
public PEMPKCS8KeyMasterConfiguration(java.io.InputStream pemKeyInputStream, KeyMasterHashingAlgorithm hashingAlgorithm, java.lang.String securityProviderName) throws java.lang.Exception
Initializes a new instance of thePEMPKCS8KeyMasterConfiguration
class that uses the private key in the supplied PKCS#8 PEM format file.- Parameters:
pemKeyInputStream
- The input stream for the PEM private key file.hashingAlgorithm
- The hashing algorithm to use.securityProviderName
- The name of the security provider to use or null to use the first suitable security provider registered.- Throws:
java.lang.IllegalArgumentException
- The specified key file is an inappropriate format.java.lang.Exception
- The specified key file cannot be found.
-
PEMPKCS8KeyMasterConfiguration
public PEMPKCS8KeyMasterConfiguration(java.lang.String pemKeyFile, KeyMasterHashingAlgorithm hashingAlgorithm, java.lang.String securityProviderName) throws java.lang.Exception
Initializes a new instance of thePEMPKCS8KeyMasterConfiguration
class that uses the private key in the supplied PKCS#8 PEM format file.- Parameters:
pemKeyFile
- The file pathname of the PEM private key file.hashingAlgorithm
- The hashing algorithm to use.securityProviderName
- The name of the security provider to use or null to use the first suitable security provider registered.- Throws:
java.lang.IllegalArgumentException
- The specified key file is an inappropriate format.java.lang.Exception
- The specified key file cannot be found.
-
-
Method Detail
-
getPrivateKey
public java.security.PrivateKey getPrivateKey()
Description copied from interface:IKeyMasterConfiguration
Gets a private key object.The KeyMaster token generator retrieves this property whenever it needs to generate a token.
- Specified by:
getPrivateKey
in interfaceIKeyMasterConfiguration
- Returns:
- The private key.
-
getHashingAlgorithm
public KeyMasterHashingAlgorithm getHashingAlgorithm()
Description copied from interface:IKeyMasterConfiguration
Gets the hashing algorithm that is used to generate the KeyMaster token.- Specified by:
getHashingAlgorithm
in interfaceIKeyMasterConfiguration
- Returns:
- The hashing algorithm.
-
getSecurityProviderName
public java.lang.String getSecurityProviderName()
Description copied from interface:IKeyMasterConfiguration
The name of the Java Security provider to be used to generate the token. If set to null the token generation traverses the list of registered security Providers, starting with the most preferred Provider, the first provider that supports the specified signature algorithm will be used.- Specified by:
getSecurityProviderName
in interfaceIKeyMasterConfiguration
- Returns:
- The name of the security provider or null.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-