Skip to content

Commit

Permalink
Add API resource mgt feature
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaminduR committed Sep 7, 2023
1 parent 1bb238b commit 0072452
Show file tree
Hide file tree
Showing 41 changed files with 7,964 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2023, 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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>api-resource-mgt</artifactId>
<version>5.25.308-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>org.wso2.carbon.identity.api.resource.mgt</artifactId>
<packaging>bundle</packaging>
<name>WSO2 Identity - API Resource Management Component</name>
<description>The API Resource Management backend component</description>
<url>http://wso2.org</url>

<dependencies>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.application.common</artifactId>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.ds-annotations</artifactId>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.agent</artifactId>
<classifier>runtime</classifier>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-testng</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-testng-common</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.testutil</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>
<Private-Package>
org.wso2.carbon.identity.api.resource.mgt.internal,
</Private-Package>
<Export-Package>
!org.wso2.carbon.identity.api.resource.mgt.internal,
org.wso2.carbon.identity.api.resource.mgt.*; version="${carbon.identity.package.export.version}"
</Export-Package>
<Import-Package>
org.osgi.framework;version="${osgi.framework.imp.pkg.version.range}",
org.osgi.service.component; version="${osgi.service.component.imp.pkg.version.range}",
javax.sql,
org.apache.commons.collections; version="${commons-collections.wso2.osgi.version.range}",
org.apache.commons.lang; version="${commons-lang.wso2.osgi.version.range}",
org.apache.commons.logging; version="${import.package.version.commons.logging}",
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.model;
version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.base; version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.core.cache;
version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.core.model;
version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.core.util;
version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.user.api; version="${carbon.user.api.imp.pkg.version.range}",
org.wso2.carbon.user.core.util; version="${carbon.kernel.package.import.version.range}",
org.wso2.carbon.utils; version="${carbon.kernel.package.import.version.range}",
</Import-Package>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<argLine>
--add-opens java.xml/jdk.xml.internal=ALL-UNNAMED
--add-exports java.base/jdk.internal.loader=ALL-UNNAMED
</argLine>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>default-prepare-agent-integration</id>
<goals>
<goal>prepare-agent-integration</goal>
</goals>
</execution>
<execution>
<id>default-report</id>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>default-report-integration</id>
<goals>
<goal>report-integration</goal>
</goals>
</execution>
<execution>
<id>default-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule implementation="org.jacoco.maven.RuleConfiguration">
<element>BUNDLE</element>
<limits>
<limit implementation="org.jacoco.report.check.Limit">
<counter>COMPLEXITY</counter>
<value>COVEREDRATIO</value>
<minimum>0.90</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<configuration>
<threshold>High</threshold>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
/*
* Copyright (c) 2023, 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.api.resource.mgt;

import org.wso2.carbon.identity.api.resource.mgt.model.APIResourceSearchResult;
import org.wso2.carbon.identity.application.common.model.APIResource;
import org.wso2.carbon.identity.application.common.model.Scope;

import java.util.List;

/**
* API Resource Manager Interface.
*/
public interface APIResourceManager {

/**
* Get API resources.
*
* @param after Get API resources after this value.
* @param before Get API resources before this value.
* @param limit Number of API resources to retrieve.
* @param filter Filter expression.
* @param sortOrder Sort order.
* @param tenantDomain Tenant domain.
* @return API resource search result.
* @throws APIResourceMgtException If an error occurs while retrieving API resources.
*/
APIResourceSearchResult getAPIResources(String after, String before, Integer limit, String filter, String sortOrder,
String tenantDomain)
throws APIResourceMgtException;

/**
* Get API resource by id.
*
* @param apiResourceId API resource id.
* @param tenantDomain Tenant domain.
* @return An <code>APIResource</code>.
* @throws APIResourceMgtException If an error occurs while retrieving the API resource.
*/
APIResource getAPIResourceById(String apiResourceId, String tenantDomain) throws APIResourceMgtException;

/**
* Add API resource.
*
* @param apiResource API resource.
* @param tenantDomain Tenant domain.
* @return An <code>APIResource</code>.
* @throws APIResourceMgtException If an error occurs while adding the API resource.
*/
APIResource addAPIResource(APIResource apiResource, String tenantDomain) throws APIResourceMgtException;

/**
* Delete API resource by id.
*
* @param apiResourceId API resource id.
* @param tenantDomain Tenant domain.
* @throws APIResourceMgtException If an error occurs while deleting the API resource.
*/
void deleteAPIResourceById(String apiResourceId, String tenantDomain) throws APIResourceMgtException;

/**
* Update API resource.
*
* @param apiResource API resource.
* @param tenantDomain Tenant domain.
* @throws APIResourceMgtException If an error occurs while updating the API resource.
*/
void updateAPIResource(APIResource apiResource, List<Scope> addedScopes, List<String> removedScopes,
String tenantDomain) throws APIResourceMgtException;

/**
* Get API resource by identifier.
*
* @param apiResourceIdentifier API resource identifier.
* @param tenantDomain Tenant domain.
* @return An <code>APIResource</code>.
* @throws APIResourceMgtException If an error occurs while retrieving the API resource.
*/
APIResource getAPIResourceByIdentifier(String apiResourceIdentifier, String tenantDomain)
throws APIResourceMgtException;

/**
* Get API scopes by id.
*
* @param apiResourceId API resource id.
* @param tenantDomain Tenant domain.
* @return List of <Code>Scope</Code>.
* @throws APIResourceMgtException If an error occurs while retrieving API scopes.
*/
List<Scope> getAPIScopesById(String apiResourceId, String tenantDomain) throws APIResourceMgtException;

/**
* Delete API scopes by id.
*
* @param apiResourceId API resource id.
* @param tenantDomain Tenant domain.
* @throws APIResourceMgtException If an error occurs while deleting API scopes.
*/
void deleteAPIScopesById(String apiResourceId, String tenantDomain) throws APIResourceMgtException;

/**
* Delete API scope by scope id.
*
* @param apiResourceId API resource id.
* @param scopeName Scope id.
* @param tenantDomain Tenant domain.
* @throws APIResourceMgtException If an error occurs while deleting API scope.
*/
void deleteAPIScopeByScopeName(String apiResourceId, String scopeName, String tenantDomain)
throws APIResourceMgtException;

/**
* Put scopes to API resource.
*
* @param apiResourceId API resource id.
* @param currentScopes List of <Code>Scope</Code> in API resource.
* @param scopes List of <Code>Scope</Code>.
* @param tenantDomain Tenant domain.
* @throws APIResourceMgtException If an error occurs while putting scopes to API resource.
*/
void putScopes(String apiResourceId, List<Scope> currentScopes, List<Scope> scopes, String tenantDomain)
throws APIResourceMgtException;

/**
* Get scopes by tenant id.
*
* @param tenantDomain Tenant domain.
* @param filter Filter expression.
* @return List of <Code>Scope</Code>.
* @throws APIResourceMgtException If an error occurs while retrieving scopes.
*/
List<Scope> getScopesByTenantId(String tenantDomain, String filter) throws APIResourceMgtException;
}
Loading

0 comments on commit 0072452

Please sign in to comment.