public SubX509CertificateValidation(CertificateWrapper currentCertificate, Date currentTime, Context context, SubContext subContext, ValidationPolicy validationPolicy) { super(new XmlSubXCV()); result.setId(currentCertificate.getId()); result.setTrustAnchor(currentCertificate.isTrusted()); this.currentCertificate = currentCertificate; this.currentTime = currentTime; this.context = context; this.subContext = subContext; this.validationPolicy = validationPolicy; }
@Override protected Indication getFailedIndicationForConclusion() { return subResult.getConclusion().getIndication(); }
public Indication getCertificateXCVIndication(String certificateId) { if (jaxbDetailedReport.getCertificate() == null) { throw new DSSException("Only supported in report for certificate"); } List<XmlBasicBuildingBlocks> basicBuildingBlocks = jaxbDetailedReport.getBasicBuildingBlocks(); for (XmlBasicBuildingBlocks xmlBasicBuildingBlocks : basicBuildingBlocks) { XmlXCV xcv = xmlBasicBuildingBlocks.getXCV(); if (xcv != null) { List<XmlSubXCV> subXCV = xcv.getSubXCV(); for (XmlSubXCV xmlSubXCV : subXCV) { if (Utils.areStringsEqual(certificateId, xmlSubXCV.getId())) { return xmlSubXCV.getConclusion().getIndication(); } } } } return null; }
@Test public void idPkixOcspNoCheck() throws Exception { LevelConstraint constraint = new LevelConstraint(); constraint.setLevel(Level.FAIL); XmlSubXCV result = new XmlSubXCV(); IdPkixOcspNoCheck ic = new IdPkixOcspNoCheck(result, constraint); ic.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.OK, constraints.get(0).getStatus()); }
/** * Create an instance of {@link XmlSubXCV } * */ public XmlSubXCV createXmlSubXCV() { return new XmlSubXCV(); }
public CheckSubXCVResult(XmlXCV result, XmlSubXCV subResult, LevelConstraint constraint) { super(result, constraint, subResult.getId()); this.subResult = subResult; }
validationPolicy); XmlRFC rfcResult = rfc.execute(); result.setRFC(rfcResult);
@Test public void certificateExpirationCheck() throws Exception { LevelConstraint constraint = new LevelConstraint(); constraint.setLevel(Level.FAIL); Date now = new Date(); long nowMil = now.getTime(); XmlCertificate xc = new XmlCertificate(); xc.setNotAfter(new Date(nowMil + 86400000)); // in 24 hours xc.setNotBefore(new Date(nowMil - 86400000)); // 24 hours ago XmlSubXCV result = new XmlSubXCV(); CertificateExpirationCheck cec = new CertificateExpirationCheck(result, new CertificateWrapper(xc), new Date(), constraint); cec.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.OK, constraints.get(0).getStatus()); }
@Test public void failedCertificateExpirationCheck() throws Exception { LevelConstraint constraint = new LevelConstraint(); constraint.setLevel(Level.FAIL); Date now = new Date(); long nowMil = now.getTime(); XmlCertificate xc = new XmlCertificate(); xc.setNotAfter(new Date(nowMil - 86400000)); // 24 hours ago xc.setNotBefore(new Date(nowMil - 172800000)); // 48 hours ago XmlSubXCV result = new XmlSubXCV(); CertificateExpirationCheck cec = new CertificateExpirationCheck(result, new CertificateWrapper(xc), new Date(), constraint); cec.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.NOT_OK, constraints.get(0).getStatus()); } }
@Override protected SubIndication getFailedSubIndicationForConclusion() { return subResult.getConclusion().getSubIndication(); }
@Test public void keyUsageCheck() throws Exception { List<String> keyUsageBits = new ArrayList<String>(); keyUsageBits.add("Valid_Key"); MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add(keyUsageBits.get(0)); XmlCertificate xc = new XmlCertificate(); xc.setKeyUsageBits(keyUsageBits); XmlSubXCV result = new XmlSubXCV(); KeyUsageCheck kuc = new KeyUsageCheck(result, new CertificateWrapper(xc), constraint); kuc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.OK, constraints.get(0).getStatus()); }
@Override protected List<XmlName> getPreviousErrors() { return subResult.getConclusion().getErrors(); }
@Test public void failedCertificateQualifiedCheck() throws Exception { LevelConstraint constraint = new LevelConstraint(); constraint.setLevel(Level.FAIL); XmlCertificate xc = new XmlCertificate(); 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.NOT_OK, constraints.get(0).getStatus()); }
List<XmlSubXCV> subXCV = xmlBasicBuildingBlocks.getXCV().getSubXCV(); for (XmlSubXCV xmlSubXCV : subXCV){ errors.addAll(xmlSubXCV.getConclusion().getErrors()); warnings.addAll(xmlSubXCV.getConclusion().getWarnings());
@Test public void failedKeyUsageCheck() throws Exception { List<String> keyUsageBits = new ArrayList<String>(); keyUsageBits.add("Valid_Key"); MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("Invalid_Key"); XmlCertificate xc = new XmlCertificate(); xc.setKeyUsageBits(keyUsageBits); XmlSubXCV result = new XmlSubXCV(); KeyUsageCheck kuc = new KeyUsageCheck(result, new CertificateWrapper(xc), constraint); kuc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.NOT_OK, constraints.get(0).getStatus()); }
@Test public void failedOrganizationUnitCheck() throws Exception { MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("Invalid_Org"); XmlCertificate xc = new XmlCertificate(); xc.setOrganizationalUnit("Valid_Org"); XmlSubXCV result = new XmlSubXCV(); OrganizationUnitCheck ouc = new OrganizationUnitCheck(result, new CertificateWrapper(xc), constraint); ouc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.NOT_OK, constraints.get(0).getStatus()); }
@Test public void certificateOnHoldCheck() throws Exception { LevelConstraint constraint = new LevelConstraint(); constraint.setLevel(Level.FAIL); XmlRevocation xr = new XmlRevocation(); xr.setStatus(true); XmlCertificate xc = new XmlCertificate(); xc.getRevocations().add(xr); XmlSubXCV result = new XmlSubXCV(); CertificateOnHoldCheck cohc = new CertificateOnHoldCheck(result, new CertificateWrapper(xc), CAL2.getTime(), constraint); cohc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.OK, constraints.get(0).getStatus()); }
@Test public void pseudonymCheck() throws Exception { MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("Valid_Pseudonym"); XmlCertificate xc = new XmlCertificate(); xc.setPseudonym("Valid_Pseudonym"); XmlSubXCV result = new XmlSubXCV(); PseudonymCheck pc = new PseudonymCheck(result, new CertificateWrapper(xc), constraint); pc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.OK, constraints.get(0).getStatus()); }
@Test public void failedCommonNameCheck() throws Exception { MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("Invalid_Name"); XmlCertificate xc = new XmlCertificate(); xc.setCommonName("Valid_Name"); XmlSubXCV result = new XmlSubXCV(); CommonNameCheck cnc = new CommonNameCheck(result, new CertificateWrapper(xc), constraint); cnc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.NOT_OK, constraints.get(0).getStatus()); }
@Test public void failedSurnameCheck() throws Exception { MultiValuesConstraint constraint = new MultiValuesConstraint(); constraint.setLevel(Level.FAIL); constraint.getId().add("Invalid_Surname"); XmlCertificate xc = new XmlCertificate(); xc.setSurname("Valid_Surname"); XmlSubXCV result = new XmlSubXCV(); SurnameCheck sc = new SurnameCheck(result, new CertificateWrapper(xc), constraint); sc.execute(); List<XmlConstraint> constraints = result.getConstraint(); assertEquals(1, constraints.size()); assertEquals(XmlStatus.NOT_OK, constraints.get(0).getStatus()); }