use of java.security.cert.CertificateNotYetValidException in project service-proxy by membrane.
the class TrustManagerWrapper method adjustChain.
private void adjustChain(X509Certificate[] chain) {
for (int i = 0; i < chain.length; i++) {
final X509Certificate x509 = chain[i];
chain[i] = new X509Certificate() {
public boolean hasUnsupportedCriticalExtension() {
return x509.hasUnsupportedCriticalExtension();
}
public Set<String> getCriticalExtensionOIDs() {
return x509.getCriticalExtensionOIDs();
}
@Override
public boolean equals(Object other) {
return x509.equals(other);
}
@Override
public int hashCode() {
return x509.hashCode();
}
public Set<String> getNonCriticalExtensionOIDs() {
return x509.getNonCriticalExtensionOIDs();
}
@Override
public byte[] getEncoded() throws CertificateEncodingException {
return x509.getEncoded();
}
@Override
public void verify(PublicKey key) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException {
x509.verify(key);
}
public byte[] getExtensionValue(String oid) {
return x509.getExtensionValue(oid);
}
@Override
public void verify(PublicKey key, String sigProvider) throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, NoSuchProviderException, SignatureException {
x509.verify(key, sigProvider);
}
@Override
public int getVersion() {
return x509.getVersion();
}
@Override
public BigInteger getSerialNumber() {
return x509.getSerialNumber();
}
@Override
public String toString() {
return x509.toString();
}
@Override
public PublicKey getPublicKey() {
return x509.getPublicKey();
}
@Override
public Principal getIssuerDN() {
return x509.getIssuerDN();
}
@Override
public X500Principal getIssuerX500Principal() {
return x509.getIssuerX500Principal();
}
@Override
public Principal getSubjectDN() {
return x509.getSubjectDN();
}
@Override
public X500Principal getSubjectX500Principal() {
return x509.getSubjectX500Principal();
}
@Override
public Date getNotBefore() {
return x509.getNotBefore();
}
@Override
public Date getNotAfter() {
return x509.getNotAfter();
}
@Override
public byte[] getTBSCertificate() throws CertificateEncodingException {
return x509.getTBSCertificate();
}
@Override
public byte[] getSignature() {
return x509.getSignature();
}
@Override
public String getSigAlgName() {
return x509.getSigAlgName();
}
@Override
public String getSigAlgOID() {
return x509.getSigAlgOID();
}
@Override
public byte[] getSigAlgParams() {
return x509.getSigAlgParams();
}
@Override
public boolean[] getIssuerUniqueID() {
return x509.getIssuerUniqueID();
}
@Override
public boolean[] getSubjectUniqueID() {
return x509.getSubjectUniqueID();
}
@Override
public boolean[] getKeyUsage() {
return x509.getKeyUsage();
}
@Override
public List<String> getExtendedKeyUsage() throws CertificateParsingException {
return x509.getExtendedKeyUsage();
}
@Override
public int getBasicConstraints() {
return x509.getBasicConstraints();
}
@Override
public Collection<List<?>> getSubjectAlternativeNames() throws CertificateParsingException {
return x509.getSubjectAlternativeNames();
}
@Override
public Collection<List<?>> getIssuerAlternativeNames() throws CertificateParsingException {
return x509.getIssuerAlternativeNames();
}
@Override
public void checkValidity(Date date) throws CertificateExpiredException, CertificateNotYetValidException {
if (ignoreTimestampCheckFailure)
return;
x509.checkValidity(date);
}
@Override
public void checkValidity() throws CertificateExpiredException, CertificateNotYetValidException {
if (ignoreTimestampCheckFailure)
return;
x509.checkValidity();
}
};
}
}
use of java.security.cert.CertificateNotYetValidException in project j2objc by google.
the class CertificateNotYetValidExceptionTest method testCertificateNotYetValidException03.
/**
* Test for <code>CertificateNotYetValidException(String)</code>
* constructor Assertion: constructs CertificateNotYetValidException when
* <code>msg</code> is null
*/
public void testCertificateNotYetValidException03() {
String msg = null;
CertificateNotYetValidException tE = new CertificateNotYetValidException(msg);
assertNull("getMessage() must return null.", tE.getMessage());
assertNull("getCause() must return null", tE.getCause());
}
use of java.security.cert.CertificateNotYetValidException in project zm-mailbox by Zimbra.
the class ClientCertAuthenticator method validateClientCert.
private void validateClientCert(X509Certificate[] certs) throws ServiceException {
String subjectDN = null;
try {
boolean revocationCheckEnabled = Provisioning.getInstance().getLocalServer().isMailSSLClientCertOCSPEnabled();
Set<TrustAnchor> trustedCertsSet = null;
if (revocationCheckEnabled) {
char[] pass = LC.client_ssl_truststore_password.value().toCharArray();
trustedCertsSet = CertValidationUtil.loadTrustedAnchors(pass, LC.client_ssl_truststore.value());
}
for (X509Certificate cert : certs) {
subjectDN = getSubjectDNForLogging(cert);
CertValidationUtil.validateCertificate(cert, revocationCheckEnabled, trustedCertsSet);
}
} catch (CertificateExpiredException e) {
throw AuthFailedServiceException.AUTH_FAILED(subjectDN, "client certificate expired", e);
} catch (CertificateNotYetValidException e) {
throw AuthFailedServiceException.AUTH_FAILED(subjectDN, "client certificate not yet valid", e);
} catch (CertificateException e) {
throw AuthFailedServiceException.AUTH_FAILED(subjectDN, "can't generate certpath for client certificate", e);
} catch (KeyStoreException e) {
throw AuthFailedServiceException.AUTH_FAILED(subjectDN, "received KeyStoreException while loading KeyStore", e);
} catch (NoSuchAlgorithmException e) {
throw AuthFailedServiceException.AUTH_FAILED(subjectDN, "received NoSuchAlgorithmException while obtaining instance of certpath validator", e);
} catch (FileNotFoundException e) {
throw AuthFailedServiceException.AUTH_FAILED(subjectDN, "mailboxd keystore can't be found", e);
} catch (IOException e) {
throw AuthFailedServiceException.AUTH_FAILED(subjectDN, "received IOException", e);
} catch (InvalidAlgorithmParameterException e) {
throw AuthFailedServiceException.AUTH_FAILED(subjectDN, "received InvalidAlgorithmParameter while obtaining instance of certpath validator", e);
} catch (CertPathValidatorException e) {
throw AuthFailedServiceException.AUTH_FAILED(subjectDN, "received CertPathValidatorException" + e.getMessage(), e);
}
}
use of java.security.cert.CertificateNotYetValidException in project robovm by robovm.
the class X509CertificateTest method checkValidity.
private void checkValidity(CertificateFactory f) throws Exception {
X509Certificate c = getCertificate(f, CERT_RSA);
Calendar cal = Calendar.getInstance();
Date[] dates = getRsaCertificateDates();
/*
* The certificate validity periods in the test certificate MUST lie
* within the tested period. The API doesn't appear to allow any other
* way to test this code path as an unprivileged user.
*/
Date now = new Date();
assertTrue(now.after(dates[0]));
assertTrue(now.before(dates[1]));
/* This assumes the script makes a long-lived cert. */
c.checkValidity();
/* A day after the start date. */
cal.setTime(dates[0]);
cal.add(Calendar.DAY_OF_MONTH, 1);
c.checkValidity(cal.getTime());
/* A second before the start date. */
cal.setTime(dates[1]);
cal.add(Calendar.SECOND, -1);
c.checkValidity(cal.getTime());
try {
cal.setTime(dates[0]);
cal.add(Calendar.SECOND, -1);
c.checkValidity(cal.getTime());
fail();
} catch (CertificateNotYetValidException expected) {
}
try {
cal.setTime(dates[0]);
cal.add(Calendar.MONTH, -6);
c.checkValidity(cal.getTime());
fail();
} catch (CertificateNotYetValidException expected) {
}
try {
cal.setTime(dates[1]);
cal.add(Calendar.SECOND, 1);
c.checkValidity(cal.getTime());
fail();
} catch (CertificateExpiredException expected) {
}
try {
cal.setTime(dates[1]);
cal.add(Calendar.YEAR, 1);
c.checkValidity(cal.getTime());
fail();
} catch (CertificateExpiredException expected) {
}
}
use of java.security.cert.CertificateNotYetValidException in project robovm by robovm.
the class CertificateNotYetValidExceptionTest method testCertificateNotYetValidException03.
/**
* Test for <code>CertificateNotYetValidException(String)</code>
* constructor Assertion: constructs CertificateNotYetValidException when
* <code>msg</code> is null
*/
public void testCertificateNotYetValidException03() {
String msg = null;
CertificateNotYetValidException tE = new CertificateNotYetValidException(msg);
assertNull("getMessage() must return null.", tE.getMessage());
assertNull("getCause() must return null", tE.getCause());
}
Aggregations