Skip to content

Commit

Permalink
SHIBUI-2581
Browse files Browse the repository at this point in the history
Remove validUntil from the EntityDescriptor (by default) XML uploads
  • Loading branch information
chasegawa committed Jul 6, 2023
1 parent b2de084 commit 274218d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public Instant getValidUntil() {

@Override
public void setValidUntil(Instant validUntilInstant) {
this.validUntil = new DateTime(validUntilInstant.toEpochMilli());
this.validUntil = validUntilInstant == null ? null : new DateTime(validUntilInstant.toEpochMilli());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import org.opensaml.xmlsec.signature.KeyName;
import org.opensaml.xmlsec.signature.KeyValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
Expand Down Expand Up @@ -90,6 +91,9 @@ public class JPAEntityDescriptorServiceImpl implements EntityDescriptorService {
@Autowired
private UserService userService;

@Value("${shibui.remove.EntityDescriptor.validUntil:true}")
private Boolean removeValidUntil;

private EntityDescriptor buildDescriptorFromRepresentation(final EntityDescriptor ed, final EntityDescriptorRepresentation representation) {
ed.setEntityID(representation.getEntityId());
ed.setIdOfOwner(representation.getIdOfOwner());
Expand Down Expand Up @@ -273,6 +277,11 @@ public EntityDescriptorRepresentation createNewEntityDescriptorFromXMLOrigin(Ent
userService.getCurrentUserGroup().getApproversList().isEmpty()) {
ed.setApproved(true);
}

if (removeValidUntil) {
ed.setValidUntil(null);
}

EntityDescriptor savedEntity = entityDescriptorRepository.save(ed);
return createRepresentationFromDescriptor(savedEntity);
}
Expand Down
5 changes: 4 additions & 1 deletion backend/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,7 @@ springdoc.pathsToMatch=/entities, /api/**
management.endpoints.web.exposure.include=openapi, swagger-ui, info, health
management.server.port=9090
management.endpoints.web.cors.allowed-origins=*
management.endpoints.web.cors.allowed-headers=*
management.endpoints.web.cors.allowed-headers=*

# When true, this will remove the validUntil attribute for an EntityDescriptor uploaded from XML source, only set to false if you want the XML uploaded as is
# shibui.remove.EntityDescriptor.validUntil=true

0 comments on commit 274218d

Please sign in to comment.