public abstract class KeyTool
extends java.lang.Object
| 限定符和类型 | 字段和说明 |
|---|---|
protected java.security.KeyStore |
keyStore |
protected java.lang.String |
keyStoreFile |
protected static org.slf4j.Logger |
logger |
protected java.lang.String |
password |
| 构造器和说明 |
|---|
KeyTool(java.io.InputStream keyStoreFileInputStream)
Constructor for PEM with key file input stream
|
KeyTool(java.io.InputStream keyStoreFileInputStream,
java.lang.String password)
Constructor for the P12: with password and key file input stream
|
KeyTool(java.lang.String keyStoreFile)
Constructor for PEM without password
|
KeyTool(java.lang.String keyStoreFile,
java.lang.String password)
Constructor for the P12: with password
|
| 限定符和类型 | 方法和说明 |
|---|---|
static java.security.KeyPair |
convertHexedStringToKeyPair(java.lang.String hexedPrivateKey,
java.lang.String curveName)
Convert string type private key integer and ECC curve name to PrivateKey type key
|
static java.security.PrivateKey |
convertHexedStringToPrivateKey(java.math.BigInteger privateKey,
java.lang.String curveName)
Convert BigInteger private key and ECC curve name to PrivateKey type key
|
static java.security.PrivateKey |
convertHexedStringToPrivateKey(java.lang.String hexedPrivateKey,
java.lang.String curveName)
convert hexed string into PrivateKey type storePublicKeyWithPem
|
static java.security.KeyPair |
convertPrivateKeyToKeyPair(java.math.BigInteger privateKey,
java.lang.String curveName)
Convert BigInteger private key and ECC curve name to KeyPair
|
static java.lang.String |
getHexedPrivateKey(java.security.PrivateKey privateKey)
Get hex string type private key
|
java.lang.String |
getHexedPublicKey()
Get hex string type public key
|
static java.lang.String |
getHexedPublicKey(java.security.PublicKey publicKey) |
java.security.KeyPair |
getKeyPair()
Get keyPair loaded from the keyStore file
|
java.lang.String |
getKeyStoreFile() |
protected abstract java.security.PrivateKey |
getPrivateKey() |
protected abstract java.security.PublicKey |
getPublicKey()
Abstract function of getting public key
|
protected java.security.PublicKey |
getPublicKeyFromPrivateKey()
Get the public key
|
static java.security.PublicKey |
getPublicKeyFromPrivateKey(java.security.PrivateKey privateKey)
Generate and get the public key from private key
|
protected void |
load()
load information from the keyStoreFile
|
protected abstract void |
load(java.io.InputStream in)
Abstract function of load key from InputStream
|
static void |
storePublicKeyWithPem(java.security.PrivateKey privateKey,
java.lang.String privateKeyFilePath)
Generate public key from private key, and store public key in to pem key file
|
static void |
storePublicKeyWithPem(java.security.PublicKey publicKey,
java.lang.String privateKeyFilePath)
Store public key in to pem key file
|
protected static org.slf4j.Logger logger
protected final java.lang.String keyStoreFile
protected final java.lang.String password
protected java.security.KeyStore keyStore
public KeyTool(java.lang.String keyStoreFile,
java.lang.String password)
keyStoreFile - the path of the keystore filepassword - password to read the keystore filepublic KeyTool(java.lang.String keyStoreFile)
keyStoreFile - the path of the keystore filepublic KeyTool(java.io.InputStream keyStoreFileInputStream,
java.lang.String password)
keyStoreFileInputStream - the input stream of the keystore filepassword - password to read the keystore filepublic KeyTool(java.io.InputStream keyStoreFileInputStream)
keyStoreFileInputStream - the input stream of the keystore fileprotected abstract java.security.PrivateKey getPrivateKey()
public final java.lang.String getKeyStoreFile()
public java.security.KeyPair getKeyPair()
protected abstract java.security.PublicKey getPublicKey()
public static java.lang.String getHexedPublicKey(java.security.PublicKey publicKey)
public java.lang.String getHexedPublicKey()
public static java.lang.String getHexedPrivateKey(java.security.PrivateKey privateKey)
privateKey - PrivateKey type private keypublic static java.security.PrivateKey convertHexedStringToPrivateKey(java.lang.String hexedPrivateKey,
java.lang.String curveName)
throws LoadKeyStoreException
hexedPrivateKey - the hexed privateKeycurveName - the curve nameLoadKeyStoreException - convert exception, return exception informationpublic static java.security.PrivateKey convertHexedStringToPrivateKey(java.math.BigInteger privateKey,
java.lang.String curveName)
privateKey - BigInteger type private keycurveName - the ECC curve namepublic static java.security.KeyPair convertHexedStringToKeyPair(java.lang.String hexedPrivateKey,
java.lang.String curveName)
throws LoadKeyStoreException
hexedPrivateKey - string type of the private key integercurveName - ECC curve nameLoadKeyStoreExceptionpublic static java.security.KeyPair convertPrivateKeyToKeyPair(java.math.BigInteger privateKey,
java.lang.String curveName)
throws LoadKeyStoreException
privateKey - BigInteger type private keycurveName - ECC curve nameLoadKeyStoreExceptionpublic static void storePublicKeyWithPem(java.security.PrivateKey privateKey,
java.lang.String privateKeyFilePath)
throws java.io.IOException
privateKey - a private keyprivateKeyFilePath - the pem key filejava.io.IOExceptionpublic static void storePublicKeyWithPem(java.security.PublicKey publicKey,
java.lang.String privateKeyFilePath)
throws java.io.IOException
publicKey - a public keyprivateKeyFilePath - the pem key filejava.io.IOExceptionprotected abstract void load(java.io.InputStream in)
in - the InputStreamprotected void load()
protected java.security.PublicKey getPublicKeyFromPrivateKey()
public static java.security.PublicKey getPublicKeyFromPrivateKey(java.security.PrivateKey privateKey)
throws LoadKeyStoreException
privateKey - the PrivateKeyLoadKeyStoreException