Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Resource Sharing Policy Management Component #416

Open
wants to merge 51 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
91de7f1
cmp_resource: Initiate Resource Sharing policy management Component
BimsaraBodaragama Nov 19, 2024
d528223
cmp_resource: Checkstyle format
BimsaraBodaragama Nov 19, 2024
350e476
cmp_resource: Introduce PolicyEnum to resource sharing policy manager
BimsaraBodaragama Nov 19, 2024
7b44434
cmp_resource: Introduce add resource sharing policy record
BimsaraBodaragama Nov 21, 2024
262ce9f
cmp_resource: Introduce add shared resource attribute record
BimsaraBodaragama Nov 21, 2024
142c6c2
cmp_resource: Make adding of shared resource attributes dumb
BimsaraBodaragama Nov 23, 2024
341a3f2
cmp_resource: Add new delete methods for deleting resource sharing po…
BimsaraBodaragama Nov 23, 2024
12dbac4
cmp_resource: Remove deleting resource sharing policy by querying its…
BimsaraBodaragama Nov 23, 2024
f155832
cmp_resource: Remove deleting resource sharing policy by querying its…
BimsaraBodaragama Nov 23, 2024
1d66d83
cmp_resource: Add a batch insert with transaction when adding shared …
BimsaraBodaragama Nov 23, 2024
9b52181
cmp_resource: Implement GET to SharedResourceAttributes
BimsaraBodaragama Nov 24, 2024
7c3dc5d
cmp_resource: Implement GET to SharedResourceAttributes - Part 2
BimsaraBodaragama Nov 24, 2024
789504e
cmp_resource: Support to implement get sharing policy
BimsaraBodaragama Nov 24, 2024
be9407a
cmp_resource: Put the ids in the models to reference UM_IDs in the DB…
BimsaraBodaragama Nov 24, 2024
1e4e1fc
cmp_resource: Restructured SharedResourceAttribute
BimsaraBodaragama Nov 24, 2024
ff15b6c
cmp_resource: Implement GETTERS for the SharedResourceAttributes
BimsaraBodaragama Nov 24, 2024
4fa453e
cmp_resource: Implement GETTERS for the ResourceSharingPolicies
BimsaraBodaragama Nov 24, 2024
84eb221
cmp_resource: Implement DELETE with type and id
BimsaraBodaragama Nov 25, 2024
be18f1b
cmp_resource: Restructure method sequence in the ResourceSharingPolic…
BimsaraBodaragama Nov 25, 2024
33018fa
cmp_resource: Rename models to model
BimsaraBodaragama Nov 26, 2024
1a6dacc
cmp_resource: Remove Builders from the GETs and replaced them with se…
BimsaraBodaragama Nov 26, 2024
63b63f3
cmp_resource: Refactor query in DELETE of ResourceSharingPolicy
BimsaraBodaragama Nov 26, 2024
56f7967
cmp_resource: Refactor deletions to support only from sharing initiat…
BimsaraBodaragama Nov 27, 2024
1ea53cc
cmp_resource: Unit test suits
BimsaraBodaragama Nov 27, 2024
511730c
cmp_resource: Unit test suits refactor
BimsaraBodaragama Nov 27, 2024
74a581c
cmp_resource: Restructure the method sequence in the component.
BimsaraBodaragama Nov 27, 2024
547de22
cmp_resource: Restructure the method sequence in the component - Part 2.
BimsaraBodaragama Nov 27, 2024
92336b1
cmp_resource: Refine test constants.
BimsaraBodaragama Nov 27, 2024
a795981
cmp_resource: Resolve dependencies.
BimsaraBodaragama Nov 28, 2024
16404d7
cmp_resource: Resolve Test Exclusions.
BimsaraBodaragama Nov 28, 2024
56ce388
cmp_resource: Make export packaged specific.
BimsaraBodaragama Nov 28, 2024
c30c9d5
cmp_resource: Revisit privatising packages.
BimsaraBodaragama Nov 28, 2024
78708e3
cmp_user-share: Resolve dependencies.
BimsaraBodaragama Nov 29, 2024
c5f9d67
cmp_resource: Rollback dependencies
BimsaraBodaragama Nov 29, 2024
0463865
cmp_resource: Re-resolve dependencies (Re did the dependency resolvin…
BimsaraBodaragama Nov 29, 2024
8ec95fa
cmp_resource: Clear up unused resources.
BimsaraBodaragama Nov 29, 2024
6153882
cmp_resource: Restructure with applicable attributes to policies and …
BimsaraBodaragama Nov 30, 2024
1de61d8
cmp_resource: Restructure the ResourceTypes to hold the applicable Sh…
BimsaraBodaragama Dec 2, 2024
d3f58a7
cmp_resource: Refine tests.
BimsaraBodaragama Dec 2, 2024
a4a4230
cmp_resource: Improve javadoc comments on interfaces following the CS…
BimsaraBodaragama Dec 4, 2024
bd2a43f
cmp_resource: Refine constants.
BimsaraBodaragama Dec 5, 2024
91b1175
cmp_resource: Update formatting.
BimsaraBodaragama Dec 11, 2024
b33e8b3
cmp_resource: Make safe for sql injections.
BimsaraBodaragama Dec 16, 2024
b3a92a7
cmp_resource: Rename deleteRequestInitiatedOrgId -> sharingPolicyInit…
BimsaraBodaragama Dec 18, 2024
c1f5b5f
cmp_resource: GET ResourceSharingPolicyById with FetchSingleRecord in…
BimsaraBodaragama Dec 18, 2024
1a7584e
cmp_resource: Format - GET ResourceSharingPolicyById with FetchSingle…
BimsaraBodaragama Dec 18, 2024
edcad1c
cmp_resource: Make GET ResourceSharingPolicyById Optional
BimsaraBodaragama Dec 18, 2024
ee5eca2
cmp_resource: New method to add resource sharing policy and attribute…
BimsaraBodaragama Dec 19, 2024
0439ba5
cmp_resource: New method to get resource sharing policy and attribute…
BimsaraBodaragama Dec 20, 2024
170abc7
cmp_resource: Remove generic validation methods for inputs and only a…
BimsaraBodaragama Dec 20, 2024
dd427f8
cmp_resource: Introduce organization scope to PolicyEnum and rename p…
BimsaraBodaragama Dec 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com).
~
~ WSO2 LLC. licenses this file to you under the Apache License,
~ Version 2.0 (the "License"); you may not use this file except
~ in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.wso2.carbon.identity.organization.management</groupId>
<artifactId>identity-organization-management</artifactId>
<version>1.4.54</version>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to bump the version before merging

