Search in sources :

Example 6 with XmlAnyType

use of xades4j.xml.bind.xades.XmlAnyType in project xades4j by luisgoncalves.

the class ToXmlCommitmentTypeConverter method convertIntoObjectTree.

@Override
public void convertIntoObjectTree(PropertyDataObject propData, XmlSignedPropertiesType xmlProps, Document doc) {
    CommitmentTypeData commitmentTypeData = (CommitmentTypeData) propData;
    // Create the JAXB CommitmentTypeIndication and add it to SignedDataObjectProperties.
    XmlCommitmentTypeIndicationType xmlCommitmentTypeProp = new XmlCommitmentTypeIndicationType();
    xmlProps.getSignedDataObjectProperties().getCommitmentTypeIndication().add(xmlCommitmentTypeProp);
    XmlIdentifierType xmlIdentifier = new XmlIdentifierType();
    xmlIdentifier.setValue(commitmentTypeData.getUri());
    XmlObjectIdentifierType xmlObjectId = new XmlObjectIdentifierType();
    xmlObjectId.setDescription(commitmentTypeData.getDescription());
    xmlObjectId.setIdentifier(xmlIdentifier);
    xmlCommitmentTypeProp.setCommitmentTypeId(xmlObjectId);
    Collection<String> refsUris = commitmentTypeData.getObjReferences();
    if (null == refsUris) {
        xmlCommitmentTypeProp.setAllSignedDataObjects();
    } else {
        xmlCommitmentTypeProp.getObjectReference().addAll(refsUris);
    }
    Collection qualifiers = commitmentTypeData.getQualifiers();
    if (!qualifiers.isEmpty()) {
        XmlCommitmentTypeQualifiersListType xmlQualifiers = new XmlCommitmentTypeQualifiersListType();
        for (Object q : qualifiers) {
            XmlAnyType xmlQualifier = new XmlAnyType();
            xmlQualifier.getContent().add(q);
            xmlQualifiers.getCommitmentTypeQualifier().add(xmlQualifier);
        }
        xmlCommitmentTypeProp.setCommitmentTypeQualifiers(xmlQualifiers);
    }
}
Also used : XmlAnyType(xades4j.xml.bind.xades.XmlAnyType) XmlIdentifierType(xades4j.xml.bind.xades.XmlIdentifierType) XmlCommitmentTypeIndicationType(xades4j.xml.bind.xades.XmlCommitmentTypeIndicationType) XmlObjectIdentifierType(xades4j.xml.bind.xades.XmlObjectIdentifierType) XmlCommitmentTypeQualifiersListType(xades4j.xml.bind.xades.XmlCommitmentTypeQualifiersListType) Collection(java.util.Collection) PropertyDataObject(xades4j.properties.data.PropertyDataObject) CommitmentTypeData(xades4j.properties.data.CommitmentTypeData)

Example 7 with XmlAnyType

use of xades4j.xml.bind.xades.XmlAnyType in project xades4j by luisgoncalves.

the class FromXmlSignaturePolicyConverter method getLocationUrl.

private static String getLocationUrl(XmlSignaturePolicyIdType xmlPolicyId) throws PropertyUnmarshalException {
    XmlSigPolicyQualifiersListType sigPolicyQualifiers = xmlPolicyId.getSigPolicyQualifiers();
    if (null == sigPolicyQualifiers) {
        return null;
    }
    List<XmlAnyType> xmlQualifiers = sigPolicyQualifiers.getSigPolicyQualifier();
    for (XmlAnyType xmlQualifier : xmlQualifiers) {
        List content = xmlQualifier.getContent();
        if (content.size() == 1 && content.get(0) instanceof JAXBElement) {
            JAXBElement xmlSPURI = (JAXBElement) content.get(0);
            if (xmlSPURI.getName().getLocalPart().equals("SPURI") && xmlSPURI.getName().getNamespaceURI().equals(QualifyingProperty.XADES_XMLNS)) {
                return (String) xmlSPURI.getValue();
            }
        }
    }
    return null;
}
Also used : XmlAnyType(xades4j.xml.bind.xades.XmlAnyType) List(java.util.List) JAXBElement(javax.xml.bind.JAXBElement) XmlSigPolicyQualifiersListType(xades4j.xml.bind.xades.XmlSigPolicyQualifiersListType)

Aggregations

XmlAnyType (xades4j.xml.bind.xades.XmlAnyType)7 Collection (java.util.Collection)2 List (java.util.List)2 JAXBElement (javax.xml.bind.JAXBElement)2 CommitmentTypeData (xades4j.properties.data.CommitmentTypeData)2 SignerRoleData (xades4j.properties.data.SignerRoleData)2 XmlCommitmentTypeIndicationType (xades4j.xml.bind.xades.XmlCommitmentTypeIndicationType)2 XmlCommitmentTypeQualifiersListType (xades4j.xml.bind.xades.XmlCommitmentTypeQualifiersListType)2 XmlSigPolicyQualifiersListType (xades4j.xml.bind.xades.XmlSigPolicyQualifiersListType)2 XmlSignerRoleType (xades4j.xml.bind.xades.XmlSignerRoleType)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 QName (javax.xml.namespace.QName)1 Element (org.w3c.dom.Element)1 GenericDOMData (xades4j.properties.data.GenericDOMData)1 PropertyDataObject (xades4j.properties.data.PropertyDataObject)1 XmlClaimedRolesListType (xades4j.xml.bind.xades.XmlClaimedRolesListType)1 XmlDigestAlgAndValueType (xades4j.xml.bind.xades.XmlDigestAlgAndValueType)1 XmlIdentifierType (xades4j.xml.bind.xades.XmlIdentifierType)1 XmlObjectIdentifierType (xades4j.xml.bind.xades.XmlObjectIdentifierType)1