public class CertUtils extends Object
| Constructor and Description |
|---|
CertUtils() |
| Modifier and Type | Method and Description |
|---|---|
static Set<String> |
extractApnsTopics(X509Certificate certificate)
Extract topics for sending push notifications from
X509Certificate certificate. |
static org.apache.commons.lang3.tuple.ImmutablePair<PrivateKey,X509Certificate> |
extractCertificateWithKey(KeyStore keyStore,
char[] keyStorePassword)
Extract a pair of key and certificate from an already loaded
KeyStore. |
static String |
getProviderName() |
static InputStream |
toInputStream(String path)
Load a keystore from an already opened
InputStream. |
static KeyStore |
toKeyStore(InputStream keyStoreInputStream,
char[] keyStorePassword)
Load a keystore from an already opened
InputStream. |
static X509Certificate |
toX509Certificate(InputStream certificateInputStream)
Load a DER Certificate from an already opened
InputStream. |
public static InputStream toInputStream(String path) throws FileNotFoundException
InputStream.
The caller is responsible for closing the resulting stream when it's no longer needed.path - path of a key store or certificate.InputStream loaded from pathFileNotFoundException - If no file exists at the given path.public static KeyStore toKeyStore(InputStream keyStoreInputStream, char[] keyStorePassword) throws CertificateException
InputStream.
The caller is responsible for closing the stream after this method completes successfully or fails.keyStoreInputStream - InputStream containing the signing key store.keyStorePassword - password to access the key store.KeyStore loaded from keyPathIllegalArgumentException - If either keyPath is or keyPath or keyPassword is empty.IllegalStateException - If KeyStore loading failed.CertificateException - If any of the certificates in the keystore could not be loaded.public static X509Certificate toX509Certificate(InputStream certificateInputStream) throws CertificateException
InputStream.
The caller is responsible for closing the stream after this method completes successfully or fails.certificateInputStream - InputStream containing the certificate.X509Certificate loaded from certificateInputStreamIllegalStateException - If X509Certificate loading failed.CertificateException - If X509Certificate is invalid or cannot be loaded.public static org.apache.commons.lang3.tuple.ImmutablePair<PrivateKey,X509Certificate> extractCertificateWithKey(KeyStore keyStore, char[] keyStorePassword)
KeyStore.keyStore - KeyStore instance.keyStorePassword - password to access the key store.PrivateKey and X509Certificate loaded from keyStoreIllegalStateException - If X509Certificate loading failed.public static Set<String> extractApnsTopics(X509Certificate certificate) throws IOException
X509Certificate certificate.certificate - X509Certificate instance.Set of topics from a certificateIOException - If X509Certificate parsing failed.public static String getProviderName()
Copyright © 2012–2022. All rights reserved.