-
Notifications
You must be signed in to change notification settings - Fork 550
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 #6260 from sahandilshan/loginflow-ai-2
Add support to connect to the LoginFlow AI service
- Loading branch information
Showing
23 changed files
with
2,346 additions
and
2 deletions.
There are no files selected for viewing
211 changes: 211 additions & 0 deletions
211
components/ai-services-mgt/org.wso2.carbon.identity.ai.service.mgt/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,211 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright (c) 2025, 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>ai-services-mgt</artifactId> | ||
<version>7.7.93-SNAPSHOT</version> | ||
<relativePath>../pom.xml</relativePath> | ||
</parent> | ||
|
||
<artifactId>org.wso2.carbon.identity.ai.service.mgt</artifactId> | ||
<packaging>bundle</packaging> | ||
<name>WSO2 Identity - AI Service Management Bundle</name> | ||
<description>This represents the AI Service Management Bundle.</description> | ||
<url>http://wso2.org</url> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.ops4j.pax.logging</groupId> | ||
<artifactId>pax-logging-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.wso2.carbon.identity.framework</groupId> | ||
<artifactId>org.wso2.carbon.identity.core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents.wso2</groupId> | ||
<artifactId>httpcore</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-core</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.wiremock</groupId> | ||
<artifactId>wiremock</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.ops4j.pax.logging</groupId> | ||
<artifactId>pax-logging-api</artifactId> | ||
<scope>provided</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> | ||
<Import-Package> | ||
org.osgi.framework; version="${osgi.framework.imp.pkg.version.range}", | ||
org.osgi.service.component; version="${osgi.service.component.imp.pkg.version.range}", | ||
com.google.gson;version="${com.google.code.gson.osgi.version.range}", | ||
org.wso2.carbon.identity.core.util; 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}", | ||
com.fasterxml.jackson.databind.*; version="${com.fasterxml.jackson.annotation.version.range}", | ||
org.wso2.carbon.context; version="${carbon.kernel.package.import.version.range}", | ||
|
||
org.apache.http; version="${httpcore.version.osgi.import.range}", | ||
org.apache.http.client; version="${httpcomponents-httpclient.imp.pkg.version.range}", | ||
org.apache.http.client.methods; version="${httpcomponents-httpclient.imp.pkg.version.range}", | ||
org.apache.http.client.config; version="${httpcomponents-httpclient.imp.pkg.version.range}", | ||
org.apache.http.entity; version="${httpcore.version.osgi.import.range}", | ||
org.apache.http.message; version="${httpcore.version.osgi.import.range}", | ||
org.apache.http.protocol; 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.concurrent; version="${httpcore.version.osgi.import.range}", | ||
</Import-Package> | ||
<Export-Package> | ||
org.wso2.carbon.identity.ai.service.mgt.*; version="${carbon.identity.package.export.version}" | ||
</Export-Package> | ||
</instructions> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>${maven.surefire.plugin.version}</version> | ||
<configuration> | ||
<!--suppress UnresolvedMavenProperty --> | ||
<argLine> | ||
${argLine} | ||
--add-opens=java.base/java.lang=ALL-UNNAMED | ||
--add-opens=java.base/java.util=ALL-UNNAMED | ||
--add-opens java.xml/jdk.xml.internal=ALL-UNNAMED | ||
--add-opens=java.base/java.io=ALL-UNNAMED | ||
--add-opens=java.base/sun.nio.fs=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> | ||
<configuration> | ||
<excludes> | ||
<exclude>**/*Exception.class</exclude> | ||
<exclude>**/*Constants*.class</exclude> | ||
</excludes> | ||
</configuration> | ||
<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.80</minimum> | ||
</limit> | ||
</limits> | ||
</rule> | ||
</rules> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<groupId>com.github.spotbugs</groupId> | ||
<artifactId>spotbugs-maven-plugin</artifactId> | ||
<configuration> | ||
<threshold>High</threshold> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
107 changes: 107 additions & 0 deletions
107
...vice.mgt/src/main/java/org/wso2/carbon/identity/ai/service/mgt/constants/AIConstants.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,107 @@ | ||
/* | ||
* Copyright (c) 2025, 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.ai.service.mgt.constants; | ||
|
||
/** | ||
* Constants for the LoginFlowAI module. | ||
*/ | ||
public class AIConstants { | ||
|
||
private AIConstants () { | ||
|
||
} | ||
|
||
public static final String AI_SERVICE_KEY_PROPERTY_NAME = "AIServices.Key"; | ||
public static final String AI_TOKEN_ENDPOINT_PROPERTY_NAME = "AIServices.TokenEndpoint"; | ||
public static final String AI_TOKEN_SERVICE_MAX_RETRIES_PROPERTY_NAME = "AIServices.TokenRequestMaxRetries"; | ||
public static final String AI_TOKEN_CONNECTION_TIMEOUT_PROPERTY_NAME = "AIServices.TokenConnectionTimeout"; | ||
public static final String AI_TOKEN_CONNECTION_REQUEST_TIMEOUT_PROPERTY_NAME = "AIServices" + | ||
".TokenConnectionRequestTimeout"; | ||
public static final String AI_TOKEN_SOCKET_TIMEOUT_PROPERTY_NAME = "AIServices.TokenConnectionSocketTimeout"; | ||
|
||
public static final String HTTP_CONNECTION_POOL_SIZE_PROPERTY_NAME = "AIServices.HTTPConnectionPoolSize"; | ||
public static final String HTTP_CONNECTION_TIMEOUT_PROPERTY_NAME = "AIServices.HTTPConnectionTimeout"; | ||
public static final String HTTP_CONNECTION_REQUEST_TIMEOUT_PROPERTY_NAME = "AIServices" + | ||
".HTTPConnectionRequestTimeout"; | ||
public static final String HTTP_SOCKET_TIMEOUT_PROPERTY_NAME = "AIServices.HTTPSocketTimeout"; | ||
|
||
// Http constants. | ||
public static final String HTTP_BASIC = "Basic"; | ||
public static final String HTTP_BEARER = "Bearer"; | ||
public static final String CONTENT_TYPE_FORM_URLENCODED = "application/x-www-form-urlencoded"; | ||
public static final String CONTENT_TYPE_JSON = "application/json"; | ||
|
||
// Access Token response constants. | ||
public static final String ACCESS_TOKEN_KEY = "access_token"; | ||
|
||
public static final String TENANT_CONTEXT_PREFIX = "/t/"; | ||
|
||
// Default Property values. | ||
public static final int DEFAULT_TOKEN_REQUEST_MAX_RETRIES = 3; | ||
public static final int DEFAULT_TOKEN_CONNECTION_TIMEOUT = 3000; | ||
public static final int DEFAULT_TOKEN_CONNECTION_REQUEST_TIMEOUT = 3000; | ||
public static final int DEFAULT_TOKEN_SOCKET_TIMEOUT = 3000; | ||
|
||
public static final int DEFAULT_HTTP_CONNECTION_POOL_SIZE = 20; | ||
public static final int DEFAULT_HTTP_CONNECTION_TIMEOUT = 3000; | ||
public static final int DEFAULT_HTTP_CONNECTION_REQUEST_TIMEOUT = 3000; | ||
public static final int DEFAULT_HTTP_SOCKET_TIMEOUT = 3000; | ||
|
||
/** | ||
* Enums for error messages. | ||
*/ | ||
public enum ErrorMessages { | ||
|
||
MAXIMUM_RETRIES_EXCEEDED("AI-10000", "Maximum retries exceeded to retrieve the access token."), | ||
UNABLE_TO_ACCESS_AI_SERVICE_WITH_RENEW_ACCESS_TOKEN("AI-10003", "Unable to access the " + | ||
"AI service with the renewed access token."), | ||
REQUEST_TIMEOUT("AI-10004", "Request to the AI service timed out."), | ||
ERROR_RETRIEVING_ACCESS_TOKEN("AI-10007", "Error occurred while retrieving the " + | ||
"access token."), | ||
CLIENT_ERROR_WHILE_CONNECTING_TO_AI_SERVICE("AI-10008", "Client error occurred " + | ||
"for %s tenant while connecting to AI service."), | ||
SERVER_ERROR_WHILE_CONNECTING_TO_AI_SERVICE("AI-10009", "Server error occurred " + | ||
"for %s tenant while connecting to AI service."); | ||
|
||
private final String code; | ||
private final String message; | ||
|
||
ErrorMessages(String code, String message) { | ||
|
||
this.code = code; | ||
this.message = message; | ||
} | ||
|
||
public String getCode() { | ||
|
||
return code; | ||
} | ||
|
||
public String getMessage() { | ||
|
||
return message; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
|
||
return code + ":" + message; | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...t/src/main/java/org/wso2/carbon/identity/ai/service/mgt/exceptions/AIClientException.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,40 @@ | ||
/* | ||
* Copyright (c) 2025, 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.ai.service.mgt.exceptions; | ||
|
||
/** | ||
* Client Exception class for AI service. | ||
*/ | ||
public class AIClientException extends AIException { | ||
|
||
public AIClientException(String message, String errorCode) { | ||
|
||
super(message, errorCode); | ||
} | ||
|
||
public AIClientException(String message, String errorCode, int serverStatusCode, String serverMessage) { | ||
|
||
super(message, errorCode, serverStatusCode, serverMessage); | ||
} | ||
|
||
public AIClientException(String message, String errorCode, Throwable cause) { | ||
|
||
super(message, errorCode, cause); | ||
} | ||
} |
Oops, something went wrong.