<relativePath>../../pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.identity.organization.resource.sharing.policy.management</artifactId>
<name>WSO2 - Organization Resource Sharing Policy Management Service</name>
<packaging>bundle</packaging>

<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.organization.management.core</groupId>
<artifactId>org.wso2.carbon.identity.organization.management.service</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.organization.management</groupId>
<artifactId>org.wso2.carbon.identity.organization.management.ext</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.organization.management</groupId>
<artifactId>org.wso2.carbon.identity.organization.management.role.management.service</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.application.mgt</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.application.authentication.framework</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.utils</groupId>
<artifactId>org.wso2.carbon.database.utils</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.user.core</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.utils</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.event</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.role.v2.mgt.core</artifactId>
</dependency>
<!--Test Dependencies-->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Bundle-Description>Organization Resource Sharing Policy Service Bundle</Bundle-Description>
<Private-Package>
org.wso2.carbon.identity.organization.resource.sharing.policy.management.internal
BimsaraBodaragama marked this conversation as resolved.
Show resolved Hide resolved
</Private-Package>
<Export-Package>
!org.wso2.carbon.identity.organization.resource.sharing.policy.management.internal,
org.wso2.carbon.identity.organization.resource.sharing.policy.management.*;
version="${identity.organization.management.exp.pkg.version}",
</Export-Package>
dhaura marked this conversation as resolved.
Show resolved Hide resolved
<Import-Package>
dhaura marked this conversation as resolved.
Show resolved Hide resolved
javax.sql,
org.apache.commons.logging; version="${org.apache.commons.logging.imp.pkg.version.range}",
org.apache.commons.collections; version="${org.apache.commons.collections.imp.pkg.version.range}",
org.apache.commons.lang;version="${org.apache.commons.lang.imp.pkg.version.range}",
org.osgi.framework; version="${osgi.framework.imp.pkg.version.range}",
org.osgi.service.component; version="${osgi.service.component.imp.pkg.version.range}",
org.wso2.carbon.context;version="${carbon.kernel.package.import.version.range}",
org.wso2.carbon.database.utils.jdbc;version="${org.wso2.carbon.database.utils.version.range}",
org.wso2.carbon.database.utils.jdbc.exceptions;version="${org.wso2.carbon.database.utils.version.range}",
org.wso2.carbon.identity.application.common;version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.application.common.model;version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.application.mgt;version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.application.authentication.framework.util; version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.core;version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.core.util;version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.role.v2.mgt.core;version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.role.v2.mgt.core.exception;version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.organization.management.service; version="${org.wso2.identity.organization.mgt.core.imp.pkg.version.range}",
org.wso2.carbon.identity.organization.management.service.util;version="${org.wso2.identity.organization.mgt.imp.pkg.version.range}",
org.wso2.carbon.identity.organization.management.service.exception;version="${org.wso2.identity.organization.mgt.imp.pkg.version.range}",
org.wso2.carbon.identity.organization.management.service.model; version="${org.wso2.identity.organization.mgt.core.imp.pkg.version.range}",
org.wso2.carbon.identity.organization.management.service.constant;version="${org.wso2.identity.organization.mgt.core.imp.pkg.version.range}",
org.wso2.carbon.identity.organization.management.role.management.service;version="${org.wso2.identity.organization.mgt.imp.pkg.version.range}",
org.wso2.carbon.identity.organization.management.role.management.service.models;version="${org.wso2.identity.organization.mgt.imp.pkg.version.range}",
org.wso2.carbon.identity.organization.management.ext;version="${org.wso2.identity.organization.mgt.imp.pkg.version.range}",
org.wso2.carbon.user.api;version="${carbon.user.api.imp.pkg.version.range}",
org.wso2.carbon.user.core;version="${carbon.kernel.package.import.version.range}",
org.wso2.carbon.user.core.common;version="${carbon.kernel.package.import.version.range}",
org.wso2.carbon.user.core.listener;version="${carbon.kernel.package.import.version.range}",
org.wso2.carbon.user.core.service;version="${carbon.kernel.package.import.version.range}",
org.wso2.carbon.user.core.util;version="${carbon.kernel.package.import.version.range}",
org.wso2.carbon.identity.event.handler; version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.event.event; version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.event; version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.event.services; version="${carbon.identity.package.import.version.range}",
org.wso2.carbon;version="${carbon.kernel.package.import.version.range}",
</Import-Package>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<!-- attached to Maven test phase -->
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*
* Copyright (c) 2024, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.wso2.carbon.identity.organization.resource.sharing.policy.management;

