Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
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,189 @@
<?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.framework</groupId>
<artifactId>policy-mgt</artifactId>
<version>7.11.126-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.identity.policy.management</artifactId>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Policy Management Component</name>
<description>Generic policy management backend component</description>
<url>http://wso2.org</url>

<dependencies>

<!-- OSGi -->
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.osgi</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.osgi.services</artifactId>
</dependency>

<!-- Database utils - NamedJdbcTemplate, TransactionException -->
<dependency>
<groupId>org.wso2.carbon.utils</groupId>
<artifactId>org.wso2.carbon.database.utils</artifactId>
</dependency>

<!-- Identity core - IdentityDatabaseUtil, IdentityTenantUtil -->
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.core</artifactId>
</dependency>

<!-- Commons logging - Log, LogFactory -->
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</dependency>

<!-- Commons lang - ArrayUtils used by PolicyManagementExceptionHandler -->
<dependency>
<groupId>commons-lang.wso2</groupId>
<artifactId>commons-lang</artifactId>
</dependency>

<!-- Rule management - RuleManagementService, Rule -->
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.rule.management</artifactId>
</dependency>

<!-- Rule evaluation - RuleEvaluationService, FlowContext, RuleEvaluationResult -->
<dependency>
<groupId>org.wso2.carbon.identity.framework</groupId>
<artifactId>org.wso2.carbon.identity.rule.evaluation</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>
<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.policy.management.internal.*
</Private-Package>
<Export-Package>
!org.wso2.carbon.identity.policy.management.internal.*,
org.wso2.carbon.identity.policy.management.api.*;
version="${carbon.identity.package.export.version}"
</Export-Package>
<Import-Package>
org.apache.commons.logging; version="${import.package.version.commons.logging}",
org.apache.commons.lang; version="${commons-lang.wso2.osgi.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.osgi.service.component.annotations;
version="${osgi.service.component.imp.pkg.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.core.util;
version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.rule.management.api.exception;
version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.rule.management.api.model;
version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.rule.management.api.service;
version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.rule.management.api.util;
version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.rule.evaluation.api.exception;
version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.rule.evaluation.api.model;
version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.identity.rule.evaluation.api.service;
version="${carbon.identity.package.import.version.range}",
org.wso2.carbon.utils;
version="${carbon.kernel.package.import.version.range}",
org.wso2.carbon.identity.core.cache;
version="${carbon.identity.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>
<suiteXmlFiles>
<suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<configuration>
<excludeFilterFile>../../../spotbugs-exclude.xml</excludeFilterFile>
<effort>Max</effort>
<threshold>High</threshold>
<xmlOutput>true</xmlOutput>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright (c) 2026, 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.policy.management.api.constant;

/**
* Error messages for Policy Management.
*/
public enum ErrorMessage {

// Client errors.
ERROR_POLICY_NOT_FOUND("PM-60001", "Policy not found.",
"No policy found for the given policy id: %s."),
ERROR_INVALID_POLICY_REQUEST_FIELD("PM-60002", "Invalid request.",
"%s is empty or invalid."),
ERROR_INVALID_POLICY_RULE("PM-60003", "Invalid policy rule.",
"Policy rule validation failed: %s"),
ERROR_POLICY_ALREADY_EXISTS("PM-60004", "Policy already exists.",
"A policy with name '%s' already exists for the tenant."),
ERROR_DUPLICATE_PLATFORM_IN_POLICY("PM-60005", "Duplicate platform in policy.",
"Policy '%s' has more than one rule for platform '%s'."),

// Server errors.
ERROR_WHILE_ADDING_POLICY("PM-65001", "Error while adding Policy.",
"Error while persisting Policy in the system."),
ERROR_WHILE_RETRIEVING_POLICY("PM-65002", "Error while retrieving Policy.",
"Error while retrieving Policy from the system."),
ERROR_WHILE_UPDATING_POLICY("PM-65003", "Error while updating Policy.",
"Error while updating Policy in the system."),
ERROR_WHILE_DELETING_POLICY("PM-65004", "Error while deleting Policy.",
"Error while deleting Policy from the system."),
ERROR_WHILE_ADDING_RULE_FOR_POLICY("PM-65005", "Error while adding Rule for Policy.",
"Error while adding Rule for Policy: %s in the system."),
ERROR_WHILE_UPDATING_RULE_FOR_POLICY("PM-65006", "Error while updating Rule for Policy.",
"Error while updating Rule for Policy: %s in the system."),
ERROR_WHILE_DELETING_RULE_FOR_POLICY("PM-65007", "Error while deleting Rule for Policy.",
"Error while deleting Rule for Policy: %s from the system.");

private final String code;
private final String message;
private final String description;

ErrorMessage(String code, String message, String description) {

this.code = code;
this.message = message;
this.description = description;
}

public String getCode() {

return code;
}

public String getMessage() {

return message;
}

public String getDescription() {

return description;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2026, 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.policy.management.api.exception;

/**
* Client exception for Device Policy Management.
*/
public class PolicyManagementClientException extends PolicyManagementException {

public PolicyManagementClientException(String message, String description, String errorCode) {

super(message, description, errorCode);
}

public PolicyManagementClientException(String message, String description, String errorCode,
Throwable cause) {

super(message, description, errorCode, cause);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2026, 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.policy.management.api.exception;

/**
* Base exception for Device Policy Management.
*/
public class PolicyManagementException extends Exception {

private final String errorCode;
private final String description;

public PolicyManagementException(String message, String description, String errorCode) {

super(message);
this.errorCode = errorCode;
this.description = description;
}

public PolicyManagementException(String message, String description, String errorCode,
Throwable cause) {

super(message, cause);
this.errorCode = errorCode;
this.description = description;
}

public String getErrorCode() {

return errorCode;
}

public String getDescription() {

return description;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2026, 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.policy.management.api.exception;

/**
* Server exception for Device Policy Management.
*/
public class PolicyManagementServerException extends PolicyManagementException {

public PolicyManagementServerException(String message, String description, String errorCode) {

super(message, description, errorCode);
}

public PolicyManagementServerException(String message, String description, String errorCode,
Throwable cause) {

super(message, description, errorCode, cause);
}
}
Loading
Loading