/** * Create an instance of {@link XmlOID } * */ public XmlOID createXmlOID() { return new XmlOID(); }
private List<String> getReadable(List<XmlOID> oids) { if (Utils.isCollectionNotEmpty(oids)) { List<String> result = new ArrayList<String>(); for (XmlOID xmlOID : oids) { if (Utils.isStringNotEmpty(xmlOID.getDescription())) { result.add(xmlOID.getDescription()); } else { result.add(xmlOID.getValue()); } } return result; } return null; }
private List<String> getOidValues(List<? extends XmlOID> xmlOids) { List<String> result = new ArrayList<String>(); if (Utils.isCollectionNotEmpty(xmlOids)) { for (XmlOID xmlOID : xmlOids) { result.add(xmlOID.getValue()); } } return result; }
public boolean isIdKpOCSPSigning() { List<XmlOID> extendedKeyUsages = certificate.getExtendedKeyUsages(); if (Utils.isCollectionNotEmpty(extendedKeyUsages)) { for (XmlOID xmlOID : extendedKeyUsages) { if (Utils.areStringsEqual(ExtendedKeyUsageOids.OCSP_SIGNING.getOid(), xmlOID.getValue())) { return true; } } } return false; }
@Test public void certificateQCStatementCheck() throws Exception { List<XmlOID> qcStatementIds = new ArrayList<XmlOID>(); XmlOID oid = new XmlOID(); oid.setValue("0.4.0.1862.1.1"); qcStatementIds.add(oid); MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("0.4.0.1862.1.1"); XmlCertificate xc = new XmlCertificate(); xc.setQCStatementIds(qcStatementIds); XmlSubXCV result = new XmlSubXCV(); CertificateQCStatementIdsCheck cqcsic = new CertificateQCStatementIdsCheck(result, new CertificateWrapper(xc), constraint); cqcsic.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.OK, constraints.get(0).getStatus()); }
@Test public void failedCertificateQCStatementCheck() throws Exception { List<XmlOID> qcStatementIds = new ArrayList<XmlOID>(); XmlOID oid = new XmlOID(); oid.setValue("0.4.0.1862.1.1"); qcStatementIds.add(oid); MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("0.4.0.1862.1.2"); XmlCertificate xc = new XmlCertificate(); xc.setQCStatementIds(qcStatementIds); XmlSubXCV result = new XmlSubXCV(); CertificateQCStatementIdsCheck cqcsic = new CertificateQCStatementIdsCheck(result, new CertificateWrapper(xc), constraint); cqcsic.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.NOT_OK, constraints.get(0).getStatus()); }
@Test public void certificateQualifiedCheckWithQCStatement() throws Exception { LevelConstraint constraint = new LevelConstraint(); constraint.setLevel(Level.FAIL); XmlCertificate xc = new XmlCertificate(); List<XmlOID> qcStatementIds = new ArrayList<XmlOID>(); XmlOID oid = new XmlOID(); oid.setValue(QCStatementOids.QC_COMPLIANCE.getOid()); qcStatementIds.add(oid); xc.setQCStatementIds(qcStatementIds); XmlSubXCV result = new XmlSubXCV(); CertificateQualifiedCheck cqc = new CertificateQualifiedCheck(result, new CertificateWrapper(xc), constraint); cqc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.OK, constraints.get(0).getStatus()); }