import org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException;
import org.wso2.carbon.identity.organization.management.service.exception.OrganizationManagementServerException;
import org.wso2.carbon.identity.organization.resource.sharing.policy.management.constant.ResourceType;
import org.wso2.carbon.identity.organization.resource.sharing.policy.management.constant.SharedAttributeType;
import org.wso2.carbon.identity.organization.resource.sharing.policy.management.exception.ResourceSharingPolicyMgtServerException;
import org.wso2.carbon.identity.organization.resource.sharing.policy.management.models.ResourceSharingPolicy;
import org.wso2.carbon.identity.organization.resource.sharing.policy.management.models.SharedResourceAttribute;

import java.util.List;
import java.util.Map;

/**
* Service that manages the core service for managing resource sharing policies.
*/
public interface ResourceSharingPolicyHandlerService {
BimsaraBodaragama marked this conversation as resolved.
Show resolved Hide resolved

/**
* Saves the resource sharing policy to the data store and return the record id.
*/
BimsaraBodaragama marked this conversation as resolved.
Show resolved Hide resolved
int addResourceSharingPolicy(ResourceSharingPolicy resourceSharingPolicy)
throws OrganizationManagementServerException, ResourceSharingPolicyMgtServerException, DataAccessException;

/**
* Deletes a resource sharing policy record by ID.
*/
boolean deleteResourceSharingPolicyRecordById(int resourceSharingPolicyId)
throws ResourceSharingPolicyMgtServerException;

/**
* Deletes a resource sharing policy record by resource Type and ID.
*/
boolean deleteResourceSharingPolicyByResourceTypeAndId(ResourceType resourceType, String resourceId)
throws ResourceSharingPolicyMgtServerException;

/**
* Retrieves resource sharing policies for the given organization IDs.
*/
List<ResourceSharingPolicy> getResourceSharingPolicies(List<String> organizationIds)
throws ResourceSharingPolicyMgtServerException;

/**
* Retrieves resource sharing policies for the given organization IDs grouped by resource type.
*/
Map<ResourceType, List<ResourceSharingPolicy>> getResourceSharingPoliciesGroupedByResourceType(
List<String> organizationIds)
BimsaraBodaragama marked this conversation as resolved.
Show resolved Hide resolved
throws ResourceSharingPolicyMgtServerException;
BimsaraBodaragama marked this conversation as resolved.
Show resolved Hide resolved

/**
* Retrieves resource sharing policies for the given organization IDs grouped by resource policy holding org IDs.
*/
Map<String, List<ResourceSharingPolicy>> getResourceSharingPoliciesGroupedByPolicyHoldingOrgId(
List<String> organizationIds)
throws ResourceSharingPolicyMgtServerException;

/**
* Saves the shared resource attributes to the data store.
*/
void addSharedResourceAttributes(List<SharedResourceAttribute> sharedResourceAttributes)
throws ResourceSharingPolicyMgtServerException;

/**
* Deletes shared resource attributes for a given resource sharing policy ID.
*/
boolean deleteSharedResourceAttributesByResourceSharingPolicyId(int resourceSharingPolicyId,
SharedAttributeType sharedAttributeType)
throws ResourceSharingPolicyMgtServerException;

/**
* Deletes shared resource attributes by attribute Type and ID.
*/
boolean deleteSharedResourceAttributeByAttributeTypeAndId(SharedAttributeType attributeType, String attributeId)
throws ResourceSharingPolicyMgtServerException;

/**
* Retrieves shared resource attributes for a given resource sharing policy ID.
*/
List<SharedResourceAttribute> getSharedResourceAttributesBySharingPolicyId(int resourceSharingPolicyId)
throws ResourceSharingPolicyMgtServerException, DataAccessException;

/**
* Retrieves shared resource attributes for a given attribute Type.
*/
List<SharedResourceAttribute> getSharedResourceAttributesByType(SharedAttributeType attributeType)
throws ResourceSharingPolicyMgtServerException;

/**
* Retrieves shared resource attributes for a given attribute ID.
*/
List<SharedResourceAttribute> getSharedResourceAttributesById(String attributeId)
throws ResourceSharingPolicyMgtServerException;

/**
* Retrieves shared resource attributes for a given attribute Type and ID.
*/
List<SharedResourceAttribute> getSharedResourceAttributesByTypeAndId(SharedAttributeType attributeType,
String attributeId)
throws ResourceSharingPolicyMgtServerException;

}
Loading
Loading