Search in sources :

Example 6 with StatusType

use of org.apache.cxf.xkms.model.xkms.StatusType in project cxf by apache.

the class ValidatorTest method testDaveSignedByAliceSginedByRootIsValid.

@Test
public void testDaveSignedByAliceSginedByRootIsValid() throws JAXBException, CertificateException {
    X509Certificate daveCertificate = readCertificate("dave.cer");
    ValidateRequestType request = prepareValidateXKMSRequest(daveCertificate);
    StatusType result = doValidate(request);
    Assert.assertEquals(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALID, result.getStatusValue());
    Assert.assertFalse(result.getValidReason().isEmpty());
    Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALIDITY_INTERVAL.value(), result.getValidReason().get(0));
    Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_ISSUER_TRUST.value(), result.getValidReason().get(1));
}
Also used : StatusType(org.apache.cxf.xkms.model.xkms.StatusType) X509Certificate(java.security.cert.X509Certificate) ValidateRequestType(org.apache.cxf.xkms.model.xkms.ValidateRequestType) BasicIntegrationTest(org.apache.cxf.xkms.itests.BasicIntegrationTest) Test(org.junit.Test)

Example 7 with StatusType

use of org.apache.cxf.xkms.model.xkms.StatusType in project cxf by apache.

the class DateValidator method validate.

@Override
public StatusType validate(ValidateRequestType request) {
    StatusType status = new StatusType();
    List<X509Certificate> certificates = ValidateRequestParser.parse(request);
    if (certificates == null || certificates.isEmpty()) {
        status.setStatusValue(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_INDETERMINATE);
        status.getIndeterminateReason().add("http://www.cxf.apache.org/2002/03/xkms#RequestNotSupported");
    }
    if (isCertificateChainValid(certificates)) {
        status.getValidReason().add(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALIDITY_INTERVAL.value());
        status.setStatusValue(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALID);
    } else {
        status.getInvalidReason().add(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALIDITY_INTERVAL.value());
        status.setStatusValue(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_INVALID);
    }
    return status;
}
Also used : StatusType(org.apache.cxf.xkms.model.xkms.StatusType) X509Certificate(java.security.cert.X509Certificate)

Example 8 with StatusType

use of org.apache.cxf.xkms.model.xkms.StatusType in project cxf by apache.

the class DirectTrustValidator method validate.

@Override
public StatusType validate(ValidateRequestType request) {
    StatusType status = new StatusType();
    if (request.getQueryKeyBinding() != null) {
        List<KeyUsageEnum> keyUsages = request.getQueryKeyBinding().getKeyUsage();
        if (keyUsages.contains(KeyUsageEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_SIGNATURE)) {
            List<X509Certificate> certificates = ValidateRequestParser.parse(request);
            if (certificates == null || certificates.isEmpty()) {
                status.setStatusValue(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_INDETERMINATE);
                status.getIndeterminateReason().add("http://www.cxf.apache.org/2002/03/xkms#RequestNotSupported");
                return status;
            }
            for (X509Certificate certificate : certificates) {
                if (!isCertificateInRepo(certificate)) {
                    LOG.warning("Certificate is not found in XKMS repo and is not directly trusted: " + certificate.getSubjectDN().getName());
                    status.getInvalidReason().add(XKMSConstants.DIRECT_TRUST_VALIDATION);
                    status.setStatusValue(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_INVALID);
                    return status;
                }
            }
            status.getValidReason().add(XKMSConstants.DIRECT_TRUST_VALIDATION);
        }
    }
    status.setStatusValue(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALID);
    return status;
}
Also used : StatusType(org.apache.cxf.xkms.model.xkms.StatusType) X509Certificate(java.security.cert.X509Certificate) KeyUsageEnum(org.apache.cxf.xkms.model.xkms.KeyUsageEnum)

Example 9 with StatusType

use of org.apache.cxf.xkms.model.xkms.StatusType in project cxf by apache.

the class DateValidatorTest method validateDateExpired.

@Test
public void validateDateExpired() throws JAXBException {
    StatusType result = processRequest("/validateRequestExpired.xml");
    Assert.assertEquals(result.getStatusValue(), KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_INVALID);
    Assert.assertFalse(result.getInvalidReason().isEmpty());
    Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALIDITY_INTERVAL.value(), result.getInvalidReason().get(0));
}
Also used : StatusType(org.apache.cxf.xkms.model.xkms.StatusType) Test(org.junit.Test)

Example 10 with StatusType

use of org.apache.cxf.xkms.model.xkms.StatusType in project cxf by apache.

the class TrustedAuthorityValidatorTest method testDaveSignedByAliceSginedByRootIsValid.

@Test
public void testDaveSignedByAliceSginedByRootIsValid() throws JAXBException, CertificateException {
    StatusType result = processRequest("validateRequestOKDave.xml");
    Assert.assertEquals(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_VALID, result.getStatusValue());
    Assert.assertFalse(result.getValidReason().isEmpty());
    Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_ISSUER_TRUST.value(), result.getValidReason().get(0));
}
Also used : StatusType(org.apache.cxf.xkms.model.xkms.StatusType) Test(org.junit.Test)

Aggregations

StatusType (org.apache.cxf.xkms.model.xkms.StatusType)24 Test (org.junit.Test)15 X509Certificate (java.security.cert.X509Certificate)12 BasicIntegrationTest (org.apache.cxf.xkms.itests.BasicIntegrationTest)9 ValidateRequestType (org.apache.cxf.xkms.model.xkms.ValidateRequestType)9 KeyBindingType (org.apache.cxf.xkms.model.xkms.KeyBindingType)3 UnverifiedKeyBindingType (org.apache.cxf.xkms.model.xkms.UnverifiedKeyBindingType)2 XKMSException (org.apache.cxf.xkms.exception.XKMSException)1 Validator (org.apache.cxf.xkms.handlers.Validator)1 KeyUsageEnum (org.apache.cxf.xkms.model.xkms.KeyUsageEnum)1 PrototypeKeyBindingType (org.apache.cxf.xkms.model.xkms.PrototypeKeyBindingType)1 ValidateResultType (org.apache.cxf.xkms.model.xkms.ValidateResultType)1