|
ehsbe CommonsTM Version 1.1.0rc3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ehsbe.commons.gui.util.JxInvalidCertHandler
public class JxInvalidCertHandler
A GUI based example implementation of an InvalidCertHandler
, which
might be used with a LocalTrustManager
to ask the user, what to do
with unknown certificates as well as to store acceptions permanently.
Constructor Summary | |
---|---|
JxInvalidCertHandler()
Create a handler, which initially has no acceptions for unknown certificates defined. |
|
JxInvalidCertHandler(File certBundlePath)
Create a handler, which accepts all certificates listed in the given file automatically. |
|
JxInvalidCertHandler(InputStream bundleStream)
Create a handler, which accepts all certificates listed in the given file automatically. |
Method Summary | |
---|---|
boolean |
accept(X509Certificate[] chain,
CertificateException ex)
Handles the invalid certificate chain and corresponding exception. |
File |
getCertBundlePath()
Get the cert bundle file, which has been used to populate the internal list of certificates, which should be accepted automatically. |
Set<X509Certificate> |
getPermanentCerts()
Get all certificates marked as always accept automatically (permanent). |
Set<X509Certificate> |
getSessionOnlyCerts()
Get all certificates marked as accept for this session only (temporary). |
boolean |
hasChanged()
Check, whether the list of permanent certificates has been changed since construction or last save operation. |
void |
reset()
Remove all certificates from internal lists and sets the cert bundle path back to null . |
void |
save()
Save all as permamnently accepted certificates, but only if the set of certificates has been changed since last save/ setCertBundle(File)
and a cert bundle path has been set. |
void |
save(File certBundlePath)
Save all as permamnently accepted certificates to the given file. |
void |
save(OutputStream out)
Save all as permamnently accepted certificates to the given stream. |
void |
setCertBundle(File certBundlePath)
Set the list of X.509 certificates, which should be accepted automatically to all certificates contained in the given bundle. |
void |
setCertBundle(InputStream in)
Set the list of X.509 certificates, which should be accepted automatically (i.e. permanently) to all certificates contained in the given bundle. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JxInvalidCertHandler()
public JxInvalidCertHandler(File certBundlePath) throws CertificateException, IOException
certBundlePath
- a bundle of X509 certificates
IOException
CertificateException
setCertBundle(File)
public JxInvalidCertHandler(InputStream bundleStream) throws CertificateException, IOException
bundleStream
- a stream of X509 certificates
IOException
CertificateException
setCertBundle(InputStream)
Method Detail |
---|
public boolean accept(X509Certificate[] chain, CertificateException ex)
accept
in interface InvalidCertHandler
chain
- certificate chain, which could not be validated.ex
- exception thrown during validation.
true
if the calling trust manager entity should add the
first certificate in the chain (aka client or server certificate) to
its trusted certificate list.public void setCertBundle(File certBundlePath) throws CertificateException, IOException
The bundle is expected to be a concatenation of Base64 DER encoded (aka
PEM encoded) X.509 certificates, i.e. each certificate is enclosed
between a "-----BEGIN CERTIFICATE-----" and a "-----END CERTIFICATE-----"
line. See also openssl x509 -in file -inform PEM -text
. The file
itself is US-ASCII
formated.
certBundlePath
- path name of the X.509 certificate
bundle to load. Ignored if null
.
CertificateException
- if no Provider can be found, which supports
X.509 certificates.
IOException
- if the resource can not be found or a read error
occures when reading the resource stream.CertificateFactory.generateCertificate(InputStream)
public void setCertBundle(InputStream in) throws CertificateException, IOException
The bundle is expected to be a concatenation of Base64 DER encoded (aka
PEM encoded) X.509 certificates, i.e. each certificate is enclosed
between a "-----BEGIN CERTIFICATE-----" and a "-----END CERTIFICATE-----"
line. See also openssl x509 -in file -inform PEM -text
. The file
itself is US-ASCII
formated.
in
- the stream of X.509 certificate bundle to load.
CertificateException
- if no Provider can be found, which supports
X.509 certificates.
IOException
- if the resource can not be found or a read error
occures when reading the resource stream.getCertBundlePath()
,
getPermanentCerts()
,
getSessionOnlyCerts()
,
CertificateFactory.generateCertificate(InputStream)
public File getCertBundlePath()
null
if not set, the cert bundle file otherwise.public void save() throws IOException
setCertBundle(File)
and a cert bundle path has been set.
IOException
setCertBundle(File)
,
getCertBundlePath()
public void save(File certBundlePath) throws IOException
certBundlePath
- where to save permanently accepted certificates.
Does nothing if null
.
IOException
- if an write error occurspublic void save(OutputStream out) throws IOException, CertificateEncodingException
out
- where to save permanently accepted certificates.
Does nothing if null
.
IOException
- if an write error occurs
CertificateEncodingException
public Set<X509Certificate> getPermanentCerts()
public Set<X509Certificate> getSessionOnlyCerts()
public void reset()
null
.
public boolean hasChanged()
true
if changed.
|
ehsbe CommonsTM Version 1.1.0rc3 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |