From 520c07693dc0123bb68b5445e9118f71ea45b3e1 Mon Sep 17 00:00:00 2001 From: harshanl Date: Mon, 2 Nov 2015 20:45:43 +0530 Subject: [PATCH 1/5] Added support for non-secured endpoints within a security enabled webapp --- .../framework/WebappAuthenticationValve.java | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticationValve.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticationValve.java index bdc5428984f..f6f077e100b 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticationValve.java +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticationValve.java @@ -29,6 +29,7 @@ import org.wso2.carbon.webapp.authenticator.framework.authenticator.WebappAuthen import javax.servlet.http.HttpServletResponse; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import java.util.StringTokenizer; @@ -36,6 +37,7 @@ public class WebappAuthenticationValve extends CarbonTomcatValve { private static final Log log = LogFactory.getLog(WebappAuthenticationValve.class); private static final String BYPASS_URIS = "bypass-uris"; + private static HashMap nonSecuredEndpoints = new HashMap<>(); @Override public void invoke(Request request, Response response, CompositeValve compositeValve) { @@ -90,7 +92,7 @@ public class WebappAuthenticationValve extends CarbonTomcatValve { private boolean skipAuthentication(Request request) { String param = request.getContext().findParameter("doAuthentication"); - return (param == null || !Boolean.parseBoolean(param)); + return (param == null || !Boolean.parseBoolean(param) || isNonSecuredEndPoint(request)); } private boolean isContextSkipped(Request request) { @@ -112,6 +114,35 @@ public class WebappAuthenticationValve extends CarbonTomcatValve { return (ctx.equalsIgnoreCase("carbon") || ctx.equalsIgnoreCase("services")); } + private boolean isNonSecuredEndPoint(Request request) { + String uri = request.getRequestURI(); + if(!uri.endsWith("/")) { + uri = uri + "/"; + } + String ctx = request.getContextPath(); + //Check the context in nonSecuredEndpoints. If so it means current context is a skippedContext. + if (nonSecuredEndpoints.containsKey(uri)) { + return true; + } + String param = request.getContext().findParameter("nonSecuredEndPoints"); + String skippedEndPoint; + if (param != null && !param.isEmpty()) { + //Add the nonSecured end-points to cache + StringTokenizer tokenizer = new StringTokenizer(param, ","); + while (tokenizer.hasMoreTokens()) { + skippedEndPoint = ctx + tokenizer.nextToken(); + if(!skippedEndPoint.endsWith("/")) { + skippedEndPoint = skippedEndPoint + "/"; + } + nonSecuredEndpoints.put(skippedEndPoint, "true"); + } + if (nonSecuredEndpoints.containsKey(uri)) { + return true; + } + } + return false; + } + private void processRequest(Request request, Response response, CompositeValve compositeValve, AuthenticationInfo authenticationInfo) { switch (authenticationInfo.getStatus()) { @@ -121,7 +152,7 @@ public class WebappAuthenticationValve extends CarbonTomcatValve { break; case FAILURE: String msg = "Failed to authorize incoming request"; - if(authenticationInfo.getMessage() != null && !authenticationInfo.getMessage().isEmpty()) { + if (authenticationInfo.getMessage() != null && !authenticationInfo.getMessage().isEmpty()) { msg = authenticationInfo.getMessage(); response.setHeader("WWW-Authenticate", msg); } @@ -132,5 +163,4 @@ public class WebappAuthenticationValve extends CarbonTomcatValve { break; } } - -} +} \ No newline at end of file From e2072e1b189d3ef779b0317de120b1a0d7cded2c Mon Sep 17 00:00:00 2001 From: Kamidu Sachith Date: Tue, 3 Nov 2015 11:06:38 +0530 Subject: [PATCH 2/5] Version bump for carbon deployment --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 40d1b95b4b7..8de2ac5bd6e 100644 --- a/pom.xml +++ b/pom.xml @@ -1465,7 +1465,7 @@ 7.0.34.wso2v2 - 4.5.2 + 4.6.0-alpha 4.6.0-SNAPSHOT From 473c06f34763a3dd8d3840f18b7b731f3da5f0cd Mon Sep 17 00:00:00 2001 From: Dileesha Rajapakse Date: Tue, 3 Nov 2015 13:56:02 +0530 Subject: [PATCH 3/5] Refactored oracle DB script --- .../main/resources/dbscripts/cdm/oracle.sql | 837 +++++++++--------- 1 file changed, 428 insertions(+), 409 deletions(-) diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql index cc3713817e8..2af12dc572d 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/dbscripts/cdm/oracle.sql @@ -1,173 +1,187 @@ CREATE TABLE DM_DEVICE_TYPE ( - ID NUMBER(10) NOT NULL, - NAME VARCHAR2(300) DEFAULT NULL, - PRIMARY KEY (ID) -); - + ID NUMBER(10) NOT NULL, + NAME VARCHAR2(300) DEFAULT NULL, + CONSTRAINT PK_DM_DEVICE_TYPE PRIMARY KEY (ID) +) +/ -- Generate ID using sequence and trigger -CREATE SEQUENCE DM_DEVICE_TYPE_seq START WITH 1 INCREMENT BY 1; - +CREATE SEQUENCE DM_DEVICE_TYPE_seq START WITH 1 INCREMENT BY 1 NOCACHE +/ CREATE OR REPLACE TRIGGER DM_DEVICE_TYPE_seq_tr - BEFORE INSERT ON DM_DEVICE_TYPE FOR EACH ROW - WHEN (NEW.ID IS NULL) -BEGIN - SELECT DM_DEVICE_TYPE_seq.NEXTVAL INTO :NEW.ID FROM DUAL; -END; +BEFORE INSERT +ON DM_DEVICE_TYPE +REFERENCING NEW AS NEW +FOR EACH ROW +WHEN (NEW.ID IS NULL) + BEGIN + SELECT DM_DEVICE_TYPE_seq.NEXTVAL INTO :NEW.ID FROM DUAL; + END; / CREATE TABLE DM_DEVICE ( - ID NUMBER(10) NOT NULL, - DESCRIPTION CLOB DEFAULT NULL, - NAME VARCHAR2(100) DEFAULT NULL, - DEVICE_TYPE_ID NUMBER(10) DEFAULT NULL, - DEVICE_IDENTIFICATION VARCHAR2(300) DEFAULT NULL, - TENANT_ID NUMBER(10) DEFAULT 0, - PRIMARY KEY (ID), - CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID ) - REFERENCES DM_DEVICE_TYPE (ID) -); - + ID NUMBER(10) NOT NULL, + DESCRIPTION CLOB DEFAULT NULL, + NAME VARCHAR2(100) DEFAULT NULL, + DEVICE_TYPE_ID NUMBER(10) DEFAULT NULL, + DEVICE_IDENTIFICATION VARCHAR2(300) DEFAULT NULL, + TENANT_ID NUMBER(10) DEFAULT 0, + CONSTRAINT PK_DM_DEVICE PRIMARY KEY (ID), + CONSTRAINT fk_DM_DEVICE_DM_DEVICE_TYPE2 FOREIGN KEY (DEVICE_TYPE_ID ) + REFERENCES DM_DEVICE_TYPE (ID) +) +/ -- Generate ID using sequence and trigger -CREATE SEQUENCE DM_DEVICE_seq START WITH 1 INCREMENT BY 1; - +CREATE SEQUENCE DM_DEVICE_seq START WITH 1 INCREMENT BY 1 NOCACHE +/ CREATE OR REPLACE TRIGGER DM_DEVICE_seq_tr - BEFORE INSERT ON DM_DEVICE FOR EACH ROW - WHEN (NEW.ID IS NULL) -BEGIN - SELECT DM_DEVICE_seq.NEXTVAL INTO :NEW.ID FROM DUAL; -END; +BEFORE INSERT +ON DM_DEVICE +REFERENCING NEW AS NEW +FOR EACH ROW +WHEN (NEW.ID IS NULL) + BEGIN + SELECT DM_DEVICE_seq.NEXTVAL INTO :NEW.ID FROM DUAL; + END; / CREATE TABLE DM_OPERATION ( - ID NUMBER(10) NOT NULL, - TYPE VARCHAR2(50) NOT NULL, - CREATED_TIMESTAMP TIMESTAMP(0) NOT NULL, - RECEIVED_TIMESTAMP TIMESTAMP(0) NULL, - OPERATION_CODE VARCHAR2(1000) NOT NULL, - PRIMARY KEY (ID) -); - + ID NUMBER(10) NOT NULL, + TYPE VARCHAR2(50) NOT NULL, + CREATED_TIMESTAMP TIMESTAMP(0) NOT NULL, + RECEIVED_TIMESTAMP TIMESTAMP(0) NULL, + OPERATION_CODE VARCHAR2(1000) NOT NULL, + CONSTRAINT PK_DM_OPERATION PRIMARY KEY (ID) +) +/ -- Generate ID using sequence and trigger -CREATE SEQUENCE DM_OPERATION_seq START WITH 1 INCREMENT BY 1; - +CREATE SEQUENCE DM_OPERATION_seq START WITH 1 INCREMENT BY 1 NOCACHE +/ CREATE OR REPLACE TRIGGER DM_OPERATION_seq_tr - BEFORE INSERT ON DM_OPERATION FOR EACH ROW - WHEN (NEW.ID IS NULL) -BEGIN - SELECT DM_OPERATION_seq.NEXTVAL INTO :NEW.ID FROM DUAL; -END; +BEFORE INSERT +ON DM_OPERATION +REFERENCING NEW AS NEW +FOR EACH ROW +WHEN (NEW.ID IS NULL) + BEGIN + SELECT DM_OPERATION_seq.NEXTVAL INTO :NEW.ID FROM DUAL; + END; / CREATE TABLE DM_CONFIG_OPERATION ( - OPERATION_ID NUMBER(10) NOT NULL, - OPERATION_CONFIG BLOB DEFAULT NULL, - PRIMARY KEY (OPERATION_ID), - CONSTRAINT fk_dm_operation_config FOREIGN KEY (OPERATION_ID) REFERENCES + OPERATION_ID NUMBER(10) NOT NULL, + OPERATION_CONFIG BLOB DEFAULT NULL, + CONSTRAINT PK_DM_CONFIG_OPERATION PRIMARY KEY (OPERATION_ID), + CONSTRAINT fk_dm_operation_config FOREIGN KEY (OPERATION_ID) REFERENCES DM_OPERATION (ID) -); - +) +/ CREATE TABLE DM_COMMAND_OPERATION ( - OPERATION_ID NUMBER(10) NOT NULL, - ENABLED CHAR(1) DEFAULT FALSE NOT NULL, - PRIMARY KEY (OPERATION_ID), - CONSTRAINT fk_dm_operation_command FOREIGN KEY (OPERATION_ID) REFERENCES + OPERATION_ID NUMBER(10) NOT NULL, + ENABLED NUMBER(10) DEFAULT 0 NOT NULL, + CONSTRAINT PK_DM_COMMAND_OPERATION PRIMARY KEY (OPERATION_ID), + CONSTRAINT fk_dm_operation_command FOREIGN KEY (OPERATION_ID) REFERENCES DM_OPERATION (ID) -); - +) +/ CREATE TABLE DM_POLICY_OPERATION ( - OPERATION_ID NUMBER(10) NOT NULL, - ENABLED NUMBER(10) DEFAULT 0 NOT NULL, - OPERATION_DETAILS BLOB DEFAULT NULL, - PRIMARY KEY (OPERATION_ID), - CONSTRAINT fk_dm_operation_policy FOREIGN KEY (OPERATION_ID) REFERENCES + OPERATION_ID NUMBER(10) NOT NULL, + ENABLED NUMBER(10) DEFAULT 0 NOT NULL, + OPERATION_DETAILS BLOB DEFAULT NULL, + CONSTRAINT PK_DM_POLICY_OPERATION PRIMARY KEY (OPERATION_ID), + CONSTRAINT fk_dm_operation_policy FOREIGN KEY (OPERATION_ID) REFERENCES DM_OPERATION (ID) -); - +) +/ CREATE TABLE DM_PROFILE_OPERATION ( - OPERATION_ID NUMBER(10) NOT NULL, - ENABLED NUMBER(10) DEFAULT 0 NOT NULL, - OPERATION_DETAILS BLOB DEFAULT NULL, - PRIMARY KEY (OPERATION_ID), - CONSTRAINT fk_dm_operation_profile FOREIGN KEY (OPERATION_ID) REFERENCES + OPERATION_ID NUMBER(10) NOT NULL, + ENABLED NUMBER(10) DEFAULT 0 NOT NULL, + OPERATION_DETAILS BLOB DEFAULT NULL, + CONSTRAINT PK_DM_PROFILE_OPERATION PRIMARY KEY (OPERATION_ID), + CONSTRAINT fk_dm_operation_profile FOREIGN KEY (OPERATION_ID) REFERENCES DM_OPERATION (ID) -); - +) +/ CREATE TABLE DM_ENROLMENT ( - ID NUMBER(10) NOT NULL, - DEVICE_ID NUMBER(10) NOT NULL, - OWNER VARCHAR2(50) NOT NULL, - OWNERSHIP VARCHAR2(45) DEFAULT NULL, - STATUS VARCHAR2(50) NULL, - DATE_OF_ENROLMENT TIMESTAMP(0) DEFAULT NULL, - DATE_OF_LAST_UPDATE TIMESTAMP(0) DEFAULT NULL, - TENANT_ID NUMBER(10) NOT NULL, - PRIMARY KEY (ID), - CONSTRAINT fk_dm_device_enrolment FOREIGN KEY (DEVICE_ID) REFERENCES + ID NUMBER(10) NOT NULL, + DEVICE_ID NUMBER(10) NOT NULL, + OWNER VARCHAR2(50) NOT NULL, + OWNERSHIP VARCHAR2(45) DEFAULT NULL, + STATUS VARCHAR2(50) NULL, + DATE_OF_ENROLMENT TIMESTAMP(0) DEFAULT NULL, + DATE_OF_LAST_UPDATE TIMESTAMP(0) DEFAULT NULL, + TENANT_ID NUMBER(10) NOT NULL, + CONSTRAINT PK_DM_ENROLMENT PRIMARY KEY (ID), + CONSTRAINT fk_dm_device_enrolment FOREIGN KEY (DEVICE_ID) REFERENCES DM_DEVICE (ID) -); - +) +/ -- Generate ID using sequence and trigger -CREATE SEQUENCE DM_ENROLMENT_seq START WITH 1 INCREMENT BY 1; - +CREATE SEQUENCE DM_ENROLMENT_seq START WITH 1 INCREMENT BY 1 NOCACHE +/ CREATE OR REPLACE TRIGGER DM_ENROLMENT_seq_tr - BEFORE INSERT ON DM_ENROLMENT FOR EACH ROW - WHEN (NEW.ID IS NULL) -BEGIN - SELECT DM_ENROLMENT_seq.NEXTVAL INTO :NEW.ID FROM DUAL; -END; -/ - -CREATE TABLE DM_ENROLMENT_OP_MAPPING ( - ID NUMBER(10) NOT NULL, - ENROLMENT_ID NUMBER(10) NOT NULL, - OPERATION_ID NUMBER(10) NOT NULL, - STATUS VARCHAR2(50) NULL, - PRIMARY KEY (ID), - CONSTRAINT fk_dm_device_operation_mapping_device FOREIGN KEY (ENROLMENT_ID) REFERENCES +BEFORE INSERT +ON DM_ENROLMENT +REFERENCING NEW AS NEW +FOR EACH ROW +WHEN (NEW.ID IS NULL) + BEGIN + SELECT DM_ENROLMENT_seq.NEXTVAL INTO :NEW.ID FROM DUAL; + END; +/ + +CREATE TABLE DM_ENROLMENT_op_map ( + ID NUMBER(10) NOT NULL, + ENROLMENT_ID NUMBER(10) NOT NULL, + OPERATION_ID NUMBER(10) NOT NULL, + STATUS VARCHAR2(50) NULL, + PRIMARY KEY (ID), + CONSTRAINT fk_dm_device_op_map_device FOREIGN KEY (ENROLMENT_ID) REFERENCES DM_ENROLMENT (ID), - CONSTRAINT fk_dm_device_operation_mapping_operation FOREIGN KEY (OPERATION_ID) REFERENCES + CONSTRAINT fk_dm_device_op_map_operation FOREIGN KEY (OPERATION_ID) REFERENCES DM_OPERATION (ID) -); - +) +/ -- Generate ID using sequence and trigger -CREATE SEQUENCE DM_ENROLMENT_OP_MAPPING_seq START WITH 1 INCREMENT BY 1; - -CREATE OR REPLACE TRIGGER DM_ENROLMENT_OP_MAPPING_seq_tr - BEFORE INSERT ON DM_ENROLMENT_OP_MAPPING FOR EACH ROW - WHEN (NEW.ID IS NULL) -BEGIN - SELECT DM_ENROLMENT_OP_MAPPING_seq.NEXTVAL INTO :NEW.ID FROM DUAL; -END; +CREATE SEQUENCE DM_ENROLMENT_op_map_seq START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER DM_ENROLMENT_op_map_seq_tr +BEFORE INSERT +ON DM_ENROLMENT_op_map +REFERENCING NEW AS NEW +FOR EACH ROW +WHEN (NEW.ID IS NULL) + BEGIN + SELECT DM_ENROLMENT_op_map_seq.NEXTVAL INTO :NEW.ID FROM DUAL; + END; / CREATE TABLE DM_DEVICE_OPERATION_RESPONSE ( - ID NUMBER(10) NOT NULL, - DEVICE_ID NUMBER(10) NOT NULL, - OPERATION_ID NUMBER(10) NOT NULL, - OPERATION_RESPONSE BLOB DEFAULT NULL, - PRIMARY KEY (ID), - CONSTRAINT fk_dm_device_operation_response_device FOREIGN KEY (DEVICE_ID) REFERENCES + ID NUMBER(10) NOT NULL, + DEVICE_ID NUMBER(10) NOT NULL, + OPERATION_ID NUMBER(10) NOT NULL, + OPERATION_RESPONSE BLOB DEFAULT NULL, + CONSTRAINT PK_DM_DEVICE_OP_RESPONSE PRIMARY KEY (ID), + CONSTRAINT fk_dm_device_op_res_device FOREIGN KEY (DEVICE_ID) REFERENCES DM_DEVICE (ID), - CONSTRAINT fk_dm_device_operation_response_operation FOREIGN KEY (OPERATION_ID) REFERENCES + CONSTRAINT fk_dm_device_op_res_operation FOREIGN KEY (OPERATION_ID) REFERENCES DM_OPERATION (ID) -); - +) +/ -- Generate ID using sequence and trigger -CREATE SEQUENCE DM_DEVICE_OPERATION_RESPONSE_seq START WITH 1 INCREMENT BY 1; - -CREATE OR REPLACE TRIGGER DM_DEVICE_OPERATION_RESPONSE_seq_tr - BEFORE INSERT ON DM_DEVICE_OPERATION_RESPONSE FOR EACH ROW - WHEN (NEW.ID IS NULL) -BEGIN - SELECT DM_DEVICE_OPERATION_RESPONSE_seq.NEXTVAL INTO :NEW.ID FROM DUAL; -END; +CREATE SEQUENCE DM_DEVICE_OP_RESPONSE_seq START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER DM_DEVICE_OP_RESPONSE_seq_tr +BEFORE INSERT +ON DM_DEVICE_OPERATION_RESPONSE +REFERENCING NEW AS NEW +FOR EACH ROW +WHEN (NEW.ID IS NULL) + BEGIN + SELECT DM_DEVICE_OP_RESPONSE_seq.NEXTVAL INTO :NEW.ID FROM DUAL; + END; / -- POLICY RELATED TABLES --- - - - - CREATE TABLE DM_PROFILE ( ID NUMBER(10) NOT NULL , PROFILE_NAME VARCHAR2(45) NOT NULL , @@ -175,27 +189,27 @@ CREATE TABLE DM_PROFILE ( DEVICE_TYPE_ID NUMBER(10) NOT NULL , CREATED_TIME TIMESTAMP(0) NOT NULL , UPDATED_TIME TIMESTAMP(0) NOT NULL , - PRIMARY KEY (ID) , + CONSTRAINT PK_DM_PROFILE PRIMARY KEY (ID) , CONSTRAINT DM_PROFILE_DEVICE_TYPE - FOREIGN KEY (DEVICE_TYPE_ID ) - REFERENCES DM_DEVICE_TYPE (ID ) -); - + FOREIGN KEY (DEVICE_TYPE_ID ) + REFERENCES DM_DEVICE_TYPE (ID ) +) +/ -- Generate ID using sequence and trigger -CREATE SEQUENCE DM_PROFILE_seq START WITH 1 INCREMENT BY 1; - +CREATE SEQUENCE DM_PROFILE_seq START WITH 1 INCREMENT BY 1 NOCACHE +/ CREATE OR REPLACE TRIGGER DM_PROFILE_seq_tr - BEFORE INSERT ON DM_PROFILE FOR EACH ROW - WHEN (NEW.ID IS NULL) -BEGIN - SELECT DM_PROFILE_seq.NEXTVAL INTO :NEW.ID FROM DUAL; -END; +BEFORE INSERT +ON DM_PROFILE +REFERENCING NEW AS NEW +FOR EACH ROW +WHEN (NEW.ID IS NULL) + BEGIN + SELECT DM_PROFILE_seq.NEXTVAL INTO :NEW.ID FROM DUAL; + END; / - - - CREATE TABLE DM_POLICY ( ID NUMBER(10) NOT NULL , NAME VARCHAR2(45) DEFAULT NULL , @@ -207,72 +221,70 @@ CREATE TABLE DM_POLICY ( PRIORITY NUMBER(10) NOT NULL, ACTIVE NUMBER(10) NOT NULL, UPDATED NUMBER(10) NULL, - PRIMARY KEY (ID) , + CONSTRAINT PK_DM_PROFILE_DM_POLICY PRIMARY KEY (ID) , CONSTRAINT FK_DM_PROFILE_DM_POLICY - FOREIGN KEY (PROFILE_ID ) - REFERENCES DM_PROFILE (ID ) -); - + FOREIGN KEY (PROFILE_ID ) + REFERENCES DM_PROFILE (ID ) +) +/ -- Generate ID using sequence and trigger -CREATE SEQUENCE DM_POLICY_seq START WITH 1 INCREMENT BY 1; - +CREATE SEQUENCE DM_POLICY_seq START WITH 1 INCREMENT BY 1 NOCACHE +/ CREATE OR REPLACE TRIGGER DM_POLICY_seq_tr - BEFORE INSERT ON DM_POLICY FOR EACH ROW - WHEN (NEW.ID IS NULL) -BEGIN - SELECT DM_POLICY_seq.NEXTVAL INTO :NEW.ID FROM DUAL; -END; +BEFORE INSERT +ON DM_POLICY +REFERENCING NEW AS NEW +FOR EACH ROW +WHEN (NEW.ID IS NULL) + BEGIN + SELECT DM_POLICY_seq.NEXTVAL INTO :NEW.ID FROM DUAL; + END; / - - CREATE TABLE DM_DEVICE_POLICY ( ID NUMBER(10) NOT NULL , DEVICE_ID NUMBER(10) NOT NULL , ENROLMENT_ID NUMBER(10) NOT NULL, DEVICE BLOB NOT NULL, POLICY_ID NUMBER(10) NOT NULL , - PRIMARY KEY (ID) , + CONSTRAINT PK_POLICY_DEVICE_POLICY PRIMARY KEY (ID) , CONSTRAINT FK_POLICY_DEVICE_POLICY - FOREIGN KEY (POLICY_ID ) - REFERENCES DM_POLICY (ID ) - , + FOREIGN KEY (POLICY_ID ) + REFERENCES DM_POLICY (ID ), CONSTRAINT FK_DEVICE_DEVICE_POLICY - FOREIGN KEY (DEVICE_ID ) - REFERENCES DM_DEVICE (ID ) -); - + FOREIGN KEY (DEVICE_ID ) + REFERENCES DM_DEVICE (ID ) +) +/ -- Generate ID using sequence and trigger -CREATE SEQUENCE DM_DEVICE_POLICY_seq START WITH 1 INCREMENT BY 1; - +CREATE SEQUENCE DM_DEVICE_POLICY_seq START WITH 1 INCREMENT BY 1 NOCACHE +/ CREATE OR REPLACE TRIGGER DM_DEVICE_POLICY_seq_tr - BEFORE INSERT ON DM_DEVICE_POLICY FOR EACH ROW - WHEN (NEW.ID IS NULL) -BEGIN - SELECT DM_DEVICE_POLICY_seq.NEXTVAL INTO :NEW.ID FROM DUAL; -END; +BEFORE INSERT +ON DM_DEVICE_POLICY +REFERENCING NEW AS NEW +FOR EACH ROW +WHEN (NEW.ID IS NULL) + BEGIN + SELECT DM_DEVICE_POLICY_seq.NEXTVAL INTO :NEW.ID FROM DUAL; + END; / - - CREATE TABLE DM_DEVICE_TYPE_POLICY ( ID NUMBER(10) NOT NULL , DEVICE_TYPE_ID NUMBER(10) NOT NULL , POLICY_ID NUMBER(10) NOT NULL , - PRIMARY KEY (ID) , - CONSTRAINT FK_DEVICE_TYPE_POLICY - FOREIGN KEY (POLICY_ID ) - REFERENCES DM_POLICY (ID ) - , - CONSTRAINT FK_DEVICE_TYPE_POLICY_DEVICE_TYPE - FOREIGN KEY (DEVICE_TYPE_ID ) - REFERENCES DM_DEVICE_TYPE (ID ) -); - - - + CONSTRAINT PK_DEV_TYPE_POLICY PRIMARY KEY (ID) , + CONSTRAINT FK_DEV_TYPE_POLICY + FOREIGN KEY (POLICY_ID ) + REFERENCES DM_POLICY (ID ), + CONSTRAINT FK_DEV_TYPE_POLICY_DEV_TYPE + FOREIGN KEY (DEVICE_TYPE_ID ) + REFERENCES DM_DEVICE_TYPE (ID ) +) +/ CREATE TABLE DM_PROFILE_FEATURES ( @@ -282,73 +294,78 @@ CREATE TABLE DM_PROFILE_FEATURES ( DEVICE_TYPE_ID NUMBER(10) NOT NULL, TENANT_ID NUMBER(10) NOT NULL , CONTENT BLOB DEFAULT NULL NULL, - PRIMARY KEY (ID), - CONSTRAINT FK_DM_PROFILE_DM_POLICY_FEATURES - FOREIGN KEY (PROFILE_ID) - REFERENCES DM_PROFILE (ID) -); + CONSTRAINT PK_DM_PROF_DM_POLICY_FEATURES PRIMARY KEY (ID), + CONSTRAINT FK_DM_PROF_DM_POLICY_FEATURES + FOREIGN KEY (PROFILE_ID) + REFERENCES DM_PROFILE (ID) +) +/ -- Generate ID using sequence and trigger -CREATE SEQUENCE DM_PROFILE_FEATURES_seq START WITH 1 INCREMENT BY 1; - +CREATE SEQUENCE DM_PROFILE_FEATURES_seq START WITH 1 INCREMENT BY 1 NOCACHE +/ CREATE OR REPLACE TRIGGER DM_PROFILE_FEATURES_seq_tr - BEFORE INSERT ON DM_PROFILE_FEATURES FOR EACH ROW - WHEN (NEW.ID IS NULL) -BEGIN - SELECT DM_PROFILE_FEATURES_seq.NEXTVAL INTO :NEW.ID FROM DUAL; -END; +BEFORE INSERT +ON DM_PROFILE_FEATURES +REFERENCING NEW AS NEW +FOR EACH ROW +WHEN (NEW.ID IS NULL) + BEGIN + SELECT DM_PROFILE_FEATURES_seq.NEXTVAL INTO :NEW.ID FROM DUAL; + END; / - - - CREATE TABLE DM_ROLE_POLICY ( ID NUMBER(10) NOT NULL , ROLE_NAME VARCHAR2(45) NOT NULL , POLICY_ID NUMBER(10) NOT NULL , - PRIMARY KEY (ID) , + CONSTRAINT PK_ROLE_POLICY_POLICY PRIMARY KEY (ID) , CONSTRAINT FK_ROLE_POLICY_POLICY - FOREIGN KEY (POLICY_ID ) - REFERENCES DM_POLICY (ID ) -); - + FOREIGN KEY (POLICY_ID ) + REFERENCES DM_POLICY (ID ) +) +/ -- Generate ID using sequence and trigger -CREATE SEQUENCE DM_ROLE_POLICY_seq START WITH 1 INCREMENT BY 1; - +CREATE SEQUENCE DM_ROLE_POLICY_seq START WITH 1 INCREMENT BY 1 NOCACHE +/ CREATE OR REPLACE TRIGGER DM_ROLE_POLICY_seq_tr - BEFORE INSERT ON DM_ROLE_POLICY FOR EACH ROW - WHEN (NEW.ID IS NULL) -BEGIN - SELECT DM_ROLE_POLICY_seq.NEXTVAL INTO :NEW.ID FROM DUAL; -END; +BEFORE INSERT +ON DM_ROLE_POLICY +REFERENCING NEW AS NEW +FOR EACH ROW +WHEN (NEW.ID IS NULL) + BEGIN + SELECT DM_ROLE_POLICY_seq.NEXTVAL INTO :NEW.ID FROM DUAL; + END; / - - CREATE TABLE DM_USER_POLICY ( ID NUMBER(10) NOT NULL , POLICY_ID NUMBER(10) NOT NULL , USERNAME VARCHAR2(45) NOT NULL , - PRIMARY KEY (ID) , - CONSTRAINT DM_POLICY_USER_POLICY - FOREIGN KEY (POLICY_ID ) - REFERENCES DM_POLICY (ID ) -); - + CONSTRAINT PK_DM_USER_POLICY PRIMARY KEY (ID) , + CONSTRAINT FK_DM_POLICY_USER_POLICY + FOREIGN KEY (POLICY_ID ) + REFERENCES DM_POLICY (ID ) +) +/ -- Generate ID using sequence and trigger -CREATE SEQUENCE DM_USER_POLICY_seq START WITH 1 INCREMENT BY 1; - +CREATE SEQUENCE DM_USER_POLICY_seq START WITH 1 INCREMENT BY 1 NOCACHE +/ CREATE OR REPLACE TRIGGER DM_USER_POLICY_seq_tr - BEFORE INSERT ON DM_USER_POLICY FOR EACH ROW - WHEN (NEW.ID IS NULL) -BEGIN - SELECT DM_USER_POLICY_seq.NEXTVAL INTO :NEW.ID FROM DUAL; -END; +BEFORE INSERT +ON DM_USER_POLICY +REFERENCING NEW AS NEW +FOR EACH ROW +WHEN (NEW.ID IS NULL) + BEGIN + SELECT DM_USER_POLICY_seq.NEXTVAL INTO :NEW.ID FROM DUAL; + END; / - CREATE TABLE DM_DEVICE_POLICY_APPLIED ( +CREATE TABLE DM_DEVICE_POLICY_APPLIED ( ID NUMBER(10) NOT NULL , DEVICE_ID NUMBER(10) NOT NULL , ENROLMENT_ID NUMBER(10) NOT NULL, @@ -359,68 +376,75 @@ END; CREATED_TIME TIMESTAMP(0) NULL , UPDATED_TIME TIMESTAMP(0) NULL , APPLIED_TIME TIMESTAMP(0) NULL , - PRIMARY KEY (ID) , - CONSTRAINT FK_DM_POLICY_DEVCIE_APPLIED - FOREIGN KEY (DEVICE_ID ) - REFERENCES DM_DEVICE (ID ) -); - + CONSTRAINT PK_DM_POLICY_DEV_APPLIED PRIMARY KEY (ID) , + CONSTRAINT FK_DM_POLICY_DEV_APPLIED + FOREIGN KEY (DEVICE_ID ) + REFERENCES DM_DEVICE (ID ), + CONSTRAINT FK_DM_POLICY_DEV_APPLY_POLICY + FOREIGN KEY (POLICY_ID ) + REFERENCES DM_POLICY (ID ) +) +/ -- Generate ID using sequence and trigger -CREATE SEQUENCE DM_DEVICE_POLICY_APPLIED_seq START WITH 1 INCREMENT BY 1; - -CREATE OR REPLACE TRIGGER DM_DEVICE_POLICY_APPLIED_seq_tr - BEFORE INSERT ON DM_DEVICE_POLICY_APPLIED FOR EACH ROW - WHEN (NEW.ID IS NULL) - BEGIN - SELECT DM_DEVICE_POLICY_APPLIED_seq.NEXTVAL INTO :NEW.ID FROM DUAL; -END; +CREATE SEQUENCE DM_DEVICE_POLICY_APPLIED_seq START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER DM_DEV_POLICY_APPLIED_seq_tr +BEFORE INSERT +ON DM_DEVICE_POLICY_APPLIED +REFERENCING NEW AS NEW +FOR EACH ROW +WHEN (NEW.ID IS NULL) + BEGIN + SELECT DM_DEVICE_POLICY_APPLIED_seq.NEXTVAL INTO :NEW.ID FROM DUAL; + END; / - - CREATE TABLE DM_CRITERIA ( ID NUMBER(10) NOT NULL, TENANT_ID NUMBER(10) NOT NULL, NAME VARCHAR2(50) NULL, - PRIMARY KEY (ID) -); - + CONSTRAINT PK_DM_CRITERIA PRIMARY KEY (ID) +) +/ -- Generate ID using sequence and trigger -CREATE SEQUENCE DM_CRITERIA_seq START WITH 1 INCREMENT BY 1; - +CREATE SEQUENCE DM_CRITERIA_seq START WITH 1 INCREMENT BY 1 NOCACHE +/ CREATE OR REPLACE TRIGGER DM_CRITERIA_seq_tr - BEFORE INSERT ON DM_CRITERIA FOR EACH ROW - WHEN (NEW.ID IS NULL) -BEGIN - SELECT DM_CRITERIA_seq.NEXTVAL INTO :NEW.ID FROM DUAL; -END; +BEFORE INSERT +ON DM_CRITERIA +REFERENCING NEW AS NEW +FOR EACH ROW +WHEN (NEW.ID IS NULL) + BEGIN + SELECT DM_CRITERIA_seq.NEXTVAL INTO :NEW.ID FROM DUAL; + END; / - - CREATE TABLE DM_POLICY_CRITERIA ( ID NUMBER(10) NOT NULL, CRITERIA_ID NUMBER(10) NOT NULL, POLICY_ID NUMBER(10) NOT NULL, - PRIMARY KEY (ID), + CONSTRAINT PK_DM_POLICY_CRITERIA PRIMARY KEY (ID), CONSTRAINT FK_CRITERIA_POLICY_CRITERIA - FOREIGN KEY (CRITERIA_ID) - REFERENCES DM_CRITERIA (ID) - , + FOREIGN KEY (CRITERIA_ID) + REFERENCES DM_CRITERIA (ID), CONSTRAINT FK_POLICY_POLICY_CRITERIA - FOREIGN KEY (POLICY_ID) - REFERENCES DM_POLICY (ID) -); - + FOREIGN KEY (POLICY_ID) + REFERENCES DM_POLICY (ID) +) +/ -- Generate ID using sequence and trigger -CREATE SEQUENCE DM_POLICY_CRITERIA_seq START WITH 1 INCREMENT BY 1; - +CREATE SEQUENCE DM_POLICY_CRITERIA_seq START WITH 1 INCREMENT BY 1 NOCACHE +/ CREATE OR REPLACE TRIGGER DM_POLICY_CRITERIA_seq_tr - BEFORE INSERT ON DM_POLICY_CRITERIA FOR EACH ROW - WHEN (NEW.ID IS NULL) -BEGIN - SELECT DM_POLICY_CRITERIA_seq.NEXTVAL INTO :NEW.ID FROM DUAL; -END; +BEFORE INSERT +ON DM_POLICY_CRITERIA +REFERENCING NEW AS NEW +FOR EACH ROW +WHEN (NEW.ID IS NULL) + BEGIN + SELECT DM_POLICY_CRITERIA_seq.NEXTVAL INTO :NEW.ID FROM DUAL; + END; / CREATE TABLE DM_POLICY_CRITERIA_PROPERTIES ( @@ -429,22 +453,25 @@ CREATE TABLE DM_POLICY_CRITERIA_PROPERTIES ( PROP_KEY VARCHAR2(45) NULL, PROP_VALUE VARCHAR2(100) NULL, CONTENT BLOB NULL , - PRIMARY KEY (ID), - CONSTRAINT FK_POLICY_CRITERIA_PROPERTIES - FOREIGN KEY (POLICY_CRITERION_ID) - REFERENCES DM_POLICY_CRITERIA (ID) - ON DELETE CASCADE -); - + CONSTRAINT PK_DM_POLICY_CRITERIA_PROP PRIMARY KEY (ID), + CONSTRAINT FK_POLICY_CRITERIA_PROP + FOREIGN KEY (POLICY_CRITERION_ID) + REFERENCES DM_POLICY_CRITERIA (ID) + ON DELETE CASCADE +) +/ -- Generate ID using sequence and trigger -CREATE SEQUENCE DM_POLICY_CRITERIA_PROPERTIES_seq START WITH 1 INCREMENT BY 1; - -CREATE OR REPLACE TRIGGER DM_POLICY_CRITERIA_PROPERTIES_seq_tr - BEFORE INSERT ON DM_POLICY_CRITERIA_PROPERTIES FOR EACH ROW - WHEN (NEW.ID IS NULL) -BEGIN - SELECT DM_POLICY_CRITERIA_PROPERTIES_seq.NEXTVAL INTO :NEW.ID FROM DUAL; -END; +CREATE SEQUENCE DM_POLICY_CRITERIA_PROP_seq START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER DM_POLICY_CRITERIA_PROP_seq_tr +BEFORE INSERT +ON DM_POLICY_CRITERIA_PROPERTIES +REFERENCING NEW AS NEW +FOR EACH ROW +WHEN (NEW.ID IS NULL) + BEGIN + SELECT DM_POLICY_CRITERIA_PROP_seq.NEXTVAL INTO :NEW.ID FROM DUAL; + END; / CREATE TABLE DM_POLICY_COMPLIANCE_STATUS ( @@ -458,169 +485,161 @@ CREATE TABLE DM_POLICY_COMPLIANCE_STATUS ( LAST_REQUESTED_TIME TIMESTAMP(0) NULL, LAST_FAILED_TIME TIMESTAMP(0) NULL, ATTEMPTS NUMBER(10) NULL, - PRIMARY KEY (ID), + CONSTRAINT PK_DM_POLICY_COMP_STATUS PRIMARY KEY (ID), CONSTRAINT DEVICE_ID_UNIQUE UNIQUE (DEVICE_ID), - CONSTRAINT FK_POLICY_COMPLIANCE_STATUS_POLICY - FOREIGN KEY (POLICY_ID) - REFERENCES DM_POLICY (ID) -); - + CONSTRAINT FK_POLICY_COMP_STATUS_POLICY + FOREIGN KEY (POLICY_ID) + REFERENCES DM_POLICY (ID) +) +/ -- Generate ID using sequence and trigger -CREATE SEQUENCE DM_POLICY_COMPLIANCE_STATUS_seq START WITH 1 INCREMENT BY 1; - -CREATE OR REPLACE TRIGGER DM_POLICY_COMPLIANCE_STATUS_seq_tr - BEFORE INSERT ON DM_POLICY_COMPLIANCE_STATUS FOR EACH ROW - WHEN (NEW.ID IS NULL) -BEGIN - SELECT DM_POLICY_COMPLIANCE_STATUS_seq.NEXTVAL INTO :NEW.ID FROM DUAL; -END; +CREATE SEQUENCE DM_POLICY_COMP_STATUS_seq START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER DM_POLICY_COMP_STATUS_seq_tr +BEFORE INSERT +ON DM_POLICY_COMPLIANCE_STATUS +REFERENCING NEW AS NEW +FOR EACH ROW +WHEN (NEW.ID IS NULL) + BEGIN + SELECT DM_POLICY_COMP_STATUS_seq.NEXTVAL INTO :NEW.ID FROM DUAL; + END; / - CREATE TABLE DM_POLICY_CHANGE_MGT ( ID NUMBER(10) NOT NULL, POLICY_ID NUMBER(10) NOT NULL, DEVICE_TYPE_ID NUMBER(10) NOT NULL, TENANT_ID NUMBER(10) NOT NULL, - PRIMARY KEY (ID) -); - + CONSTRAINT PK_DM_POLICY_CHANGE_MGT PRIMARY KEY (ID) +) +/ -- Generate ID using sequence and trigger -CREATE SEQUENCE DM_POLICY_CHANGE_MGT_seq START WITH 1 INCREMENT BY 1; - +CREATE SEQUENCE DM_POLICY_CHANGE_MGT_seq START WITH 1 INCREMENT BY 1 NOCACHE +/ CREATE OR REPLACE TRIGGER DM_POLICY_CHANGE_MGT_seq_tr - BEFORE INSERT ON DM_POLICY_CHANGE_MGT FOR EACH ROW - WHEN (NEW.ID IS NULL) -BEGIN - SELECT DM_POLICY_CHANGE_MGT_seq.NEXTVAL INTO :NEW.ID FROM DUAL; -END; +BEFORE INSERT +ON DM_POLICY_CHANGE_MGT +REFERENCING NEW AS NEW +FOR EACH ROW +WHEN (NEW.ID IS NULL) + BEGIN + SELECT DM_POLICY_CHANGE_MGT_seq.NEXTVAL INTO :NEW.ID FROM DUAL; + END; / - CREATE TABLE DM_POLICY_COMPLIANCE_FEATURES ( ID NUMBER(10) NOT NULL, COMPLIANCE_STATUS_ID NUMBER(10) NOT NULL, TENANT_ID NUMBER(10) NOT NULL, FEATURE_CODE VARCHAR2(15) NOT NULL, STATUS NUMBER(10) NULL, - PRIMARY KEY (ID), + CONSTRAINT PK_COMPLIANCE_FEATURES_STATUS PRIMARY KEY (ID), CONSTRAINT FK_COMPLIANCE_FEATURES_STATUS - FOREIGN KEY (COMPLIANCE_STATUS_ID) - REFERENCES DM_POLICY_COMPLIANCE_STATUS (ID) -); - --- Generate ID using sequence and trigger -CREATE SEQUENCE DM_POLICY_COMPLIANCE_FEATURES_seq START WITH 1 INCREMENT BY 1; - -CREATE OR REPLACE TRIGGER DM_POLICY_COMPLIANCE_FEATURES_seq_tr - BEFORE INSERT ON DM_POLICY_COMPLIANCE_FEATURES FOR EACH ROW - WHEN (NEW.ID IS NULL) -BEGIN - SELECT DM_POLICY_COMPLIANCE_FEATURES_seq.NEXTVAL INTO :NEW.ID FROM DUAL; -END; + FOREIGN KEY (COMPLIANCE_STATUS_ID) + REFERENCES DM_POLICY_COMPLIANCE_STATUS (ID) +) / - -CREATE TABLE DM_ENROLMENT ( - ID NUMBER(10) NOT NULL, - DEVICE_ID NUMBER(10) NOT NULL, - OWNER VARCHAR2(50) NOT NULL, - OWNERSHIP VARCHAR2(45) DEFAULT NULL, - STATUS VARCHAR2(50) NULL, - DATE_OF_ENROLMENT TIMESTAMP(0) DEFAULT NULL, - DATE_OF_LAST_UPDATE TIMESTAMP(0) DEFAULT NULL, - TENANT_ID NUMBER(10) NOT NULL, - PRIMARY KEY (ID), - CONSTRAINT fk_dm_device_enrolment FOREIGN KEY (DEVICE_ID) REFERENCES - DM_DEVICE (ID) -); - -- Generate ID using sequence and trigger -CREATE SEQUENCE DM_ENROLMENT_seq START WITH 1 INCREMENT BY 1; - -CREATE OR REPLACE TRIGGER DM_ENROLMENT_seq_tr - BEFORE INSERT ON DM_ENROLMENT FOR EACH ROW - WHEN (NEW.ID IS NULL) -BEGIN - SELECT DM_ENROLMENT_seq.NEXTVAL INTO :NEW.ID FROM DUAL; -END; +CREATE SEQUENCE DM_POLICY_COMP_FEATURES_seq START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER DM_POLICY_COMP_FEATURES_seq_tr +BEFORE INSERT +ON DM_POLICY_COMPLIANCE_FEATURES +REFERENCING NEW AS NEW +FOR EACH ROW +WHEN (NEW.ID IS NULL) + BEGIN + SELECT DM_POLICY_COMP_FEATURES_seq.NEXTVAL INTO :NEW.ID FROM DUAL; + END; / CREATE TABLE DM_APPLICATION ( - ID NUMBER(10) NOT NULL, - NAME VARCHAR2(150) NOT NULL, - APP_IDENTIFIER VARCHAR2(150) NOT NULL, - PLATFORM VARCHAR2(50) DEFAULT NULL, - CATEGORY VARCHAR2(50) NULL, - VERSION VARCHAR2(50) NULL, - TYPE VARCHAR2(50) NULL, - LOCATION_URL VARCHAR2(100) DEFAULT NULL, - IMAGE_URL VARCHAR2(100) DEFAULT NULL, - APP_PROPERTIES BLOB NULL, - TENANT_ID NUMBER(10) NOT NULL, - PRIMARY KEY (ID) -); - + ID NUMBER(10) NOT NULL, + NAME VARCHAR2(150) NOT NULL, + APP_IDENTIFIER VARCHAR2(150) NOT NULL, + PLATFORM VARCHAR2(50) DEFAULT NULL, + CATEGORY VARCHAR2(50) NULL, + VERSION VARCHAR2(50) NULL, + TYPE VARCHAR2(50) NULL, + LOCATION_URL VARCHAR2(100) DEFAULT NULL, + IMAGE_URL VARCHAR2(100) DEFAULT NULL, + APP_PROPERTIES BLOB NULL, + TENANT_ID NUMBER(10) NOT NULL, + CONSTRAINT PK_DM_APPLICATION PRIMARY KEY (ID) +) +/ -- Generate ID using sequence and trigger -CREATE SEQUENCE DM_APPLICATION_seq START WITH 1 INCREMENT BY 1; - +CREATE SEQUENCE DM_APPLICATION_seq START WITH 1 INCREMENT BY 1 NOCACHE +/ CREATE OR REPLACE TRIGGER DM_APPLICATION_seq_tr - BEFORE INSERT ON DM_APPLICATION FOR EACH ROW - WHEN (NEW.ID IS NULL) -BEGIN - SELECT DM_APPLICATION_seq.NEXTVAL INTO :NEW.ID FROM DUAL; -END; +BEFORE INSERT +ON DM_APPLICATION +REFERENCING NEW AS NEW +FOR EACH ROW +WHEN (NEW.ID IS NULL) + BEGIN + SELECT DM_APPLICATION_seq.NEXTVAL INTO :NEW.ID FROM DUAL; + END; / + CREATE TABLE DM_DEVICE_APPLICATION_MAPPING ( - ID NUMBER(10) NOT NULL, - DEVICE_ID NUMBER(10) NOT NULL, - APPLICATION_ID NUMBER(10) NOT NULL, - TENANT_ID NUMBER(10) NOT NULL, - PRIMARY KEY (ID), - CONSTRAINT fk_dm_device FOREIGN KEY (DEVICE_ID) REFERENCES + ID NUMBER(10) NOT NULL, + DEVICE_ID NUMBER(10) NOT NULL, + APPLICATION_ID NUMBER(10) NOT NULL, + TENANT_ID NUMBER(10) NOT NULL, + CONSTRAINT PK_DM_DEVICE_APP_MAPPING PRIMARY KEY (ID), + CONSTRAINT fk_dm_device FOREIGN KEY (DEVICE_ID) REFERENCES DM_DEVICE (ID), - CONSTRAINT fk_dm_application FOREIGN KEY (APPLICATION_ID) REFERENCES + CONSTRAINT fk_dm_application FOREIGN KEY (APPLICATION_ID) REFERENCES DM_APPLICATION (ID) -); - +) +/ -- Generate ID using sequence and trigger -CREATE SEQUENCE DM_DEVICE_APPLICATION_MAPPING_seq START WITH 1 INCREMENT BY 1; - -CREATE OR REPLACE TRIGGER DM_DEVICE_APPLICATION_MAPPING_seq_tr - BEFORE INSERT ON DM_DEVICE_APPLICATION_MAPPING FOR EACH ROW - WHEN (NEW.ID IS NULL) -BEGIN - SELECT DM_DEVICE_APPLICATION_MAPPING_seq.NEXTVAL INTO :NEW.ID FROM DUAL; -END; +CREATE SEQUENCE DM_DEVICE_APP_MAPPING_seq START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE OR REPLACE TRIGGER DM_DEVICE_APP_MAPPING_seq_tr +BEFORE INSERT +ON DM_DEVICE_APPLICATION_MAPPING +REFERENCING NEW AS NEW +FOR EACH ROW +WHEN (NEW.ID IS NULL) + BEGIN + SELECT DM_DEVICE_APP_MAPPING_seq.NEXTVAL INTO :NEW.ID FROM DUAL; + END; / -- POLICY RELATED TABLES FINISHED -- -- NOTIFICATION TABLE -- CREATE TABLE DM_NOTIFICATION ( - NOTIFICATION_ID NUMBER(10) NOT NULL, - DEVICE_ID NUMBER(10) NOT NULL, - OPERATION_ID NUMBER(10) NOT NULL, - TENANT_ID NUMBER(10) NOT NULL, - STATUS VARCHAR2(10) NULL, - DESCRIPTION VARCHAR2(100) NULL, - PRIMARY KEY (NOTIFICATION_ID), - CONSTRAINT fk_dm_device_notification FOREIGN KEY (DEVICE_ID) REFERENCES + NOTIFICATION_ID NUMBER(10) NOT NULL, + DEVICE_ID NUMBER(10) NOT NULL, + OPERATION_ID NUMBER(10) NOT NULL, + TENANT_ID NUMBER(10) NOT NULL, + STATUS VARCHAR2(10) NULL, + DESCRIPTION VARCHAR2(100) NULL, + CONSTRAINT PK_DM_NOTIFICATION PRIMARY KEY (NOTIFICATION_ID), + CONSTRAINT fk_dm_device_notification FOREIGN KEY (DEVICE_ID) REFERENCES DM_DEVICE (ID), - CONSTRAINT fk_dm_operation_notification FOREIGN KEY (OPERATION_ID) REFERENCES + CONSTRAINT fk_dm_operation_notification FOREIGN KEY (OPERATION_ID) REFERENCES DM_OPERATION (ID) -); +) +/ -- Generate ID using sequence and trigger -CREATE SEQUENCE DM_NOTIFICATION_seq START WITH 1 INCREMENT BY 1; - +CREATE SEQUENCE DM_NOTIFICATION_seq START WITH 1 INCREMENT BY 1 NOCACHE +/ CREATE OR REPLACE TRIGGER DM_NOTIFICATION_seq_tr - BEFORE INSERT ON DM_NOTIFICATION FOR EACH ROW - WHEN (NEW.NOTIFICATION_ID IS NULL) -BEGIN - SELECT DM_NOTIFICATION_seq.NEXTVAL INTO :NEW.NOTIFICATION_ID FROM DUAL; -END; +BEFORE INSERT +ON DM_NOTIFICATION +REFERENCING NEW AS NEW +FOR EACH ROW +WHEN (NEW.NOTIFICATION_ID IS NULL) + BEGIN + SELECT DM_NOTIFICATION_seq.NEXTVAL INTO :NEW.NOTIFICATION_ID FROM DUAL; + END; / -- NOTIFICATION TABLE END -- - From 2b9239d2086dc860ca558f74a87a6160fb17241a Mon Sep 17 00:00:00 2001 From: harshanl Date: Tue, 3 Nov 2015 14:29:38 +0530 Subject: [PATCH 4/5] Optimized the authenticator framework --- .../framework/WebappAuthenticationValve.java | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticationValve.java b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticationValve.java index f6f077e100b..bf9a80e5ca0 100644 --- a/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticationValve.java +++ b/components/webapp-authenticator-framework/org.wso2.carbon.webapp.authenticator.framework/src/main/java/org/wso2/carbon/webapp/authenticator/framework/WebappAuthenticationValve.java @@ -36,7 +36,6 @@ import java.util.StringTokenizer; public class WebappAuthenticationValve extends CarbonTomcatValve { private static final Log log = LogFactory.getLog(WebappAuthenticationValve.class); - private static final String BYPASS_URIS = "bypass-uris"; private static HashMap nonSecuredEndpoints = new HashMap<>(); @Override @@ -47,21 +46,6 @@ public class WebappAuthenticationValve extends CarbonTomcatValve { return; } - String byPassURIs = request.getContext().findParameter(WebappAuthenticationValve.BYPASS_URIS); - - if (byPassURIs != null && !byPassURIs.isEmpty()) { - List requestURI = Arrays.asList(byPassURIs.split(",")); - if (requestURI != null && requestURI.size() > 0) { - for (String pathURI : requestURI) { - pathURI = pathURI.replace("\n", "").replace("\r", "").trim(); - if (request.getRequestURI().equals(pathURI)) { - this.getNext().invoke(request, response, compositeValve); - return; - } - } - } - } - WebappAuthenticator authenticator = WebappAuthenticatorFactory.getAuthenticator(request); if (authenticator == null) { String msg = "Failed to load an appropriate authenticator to authenticate the request"; @@ -131,6 +115,7 @@ public class WebappAuthenticationValve extends CarbonTomcatValve { StringTokenizer tokenizer = new StringTokenizer(param, ","); while (tokenizer.hasMoreTokens()) { skippedEndPoint = ctx + tokenizer.nextToken(); + skippedEndPoint = skippedEndPoint.replace("\n", "").replace("\r", "").trim(); if(!skippedEndPoint.endsWith("/")) { skippedEndPoint = skippedEndPoint + "/"; } From 30c53b7d1455a75264cc778b26727d4a0ba4a4ba Mon Sep 17 00:00:00 2001 From: geethkokila Date: Tue, 3 Nov 2015 16:24:49 +0530 Subject: [PATCH 5/5] Fixing the EMM-900, Ading the LB host name and port to the email url --- .../config/email/EmailConfigurations.java | 20 +++++++++++++++++++ .../DeviceManagementProviderServiceImpl.java | 16 +++++++++++++++ .../src/main/resources/conf/cdm-config.xml | 2 ++ 3 files changed, 38 insertions(+) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/email/EmailConfigurations.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/email/EmailConfigurations.java index b0a242df46a..b0e3a9009ae 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/email/EmailConfigurations.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/config/email/EmailConfigurations.java @@ -28,6 +28,8 @@ public class EmailConfigurations { private int maxNumOfThread; private int keepAliveTime; private int threadQueueCapacity; + private String lBHostPortPrefix; + private String enrollmentContextPath; @XmlElement(name = "minimumThread", required = true) public int getMinNumOfThread() { @@ -62,4 +64,22 @@ public class EmailConfigurations { public void setThreadQueueCapacity(int threadQueueCapacity) { this.threadQueueCapacity = threadQueueCapacity; } + + @XmlElement(name = "LBHostPortPrefix", required = true) + public String getlBHostPortPrefix() { + return lBHostPortPrefix; + } + + public void setlBHostPortPrefix(String lBHostPortPrefix) { + this.lBHostPortPrefix = lBHostPortPrefix; + } + + @XmlElement(name = "enrollmentContextPath", required = true) + public String getEnrollmentContextPath() { + return enrollmentContextPath; + } + + public void setEnrollmentContextPath(String enrollmentContextPath) { + this.enrollmentContextPath = enrollmentContextPath; + } } diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java index 054e4c5e3b0..26d5245ad0f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.core/src/main/java/org/wso2/carbon/device/mgt/core/service/DeviceManagementProviderServiceImpl.java @@ -29,6 +29,7 @@ import org.wso2.carbon.device.mgt.common.operation.mgt.OperationManagementExcept import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService; import org.wso2.carbon.device.mgt.core.DeviceManagementPluginRepository; import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; +import org.wso2.carbon.device.mgt.core.config.email.EmailConfigurations; import org.wso2.carbon.device.mgt.core.config.email.NotificationMessages; import org.wso2.carbon.device.mgt.core.dao.*; import org.wso2.carbon.device.mgt.core.dto.DeviceType; @@ -494,6 +495,13 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv StringBuilder messageBuilder = new StringBuilder(); try { + + // Reading the download url from the cdm-config.xml file + EmailConfigurations emailConfig = + DeviceConfigurationManager.getInstance().getDeviceManagementConfig(). + getDeviceManagementConfigRepository().getEmailConfigurations(); + emailMessageProperties.setEnrolmentUrl(emailConfig.getlBHostPortPrefix()+ emailConfig.getEnrollmentContextPath()); + messageHeader = messageHeader.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.FIRST_NAME + "\\}", URLEncoder.encode(emailMessageProperties.getFirstName(), EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); @@ -549,6 +557,14 @@ public class DeviceManagementProviderServiceImpl implements DeviceManagementProv StringBuilder messageBuilder = new StringBuilder(); try { + + // Reading the download url from the cdm-config.xml file + EmailConfigurations emailConfig = + DeviceConfigurationManager.getInstance().getDeviceManagementConfig(). + getDeviceManagementConfigRepository().getEmailConfigurations(); + emailMessageProperties.setEnrolmentUrl(emailConfig.getlBHostPortPrefix()+ emailConfig.getEnrollmentContextPath()); + + messageHeader = messageHeader.replaceAll("\\{" + EmailConstants.EnrolmentEmailConstants.FIRST_NAME + "\\}", URLEncoder.encode(emailMessageProperties.getFirstName(), EmailConstants.EnrolmentEmailConstants.ENCODED_SCHEME)); diff --git a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml index 0f5861cc1d1..2fdabf455a3 100644 --- a/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml +++ b/features/device-mgt/org.wso2.carbon.device.mgt.server.feature/src/main/resources/conf/cdm-config.xml @@ -29,6 +29,8 @@ 100 20 1000 + https://localhost:9443 + /mdm/enrollment https://localhost:9443