Skip to content

Commit

Permalink
[SHIBUI-1226]
Browse files Browse the repository at this point in the history
add implementation for updating relying party overrides
  • Loading branch information
jj committed Feb 13, 2019
1 parent 370c88b commit 29b5a04
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -300,13 +300,11 @@ private EntityDescriptor buildDescriptorFromRepresentation(final EntityDescripto
}

if (representation.getRelyingPartyOverrides() != null || (representation.getAttributeRelease() != null && representation.getAttributeRelease().size() > 0)) {
// TODO: fix implementation
// TODO: review if we need more than a naive implementation
getOptionalEntityAttributes(ed).ifPresent(entityAttributes -> entityAttributes.getAttributes().clear());
getEntityAttributes(ed).getAttributes().addAll(entityService.getAttributeListFromEntityRepresentation(representation));
} else {
EntityAttributes entityAttributes = getEntityAttributes(ed, false);
if (entityAttributes != null) {
entityAttributes.getAttributes().clear();
}
getOptionalEntityAttributes(ed).ifPresent(entityAttributes -> entityAttributes.getAttributes().clear());
}
return ed;
}
Expand Down Expand Up @@ -387,6 +385,10 @@ private EntityAttributes getEntityAttributes(EntityDescriptor ed) {
return getEntityAttributes(ed, true);
}

private Optional<EntityAttributes> getOptionalEntityAttributes(EntityDescriptor ed) {
return Optional.ofNullable(getEntityAttributes(ed, false));
}

private EntityAttributes getEntityAttributes(EntityDescriptor ed, boolean create) {
Extensions extensions = ed.getExtensions();
if (extensions == null && !create) {
Expand All @@ -397,12 +399,14 @@ private EntityAttributes getEntityAttributes(EntityDescriptor ed, boolean create
ed.setExtensions(extensions);
}

EntityAttributes entityAttributes;
EntityAttributes entityAttributes = null;
if (extensions.getUnknownXMLObjects(EntityAttributes.DEFAULT_ELEMENT_NAME).size() > 0) {
entityAttributes = (EntityAttributes) extensions.getUnknownXMLObjects(EntityAttributes.DEFAULT_ELEMENT_NAME).get(0);
} else {
entityAttributes = ((EntityAttributesBuilder) openSamlObjects.getBuilderFactory().getBuilder(EntityAttributes.DEFAULT_ELEMENT_NAME)).buildObject();
extensions.getUnknownXMLObjects().add(entityAttributes);
if (create) {
entityAttributes = ((EntityAttributesBuilder) openSamlObjects.getBuilderFactory().getBuilder(EntityAttributes.DEFAULT_ELEMENT_NAME)).buildObject();
extensions.getUnknownXMLObjects().add(entityAttributes);
}
}
return entityAttributes;
}
Expand Down

0 comments on commit 29b5a04

Please sign in to comment.