diff --git a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/controller/EntityDescriptorController.java b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/controller/EntityDescriptorController.java index e57870cb9..e4de49273 100644 --- a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/controller/EntityDescriptorController.java +++ b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/controller/EntityDescriptorController.java @@ -104,8 +104,7 @@ public Iterable getDisabledAndNotOwnedByAdmin() @GetMapping("/EntityDescriptor/{resourceId}") @Transactional public ResponseEntity getOne(@PathVariable String resourceId) throws PersistentEntityNotFound, ForbiddenException { - return ResponseEntity.ok(entityDescriptorService - .createRepresentationFromDescriptor(entityDescriptorService.getEntityDescriptorByResourceId(resourceId))); + return ResponseEntity.ok(entityDescriptorService.createRepresentationFromDescriptor(entityDescriptorService.getEntityDescriptorByResourceId(resourceId))); } @GetMapping(value = "/EntityDescriptor/{resourceId}", produces = "application/xml") diff --git a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/domain/KeyInfo.java b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/domain/KeyInfo.java index 7497e5837..f07d98ca6 100644 --- a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/domain/KeyInfo.java +++ b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/domain/KeyInfo.java @@ -45,9 +45,7 @@ public String getID() { } @Override - public void setID(@Nullable String newID) { - - } + public void setID(@Nullable String newID) {} @Nonnull @Override @@ -64,7 +62,14 @@ public List getXMLObjects(@Nonnull QName typeOrName) { @Nonnull @Override public List getKeyNames() { - return Collections.emptyList(); + List result = new ArrayList<>(); + getXMLObjects().forEach(obj -> { + if (obj instanceof KeyName){ + result.add((KeyName)obj); + } + }); + return result; + } @Nonnull @@ -144,4 +149,4 @@ public List getOrderedChildren() { return children; } -} +} \ No newline at end of file diff --git a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/service/JPAEntityDescriptorServiceImpl.java b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/service/JPAEntityDescriptorServiceImpl.java index b7b034546..4a54c7543 100644 --- a/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/service/JPAEntityDescriptorServiceImpl.java +++ b/backend/src/main/java/edu/internet2/tier/shibboleth/admin/ui/service/JPAEntityDescriptorServiceImpl.java @@ -5,6 +5,7 @@ import edu.internet2.tier.shibboleth.admin.ui.domain.EntityDescriptor; import edu.internet2.tier.shibboleth.admin.ui.domain.EntityDescriptorProtocol; import edu.internet2.tier.shibboleth.admin.ui.domain.IRelyingPartyOverrideProperty; +import edu.internet2.tier.shibboleth.admin.ui.domain.KeyDescriptor; import edu.internet2.tier.shibboleth.admin.ui.domain.UIInfo; import edu.internet2.tier.shibboleth.admin.ui.domain.X509Data; import edu.internet2.tier.shibboleth.admin.ui.domain.XSBoolean; @@ -501,6 +502,7 @@ private void setupSecurityRepresentationFromEntityDescriptor(EntityDescriptor ed for (org.opensaml.saml.saml2.metadata.KeyDescriptor keyDescriptor : ed.getSPSSODescriptor("").getKeyDescriptors()) { KeyDescriptorRepresentation keyDescriptorRep = new KeyDescriptorRepresentation(); String name = keyDescriptor.getKeyInfo().getKeyNames().size() > 0 ? keyDescriptor.getKeyInfo().getKeyNames().get(0).getValue() : null; + name = name == null ? ((KeyDescriptor)keyDescriptor).getName() : name; keyDescriptorRep.setName(name); //TODO: check this. assume that if no value is set, it's used for both diff --git a/backend/src/test/groovy/edu/internet2/tier/shibboleth/admin/ui/controller/EntityDescriptorControllerTests.groovy b/backend/src/test/groovy/edu/internet2/tier/shibboleth/admin/ui/controller/EntityDescriptorControllerTests.groovy index a78a76c24..a8eda4349 100644 --- a/backend/src/test/groovy/edu/internet2/tier/shibboleth/admin/ui/controller/EntityDescriptorControllerTests.groovy +++ b/backend/src/test/groovy/edu/internet2/tier/shibboleth/admin/ui/controller/EntityDescriptorControllerTests.groovy @@ -722,6 +722,7 @@ class EntityDescriptorControllerTests extends AbstractBaseDataJpaTest { .andExpect(jsonPath("\$.serviceEnabled").value(false)) .andExpect(jsonPath("\$.idOfOwner").value("admingroup")) .andExpect(jsonPath("\$.serviceProviderSsoDescriptor.protocolSupportEnum").value("http://openid.net/specs/openid-connect-core-1_0.html")) + .andExpect(jsonPath("\$.securityInfo.keyDescriptors[0].name").value("test1")) .andExpect(jsonPath(shortNameToOAuth + "attributes.clientUri").value("https://example.org/clientUri")) .andExpect(jsonPath(shortNameToOAuth + "attributes.responseTypes").value("code id_token")) .andExpect(jsonPath(shortNameToOAuth + "attributes.sectorIdentifierUri").value("https://example.org/sectorIdentifier")) @@ -776,6 +777,7 @@ class EntityDescriptorControllerTests extends AbstractBaseDataJpaTest { .andExpect(jsonPath("\$.protocol").value("OIDC")) .andExpect(jsonPath("\$.serviceEnabled").value(false)) .andExpect(jsonPath("\$.idOfOwner").value("admingroup")) + .andExpect(jsonPath("\$.securityInfo.keyDescriptors[0].name").value("test1")) .andExpect(jsonPath(shortNameToOAuth + "attributes.clientUri").value("https://example.org/clientUri")) .andExpect(jsonPath(shortNameToOAuth + "attributes.responseTypes").value("code id_token")) .andExpect(jsonPath(shortNameToOAuth + "attributes.sectorIdentifierUri").value("https://example.org/sectorIdentifier")) diff --git a/backend/src/test/resources/json/SHIBUI-2380-1.json b/backend/src/test/resources/json/SHIBUI-2380-1.json index 2e83f768b..833ca5bff 100644 --- a/backend/src/test/resources/json/SHIBUI-2380-1.json +++ b/backend/src/test/resources/json/SHIBUI-2380-1.json @@ -19,21 +19,25 @@ "wantAssertionsSigned": false, "keyDescriptors": [ { + "name": "test1", "value": "MIIEQDCCAqigAwIBAgIVAIarXvdvyS47KJR7U40FlTufyD8vMA0GCSqGSIb3DQEB", "type": "signing", "elementType": "X509Data" }, { + "name": "test2", "value": "MIIBKDCBzgIJAOYlspXlaqguMAoGCCqGSM49BAMCMBwxCzAJBgNVBAYTAkZJMQ0w", "type": "signing", "elementType": "X509Data" }, { + "name": "mockJwksData", "value": "ewogICJrdHkiOiAiUlNBIiwKICAiZSI6ICJBUUFCIiwKICAia2lkIjogIm1vY2siLAogICJhbGci", "type": "signing", "elementType": "jwksData" }, { + "name": "mockClientSecret", "value": "mockClientSecretValue", "type": "both", "elementType": "clientSecret" diff --git a/backend/src/test/resources/json/SHIBUI-2380.json b/backend/src/test/resources/json/SHIBUI-2380.json index f71c6de6b..106e4ed45 100644 --- a/backend/src/test/resources/json/SHIBUI-2380.json +++ b/backend/src/test/resources/json/SHIBUI-2380.json @@ -23,11 +23,13 @@ "wantAssertionsSigned": false, "keyDescriptors": [ { + "name": "test1", "value": "MIIEQDCCAqigAwIBAgIVAIarXvdvyS47KJR7U40FlTufyD8vMA0GCSqGSIb3DQEB", "type": "signing", "elementType": "X509Data" }, { + "name": "test2", "value": "MIIBKDCBzgIJAOYlspXlaqguMAoGCCqGSM49BAMCMBwxCzAJBgNVBAYTAkZJMQ0w", "type": "signing", "elementType": "X509Data" diff --git a/backend/src/test/resources/metadata/SHIBUI-2380.xml b/backend/src/test/resources/metadata/SHIBUI-2380.xml index 7f292cdcd..7ac4ac393 100644 --- a/backend/src/test/resources/metadata/SHIBUI-2380.xml +++ b/backend/src/test/resources/metadata/SHIBUI-2380.xml @@ -33,6 +33,7 @@ + test1 MIIEQDCCAqigAwIBAgIVAIarXvdvyS47KJR7U40FlTufyD8vMA0GCSqGSIb3DQEB @@ -42,6 +43,7 @@ + test2 MIIBKDCBzgIJAOYlspXlaqguMAoGCCqGSM49BAMCMBwxCzAJBgNVBAYTAkZJMQ0w