Class P12KeyStore
java.lang.Object
org.fisco.bcos.sdk.crypto.keystore.KeyTool
org.fisco.bcos.sdk.crypto.keystore.P12KeyStore
public class P12KeyStore extends KeyTool
-
Field Summary
Fields inherited from class org.fisco.bcos.sdk.crypto.keystore.KeyTool
keyStoreFile, logger, password
-
Constructor Summary
Constructors Constructor Description P12KeyStore(java.io.InputStream keyStoreFileInputStream, java.lang.String password)
P12KeyStore(java.lang.String keyStoreFile, java.lang.String password)
-
Method Summary
Modifier and Type Method Description static java.security.cert.X509Certificate
generateSelfSignedCertificate(java.security.KeyPair keyPair, java.lang.String signatureAlgorithm)
generate self-signed certificateprotected java.security.PrivateKey
getPrivateKey()
get private key from the keyStorejava.security.PublicKey
getPublicKey()
protected void
load(java.io.InputStream in)
load keyPair from the given input streamstatic void
storeKeyPairWithP12Format(java.lang.String hexedPrivateKey, java.lang.String password, java.lang.String privateKeyFilePath, java.lang.String curveName, java.lang.String signatureAlgorithm)
Methods inherited from class org.fisco.bcos.sdk.crypto.keystore.KeyTool
convertHexedStringToPrivateKey, convertHexedStringToPrivateKey, getHexedPrivateKey, getHexedPublicKey, getHexedPublicKey, getKeyPair, getKeyStoreFile, getPublicKeyFromPrivateKey, getPublicKeyFromPrivateKey, load, storePublicKeyWithPem
-
Constructor Details
-
P12KeyStore
public P12KeyStore(java.lang.String keyStoreFile, java.lang.String password) -
P12KeyStore
public P12KeyStore(java.io.InputStream keyStoreFileInputStream, java.lang.String password)
-
-
Method Details
-
getPublicKey
public java.security.PublicKey getPublicKey()- Specified by:
getPublicKey
in classKeyTool
-
load
protected void load(java.io.InputStream in)load keyPair from the given input stream -
getPrivateKey
protected java.security.PrivateKey getPrivateKey()get private key from the keyStore- Specified by:
getPrivateKey
in classKeyTool
- Returns:
- the private key
-
storeKeyPairWithP12Format
public static void storeKeyPairWithP12Format(java.lang.String hexedPrivateKey, java.lang.String password, java.lang.String privateKeyFilePath, java.lang.String curveName, java.lang.String signatureAlgorithm) throws SaveKeyStoreException- Throws:
SaveKeyStoreException
-
generateSelfSignedCertificate
public static java.security.cert.X509Certificate generateSelfSignedCertificate(java.security.KeyPair keyPair, java.lang.String signatureAlgorithm) throws java.security.NoSuchAlgorithmException, java.security.cert.CertificateEncodingException, java.security.NoSuchProviderException, java.security.InvalidKeyException, java.security.SignatureExceptiongenerate self-signed certificate- Parameters:
keyPair
- the keyPair used to generated the certificatesignatureAlgorithm
- the signature algorithm of the cert- Returns:
- the generated self-signed certificate object
- Throws:
java.security.NoSuchAlgorithmException
- no such algorithm exceptionjava.security.cert.CertificateEncodingException
- error occurs when encoding certificatejava.security.NoSuchProviderException
- no such provider exceptionjava.security.InvalidKeyException
- invalid key exceptionjava.security.SignatureException
- generic signature exception
-