Search in sources :

Example 1 with XmlSignerRoleType

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

the class FromXmlSignerRoleConverter method convertFromObjectTree.

@Override
public void convertFromObjectTree(XmlSignedSignaturePropertiesType xmlProps, QualifyingPropertiesDataCollector propertyDataCollector) throws PropertyUnmarshalException {
    XmlSignerRoleType xmlSignerRole = xmlProps.getSignerRole();
    if (null == xmlSignerRole)
        return;
    if (xmlSignerRole.getCertifiedRoles() != null)
        throw new PropertyUnmarshalException("certified roles not supported", SignerRoleProperty.PROP_NAME);
    Set<String> claimedRoles = new HashSet<String>();
    for (XmlAnyType xmlRole : xmlSignerRole.getClaimedRoles().getClaimedRole()) {
        List contents = xmlRole.getContent();
        if (contents.size() != 1 || !(contents.get(0) instanceof String))
            throw new PropertyUnmarshalException("unsupported claimed role. Only one string is supported", SignerRoleProperty.PROP_NAME);
        claimedRoles.add((String) contents.get(0));
    }
    propertyDataCollector.setSignerRole(new SignerRoleData(claimedRoles));
}
Also used : XmlAnyType(xades4j.xml.bind.xades.XmlAnyType) List(java.util.List) SignerRoleData(xades4j.properties.data.SignerRoleData) XmlSignerRoleType(xades4j.xml.bind.xades.XmlSignerRoleType) HashSet(java.util.HashSet)

Example 2 with XmlSignerRoleType

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

the class ToXmlSignerRoleConverter method convertIntoObjectTree.

@Override
public void convertIntoObjectTree(PropertyDataObject propData, XmlSignedPropertiesType xmlProps, Document doc) {
    SignerRoleData signerRoleData = (SignerRoleData) propData;
    XmlSignerRoleType xmlSignerRole = new XmlSignerRoleType();
    XmlClaimedRolesListType xmlClaimedRoles = new XmlClaimedRolesListType();
    xmlSignerRole.setClaimedRoles(xmlClaimedRoles);
    for (String r : signerRoleData.getClaimedRoles()) {
        XmlAnyType xmlRole = new XmlAnyType();
        xmlRole.getContent().add(r);
        xmlClaimedRoles.getClaimedRole().add(xmlRole);
    }
    xmlProps.getSignedSignatureProperties().setSignerRole(xmlSignerRole);
}
Also used : XmlAnyType(xades4j.xml.bind.xades.XmlAnyType) XmlClaimedRolesListType(xades4j.xml.bind.xades.XmlClaimedRolesListType) SignerRoleData(xades4j.properties.data.SignerRoleData) XmlSignerRoleType(xades4j.xml.bind.xades.XmlSignerRoleType)

Aggregations

SignerRoleData (xades4j.properties.data.SignerRoleData)2 XmlAnyType (xades4j.xml.bind.xades.XmlAnyType)2 XmlSignerRoleType (xades4j.xml.bind.xades.XmlSignerRoleType)2 HashSet (java.util.HashSet)1 List (java.util.List)1 XmlClaimedRolesListType (xades4j.xml.bind.xades.XmlClaimedRolesListType)1