From ff0c8a87e4e5f6fe34f6404c519a42d1eabc7a8f Mon Sep 17 00:00:00 2001 From: kaviska Date: Sun, 19 Jul 2026 18:30:51 +0530 Subject: [PATCH 1/2] Introduce Device Policy API Add a new Device Policy API component exposing device policy field metadata for the devicePolicy rule flow, optionally filtered by platform. - GET /device-policies/metadata?platform={android|ios|macos|windows} returns the rule fields applicable to the given platform. Platform applicability is resolved from the device field configuration; fields with no platform restriction apply to all platforms. - Invalid platform values are rejected with HTTP 400. - Adds the component to the reactor and to dependency management. Requires org.wso2.carbon.identity.device.policy from carbon-identity-framework. --- .../pom.xml | 57 ++++ .../device/policy/common/Constants.java | 88 +++++++ .../DevicePolicyMetadataServiceHolder.java | 59 +++++ .../pom.xml | 170 ++++++++++++ .../device/policy/v1/DevicePoliciesApi.java | 73 +++++ .../policy/v1/DevicePoliciesApiService.java | 35 +++ .../DevicePoliciesApiServiceFactory.java | 32 +++ .../policy/v1/model/DevicePolicyField.java | 119 +++++++++ .../v1/model/DevicePolicyFieldDefinition.java | 154 +++++++++++ .../policy/v1/model/DevicePolicyLink.java | 206 +++++++++++++++ .../policy/v1/model/DevicePolicyOperator.java | 119 +++++++++ .../policy/v1/model/DevicePolicyValue.java | 249 ++++++++++++++++++ .../v1/model/DevicePolicyValueObject.java | 119 +++++++++ .../server/device/policy/v1/model/Error.java | 161 +++++++++++ .../v1/core/DevicePolicyMetadataService.java | 170 ++++++++++++ .../DevicePolicyMetadataServiceFactory.java | 54 ++++ .../v1/impl/DevicePoliciesApiServiceImpl.java | 44 ++++ .../v1/util/DevicePolicyAPIErrorBuilder.java | 76 ++++++ .../src/main/resources/device-policy.yaml | 165 ++++++++++++ .../pom.xml | 33 +++ pom.xml | 7 + 21 files changed, 2190 insertions(+) create mode 100644 components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.common/pom.xml create mode 100644 components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.common/src/main/java/org/wso2/carbon/identity/api/server/device/policy/common/Constants.java create mode 100644 components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.common/src/main/java/org/wso2/carbon/identity/api/server/device/policy/common/DevicePolicyMetadataServiceHolder.java create mode 100644 components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/pom.xml create mode 100644 components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/DevicePoliciesApi.java create mode 100644 components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/DevicePoliciesApiService.java create mode 100644 components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/factories/DevicePoliciesApiServiceFactory.java create mode 100644 components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyField.java create mode 100644 components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyFieldDefinition.java create mode 100644 components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyLink.java create mode 100644 components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyOperator.java create mode 100644 components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyValue.java create mode 100644 components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyValueObject.java create mode 100644 components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/Error.java create mode 100644 components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/main/java/org/wso2/carbon/identity/api/server/device/policy/v1/core/DevicePolicyMetadataService.java create mode 100644 components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/main/java/org/wso2/carbon/identity/api/server/device/policy/v1/factories/DevicePolicyMetadataServiceFactory.java create mode 100644 components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/main/java/org/wso2/carbon/identity/api/server/device/policy/v1/impl/DevicePoliciesApiServiceImpl.java create mode 100644 components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/main/java/org/wso2/carbon/identity/api/server/device/policy/v1/util/DevicePolicyAPIErrorBuilder.java create mode 100644 components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/main/resources/device-policy.yaml create mode 100644 components/org.wso2.carbon.identity.api.server.device.policy/pom.xml diff --git a/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.common/pom.xml b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.common/pom.xml new file mode 100644 index 0000000000..23ac2217cf --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.common/pom.xml @@ -0,0 +1,57 @@ + + + + 4.0.0 + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.device.policy + 1.6.36-SNAPSHOT + + + org.wso2.carbon.identity.api.server.device.policy.common + jar + + + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.rule.metadata + provided + + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.device.policy + ${carbon.identity.framework.version} + provided + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + + diff --git a/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.common/src/main/java/org/wso2/carbon/identity/api/server/device/policy/common/Constants.java b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.common/src/main/java/org/wso2/carbon/identity/api/server/device/policy/common/Constants.java new file mode 100644 index 0000000000..fe3040498c --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.common/src/main/java/org/wso2/carbon/identity/api/server/device/policy/common/Constants.java @@ -0,0 +1,88 @@ +/* + * 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.api.server.device.policy.common; + +/** + * Constants for the Device Policy API. + */ +public class Constants { + + private Constants() { + } + + public static final String DEVICE_POLICY_ERROR_PREFIX = "DPM-"; + + public static final String V1_API_PATH_COMPONENT = "/v1"; + + public static final String DEVICE_POLICY_PATH_COMPONENT = "/device-policies"; + + /** + * Error messages for the Device Policy API. + */ + public enum ErrorMessage { + + ERROR_CODE_INVALID_PLATFORM("60001", + "Invalid platform.", + "Supported platforms: android, ios, macos, windows."), + ERROR_CODE_ERROR_RETRIEVING_METADATA("65001", + "Unable to retrieve device policy metadata.", + "Server encountered an error while retrieving device policy field metadata."); + + 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; + } + + /** + * Returns the error code with prefix. + * + * @return Error code. + */ + public String code() { + + return DEVICE_POLICY_ERROR_PREFIX + code; + } + + /** + * Returns the error message. + * + * @return Error message. + */ + public String message() { + + return message; + } + + /** + * Returns the error description. + * + * @return Error description. + */ + public String description() { + + return description; + } + } +} diff --git a/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.common/src/main/java/org/wso2/carbon/identity/api/server/device/policy/common/DevicePolicyMetadataServiceHolder.java b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.common/src/main/java/org/wso2/carbon/identity/api/server/device/policy/common/DevicePolicyMetadataServiceHolder.java new file mode 100644 index 0000000000..92a60cbc25 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.common/src/main/java/org/wso2/carbon/identity/api/server/device/policy/common/DevicePolicyMetadataServiceHolder.java @@ -0,0 +1,59 @@ +/* + * 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.api.server.device.policy.common; + +import org.wso2.carbon.context.PrivilegedCarbonContext; +import org.wso2.carbon.identity.device.policy.api.service.DeviceFieldMetadataService; +import org.wso2.carbon.identity.rule.metadata.api.service.RuleMetadataService; + +/** + * Service holder for the device policy API — retrieves OSGi services from the Carbon context. + */ +public class DevicePolicyMetadataServiceHolder { + + private DevicePolicyMetadataServiceHolder() {} + + private static class RuleMetadataServiceHolder { + + static final RuleMetadataService SERVICE = (RuleMetadataService) PrivilegedCarbonContext + .getThreadLocalCarbonContext().getOSGiService(RuleMetadataService.class, null); + } + + private static class DeviceFieldMetadataServiceHolder { + + static final DeviceFieldMetadataService SERVICE = (DeviceFieldMetadataService) PrivilegedCarbonContext + .getThreadLocalCarbonContext().getOSGiService(DeviceFieldMetadataService.class, null); + } + + /** + * Returns the RuleMetadataService OSGi service. + */ + public static RuleMetadataService getRuleMetadataService() { + + return RuleMetadataServiceHolder.SERVICE; + } + + /** + * Returns the DeviceFieldMetadataService OSGi service. + */ + public static DeviceFieldMetadataService getDeviceFieldMetadataService() { + + return DeviceFieldMetadataServiceHolder.SERVICE; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/pom.xml b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/pom.xml new file mode 100644 index 0000000000..6b28465ed7 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/pom.xml @@ -0,0 +1,170 @@ + + + + 4.0.0 + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.device.policy + 1.6.36-SNAPSHOT + + + org.wso2.carbon.identity.api.server.device.policy.v1 + jar + + + + org.apache.cxf + cxf-rt-frontend-jaxrs + provided + + + org.apache.cxf + cxf-rt-rs-service-description + provided + + + javax.ws.rs + javax.ws.rs-api + provided + + + io.swagger + swagger-jaxrs + + + com.fasterxml.jackson.core + jackson-databind + + + com.fasterxml.jackson.core + jackson-annotations + + + com.fasterxml.jackson.core + jackson-core + + + com.fasterxml.jackson.dataformat + jackson-dataformat-yaml + + + javax.ws.rs + jsr311-api + + + com.google.guava + guava + + + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + provided + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.common + provided + + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.device.policy.common + provided + + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.rule.metadata + provided + + + org.wso2.carbon.identity.framework + org.wso2.carbon.identity.device.policy + ${carbon.identity.framework.version} + provided + + + + + + + org.openapitools + openapi-generator-maven-plugin + 4.1.2 + + + + generate + + + ${project.basedir}/src/main/resources/device-policy.yaml + org.wso2.carbon.codegen.CxfWso2Generator + + src/gen/java + org.wso2.carbon.identity.api.server.device.policy.v1 + org.wso2.carbon.identity.api.server.device.policy.v1.model + org.wso2.carbon.identity.api.server.device.policy.v1 + java8 + true + + . + false + + + + + + org.openapitools + cxf-wso2-openapi-generator + 1.0.0 + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.8 + + + add-source + generate-sources + + add-source + + + + src/gen/java + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compiler.plugin.version} + + 1.8 + 1.8 + + + + + diff --git a/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/DevicePoliciesApi.java b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/DevicePoliciesApi.java new file mode 100644 index 0000000000..f9c175d5e2 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/DevicePoliciesApi.java @@ -0,0 +1,73 @@ +/* + * 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.api.server.device.policy.v1; + +import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.apache.cxf.jaxrs.ext.multipart.Multipart; +import java.io.InputStream; +import java.util.List; + +import org.wso2.carbon.identity.api.server.device.policy.v1.model.DevicePolicyFieldDefinition; +import org.wso2.carbon.identity.api.server.device.policy.v1.model.Error; +import org.wso2.carbon.identity.api.server.device.policy.v1.DevicePoliciesApiService; +import org.wso2.carbon.identity.api.server.device.policy.v1.factories.DevicePoliciesApiServiceFactory; + +import javax.validation.Valid; +import javax.ws.rs.*; +import javax.ws.rs.core.Response; +import io.swagger.annotations.*; + +import javax.validation.constraints.*; + +@Path("/device-policies") +@Api(description = "The device-policies API") + +public class DevicePoliciesApi { + + private final DevicePoliciesApiService delegate; + + public DevicePoliciesApi() { + + this.delegate = DevicePoliciesApiServiceFactory.getDevicePoliciesApi(); + } + + @Valid + @GET + @Path("/metadata") + + @Produces({ "application/json" }) + @ApiOperation(value = "Get device policy field metadata filtered by platform.", notes = "Returns the list of rule fields applicable for the devicePolicy flow, optionally filtered to a specific platform. Used by the UI to populate the rule builder with platform-relevant fields only. ", response = DevicePolicyFieldDefinition.class, responseContainer = "List", authorizations = { + @Authorization(value = "BasicAuth"), + @Authorization(value = "OAuth2", scopes = { + + }) + }, tags={ "Device Policy Management" }) + @ApiResponses(value = { + @ApiResponse(code = 200, message = "Applicable fields for the given platform.", response = DevicePolicyFieldDefinition.class, responseContainer = "List"), + @ApiResponse(code = 400, message = "Bad Request", response = Error.class), + @ApiResponse(code = 401, message = "Unauthorized", response = Void.class), + @ApiResponse(code = 403, message = "Forbidden", response = Void.class), + @ApiResponse(code = 500, message = "Server Error", response = Error.class) + }) + public Response getDevicePolicyMetadata( @Valid@ApiParam(value = "Filter fields to those applicable for this platform. If omitted all fields are returned.", allowableValues="android, ios, macos, windows") @QueryParam("platform") String platform) { + + return delegate.getDevicePolicyMetadata(platform ); + } + +} diff --git a/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/DevicePoliciesApiService.java b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/DevicePoliciesApiService.java new file mode 100644 index 0000000000..b6e719c4d7 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/DevicePoliciesApiService.java @@ -0,0 +1,35 @@ +/* + * 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.api.server.device.policy.v1; + +import org.wso2.carbon.identity.api.server.device.policy.v1.*; +import org.wso2.carbon.identity.api.server.device.policy.v1.model.*; +import org.apache.cxf.jaxrs.ext.multipart.Attachment; +import org.apache.cxf.jaxrs.ext.multipart.Multipart; +import java.io.InputStream; +import java.util.List; +import org.wso2.carbon.identity.api.server.device.policy.v1.model.DevicePolicyFieldDefinition; +import org.wso2.carbon.identity.api.server.device.policy.v1.model.Error; +import javax.ws.rs.core.Response; + + +public interface DevicePoliciesApiService { + + public Response getDevicePolicyMetadata(String platform); +} diff --git a/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/factories/DevicePoliciesApiServiceFactory.java b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/factories/DevicePoliciesApiServiceFactory.java new file mode 100644 index 0000000000..066afba4d1 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/factories/DevicePoliciesApiServiceFactory.java @@ -0,0 +1,32 @@ +/* + * 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.api.server.device.policy.v1.factories; + +import org.wso2.carbon.identity.api.server.device.policy.v1.DevicePoliciesApiService; +import org.wso2.carbon.identity.api.server.device.policy.v1.impl.DevicePoliciesApiServiceImpl; + +public class DevicePoliciesApiServiceFactory { + + private final static DevicePoliciesApiService SERVICE = new DevicePoliciesApiServiceImpl(); + + public static DevicePoliciesApiService getDevicePoliciesApi() { + + return SERVICE; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyField.java b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyField.java new file mode 100644 index 0000000000..a608dd1e14 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyField.java @@ -0,0 +1,119 @@ +/* + * 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.api.server.device.policy.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class DevicePolicyField { + + private String name; + private String displayName; + + /** + **/ + public DevicePolicyField name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "platform", value = "") + @JsonProperty("name") + @Valid + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public DevicePolicyField displayName(String displayName) { + + this.displayName = displayName; + return this; + } + + @ApiModelProperty(example = "platform", value = "") + @JsonProperty("displayName") + @Valid + public String getDisplayName() { + return displayName; + } + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DevicePolicyField devicePolicyField = (DevicePolicyField) o; + return Objects.equals(this.name, devicePolicyField.name) && + Objects.equals(this.displayName, devicePolicyField.displayName); + } + + @Override + public int hashCode() { + return Objects.hash(name, displayName); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class DevicePolicyField {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyFieldDefinition.java b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyFieldDefinition.java new file mode 100644 index 0000000000..6a34691d1b --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyFieldDefinition.java @@ -0,0 +1,154 @@ +/* + * 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.api.server.device.policy.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import org.wso2.carbon.identity.api.server.device.policy.v1.model.DevicePolicyField; +import org.wso2.carbon.identity.api.server.device.policy.v1.model.DevicePolicyOperator; +import org.wso2.carbon.identity.api.server.device.policy.v1.model.DevicePolicyValue; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class DevicePolicyFieldDefinition { + + private DevicePolicyField field; + private List operators = null; + + private DevicePolicyValue value; + + /** + **/ + public DevicePolicyFieldDefinition field(DevicePolicyField field) { + + this.field = field; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("field") + @Valid + public DevicePolicyField getField() { + return field; + } + public void setField(DevicePolicyField field) { + this.field = field; + } + + /** + **/ + public DevicePolicyFieldDefinition operators(List operators) { + + this.operators = operators; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("operators") + @Valid + public List getOperators() { + return operators; + } + public void setOperators(List operators) { + this.operators = operators; + } + + public DevicePolicyFieldDefinition addOperatorsItem(DevicePolicyOperator operatorsItem) { + if (this.operators == null) { + this.operators = new ArrayList<>(); + } + this.operators.add(operatorsItem); + return this; + } + + /** + **/ + public DevicePolicyFieldDefinition value(DevicePolicyValue value) { + + this.value = value; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("value") + @Valid + public DevicePolicyValue getValue() { + return value; + } + public void setValue(DevicePolicyValue value) { + this.value = value; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DevicePolicyFieldDefinition devicePolicyFieldDefinition = (DevicePolicyFieldDefinition) o; + return Objects.equals(this.field, devicePolicyFieldDefinition.field) && + Objects.equals(this.operators, devicePolicyFieldDefinition.operators) && + Objects.equals(this.value, devicePolicyFieldDefinition.value); + } + + @Override + public int hashCode() { + return Objects.hash(field, operators, value); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class DevicePolicyFieldDefinition {\n"); + + sb.append(" field: ").append(toIndentedString(field)).append("\n"); + sb.append(" operators: ").append(toIndentedString(operators)).append("\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyLink.java b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyLink.java new file mode 100644 index 0000000000..4caf6a53b8 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyLink.java @@ -0,0 +1,206 @@ +/* + * 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.api.server.device.policy.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class DevicePolicyLink { + + private String href; + +@XmlType(name="MethodEnum") +@XmlEnum(String.class) +public enum MethodEnum { + + @XmlEnumValue("GET") GET(String.valueOf("GET")); + + + private String value; + + MethodEnum(String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static MethodEnum fromValue(String value) { + for (MethodEnum b : MethodEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + + private MethodEnum method; + +@XmlType(name="RelEnum") +@XmlEnum(String.class) +public enum RelEnum { + + @XmlEnumValue("values") VALUES(String.valueOf("values")), @XmlEnumValue("filter") FILTER(String.valueOf("filter")); + + + private String value; + + RelEnum(String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static RelEnum fromValue(String value) { + for (RelEnum b : RelEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + + private RelEnum rel; + + /** + **/ + public DevicePolicyLink href(String href) { + + this.href = href; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("href") + @Valid + public String getHref() { + return href; + } + public void setHref(String href) { + this.href = href; + } + + /** + **/ + public DevicePolicyLink method(MethodEnum method) { + + this.method = method; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("method") + @Valid + public MethodEnum getMethod() { + return method; + } + public void setMethod(MethodEnum method) { + this.method = method; + } + + /** + **/ + public DevicePolicyLink rel(RelEnum rel) { + + this.rel = rel; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("rel") + @Valid + public RelEnum getRel() { + return rel; + } + public void setRel(RelEnum rel) { + this.rel = rel; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DevicePolicyLink devicePolicyLink = (DevicePolicyLink) o; + return Objects.equals(this.href, devicePolicyLink.href) && + Objects.equals(this.method, devicePolicyLink.method) && + Objects.equals(this.rel, devicePolicyLink.rel); + } + + @Override + public int hashCode() { + return Objects.hash(href, method, rel); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class DevicePolicyLink {\n"); + + sb.append(" href: ").append(toIndentedString(href)).append("\n"); + sb.append(" method: ").append(toIndentedString(method)).append("\n"); + sb.append(" rel: ").append(toIndentedString(rel)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyOperator.java b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyOperator.java new file mode 100644 index 0000000000..7d9bf7f79b --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyOperator.java @@ -0,0 +1,119 @@ +/* + * 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.api.server.device.policy.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class DevicePolicyOperator { + + private String name; + private String displayName; + + /** + **/ + public DevicePolicyOperator name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "equals", value = "") + @JsonProperty("name") + @Valid + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public DevicePolicyOperator displayName(String displayName) { + + this.displayName = displayName; + return this; + } + + @ApiModelProperty(example = "equals", value = "") + @JsonProperty("displayName") + @Valid + public String getDisplayName() { + return displayName; + } + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DevicePolicyOperator devicePolicyOperator = (DevicePolicyOperator) o; + return Objects.equals(this.name, devicePolicyOperator.name) && + Objects.equals(this.displayName, devicePolicyOperator.displayName); + } + + @Override + public int hashCode() { + return Objects.hash(name, displayName); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class DevicePolicyOperator {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyValue.java b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyValue.java new file mode 100644 index 0000000000..83edc91c8f --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyValue.java @@ -0,0 +1,249 @@ +/* + * 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.api.server.device.policy.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import org.wso2.carbon.identity.api.server.device.policy.v1.model.DevicePolicyLink; +import org.wso2.carbon.identity.api.server.device.policy.v1.model.DevicePolicyValueObject; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class DevicePolicyValue { + + +@XmlType(name="InputTypeEnum") +@XmlEnum(String.class) +public enum InputTypeEnum { + + @XmlEnumValue("input") INPUT(String.valueOf("input")), @XmlEnumValue("options") OPTIONS(String.valueOf("options")); + + + private String value; + + InputTypeEnum(String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static InputTypeEnum fromValue(String value) { + for (InputTypeEnum b : InputTypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + + private InputTypeEnum inputType; + +@XmlType(name="ValueTypeEnum") +@XmlEnum(String.class) +public enum ValueTypeEnum { + + @XmlEnumValue("string") STRING(String.valueOf("string")), @XmlEnumValue("number") NUMBER(String.valueOf("number")), @XmlEnumValue("boolean") BOOLEAN(String.valueOf("boolean")), @XmlEnumValue("date") DATE(String.valueOf("date")), @XmlEnumValue("reference") REFERENCE(String.valueOf("reference")), @XmlEnumValue("symbolic") SYMBOLIC(String.valueOf("symbolic")); + + + private String value; + + ValueTypeEnum(String v) { + value = v; + } + + public String value() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ValueTypeEnum fromValue(String value) { + for (ValueTypeEnum b : ValueTypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } +} + + private ValueTypeEnum valueType; + private List values = null; + + private List links = null; + + + /** + **/ + public DevicePolicyValue inputType(InputTypeEnum inputType) { + + this.inputType = inputType; + return this; + } + + @ApiModelProperty(example = "options", value = "") + @JsonProperty("inputType") + @Valid + public InputTypeEnum getInputType() { + return inputType; + } + public void setInputType(InputTypeEnum inputType) { + this.inputType = inputType; + } + + /** + **/ + public DevicePolicyValue valueType(ValueTypeEnum valueType) { + + this.valueType = valueType; + return this; + } + + @ApiModelProperty(example = "string", value = "") + @JsonProperty("valueType") + @Valid + public ValueTypeEnum getValueType() { + return valueType; + } + public void setValueType(ValueTypeEnum valueType) { + this.valueType = valueType; + } + + /** + **/ + public DevicePolicyValue values(List values) { + + this.values = values; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("values") + @Valid + public List getValues() { + return values; + } + public void setValues(List values) { + this.values = values; + } + + public DevicePolicyValue addValuesItem(DevicePolicyValueObject valuesItem) { + if (this.values == null) { + this.values = new ArrayList<>(); + } + this.values.add(valuesItem); + return this; + } + + /** + **/ + public DevicePolicyValue links(List links) { + + this.links = links; + return this; + } + + @ApiModelProperty(value = "") + @JsonProperty("links") + @Valid + public List getLinks() { + return links; + } + public void setLinks(List links) { + this.links = links; + } + + public DevicePolicyValue addLinksItem(DevicePolicyLink linksItem) { + if (this.links == null) { + this.links = new ArrayList<>(); + } + this.links.add(linksItem); + return this; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DevicePolicyValue devicePolicyValue = (DevicePolicyValue) o; + return Objects.equals(this.inputType, devicePolicyValue.inputType) && + Objects.equals(this.valueType, devicePolicyValue.valueType) && + Objects.equals(this.values, devicePolicyValue.values) && + Objects.equals(this.links, devicePolicyValue.links); + } + + @Override + public int hashCode() { + return Objects.hash(inputType, valueType, values, links); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class DevicePolicyValue {\n"); + + sb.append(" inputType: ").append(toIndentedString(inputType)).append("\n"); + sb.append(" valueType: ").append(toIndentedString(valueType)).append("\n"); + sb.append(" values: ").append(toIndentedString(values)).append("\n"); + sb.append(" links: ").append(toIndentedString(links)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyValueObject.java b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyValueObject.java new file mode 100644 index 0000000000..1a1ee604cc --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/DevicePolicyValueObject.java @@ -0,0 +1,119 @@ +/* + * 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.api.server.device.policy.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class DevicePolicyValueObject { + + private String name; + private String displayName; + + /** + **/ + public DevicePolicyValueObject name(String name) { + + this.name = name; + return this; + } + + @ApiModelProperty(example = "android", value = "") + @JsonProperty("name") + @Valid + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + + /** + **/ + public DevicePolicyValueObject displayName(String displayName) { + + this.displayName = displayName; + return this; + } + + @ApiModelProperty(example = "Android", value = "") + @JsonProperty("displayName") + @Valid + public String getDisplayName() { + return displayName; + } + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DevicePolicyValueObject devicePolicyValueObject = (DevicePolicyValueObject) o; + return Objects.equals(this.name, devicePolicyValueObject.name) && + Objects.equals(this.displayName, devicePolicyValueObject.displayName); + } + + @Override + public int hashCode() { + return Objects.hash(name, displayName); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class DevicePolicyValueObject {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/Error.java b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/Error.java new file mode 100644 index 0000000000..70110db26b --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/gen/java/org/wso2/carbon/identity/api/server/device/policy/v1/model/Error.java @@ -0,0 +1,161 @@ +/* + * 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.api.server.device.policy.v1.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonCreator; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import javax.validation.constraints.*; + + +import io.swagger.annotations.*; +import java.util.Objects; +import javax.validation.Valid; +import javax.xml.bind.annotation.*; + +public class Error { + + private String code; + private String message; + private String description; + private String traceId; + + /** + **/ + public Error code(String code) { + + this.code = code; + return this; + } + + @ApiModelProperty(example = "DPM-65001", value = "") + @JsonProperty("code") + @Valid + public String getCode() { + return code; + } + public void setCode(String code) { + this.code = code; + } + + /** + **/ + public Error message(String message) { + + this.message = message; + return this; + } + + @ApiModelProperty(example = "Some Error Message.", value = "") + @JsonProperty("message") + @Valid + public String getMessage() { + return message; + } + public void setMessage(String message) { + this.message = message; + } + + /** + **/ + public Error description(String description) { + + this.description = description; + return this; + } + + @ApiModelProperty(example = "Some Error Description.", value = "") + @JsonProperty("description") + @Valid + public String getDescription() { + return description; + } + public void setDescription(String description) { + this.description = description; + } + + /** + **/ + public Error traceId(String traceId) { + + this.traceId = traceId; + return this; + } + + @ApiModelProperty(example = "e0fbcfeb-3617-43c4-8dd0-7b7d38e13047", value = "") + @JsonProperty("traceId") + @Valid + public String getTraceId() { + return traceId; + } + public void setTraceId(String traceId) { + this.traceId = traceId; + } + + + + @Override + public boolean equals(java.lang.Object o) { + + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Error error = (Error) o; + return Objects.equals(this.code, error.code) && + Objects.equals(this.message, error.message) && + Objects.equals(this.description, error.description) && + Objects.equals(this.traceId, error.traceId); + } + + @Override + public int hashCode() { + return Objects.hash(code, message, description, traceId); + } + + @Override + public String toString() { + + StringBuilder sb = new StringBuilder(); + sb.append("class Error {\n"); + + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" traceId: ").append(toIndentedString(traceId)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(java.lang.Object o) { + + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n"); + } +} + diff --git a/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/main/java/org/wso2/carbon/identity/api/server/device/policy/v1/core/DevicePolicyMetadataService.java b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/main/java/org/wso2/carbon/identity/api/server/device/policy/v1/core/DevicePolicyMetadataService.java new file mode 100644 index 0000000000..88161e5ee9 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/main/java/org/wso2/carbon/identity/api/server/device/policy/v1/core/DevicePolicyMetadataService.java @@ -0,0 +1,170 @@ +/* + * 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.api.server.device.policy.v1.core; + +import org.wso2.carbon.identity.api.server.common.ContextLoader; +import org.wso2.carbon.identity.api.server.device.policy.common.Constants; +import org.wso2.carbon.identity.api.server.device.policy.v1.model.DevicePolicyField; +import org.wso2.carbon.identity.api.server.device.policy.v1.model.DevicePolicyFieldDefinition; +import org.wso2.carbon.identity.api.server.device.policy.v1.model.DevicePolicyLink; +import org.wso2.carbon.identity.api.server.device.policy.v1.model.DevicePolicyOperator; +import org.wso2.carbon.identity.api.server.device.policy.v1.model.DevicePolicyValue; +import org.wso2.carbon.identity.api.server.device.policy.v1.model.DevicePolicyValueObject; +import org.wso2.carbon.identity.api.server.device.policy.v1.util.DevicePolicyAPIErrorBuilder; +import org.wso2.carbon.identity.device.policy.api.service.DeviceFieldMetadataService; +import org.wso2.carbon.identity.rule.metadata.api.exception.RuleMetadataException; +import org.wso2.carbon.identity.rule.metadata.api.model.FieldDefinition; +import org.wso2.carbon.identity.rule.metadata.api.model.FlowType; +import org.wso2.carbon.identity.rule.metadata.api.model.Link; +import org.wso2.carbon.identity.rule.metadata.api.model.Operator; +import org.wso2.carbon.identity.rule.metadata.api.model.OptionsInputValue; +import org.wso2.carbon.identity.rule.metadata.api.model.OptionsReferenceValue; +import org.wso2.carbon.identity.rule.metadata.api.model.OptionsValue; +import org.wso2.carbon.identity.rule.metadata.api.model.Value; +import org.wso2.carbon.identity.rule.metadata.api.service.RuleMetadataService; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import javax.ws.rs.core.Response; + +/** + * Core service for the Device Policy API — serves device policy field metadata, + * optionally filtered by platform. + */ +public class DevicePolicyMetadataService { + + private static final Set SUPPORTED_PLATFORMS = Collections.unmodifiableSet( + new HashSet<>(Arrays.asList("android", "ios", "macos", "windows"))); + + private final RuleMetadataService ruleMetadataService; + private final DeviceFieldMetadataService deviceFieldMetadataService; + + public DevicePolicyMetadataService(RuleMetadataService ruleMetadataService, + DeviceFieldMetadataService deviceFieldMetadataService) { + + this.ruleMetadataService = ruleMetadataService; + this.deviceFieldMetadataService = deviceFieldMetadataService; + } + + /** + * Returns device policy field metadata, optionally filtered to a specific platform. + * Retrieves field definitions from the rule metadata service and applies the platform + * filter based on the device field applicable-platforms mapping. + * + * @param platform Platform to filter by (android/ios/macos/windows); null returns all fields. + * @return List of device policy field definitions. + */ + public List getMetadata(String platform) { + + if (platform != null && !SUPPORTED_PLATFORMS.contains(platform)) { + throw DevicePolicyAPIErrorBuilder.handleException(Response.Status.BAD_REQUEST, + Constants.ErrorMessage.ERROR_CODE_INVALID_PLATFORM); + } + + try { + String tenantDomain = ContextLoader.getTenantDomainFromContext(); + List allFields = + ruleMetadataService.getExpressionMeta(FlowType.DEVICE_POLICY, tenantDomain); + + Map> applicablePlatforms = + deviceFieldMetadataService.getFieldApplicablePlatforms(); + + return allFields.stream() + .filter(fd -> isApplicable(fd.getField().getName(), platform, applicablePlatforms)) + .map(this::toApiModel) + .collect(Collectors.toList()); + } catch (RuleMetadataException e) { + throw DevicePolicyAPIErrorBuilder.handleException(Response.Status.INTERNAL_SERVER_ERROR, + Constants.ErrorMessage.ERROR_CODE_ERROR_RETRIEVING_METADATA, e); + } + } + + private boolean isApplicable(String fieldName, String platform, + Map> applicablePlatformsMap) { + + if (platform == null) { + return true; + } + List platforms = applicablePlatformsMap.get(fieldName); + return platforms == null || platforms.contains(platform); + } + + private DevicePolicyFieldDefinition toApiModel(FieldDefinition fd) { + + DevicePolicyField field = new DevicePolicyField(); + field.setName(fd.getField().getName()); + field.setDisplayName(fd.getField().getDisplayName()); + + List operators = new ArrayList<>(); + for (Operator op : fd.getOperators()) { + DevicePolicyOperator apiOp = new DevicePolicyOperator(); + apiOp.setName(op.getName()); + apiOp.setDisplayName(op.getDisplayName()); + operators.add(apiOp); + } + + DevicePolicyValue value = new DevicePolicyValue(); + Value coreValue = fd.getValue(); + value.setInputType(DevicePolicyValue.InputTypeEnum.fromValue( + coreValue.getInputType().name().toLowerCase())); + value.setValueType(DevicePolicyValue.ValueTypeEnum.fromValue( + mapValueType(coreValue.getValueType()))); + + if (coreValue instanceof OptionsInputValue) { + List values = new ArrayList<>(); + for (OptionsValue ov : ((OptionsInputValue) coreValue).getValues()) { + DevicePolicyValueObject vo = new DevicePolicyValueObject(); + vo.setName(ov.getName()); + vo.setDisplayName(ov.getDisplayName()); + values.add(vo); + } + value.setValues(values); + } else if (coreValue instanceof OptionsReferenceValue) { + List links = new ArrayList<>(); + for (Link l : ((OptionsReferenceValue) coreValue).getLinks()) { + DevicePolicyLink link = new DevicePolicyLink(); + link.setHref(l.getHref()); + link.setMethod(DevicePolicyLink.MethodEnum.fromValue(l.getMethod())); + link.setRel(DevicePolicyLink.RelEnum.fromValue(l.getRel())); + links.add(link); + } + value.setLinks(links); + } + + DevicePolicyFieldDefinition result = new DevicePolicyFieldDefinition(); + result.setField(field); + result.setOperators(operators); + result.setValue(value); + return result; + } + + private String mapValueType(Value.ValueType valueType) { + + if (valueType == Value.ValueType.DATE_TIME) { + return "date"; + } + return valueType.name().toLowerCase(); + } +} diff --git a/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/main/java/org/wso2/carbon/identity/api/server/device/policy/v1/factories/DevicePolicyMetadataServiceFactory.java b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/main/java/org/wso2/carbon/identity/api/server/device/policy/v1/factories/DevicePolicyMetadataServiceFactory.java new file mode 100644 index 0000000000..8ed2c6a1ab --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/main/java/org/wso2/carbon/identity/api/server/device/policy/v1/factories/DevicePolicyMetadataServiceFactory.java @@ -0,0 +1,54 @@ +/* + * 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.api.server.device.policy.v1.factories; + +import org.wso2.carbon.identity.api.server.device.policy.common.DevicePolicyMetadataServiceHolder; +import org.wso2.carbon.identity.api.server.device.policy.v1.core.DevicePolicyMetadataService; +import org.wso2.carbon.identity.device.policy.api.service.DeviceFieldMetadataService; +import org.wso2.carbon.identity.rule.metadata.api.service.RuleMetadataService; + +/** + * Factory class for DevicePolicyMetadataService. + * Gets the OSGi services from the ServiceHolder and injects them into DevicePolicyMetadataService. + * Created once at startup — singleton pattern using static initializer. + */ +public class DevicePolicyMetadataServiceFactory { + + private static final DevicePolicyMetadataService SERVICE; + + static { + RuleMetadataService ruleMetadataService = DevicePolicyMetadataServiceHolder.getRuleMetadataService(); + DeviceFieldMetadataService deviceFieldMetadataService = + DevicePolicyMetadataServiceHolder.getDeviceFieldMetadataService(); + + if (ruleMetadataService == null) { + throw new IllegalStateException("RuleMetadataService is not available from OSGi context."); + } + if (deviceFieldMetadataService == null) { + throw new IllegalStateException("DeviceFieldMetadataService is not available from OSGi context."); + } + + SERVICE = new DevicePolicyMetadataService(ruleMetadataService, deviceFieldMetadataService); + } + + public static DevicePolicyMetadataService getDevicePolicyMetadataService() { + + return SERVICE; + } +} diff --git a/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/main/java/org/wso2/carbon/identity/api/server/device/policy/v1/impl/DevicePoliciesApiServiceImpl.java b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/main/java/org/wso2/carbon/identity/api/server/device/policy/v1/impl/DevicePoliciesApiServiceImpl.java new file mode 100644 index 0000000000..7743ae8e5b --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/main/java/org/wso2/carbon/identity/api/server/device/policy/v1/impl/DevicePoliciesApiServiceImpl.java @@ -0,0 +1,44 @@ +/* + * 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.api.server.device.policy.v1.impl; + +import org.wso2.carbon.identity.api.server.device.policy.v1.DevicePoliciesApiService; +import org.wso2.carbon.identity.api.server.device.policy.v1.core.DevicePolicyMetadataService; +import org.wso2.carbon.identity.api.server.device.policy.v1.factories.DevicePolicyMetadataServiceFactory; + +import javax.ws.rs.core.Response; + +/** + * JAX-RS delegate implementation — bridges generated DevicePoliciesApiService to the core service. + */ +public class DevicePoliciesApiServiceImpl implements DevicePoliciesApiService { + + private final DevicePolicyMetadataService devicePolicyMetadataService; + + public DevicePoliciesApiServiceImpl() { + + this.devicePolicyMetadataService = DevicePolicyMetadataServiceFactory.getDevicePolicyMetadataService(); + } + + @Override + public Response getDevicePolicyMetadata(String platform) { + + return Response.ok().entity(devicePolicyMetadataService.getMetadata(platform)).build(); + } +} diff --git a/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/main/java/org/wso2/carbon/identity/api/server/device/policy/v1/util/DevicePolicyAPIErrorBuilder.java b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/main/java/org/wso2/carbon/identity/api/server/device/policy/v1/util/DevicePolicyAPIErrorBuilder.java new file mode 100644 index 0000000000..1a334d6f6a --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/main/java/org/wso2/carbon/identity/api/server/device/policy/v1/util/DevicePolicyAPIErrorBuilder.java @@ -0,0 +1,76 @@ +/* + * 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.api.server.device.policy.v1.util; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.identity.api.server.common.error.APIError; +import org.wso2.carbon.identity.api.server.common.error.ErrorResponse; +import org.wso2.carbon.identity.api.server.device.policy.common.Constants; + +import javax.ws.rs.core.Response; + +/** + * Builds {@link APIError} instances for the Device Policy API. + */ +public class DevicePolicyAPIErrorBuilder { + + private static final Log LOG = LogFactory.getLog(DevicePolicyAPIErrorBuilder.class); + + private DevicePolicyAPIErrorBuilder() { + + } + + /** + * Build an APIError for an error detected at the API layer, with no backend cause to log + * (e.g. request validation failures). + * + * @param status HTTP status to return. + * @param errorEnum API-layer error message. + * @return APIError to be thrown back to the JAX-RS layer. + */ + public static APIError handleException(Response.Status status, Constants.ErrorMessage errorEnum) { + + ErrorResponse errorResponse = new ErrorResponse.Builder() + .withCode(errorEnum.code()) + .withMessage(errorEnum.message()) + .withDescription(errorEnum.description()) + .build(); + return new APIError(status, errorResponse); + } + + /** + * Build an APIError that wraps a backend cause (e.g. a failure while retrieving rule metadata). + * The cause is logged. + * + * @param status HTTP status to return. + * @param errorEnum API-layer error message. + * @param cause The underlying exception to log. + * @return APIError to be thrown back to the JAX-RS layer. + */ + public static APIError handleException(Response.Status status, Constants.ErrorMessage errorEnum, Exception cause) { + + ErrorResponse errorResponse = new ErrorResponse.Builder() + .withCode(errorEnum.code()) + .withMessage(errorEnum.message()) + .withDescription(errorEnum.description()) + .build(LOG, cause, errorEnum.description()); + return new APIError(status, errorResponse); + } +} diff --git a/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/main/resources/device-policy.yaml b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/main/resources/device-policy.yaml new file mode 100644 index 0000000000..5696b29339 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/src/main/resources/device-policy.yaml @@ -0,0 +1,165 @@ +openapi: 3.0.0 +info: + version: v1 + title: 'WSO2 Identity Server - Device Policy API' + description: 'This document specifies a RESTful API for WSO2 Identity Server Device Policy Management' + contact: + name: WSO2 + url: 'http://wso2.com/products/identity-server/' + email: architecture@wso2.org + license: + name: Apache 2.0 + url: 'http://www.apache.org/licenses/LICENSE-2.0.html' +security: + - OAuth2: [] + - BasicAuth: [] +paths: + /device-policies/metadata: + get: + tags: + - Device Policy Management + summary: Get device policy field metadata filtered by platform. + operationId: getDevicePolicyMetadata + description: | + Returns the list of rule fields applicable for the devicePolicy flow, + optionally filtered to a specific platform. Used by the UI to populate + the rule builder with platform-relevant fields only. + parameters: + - name: platform + in: query + description: Filter fields to those applicable for this platform. If omitted all fields are returned. + required: false + schema: + type: string + enum: + - android + - ios + - macos + - windows + responses: + '200': + description: Applicable fields for the given platform. + content: + application/json: + schema: + type: array + items: + $ref: '#/components/schemas/DevicePolicyFieldDefinition' + '400': + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + '401': + description: Unauthorized + '403': + description: Forbidden + '500': + description: Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' +servers: + - url: 'https://localhost:9443/t/{tenant-domain}/api/server/v1' + variables: + tenant-domain: + default: carbon.super +components: + securitySchemes: + BasicAuth: + type: http + scheme: basic + OAuth2: + type: oauth2 + flows: + authorizationCode: + authorizationUrl: 'https://localhost:9443/oauth2/authorize' + tokenUrl: 'https://localhost:9443/oauth2/token' + scopes: + read: internal_device_policy_view + schemas: + DevicePolicyFieldDefinition: + type: object + properties: + field: + $ref: '#/components/schemas/DevicePolicyField' + operators: + type: array + items: + $ref: '#/components/schemas/DevicePolicyOperator' + value: + $ref: '#/components/schemas/DevicePolicyValue' + DevicePolicyField: + type: object + properties: + name: + type: string + example: platform + displayName: + type: string + example: platform + DevicePolicyOperator: + type: object + properties: + name: + type: string + example: equals + displayName: + type: string + example: equals + DevicePolicyValue: + type: object + properties: + inputType: + type: string + enum: [input, options] + example: options + valueType: + type: string + enum: [string, number, boolean, date, reference, symbolic] + example: string + values: + type: array + items: + $ref: '#/components/schemas/DevicePolicyValueObject' + links: + type: array + items: + $ref: '#/components/schemas/DevicePolicyLink' + DevicePolicyValueObject: + type: object + properties: + name: + type: string + example: android + displayName: + type: string + example: Android + DevicePolicyLink: + type: object + properties: + href: + type: string + method: + type: string + enum: [GET] + rel: + type: string + enum: [values, filter] + Error: + type: object + properties: + code: + type: string + example: DPM-65001 + message: + type: string + example: Some Error Message. + description: + type: string + example: Some Error Description. + traceId: + type: string + example: "e0fbcfeb-3617-43c4-8dd0-7b7d38e13047" diff --git a/components/org.wso2.carbon.identity.api.server.device.policy/pom.xml b/components/org.wso2.carbon.identity.api.server.device.policy/pom.xml new file mode 100644 index 0000000000..3ad2f3cd4c --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.device.policy/pom.xml @@ -0,0 +1,33 @@ + + + + + identity-api-server + org.wso2.carbon.identity.server.api + 1.6.36-SNAPSHOT + ../../pom.xml + + 4.0.0 + org.wso2.carbon.identity.api.server.device.policy + pom + + org.wso2.carbon.identity.api.server.device.policy.common + org.wso2.carbon.identity.api.server.device.policy.v1 + + diff --git a/pom.xml b/pom.xml index 8a42a22e02..2e765d58ef 100644 --- a/pom.xml +++ b/pom.xml @@ -477,6 +477,12 @@ ${project.version} provided + + org.wso2.carbon.identity.server.api + org.wso2.carbon.identity.api.server.device.policy.common + ${project.version} + provided + org.apache.cxf cxf-rt-rs-extension-search @@ -1216,6 +1222,7 @@ components/org.wso2.carbon.identity.api.server.vc.template.management components/org.wso2.carbon.identity.api.server.credential.management components/org.wso2.carbon.identity.api.server.moesif.publisher + components/org.wso2.carbon.identity.api.server.device.policy From 1dfb7dba8909dbcfa19946191acda995d364bda0 Mon Sep 17 00:00:00 2001 From: kaviska Date: Thu, 30 Jul 2026 03:40:33 +0530 Subject: [PATCH 2/2] Prevent generator from overwriting hand-written API service impl --- .../.openapi-generator-ignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/.openapi-generator-ignore diff --git a/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/.openapi-generator-ignore b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/.openapi-generator-ignore new file mode 100644 index 0000000000..aac396a693 --- /dev/null +++ b/components/org.wso2.carbon.identity.api.server.device.policy/org.wso2.carbon.identity.api.server.device.policy.v1/.openapi-generator-ignore @@ -0,0 +1,4 @@ +# OpenAPI Generator Ignore +# Prevents the generator from overwriting hand-written impl classes. + +**/impl/*