Class AbstractKeyConverter
java.lang.Object
com.github.toolarium.security.pki.impl.AbstractKeyConverter
- All Implemented Interfaces:
IKeyConverter
- Direct Known Subclasses:
DSAKeyConverter,ECKeyConverter,RSAKeyConverter
This key converter base class
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractKeyConverter(String provider, String type, int defaultSize) Constructor for AbstractKeyConverter -
Method Summary
Modifier and TypeMethodDescriptionformatPrivateKey(PrivateKey privateKey) Formats a private key to a well formed private key, which is bounded at the beginning by-----BEGIN ...Generates a KeyPair containing a Private- and PublicKeygenerateKeyPair(String algorithm, int keySize) Generates a KeyPair containing a Private- and PublicKeygetPrivateKey(byte[] content) Reads PKCS#8 formated private key from a buffer, which are each bounded at the beginning by-----BEGIN ...getPrivateKey(File file) Reads PKCS#8 formated private key from a file, which are each bounded at the beginning by-----BEGIN ...getPrivateKey(String content) Reads PKCS#8 formated private key from a buffer, which are each bounded at the beginning by-----BEGIN ...Get the providergetPublicKey(File file) Reads PKCS#8 formated public key from a file, which are each bounded at the beginning by-----BEGIN ...getPublicKey(String content) Reads PKCS#8 formated public key from a buffer which are each bounded at the beginning by-----BEGIN PUBLIC KEY-----, and bounded at the end by-----END PUBLIC KEY-----.getType()Get the type, e.g.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.github.toolarium.security.pki.IKeyConverter
formatPKCS8, formatPublicKey, getPublicKey, normalizePKCS8
-
Field Details
-
NL
- See Also:
-
-
Constructor Details
-
AbstractKeyConverter
Constructor for AbstractKeyConverter- Parameters:
provider- the providertype- the typedefaultSize- the default size
-
-
Method Details
-
getProvider
Description copied from interface:IKeyConverterGet the provider- Specified by:
getProviderin interfaceIKeyConverter- Returns:
- the provider or null
- See Also:
-
getType
Description copied from interface:IKeyConverterGet the type, e.g. RSA, DSA or EC- Specified by:
getTypein interfaceIKeyConverter- Returns:
- the type as string
- See Also:
-
generateKeyPair
Description copied from interface:IKeyConverterGenerates a KeyPair containing a Private- and PublicKey- Specified by:
generateKeyPairin interfaceIKeyConverter- Returns:
- the created KeyPair
- Throws:
GeneralSecurityException- in case of error- See Also:
-
generateKeyPair
Description copied from interface:IKeyConverterGenerates a KeyPair containing a Private- and PublicKey- Specified by:
generateKeyPairin interfaceIKeyConverter- Parameters:
algorithm- the algorithm like: SHA1withRSA, SHA1withDSA, RSA...keySize- the size of the key- Returns:
- the created KeyPair
- Throws:
GeneralSecurityException- in case of error- See Also:
-
getPublicKey
Description copied from interface:IKeyConverterReads PKCS#8 formated public key from a buffer which are each bounded at the beginning by-----BEGIN PUBLIC KEY-----, and bounded at the end by-----END PUBLIC KEY-----.- Specified by:
getPublicKeyin interfaceIKeyConverter- Parameters:
content- the content- Returns:
- the public key
- Throws:
IOException- in case of errorGeneralSecurityException- in case of error- See Also:
-
getPublicKey
Description copied from interface:IKeyConverterReads PKCS#8 formated public key from a file, which are each bounded at the beginning by-----BEGIN ... PUBLIC KEY-----, and bounded at the end by-----END ... PUBLIC KEY-----.- Specified by:
getPublicKeyin interfaceIKeyConverter- Parameters:
file- the file to read- Returns:
- the private key
- Throws:
IOException- in case of errorGeneralSecurityException- in case of error- See Also:
-
getPrivateKey
Description copied from interface:IKeyConverterReads PKCS#8 formated private key from a buffer, which are each bounded at the beginning by-----BEGIN ... PRIVATE KEY-----, and bounded at the end by-----END ... PRIVATE KEY-----.- Specified by:
getPrivateKeyin interfaceIKeyConverter- Parameters:
content- the private key to encode- Returns:
- the private key
- Throws:
IOException- in case of errorGeneralSecurityException- in case of error- See Also:
-
getPrivateKey
Description copied from interface:IKeyConverterReads PKCS#8 formated private key from a buffer, which are each bounded at the beginning by-----BEGIN ... PRIVATE KEY-----, and bounded at the end by-----END ... PRIVATE KEY-----.- Specified by:
getPrivateKeyin interfaceIKeyConverter- Parameters:
content- the private key to encode- Returns:
- the private key
- Throws:
GeneralSecurityException- in case of error- See Also:
-
getPrivateKey
Description copied from interface:IKeyConverterReads PKCS#8 formated private key from a file, which are each bounded at the beginning by-----BEGIN ... PRIVATE KEY-----, and bounded at the end by-----END ... PRIVATE KEY-----.- Specified by:
getPrivateKeyin interfaceIKeyConverter- Parameters:
file- the file to read- Returns:
- the private key
- Throws:
IOException- in case of errorGeneralSecurityException- in case of error- See Also:
-
formatPrivateKey
Description copied from interface:IKeyConverterFormats a private key to a well formed private key, which is bounded at the beginning by-----BEGIN ... PRIVATE KEY-----, and bounded at the end by-----END ... PRIVATE KEY-----.- Specified by:
formatPrivateKeyin interfaceIKeyConverter- Parameters:
privateKey- the private key to format- Returns:
- the well formed certificate
- See Also:
-