diff --git a/perun-auditlogger/pom.xml b/perun-auditlogger/pom.xml index 5a184ea998..903046339b 100644 --- a/perun-auditlogger/pom.xml +++ b/perun-auditlogger/pom.xml @@ -6,7 +6,7 @@ perun cz.metacentrum - 0.0.0-development + 3.29.4 cz.metacentrum.perun diff --git a/perun-auditparser/pom.xml b/perun-auditparser/pom.xml index 88f706526f..1001bdb8fe 100644 --- a/perun-auditparser/pom.xml +++ b/perun-auditparser/pom.xml @@ -6,7 +6,7 @@ perun cz.metacentrum - 0.0.0-development + 3.29.4 cz.metacentrum.perun diff --git a/perun-base/pom.xml b/perun-base/pom.xml index 55ba4e794f..806f69be18 100644 --- a/perun-base/pom.xml +++ b/perun-base/pom.xml @@ -6,7 +6,7 @@ perun cz.metacentrum - 0.0.0-development + 3.29.4 cz.metacentrum.perun diff --git a/perun-cabinet/pom.xml b/perun-cabinet/pom.xml index 47a41b7c99..f4558e6a20 100644 --- a/perun-cabinet/pom.xml +++ b/perun-cabinet/pom.xml @@ -6,7 +6,7 @@ perun cz.metacentrum - 0.0.0-development + 3.29.4 cz.metacentrum.perun diff --git a/perun-cli-java/pom.xml b/perun-cli-java/pom.xml index b34181cb17..11f22d70fa 100644 --- a/perun-cli-java/pom.xml +++ b/perun-cli-java/pom.xml @@ -7,7 +7,7 @@ perun cz.metacentrum - 0.0.0-development + 3.29.4 cz.metacentrum.perun diff --git a/perun-cli/Perun/Agent.pm b/perun-cli/Perun/Agent.pm index a6d06f31b5..43d5255580 100644 --- a/perun-cli/Perun/Agent.pm +++ b/perun-cli/Perun/Agent.pm @@ -1,5 +1,5 @@ package Perun::Agent; -my $agentVersion = '0.0.0'; +my $agentVersion = '3.29.4'; my $agentVersionMajor; if ($agentVersion !~ /^(\d+)(?{ $agentVersionMajor = $^N })\..*/i) { diff --git a/perun-core/pom.xml b/perun-core/pom.xml index fd38ee8379..8c9812f6eb 100644 --- a/perun-core/pom.xml +++ b/perun-core/pom.xml @@ -6,7 +6,7 @@ perun cz.metacentrum - 0.0.0-development + 3.29.4 cz.metacentrum.perun diff --git a/perun-core/src/main/java/cz/metacentrum/perun/core/blImpl/ExtSourcesManagerBlImpl.java b/perun-core/src/main/java/cz/metacentrum/perun/core/blImpl/ExtSourcesManagerBlImpl.java index 26cb39f328..bc454b81f3 100644 --- a/perun-core/src/main/java/cz/metacentrum/perun/core/blImpl/ExtSourcesManagerBlImpl.java +++ b/perun-core/src/main/java/cz/metacentrum/perun/core/blImpl/ExtSourcesManagerBlImpl.java @@ -180,6 +180,16 @@ public List getInvalidUsers(PerunSession sess, ExtSource source) { invalidUsers.add(user); } catch (ExtSourceUnsupportedOperationException e) { log.warn("ExtSource {} doesn't support getSubjectByLogin", source.getName()); + } finally { + if (source instanceof ExtSourceSimpleApi) { + try { + ((ExtSourceSimpleApi) source).close(); + } catch (ExtSourceUnsupportedOperationException e) { + // silently skip + } catch (Exception e) { + log.error("Failed to close connection to extsource", e); + } + } } } diff --git a/perun-core/src/main/java/cz/metacentrum/perun/core/blImpl/GroupsManagerBlImpl.java b/perun-core/src/main/java/cz/metacentrum/perun/core/blImpl/GroupsManagerBlImpl.java index 02058cfdde..ef4930129a 100644 --- a/perun-core/src/main/java/cz/metacentrum/perun/core/blImpl/GroupsManagerBlImpl.java +++ b/perun-core/src/main/java/cz/metacentrum/perun/core/blImpl/GroupsManagerBlImpl.java @@ -1787,45 +1787,57 @@ public List synchronizeGroupStructure(PerunSession sess, Group baseGroup //get extSource for group structure ExtSource source = getGroupExtSourceForSynchronization(sess, baseGroup); + try { - //get login attribute for structure - AttributeDefinition loginAttributeDefinition = getLoginAttributeForGroupStructure(sess, baseGroup); - //get login prefix if exists - String loginPrefix = getLoginPrefixForGroupStructure(sess, baseGroup); + //get login attribute for structure + AttributeDefinition loginAttributeDefinition = getLoginAttributeForGroupStructure(sess, baseGroup); + //get login prefix if exists + String loginPrefix = getLoginPrefixForGroupStructure(sess, baseGroup); - List candidateGroupsToAdd = new ArrayList<>(); - Map groupsToUpdate = new HashMap<>(); - List groupsToRemove = new ArrayList<>(); + List candidateGroupsToAdd = new ArrayList<>(); + Map groupsToUpdate = new HashMap<>(); + List groupsToRemove = new ArrayList<>(); - Map actualGroups = getAllSubGroupsWithLogins(sess, baseGroup, loginAttributeDefinition); - List> subjectGroups = getSubjectGroupsFromExtSource(sess, source, baseGroup); + Map actualGroups = getAllSubGroupsWithLogins(sess, baseGroup, loginAttributeDefinition); + List> subjectGroups = getSubjectGroupsFromExtSource(sess, source, baseGroup); - if (isThisFlatSynchronization(sess, baseGroup)) { - for(Map subjectGroup : subjectGroups) { - subjectGroup.put(PARENT_GROUP_LOGIN, null); + if (isThisFlatSynchronization(sess, baseGroup)) { + for(Map subjectGroup : subjectGroups) { + subjectGroup.put(PARENT_GROUP_LOGIN, null); + } } - } - List mergeAttributes = getAttributesListFromExtSource(source, MERGE_GROUP_ATTRIBUTES); + List mergeAttributes = getAttributesListFromExtSource(source, MERGE_GROUP_ATTRIBUTES); - List candidateGroups = getPerunBl().getExtSourcesManagerBl().generateCandidateGroups(sess, subjectGroups, source, loginPrefix); + List candidateGroups = getPerunBl().getExtSourcesManagerBl().generateCandidateGroups(sess, subjectGroups, source, loginPrefix); - categorizeGroupsForSynchronization(actualGroups, candidateGroups, candidateGroupsToAdd, groupsToUpdate, groupsToRemove); + categorizeGroupsForSynchronization(actualGroups, candidateGroups, candidateGroupsToAdd, groupsToUpdate, groupsToRemove); - //order of operations is important here - //removing need to go first to be able to replace groups with same name but different login - //updating need to be last to set right order of groups again - List removedGroupsIds = removeFormerGroupsWhileSynchronization(sess, baseGroup, groupsToRemove, skippedGroups); - addMissingGroupsWhileSynchronization(sess, baseGroup, candidateGroupsToAdd, loginAttributeDefinition, skippedGroups, mergeAttributes); - updateExistingGroupsWhileSynchronization(sess, baseGroup, groupsToUpdate, removedGroupsIds, loginAttributeDefinition, skippedGroups, mergeAttributes); + //order of operations is important here + //removing need to go first to be able to replace groups with same name but different login + //updating need to be last to set right order of groups again + List removedGroupsIds = removeFormerGroupsWhileSynchronization(sess, baseGroup, groupsToRemove, skippedGroups); + addMissingGroupsWhileSynchronization(sess, baseGroup, candidateGroupsToAdd, loginAttributeDefinition, skippedGroups, mergeAttributes); + updateExistingGroupsWhileSynchronization(sess, baseGroup, groupsToUpdate, removedGroupsIds, loginAttributeDefinition, skippedGroups, mergeAttributes); - setUpSynchronizationAttributesForAllSubGroups(sess, baseGroup, source, loginAttributeDefinition, loginPrefix); + setUpSynchronizationAttributesForAllSubGroups(sess, baseGroup, source, loginAttributeDefinition, loginPrefix); - syncResourcesForSynchronization(sess, baseGroup, loginAttributeDefinition, skippedGroups); + syncResourcesForSynchronization(sess, baseGroup, loginAttributeDefinition, skippedGroups); - log.info("Group structure synchronization {}: ended.", baseGroup); + log.info("Group structure synchronization {}: ended.", baseGroup); - return skippedGroups; + return skippedGroups; + } finally { + if (source instanceof ExtSourceSimpleApi) { + try { + ((ExtSourceSimpleApi) source).close(); + } catch (ExtSourceUnsupportedOperationException e) { + // silently skip + } catch (Exception e) { + log.error("Failed to close extsource after structure synchronization.", e); + } + } + } } /** diff --git a/perun-core/src/main/java/cz/metacentrum/perun/core/blImpl/MembersManagerBlImpl.java b/perun-core/src/main/java/cz/metacentrum/perun/core/blImpl/MembersManagerBlImpl.java index 7095f95455..92910b43e2 100644 --- a/perun-core/src/main/java/cz/metacentrum/perun/core/blImpl/MembersManagerBlImpl.java +++ b/perun-core/src/main/java/cz/metacentrum/perun/core/blImpl/MembersManagerBlImpl.java @@ -612,6 +612,16 @@ public Member createMember(PerunSession sess, Vo vo, ExtSource extSource, String throw new InternalErrorException("Can't find candidate for login " + login + " in extSource " + extSource, ex); } catch (ExtSourceUnsupportedOperationException ex) { throw new InternalErrorException("Some operation is not allowed for extSource " + extSource, ex); + } finally { + if (extSource instanceof ExtSourceSimpleApi) { + try { + ((ExtSourceSimpleApi) extSource).close(); + } catch (ExtSourceUnsupportedOperationException e) { + // silently skip + } catch (Exception e) { + log.error("Failed to close connection to extsource", e); + } + } } return this.createMember(sess, vo, candidate, groups); diff --git a/perun-core/src/main/java/cz/metacentrum/perun/core/blImpl/VosManagerBlImpl.java b/perun-core/src/main/java/cz/metacentrum/perun/core/blImpl/VosManagerBlImpl.java index b96a345c96..d2e93c3b2f 100644 --- a/perun-core/src/main/java/cz/metacentrum/perun/core/blImpl/VosManagerBlImpl.java +++ b/perun-core/src/main/java/cz/metacentrum/perun/core/blImpl/VosManagerBlImpl.java @@ -377,6 +377,16 @@ public List findCandidates(PerunSession sess, Vo vo, String searchStr } catch (InternalErrorException e) { log.error("Failed to get candidates from ExtSource: {}", source); + } finally { + if (source instanceof ExtSourceSimpleApi) { + try { + ((ExtSourceSimpleApi) source).close(); + } catch (ExtSourceUnsupportedOperationException e) { + // silently skip + } catch (Exception e) { + log.error("Failed to close connection to extsource", e); + } + } } // Stop walking through next sources if the number of already retrieved members exceeded the maxNumOfResults if (maxNumOfResults > 0 && numOfResults >= maxNumOfResults) { @@ -493,6 +503,16 @@ public List findCandidates(PerunSession sess, Group group, String sea } } catch (InternalErrorException e) { log.error("Failed to get candidates from ExtSource: {}", source); + } finally { + if (source instanceof ExtSourceSimpleApi) { + try { + ((ExtSourceSimpleApi) source).close(); + } catch (ExtSourceUnsupportedOperationException e) { + // silently skip + } catch (Exception e) { + log.error("Failed to close connection to extsource", e); + } + } } } diff --git a/perun-core/src/main/java/cz/metacentrum/perun/core/entry/ExtSourcesManagerEntry.java b/perun-core/src/main/java/cz/metacentrum/perun/core/entry/ExtSourcesManagerEntry.java index 46d003da6b..6409d65f3f 100644 --- a/perun-core/src/main/java/cz/metacentrum/perun/core/entry/ExtSourcesManagerEntry.java +++ b/perun-core/src/main/java/cz/metacentrum/perun/core/entry/ExtSourcesManagerEntry.java @@ -22,6 +22,7 @@ import cz.metacentrum.perun.core.bl.ExtSourcesManagerBl; import cz.metacentrum.perun.core.bl.PerunBl; import cz.metacentrum.perun.core.impl.Utils; +import cz.metacentrum.perun.core.implApi.ExtSourceSimpleApi; import cz.metacentrum.perun.core.implApi.ExtSourcesManagerImplApi; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -278,7 +279,21 @@ public Candidate getCandidate(PerunSession sess, ExtSource source, String login) if (!AuthzResolver.authorizedInternal(sess, "getCandidate_ExtSource_String_policy", source)) throw new PrivilegeException(sess, "getCandidate"); - return new Candidate(getExtSourcesManagerBl().getCandidate(sess, source, login)); + try { + return new Candidate(getExtSourcesManagerBl().getCandidate(sess, source, login)); + + // we need to close the extsource here because we don't want to always do it in the BL layer + } finally { + if (source instanceof ExtSourceSimpleApi) { + try { + ((ExtSourceSimpleApi) source).close(); + } catch (ExtSourceUnsupportedOperationException e) { + // silently skip + } catch (Exception e) { + log.error("Failed to close connection to extsource", e); + } + } + } } @Override diff --git a/perun-core/src/main/java/cz/metacentrum/perun/core/entry/ResourcesManagerEntry.java b/perun-core/src/main/java/cz/metacentrum/perun/core/entry/ResourcesManagerEntry.java index 784d603691..e48d365ce0 100644 --- a/perun-core/src/main/java/cz/metacentrum/perun/core/entry/ResourcesManagerEntry.java +++ b/perun-core/src/main/java/cz/metacentrum/perun/core/entry/ResourcesManagerEntry.java @@ -1310,7 +1310,9 @@ public List getResourceAssignments(PerunSession sess, Group gr List filteredResources = getResourcesManagerBl().getResourceAssignments(sess, group, attrNames).stream() .filter(assignedResource -> AuthzResolver.authorizedInternal(sess, - "filter-getResourceAssignments_Group_policy", assignedResource.getEnrichedResource().getResource())) + "filter-getResourceAssignments_Group_policy", + assignedResource.getEnrichedResource().getResource(), + group)) .collect(Collectors.toList()); filteredResources.forEach(assignedResource -> @@ -1332,7 +1334,9 @@ public List getGroupAssignments(PerunSession sess, Resource resou List filteredGroups = getResourcesManagerBl().getGroupAssignments(sess, resource, attrNames).stream() .filter(assignedGroup -> AuthzResolver.authorizedInternal(sess, - "filter-getGroupAssignments_Resource_policy", assignedGroup.getEnrichedGroup().getGroup())) + "filter-getGroupAssignments_Resource_policy", + assignedGroup.getEnrichedGroup().getGroup(), + resource)) .collect(Collectors.toList()); filteredGroups.forEach(assignedGroup -> diff --git a/perun-dispatcher/pom.xml b/perun-dispatcher/pom.xml index d070328110..7c5ff0824d 100644 --- a/perun-dispatcher/pom.xml +++ b/perun-dispatcher/pom.xml @@ -6,7 +6,7 @@ perun cz.metacentrum - 0.0.0-development + 3.29.4 cz.metacentrum.perun diff --git a/perun-engine/pom.xml b/perun-engine/pom.xml index 580cc49ede..010b447a25 100644 --- a/perun-engine/pom.xml +++ b/perun-engine/pom.xml @@ -6,7 +6,7 @@ perun cz.metacentrum - 0.0.0-development + 3.29.4 cz.metacentrum.perun diff --git a/perun-ldapc/pom.xml b/perun-ldapc/pom.xml index 6e5bc6577a..e3a6ea1fd4 100644 --- a/perun-ldapc/pom.xml +++ b/perun-ldapc/pom.xml @@ -7,7 +7,7 @@ perun cz.metacentrum - 0.0.0-development + 3.29.4 cz.metacentrum.perun diff --git a/perun-notification/pom.xml b/perun-notification/pom.xml index 70dd1cbe35..be66a9263f 100644 --- a/perun-notification/pom.xml +++ b/perun-notification/pom.xml @@ -6,7 +6,7 @@ perun cz.metacentrum - 0.0.0-development + 3.29.4 cz.metacentrum.perun diff --git a/perun-openapi/openapi.yml b/perun-openapi/openapi.yml index 331f31efbb..1a07c7cd9e 100644 --- a/perun-openapi/openapi.yml +++ b/perun-openapi/openapi.yml @@ -1,7 +1,7 @@ openapi: 3.0.2 info: - version: 0.0.0 + version: 3.29.4 title: Perun RPC API description: Perun Remote Procedure Calls Application Programming Interface contact: diff --git a/perun-openapi/pom.xml b/perun-openapi/pom.xml index adcdb0d620..6660a6c17e 100644 --- a/perun-openapi/pom.xml +++ b/perun-openapi/pom.xml @@ -7,7 +7,7 @@ perun cz.metacentrum - 0.0.0-development + 3.29.4 cz.metacentrum.perun diff --git a/perun-registrar-lib/pom.xml b/perun-registrar-lib/pom.xml index 51534c4516..95a59debdf 100644 --- a/perun-registrar-lib/pom.xml +++ b/perun-registrar-lib/pom.xml @@ -6,7 +6,7 @@ perun cz.metacentrum - 0.0.0-development + 3.29.4 cz.metacentrum.perun diff --git a/perun-rpc/pom.xml b/perun-rpc/pom.xml index 5bb4425e80..95608c85a9 100644 --- a/perun-rpc/pom.xml +++ b/perun-rpc/pom.xml @@ -6,7 +6,7 @@ perun cz.metacentrum - 0.0.0-development + 3.29.4 cz.metacentrum.perun diff --git a/perun-scim/pom.xml b/perun-scim/pom.xml index fc5ecdf079..4fa1e89527 100644 --- a/perun-scim/pom.xml +++ b/perun-scim/pom.xml @@ -6,7 +6,7 @@ perun cz.metacentrum - 0.0.0-development + 3.29.4 cz.metacentrum.perun diff --git a/perun-web-gui/pom.xml b/perun-web-gui/pom.xml index d8d2ef0a07..b42b48f39c 100644 --- a/perun-web-gui/pom.xml +++ b/perun-web-gui/pom.xml @@ -6,7 +6,7 @@ perun cz.metacentrum - 0.0.0-development + 3.29.4 cz.metacentrum.perun diff --git a/pom.xml b/pom.xml index 0a67a28bf4..d23e115781 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ cz.metacentrum perun - 0.0.0-development + 3.29.4 pom