diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml index 9ec44fb8e0..31f3ee6fbb 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.api/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.38-SNAPSHOT + 5.0.40-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml index f6acc863f0..d785dc4985 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.common/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.38-SNAPSHOT + 5.0.40-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml index 605085f836..278e649def 100644 --- a/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml +++ b/components/analytics-mgt/grafana-mgt/io.entgra.device.mgt.core.analytics.mgt.grafana.proxy.core/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core grafana-mgt - 5.0.38-SNAPSHOT + 5.0.40-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/grafana-mgt/pom.xml b/components/analytics-mgt/grafana-mgt/pom.xml index b727405a97..c4591f4e67 100644 --- a/components/analytics-mgt/grafana-mgt/pom.xml +++ b/components/analytics-mgt/grafana-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core analytics-mgt - 5.0.38-SNAPSHOT + 5.0.40-SNAPSHOT ../pom.xml diff --git a/components/analytics-mgt/pom.xml b/components/analytics-mgt/pom.xml index a059180ec0..1b67f931d7 100644 --- a/components/analytics-mgt/pom.xml +++ b/components/analytics-mgt/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core.parent io.entgra.device.mgt.core - 5.0.38-SNAPSHOT + 5.0.40-SNAPSHOT ../../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml index 7d4c9f4674..8075021a33 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.analytics.extension/pom.xml @@ -20,7 +20,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.38-SNAPSHOT + 5.0.40-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml index 11c12b310d..1581c4dbfc 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.annotations/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.38-SNAPSHOT + 5.0.40-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml index 95272e5c94..b0f5410d28 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.38-SNAPSHOT + 5.0.40-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/util/APIUtil.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/util/APIUtil.java index f56ec6831b..9a4702cdcb 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/util/APIUtil.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension.api/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/api/util/APIUtil.java @@ -51,6 +51,8 @@ public class APIUtil { private static final String DEFAULT_ENTERPRISE_TAG= "androidforwork"; private static final String DEFAULT_ANALYTICS_MGT_TAG= "analytics_management"; + private static final String DEFAULT_DEVICE_ORGANIZATION_MGT_TAG= "device_organization_management"; + public static final String PERMISSION_PROPERTY_NAME = "name"; public static String getAuthenticatedUser() { @@ -121,6 +123,7 @@ public class APIUtil { allowedApisTags.add(DEFAULT_ANALYTICS_ARTIFACT_TAG); allowedApisTags.add(DEFAULT_TRANSPORT_MGT_TAG); allowedApisTags.add(DEFAULT_ANALYTICS_MGT_TAG); + allowedApisTags.add(DEFAULT_DEVICE_ORGANIZATION_MGT_TAG); // In an environment only super tenant should be capable of calling this API tag if (PrivilegedCarbonContext.getThreadLocalCarbonContext().getTenantId() == MultitenantConstants.SUPER_TENANT_ID) { diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml index 87b20c6188..42209a881a 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.38-SNAPSHOT + 5.0.40-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml index 076b2ee983..31e52840c3 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.extension.rest.api/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.38-SNAPSHOT + 5.0.40-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml index 3d241b172a..d3faeba0b7 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension.api/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.38-SNAPSHOT + 5.0.40-SNAPSHOT 4.0.0 diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml index e623d369b0..5fd353e02d 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.keymgt.extension/pom.xml @@ -21,7 +21,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.38-SNAPSHOT + 5.0.40-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml index c99ad0899a..80de344fbb 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/pom.xml @@ -22,7 +22,7 @@ apimgt-extensions io.entgra.device.mgt.core - 5.0.38-SNAPSHOT + 5.0.40-SNAPSHOT ../pom.xml diff --git a/components/apimgt-extensions/pom.xml b/components/apimgt-extensions/pom.xml index 57ca6e06bc..522dd8c4b4 100644 --- a/components/apimgt-extensions/pom.xml +++ b/components/apimgt-extensions/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.38-SNAPSHOT + 5.0.40-SNAPSHOT ../../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml index 8f8b82d644..21d7cb87e6 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.common/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.38-SNAPSHOT + 5.0.40-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml index 79305be683..52565ff227 100644 --- a/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml +++ b/components/application-mgt/io.entgra.device.mgt.core.application.mgt.core/pom.xml @@ -21,7 +21,7 @@ io.entgra.device.mgt.core application-mgt - 5.0.38-SNAPSHOT + 5.0.40-SNAPSHOT ../pom.xml diff --git a/components/application-mgt/pom.xml b/components/application-mgt/pom.xml index 90f0f8b4d6..d0e495c5ec 100644 --- a/components/application-mgt/pom.xml +++ b/components/application-mgt/pom.xml @@ -22,7 +22,7 @@ io.entgra.device.mgt.core io.entgra.device.mgt.core.parent - 5.0.38-SNAPSHOT + 5.0.40-SNAPSHOT ../../pom.xml 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 0000000000..239156f4d9 --- /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/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 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 new file mode 100644 index 0000000000..cf5c9e7167 --- /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/bean/AccessPolicyWrapper.java @@ -0,0 +1,77 @@ +/* + * 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 = "AccessPolicyWrapper", description = "Access policy transferring DTO") +public class AccessPolicyWrapper { + @JsonProperty(value = "defaultAccessPolicy", required = true) + @ApiModelProperty(name = "defaultAccessPolicy", value = "Default access policy value", required = true) + private String defaultAccessPolicy; + + @JsonProperty(value = "emailOutlookAccessPolicy", required = true) + @ApiModelProperty(name = "emailOutlookAccessPolicy", value = "Email outlook access policy value", required = true) + private Set emailOutlookAccessPolicy; + + @JsonProperty(value = "POPIMAPAccessPolicy", required = true) + @ApiModelProperty(name = "POPIMAPAccessPolicy", value = "POP/IMAP access policy value", required = true) + private String POPIMAPAccessPolicy; + + @JsonProperty(value = "webOutlookAccessPolicy", required = true) + @ApiModelProperty(name = "webOutlookAccessPolicy", value = "Web outlook access policy value", required = true) + private String webOutlookAccessPolicy; + + public String getDefaultAccessPolicy() { + return defaultAccessPolicy; + } + + public void setDefaultAccessPolicy(String defaultAccessPolicy) { + this.defaultAccessPolicy = defaultAccessPolicy; + } + + public Set getEmailOutlookAccessPolicy() { + return emailOutlookAccessPolicy; + } + + public void setEmailOutlookAccessPolicy(Set emailOutlookAccessPolicy) { + this.emailOutlookAccessPolicy = emailOutlookAccessPolicy; + } + + public String getPOPIMAPAccessPolicy() { + return POPIMAPAccessPolicy; + } + + public void setPOPIMAPAccessPolicy(String POPIMAPAccessPolicy) { + this.POPIMAPAccessPolicy = POPIMAPAccessPolicy; + } + + public String getWebOutlookAccessPolicy() { + return webOutlookAccessPolicy; + } + + public void setWebOutlookAccessPolicy(String webOutlookAccessPolicy) { + this.webOutlookAccessPolicy = webOutlookAccessPolicy; + } +} 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/bean/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 new file mode 100644 index 0000000000..a92198f053 --- /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/bean/CEAPolicyWrapper.java @@ -0,0 +1,64 @@ +/* + * 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.entgra.device.mgt.core.cea.mgt.common.bean.ActiveSyncServer; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel(value = "CEAPolicyWrapper", description = "CEA policy transferring DTO") +public class CEAPolicyWrapper { + @JsonProperty(value = "activeSyncServerEntries", required = true) + @ApiModelProperty(name = "activeSyncServerEntries", value = "Active sync server properties", required = true) + private ActiveSyncServer activeSyncServerEntries; + + @JsonProperty(value = "conditionalAccessPolicyEntries", required = true) + @ApiModelProperty(name = "conditionalAccessPolicyEntries", value = "Definition of the access policy", required = true) + private AccessPolicyWrapper conditionalAccessPolicyEntries; + + @JsonProperty(value = "gracePeriodEntries", required = true) + @ApiModelProperty(name = "gracePeriodEntries", value = "Definition of the grace period", required = true) + private GracePeriodWrapper gracePeriodEntries; + + public ActiveSyncServer getActiveSyncServerEntries() { + return activeSyncServerEntries; + } + + public void setActiveSyncServerEntries(ActiveSyncServer activeSyncServerEntries) { + this.activeSyncServerEntries = activeSyncServerEntries; + } + + public AccessPolicyWrapper getConditionalAccessPolicyEntries() { + return conditionalAccessPolicyEntries; + } + + public void setConditionalAccessPolicyEntries(AccessPolicyWrapper conditionalAccessPolicyEntries) { + this.conditionalAccessPolicyEntries = conditionalAccessPolicyEntries; + } + + public GracePeriodWrapper getGracePeriodEntries() { + return gracePeriodEntries; + } + + public void setGracePeriodEntries(GracePeriodWrapper gracePeriodEntries) { + this.gracePeriodEntries = gracePeriodEntries; + } +} 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/bean/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 new file mode 100644 index 0000000000..2a74e89fe4 --- /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/bean/GracePeriodWrapper.java @@ -0,0 +1,52 @@ +/* + * 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; + +@ApiModel(value = "GracePeriodWrapper", description = "GracePeriod transferring DTO") +public class GracePeriodWrapper { + + @JsonProperty(value = "gracePeriod", required = true) + @ApiModelProperty(name = "gracePeriod", value = "Grace period in days", required = true) + private int gracePeriod; + + @JsonProperty(value = "graceAllowedPolicy", required = true) + @ApiModelProperty(name = "graceAllowedPolicy", value = "Grace allowed policy values", required = true) + private String graceAllowedPolicy; + + public int getGracePeriod() { + return gracePeriod; + } + + public void setGracePeriod(int gracePeriod) { + this.gracePeriod = gracePeriod; + } + + public String getGraceAllowedPolicy() { + return graceAllowedPolicy; + } + + public void setGraceAllowedPolicy(String graceAllowedPolicy) { + this.graceAllowedPolicy = graceAllowedPolicy; + } +} 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 0000000000..06abe1496f --- /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 0000000000..ec5505ab71 --- /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/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 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 new file mode 100644 index 0000000000..dab95bed5a --- /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/impl/CEAManagementAdminServiceImpl.java @@ -0,0 +1,198 @@ +/* + * 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.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.CEAPolicy; +import io.entgra.device.mgt.core.cea.mgt.common.bean.GracePeriod; +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 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.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 javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +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.HashSet; +import java.util.Set; + +@Path("/admin/cea-policies") +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +public class CEAManagementAdminServiceImpl implements CEAManagementAdminService { + private static final Log log = LogFactory.getLog(CEAManagementAdminServiceImpl.class); + + @GET + @Path("/ui") + @Override + public Response getCEAPolicyUI() { + CEAManagementService ceaManagementService = CEAManagementApiUtil.getCEAManagementService(); + try { + CEAPolicyUIConfiguration ceaPolicyUIConfiguration = ceaManagementService.getCEAPolicyUIConfiguration(); + if (ceaPolicyUIConfiguration == null) { + return Response.status(HttpStatus.SC_NOT_FOUND).entity("UI configurations not found").build(); + } + return Response.status(HttpStatus.SC_OK).entity(ceaPolicyUIConfiguration).build(); + } catch (CEAManagementException e) { + String msg = "Error occurred while retrieving CEA ui configs"; + log.error(msg, e); + return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).entity(msg).build(); + } + } + + @POST + @Override + public Response createCEAPolicy(CEAPolicyWrapper ceaPolicyWrapper) { + try { + RequestValidationUtil.validateCEAPolicy(ceaPolicyWrapper); + CEAManagementService ceaManagementService = CEAManagementApiUtil.getCEAManagementService(); + CEAPolicy ceaPolicy = constructCEAPolicy(ceaPolicyWrapper); + ceaPolicy = ceaManagementService.createCEAPolicy(ceaPolicy); + return Response.status(HttpStatus.SC_CREATED).entity(ceaPolicy).build(); + } catch (CEAPolicyAlreadyExistsException e) { + String msg = "CEA policy already exists for the tenant"; + log.warn(msg); + return Response.status(HttpStatus.SC_CONFLICT).entity(msg).build(); + } catch (CEAManagementException e) { + String msg = "Error occurred while creating CEA policy"; + log.error(msg, e); + return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).entity(msg).build(); + } + } + + @Override + public Response retrieveCEAPolicy() { + try { + 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(); + } + return Response.status(HttpStatus.SC_OK).entity(ceaPolicy).build(); + } catch (CEAManagementException e) { + String msg = "Error occurred while retrieving CEA policy"; + log.error(msg, e); + return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).entity(msg).build(); + } + } + + @Override + public Response deleteCEAPolicy() { + try { + CEAManagementService ceaManagementService = CEAManagementApiUtil.getCEAManagementService(); + ceaManagementService.deleteCEAPolicy(); + return Response.status(HttpStatus.SC_OK).build(); + } catch (CEAPolicyNotFoundException e) { + String msg = "CEA policy isn't exists in the tenant"; + log.warn(msg); + return Response.status(HttpStatus.SC_NOT_FOUND).entity(msg).build(); + } catch (CEAManagementException e) { + String msg = "Error occurred while deleting CEA policy"; + log.error(msg, e); + return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).entity(msg).build(); + } + } + + @Override + public Response updateCEAPolicy(CEAPolicyWrapper ceaPolicyWrapper) { + try { + RequestValidationUtil.validateCEAPolicy(ceaPolicyWrapper); + CEAManagementService ceaManagementService = CEAManagementApiUtil.getCEAManagementService(); + CEAPolicy ceaPolicy = constructCEAPolicy(ceaPolicyWrapper); + ceaPolicy = ceaManagementService.updateCEAPolicy(ceaPolicy); + return Response.status(HttpStatus.SC_CREATED).entity(ceaPolicy).build(); + } catch (CEAPolicyNotFoundException e) { + String msg = "CEA policy isn't exists in the tenant"; + log.warn(msg); + return Response.status(HttpStatus.SC_NOT_FOUND).entity(msg).build(); + } catch (CEAManagementException e) { + String msg = "Error occurred while updating CEA policy"; + log.error(msg, e); + return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).entity(msg).build(); + } + } + + @GET + @Path("/sync-now") + @Override + public Response sync() { + CEAManagementService ceaManagementService = CEAManagementApiUtil.getCEAManagementService(); + try { + ceaManagementService.syncNow(); + return Response.status(HttpStatus.SC_OK).build(); + } catch (CEAManagementException e) { + String msg = "Error occurred while trigger syncing"; + log.error(msg, e); + return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR).entity(msg).build(); + } + } + + /** + * Construct {@link CEAPolicy} from {@link CEAPolicyWrapper} + * @param ceaPolicyWrapper {@link CEAPolicyWrapper} + * @return {@link CEAPolicy} + */ + private CEAPolicy constructCEAPolicy(CEAPolicyWrapper ceaPolicyWrapper) { + AccessPolicyWrapper accessPolicyWrapper = ceaPolicyWrapper.getConditionalAccessPolicyEntries(); + AccessPolicy accessPolicy = new AccessPolicy(); + accessPolicy.setDefaultAccessPolicy(Enum.valueOf(DefaultAccessPolicy.class, + accessPolicyWrapper.getDefaultAccessPolicy())); + accessPolicy.setPOPIMAPAccessPolicy(Enum.valueOf(POPIMAPAccessPolicy.class, + accessPolicyWrapper.getPOPIMAPAccessPolicy())); + accessPolicy.setWebOutlookAccessPolicy(Enum.valueOf(WebOutlookAccessPolicy.class, + accessPolicyWrapper.getWebOutlookAccessPolicy())); + Set emailOutlookAccessPolicy = new HashSet<>(); + for (String value : ceaPolicyWrapper.getConditionalAccessPolicyEntries().getEmailOutlookAccessPolicy()) { + emailOutlookAccessPolicy.add(Enum.valueOf(EmailOutlookAccessPolicy.class, value)); + } + accessPolicy.setEmailOutlookAccessPolicy(emailOutlookAccessPolicy); + GracePeriodWrapper gracePeriodWrapper = ceaPolicyWrapper.getGracePeriodEntries(); + GracePeriod gracePeriod = new GracePeriod(); + gracePeriod.setGracePeriod(gracePeriodWrapper.getGracePeriod()); + gracePeriod.setGraceAllowedPolicy(Enum.valueOf(GraceAllowedPolicy.class, + gracePeriodWrapper.getGraceAllowedPolicy())); + ActiveSyncServer activeSyncServer = ceaPolicyWrapper.getActiveSyncServerEntries(); + CEAPolicy ceaPolicy = new CEAPolicy(); + ceaPolicy.setAccessPolicy(accessPolicy); + ceaPolicy.setGracePeriod(gracePeriod); + ceaPolicy.setActiveSyncServer(activeSyncServer); + return ceaPolicy; + } +} 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/service/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 new file mode 100644 index 0000000000..2a2bd0daea --- /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/service/CEAManagementAdminService.java @@ -0,0 +1,365 @@ +/* + * 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.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.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.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; + +@Api(tags = {"conditional_email_access", "device_management"}) +@Path("/admin/cea-policies") +@SwaggerDefinition( + info = @Info( + description = "Conditional Email Access Management", + version = "v1.0.0", + title = "CEAManagementAdminService API", + extensions = @Extension(properties = { + @ExtensionProperty(name = "name", value = "CEAManagementAdminService"), + @ExtensionProperty(name = "context", value = "/api/cea-mgt/v1.0/admin/cea-policies"), + }) + ), + consumes = {MediaType.APPLICATION_JSON}, + produces = {MediaType.APPLICATION_JSON}, + schemes = {SwaggerDefinition.Scheme.HTTP, SwaggerDefinition.Scheme.HTTPS}, + tags = { + @Tag(name = "device_management", description = "Device management"), + @Tag(name = "conditional_email_access", description = "Mailbox access management") + } +) +@Consumes(MediaType.APPLICATION_JSON) +@Produces(MediaType.APPLICATION_JSON) +@Scopes( + scopes = { + @Scope( + name = "CEA policy ui configuration view", + description = "CEA policy ui configuration view", + key = "dm:admin:cea:view", + roles = {"Internal/devicemgt-admin"}, + permissions = {"/device-mgt/admin/cea/view"} + ), + @Scope( + name = "Add CEA policy", + description = "Add CEA policy", + key = "dm:admin:cea:add", + roles = {"Internal/devicemgt-admin"}, + permissions = {"/device-mgt/admin/cea/add"} + ), + @Scope( + name = "Update CEA policy", + description = "Update CEA policy", + key = "dm:admin:cea:update", + roles = {"Internal/devicemgt-admin"}, + permissions = {"/device-mgt/admin/cea/update"} + ), + @Scope( + name = "Delete CEA policy", + description = "Delete CEA policy", + key = "dm:admin:cea:delete", + roles = {"Internal/devicemgt-admin"}, + permissions = {"/device-mgt/admin/cea/delete"} + ), + @Scope( + name = "Sync CEA policy", + description = "Sync CEA policy", + key = "dm:admin:cea:sync", + roles = {"Internal/devicemgt-admin"}, + permissions = {"/device-mgt/admin/cea/sync"} + ) + } +) +public interface CEAManagementAdminService { + String SCOPE = "scope"; + + @GET + @Path("/ui") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = HttpMethod.GET, + value = "Retrieve CEA policy ui configurations", + notes = "Returns CEA policy ui configurations for supporting mail services", + tags = {"conditional_email_access", "device_management"}, + extensions = { + @Extension(properties = { + @ExtensionProperty(name = SCOPE, value = "dm:admin:cea:view") + }) + } + ) + @ApiResponses( + value = { + @ApiResponse(code = 200, + message = "OK. \n Successfully retrieve the cea ui configurations", + response = Integer.class), + @ApiResponse( + code = 304, + message = "Not Modified. \n Empty body because the client has already the latest version of " + + "the requested resource.", + response = Response.class), + @ApiResponse( + code = 404, + message = "Configurations not found", + response = Response.class), + @ApiResponse( + code = 406, + 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 = Response.class) + } + ) + Response getCEAPolicyUI(); + + + @POST + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = HttpMethod.POST, + value = "Add CEA policy", + notes = "Create conditional email access policy", + tags = {"conditional_email_access", "device_management"}, + extensions = { + @Extension(properties = { + @ExtensionProperty(name = SCOPE, value = "dm:admin:cea:add") + }) + } + ) + @ApiResponses( + value = { + @ApiResponse( + code = 201, + message = "OK. \n Successfully created the CEA policy", + response = Response.class), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error.", + response = Response.class), + @ApiResponse( + code = 404, + 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.", + response = Response.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred while creating the resource.", + response = Response.class) + } + ) + Response createCEAPolicy( + @ApiParam( + name = "ceaPolicy", + value = "Conditional email access policy details", + required = true + ) + CEAPolicyWrapper ceaPolicyWrapper); + + @GET + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = HttpMethod.GET, + value = "Retrieve CEA policy", + notes = "Retrieve conditional email access policy", + tags = {"conditional_email_access", "device_management"}, + extensions = { + @Extension(properties = { + @ExtensionProperty(name = SCOPE, value = "dm:admin:cea:view") + }) + } + ) + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully retrieved the CEA policy", + response = Response.class), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error.", + response = Response.class), + @ApiResponse( + code = 404, + 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.", + response = Response.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred while creating the resource.", + response = Response.class) + } + ) + Response retrieveCEAPolicy(); + + @DELETE + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = HttpMethod.DELETE, + value = "Delete CEA policy", + notes = "Delete conditional email access policy", + tags = {"conditional_email_access", "device_management"}, + extensions = { + @Extension(properties = { + @ExtensionProperty(name = SCOPE, value = "dm:admin:cea:delete") + }) + } + ) + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully deleted the CEA policy", + response = Response.class), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error.", + response = Response.class), + @ApiResponse( + code = 404, + 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.", + response = Response.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred while creating the resource.", + response = Response.class) + } + ) + Response deleteCEAPolicy(); + + @PUT + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = HttpMethod.PUT, + value = "Update CEA policy", + notes = "Update conditional email access policy", + tags = {"conditional_email_access", "device_management"}, + extensions = { + @Extension(properties = { + @ExtensionProperty(name = SCOPE, value = "dm:admin:cea:update") + }) + } + ) + @ApiResponses( + value = { + @ApiResponse( + code = 200, + message = "OK. \n Successfully updated the CEA policy", + response = Response.class), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error.", + response = Response.class), + @ApiResponse( + code = 404, + 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.", + response = Response.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred while creating the resource.", + response = Response.class) + } + ) + Response updateCEAPolicy(@ApiParam( + name = "ceaPolicy", + value = "Conditional email access policy details", + required = true + ) CEAPolicyWrapper ceaPolicyWrapper); + + @GET + @Path("/sync-now") + @ApiOperation( + produces = MediaType.APPLICATION_JSON, + httpMethod = HttpMethod.GET, + value = "Sync with active sync server", + notes = "Sync and enforce conditional access policy", + tags = {"conditional_email_access", "device_management"}, + extensions = { + @Extension(properties = { + @ExtensionProperty(name = SCOPE, value = "dm:admin:cea:sync") + }) + } + ) + @ApiResponses( + value = { + @ApiResponse( + code = 201, + message = "OK. \n Successfully triggered CEA policy sync", + response = Response.class), + @ApiResponse( + code = 400, + message = "Bad Request. \n Invalid request or validation error.", + response = Response.class), + @ApiResponse( + code = 404, + 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.", + response = Response.class), + @ApiResponse( + code = 500, + message = "Internal Server Error. \n Server error occurred while creating the resource.", + 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 0000000000..e135f06237 --- /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 0000000000..9d4ca453d6 --- /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 0000000000..6ba6a22ad4 --- /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 0000000000..c77d3abeb1 --- /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 0000000000..27e5caa896 --- /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/io.entgra.device.mgt.core.cea.mgt.common/pom.xml b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml new file mode 100644 index 0000000000..f2649e8498 --- /dev/null +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/pom.xml @@ -0,0 +1,75 @@ + + + + + + + io.entgra.device.mgt.core + cea-mgt + 5.0.40-SNAPSHOT + ../pom.xml + + + 4.0.0 + io.entgra.device.mgt.core.cea.mgt.common + bundle + Entgra IoT - CEA Management Common + Entgra IoT - Conditional Email Access Management Common + + + + + org.apache.felix + maven-scr-plugin + + + org.apache.felix + maven-bundle-plugin + true + + + ${project.artifactId} + ${project.artifactId} + ${io.entgra.device.mgt.core.version} + CEA Management Common Bundle + + org.apache.commons.logging, + io.entgra.device.mgt.core.device.mgt.common.* + + + io.entgra.device.mgt.core.cea.mgt.common.* + + + + + + + + + + io.entgra.device.mgt.core + io.entgra.device.mgt.core.device.mgt.common + + + io.swagger + swagger-annotations + + + \ No newline at end of file diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/AccessPolicy.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/AccessPolicy.java new file mode 100644 index 0000000000..a874557092 --- /dev/null +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/AccessPolicy.java @@ -0,0 +1,66 @@ +/* + * 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.common.bean; + +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.POPIMAPAccessPolicy; +import io.entgra.device.mgt.core.cea.mgt.common.bean.enums.WebOutlookAccessPolicy; + +import java.util.Set; + +public class AccessPolicy { + private DefaultAccessPolicy defaultAccessPolicy; + private Set emailOutlookAccessPolicy; + private POPIMAPAccessPolicy POPIMAPAccessPolicy; + private WebOutlookAccessPolicy webOutlookAccessPolicy; + + public DefaultAccessPolicy getDefaultAccessPolicy() { + return defaultAccessPolicy; + } + + public void setDefaultAccessPolicy(DefaultAccessPolicy defaultAccessPolicy) { + this.defaultAccessPolicy = defaultAccessPolicy; + } + + public Set getEmailOutlookAccessPolicy() { + return emailOutlookAccessPolicy; + } + + public void setEmailOutlookAccessPolicy(Set emailOutlookAccessPolicy) { + this.emailOutlookAccessPolicy = emailOutlookAccessPolicy; + } + + public POPIMAPAccessPolicy getPOPIMAPAccessPolicy() { + return POPIMAPAccessPolicy; + } + + public void setPOPIMAPAccessPolicy(POPIMAPAccessPolicy POPIMAPAccessPolicy) { + this.POPIMAPAccessPolicy = POPIMAPAccessPolicy; + } + + public WebOutlookAccessPolicy getWebOutlookAccessPolicy() { + return webOutlookAccessPolicy; + } + + public void setWebOutlookAccessPolicy(WebOutlookAccessPolicy webOutlookAccessPolicy) { + this.webOutlookAccessPolicy = webOutlookAccessPolicy; + } +} diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ActiveSyncDevice.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ActiveSyncDevice.java new file mode 100644 index 0000000000..12c8987e09 --- /dev/null +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ActiveSyncDevice.java @@ -0,0 +1,84 @@ +/* + * 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.common.bean; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.Date; +import java.util.Objects; + +public class ActiveSyncDevice { + @JsonProperty(value = "DeviceID", required = true) + private String deviceId; + @JsonProperty(value = "FirstSyncTime", required = true) + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") + private Date firstSyncTime; + @JsonProperty(value = "UserPrincipalName", required = true) + private String userPrincipalName; + @JsonProperty(value = "Identity", required = true) + private String identity; + + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(String deviceId) { + this.deviceId = deviceId; + } + + public Date getFirstSyncTime() { + return firstSyncTime; + } + + public void setFirstSyncTime(Date firstSyncTime) { + this.firstSyncTime = firstSyncTime; + } + + public String getIdentity() { + return identity; + } + + public void setIdentity(String identity) { + this.identity = identity; + } + + public String getUserPrincipalName() { + return userPrincipalName; + } + + public void setUserPrincipalName(String userPrincipalName) { + this.userPrincipalName = userPrincipalName; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof ActiveSyncDevice)) return false; + ActiveSyncDevice that = (ActiveSyncDevice) o; + return Objects.equals(deviceId, that.deviceId) + && Objects.equals(userPrincipalName, that.userPrincipalName); + } + + @Override + public int hashCode() { + return Objects.hash(deviceId, userPrincipalName, identity); + } +} diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ActiveSyncServer.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ActiveSyncServer.java new file mode 100644 index 0000000000..b4045b4f02 --- /dev/null +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ActiveSyncServer.java @@ -0,0 +1,74 @@ +/* + * 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.common.bean; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel(value = "ActiveSyncServer", description = "Active sync server properties") +public class ActiveSyncServer { + @JsonProperty(value = "key", required = true) + @ApiModelProperty(name = "key", value = "Key describing the server type according to cea-config.xml", required = true) + private String key; + + @JsonProperty(value = "gatewayUrl", required = true) + @ApiModelProperty(name = "gatewayUrl", value = "Gateway URL of the active sync server", required = true) + private String gatewayUrl; + + @JsonProperty(value = "client", required = true) + @ApiModelProperty(name = "client", value = "Client identifier", required = true) + private String client; + @JsonProperty(value = "secret", required = true) + @ApiModelProperty(name = "secret", value = "Client secret", required = true) + private String secret; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getGatewayUrl() { + return gatewayUrl; + } + + public void setGatewayUrl(String gatewayUrl) { + this.gatewayUrl = gatewayUrl; + } + + public String getClient() { + return client; + } + + public void setClient(String client) { + this.client = client; + } + + public String getSecret() { + return secret; + } + + public void setSecret(String secret) { + this.secret = secret; + } +} diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ActiveSyncServerUIConfiguration.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ActiveSyncServerUIConfiguration.java new file mode 100644 index 0000000000..7db46e5d28 --- /dev/null +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ActiveSyncServerUIConfiguration.java @@ -0,0 +1,50 @@ +/* + * 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.common.bean; + +public class ActiveSyncServerUIConfiguration { + private String name; + private String description; + private String key; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } +} diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/AndroidEASIdentifier.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/AndroidEASIdentifier.java new file mode 100644 index 0000000000..e38b43cbf9 --- /dev/null +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/AndroidEASIdentifier.java @@ -0,0 +1,32 @@ +/* + * 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.common.bean; + +public class AndroidEASIdentifier { + private String identifier; + + public String getIdentifier() { + return identifier; + } + + public void setIdentifier(String identifier) { + this.identifier = identifier; + } +} diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/CEAPolicy.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/CEAPolicy.java new file mode 100644 index 0000000000..33ed04f2c5 --- /dev/null +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/CEAPolicy.java @@ -0,0 +1,99 @@ +/* + * 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.common.bean; + +import java.io.Serializable; +import java.util.Date; + +public class CEAPolicy implements Serializable { + private static final long serialVersionUID = -4578284769501447L; + private ActiveSyncServer activeSyncServer; + private AccessPolicy accessPolicy; + private GracePeriod gracePeriod; + private Date created; + private Date lastUpdated; + private Date lastSynced; + private boolean isSynced; + private int tenantId; + + public boolean isSynced() { + return isSynced; + } + + public void setSynced(boolean synced) { + isSynced = synced; + } + + public Date getCreated() { + return created; + } + + public void setCreated(Date created) { + this.created = created; + } + + public Date getLastUpdated() { + return lastUpdated; + } + + public void setLastUpdated(Date lastUpdated) { + this.lastUpdated = lastUpdated; + } + + public Date getLastSynced() { + return lastSynced; + } + + public void setLastSynced(Date lastSynced) { + this.lastSynced = lastSynced; + } + + public AccessPolicy getAccessPolicy() { + return accessPolicy; + } + + public void setAccessPolicy(AccessPolicy accessPolicy) { + this.accessPolicy = accessPolicy; + } + + public GracePeriod getGracePeriod() { + return gracePeriod; + } + + public void setGracePeriod(GracePeriod gracePeriod) { + this.gracePeriod = gracePeriod; + } + + public ActiveSyncServer getActiveSyncServer() { + return activeSyncServer; + } + + public void setActiveSyncServer(ActiveSyncServer activeSyncServer) { + this.activeSyncServer = activeSyncServer; + } + + public int getTenantId() { + return tenantId; + } + + public void setTenantId(int tenantId) { + this.tenantId = tenantId; + } +} diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/CEAPolicyEASWrapper.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/CEAPolicyEASWrapper.java new file mode 100644 index 0000000000..b898ac6cbc --- /dev/null +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/CEAPolicyEASWrapper.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.common.bean; + +import java.util.List; + +public class CEAPolicyEASWrapper { + private List activeSyncDevices; + private CEAPolicy ceaPolicy; + + public List getActiveSyncDevices() { + return activeSyncDevices; + } + + public void setActiveSyncDevices(List activeSyncDevices) { + this.activeSyncDevices = activeSyncDevices; + } + + public CEAPolicy getCeaPolicy() { + return ceaPolicy; + } + + public void setCeaPolicy(CEAPolicy ceaPolicy) { + this.ceaPolicy = ceaPolicy; + } +} diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/GracePeriod.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/GracePeriod.java new file mode 100644 index 0000000000..51f44fff74 --- /dev/null +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/GracePeriod.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.common.bean; + +import io.entgra.device.mgt.core.cea.mgt.common.bean.enums.GraceAllowedPolicy; + +public class GracePeriod { + private int gracePeriod; + private GraceAllowedPolicy graceAllowedPolicy; + + public int getGracePeriod() { + return gracePeriod; + } + + public void setGracePeriod(int gracePeriod) { + this.gracePeriod = gracePeriod; + } + + public GraceAllowedPolicy getGraceAllowedPolicy() { + return graceAllowedPolicy; + } + + public void setGraceAllowedPolicy(GraceAllowedPolicy graceAllowedPolicy) { + this.graceAllowedPolicy = graceAllowedPolicy; + } +} diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/MailboxProfile.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/MailboxProfile.java new file mode 100644 index 0000000000..e172009ea1 --- /dev/null +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/MailboxProfile.java @@ -0,0 +1,123 @@ +/* + * 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.common.bean; + +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +public class MailboxProfile { + private final Set activeSyncAllowedEASIdentifiers = new HashSet<>(); + private final Set activeSyncBlockedEASIdentifiers = new HashSet<>(); + private String identity; + + public Set getActiveSyncAllowedEASIdentifiers() { + return activeSyncAllowedEASIdentifiers; + } + + public Set getActiveSyncBlockedEASIdentifiers() { + return activeSyncBlockedEASIdentifiers; + } + + public void addActiveSyncAllowedEASIdentifier(String EASIdentifier) { + activeSyncAllowedEASIdentifiers.add(EASIdentifier); + } + + public void addActiveSyncBlockEASIdentifier(String EASIdentifier) { + activeSyncBlockedEASIdentifiers.add(EASIdentifier); + } + + public String getIdentity() { + return identity; + } + + public void setIdentity(String identity) { + this.identity = identity; + } + + public String getAllowedEASIdentifierString() { + String add = "", remove = ""; + if (!activeSyncAllowedEASIdentifiers.isEmpty()) { + Set processedEASIdentifiers = new HashSet<>(); + for (String activeSyncAllowedEASIdentifier : activeSyncAllowedEASIdentifiers) { + processedEASIdentifiers.add("'" + activeSyncAllowedEASIdentifier + "'"); + } + add = String.join(",", processedEASIdentifiers); + } + + if (!activeSyncBlockedEASIdentifiers.isEmpty()) { + Set processedEASIdentifiers = new HashSet<>(); + for (String activeSyncBlockedEASIdentifier : activeSyncBlockedEASIdentifiers) { + processedEASIdentifiers.add("'" + activeSyncBlockedEASIdentifier + "'"); + } + remove = String.join(",", processedEASIdentifiers); + } + + String begin = "@{", end = "}"; + if (!add.isEmpty()) { + begin = begin + "Add=" + add + ";"; + } + if (!remove.isEmpty()) { + begin = begin + "Remove=" + remove + ";"; + } + return begin + end; + } + + public String getBlockedEASIdentifierString() { + String add = "", remove = ""; + if (!activeSyncAllowedEASIdentifiers.isEmpty()) { + Set processedEASIdentifiers = new HashSet<>(); + for (String activeSyncAllowedEASIdentifier : activeSyncAllowedEASIdentifiers) { + processedEASIdentifiers.add("'" + activeSyncAllowedEASIdentifier + "'"); + } + remove = String.join(",", processedEASIdentifiers); + } + + if (!activeSyncBlockedEASIdentifiers.isEmpty()) { + Set processedEASIdentifiers = new HashSet<>(); + for (String activeSyncBlockedEASIdentifier : activeSyncBlockedEASIdentifiers) { + processedEASIdentifiers.add("'" + activeSyncBlockedEASIdentifier + "'"); + } + add = String.join(",", processedEASIdentifiers); + } + + String begin = "@{", end = "}"; + if (!add.isEmpty()) { + begin = begin + "Add=" + add + ";"; + } + if (!remove.isEmpty()) { + begin = begin + "Remove=" + remove + ";"; + } + return begin + end; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof MailboxProfile)) return false; + MailboxProfile that = (MailboxProfile) o; + return Objects.equals(identity, that.identity); + } + + @Override + public int hashCode() { + return Objects.hash(identity); + } +} diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/enums/DefaultAccessPolicy.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/enums/DefaultAccessPolicy.java new file mode 100644 index 0000000000..d3a6f8a9f6 --- /dev/null +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/enums/DefaultAccessPolicy.java @@ -0,0 +1,40 @@ +/* + * 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.common.bean.enums; + +public enum DefaultAccessPolicy { + ALLOW("ALLOW"), + QUARANTINE("QUARANTINE"), + BLOCK("BLOCK"); + + private final String name; + + DefaultAccessPolicy(String name) { + this.name = name; + } + + public boolean equalsName(String thatName) { + return name.equals(thatName); + } + + public String toString() { + return name; + } +} diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/enums/EmailOutlookAccessPolicy.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/enums/EmailOutlookAccessPolicy.java new file mode 100644 index 0000000000..a9ffb1c88e --- /dev/null +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/enums/EmailOutlookAccessPolicy.java @@ -0,0 +1,42 @@ +/* + * 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.common.bean.enums; + +public enum EmailOutlookAccessPolicy { + MOBILE_OUTLOOK_BLOCK("MOBILE_OUTLOOK_BLOCK"), + WINDOWS_OUTLOOK_BLOCK("WINDOWS_OUTLOOK_BLOCK"), + MAC_OUTLOOK_BLOCK("MAC_OUTLOOK_BLOCK"), + MAC_OLD_OUTLOOK_BLOCK("MAC_OLD_OUTLOOK_BLOCK"), + NOT_CONFIGURED("NOT_CONFIGURED"); + + private final String name; + + EmailOutlookAccessPolicy(String name) { + this.name = name; + } + + public boolean equalsName(String thatName) { + return name.equals(thatName); + } + + public String toString() { + return name; + } +} diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/enums/GraceAllowedPolicy.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/enums/GraceAllowedPolicy.java new file mode 100644 index 0000000000..dbcb9668df --- /dev/null +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/enums/GraceAllowedPolicy.java @@ -0,0 +1,41 @@ +/* + * 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.common.bean.enums; + +public enum GraceAllowedPolicy { + NEW_AND_EXISTING("NEW_AND_EXISTING"), + EXISTING_ONLY("EXISTING_ONLY"), + NEW_ONLY("NEW_ONLY"), + NOT_ALLOWED("NOT_ALLOWED"); + + private final String name; + + GraceAllowedPolicy(String name) { + this.name = name; + } + + public boolean equalsName(String thatName) { + return name.equals(thatName); + } + + public String toString() { + return name; + } +} diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/enums/POPIMAPAccessPolicy.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/enums/POPIMAPAccessPolicy.java new file mode 100644 index 0000000000..9847c1155a --- /dev/null +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/enums/POPIMAPAccessPolicy.java @@ -0,0 +1,40 @@ +/* + * 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.common.bean.enums; + +public enum POPIMAPAccessPolicy { + ALLOW("ALLOW"), + BLOCK("BLOCK"), + NOT_CONFIGURED("NOT_CONFIGURED"); + + private final String name; + + POPIMAPAccessPolicy(String name) { + this.name = name; + } + + public boolean equalsName(String thatName) { + return name.equals(thatName); + } + + public String toString() { + return name; + } +} diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/enums/WebOutlookAccessPolicy.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/enums/WebOutlookAccessPolicy.java new file mode 100644 index 0000000000..660afe6d0d --- /dev/null +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/enums/WebOutlookAccessPolicy.java @@ -0,0 +1,40 @@ +/* + * 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.common.bean.enums; + +public enum WebOutlookAccessPolicy { + ALLOW("ALLOW"), + BLOCK("BLOCK"), + NOT_CONFIGURED("NOT_CONFIGURED"); + + private final String name; + + WebOutlookAccessPolicy(String name) { + this.name = name; + } + + public boolean equalsName(String thatName) { + return name.equals(thatName); + } + + public String toString() { + return name; + } +} diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/CEAPolicyUIConfiguration.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/CEAPolicyUIConfiguration.java new file mode 100644 index 0000000000..84f35b1fdf --- /dev/null +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/CEAPolicyUIConfiguration.java @@ -0,0 +1,40 @@ +/* + * 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.common.bean.ui; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + +@XmlRootElement(name = "CEAPolicyUIConfiguration") +public class CEAPolicyUIConfiguration { + private List serverUIConfigurations; + + public List getServerConfigurations() { + return serverUIConfigurations; + } + + @XmlElementWrapper(name = "ServerUIConfigurations", required = true) + @XmlElement(name = "ServerUIConfiguration") + public void setServerConfigurations(List serverUIConfigurations) { + this.serverUIConfigurations = serverUIConfigurations; + } +} diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/Checkbox.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/Checkbox.java new file mode 100644 index 0000000000..111fbd9427 --- /dev/null +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/Checkbox.java @@ -0,0 +1,47 @@ +/* + * 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.common.bean.ui; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "Checkbox") +public class Checkbox { + private String label; + private String value; + + public String getLabel() { + return label; + } + + @XmlElement(name = "Label", required = true) + public void setLabel(String label) { + this.label = label; + } + + public String getValue() { + return value; + } + + @XmlElement(name = "Value", required = true) + public void setValue(String value) { + this.value = value; + } +} diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/CheckboxGroup.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/CheckboxGroup.java new file mode 100644 index 0000000000..478ccc6f01 --- /dev/null +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/CheckboxGroup.java @@ -0,0 +1,50 @@ +/* + * 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.common.bean.ui; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + +@XmlRootElement(name = "CheckboxGroup") +public class CheckboxGroup { + private String name; + private List checkboxes; + + public String getName() { + return name; + } + + @XmlElement(name = "Name", required = true) + public void setName(String name) { + this.name = name; + } + + public List getCheckboxes() { + return checkboxes; + } + + @XmlElementWrapper(name = "Checkboxes", required = true) + @XmlElement(name = "Checkbox") + public void setCheckboxes(List checkboxes) { + this.checkboxes = checkboxes; + } +} diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/Entry.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/Entry.java new file mode 100644 index 0000000000..d9ef169086 --- /dev/null +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/Entry.java @@ -0,0 +1,137 @@ +/* + * 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.common.bean.ui; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "Entry") +public class Entry { + private String code; + private boolean required; + private String label; + private String tooltip; + private boolean hidden; + private Supportability supportability; + private String docLink; + private Input input; + private Select select; + private CheckboxGroup checkboxGroup; + private Switch inputSwitch; + + public String getCode() { + return code; + } + + @XmlElement(name = "Code", required = true) + public void setCode(String code) { + this.code = code; + } + + public boolean isRequired() { + return required; + } + + @XmlElement(name = "Required", defaultValue = "false") + public void setRequired(boolean required) { + this.required = required; + } + + public String getLabel() { + return label; + } + + @XmlElement(name = "Label", required = true) + public void setLabel(String label) { + this.label = label; + } + + public String getTooltip() { + return tooltip; + } + + @XmlElement(name = "Tooltip") + public void setTooltip(String tooltip) { + this.tooltip = tooltip; + } + + public boolean isHidden() { + return hidden; + } + + @XmlElement(name = "Hidden", defaultValue = "false") + public void setHidden(boolean hidden) { + this.hidden = hidden; + } + + public Supportability getSupportability() { + return supportability; + } + + @XmlElement(name = "Supportability") + public void setSupportability(Supportability supportability) { + this.supportability = supportability; + } + + public String getDocLink() { + return docLink; + } + + @XmlElement(name = "DocLink") + public void setDocLink(String docLink) { + this.docLink = docLink; + } + + public Input getInput() { + return input; + } + + @XmlElement(name = "Input", nillable = true) + public void setInput(Input input) { + this.input = input; + } + + public Select getSelect() { + return select; + } + + @XmlElement(name = "Select", nillable = true) + public void setSelect(Select select) { + this.select = select; + } + + public CheckboxGroup getCheckboxGroup() { + return checkboxGroup; + } + + @XmlElement(name = "CheckboxGroup", nillable = true) + public void setCheckboxGroup(CheckboxGroup checkboxGroup) { + this.checkboxGroup = checkboxGroup; + } + + public Switch getInputSwitch() { + return inputSwitch; + } + + @XmlElement(name = "Switch", nillable = true) + public void setInputSwitch(Switch inputSwitch) { + this.inputSwitch = inputSwitch; + } +} diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/Input.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/Input.java new file mode 100644 index 0000000000..52c6b30d75 --- /dev/null +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/Input.java @@ -0,0 +1,57 @@ +/* + * 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.common.bean.ui; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "Input") +public class Input { + private String name; + private String placeholder; + private String type; + + public String getName() { + return name; + } + + @XmlElement(name = "Name", required = true) + public void setName(String name) { + this.name = name; + } + + public String getPlaceholder() { + return placeholder; + } + + @XmlElement(name = "Placeholder", required = true) + public void setPlaceholder(String placeholder) { + this.placeholder = placeholder; + } + + public String getType() { + return type; + } + + @XmlElement(name = "Type", required = true) + public void setType(String type) { + this.type = type; + } +} diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/Option.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/Option.java new file mode 100644 index 0000000000..41e5b14a27 --- /dev/null +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/Option.java @@ -0,0 +1,47 @@ +/* + * 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.common.bean.ui; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement(name = "Option") +public class Option { + private String value; + private String label; + + public String getValue() { + return value; + } + + @XmlElement(name = "Value", required = true) + public void setValue(String value) { + this.value = value; + } + + public String getLabel() { + return label; + } + + @XmlElement(name = "Label", required = true) + public void setLabel(String label) { + this.label = label; + } +} diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/PolicyEntries.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/PolicyEntries.java new file mode 100644 index 0000000000..a631559ee4 --- /dev/null +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/PolicyEntries.java @@ -0,0 +1,62 @@ +/* + * 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.common.bean.ui; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + +@XmlRootElement(name = "PolicyEntries") +public class PolicyEntries { + private List activeSyncServerEntries; + private List conditionalAccessPolicyEntries; + private List gracePeriodEntries; + + public List getActiveSyncServerEntries() { + return activeSyncServerEntries; + } + + @XmlElementWrapper(name = "ActiveSyncServerEntries", required = true) + @XmlElement(name = "Entry", required = true) + public void setActiveSyncServerEntries(List activeSyncServerEntries) { + this.activeSyncServerEntries = activeSyncServerEntries; + } + + public List getConditionalAccessPolicyEntries() { + return conditionalAccessPolicyEntries; + } + + @XmlElementWrapper(name = "ConditionalAccessPolicyEntries", required = true) + @XmlElement(name = "Entry", required = true) + public void setConditionalAccessPolicyEntries(List conditionalAccessPolicyEntries) { + this.conditionalAccessPolicyEntries = conditionalAccessPolicyEntries; + } + + public List getGracePeriodEntries() { + return gracePeriodEntries; + } + + @XmlElementWrapper(name = "GracePeriodEntries", required = true) + @XmlElement(name = "Entry", required = true) + public void setGracePeriodEntries(List gracePeriodEntries) { + this.gracePeriodEntries = gracePeriodEntries; + } +} diff --git a/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/Select.java b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/Select.java new file mode 100644 index 0000000000..e51bc4202a --- /dev/null +++ b/components/cea-mgt/io.entgra.device.mgt.core.cea.mgt.common/src/main/java/io/entgra/device/mgt/core/cea/mgt/common/bean/ui/Select.java @@ -0,0 +1,60 @@ +/* + * 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.common.bean.ui; + +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlElementWrapper; +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + +@XmlRootElement(name = "Select") +public class Select { + private String name; + private String placeholder; + private List