Package de.brendamour.jpasskit.util
Class CertUtils
java.lang.Object
de.brendamour.jpasskit.util.CertUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionextractApnsTopics(X509Certificate certificate) Extract topics for sending push notifications fromX509Certificatecertificate.static org.apache.commons.lang3.tuple.ImmutablePair<PrivateKey,X509Certificate> extractCertificateWithKey(KeyStore keyStore, char[] keyStorePassword) Extract a pair of key and certificate from an already loadedKeyStore.static Stringstatic InputStreamtoInputStream(String path) Load a keystore from an already openedInputStream.static KeyStoretoKeyStore(InputStream keyStoreInputStream, char[] keyStorePassword) Load a keystore from an already openedInputStream.static X509CertificatetoX509Certificate(InputStream certificateInputStream) Load a DER Certificate from an already openedInputStream.
-
Constructor Details
-
CertUtils
public CertUtils()
-
-
Method Details
-
toInputStream
Load a keystore from an already openedInputStream. The caller is responsible for closing the resulting stream when it's no longer needed.- Parameters:
path- path of a key store or certificate.- Returns:
InputStreamloaded frompath- Throws:
FileNotFoundException- If no file exists at the givenpath.
-
toKeyStore
public static KeyStore toKeyStore(InputStream keyStoreInputStream, char[] keyStorePassword) throws CertificateException Load a keystore from an already openedInputStream. The caller is responsible for closing the stream after this method completes successfully or fails.- Parameters:
keyStoreInputStream-InputStreamcontaining the signing key store.keyStorePassword- password to access the key store.- Returns:
KeyStoreloaded fromkeyPath- Throws:
IllegalArgumentException- If eitherkeyPathis orkeyPathorkeyPasswordis empty.IllegalStateException- IfKeyStoreloading failed.CertificateException- If any of the certificates in the keystore could not be loaded.
-
toX509Certificate
public static X509Certificate toX509Certificate(InputStream certificateInputStream) throws CertificateException Load a DER Certificate from an already openedInputStream. The caller is responsible for closing the stream after this method completes successfully or fails.- Parameters:
certificateInputStream-InputStreamcontaining the certificate.- Returns:
X509Certificateloaded fromcertificateInputStream- Throws:
IllegalStateException- IfX509Certificateloading failed.CertificateException- IfX509Certificateis invalid or cannot be loaded.
-
extractCertificateWithKey
public static org.apache.commons.lang3.tuple.ImmutablePair<PrivateKey,X509Certificate> extractCertificateWithKey(KeyStore keyStore, char[] keyStorePassword) Extract a pair of key and certificate from an already loadedKeyStore.- Parameters:
keyStore-KeyStoreinstance.keyStorePassword- password to access the key store.- Returns:
- pair of valid
PrivateKeyandX509Certificateloaded fromkeyStore - Throws:
IllegalStateException- IfX509Certificateloading failed.
-
extractApnsTopics
Extract topics for sending push notifications fromX509Certificatecertificate.- Parameters:
certificate-X509Certificateinstance.- Returns:
- unique
Setof topics from a certificate - Throws:
IOException- IfX509Certificateparsing failed.
-
getProviderName
-