Class CertificateLoadUtil
java.lang.Object
org.globus.gsi.util.CertificateLoadUtil
Contains various security-related utility methods.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static CertificateFactoryReturns appropriateCertificateFactory.static Collection<X509Certificate> getTrustedCertificates(KeyStore keyStore, X509CertSelector selector) static voidinit()A no-op function that can be used to force the class to load and initialize.static X509CertificateLoads a X509 certificate from the specified input stream.static X509CertificateloadCertificate(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 X509CRLloadCrl(InputStream in) static X509CRLstatic X509CertificatereadCertificate(BufferedReader reader) Loads a X.509 certificate from the specified reader.static voidsetProvider(String providerName) Sets a provider name to use for loading certificates and for generating key pairs.
-
Field Details
-
logger
private static org.apache.commons.logging.Log logger -
provider
-
-
Constructor Details
-
CertificateLoadUtil
private CertificateLoadUtil()
-
-
Method Details
-
init
public static void init()A no-op function that can be used to force the class to load and initialize. -
setProvider
Sets a provider name to use for loading certificates and for generating key pairs.- Parameters:
providerName- provider name to use.
-
getCertificateFactory
Returns appropriateCertificateFactory. If provider was set a provider-specificCertificateFactorywill be used. Otherwise, a defaultCertificateFactorywill be used.- Returns:
CertificateFactory- Throws:
GeneralSecurityException
-
loadCertificate
Loads a X509 certificate from the specified input stream. Input stream must contain DER-encoded certificate.- Parameters:
in- the input stream to read the certificate from.- Returns:
X509Certificatethe loaded certificate.- Throws:
GeneralSecurityException- if certificate failed to load.
-
loadCertificate
public static X509Certificate loadCertificate(String file) throws IOException, GeneralSecurityException Loads an X.509 certificate from the specified file. The certificate file must be in PEM/Base64 format and start with "BEGIN CERTIFICATE" and end with "END CERTIFICATE" line.- Parameters:
file- the file to load the certificate from.- Returns:
java.security.cert.X509Certificatethe loaded certificate.- Throws:
IOException- if I/O error occursGeneralSecurityException- if security problems occurs.
-
loadCertificates
public static X509Certificate[] loadCertificates(String file) throws IOException, GeneralSecurityException Loads multiple X.509 certificates from the specified file. Each certificate must be in PEM/Base64 format and start with "BEGIN CERTIFICATE" and end with "END CERTIFICATE" line.- Parameters:
file- the certificate file to load the certificate from.- Returns:
- an array of certificates loaded from the file.
- Throws:
IOException- if I/O error occursGeneralSecurityException- if security problems occurs.
-
readCertificate
public static X509Certificate readCertificate(BufferedReader reader) throws IOException, GeneralSecurityException Loads a X.509 certificate from the specified reader. The certificate contents must start with "BEGIN CERTIFICATE" line and end with "END CERTIFICATE" line, and be in PEM/Base64 format.This function does not close the input stream.
- Parameters:
reader- the stream from which load the certificate.- Returns:
- the loaded certificate or null if there was no certificate in the stream or the stream is closed.
- Throws:
IOException- if I/O error occursGeneralSecurityException- if security problems occurs.
-
loadCrl
- Throws:
IOExceptionGeneralSecurityException
-
loadCrl
- Throws:
GeneralSecurityException
-
getTrustedCertificates
public static Collection<X509Certificate> getTrustedCertificates(KeyStore keyStore, X509CertSelector selector) throws KeyStoreException - Throws:
KeyStoreException
-