use of java.security.cert.CRLException in project jdk8u_jdk by JetBrains.
the class AlgorithmChecker method check.
/**
* Check the signature algorithm with the specified public key.
*
* @param key the public key to verify the CRL signature
* @param crl the target CRL
* @param variant is the Validator variants of the operation. A null value
* passed will set it to Validator.GENERIC.
*/
static void check(PublicKey key, X509CRL crl, String variant) throws CertPathValidatorException {
X509CRLImpl x509CRLImpl = null;
try {
x509CRLImpl = X509CRLImpl.toImpl(crl);
} catch (CRLException ce) {
throw new CertPathValidatorException(ce);
}
AlgorithmId algorithmId = x509CRLImpl.getSigAlgId();
check(key, algorithmId, variant);
}
use of java.security.cert.CRLException in project jdk8u_jdk by JetBrains.
the class CRLExtensions method init.
// helper routine
private void init(DerInputStream derStrm) throws CRLException {
try {
DerInputStream str = derStrm;
byte nextByte = (byte) derStrm.peekByte();
// check for context specific byte 0; skip it
if (((nextByte & 0x0c0) == 0x080) && ((nextByte & 0x01f) == 0x000)) {
DerValue val = str.getDerValue();
str = val.data;
}
DerValue[] exts = str.getSequence(5);
for (int i = 0; i < exts.length; i++) {
Extension ext = new Extension(exts[i]);
parseExtension(ext);
}
} catch (IOException e) {
throw new CRLException("Parsing error: " + e.toString());
}
}
use of java.security.cert.CRLException in project jdk8u_jdk by JetBrains.
the class CRLExtensions method encode.
/**
* Encode the extensions in DER form to the stream.
*
* @param out the DerOutputStream to marshal the contents to.
* @param isExplicit the tag indicating whether this is an entry
* extension (false) or a CRL extension (true).
* @exception CRLException on encoding errors.
*/
public void encode(OutputStream out, boolean isExplicit) throws CRLException {
try {
DerOutputStream extOut = new DerOutputStream();
Collection<Extension> allExts = map.values();
Object[] objs = allExts.toArray();
for (int i = 0; i < objs.length; i++) {
if (objs[i] instanceof CertAttrSet)
((CertAttrSet) objs[i]).encode(extOut);
else if (objs[i] instanceof Extension)
((Extension) objs[i]).encode(extOut);
else
throw new CRLException("Illegal extension object");
}
DerOutputStream seq = new DerOutputStream();
seq.write(DerValue.tag_Sequence, extOut);
DerOutputStream tmp = new DerOutputStream();
if (isExplicit)
tmp.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0), seq);
else
tmp = seq;
out.write(tmp.toByteArray());
} catch (IOException e) {
throw new CRLException("Encoding error: " + e.toString());
} catch (CertificateException e) {
throw new CRLException("Encoding error: " + e.toString());
}
}
use of java.security.cert.CRLException in project jdk8u_jdk by JetBrains.
the class CRLExtensions method parseExtension.
// Parse the encoded extension
private void parseExtension(Extension ext) throws CRLException {
try {
Class<?> extClass = OIDMap.getClass(ext.getExtensionId());
if (extClass == null) {
// Unsupported extension
if (ext.isCritical())
unsupportedCritExt = true;
if (map.put(ext.getExtensionId().toString(), ext) != null)
throw new CRLException("Duplicate extensions not allowed");
return;
}
Constructor<?> cons = extClass.getConstructor(PARAMS);
Object[] passed = new Object[] { Boolean.valueOf(ext.isCritical()), ext.getExtensionValue() };
CertAttrSet<?> crlExt = (CertAttrSet<?>) cons.newInstance(passed);
if (map.put(crlExt.getName(), (Extension) crlExt) != null) {
throw new CRLException("Duplicate extensions not allowed");
}
} catch (InvocationTargetException invk) {
throw new CRLException(invk.getTargetException().getMessage());
} catch (Exception e) {
throw new CRLException(e.toString());
}
}
use of java.security.cert.CRLException in project jdk8u_jdk by JetBrains.
the class X509CRLEntryImpl method parse.
private void parse(DerValue derVal) throws CRLException, IOException {
if (derVal.tag != DerValue.tag_Sequence) {
throw new CRLException("Invalid encoded RevokedCertificate, " + "starting sequence tag missing.");
}
if (derVal.data.available() == 0)
throw new CRLException("No data encoded for RevokedCertificates");
revokedCert = derVal.toByteArray();
// serial number
DerInputStream in = derVal.toDerInputStream();
DerValue val = in.getDerValue();
this.serialNumber = new SerialNumber(val);
// revocationDate
int nextByte = derVal.data.peekByte();
if ((byte) nextByte == DerValue.tag_UtcTime) {
this.revocationDate = derVal.data.getUTCTime();
} else if ((byte) nextByte == DerValue.tag_GeneralizedTime) {
this.revocationDate = derVal.data.getGeneralizedTime();
} else
throw new CRLException("Invalid encoding for revocation date");
if (derVal.data.available() == 0)
// no extensions
return;
// crlEntryExtensions
this.extensions = new CRLExtensions(derVal.toDerInputStream());
}
Aggregations