use of xades4j.properties.data.SignerRoleData 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));
}
use of xades4j.properties.data.SignerRoleData 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);
}
Aggregations