Skip to content

Commit

Permalink
SHIBUI-1776
Browse files Browse the repository at this point in the history
Corrects the logic being used to fetch the EntityDescriptor
  • Loading branch information
chasegawa committed May 7, 2021
1 parent 1f0606a commit 4b52655
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import edu.internet2.tier.shibboleth.admin.ui.domain.frontend.EntityDescriptorRepresentation;
import edu.internet2.tier.shibboleth.admin.ui.opensaml.OpenSamlObjects;
import edu.internet2.tier.shibboleth.admin.ui.repository.EntityDescriptorRepository;
import edu.internet2.tier.shibboleth.admin.ui.service.EntityDescriptorService;
import lombok.extern.slf4j.Slf4j;
import net.shibboleth.utilities.java.support.resolver.CriteriaSet;
Expand All @@ -30,16 +32,17 @@
method = RequestMethod.GET)
@Slf4j
public class EntitiesController {
@Autowired
private MetadataResolver metadataResolver;

@Autowired
private EntityDescriptorService entityDescriptorService;

@Autowired
private OpenSamlObjects openSamlObjects;

@Autowired
private EntityDescriptorRepository entityDescriptorRepository;

@RequestMapping(value = "{entityId:.*}")
@RequestMapping(value = "/{entityId:.*}")
@Transactional(readOnly = true)
public ResponseEntity<?> getOne(final @PathVariable String entityId, HttpServletRequest request) throws UnsupportedEncodingException, ResolverException {
EntityDescriptor entityDescriptor = this.getEntityDescriptor(entityId);
if (entityDescriptor == null) {
Expand All @@ -50,7 +53,8 @@ public ResponseEntity<?> getOne(final @PathVariable String entityId, HttpServlet
return result;
}

@RequestMapping(value = "{entityId:.*}", produces = "application/xml")
@RequestMapping(value = "/{entityId:.*}", produces = "application/xml")
@Transactional(readOnly = true)
public ResponseEntity<?> getOneXml(final @PathVariable String entityId) throws MarshallingException, ResolverException, UnsupportedEncodingException {
EntityDescriptor entityDescriptor = this.getEntityDescriptor(entityId);
if (entityDescriptor == null) {
Expand All @@ -62,7 +66,7 @@ public ResponseEntity<?> getOneXml(final @PathVariable String entityId) throws M

private EntityDescriptor getEntityDescriptor(final String entityId) throws ResolverException, UnsupportedEncodingException {
String decodedEntityId = URLDecoder.decode(entityId, "UTF-8");
EntityDescriptor entityDescriptor = this.metadataResolver.resolveSingle(new CriteriaSet(new EntityIdCriterion(decodedEntityId)));
EntityDescriptor entityDescriptor = entityDescriptorRepository.findByEntityID(decodedEntityId);
// TODO: we need to clean this up sometime
if (entityDescriptor instanceof edu.internet2.tier.shibboleth.admin.ui.domain.EntityDescriptor) {
((edu.internet2.tier.shibboleth.admin.ui.domain.EntityDescriptor) entityDescriptor).setResourceId(null);
Expand Down

0 comments on commit 4b52655

Please sign in to comment.