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

Add action execution component. #5810

Merged
merged 26 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9725a5b
Add action execution component.
malithie Jul 22, 2024
acc1263
Add action execution component.
malithie Jul 22, 2024
51c2667
Add action execution component.
malithie Jul 22, 2024
50e2895
Fix checkstyle issues.
malithie Jul 22, 2024
efd4b36
Merge remote-tracking branch 'origin/actions-core' into actions-core
malithie Jul 22, 2024
6e68ec9
Implement request/response service registration.
malithie Jul 23, 2024
f7621c0
Fix request response parsing.
malithie Jul 24, 2024
98c52a3
Improve code readability.
malithie Jul 24, 2024
20fead1
Changed variable all caps when static final.
malithie Jul 24, 2024
0bd1c7e
Remove incomplete tests.
malithie Jul 24, 2024
b8c8c3d
Update action.mgt dependency version.
malithie Jul 24, 2024
bdd4455
Merge branch 'master' into actions-core
malithie Jul 24, 2024
22aed58
Merge master branch and update version.
malithie Jul 24, 2024
16b65a4
Add isActive method.
malithie Jul 25, 2024
35ba937
Revert "Add isActive method."
malithie Jul 25, 2024
64040ff
Check for active actions before invoking.
malithie Jul 25, 2024
009a79a
Address review comments.
malithie Jul 26, 2024
bd9b4c2
Address review comments.
malithie Jul 26, 2024
38b9b3a
Address review comments.
malithie Jul 26, 2024
d69fa2c
Address review comments.
malithie Jul 26, 2024
a63ceb6
Merge branch 'master' into actions-core
malithie Jul 27, 2024
20c14a8
Address review comments.
malithie Jul 27, 2024
4f224ec
Changed FAILURE to FAILED.
malithie Jul 29, 2024
a553164
Updated user model.
malithie Jul 29, 2024
325a248
Merge branch 'master' into actions-core
malithie Jul 29, 2024
2c162cc
Update version.
malithie Jul 29, 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,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.42-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>
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(ActionType actionType, Map<String, Object> eventContext) throws
malithie marked this conversation as resolved.
Show resolved Hide resolved
malithie marked this conversation as resolved.
Show resolved Hide resolved
ActionExecutionRequestBuilderException;

}
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 =
malithie marked this conversation as resolved.
Show resolved Hide resolved
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());
}

}
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(ActionType actionType, Map<String, Object> eventContext,
Event actionEvent,
ActionInvocationSuccessResponse successResponse) throws
ActionExecutionResponseProcessorException;

ActionExecutionStatus processErrorResponse(ActionType actionType, Map<String, Object> eventContext,
Event actionEvent,
ActionInvocationErrorResponse errorResponse) throws
ActionExecutionResponseProcessorException;
}
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) {
malithie marked this conversation as resolved.
Show resolved Hide resolved
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());
}

}
Loading
Loading