public final class CertificateLoadUtil extends Object
Modifier and Type | Method and Description |
---|---|
protected static CertificateFactory |
getCertificateFactory()
Returns appropriate
CertificateFactory . |
static Collection<X509Certificate> |
getTrustedCertificates(KeyStore keyStore,
X509CertSelector selector) |
static void |
init()
A no-op function that can be used to force the class to load and
initialize.
|
static X509Certificate |
loadCertificate(InputStream in)
Loads a X509 certificate from the specified input stream.
|
static X509Certificate |
loadCertificate(String file)
Loads an X.509 certificate from the specified file.
|
static X509Certificate[] |
loadCertificates(String file)
Loads multiple X.509 certificates from the specified file.
|
static X509CRL |
loadCrl(InputStream in) |
static X509CRL |
loadCrl(String file) |
static X509Certificate |
readCertificate(BufferedReader reader)
Loads a X.509 certificate from the specified reader.
|
static void |
setProvider(String providerName)
Sets a provider name to use for loading certificates and for generating
key pairs.
|
public static void init()
public static void setProvider(String providerName)
providerName
- provider name to use.protected static CertificateFactory getCertificateFactory() throws GeneralSecurityException
CertificateFactory
. If provider
was set a provider-specific CertificateFactory
will be used.
Otherwise, a default CertificateFactory
will be used.CertificateFactory
GeneralSecurityException
public static X509Certificate loadCertificate(InputStream in) throws GeneralSecurityException
in
- the input stream to read the certificate from.X509Certificate
the loaded certificate.GeneralSecurityException
- if certificate failed to load.public static X509Certificate loadCertificate(String file) throws IOException, GeneralSecurityException
file
- the file to load the certificate from.java.security.cert.X509Certificate
the loaded
certificate.IOException
- if I/O error occursGeneralSecurityException
- if security problems occurs.public static X509Certificate[] loadCertificates(String file) throws IOException, GeneralSecurityException
file
- the certificate file to load the certificate from.IOException
- if I/O error occursGeneralSecurityException
- if security problems occurs.public static X509Certificate readCertificate(BufferedReader reader) throws IOException, GeneralSecurityException
reader
- the stream from which load the certificate.IOException
- if I/O error occursGeneralSecurityException
- if security problems occurs.public static X509CRL loadCrl(String file) throws IOException, GeneralSecurityException
IOException
GeneralSecurityException
public static X509CRL loadCrl(InputStream in) throws GeneralSecurityException
GeneralSecurityException
public static Collection<X509Certificate> getTrustedCertificates(KeyStore keyStore, X509CertSelector selector) throws KeyStoreException
KeyStoreException
Copyright © 2016. All rights reserved.