-
Notifications
You must be signed in to change notification settings - Fork 541
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5810 from malithie/actions-core
Add action execution component.
- Loading branch information
Showing
35 changed files
with
2,666 additions
and
0 deletions.
There are no files selected for viewing
190 changes: 190 additions & 0 deletions
190
components/action-mgt/org.wso2.carbon.identity.action.execution/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
<!-- | ||
~ 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/maven-v4_0_0.xsd"> | ||
|
||
<parent> | ||
<groupId>org.wso2.carbon.identity.framework</groupId> | ||
<artifactId>action-mgt</artifactId> | ||
<version>7.3.50-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
<artifactId>org.wso2.carbon.identity.action.execution</artifactId> | ||
<packaging>bundle</packaging> | ||
<name>WSO2 Identity - Action Executor Component</name> | ||
<description>Action execution backend component</description> | ||
<url>http://wso2.org</url> | ||
|
||
<dependencies> | ||
<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.action.management</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</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>org.mockito</groupId> | ||
<artifactId>mockito-testng</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.action.execution.internal, | ||
</Private-Package> | ||
<Export-Package> | ||
!org.wso2.carbon.identity.action.execution.internal, | ||
org.wso2.carbon.identity.action.execution.*; | ||
version="${carbon.identity.package.export.version}" | ||
</Export-Package> | ||
<Import-Package> | ||
org.wso2.carbon.identity.action.management.*; | ||
version="${carbon.identity.package.import.version.range}", | ||
org.apache.commons.lang; version="${commons-lang.wso2.osgi.version.range}", | ||
org.apache.commons.logging; version="${import.package.version.commons.logging}", | ||
org.apache.commons.collections; version="${commons-collections.wso2.osgi.version.range}", | ||
org.apache.http; version="${httpcore.version.osgi.import.range}", | ||
org.apache.http.client.config; version="${httpcore.version.osgi.import.range}", | ||
org.apache.http.client.methods; version="${httpcore.version.osgi.import.range}", | ||
org.apache.http.concurrent; version="${httpcore.version.osgi.import.range}", | ||
org.apache.http.conn; version="${httpcore.version.osgi.import.range}", | ||
org.apache.http.entity; version="${httpcore.version.osgi.import.range}", | ||
org.apache.http.util; version="${httpcore.version.osgi.import.range}", | ||
org.apache.http.impl.client; version="${httpcomponents-httpclient.imp.pkg.version.range}", | ||
org.apache.http.impl.conn; version="${httpcomponents-httpclient.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.utils; version="${carbon.kernel.package.import.version.range}", | ||
com.fasterxml.jackson.core.*; version="${com.fasterxml.jackson.annotation.version.range}", | ||
com.fasterxml.jackson.databind.*; version="${com.fasterxml.jackson.annotation.version.range}", | ||
com.fasterxml.jackson.annotation.*; version="${com.fasterxml.jackson.annotation.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>com.github.spotbugs</groupId> | ||
<artifactId>spotbugs-maven-plugin</artifactId> | ||
<configuration> | ||
<excludeFilterFile>../../../spotbugs-exclude.xml</excludeFilterFile> | ||
<effort>Max</effort> | ||
<threshold>Low</threshold> | ||
<xmlOutput>true</xmlOutput> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
39 changes: 39 additions & 0 deletions
39
...rc/main/java/org/wso2/carbon/identity/action/execution/ActionExecutionRequestBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* 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.action.execution; | ||
|
||
import org.wso2.carbon.identity.action.execution.exception.ActionExecutionRequestBuilderException; | ||
import org.wso2.carbon.identity.action.execution.model.ActionExecutionRequest; | ||
import org.wso2.carbon.identity.action.execution.model.ActionType; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* This interface defines the Action Execution Request Builder. | ||
* Action Execution Request Builder is the component that is responsible for building the Action Execution Request | ||
* based on the action type and the event context. | ||
*/ | ||
public interface ActionExecutionRequestBuilder { | ||
|
||
ActionType getSupportedActionType(); | ||
|
||
ActionExecutionRequest buildActionExecutionRequest(Map<String, Object> eventContext) throws | ||
ActionExecutionRequestBuilderException; | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
.../java/org/wso2/carbon/identity/action/execution/ActionExecutionRequestBuilderFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* 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.action.execution; | ||
|
||
import org.wso2.carbon.identity.action.execution.model.ActionExecutionRequest; | ||
import org.wso2.carbon.identity.action.execution.model.ActionType; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* This class defines the Action Execution Request Builder Factory. | ||
* Action Execution Request Builder Factory is the component that is responsible for building | ||
* {@link ActionExecutionRequest} | ||
* based on the action type and the event context. | ||
*/ | ||
public class ActionExecutionRequestBuilderFactory { | ||
|
||
private static final Map<ActionType, ActionExecutionRequestBuilder> actionInvocationRequestBuilders = | ||
new HashMap<>(); | ||
|
||
public static ActionExecutionRequestBuilder getActionExecutionRequestBuilder(ActionType actionType) { | ||
|
||
return actionInvocationRequestBuilders.get(actionType); | ||
} | ||
|
||
public static void registerActionExecutionRequestBuilder(ActionExecutionRequestBuilder | ||
actionExecutionRequestBuilder) { | ||
|
||
actionInvocationRequestBuilders.put(actionExecutionRequestBuilder.getSupportedActionType(), | ||
actionExecutionRequestBuilder); | ||
} | ||
|
||
public static void unregisterActionExecutionRequestBuilder(ActionExecutionRequestBuilder | ||
actionExecutionRequestBuilder) { | ||
|
||
actionInvocationRequestBuilders.remove(actionExecutionRequestBuilder.getSupportedActionType()); | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
...main/java/org/wso2/carbon/identity/action/execution/ActionExecutionResponseProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* 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.action.execution; | ||
|
||
import org.wso2.carbon.identity.action.execution.exception.ActionExecutionResponseProcessorException; | ||
import org.wso2.carbon.identity.action.execution.model.ActionExecutionStatus; | ||
import org.wso2.carbon.identity.action.execution.model.ActionInvocationErrorResponse; | ||
import org.wso2.carbon.identity.action.execution.model.ActionInvocationSuccessResponse; | ||
import org.wso2.carbon.identity.action.execution.model.ActionType; | ||
import org.wso2.carbon.identity.action.execution.model.Event; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* This interface defines the Action Execution Response Processor. | ||
* Action Execution Response Processor is the component that is responsible for processing the response received | ||
* from the action execution. | ||
*/ | ||
public interface ActionExecutionResponseProcessor { | ||
|
||
ActionType getSupportedActionType(); | ||
|
||
ActionExecutionStatus processSuccessResponse(Map<String, Object> eventContext, | ||
Event actionEvent, | ||
ActionInvocationSuccessResponse successResponse) throws | ||
ActionExecutionResponseProcessorException; | ||
|
||
ActionExecutionStatus processErrorResponse(Map<String, Object> eventContext, | ||
Event actionEvent, | ||
ActionInvocationErrorResponse errorResponse) throws | ||
ActionExecutionResponseProcessorException; | ||
} |
59 changes: 59 additions & 0 deletions
59
...va/org/wso2/carbon/identity/action/execution/ActionExecutionResponseProcessorFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* 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.action.execution; | ||
|
||
import org.wso2.carbon.identity.action.execution.model.ActionType; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* This class defines the Action Execution Response Processor Factory. | ||
* Action Execution Response Processor Factory is the component that is responsible for providing the | ||
* {@link ActionExecutionResponseProcessor} based on the action type. | ||
*/ | ||
public class ActionExecutionResponseProcessorFactory { | ||
|
||
private static final Map<ActionType, ActionExecutionResponseProcessor> actionInvocationResponseProcessors = | ||
new HashMap<>(); | ||
|
||
public static ActionExecutionResponseProcessor getActionExecutionResponseProcessor(ActionType actionType) { | ||
|
||
switch (actionType) { | ||
case PRE_ISSUE_ACCESS_TOKEN: | ||
return actionInvocationResponseProcessors.get(ActionType.PRE_ISSUE_ACCESS_TOKEN); | ||
default: | ||
return null; | ||
} | ||
} | ||
|
||
public static void registerActionExecutionResponseProcessor(ActionExecutionResponseProcessor | ||
actionExecutionResponseProcessor) { | ||
|
||
actionInvocationResponseProcessors.put(actionExecutionResponseProcessor.getSupportedActionType(), | ||
actionExecutionResponseProcessor); | ||
} | ||
|
||
public static void unregisterActionExecutionResponseProcessor(ActionExecutionResponseProcessor | ||
actionExecutionResponseProcessor) { | ||
|
||
actionInvocationResponseProcessors.remove(actionExecutionResponseProcessor.getSupportedActionType()); | ||
} | ||
|
||
} |
Oops, something went wrong.