Package eu.europa.esig.dss.spi.x509
Class KeyStoreCertificateSource
- java.lang.Object
-
- eu.europa.esig.dss.spi.x509.CommonCertificateSource
-
- eu.europa.esig.dss.spi.x509.KeyStoreCertificateSource
-
- All Implemented Interfaces:
CertificateSource,Serializable
public class KeyStoreCertificateSource extends CommonCertificateSource
Implements a CertificateSource using a KeyStore (PKCS12, JKS,...). Note: PKCS12 + JDK7 don't allow trust store- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description KeyStoreCertificateSource(File ksFile, String ksType, String ksPassword)Constructor for KeyStoreCertificateSource withoutCertificatePool.KeyStoreCertificateSource(File ksFile, String ksType, String ksPassword, CertificatePool certPool)Constructor for KeyStoreCertificateSource withCertificatePool.KeyStoreCertificateSource(InputStream ksStream, String ksType, String ksPassword)The default constructor for KeyStoreCertificateSource withoutCertificatePool.KeyStoreCertificateSource(InputStream ksStream, String ksType, String ksPassword, CertificatePool certPool)The default constructor for KeyStoreCertificateSource.KeyStoreCertificateSource(String ksType, String ksPassword)Constructor for KeyStoreCertificateSource withoutCertificatePool.KeyStoreCertificateSource(String ksType, String ksPassword, CertificatePool certPool)Constructor for KeyStoreCertificateSource withCertificatePool.KeyStoreCertificateSource(String ksFilePath, String ksType, String ksPassword)Constructor for KeyStoreCertificateSource withoutCertificatePool.KeyStoreCertificateSource(String ksFilePath, String ksType, String ksPassword, CertificatePool certPool)Constructor for KeyStoreCertificateSource withCertificatePool.
-
Method Summary
Modifier and Type Method Description voidaddAllCertificatesToKeyStore(List<CertificateToken> certificates)This method allows to add a list of certificates to the keystorevoidaddCertificateToKeyStore(CertificateToken certificateToken)This method allows to add a certificate in the keystore.voidclearAllCertificates()This method allows to remove all certificates from the keystorevoiddeleteCertificateFromKeyStore(String alias)This method allows to remove a certificate from the keystoreCertificateTokengetCertificate(String alias)This method allows to retrieve a certificate by its aliasList<CertificateToken>getCertificates()This method returns all certificates from the keystorevoidstore(OutputStream os)This method allows to store the keystore in the OutputStream-
Methods inherited from class eu.europa.esig.dss.spi.x509.CommonCertificateSource
addCertificate, getCertificatePool, getCertificateSourceType, getCertificateTokenByDigest, getNumberOfCertificates, isTrusted, removeCertificate
-
-
-
-
Constructor Detail
-
KeyStoreCertificateSource
public KeyStoreCertificateSource(String ksType, String ksPassword, CertificatePool certPool)
Constructor for KeyStoreCertificateSource withCertificatePool. This constructor allows to create a new empty keystore.- Parameters:
ksType- the keystore typeksPassword- the keystore passwordcertPool- the certificate pool
-
KeyStoreCertificateSource
public KeyStoreCertificateSource(String ksFilePath, String ksType, String ksPassword, CertificatePool certPool) throws IOException
Constructor for KeyStoreCertificateSource withCertificatePool.- Parameters:
ksFilePath- the keystore filepathksType- the keystore typeksPassword- the keystore passwordcertPool- the certificate pool- Throws:
IOException- if the file not exists
-
KeyStoreCertificateSource
public KeyStoreCertificateSource(File ksFile, String ksType, String ksPassword, CertificatePool certPool) throws IOException
Constructor for KeyStoreCertificateSource withCertificatePool.- Parameters:
ksFile- the keystore fileksType- the keystore typeksPassword- the keystore passwordcertPool- the certificate pool- Throws:
IOException- if the file not exists
-
KeyStoreCertificateSource
public KeyStoreCertificateSource(InputStream ksStream, String ksType, String ksPassword, CertificatePool certPool)
The default constructor for KeyStoreCertificateSource.- Parameters:
ksStream- the inputstream with the keystore (can be null to create a new keystore)ksType- the keystore typeksPassword- the keystore passwordcertPool- the certificate pool
-
KeyStoreCertificateSource
public KeyStoreCertificateSource(String ksType, String ksPassword)
Constructor for KeyStoreCertificateSource withoutCertificatePool. This constructor allows to create a new empty keystore.- Parameters:
ksType- the keystore typeksPassword- the keystore password
-
KeyStoreCertificateSource
public KeyStoreCertificateSource(String ksFilePath, String ksType, String ksPassword) throws IOException
Constructor for KeyStoreCertificateSource withoutCertificatePool.- Parameters:
ksFilePath- the keystore filepathksType- the keystore typeksPassword- the keystore password- Throws:
IOException- if the file not exists
-
KeyStoreCertificateSource
public KeyStoreCertificateSource(File ksFile, String ksType, String ksPassword) throws IOException
Constructor for KeyStoreCertificateSource withoutCertificatePool.- Parameters:
ksFile- the keystore fileksType- the keystore typeksPassword- the keystore password- Throws:
IOException- if the file not exists
-
KeyStoreCertificateSource
public KeyStoreCertificateSource(InputStream ksStream, String ksType, String ksPassword)
The default constructor for KeyStoreCertificateSource withoutCertificatePool.- Parameters:
ksStream- the inputstream with the keystore (can be null to create a new keystore)ksType- the keystore typeksPassword- the keystore password
-
-
Method Detail
-
getCertificate
public CertificateToken getCertificate(String alias)
This method allows to retrieve a certificate by its alias- Parameters:
alias- the certificate alias in the keystore- Returns:
- the certificate
-
getCertificates
public List<CertificateToken> getCertificates()
This method returns all certificates from the keystore- Specified by:
getCertificatesin interfaceCertificateSource- Overrides:
getCertificatesin classCommonCertificateSource- Returns:
- all certificates from this source
-
addAllCertificatesToKeyStore
public void addAllCertificatesToKeyStore(List<CertificateToken> certificates)
This method allows to add a list of certificates to the keystore- Parameters:
certificates- the list of certificates
-
addCertificateToKeyStore
public void addCertificateToKeyStore(CertificateToken certificateToken)
This method allows to add a certificate in the keystore. The generated alias will be the DSS ID.- Parameters:
certificateToken- the certificate to be added in the keystore
-
deleteCertificateFromKeyStore
public void deleteCertificateFromKeyStore(String alias)
This method allows to remove a certificate from the keystore- Parameters:
alias- the certificate alias
-
clearAllCertificates
public void clearAllCertificates()
This method allows to remove all certificates from the keystore
-
store
public void store(OutputStream os)
This method allows to store the keystore in the OutputStream- Parameters:
os- the OutpuStream where to store the keystore
-
-