Search in sources :

Example 6 with QueryKeyBindingType

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

the class ValidatorTest method prepareValidateXKMSRequest.

/*
     * Method is taken from {@link org.apache.cxf.xkms.client.XKMSInvokder}.
     */
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 7 with QueryKeyBindingType

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

the class XKMSInvoker method prepareValidateXKMSRequest.

protected 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 8 with QueryKeyBindingType

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

the class XKMSServiceTest method testLocatePKIX.

@Test
public void testLocatePKIX() throws URISyntaxException, Exception {
    LocateRequestType request = XKMS_OF.createLocateRequestType();
    setGenericRequestParams(request);
    QueryKeyBindingType queryKeyBindingType = XKMS_OF.createQueryKeyBindingType();
    UseKeyWithType useKeyWithType = XKMS_OF.createUseKeyWithType();
    useKeyWithType.setIdentifier("CN=Dave, OU=Apache, O=CXF, L=CGN, ST=NRW, C=DE");
    useKeyWithType.setApplication(Applications.PKIX.getUri());
    locateCertificate(request, queryKeyBindingType, useKeyWithType);
}
Also used : QueryKeyBindingType(org.apache.cxf.xkms.model.xkms.QueryKeyBindingType) UseKeyWithType(org.apache.cxf.xkms.model.xkms.UseKeyWithType) LocateRequestType(org.apache.cxf.xkms.model.xkms.LocateRequestType) BasicIntegrationTest(org.apache.cxf.xkms.itests.BasicIntegrationTest) Test(org.junit.Test)

Example 9 with QueryKeyBindingType

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

the class XKMSServiceTest method testLocateByEndpoint.

@Test
public void testLocateByEndpoint() throws URISyntaxException, Exception {
    LocateRequestType request = XKMS_OF.createLocateRequestType();
    setGenericRequestParams(request);
    QueryKeyBindingType queryKeyBindingType = XKMS_OF.createQueryKeyBindingType();
    UseKeyWithType useKeyWithType = XKMS_OF.createUseKeyWithType();
    useKeyWithType.setIdentifier("http://localhost:8080/services/TestService");
    useKeyWithType.setApplication(Applications.SERVICE_ENDPOINT.getUri());
    locateCertificate(request, queryKeyBindingType, useKeyWithType);
}
Also used : QueryKeyBindingType(org.apache.cxf.xkms.model.xkms.QueryKeyBindingType) UseKeyWithType(org.apache.cxf.xkms.model.xkms.UseKeyWithType) LocateRequestType(org.apache.cxf.xkms.model.xkms.LocateRequestType) BasicIntegrationTest(org.apache.cxf.xkms.itests.BasicIntegrationTest) Test(org.junit.Test)

Aggregations

QueryKeyBindingType (org.apache.cxf.xkms.model.xkms.QueryKeyBindingType)9 UseKeyWithType (org.apache.cxf.xkms.model.xkms.UseKeyWithType)6 LocateRequestType (org.apache.cxf.xkms.model.xkms.LocateRequestType)5 KeyInfoType (org.apache.cxf.xkms.model.xmldsig.KeyInfoType)4 CertificateEncodingException (java.security.cert.CertificateEncodingException)3 ValidateRequestType (org.apache.cxf.xkms.model.xkms.ValidateRequestType)3 X509DataType (org.apache.cxf.xkms.model.xmldsig.X509DataType)3 BasicIntegrationTest (org.apache.cxf.xkms.itests.BasicIntegrationTest)2 Test (org.junit.Test)2 InputStream (java.io.InputStream)1 URL (java.net.URL)1 Path (java.nio.file.Path)1 Certificate (java.security.cert.Certificate)1 CertificateFactory (java.security.cert.CertificateFactory)1 X509Certificate (java.security.cert.X509Certificate)1 ArrayList (java.util.ArrayList)1 QName (javax.xml.namespace.QName)1 Service (javax.xml.ws.Service)1 Bus (org.apache.cxf.Bus)1 SpringBusFactory (org.apache.cxf.bus.spring.SpringBusFactory)1