Search in sources :

Example 6 with X509DataType

use of org.apache.cxf.xkms.model.xmldsig.X509DataType 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 X509DataType

use of org.apache.cxf.xkms.model.xmldsig.X509DataType in project cxf by apache.

the class X509Utils method getKeyInfo.

public static KeyInfoType getKeyInfo(X509Certificate cert) throws CertificateEncodingException {
    KeyInfoType keyInfo = new KeyInfoType();
    JAXBElement<byte[]> certificate = new ObjectFactory().createX509DataTypeX509Certificate(cert.getEncoded());
    X509DataType x509DataType = new X509DataType();
    List<Object> x509DataContent = x509DataType.getX509IssuerSerialOrX509SKIOrX509SubjectName();
    x509DataContent.add(certificate);
    JAXBElement<X509DataType> x509Data = new ObjectFactory().createX509Data(x509DataType);
    List<Object> keyInfoContent = keyInfo.getContent();
    keyInfoContent.add(x509Data);
    return keyInfo;
}
Also used : X509DataType(org.apache.cxf.xkms.model.xmldsig.X509DataType) ObjectFactory(org.apache.cxf.xkms.model.xmldsig.ObjectFactory) KeyInfoType(org.apache.cxf.xkms.model.xmldsig.KeyInfoType)

Aggregations

X509DataType (org.apache.cxf.xkms.model.xmldsig.X509DataType)7 KeyInfoType (org.apache.cxf.xkms.model.xmldsig.KeyInfoType)5 CertificateEncodingException (java.security.cert.CertificateEncodingException)3 JAXBElement (javax.xml.bind.JAXBElement)3 QueryKeyBindingType (org.apache.cxf.xkms.model.xkms.QueryKeyBindingType)3 ValidateRequestType (org.apache.cxf.xkms.model.xkms.ValidateRequestType)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 X509Certificate (java.security.cert.X509Certificate)2 ArrayList (java.util.ArrayList)2 CertificateException (java.security.cert.CertificateException)1 CertificateFactory (java.security.cert.CertificateFactory)1 List (java.util.List)1 XKMSException (org.apache.cxf.xkms.exception.XKMSException)1 XKMSLocateException (org.apache.cxf.xkms.exception.XKMSLocateException)1 UseKeyWithType (org.apache.cxf.xkms.model.xkms.UseKeyWithType)1 ObjectFactory (org.apache.cxf.xkms.model.xmldsig.ObjectFactory)1 X509IssuerSerialType (org.apache.cxf.xkms.model.xmldsig.X509IssuerSerialType)1