public class SecureIdentity extends Object
| Modifier and Type | Field and Description |
|---|---|
protected Cert |
certificate |
protected PrivKey |
privateKey |
| Modifier | Constructor and Description |
|---|---|
protected |
SecureIdentity() |
|
SecureIdentity(Cert certificate,
PrivKey privateKey)
Create a new identity
|
|
SecureIdentity(File certificateFile,
File privateKeyFile,
String privateKeyPassword)
Create a new identity by loading the certificate and private key from files.
|
|
SecureIdentity(File storeLocation,
String alias,
String privateKeyPassword,
String keyStorePassword,
String keyStoreType)
Creates a new SecureIdentity object from a pfx-keystore file.
|
|
SecureIdentity(URL certificateFile,
URL privateKeyFile,
String privateKeyPassword)
Create a new identity by loading the certificate and private key from files.
|
| Modifier and Type | Method and Description |
|---|---|
protected byte[] |
decrypt(SecurityAlgorithm algorithm,
byte[] dataToDecrypt,
PrivKey privKey)
Decrypt data using the provided securityPolicy.
|
byte[] |
decrypt(SecurityPolicy securityPolicy,
byte[] dataToDecrypt)
Decrypt data using the provided securityPolicy.
|
byte[] |
encrypt(SecurityPolicy securityPolicy,
byte[] dataToEncrypt)
Encrypt data using the provided securityPolicy.
|
boolean |
equals(Object obj) |
Cert |
getCertificate() |
KeyPair |
getKeys() |
PrivKey |
getPrivateKey() |
int |
hashCode() |
public SecureIdentity(Cert certificate, PrivKey privateKey)
certificate - The public key certificateprivateKey - The private key (optional)public SecureIdentity(File certificateFile, File privateKeyFile, String privateKeyPassword) throws IOException, SecureIdentityException
certificateFile - The certificate file.privateKeyFile - The private key file.privateKeyPassword - The password protecting the private key.IOException - If the files are not valid.SecureIdentityException - if the certificate or private key file is not validpublic SecureIdentity(File storeLocation, String alias, String privateKeyPassword, String keyStorePassword, String keyStoreType) throws IOException, SecureIdentityException
storeLocation - location of the pfx-filealias - string alias of the key pair, if null or not found in specified pfx-file, last
entry is usedprivateKeyPassword - password of the private keykeyStorePassword - password of the keystorekeyStoreType - type of the key store, "JKS" and "PKCS12" supportedKeyStoreException - if the keystore has not been initialized (loaded)NoSuchProviderException - if the specified provider (Bouncy Castle) is not registered in
the security provider listNoSuchAlgorithmException - if the algorithm used to check the integrity of the keystore
cannot be foundCertificateException - if any of the certificates in the keystore could not be loadedIOExceptionUnrecoverableKeyException - if a key in the keystore cannot be recoveredSecureIdentityExceptionpublic SecureIdentity(URL certificateFile, URL privateKeyFile, String privateKeyPassword) throws IOException, SecureIdentityException
certificateFile - The certificate file.privateKeyFile - The private key file.privateKeyPassword - The password protecting the private key.IOException - If the files are not valid.SecureIdentityException - if the certificate or private key file is not validprotected SecureIdentity()
public byte[] decrypt(SecurityPolicy securityPolicy, byte[] dataToDecrypt) throws SecureIdentityException
securityPolicy - the security policy to use for the encryption.dataToDecrypt - data to decryptSecureIdentityException - if the decryption failspublic byte[] encrypt(SecurityPolicy securityPolicy, byte[] dataToEncrypt) throws SecureIdentityException
securityPolicy - the security policy to use for the encryption.dataToEncrypt - data to encryptSecureIdentityException - if the encryption failspublic Cert getCertificate()
public KeyPair getKeys()
public PrivKey getPrivateKey()
protected byte[] decrypt(SecurityAlgorithm algorithm, byte[] dataToDecrypt, PrivKey privKey) throws SecureIdentityException
algorithm - the security policy to use for the encryption.dataToDecrypt - data to decryptprivKey - the private key to useSecureIdentityException - if the decryption failsCopyright © 2026. All rights reserved.