diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml
new file mode 100644
index 00000000000..239156f4d99
--- /dev/null
+++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/pom.xml
@@ -0,0 +1,195 @@
+
+
+
+
+
+ io.entgra.device.mgt.core
+ cea-mgt
+ 5.0.40-SNAPSHOT
+ ../pom.xml
+
+
+ 4.0.0
+ io.entgra.device.mgt.core.cea.mgt.admin.api
+ war
+ Entgra IoT - CEA Management Admin API
+ Entgra IoT - Conditional Email Access Management Admin API
+
+
+
+
+ maven-compiler-plugin
+
+ 1.8
+ 1.8
+
+
+
+ maven-war-plugin
+
+ WEB-INF/lib/*cxf*.jar
+ api#cea-mgt#v1.0
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+
+ ${basedir}/target/coverage-reports/jacoco-unit.exec
+
+
+
+ jacoco-initialize
+
+ prepare-agent
+
+
+
+ jacoco-site
+ test
+
+ report
+
+
+ ${basedir}/target/coverage-reports/jacoco-unit.exec
+ ${basedir}/target/coverage-reports/site
+
+
+
+
+
+
+
+
+
+ deploy
+
+ compile
+
+
+ org.apache.maven.plugins
+ maven-antrun-plugin
+ 1.7
+
+
+ compile
+
+ run
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.springframework
+ spring-web
+ provided
+
+
+ org.apache.cxf
+ cxf-bundle-jaxrs
+ provided
+
+
+ commons-codec.wso2
+ commons-codec
+
+
+ commons-codec
+ commons-codec
+
+
+
+
+ junit
+ junit
+ test
+
+
+ io.swagger
+ swagger-annotations
+
+
+ io.swagger
+ swagger-core
+
+
+ org.wso2.orbit.com.fasterxml.jackson.core
+ jackson-annotations
+
+
+ org.slf4j
+ slf4j-api
+
+
+
+
+ org.wso2.carbon
+ org.wso2.carbon.logging
+ provided
+
+
+ io.swagger
+ swagger-jaxrs
+
+
+ com.fasterxml.jackson.module
+ jackson-module-jaxb-annotations
+
+
+ org.slf4j
+ slf4j-api
+
+
+
+
+ io.entgra.device.mgt.core
+ io.entgra.device.mgt.core.apimgt.annotations
+ provided
+
+
+ io.entgra.device.mgt.core
+ io.entgra.device.mgt.core.cea.mgt.common
+ provided
+
+
+ org.wso2.carbon
+ org.wso2.carbon.utils
+ provided
+
+
+
+
\ No newline at end of file
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/AccessPolicyWrapper.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/bean/AccessPolicyWrapper.java
similarity index 73%
rename from components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/AccessPolicyWrapper.java
rename to components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/bean/AccessPolicyWrapper.java
index a2d3405e276..cf5c9e71675 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/AccessPolicyWrapper.java
+++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/bean/AccessPolicyWrapper.java
@@ -1,4 +1,23 @@
-package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans;
+/*
+ * Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
+ *
+ * Entgra (Pvt) Ltd. 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 io.entgra.device.mgt.core.cea.mgt.admin.api.bean;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/CEAPolicyWrapper.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/bean/CEAPolicyWrapper.java
similarity index 92%
rename from components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/CEAPolicyWrapper.java
rename to components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/bean/CEAPolicyWrapper.java
index 56e872a189d..a92198f0536 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/CEAPolicyWrapper.java
+++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/bean/CEAPolicyWrapper.java
@@ -1,12 +1,12 @@
/*
- * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
+ * Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. 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
+ * 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
@@ -14,9 +14,10 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
+ *
*/
-package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans;
+package io.entgra.device.mgt.core.cea.mgt.admin.api.bean;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.entgra.device.mgt.core.cea.mgt.common.bean.ActiveSyncServer;
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/GracePeriodWrapper.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/bean/GracePeriodWrapper.java
similarity index 57%
rename from components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/GracePeriodWrapper.java
rename to components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/bean/GracePeriodWrapper.java
index a52a9f099db..2a74e89fe4d 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/beans/GracePeriodWrapper.java
+++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/bean/GracePeriodWrapper.java
@@ -1,11 +1,28 @@
-package io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans;
+/*
+ * Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
+ *
+ * Entgra (Pvt) Ltd. 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 io.entgra.device.mgt.core.cea.mgt.admin.api.bean;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
-import java.util.Set;
-
@ApiModel(value = "GracePeriodWrapper", description = "GracePeriod transferring DTO")
public class GracePeriodWrapper {
diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/common/GsonMessageBodyHandler.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/common/GsonMessageBodyHandler.java
new file mode 100644
index 00000000000..06abe1496f5
--- /dev/null
+++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/common/GsonMessageBodyHandler.java
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
+ *
+ * Entgra (Pvt) Ltd. 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 io.entgra.device.mgt.core.cea.mgt.admin.api.common;
+
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyReader;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
+
+@Provider
+@Produces(APPLICATION_JSON)
+@Consumes(APPLICATION_JSON)
+public class GsonMessageBodyHandler implements MessageBodyWriter, MessageBodyReader {
+
+ private Gson gson;
+ private static final String UTF_8 = "UTF-8";
+
+ public boolean isReadable(Class> aClass, Type type, Annotation[] annotations, MediaType mediaType) {
+ return true;
+ }
+
+ private Gson getGson() {
+ if (gson == null) {
+ final GsonBuilder gsonBuilder = new GsonBuilder();
+ gson = gsonBuilder.create();
+ }
+ return gson;
+ }
+
+ public Object readFrom(Class objectClass, Type type, Annotation[] annotations, MediaType mediaType,
+ MultivaluedMap stringStringMultivaluedMap, InputStream entityStream)
+ throws IOException, WebApplicationException {
+
+ InputStreamReader reader = new InputStreamReader(entityStream, "UTF-8");
+
+ try {
+ return getGson().fromJson(reader, type);
+ } finally {
+ reader.close();
+ }
+ }
+
+ public boolean isWriteable(Class> aClass, Type type, Annotation[] annotations, MediaType mediaType) {
+ return true;
+ }
+
+ public long getSize(Object o, Class> aClass, Type type, Annotation[] annotations, MediaType mediaType) {
+ return -1;
+ }
+
+ public void writeTo(Object object, Class> aClass, Type type, Annotation[] annotations, MediaType mediaType,
+ MultivaluedMap stringObjectMultivaluedMap, OutputStream entityStream)
+ throws IOException, WebApplicationException {
+
+ OutputStreamWriter writer = new OutputStreamWriter(entityStream, UTF_8);
+ try {
+ getGson().toJson(object, type, writer);
+ } finally {
+ writer.close();
+ }
+ }
+}
diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/exception/BadRequestException.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/exception/BadRequestException.java
new file mode 100644
index 00000000000..ec5505ab716
--- /dev/null
+++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/exception/BadRequestException.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
+ *
+ * Entgra (Pvt) Ltd. 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 io.entgra.device.mgt.core.cea.mgt.admin.api.exception;
+
+import javax.ws.rs.WebApplicationException;
+
+public class BadRequestException extends WebApplicationException {
+ private String message;
+ private static final long serialVersionUID = -24991345567891192L;
+
+ public BadRequestException(String message) {
+ this.message = message;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public void setMessage(String message) {
+ this.message = message;
+ }
+}
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/CEAManagementAdminServiceImpl.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/impl/CEAManagementAdminServiceImpl.java
similarity index 85%
rename from components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/CEAManagementAdminServiceImpl.java
rename to components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/impl/CEAManagementAdminServiceImpl.java
index 8389ce8f9ce..dab95bed5a7 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/admin/CEAManagementAdminServiceImpl.java
+++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/impl/CEAManagementAdminServiceImpl.java
@@ -17,11 +17,16 @@
*
*/
-package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.admin;
+package io.entgra.device.mgt.core.cea.mgt.admin.api.impl;
+import io.entgra.device.mgt.core.cea.mgt.admin.api.bean.AccessPolicyWrapper;
+import io.entgra.device.mgt.core.cea.mgt.admin.api.bean.CEAPolicyWrapper;
+import io.entgra.device.mgt.core.cea.mgt.admin.api.bean.GracePeriodWrapper;
+import io.entgra.device.mgt.core.cea.mgt.admin.api.service.CEAManagementAdminService;
+import io.entgra.device.mgt.core.cea.mgt.admin.api.util.CEAManagementApiUtil;
+import io.entgra.device.mgt.core.cea.mgt.admin.api.util.RequestValidationUtil;
import io.entgra.device.mgt.core.cea.mgt.common.bean.AccessPolicy;
import io.entgra.device.mgt.core.cea.mgt.common.bean.ActiveSyncServer;
-import io.entgra.device.mgt.core.cea.mgt.common.bean.ActiveSyncServerUIConfiguration;
import io.entgra.device.mgt.core.cea.mgt.common.bean.CEAPolicy;
import io.entgra.device.mgt.core.cea.mgt.common.bean.GracePeriod;
import io.entgra.device.mgt.core.cea.mgt.common.bean.enums.DefaultAccessPolicy;
@@ -29,21 +34,14 @@ import io.entgra.device.mgt.core.cea.mgt.common.bean.enums.EmailOutlookAccessPol
import io.entgra.device.mgt.core.cea.mgt.common.bean.enums.GraceAllowedPolicy;
import io.entgra.device.mgt.core.cea.mgt.common.bean.enums.POPIMAPAccessPolicy;
import io.entgra.device.mgt.core.cea.mgt.common.bean.enums.WebOutlookAccessPolicy;
-import io.entgra.device.mgt.core.cea.mgt.common.bean.ui.CEAPolicyUIConfiguration;
-import io.entgra.device.mgt.core.cea.mgt.common.bean.ui.ServerUIConfiguration;
import io.entgra.device.mgt.core.cea.mgt.common.exception.CEAManagementException;
import io.entgra.device.mgt.core.cea.mgt.common.exception.CEAPolicyAlreadyExistsException;
import io.entgra.device.mgt.core.cea.mgt.common.exception.CEAPolicyNotFoundException;
import io.entgra.device.mgt.core.cea.mgt.common.service.CEAManagementService;
-import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.AccessPolicyWrapper;
-import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.CEAPolicyWrapper;
-import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.GracePeriodWrapper;
-import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin.CEAManagementAdminService;
-import io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util.RequestValidationUtil;
-import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.DeviceMgtAPIUtils;
+import io.entgra.device.mgt.core.cea.mgt.common.bean.ui.CEAPolicyUIConfiguration;
+import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.http.HttpStatus;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
@@ -52,9 +50,7 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import java.util.ArrayList;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
@Path("/admin/cea-policies")
@@ -67,7 +63,7 @@ public class CEAManagementAdminServiceImpl implements CEAManagementAdminService
@Path("/ui")
@Override
public Response getCEAPolicyUI() {
- CEAManagementService ceaManagementService = DeviceMgtAPIUtils.getCEAManagementService();
+ CEAManagementService ceaManagementService = CEAManagementApiUtil.getCEAManagementService();
try {
CEAPolicyUIConfiguration ceaPolicyUIConfiguration = ceaManagementService.getCEAPolicyUIConfiguration();
if (ceaPolicyUIConfiguration == null) {
@@ -86,7 +82,7 @@ public class CEAManagementAdminServiceImpl implements CEAManagementAdminService
public Response createCEAPolicy(CEAPolicyWrapper ceaPolicyWrapper) {
try {
RequestValidationUtil.validateCEAPolicy(ceaPolicyWrapper);
- CEAManagementService ceaManagementService = DeviceMgtAPIUtils.getCEAManagementService();
+ CEAManagementService ceaManagementService = CEAManagementApiUtil.getCEAManagementService();
CEAPolicy ceaPolicy = constructCEAPolicy(ceaPolicyWrapper);
ceaPolicy = ceaManagementService.createCEAPolicy(ceaPolicy);
return Response.status(HttpStatus.SC_CREATED).entity(ceaPolicy).build();
@@ -104,7 +100,7 @@ public class CEAManagementAdminServiceImpl implements CEAManagementAdminService
@Override
public Response retrieveCEAPolicy() {
try {
- CEAManagementService ceaManagementService = DeviceMgtAPIUtils.getCEAManagementService();
+ CEAManagementService ceaManagementService = CEAManagementApiUtil.getCEAManagementService();
CEAPolicy ceaPolicy = ceaManagementService.retrieveCEAPolicy();
if (ceaPolicy == null) {
return Response.status(HttpStatus.SC_NOT_FOUND).entity("CEA policy isn't exists in the tenant").build();
@@ -120,7 +116,7 @@ public class CEAManagementAdminServiceImpl implements CEAManagementAdminService
@Override
public Response deleteCEAPolicy() {
try {
- CEAManagementService ceaManagementService = DeviceMgtAPIUtils.getCEAManagementService();
+ CEAManagementService ceaManagementService = CEAManagementApiUtil.getCEAManagementService();
ceaManagementService.deleteCEAPolicy();
return Response.status(HttpStatus.SC_OK).build();
} catch (CEAPolicyNotFoundException e) {
@@ -138,7 +134,7 @@ public class CEAManagementAdminServiceImpl implements CEAManagementAdminService
public Response updateCEAPolicy(CEAPolicyWrapper ceaPolicyWrapper) {
try {
RequestValidationUtil.validateCEAPolicy(ceaPolicyWrapper);
- CEAManagementService ceaManagementService = DeviceMgtAPIUtils.getCEAManagementService();
+ CEAManagementService ceaManagementService = CEAManagementApiUtil.getCEAManagementService();
CEAPolicy ceaPolicy = constructCEAPolicy(ceaPolicyWrapper);
ceaPolicy = ceaManagementService.updateCEAPolicy(ceaPolicy);
return Response.status(HttpStatus.SC_CREATED).entity(ceaPolicy).build();
@@ -157,7 +153,7 @@ public class CEAManagementAdminServiceImpl implements CEAManagementAdminService
@Path("/sync-now")
@Override
public Response sync() {
- CEAManagementService ceaManagementService = DeviceMgtAPIUtils.getCEAManagementService();
+ CEAManagementService ceaManagementService = CEAManagementApiUtil.getCEAManagementService();
try {
ceaManagementService.syncNow();
return Response.status(HttpStatus.SC_OK).build();
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/CEAManagementAdminService.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/service/CEAManagementAdminService.java
similarity index 78%
rename from components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/CEAManagementAdminService.java
rename to components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/service/CEAManagementAdminService.java
index 7ecfb2ae353..2a2bd0daea4 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/api/admin/CEAManagementAdminService.java
+++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/service/CEAManagementAdminService.java
@@ -1,12 +1,12 @@
/*
- * Copyright (c) 2018 - 2023, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
+ * Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
*
* Entgra (Pvt) Ltd. 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
+ * 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
@@ -14,18 +14,33 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
+ *
*/
-package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.api.admin;
+package io.entgra.device.mgt.core.cea.mgt.admin.api.service;
import io.entgra.device.mgt.core.apimgt.annotations.Scope;
import io.entgra.device.mgt.core.apimgt.annotations.Scopes;
-import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.CEAPolicyWrapper;
-import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.ErrorResponse;
-import io.entgra.device.mgt.core.device.mgt.api.jaxrs.util.Constants;
-import io.swagger.annotations.*;
+import io.entgra.device.mgt.core.cea.mgt.admin.api.bean.CEAPolicyWrapper;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import io.swagger.annotations.Extension;
+import io.swagger.annotations.ExtensionProperty;
+import io.swagger.annotations.Info;
+import io.swagger.annotations.SwaggerDefinition;
+import io.swagger.annotations.Tag;
-import javax.ws.rs.*;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.HttpMethod;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@@ -38,7 +53,7 @@ import javax.ws.rs.core.Response;
title = "CEAManagementAdminService API",
extensions = @Extension(properties = {
@ExtensionProperty(name = "name", value = "CEAManagementAdminService"),
- @ExtensionProperty(name = "context", value = "/api/device-mgt/v1.0/admin/cea-policies"),
+ @ExtensionProperty(name = "context", value = "/api/cea-mgt/v1.0/admin/cea-policies"),
})
),
consumes = {MediaType.APPLICATION_JSON},
@@ -91,6 +106,8 @@ import javax.ws.rs.core.Response;
}
)
public interface CEAManagementAdminService {
+ String SCOPE = "scope";
+
@GET
@Path("/ui")
@ApiOperation(
@@ -101,7 +118,7 @@ public interface CEAManagementAdminService {
tags = {"conditional_email_access", "device_management"},
extensions = {
@Extension(properties = {
- @ExtensionProperty(name = Constants.SCOPE, value = "dm:admin:cea:view")
+ @ExtensionProperty(name = SCOPE, value = "dm:admin:cea:view")
})
}
)
@@ -113,18 +130,20 @@ public interface CEAManagementAdminService {
@ApiResponse(
code = 304,
message = "Not Modified. \n Empty body because the client has already the latest version of " +
- "the requested resource."),
+ "the requested resource.",
+ response = Response.class),
@ApiResponse(
code = 404,
message = "Configurations not found",
- response = ErrorResponse.class),
+ response = Response.class),
@ApiResponse(
code = 406,
- message = "Not Acceptable.\n The requested media type is not supported."),
+ message = "Not Acceptable.\n The requested media type is not supported.",
+ response = Response.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while fetching the group count.",
- response = ErrorResponse.class)
+ response = Response.class)
}
)
Response getCEAPolicyUI();
@@ -139,7 +158,7 @@ public interface CEAManagementAdminService {
tags = {"conditional_email_access", "device_management"},
extensions = {
@Extension(properties = {
- @ExtensionProperty(name = Constants.SCOPE, value = "dm:admin:cea:add")
+ @ExtensionProperty(name = SCOPE, value = "dm:admin:cea:add")
})
}
)
@@ -152,21 +171,23 @@ public interface CEAManagementAdminService {
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
- response = ErrorResponse.class),
+ response = Response.class),
@ApiResponse(
code = 404,
- message = "Not Found. \n The specified resource does not exist."),
+ message = "Not Found. \n The specified resource does not exist.",
+ response = Response.class),
@ApiResponse(
code = 409,
message = "Conflict. \n CEA policy already exists.",
response = Response.class),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ message = "Unsupported media type. \n The entity of the request was in a not supported format.",
+ response = Response.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while creating the resource.",
- response = ErrorResponse.class)
+ response = Response.class)
}
)
Response createCEAPolicy(
@@ -186,7 +207,7 @@ public interface CEAManagementAdminService {
tags = {"conditional_email_access", "device_management"},
extensions = {
@Extension(properties = {
- @ExtensionProperty(name = Constants.SCOPE, value = "dm:admin:cea:view")
+ @ExtensionProperty(name = SCOPE, value = "dm:admin:cea:view")
})
}
)
@@ -199,21 +220,23 @@ public interface CEAManagementAdminService {
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
- response = ErrorResponse.class),
+ response = Response.class),
@ApiResponse(
code = 404,
- message = "Not Found. \n The specified resource does not exist."),
+ message = "Not Found. \n The specified resource does not exist.",
+ response = Response.class),
@ApiResponse(
code = 409,
message = "Conflict. \n CEA policy already exists.",
response = Response.class),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ message = "Unsupported media type. \n The entity of the request was in a not supported format.",
+ response = Response.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while creating the resource.",
- response = ErrorResponse.class)
+ response = Response.class)
}
)
Response retrieveCEAPolicy();
@@ -227,7 +250,7 @@ public interface CEAManagementAdminService {
tags = {"conditional_email_access", "device_management"},
extensions = {
@Extension(properties = {
- @ExtensionProperty(name = Constants.SCOPE, value = "dm:admin:cea:delete")
+ @ExtensionProperty(name = SCOPE, value = "dm:admin:cea:delete")
})
}
)
@@ -240,17 +263,19 @@ public interface CEAManagementAdminService {
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
- response = ErrorResponse.class),
+ response = Response.class),
@ApiResponse(
code = 404,
- message = "Not Found. \n The specified resource does not exist."),
+ message = "Not Found. \n The specified resource does not exist.",
+ response = Response.class),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ message = "Unsupported media type. \n The entity of the request was in a not supported format.",
+ response = Response.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while creating the resource.",
- response = ErrorResponse.class)
+ response = Response.class)
}
)
Response deleteCEAPolicy();
@@ -264,7 +289,7 @@ public interface CEAManagementAdminService {
tags = {"conditional_email_access", "device_management"},
extensions = {
@Extension(properties = {
- @ExtensionProperty(name = Constants.SCOPE, value = "dm:admin:cea:update")
+ @ExtensionProperty(name = SCOPE, value = "dm:admin:cea:update")
})
}
)
@@ -277,17 +302,19 @@ public interface CEAManagementAdminService {
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
- response = ErrorResponse.class),
+ response = Response.class),
@ApiResponse(
code = 404,
- message = "Not Found. \n The specified resource does not exist."),
+ message = "Not Found. \n The specified resource does not exist.",
+ response = Response.class),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ message = "Unsupported media type. \n The entity of the request was in a not supported format.",
+ response = Response.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while creating the resource.",
- response = ErrorResponse.class)
+ response = Response.class)
}
)
Response updateCEAPolicy(@ApiParam(
@@ -306,7 +333,7 @@ public interface CEAManagementAdminService {
tags = {"conditional_email_access", "device_management"},
extensions = {
@Extension(properties = {
- @ExtensionProperty(name = Constants.SCOPE, value = "dm:admin:cea:sync")
+ @ExtensionProperty(name = SCOPE, value = "dm:admin:cea:sync")
})
}
)
@@ -319,17 +346,19 @@ public interface CEAManagementAdminService {
@ApiResponse(
code = 400,
message = "Bad Request. \n Invalid request or validation error.",
- response = ErrorResponse.class),
+ response = Response.class),
@ApiResponse(
code = 404,
- message = "Not Found. \n The specified resource does not exist."),
+ message = "Not Found. \n The specified resource does not exist.",
+ response = Response.class),
@ApiResponse(
code = 415,
- message = "Unsupported media type. \n The entity of the request was in a not supported format."),
+ message = "Unsupported media type. \n The entity of the request was in a not supported format.",
+ response = Response.class),
@ApiResponse(
code = 500,
message = "Internal Server Error. \n Server error occurred while creating the resource.",
- response = ErrorResponse.class)
+ response = Response.class)
}
)
Response sync();
diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/util/CEAManagementApiUtil.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/util/CEAManagementApiUtil.java
new file mode 100644
index 00000000000..e135f062376
--- /dev/null
+++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/util/CEAManagementApiUtil.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
+ *
+ * Entgra (Pvt) Ltd. 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 io.entgra.device.mgt.core.cea.mgt.admin.api.util;
+
+import io.entgra.device.mgt.core.cea.mgt.common.service.CEAManagementService;
+import org.wso2.carbon.context.PrivilegedCarbonContext;
+
+public class CEAManagementApiUtil {
+ private static volatile CEAManagementService ceaManagementService;
+
+ public static CEAManagementService getCEAManagementService() {
+ if (ceaManagementService == null) {
+ synchronized (CEAManagementApiUtil.class) {
+ if (ceaManagementService == null) {
+ PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
+ ceaManagementService = (CEAManagementService)
+ ctx.getOSGiService(CEAManagementService.class, null);
+ if (ceaManagementService == null) {
+ throw new IllegalStateException("Conditional Email Access Management Service is not initialize");
+ }
+ }
+ }
+ }
+ return ceaManagementService;
+ }
+}
diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/util/RequestValidationUtil.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/util/RequestValidationUtil.java
new file mode 100644
index 00000000000..9d4ca453d6d
--- /dev/null
+++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/java/io/entgra/device/mgt/core/cea/mgt/admin/api/util/RequestValidationUtil.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2018 - 2024, Entgra (Pvt) Ltd. (http://www.entgra.io) All Rights Reserved.
+ *
+ * Entgra (Pvt) Ltd. 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 io.entgra.device.mgt.core.cea.mgt.admin.api.util;
+
+import io.entgra.device.mgt.core.cea.mgt.admin.api.bean.AccessPolicyWrapper;
+import io.entgra.device.mgt.core.cea.mgt.admin.api.bean.CEAPolicyWrapper;
+import io.entgra.device.mgt.core.cea.mgt.admin.api.bean.GracePeriodWrapper;
+import io.entgra.device.mgt.core.cea.mgt.admin.api.exception.BadRequestException;
+import io.entgra.device.mgt.core.cea.mgt.common.bean.ActiveSyncServer;
+import io.entgra.device.mgt.core.cea.mgt.common.bean.enums.DefaultAccessPolicy;
+import io.entgra.device.mgt.core.cea.mgt.common.bean.enums.EmailOutlookAccessPolicy;
+import io.entgra.device.mgt.core.cea.mgt.common.bean.enums.GraceAllowedPolicy;
+import io.entgra.device.mgt.core.cea.mgt.common.bean.enums.POPIMAPAccessPolicy;
+import io.entgra.device.mgt.core.cea.mgt.common.bean.enums.WebOutlookAccessPolicy;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class RequestValidationUtil {
+ private static final Log log = LogFactory.getLog(RequestValidationUtil.class);
+
+ /**
+ * Validate conditional access policy
+ * @param ceaPolicyWrapper {@link CEAPolicyWrapper}
+ */
+ public static void validateCEAPolicy(CEAPolicyWrapper ceaPolicyWrapper) {
+ if (ceaPolicyWrapper == null) {
+ String msg = "CEA policy should not be null";
+ log.error(msg);
+ throw new BadRequestException(msg);
+ }
+ validateActiveSyncServer(ceaPolicyWrapper.getActiveSyncServerEntries());
+ validateCEAAccessPolicy(ceaPolicyWrapper.getConditionalAccessPolicyEntries());
+ validateCEAGracePeriod(ceaPolicyWrapper.getGracePeriodEntries());
+ }
+
+ /**
+ * Validate active sync server configurations
+ * @param activeSyncServer {@link ActiveSyncServer}
+ */
+ public static void validateActiveSyncServer(ActiveSyncServer activeSyncServer) {
+ if (activeSyncServer == null) {
+ String msg = "Active sync server should not be null";
+ log.error(msg);
+ throw new BadRequestException(msg);
+ }
+ if (activeSyncServer.getGatewayUrl() == null) {
+ String msg = "Active sync server url should not be null";
+ log.error(msg);
+ throw new BadRequestException(msg);
+ }
+ if (activeSyncServer.getKey() == null) {
+ String msg = "Active sync server type should not be null";
+ log.error(msg);
+ throw new BadRequestException(msg);
+ }
+ if (activeSyncServer.getClient() == null) {
+ String msg = "Active sync server username should not be null";
+ log.error(msg);
+ throw new BadRequestException(msg);
+ }
+ if (activeSyncServer.getSecret() == null) {
+ String msg = "Active sync server secret should not be null";
+ log.error(msg);
+ throw new BadRequestException(msg);
+ }
+ }
+
+ /**
+ * Validate conditional access policy configurations
+ * @param accessPolicyWrapper {@link AccessPolicyWrapper}
+ */
+ public static void validateCEAAccessPolicy(AccessPolicyWrapper accessPolicyWrapper) {
+ if (accessPolicyWrapper == null) {
+ String msg = "Access policy should not be null";
+ log.error(msg);
+ throw new BadRequestException(msg);
+ }
+ try {
+ Enum.valueOf(DefaultAccessPolicy.class, accessPolicyWrapper.getDefaultAccessPolicy());
+ Enum.valueOf(WebOutlookAccessPolicy.class, accessPolicyWrapper.getWebOutlookAccessPolicy());
+ Enum.valueOf(POPIMAPAccessPolicy.class, accessPolicyWrapper.getPOPIMAPAccessPolicy());
+ for(String value : accessPolicyWrapper.getEmailOutlookAccessPolicy()) {
+ Enum.valueOf(EmailOutlookAccessPolicy.class, value);
+ }
+ } catch (IllegalArgumentException | NullPointerException e) {
+ String msg = "Access policy contains illegal arguments";
+ log.error(msg);
+ throw new BadRequestException(msg);
+ }
+ }
+
+ /**
+ * Validate grace period configurations
+ * @param gracePeriodWrapper {@link GracePeriodWrapper}
+ */
+ public static void validateCEAGracePeriod(GracePeriodWrapper gracePeriodWrapper) {
+ if (gracePeriodWrapper == null) {
+ String msg = "Grace period should not be null";
+ log.error(msg);
+ throw new BadRequestException(msg);
+ }
+ if (gracePeriodWrapper.getGracePeriod() < 0 || gracePeriodWrapper.getGracePeriod() >
+ io.entgra.device.mgt.core.cea.mgt.common.util.Constants.MAX_GRACE_PERIOD_IN_DAYS) {
+ String msg = "Grace period should in range of 0-30 days";
+ log.error(msg);
+ throw new BadRequestException(msg);
+ }
+ try {
+ Enum.valueOf(GraceAllowedPolicy.class, gracePeriodWrapper.getGraceAllowedPolicy());
+ } catch (IllegalArgumentException | NullPointerException e) {
+ String msg = "Grace allowed policy contains illegal arguments";
+ log.error(msg);
+ throw new BadRequestException(msg);
+ }
+ }
+}
diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/webapp/META-INF/webapp-classloading.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/webapp/META-INF/webapp-classloading.xml
new file mode 100644
index 00000000000..6ba6a22ad47
--- /dev/null
+++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/webapp/META-INF/webapp-classloading.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+ false
+
+
+ CXF3,Carbon
+
diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/webapp/WEB-INF/cxf-servlet.xml
new file mode 100644
index 00000000000..c77d3abeb14
--- /dev/null
+++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/webapp/WEB-INF/cxf-servlet.xml
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/webapp/WEB-INF/web.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 00000000000..27e5caa8960
--- /dev/null
+++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.admin.api/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,106 @@
+
+
+
+ CEA-Management-Webapp
+
+ JAX-WS/JAX-RS Conditional Email Access Management Endpoint
+ JAX-WS/JAX-RS Servlet
+ CXFServlet
+
+ org.apache.cxf.transport.servlet.CXFServlet
+
+
+
+ CXFServlet
+ /*
+
+
+ 60
+
+
+ doAuthentication
+ true
+
+
+ basicAuth
+ true
+
+
+
+
+ managed-api-enabled
+ true
+
+
+ managed-api-owner
+ admin
+
+
+ isSharedWithAllTenants
+ true
+
+
+
+
+ CEAMgt-Admin
+ /*
+
+
+ CONFIDENTIAL
+
+
+
+
+ HttpHeaderSecurityFilter
+ org.apache.catalina.filters.HttpHeaderSecurityFilter
+
+ hstsEnabled
+ false
+
+
+
+
+ ContentTypeBasedCachePreventionFilter
+ org.wso2.carbon.ui.filters.cache.ContentTypeBasedCachePreventionFilter
+
+ patterns
+ text/html" ,application/json" ,text/plain
+
+
+ filterAction
+ enforce
+
+
+ httpHeaders
+ Cache-Control: no-store, no-cache, must-revalidate, private
+
+
+
+
+ HttpHeaderSecurityFilter
+ /*
+
+
+
+ ContentTypeBasedCachePreventionFilter
+ /*
+
+
+
diff --git a/components/cea-mgt/pom.xml b/components/cea-mgt/pom.xml
index f0d3105f475..7b7bfab5ab3 100644
--- a/components/cea-mgt/pom.xml
+++ b/components/cea-mgt/pom.xml
@@ -1,13 +1,13 @@
@@ -35,5 +36,6 @@
io.entgra.device.mgt.core.cea.mgt.core
io.entgra.device.mgt.core.cea.mgt.common
io.entgra.device.mgt.core.cea.mgt.enforce
+ io.entgra.device.mgt.core.cea.mgt.admin.api
\ No newline at end of file
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml
index 9b7b786e580..ddc2ac42d14 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/pom.xml
@@ -460,10 +460,5 @@
io.entgra.device.mgt.core.apimgt.webapp.publisher
provided
-
- io.entgra.device.mgt.core
- io.entgra.device.mgt.core.cea.mgt.common
- provided
-
\ No newline at end of file
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java
index 0d984bd1e53..5eb474cb322 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/service/impl/util/RequestValidationUtil.java
@@ -19,15 +19,6 @@ package io.entgra.device.mgt.core.device.mgt.api.jaxrs.service.impl.util;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
-import io.entgra.device.mgt.core.cea.mgt.common.bean.ActiveSyncServer;
-import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.AccessPolicyWrapper;
-import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.CEAPolicyWrapper;
-import io.entgra.device.mgt.core.device.mgt.api.jaxrs.beans.GracePeriodWrapper;
-import io.entgra.device.mgt.core.cea.mgt.common.bean.enums.DefaultAccessPolicy;
-import io.entgra.device.mgt.core.cea.mgt.common.bean.enums.EmailOutlookAccessPolicy;
-import io.entgra.device.mgt.core.cea.mgt.common.bean.enums.GraceAllowedPolicy;
-import io.entgra.device.mgt.core.cea.mgt.common.bean.enums.POPIMAPAccessPolicy;
-import io.entgra.device.mgt.core.cea.mgt.common.bean.enums.WebOutlookAccessPolicy;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -922,100 +913,4 @@ public class RequestValidationUtil {
"a higher value than endTimestamp").build());
}
}
-
- /**
- * Validate conditional access policy
- * @param ceaPolicyWrapper {@link CEAPolicyWrapper}
- */
- public static void validateCEAPolicy(CEAPolicyWrapper ceaPolicyWrapper) {
- if (ceaPolicyWrapper == null) {
- String msg = "CEA policy should not be null";
- log.error(msg);
- throw new BadRequestException(msg);
- }
- validateActiveSyncServer(ceaPolicyWrapper.getActiveSyncServerEntries());
- validateCEAAccessPolicy(ceaPolicyWrapper.getConditionalAccessPolicyEntries());
- validateCEAGracePeriod(ceaPolicyWrapper.getGracePeriodEntries());
- }
-
- /**
- * Validate active sync server configurations
- * @param activeSyncServer {@link ActiveSyncServer}
- */
- public static void validateActiveSyncServer(ActiveSyncServer activeSyncServer) {
- if (activeSyncServer == null) {
- String msg = "Active sync server should not be null";
- log.error(msg);
- throw new BadRequestException(msg);
- }
- if (activeSyncServer.getGatewayUrl() == null) {
- String msg = "Active sync server url should not be null";
- log.error(msg);
- throw new BadRequestException(msg);
- }
- if (activeSyncServer.getKey() == null) {
- String msg = "Active sync server type should not be null";
- log.error(msg);
- throw new BadRequestException(msg);
- }
- if (activeSyncServer.getClient() == null) {
- String msg = "Active sync server username should not be null";
- log.error(msg);
- throw new BadRequestException(msg);
- }
- if (activeSyncServer.getSecret() == null) {
- String msg = "Active sync server secret should not be null";
- log.error(msg);
- throw new BadRequestException(msg);
- }
- }
-
- /**
- * Validate conditional access policy configurations
- * @param accessPolicyWrapper {@link AccessPolicyWrapper}
- */
- public static void validateCEAAccessPolicy(AccessPolicyWrapper accessPolicyWrapper) {
- if (accessPolicyWrapper == null) {
- String msg = "Access policy should not be null";
- log.error(msg);
- throw new BadRequestException(msg);
- }
- try {
- Enum.valueOf(DefaultAccessPolicy.class, accessPolicyWrapper.getDefaultAccessPolicy());
- Enum.valueOf(WebOutlookAccessPolicy.class, accessPolicyWrapper.getWebOutlookAccessPolicy());
- Enum.valueOf(POPIMAPAccessPolicy.class, accessPolicyWrapper.getPOPIMAPAccessPolicy());
- for(String value : accessPolicyWrapper.getEmailOutlookAccessPolicy()) {
- Enum.valueOf(EmailOutlookAccessPolicy.class, value);
- }
- } catch (IllegalArgumentException | NullPointerException e) {
- String msg = "Access policy contains illegal arguments";
- log.error(msg);
- throw new BadRequestException(msg);
- }
- }
-
- /**
- * Validate grace period configurations
- * @param gracePeriodWrapper {@link GracePeriodWrapper}
- */
- public static void validateCEAGracePeriod(GracePeriodWrapper gracePeriodWrapper) {
- if (gracePeriodWrapper == null) {
- String msg = "Grace period should not be null";
- log.error(msg);
- throw new BadRequestException(msg);
- }
- if (gracePeriodWrapper.getGracePeriod() < 0 || gracePeriodWrapper.getGracePeriod() >
- io.entgra.device.mgt.core.cea.mgt.common.util.Constants.MAX_GRACE_PERIOD_IN_DAYS) {
- String msg = "Grace period should in range of 0-30 days";
- log.error(msg);
- throw new BadRequestException(msg);
- }
- try {
- Enum.valueOf(GraceAllowedPolicy.class, gracePeriodWrapper.getGraceAllowedPolicy());
- } catch (IllegalArgumentException | NullPointerException e) {
- String msg = "Grace allowed policy contains illegal arguments";
- log.error(msg);
- throw new BadRequestException(msg);
- }
- }
}
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java
index e28989ae6c1..6de5d1d1ca8 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/java/io/entgra/device/mgt/core/device/mgt/api/jaxrs/util/DeviceMgtAPIUtils.java
@@ -22,7 +22,6 @@ import io.entgra.device.mgt.core.apimgt.webapp.publisher.APIPublisherService;
import io.entgra.device.mgt.core.application.mgt.common.services.ApplicationManager;
import io.entgra.device.mgt.core.application.mgt.common.services.SubscriptionManager;
import io.entgra.device.mgt.core.device.mgt.common.metadata.mgt.DeviceStatusManagementService;
-import io.entgra.device.mgt.core.cea.mgt.common.service.CEAManagementService;
import org.apache.axis2.AxisFault;
import org.apache.axis2.client.Options;
import org.apache.axis2.java.security.SSLProtocolSocketFactory;
@@ -162,7 +161,6 @@ public class DeviceMgtAPIUtils {
private static volatile ApplicationManager applicationManager;
private static volatile APIPublisherService apiPublisher;
- private static volatile CEAManagementService ceaManagementService;
static {
String keyStorePassword = ServerConfiguration.getInstance().getFirstProperty("Security.KeyStore.Password");
@@ -1230,20 +1228,4 @@ public class DeviceMgtAPIUtils {
}
return isPermitted;
}
-
- public static CEAManagementService getCEAManagementService() {
- if (ceaManagementService == null) {
- synchronized (DeviceMgtAPIUtils.class) {
- if (ceaManagementService == null) {
- PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
- ceaManagementService = (CEAManagementService)
- ctx.getOSGiService(CEAManagementService.class, null);
- if (ceaManagementService == null) {
- throw new IllegalStateException("Conditional Email Access Management Service is not initialize");
- }
- }
- }
- }
- return ceaManagementService;
- }
}
diff --git a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml
index 21e75b40d09..7cdb4ffa0e1 100644
--- a/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml
+++ b/components/device-mgt/io.entgra.device.mgt.core.device.mgt.api/src/main/webapp/WEB-INF/cxf-servlet.xml
@@ -51,7 +51,6 @@
-
@@ -104,7 +103,6 @@
-
diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml
new file mode 100644
index 00000000000..e0f9f3f14a9
--- /dev/null
+++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/pom.xml
@@ -0,0 +1,119 @@
+
+
+
+
+
+ io.entgra.device.mgt.core
+ io.entgra.device.mgt.core.parent
+ 5.0.40-SNAPSHOT
+ ../pom.xml
+
+
+ 4.0.0
+ io.entgra.device.mgt.core.cea.mgt.admin.api.feature
+ Entgra IoT - CEA Management Admin API Feature
+ Entgra IoT - Conditional Email Access Management Admin API Feature
+
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ copy
+ package
+
+ copy
+
+
+
+
+ io.entgra.device.mgt.core
+ io.entgra.device.mgt.core.cea.mgt.admin.api
+ ${project.version}
+ war
+ true
+
+ ${project.build.directory}/maven-shared-archive-resources/webapps
+
+ api#cea-mgt#v1.0.war
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+
+
+ copy-resources
+ generate-resources
+
+ copy-resources
+
+
+ src/main/resources
+
+
+ resources
+
+ build.properties
+ p2.inf
+
+
+
+
+
+
+
+
+ org.wso2.maven
+ carbon-p2-plugin
+
+
+ p2-feature-generation
+ package
+
+ p2-feature-gen
+
+
+ io.entgra.device.mgt.core.cea.mgt.admin.api
+ ../../../features/etc/feature.properties
+
+
+
+ org.wso2.carbon.p2.category.type:server
+
+ org.eclipse.equinox.p2.type.group:false
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/src/main/resources/build.properties b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/src/main/resources/build.properties
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/src/main/resources/p2.inf b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/src/main/resources/p2.inf
new file mode 100644
index 00000000000..6d13a301cd6
--- /dev/null
+++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.admin.api.feature/src/main/resources/p2.inf
@@ -0,0 +1,2 @@
+instructions.configure = \
+org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/io.entgra.device.mgt.core.cea.mgt.admin.api_${feature.version}/webapps/api#cea-mgt#v1.0.war,target:${installFolder}/../../deployment/server/webapps/api#cea-mgt#v1.0.war,overwrite:true);\
\ No newline at end of file
diff --git a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml
index ef7acb546f5..c75f8807428 100644
--- a/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml
+++ b/features/cea-mgt-feature/io.entgra.device.mgt.core.cea.mgt.server.feature/pom.xml
@@ -23,12 +23,13 @@
io.entgra.device.mgt.core
cea-mgt-feature
5.0.40-SNAPSHOT
+ ../pom.xml
4.0.0
io.entgra.device.mgt.core.cea.mgt.server.feature
Entgra IoT - CEA Management Server Feature
- Entgra IoT - CEA Management Server Feature
+ Entgra IoT - Conditional Email Access Management Server Feature
diff --git a/features/cea-mgt-feature/pom.xml b/features/cea-mgt-feature/pom.xml
index 3fd269dab94..93fce41bcaa 100644
--- a/features/cea-mgt-feature/pom.xml
+++ b/features/cea-mgt-feature/pom.xml
@@ -33,5 +33,6 @@
io.entgra.device.mgt.core.cea.mgt.server.feature
+ io.entgra.device.mgt.core.cea.mgt.admin.api.feature
\ No newline at end of file