Skip to content

Commit

Permalink
Merge branch 'feature/shibui-2394' of bitbucket.org:unicon/shib-idp-u…
Browse files Browse the repository at this point in the history
…i into feature/shibui-2394
  • Loading branch information
rmathis committed Oct 19, 2022
2 parents a2badf4 + 006ac2e commit 99e6a10
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import edu.internet2.tier.shibboleth.admin.ui.security.exception.OwnershipConflictException;
import edu.internet2.tier.shibboleth.admin.ui.security.model.Group;
import edu.internet2.tier.shibboleth.admin.ui.security.model.Ownable;
import edu.internet2.tier.shibboleth.admin.ui.security.model.OwnableType;
import edu.internet2.tier.shibboleth.admin.ui.security.model.OwnerType;
import edu.internet2.tier.shibboleth.admin.ui.security.model.Ownership;
import edu.internet2.tier.shibboleth.admin.ui.security.model.Role;
Expand All @@ -25,6 +26,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -144,8 +146,17 @@ public Group getCurrentUserGroup() {
}
}

/**
* @return a list of ALL groups that the user can approve for (checks ALL the users groups)
*/
public List<String> getGroupsCurrentUserCanApprove() {
return getCurrentUserGroup().getApproveForList();
HashSet<String> fullSet = new HashSet<>();
for (Group g : getCurrentUser().getUserGroups()) {
fullSet.addAll(g.getApproveForList());
}
ArrayList<String> result = new ArrayList<>();
result.addAll(fullSet);
return result;
}

public Set<String> getUserRoles(String username) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ public EntityDescriptorRepresentation createNew(EntityDescriptor ed) throws Forb
@Override
public EntityDescriptorRepresentation createNewEntityDescriptorFromXMLOrigin(EntityDescriptor ed) {
ed.setIdOfOwner(userService.getCurrentUserGroup().getOwnerId());
ownershipRepository.deleteEntriesForOwnedObject(ed);
ownershipRepository.save(new Ownership(userService.getCurrentUserGroup(), ed));
EntityDescriptor savedEntity = entityDescriptorRepository.save(ed);
return createRepresentationFromDescriptor(savedEntity);
}
Expand All @@ -153,6 +155,8 @@ public boolean entityExists(String entityID) {
public EntityDescriptorRepresentation updateGroupForEntityDescriptor(String resourceId, String groupId) {
EntityDescriptor ed = entityDescriptorRepository.findByResourceId(resourceId);
ed.setIdOfOwner(groupId);
ownershipRepository.deleteEntriesForOwnedObject(ed);
ownershipRepository.save(new Ownership(groupService.find(groupId), ed));
EntityDescriptor savedEntity = entityDescriptorRepository.save(ed);
return createRepresentationFromDescriptor(savedEntity);
}
Expand Down

0 comments on commit 99e6a10

Please sign in to comment.