Search in sources :

Example 1 with ValidateRequestType

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

the class ValidatorCRLTest method prepareValidateXKMSRequest.

/*
     * Method is taken from {@link org.apache.cxf.xkms.client.XKMSInvoker}.
     */
private ValidateRequestType prepareValidateXKMSRequest(X509Certificate cert) {
    JAXBElement<byte[]> x509Cert;
    try {
        x509Cert = DSIG_OF.createX509DataTypeX509Certificate(cert.getEncoded());
    } catch (CertificateEncodingException e) {
        throw new IllegalArgumentException(e);
    }
    X509DataType x509DataType = DSIG_OF.createX509DataType();
    x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName().add(x509Cert);
    JAXBElement<X509DataType> x509Data = DSIG_OF.createX509Data(x509DataType);
    KeyInfoType keyInfoType = DSIG_OF.createKeyInfoType();
    keyInfoType.getContent().add(x509Data);
    QueryKeyBindingType queryKeyBindingType = XKMS_OF.createQueryKeyBindingType();
    queryKeyBindingType.setKeyInfo(keyInfoType);
    ValidateRequestType validateRequestType = XKMS_OF.createValidateRequestType();
    setGenericRequestParams(validateRequestType);
    validateRequestType.setQueryKeyBinding(queryKeyBindingType);
    // temporary
    validateRequestType.setId(cert.getSubjectDN().toString());
    return validateRequestType;
}
Also used : X509DataType(org.apache.cxf.xkms.model.xmldsig.X509DataType) QueryKeyBindingType(org.apache.cxf.xkms.model.xkms.QueryKeyBindingType) CertificateEncodingException(java.security.cert.CertificateEncodingException) KeyInfoType(org.apache.cxf.xkms.model.xmldsig.KeyInfoType) ValidateRequestType(org.apache.cxf.xkms.model.xkms.ValidateRequestType)

Example 2 with ValidateRequestType

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

the class ValidatorCRLTest method testValidCertWithCRL.

@Test
public void testValidCertWithCRL() throws CertificateException {
    X509Certificate wss40Certificate = readCertificate("wss40.cer");
    ValidateRequestType request = prepareValidateXKMSRequest(wss40Certificate);
    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 3 with ValidateRequestType

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

the class ValidatorCRLTest method testRevokedCertificate.

@Test
public void testRevokedCertificate() throws CertificateException {
    X509Certificate wss40Certificate = readCertificate("wss40rev.cer");
    ValidateRequestType request = prepareValidateXKMSRequest(wss40Certificate);
    StatusType result = doValidate(request);
    Assert.assertEquals(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_INVALID, result.getStatusValue());
    Assert.assertFalse(result.getInvalidReason().isEmpty());
    Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_ISSUER_TRUST.value(), result.getInvalidReason().get(0));
}
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 4 with ValidateRequestType

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

the class ValidatorTest method testExpiredCertIsNotValid.

@Test
public void testExpiredCertIsNotValid() throws CertificateException {
    X509Certificate expiredCertificate = readCertificate("expired.cer");
    ValidateRequestType request = prepareValidateXKMSRequest(expiredCertificate);
    StatusType result = doValidate(request);
    Assert.assertEquals(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_INVALID, result.getStatusValue());
    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) 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 5 with ValidateRequestType

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

the class ValidatorTest method testSelfSignedCertOscarIsNotValid.

@Test
public void testSelfSignedCertOscarIsNotValid() throws JAXBException, CertificateException {
    X509Certificate oscarCertificate = readCertificate("oscar.cer");
    ValidateRequestType request = prepareValidateXKMSRequest(oscarCertificate);
    StatusType result = doValidate(request);
    Assert.assertEquals(KeyBindingEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_INVALID, result.getStatusValue());
    Assert.assertFalse(result.getInvalidReason().isEmpty());
    Assert.assertEquals(ReasonEnum.HTTP_WWW_W_3_ORG_2002_03_XKMS_ISSUER_TRUST.value(), result.getInvalidReason().get(0));
}
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)

Aggregations

ValidateRequestType (org.apache.cxf.xkms.model.xkms.ValidateRequestType)16 Test (org.junit.Test)11 X509Certificate (java.security.cert.X509Certificate)10 BasicIntegrationTest (org.apache.cxf.xkms.itests.BasicIntegrationTest)9 StatusType (org.apache.cxf.xkms.model.xkms.StatusType)9 InputStream (java.io.InputStream)3 CertificateEncodingException (java.security.cert.CertificateEncodingException)3 JAXBElement (javax.xml.bind.JAXBElement)3 QueryKeyBindingType (org.apache.cxf.xkms.model.xkms.QueryKeyBindingType)3 KeyInfoType (org.apache.cxf.xkms.model.xmldsig.KeyInfoType)3 X509DataType (org.apache.cxf.xkms.model.xmldsig.X509DataType)3 BasicValidationTest (org.apache.cxf.xkms.x509.validator.BasicValidationTest)2 XKMSValidateException (org.apache.cxf.xkms.exception.XKMSValidateException)1 ValidateResultType (org.apache.cxf.xkms.model.xkms.ValidateResultType)1