From 4829277e97bea2df414c2315e6c3c51ea20ee730 Mon Sep 17 00:00:00 2001 From: Ace Date: Sun, 25 Sep 2016 07:15:56 +0530 Subject: [PATCH 01/10] Chainging iots to use earlier version of components and plugins on top of kernel 4.4.3 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 70a31be0..19ecdf55 100644 --- a/pom.xml +++ b/pom.xml @@ -1081,14 +1081,14 @@ 4.5.8 - 1.2.2-SNAPSHOT + 1.2.1 [1.1.3, 2.0.0) 1.0.0-SNAPSHOT - 2.2.2-SNAPSHOT + 2.2.1 5.0.5 From 82a352242cee52ca01878da28f28b386ef30ff55 Mon Sep 17 00:00:00 2001 From: warunalakshitha Date: Thu, 29 Sep 2016 00:57:29 +0530 Subject: [PATCH 02/10] Update api manager db scripts to 6.0.5 version --- .../resources/dbscripts/apimgt/db2.sql | 1304 +++++++++++++++++ .../resources/dbscripts/apimgt/h2.sql | 223 ++- .../resources/dbscripts/apimgt/mssql.sql | 297 +++- .../resources/dbscripts/apimgt/mysql.sql | 260 +++- .../resources/dbscripts/apimgt/mysql5.7.sql | 1038 +++++++++++++ .../dbscripts/apimgt/mysql_cluster.sql | 1039 +++++++++++++ .../resources/dbscripts/apimgt/oracle.sql | 399 ++++- .../resources/dbscripts/apimgt/oracle_rac.sql | 394 ++++- .../resources/dbscripts/apimgt/postgresql.sql | 296 +++- 9 files changed, 5165 insertions(+), 85 deletions(-) create mode 100644 modules/distribution/src/repository/resources/dbscripts/apimgt/db2.sql create mode 100644 modules/distribution/src/repository/resources/dbscripts/apimgt/mysql5.7.sql create mode 100644 modules/distribution/src/repository/resources/dbscripts/apimgt/mysql_cluster.sql diff --git a/modules/distribution/src/repository/resources/dbscripts/apimgt/db2.sql b/modules/distribution/src/repository/resources/dbscripts/apimgt/db2.sql new file mode 100644 index 00000000..bb56b48c --- /dev/null +++ b/modules/distribution/src/repository/resources/dbscripts/apimgt/db2.sql @@ -0,0 +1,1304 @@ +-- Start of IDENTITY Tables-- +CREATE TABLE IDN_BASE_TABLE ( + PRODUCT_NAME VARCHAR (20) NOT NULL, + PRIMARY KEY (PRODUCT_NAME)) +/ +INSERT INTO IDN_BASE_TABLE values ('WSO2 Identity Server') +/ +CREATE TABLE IDN_OAUTH_CONSUMER_APPS ( + ID INTEGER NOT NULL, + CONSUMER_KEY VARCHAR (255) NOT NULL, + CONSUMER_SECRET VARCHAR (512), + USERNAME VARCHAR (255), + TENANT_ID INTEGER DEFAULT 0, + USER_DOMAIN VARCHAR(50), + APP_NAME VARCHAR (255), + OAUTH_VERSION VARCHAR (128), + CALLBACK_URL VARCHAR (1024), + GRANT_TYPES VARCHAR (1024), + PKCE_MANDATORY CHAR(1) DEFAULT '0', + PKCE_SUPPORT_PLAIN CHAR(1) DEFAULT '0', + CONSTRAINT CONSUMER_KEY_CONSTRAINT UNIQUE (CONSUMER_KEY), + PRIMARY KEY (ID)) +/ +CREATE SEQUENCE IDN_OAUTH_CONSUMER_APPS_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE + / +CREATE TRIGGER IDN_OAUTH_CONSUMER_APPS_TRIGGER NO CASCADE BEFORE INSERT ON IDN_OAUTH_CONSUMER_APPS +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + BEGIN ATOMIC + SET (NEW.ID) + = (NEXTVAL FOR IDN_OAUTH_CONSUMER_APPS_SEQUENCE); + END +/ +CREATE TABLE IDN_OAUTH1A_REQUEST_TOKEN ( + REQUEST_TOKEN VARCHAR (512) NOT NULL, + REQUEST_TOKEN_SECRET VARCHAR (512), + CONSUMER_KEY_ID INTEGER, + CALLBACK_URL VARCHAR (1024), + SCOPE VARCHAR(2048), + AUTHORIZED VARCHAR (128), + OAUTH_VERIFIER VARCHAR (512), + AUTHZ_USER VARCHAR (512), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (REQUEST_TOKEN), + FOREIGN KEY (CONSUMER_KEY_ID) REFERENCES IDN_OAUTH_CONSUMER_APPS(ID) ON DELETE CASCADE) +/ +CREATE TABLE IDN_OAUTH1A_ACCESS_TOKEN ( + ACCESS_TOKEN VARCHAR (512) NOT NULL, + ACCESS_TOKEN_SECRET VARCHAR (512), + CONSUMER_KEY_ID INTEGER, + SCOPE VARCHAR(2048), + AUTHZ_USER VARCHAR (512), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (ACCESS_TOKEN), + FOREIGN KEY (CONSUMER_KEY_ID) REFERENCES IDN_OAUTH_CONSUMER_APPS(ID) ON DELETE CASCADE) +/ +CREATE TABLE IDN_OAUTH2_ACCESS_TOKEN ( + TOKEN_ID VARCHAR (255) NOT NULL, + ACCESS_TOKEN VARCHAR (255) NOT NULL, + REFRESH_TOKEN VARCHAR (255), + CONSUMER_KEY_ID INTEGER NOT NULL, + AUTHZ_USER VARCHAR (100) NOT NULL, + TENANT_ID INTEGER NOT NULL, + USER_DOMAIN VARCHAR (50) NOT NULL, + USER_TYPE VARCHAR (25) NOT NULL, + GRANT_TYPE VARCHAR (50), + TIME_CREATED TIMESTAMP, + REFRESH_TOKEN_TIME_CREATED TIMESTAMP, + VALIDITY_PERIOD BIGINT, + REFRESH_TOKEN_VALIDITY_PERIOD BIGINT, + TOKEN_SCOPE_HASH VARCHAR (32) NOT NULL, + TOKEN_STATE VARCHAR (25) DEFAULT 'ACTIVE' NOT NULL, + TOKEN_STATE_ID VARCHAR (128) DEFAULT 'NONE' NOT NULL, + SUBJECT_IDENTIFIER VARCHAR(255), + PRIMARY KEY (TOKEN_ID), + FOREIGN KEY (CONSUMER_KEY_ID) REFERENCES IDN_OAUTH_CONSUMER_APPS(ID) ON DELETE CASCADE, + CONSTRAINT CON_APP_KEY UNIQUE (CONSUMER_KEY_ID,AUTHZ_USER,TENANT_ID,USER_DOMAIN,USER_TYPE,TOKEN_SCOPE_HASH, + TOKEN_STATE,TOKEN_STATE_ID)) +/ + +CREATE INDEX IDX_AT_CK_AU ON IDN_OAUTH2_ACCESS_TOKEN(CONSUMER_KEY_ID, AUTHZ_USER, TOKEN_STATE, USER_TYPE) +/ + +CREATE INDEX IDX_TC ON IDN_OAUTH2_ACCESS_TOKEN(TIME_CREATED) +/ + +CREATE TABLE IDN_OAUTH2_AUTHORIZATION_CODE ( + CODE_ID VARCHAR (255) NOT NULL, + AUTHORIZATION_CODE VARCHAR (512) NOT NULL, + CONSUMER_KEY_ID INTEGER, + CALLBACK_URL VARCHAR (1024), + SCOPE VARCHAR(2048), + AUTHZ_USER VARCHAR (100) NOT NULL, + TENANT_ID INTEGER, + USER_DOMAIN VARCHAR (50) NOT NULL, + TIME_CREATED TIMESTAMP, + VALIDITY_PERIOD BIGINT, + STATE VARCHAR (25) DEFAULT 'ACTIVE', + TOKEN_ID VARCHAR(255), + SUBJECT_IDENTIFIER VARCHAR(255), + PKCE_CODE_CHALLENGE VARCHAR(255), + PKCE_CODE_CHALLENGE_METHOD VARCHAR(128), + PRIMARY KEY (CODE_ID), + FOREIGN KEY (CONSUMER_KEY_ID) REFERENCES IDN_OAUTH_CONSUMER_APPS(ID) ON DELETE CASCADE) +/ + +CREATE TABLE IDN_OAUTH2_ACCESS_TOKEN_SCOPE ( + TOKEN_ID VARCHAR (255) NOT NULL, + TOKEN_SCOPE VARCHAR (60) NOT NULL, + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (TOKEN_ID, TOKEN_SCOPE), + FOREIGN KEY (TOKEN_ID) REFERENCES IDN_OAUTH2_ACCESS_TOKEN(TOKEN_ID) ON DELETE CASCADE) +/ +CREATE TABLE IDN_OAUTH2_SCOPE ( + SCOPE_ID INTEGER NOT NULL, + SCOPE_KEY VARCHAR (100) NOT NULL, + NAME VARCHAR (255) NULL, + DESCRIPTION VARCHAR (512) NULL, + TENANT_ID INTEGER DEFAULT 0 NOT NULL, + ROLES VARCHAR (500) NULL, + PRIMARY KEY (SCOPE_ID)) +/ +CREATE SEQUENCE IDN_OAUTH2_SCOPE_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER IDN_OAUTH2_SCOPE_TRIGGER NO CASCADE BEFORE INSERT ON IDN_OAUTH2_SCOPE +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.SCOPE_ID) + = (NEXTVAL FOR IDN_OAUTH2_SCOPE_SEQUENCE); + +END +/ +CREATE TABLE IDN_OAUTH2_RESOURCE_SCOPE ( + RESOURCE_PATH VARCHAR (255) NOT NULL, + SCOPE_ID INTEGER NOT NULL, + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (RESOURCE_PATH), + FOREIGN KEY (SCOPE_ID) REFERENCES IDN_OAUTH2_SCOPE (SCOPE_ID) ON DELETE CASCADE +)/ + +CREATE TABLE IDN_SCIM_GROUP ( + ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + ROLE_NAME VARCHAR(255) NOT NULL, + ATTR_NAME VARCHAR(1024) NOT NULL, + ATTR_VALUE VARCHAR(1024), + PRIMARY KEY (ID)) +/ +CREATE SEQUENCE IDN_SCIM_GROUP_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER IDN_SCIM_GROUP_TRIGGER NO CASCADE BEFORE INSERT ON IDN_SCIM_GROUP +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.ID) + = (NEXTVAL FOR IDN_SCIM_GROUP_SEQUENCE); + +END +/ +CREATE TABLE IDN_OPENID_REMEMBER_ME ( + USER_NAME VARCHAR(255) NOT NULL, + TENANT_ID INTEGER DEFAULT 0 NOT NULL, + COOKIE_VALUE VARCHAR(1024), + CREATED_TIME TIMESTAMP, + PRIMARY KEY (USER_NAME, TENANT_ID)) +/ +CREATE TABLE IDN_OPENID_USER_RPS ( + USER_NAME VARCHAR(255) NOT NULL, + TENANT_ID INTEGER DEFAULT 0 NOT NULL, + RP_URL VARCHAR(255) NOT NULL, + TRUSTED_ALWAYS VARCHAR(128) DEFAULT 'FALSE', + LAST_VISIT DATE NOT NULL, + VISIT_COUNT INTEGER DEFAULT 0, + DEFAULT_PROFILE_NAME VARCHAR(255) DEFAULT 'DEFAULT', + PRIMARY KEY (USER_NAME, TENANT_ID, RP_URL)) +/ +CREATE TABLE IDN_OPENID_ASSOCIATIONS ( + HANDLE VARCHAR(255) NOT NULL, + ASSOC_TYPE VARCHAR(255) NOT NULL, + EXPIRE_IN TIMESTAMP NOT NULL, + MAC_KEY VARCHAR(255) NOT NULL, + ASSOC_STORE VARCHAR(128) DEFAULT 'SHARED', + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (HANDLE)) +/ +CREATE TABLE IDN_STS_STORE ( + ID INTEGER NOT NULL, + TOKEN_ID VARCHAR(255) NOT NULL, + TOKEN_CONTENT BLOB NOT NULL, + CREATE_DATE TIMESTAMP NOT NULL, + EXPIRE_DATE TIMESTAMP NOT NULL, + STATE INTEGER DEFAULT 0, + PRIMARY KEY (ID)) +/ +CREATE SEQUENCE IDN_STS_STORE_SEQUENCE START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER IDN_STS_STORE_TRIGGER NO CASCADE BEFORE INSERT ON IDN_STS_STORE +REFERENCING NEW AS NEW FOR EACH ROW MODE DB2SQL + +BEGIN ATOMIC + + SET (NEW.ID) + = (NEXTVAL FOR IDN_STS_STORE_SEQUENCE); + +END +/ +CREATE TABLE IDN_IDENTITY_USER_DATA ( + TENANT_ID INTEGER DEFAULT -1234 NOT NULL, + USER_NAME VARCHAR(255) NOT NULL, + DATA_KEY VARCHAR(255) NOT NULL, + DATA_VALUE VARCHAR(255), + PRIMARY KEY (TENANT_ID, USER_NAME, DATA_KEY)) +/ +CREATE TABLE IDN_IDENTITY_META_DATA ( + USER_NAME VARCHAR(255) NOT NULL, + TENANT_ID INTEGER DEFAULT -1234 NOT NULL, + METADATA_TYPE VARCHAR(255) NOT NULL, + METADATA VARCHAR(255) NOT NULL, + VALID VARCHAR(255) NOT NULL, + PRIMARY KEY (TENANT_ID, USER_NAME, METADATA_TYPE,METADATA)) +/ +CREATE TABLE IDN_THRIFT_SESSION ( + SESSION_ID VARCHAR(255) NOT NULL, + USER_NAME VARCHAR(255) NOT NULL, + CREATED_TIME VARCHAR(255) NOT NULL, + LAST_MODIFIED_TIME VARCHAR(255) NOT NULL, + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (SESSION_ID) +) +/ + +CREATE TABLE IDN_AUTH_SESSION_STORE ( + SESSION_ID VARCHAR (100) NOT NULL, + SESSION_TYPE VARCHAR(100) NOT NULL, + OPERATION VARCHAR(10) NOT NULL, + SESSION_OBJECT BLOB, + TIME_CREATED BIGINT NOT NULL, + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (SESSION_ID, SESSION_TYPE, TIME_CREATED, OPERATION) +) +/ +CREATE TABLE SP_APP ( + ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + APP_NAME VARCHAR (255) NOT NULL , + USER_STORE VARCHAR (255) NOT NULL, + USERNAME VARCHAR (255) NOT NULL , + DESCRIPTION VARCHAR (1024), + ROLE_CLAIM VARCHAR (512), + AUTH_TYPE VARCHAR (255) NOT NULL, + PROVISIONING_USERSTORE_DOMAIN VARCHAR (512), + IS_LOCAL_CLAIM_DIALECT CHAR(1) DEFAULT '1', + IS_SEND_LOCAL_SUBJECT_ID CHAR(1) DEFAULT '0', + IS_SEND_AUTH_LIST_OF_IDPS CHAR(1) DEFAULT '0', + IS_USE_TENANT_DOMAIN_SUBJECT CHAR(1) DEFAULT '1', + IS_USE_USER_DOMAIN_SUBJECT CHAR(1) DEFAULT '1', + SUBJECT_CLAIM_URI VARCHAR (512), + IS_SAAS_APP CHAR(1) DEFAULT '0', + IS_DUMB_MODE CHAR(1) DEFAULT '0', + PRIMARY KEY (ID)) +/ +CREATE SEQUENCE SP_APP_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER SP_APP_TRIG NO CASCADE + BEFORE INSERT + ON SP_APP + REFERENCING NEW AS NEW + FOR EACH ROW MODE DB2SQL + BEGIN ATOMIC + SET (NEW.ID) = (NEXTVAL FOR SP_APP_SEQ); + END +/ +ALTER TABLE SP_APP ADD CONSTRAINT APPLICATION_NAME_CONSTRAINT UNIQUE(APP_NAME, TENANT_ID) +/ + + +CREATE TABLE SP_METADATA ( + ID INTEGER NOT NULL, + SP_ID INTEGER NOT NULL, + NAME VARCHAR(255) NOT NULL, + VALUE VARCHAR(255) NOT NULL, + DISPLAY_NAME VARCHAR(255), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (ID), + CONSTRAINT SP_METADATA_CONSTRAINT UNIQUE (SP_ID, NAME), + FOREIGN KEY (SP_ID) REFERENCES SP_APP(ID) ON DELETE CASCADE) +/ +CREATE SEQUENCE SP_METADATA_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER SP_METADATA_TRIG NO CASCADE + BEFORE INSERT + ON SP_METADATA + REFERENCING NEW AS NEW + FOR EACH ROW MODE DB2SQL + BEGIN ATOMIC + SET (NEW.ID) = (NEXTVAL FOR SP_METADATA_SEQ); + END +/ + +CREATE TABLE SP_INBOUND_AUTH ( + ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + INBOUND_AUTH_KEY VARCHAR (255), + INBOUND_AUTH_TYPE VARCHAR (255) NOT NULL, + PROP_NAME VARCHAR (255), + PROP_VALUE VARCHAR (1024) , + APP_ID INTEGER NOT NULL, + PRIMARY KEY (ID)) +/ +CREATE SEQUENCE SP_INBOUND_AUTH_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER SP_INBOUND_AUTH_TRIG NO CASCADE + BEFORE INSERT + ON SP_INBOUND_AUTH + REFERENCING NEW AS NEW + FOR EACH ROW MODE DB2SQL + BEGIN ATOMIC + SET (NEW.ID) = (NEXTVAL FOR SP_INBOUND_AUTH_SEQ); + END +/ +ALTER TABLE SP_INBOUND_AUTH ADD CONSTRAINT APPLICATION_ID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE +/ +CREATE TABLE SP_AUTH_STEP ( + ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + STEP_ORDER INTEGER DEFAULT 1, + APP_ID INTEGER NOT NULL , + IS_SUBJECT_STEP CHAR(1) DEFAULT '0', + IS_ATTRIBUTE_STEP CHAR(1) DEFAULT '0', + PRIMARY KEY (ID)) +/ +CREATE SEQUENCE SP_AUTH_STEP_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER SP_AUTH_STEP_TRIG NO CASCADE + BEFORE INSERT + ON SP_AUTH_STEP + REFERENCING NEW AS NEW + FOR EACH ROW MODE DB2SQL + BEGIN ATOMIC + SET (NEW.ID) = (NEXTVAL FOR SP_AUTH_STEP_SEQ); + END +/ +ALTER TABLE SP_AUTH_STEP ADD CONSTRAINT APPLICATION_ID_CONSTRAINT_STEP FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE +/ +CREATE TABLE SP_FEDERATED_IDP ( + ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + AUTHENTICATOR_ID INTEGER NOT NULL, + PRIMARY KEY (ID, AUTHENTICATOR_ID)) +/ +ALTER TABLE SP_FEDERATED_IDP ADD CONSTRAINT STEP_ID_CONSTRAINT FOREIGN KEY (ID) REFERENCES SP_AUTH_STEP (ID) ON DELETE CASCADE +/ +CREATE TABLE SP_CLAIM_MAPPING ( + ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + IDP_CLAIM VARCHAR (512) NOT NULL , + SP_CLAIM VARCHAR (512) NOT NULL , + APP_ID INTEGER NOT NULL, + IS_REQUESTED VARCHAR(128) DEFAULT '0', + DEFAULT_VALUE VARCHAR(255), + PRIMARY KEY (ID)) +/ +CREATE SEQUENCE SP_CLAIM_MAPPING_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER SP_CLAIM_MAPPING_TRIG NO CASCADE + BEFORE INSERT + ON SP_CLAIM_MAPPING + REFERENCING NEW AS NEW + FOR EACH ROW MODE DB2SQL + BEGIN ATOMIC + SET (NEW.ID) = (NEXTVAL FOR SP_CLAIM_MAPPING_SEQ); + END +/ +ALTER TABLE SP_CLAIM_MAPPING ADD CONSTRAINT CLAIMID_APPID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE +/ +CREATE TABLE SP_ROLE_MAPPING ( + ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + IDP_ROLE VARCHAR (255) NOT NULL , + SP_ROLE VARCHAR (255) NOT NULL , + APP_ID INTEGER NOT NULL, + PRIMARY KEY (ID)) +/ +CREATE SEQUENCE SP_ROLE_MAPPING_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER SP_ROLE_MAPPING_TRIG NO CASCADE + BEFORE INSERT + ON SP_ROLE_MAPPING + REFERENCING NEW AS NEW + FOR EACH ROW MODE DB2SQL + BEGIN ATOMIC + SET (NEW.ID) = (NEXTVAL FOR SP_ROLE_MAPPING_SEQ); + END +/ +ALTER TABLE SP_ROLE_MAPPING ADD CONSTRAINT ROLEID_APPID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE +/ +CREATE TABLE SP_REQ_PATH_AUTHENTICATOR ( + ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + AUTHENTICATOR_NAME VARCHAR (255) NOT NULL , + APP_ID INTEGER NOT NULL, + PRIMARY KEY (ID)) +/ +CREATE SEQUENCE SP_REQ_PATH_AUTH_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER SP_REQ_PATH_AUTH_TRIG NO CASCADE + BEFORE INSERT + ON SP_REQ_PATH_AUTHENTICATOR + REFERENCING NEW AS NEW + FOR EACH ROW MODE DB2SQL + BEGIN ATOMIC + SET (NEW.ID) = (NEXTVAL FOR SP_REQ_PATH_AUTH_SEQ); + END +/ +ALTER TABLE SP_REQ_PATH_AUTHENTICATOR ADD CONSTRAINT REQ_AUTH_APPID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE +/ +CREATE TABLE SP_PROVISIONING_CONNECTOR ( + ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + IDP_NAME VARCHAR (255) NOT NULL , + CONNECTOR_NAME VARCHAR (255) NOT NULL , + APP_ID INTEGER NOT NULL, + IS_JIT_ENABLED CHAR(1) NOT NULL DEFAULT '0', + BLOCKING CHAR(1) NOT NULL DEFAULT '0', + PRIMARY KEY (ID)) +/ +CREATE SEQUENCE SP_PROV_CONNECTOR_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER SP_PROV_CONNECTOR_TRIG NO CASCADE + BEFORE INSERT + ON SP_PROVISIONING_CONNECTOR + REFERENCING NEW AS NEW + FOR EACH ROW MODE DB2SQL + BEGIN ATOMIC + SET (NEW.ID) = (NEXTVAL FOR SP_PROV_CONNECTOR_SEQ); + END +/ +ALTER TABLE SP_PROVISIONING_CONNECTOR ADD CONSTRAINT PRO_CONNECTOR_APPID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE +/ +CREATE TABLE IDP ( + ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + NAME VARCHAR(254) NOT NULL, + IS_ENABLED CHAR(1) NOT NULL DEFAULT '1', + IS_PRIMARY CHAR(1) NOT NULL DEFAULT '0', + HOME_REALM_ID VARCHAR(254), + IMAGE BLOB, + CERTIFICATE BLOB, + ALIAS VARCHAR(254), + INBOUND_PROV_ENABLED CHAR (1) NOT NULL DEFAULT '0', + INBOUND_PROV_USER_STORE_ID VARCHAR(254), + USER_CLAIM_URI VARCHAR(254), + ROLE_CLAIM_URI VARCHAR(254), + DESCRIPTION VARCHAR (1024), + DEFAULT_AUTHENTICATOR_NAME VARCHAR(254), + DEFAULT_PRO_CONNECTOR_NAME VARCHAR(254), + PROVISIONING_ROLE VARCHAR(128), + IS_FEDERATION_HUB CHAR(1) NOT NULL DEFAULT '0', + IS_LOCAL_CLAIM_DIALECT CHAR(1) NOT NULL DEFAULT '0', + DISPLAY_NAME VARCHAR(254), + PRIMARY KEY (ID), + UNIQUE (TENANT_ID, NAME)) +/ +CREATE SEQUENCE IDP_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER IDP_TRIG NO CASCADE + BEFORE INSERT + ON IDP + REFERENCING NEW AS NEW + FOR EACH ROW MODE DB2SQL + BEGIN ATOMIC + SET (NEW.ID) = (NEXTVAL FOR IDP_SEQ); + END +/ + +INSERT INTO IDP (TENANT_ID, NAME, HOME_REALM_ID) VALUES (-1234, 'LOCAL', 'localhost')/ + +CREATE TABLE IDP_ROLE ( + ID INTEGER NOT NULL, + IDP_ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + ROLE VARCHAR(254) NOT NULL, + PRIMARY KEY (ID), + UNIQUE (IDP_ID, ROLE), + FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE) +/ +CREATE SEQUENCE IDP_ROLE_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER IDP_ROLE_TRIG NO CASCADE + BEFORE INSERT + ON IDP_ROLE + REFERENCING NEW AS NEW + FOR EACH ROW MODE DB2SQL + BEGIN ATOMIC + SET (NEW.ID) = (NEXTVAL FOR IDP_ROLE_SEQ); + END +/ +CREATE TABLE IDP_ROLE_MAPPING ( + ID INTEGER NOT NULL, + IDP_ROLE_ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + USER_STORE_ID VARCHAR (253) NOT NULL, + LOCAL_ROLE VARCHAR(253) NOT NULL, + PRIMARY KEY (ID), + UNIQUE (IDP_ROLE_ID, TENANT_ID, USER_STORE_ID, LOCAL_ROLE), + FOREIGN KEY (IDP_ROLE_ID) REFERENCES IDP_ROLE(ID) ON DELETE CASCADE) +/ +CREATE SEQUENCE IDP_ROLE_MAPPING_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER IDP_ROLE_MAPPING_TRIG NO CASCADE + BEFORE INSERT + ON IDP_ROLE_MAPPING + REFERENCING NEW AS NEW + FOR EACH ROW MODE DB2SQL + BEGIN ATOMIC + SET (NEW.ID) = (NEXTVAL FOR IDP_ROLE_MAPPING_SEQ); + END +/ +CREATE TABLE IDP_CLAIM ( + ID INTEGER NOT NULL, + IDP_ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + CLAIM VARCHAR(254) NOT NULL, + PRIMARY KEY (ID), + UNIQUE (IDP_ID, CLAIM), + FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE) +/ +CREATE SEQUENCE IDP_CLAIM_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER IDP_CLAIM_TRIG NO CASCADE + BEFORE INSERT + ON IDP_CLAIM + REFERENCING NEW AS NEW + FOR EACH ROW MODE DB2SQL + BEGIN ATOMIC + SET (NEW.ID) = (NEXTVAL FOR IDP_CLAIM_SEQ); + END +/ +CREATE TABLE IDP_CLAIM_MAPPING ( + ID INTEGER NOT NULL, + IDP_CLAIM_ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + LOCAL_CLAIM VARCHAR(253) NOT NULL, + DEFAULT_VALUE VARCHAR(255), + IS_REQUESTED VARCHAR(128) DEFAULT '0', + PRIMARY KEY (ID), + UNIQUE (IDP_CLAIM_ID, TENANT_ID, LOCAL_CLAIM), + FOREIGN KEY (IDP_CLAIM_ID) REFERENCES IDP_CLAIM(ID) ON DELETE CASCADE) +/ +CREATE SEQUENCE IDP_CLAIM_MAPPING_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER IDP_CLAIM_MAPPING_TRIG NO CASCADE + BEFORE INSERT + ON IDP_CLAIM_MAPPING + REFERENCING NEW AS NEW + FOR EACH ROW MODE DB2SQL + BEGIN ATOMIC + SET (NEW.ID) = (NEXTVAL FOR IDP_CLAIM_MAPPING_SEQ); + END +/ +CREATE TABLE IDP_AUTHENTICATOR ( + ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + IDP_ID INTEGER NOT NULL, + NAME VARCHAR(255) NOT NULL, + IS_ENABLED CHAR (1) DEFAULT '1', + DISPLAY_NAME VARCHAR(255), + PRIMARY KEY (ID), + UNIQUE (TENANT_ID, IDP_ID, NAME), + FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE) +/ +CREATE SEQUENCE IDP_AUTHENTICATOR_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER IDP_AUTHENTICATOR_TRIG NO CASCADE + BEFORE INSERT + ON IDP_AUTHENTICATOR + REFERENCING NEW AS NEW + FOR EACH ROW MODE DB2SQL + BEGIN ATOMIC + SET (NEW.ID) = (NEXTVAL FOR IDP_AUTHENTICATOR_SEQ); + END +/ + +INSERT INTO IDP_AUTHENTICATOR (TENANT_ID, IDP_ID, NAME) VALUES (-1234, 1, 'samlsso')/ +INSERT INTO IDP_AUTHENTICATOR (TENANT_ID, IDP_ID, NAME) VALUES (-1234, 1, 'IDPProperties')/ +INSERT INTO IDP_AUTHENTICATOR (TENANT_ID, IDP_ID, NAME) VALUES (-1234, 1, 'passivests')/ + +CREATE TABLE IDP_METADATA ( + ID INTEGER NOT NULL, + IDP_ID INTEGER NOT NULL, + NAME VARCHAR(255) NOT NULL, + VALUE VARCHAR(255), + DISPLAY_NAME VARCHAR(255), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (ID), + CONSTRAINT IDP_METADATA_CONSTRAINT UNIQUE (IDP_ID, NAME), + FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE) +/ + +CREATE SEQUENCE IDP_METADATA_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER IDP_METADATA_TRIG NO CASCADE + BEFORE INSERT + ON IDP_METADATA + REFERENCING NEW AS NEW + FOR EACH ROW MODE DB2SQL + BEGIN ATOMIC + SET (NEW.ID) = (NEXTVAL FOR IDP_METADATA_SEQ); + END +/ + +INSERT INTO IDP_METADATA (IDP_ID, NAME, VALUE, DISPLAY_NAME) VALUES (1, 'SessionIdleTimeout', '20160', 'Session Idle Timeout')/ +INSERT INTO IDP_METADATA (IDP_ID, NAME, VALUE, DISPLAY_NAME) VALUES (1, 'RememberMeTimeout', '15', 'RememberMe Timeout')/ + +CREATE TABLE IDP_AUTHENTICATOR_PROPERTY ( + ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + AUTHENTICATOR_ID INTEGER NOT NULL, + PROPERTY_KEY VARCHAR(255) NOT NULL, + PROPERTY_VALUE VARCHAR(2047), + IS_SECRET CHAR (1) DEFAULT '0', + PRIMARY KEY (ID), + UNIQUE (TENANT_ID, AUTHENTICATOR_ID, PROPERTY_KEY), + FOREIGN KEY (AUTHENTICATOR_ID) REFERENCES IDP_AUTHENTICATOR(ID) ON DELETE CASCADE) +/ +CREATE SEQUENCE IDP_AUTHENTICATOR_PROP_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER IDP_AUTHENTICATOR_PROP_TRIG NO CASCADE + BEFORE INSERT + ON IDP_AUTHENTICATOR_PROPERTY + REFERENCING NEW AS NEW + FOR EACH ROW MODE DB2SQL + BEGIN ATOMIC + SET (NEW.ID) = (NEXTVAL FOR IDP_AUTHENTICATOR_PROP_SEQ); + END +/ + +INSERT INTO IDP_AUTHENTICATOR_PROPERTY (TENANT_ID, AUTHENTICATOR_ID, PROPERTY_KEY,PROPERTY_VALUE, IS_SECRET ) VALUES (-1234, 1 , 'IdPEntityId', 'localhost', '0')/ +INSERT INTO IDP_AUTHENTICATOR_PROPERTY (TENANT_ID, AUTHENTICATOR_ID, PROPERTY_KEY,PROPERTY_VALUE, IS_SECRET ) VALUES (-1234, 3 , 'IdPEntityId', 'localhost', '0')/ + +CREATE TABLE IDP_PROVISIONING_CONFIG ( + ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + IDP_ID INTEGER NOT NULL, + PROVISIONING_CONNECTOR_TYPE VARCHAR(255) NOT NULL, + IS_ENABLED CHAR (1) DEFAULT '0', + IS_BLOCKING CHAR (1) DEFAULT '0', + PRIMARY KEY (ID), + UNIQUE (TENANT_ID, IDP_ID, PROVISIONING_CONNECTOR_TYPE), + FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE) +/ +CREATE SEQUENCE IDP_PROV_CONFIG_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER IDP_PROV_CONFIG_TRIG NO CASCADE + BEFORE INSERT + ON IDP_PROVISIONING_CONFIG + REFERENCING NEW AS NEW + FOR EACH ROW MODE DB2SQL + BEGIN ATOMIC + SET (NEW.ID) = (NEXTVAL FOR IDP_PROV_CONFIG_SEQ); + END +/ +CREATE TABLE IDP_PROV_CONFIG_PROPERTY ( + ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + PROVISIONING_CONFIG_ID INTEGER NOT NULL, + PROPERTY_KEY VARCHAR(255) NOT NULL, + PROPERTY_VALUE VARCHAR(2048), + PROPERTY_BLOB_VALUE BLOB, + PROPERTY_TYPE CHAR(32) NOT NULL, + IS_SECRET CHAR (1) DEFAULT '0', + PRIMARY KEY (ID), + UNIQUE (TENANT_ID, PROVISIONING_CONFIG_ID, PROPERTY_KEY), + FOREIGN KEY (PROVISIONING_CONFIG_ID) REFERENCES IDP_PROVISIONING_CONFIG(ID) ON DELETE CASCADE) +/ +CREATE SEQUENCE IDP_PROV_CONFIG_PROP_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER IDP_PROV_CONFIG_PROP_TRIG NO CASCADE + BEFORE INSERT + ON IDP_PROV_CONFIG_PROPERTY + REFERENCING NEW AS NEW + FOR EACH ROW MODE DB2SQL + BEGIN ATOMIC + SET (NEW.ID) = (NEXTVAL FOR IDP_PROV_CONFIG_PROP_SEQ); + END +/ +CREATE TABLE IDP_PROVISIONING_ENTITY ( + ID INTEGER NOT NULL, + PROVISIONING_CONFIG_ID INTEGER NOT NULL, + ENTITY_TYPE VARCHAR(255) NOT NULL, + ENTITY_LOCAL_USERSTORE VARCHAR(255) NOT NULL, + ENTITY_NAME VARCHAR(255) NOT NULL, + ENTITY_VALUE VARCHAR(255) NOT NULL, + TENANT_ID INTEGER NOT NULL, + ENTITY_LOCAL_ID VARCHAR(255), + PRIMARY KEY (ID), + UNIQUE (ENTITY_TYPE, TENANT_ID, ENTITY_LOCAL_USERSTORE, ENTITY_NAME, PROVISIONING_CONFIG_ID), + UNIQUE (PROVISIONING_CONFIG_ID, ENTITY_TYPE, ENTITY_VALUE), + FOREIGN KEY (PROVISIONING_CONFIG_ID) REFERENCES IDP_PROVISIONING_CONFIG(ID) ON DELETE CASCADE) +/ +CREATE SEQUENCE IDP_PROV_ENTITY_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER IDP_PROV_ENTITY_TRIG NO CASCADE + BEFORE INSERT + ON IDP_PROVISIONING_ENTITY + REFERENCING NEW AS NEW + FOR EACH ROW MODE DB2SQL + BEGIN ATOMIC + SET (NEW.ID) = (NEXTVAL FOR IDP_PROV_ENTITY_SEQ); + END +/ +CREATE TABLE IDP_LOCAL_CLAIM ( + ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + IDP_ID INTEGER NOT NULL, + CLAIM_URI VARCHAR(255) NOT NULL, + DEFAULT_VALUE VARCHAR(255), + IS_REQUESTED VARCHAR(128) DEFAULT '0', + PRIMARY KEY (ID), + UNIQUE (TENANT_ID, IDP_ID, CLAIM_URI), + FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE) +/ +CREATE SEQUENCE IDP_LOCAL_CLAIM_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER IDP_LOCAL_CLAIM_TRIG NO CASCADE + BEFORE INSERT + ON IDP_LOCAL_CLAIM + REFERENCING NEW AS NEW + FOR EACH ROW MODE DB2SQL + BEGIN ATOMIC + SET (NEW.ID) = (NEXTVAL FOR IDP_LOCAL_CLAIM_SEQ); + END +/ +CREATE TABLE IDN_ASSOCIATED_ID ( + ID INTEGER NOT NULL, + IDP_USER_ID VARCHAR(255) NOT NULL, + TENANT_ID INTEGER NOT NULL DEFAULT -1234, + IDP_ID INTEGER NOT NULL, + DOMAIN_NAME VARCHAR(255) NOT NULL, + USER_NAME VARCHAR(255) NOT NULL, + PRIMARY KEY (ID), + UNIQUE(IDP_USER_ID, TENANT_ID, IDP_ID), + FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE) +/ + +CREATE SEQUENCE IDN_ASSOCIATED_ID_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ +CREATE TRIGGER IDN_ASSOCIATED_ID_TRIG NO CASCADE + BEFORE INSERT + ON IDN_ASSOCIATED_ID + REFERENCING NEW AS NEW + FOR EACH ROW MODE DB2SQL + BEGIN ATOMIC + SET (NEW.ID) = (NEXTVAL FOR IDN_ASSOCIATED_ID_SEQ); + END +/ +CREATE TABLE IDN_USER_ACCOUNT_ASSOCIATION ( + ASSOCIATION_KEY VARCHAR(255) NOT NULL, + TENANT_ID INTEGER NOT NULL, + DOMAIN_NAME VARCHAR(255) NOT NULL, + USER_NAME VARCHAR(255) NOT NULL, + PRIMARY KEY (TENANT_ID, DOMAIN_NAME, USER_NAME)) +/ +CREATE TABLE FIDO_DEVICE_STORE ( + TENANT_ID INTEGER NOT NULL, + DOMAIN_NAME VARCHAR(255) NOT NULL, + USER_NAME VARCHAR(45) NOT NULL, + TIME_REGISTERED TIMESTAMP, + KEY_HANDLE VARCHAR(200) NOT NULL, + DEVICE_DATA VARCHAR(2048) NOT NULL, + PRIMARY KEY (TENANT_ID, DOMAIN_NAME, USER_NAME, KEY_HANDLE)) +/ + +CREATE TABLE WF_REQUEST ( + UUID VARCHAR (45) NOT NULL, + CREATED_BY VARCHAR (255), + TENANT_ID INTEGER NOT NULL DEFAULT -1, + OPERATION_TYPE VARCHAR (50), + CREATED_AT TIMESTAMP, + UPDATED_AT TIMESTAMP, + STATUS VARCHAR (30), + REQUEST BLOB, + PRIMARY KEY (UUID)) +/ + +CREATE TABLE WF_BPS_PROFILE ( + PROFILE_NAME VARCHAR(45) NOT NULL, + HOST_URL_MANAGER VARCHAR(255), + HOST_URL_WORKER VARCHAR(255), + USERNAME VARCHAR(45), + PASSWORD VARCHAR(255), + CALLBACK_HOST VARCHAR (45), + TENANT_ID INTEGER NOT NULL DEFAULT -1, + PRIMARY KEY (PROFILE_NAME, TENANT_ID)) +/ + +CREATE TABLE WF_WORKFLOW( + ID VARCHAR (45) NOT NULL, + WF_NAME VARCHAR (45), + DESCRIPTION VARCHAR (255), + TEMPLATE_ID VARCHAR (45), + IMPL_ID VARCHAR (45), + TENANT_ID INTEGER NOT NULL DEFAULT -1, + PRIMARY KEY (ID)) +/ + +CREATE TABLE WF_WORKFLOW_ASSOCIATION( + ID INTEGER NOT NULL, + ASSOC_NAME VARCHAR (45), + EVENT_ID VARCHAR(45), + ASSOC_CONDITION VARCHAR (2000), + WORKFLOW_ID VARCHAR (45), + IS_ENABLED CHAR (1) DEFAULT '1', + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY(ID), + FOREIGN KEY (WORKFLOW_ID) REFERENCES WF_WORKFLOW(ID)ON DELETE CASCADE) +/ + +CREATE SEQUENCE WF_WORKFLOW_ASSOCIATION_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ + +CREATE TRIGGER WF_WORKFLOW_ASSOCIATION_TRIG NO CASCADE + BEFORE INSERT + ON WF_WORKFLOW_ASSOCIATION + REFERENCING NEW AS NEW + FOR EACH ROW MODE DB2SQL + BEGIN ATOMIC + SET (NEW.ID) = (NEXTVAL FOR WF_WORKFLOW_ASSOCIATION_SEQ); + END +/ + +CREATE TABLE WF_WORKFLOW_CONFIG_PARAM( + WORKFLOW_ID VARCHAR (45) NOT NULL, + PARAM_NAME VARCHAR (45) NOT NULL, + PARAM_VALUE VARCHAR (1000), + PARAM_QNAME VARCHAR (45) NOT NULL, + PARAM_HOLDER VARCHAR (45) NOT NULL, + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (WORKFLOW_ID, PARAM_NAME, PARAM_QNAME, PARAM_HOLDER), + FOREIGN KEY (WORKFLOW_ID) REFERENCES WF_WORKFLOW(ID)ON DELETE CASCADE) +/ + +CREATE TABLE WF_REQUEST_ENTITY_RELATIONSHIP( + REQUEST_ID VARCHAR (45) NOT NULL, + ENTITY_NAME VARCHAR (255) NOT NULL, + ENTITY_TYPE VARCHAR (50) NOT NULL, + TENANT_ID INTEGER NOT NULL DEFAULT -1, + PRIMARY KEY(REQUEST_ID, ENTITY_NAME, ENTITY_TYPE, TENANT_ID), + FOREIGN KEY (REQUEST_ID) REFERENCES WF_REQUEST(UUID)ON DELETE CASCADE) +/ + +CREATE TABLE WF_WORKFLOW_REQUEST_RELATION( + RELATIONSHIP_ID VARCHAR (45) NOT NULL, + WORKFLOW_ID VARCHAR (45), + REQUEST_ID VARCHAR (45), + UPDATED_AT TIMESTAMP, + STATUS VARCHAR (30), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (RELATIONSHIP_ID), + FOREIGN KEY (WORKFLOW_ID) REFERENCES WF_WORKFLOW(ID)ON DELETE CASCADE, + FOREIGN KEY (REQUEST_ID) REFERENCES WF_REQUEST(UUID)ON DELETE CASCADE) + / + + +-- End of IDENTITY Tables-- + + +-- Start of API-MGT Tables -- +CREATE TABLE AM_SUBSCRIBER ( + SUBSCRIBER_ID INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + USER_ID VARCHAR(255) NOT NULL, + TENANT_ID INTEGER NOT NULL, + EMAIL_ADDRESS VARCHAR(256) NULL, + DATE_SUBSCRIBED TIMESTAMP NOT NULL, + PRIMARY KEY (SUBSCRIBER_ID), + CREATED_BY VARCHAR(100), + CREATED_TIME TIMESTAMP, + UPDATED_BY VARCHAR(100), + UPDATED_TIME TIMESTAMP, + UNIQUE (TENANT_ID,USER_ID) +)/ + +CREATE TABLE AM_APPLICATION ( + APPLICATION_ID INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + NAME VARCHAR(100) NOT NULL, + SUBSCRIBER_ID INTEGER NOT NULL, + APPLICATION_TIER VARCHAR(50) DEFAULT 'Unlimited', + CALLBACK_URL VARCHAR(512), + DESCRIPTION VARCHAR(512), + APPLICATION_STATUS VARCHAR(50) DEFAULT 'APPROVED', + GROUP_ID VARCHAR(100), + CREATED_BY VARCHAR(100), + CREATED_TIME TIMESTAMP, + UPDATED_BY VARCHAR(100), + UPDATED_TIME TIMESTAMP, + UUID VARCHAR(256), + FOREIGN KEY(SUBSCRIBER_ID) REFERENCES AM_SUBSCRIBER(SUBSCRIBER_ID) ON DELETE RESTRICT, + PRIMARY KEY(APPLICATION_ID), + UNIQUE (NAME,SUBSCRIBER_ID) +)/ + +CREATE TABLE AM_API ( + API_ID INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + API_PROVIDER VARCHAR(200) NOT NULL, + API_NAME VARCHAR(200) NOT NULL, + API_VERSION VARCHAR(30) NOT NULL, + CONTEXT VARCHAR(256), + CONTEXT_TEMPLATE VARCHAR(256), + API_TIER VARCHAR(256), + CREATED_BY VARCHAR(100), + CREATED_TIME TIMESTAMP, + UPDATED_BY VARCHAR(100), + UPDATED_TIME TIMESTAMP, + PRIMARY KEY(API_ID), + UNIQUE (API_PROVIDER,API_NAME,API_VERSION) +)/ + +CREATE TABLE AM_API_URL_MAPPING ( + URL_MAPPING_ID INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + API_ID INTEGER NOT NULL, + HTTP_METHOD VARCHAR(20) NULL, + AUTH_SCHEME VARCHAR(50) NULL, + URL_PATTERN VARCHAR(512) NULL, + THROTTLING_TIER varchar(512) DEFAULT NULL, + MEDIATION_SCRIPT BLOB, + PRIMARY KEY (URL_MAPPING_ID) +)/ + +CREATE TABLE AM_SUBSCRIPTION ( + SUBSCRIPTION_ID INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + TIER_ID VARCHAR(50), + API_ID INTEGER, + LAST_ACCESSED TIMESTAMP NULL, + APPLICATION_ID INTEGER, + SUB_STATUS VARCHAR(50), + SUBS_CREATE_STATE VARCHAR(50) DEFAULT 'SUBSCRIBE', + CREATED_BY VARCHAR(100), + CREATED_TIME TIMESTAMP, + UPDATED_BY VARCHAR(100), + UPDATED_TIME TIMESTAMP, + UUID VARCHAR(256) NOT NULL, + FOREIGN KEY(APPLICATION_ID) REFERENCES AM_APPLICATION(APPLICATION_ID) ON DELETE RESTRICT, + FOREIGN KEY(API_ID) REFERENCES AM_API(API_ID) ON DELETE RESTRICT, + PRIMARY KEY (SUBSCRIPTION_ID), + UNIQUE (UUID) +)/ + +CREATE TABLE AM_SUBSCRIPTION_KEY_MAPPING ( + SUBSCRIPTION_ID INTEGER NOT NULL, + ACCESS_TOKEN VARCHAR(255) NOT NULL, + KEY_TYPE VARCHAR(512) NOT NULL, + FOREIGN KEY(SUBSCRIPTION_ID) REFERENCES AM_SUBSCRIPTION(SUBSCRIPTION_ID) ON DELETE RESTRICT, + PRIMARY KEY(SUBSCRIPTION_ID,ACCESS_TOKEN) +)/ + +CREATE TABLE AM_APPLICATION_KEY_MAPPING ( + APPLICATION_ID INTEGER NOT NULL, + CONSUMER_KEY VARCHAR(255), + KEY_TYPE VARCHAR(512) NOT NULL, + STATE VARCHAR(30) NOT NULL, + CREATE_MODE VARCHAR(30) DEFAULT 'CREATED', + FOREIGN KEY(APPLICATION_ID) REFERENCES AM_APPLICATION(APPLICATION_ID) ON DELETE RESTRICT, + PRIMARY KEY(APPLICATION_ID,KEY_TYPE) +)/ + +CREATE TABLE AM_API_LC_EVENT ( + EVENT_ID INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + API_ID INTEGER NOT NULL, + PREVIOUS_STATE VARCHAR(50), + NEW_STATE VARCHAR(50) NOT NULL, + USER_ID VARCHAR(255) NOT NULL, + TENANT_ID INTEGER NOT NULL, + EVENT_DATE TIMESTAMP NOT NULL, + FOREIGN KEY(API_ID) REFERENCES AM_API(API_ID) ON DELETE RESTRICT, + PRIMARY KEY (EVENT_ID) +)/ + +CREATE TABLE AM_APP_KEY_DOMAIN_MAPPING ( + CONSUMER_KEY VARCHAR(255) NOT NULL, + AUTHZ_DOMAIN VARCHAR(255) NOT NULL DEFAULT 'ALL', + PRIMARY KEY (CONSUMER_KEY,AUTHZ_DOMAIN) +)/ + +CREATE TABLE AM_API_COMMENTS ( + COMMENT_ID INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + COMMENT_TEXT VARCHAR(512), + COMMENTED_USER VARCHAR(255), + DATE_COMMENTED TIMESTAMP NOT NULL, + API_ID INTEGER NOT NULL, + FOREIGN KEY(API_ID) REFERENCES AM_API(API_ID) ON DELETE RESTRICT, + PRIMARY KEY (COMMENT_ID) +)/ + +CREATE TABLE AM_API_RATINGS ( + RATING_ID INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + API_ID INTEGER, + RATING INTEGER, + SUBSCRIBER_ID INTEGER, + FOREIGN KEY(API_ID) REFERENCES AM_API(API_ID) ON DELETE RESTRICT, + FOREIGN KEY(SUBSCRIBER_ID) REFERENCES AM_SUBSCRIBER(SUBSCRIBER_ID) ON DELETE RESTRICT, + PRIMARY KEY (RATING_ID) +)/ + +CREATE TABLE AM_TIER_PERMISSIONS ( + TIER_PERMISSIONS_ID INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + TIER VARCHAR(50) NOT NULL, + PERMISSIONS_TYPE VARCHAR(50) NOT NULL, + ROLES VARCHAR(512) NOT NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY(TIER_PERMISSIONS_ID) +)/ + +CREATE TABLE AM_EXTERNAL_STORES ( + APISTORE_ID INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + API_ID INTEGER, + STORE_ID VARCHAR(255) NOT NULL, + STORE_DISPLAY_NAME VARCHAR(255) NOT NULL, + STORE_ENDPOINT VARCHAR(255) NOT NULL, + STORE_TYPE VARCHAR(255) NOT NULL, + FOREIGN KEY(API_ID) REFERENCES AM_API(API_ID) ON DELETE RESTRICT, + PRIMARY KEY (APISTORE_ID) +) +/ + +CREATE TABLE AM_WORKFLOWS( + WF_ID INTEGER GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + WF_REFERENCE VARCHAR(255) NOT NULL, + WF_TYPE VARCHAR(255) NOT NULL, + WF_STATUS VARCHAR(255) NOT NULL, + WF_CREATED_TIME TIMESTAMP, + WF_UPDATED_TIME TIMESTAMP NOT NULL GENERATED ALWAYS FOR EACH ROW ON UPDATE AS ROW CHANGE TIMESTAMP, + WF_STATUS_DESC VARCHAR(1000), + TENANT_ID INTEGER, + TENANT_DOMAIN VARCHAR(255), + WF_EXTERNAL_REFERENCE VARCHAR(255) NOT NULL, + PRIMARY KEY (WF_ID), + UNIQUE (WF_EXTERNAL_REFERENCE) +)/ + +CREATE TABLE AM_APPLICATION_REGISTRATION ( + REG_ID INT GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + SUBSCRIBER_ID INT NOT NULL, + WF_REF VARCHAR(255) NOT NULL, + APP_ID INT NOT NULL, + TOKEN_TYPE VARCHAR(30) NOT NULL, + TOKEN_SCOPE VARCHAR(256) DEFAULT 'default', + INPUTS VARCHAR(1000), + ALLOWED_DOMAINS VARCHAR(256), + VALIDITY_PERIOD BIGINT, + UNIQUE (SUBSCRIBER_ID,APP_ID,TOKEN_TYPE), + FOREIGN KEY(SUBSCRIBER_ID) REFERENCES AM_SUBSCRIBER(SUBSCRIBER_ID) ON DELETE RESTRICT, + FOREIGN KEY(APP_ID) REFERENCES AM_APPLICATION(APPLICATION_ID) ON DELETE RESTRICT, + PRIMARY KEY (REG_ID) +)/ + +CREATE TABLE AM_API_SCOPES ( + API_ID INTEGER NOT NULL, + SCOPE_ID INTEGER NOT NULL, + FOREIGN KEY (API_ID) REFERENCES AM_API (API_ID) ON DELETE CASCADE , + FOREIGN KEY (SCOPE_ID) REFERENCES IDN_OAUTH2_SCOPE (SCOPE_ID) ON DELETE CASCADE +)/ + +CREATE TABLE AM_API_DEFAULT_VERSION ( + DEFAULT_VERSION_ID INT GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + API_NAME VARCHAR(256) NOT NULL , + API_PROVIDER VARCHAR(256) NOT NULL , + DEFAULT_API_VERSION VARCHAR(30) , + PUBLISHED_DEFAULT_API_VERSION VARCHAR(30) , + PRIMARY KEY (DEFAULT_VERSION_ID) +)/ + +CREATE INDEX IDX_SUB_APP_ID ON AM_SUBSCRIPTION (APPLICATION_ID, SUBSCRIPTION_ID)/ + +CREATE TABLE AM_ALERT_TYPES ( + ALERT_TYPE_ID INT GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + ALERT_TYPE_NAME VARCHAR(256) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL, + PRIMARY KEY (ALERT_TYPE_ID) +)/ + +CREATE TABLE AM_ALERT_TYPES_VALUES ( + ALERT_TYPE_ID INTEGER NOT NULL, + USER_NAME VARCHAR(256) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL , + CONSTRAINT AM_ALERT_TYPES_VALUES_CONSTRAINT UNIQUE (ALERT_TYPE_ID,USER_NAME,STAKE_HOLDER) +)/ + +CREATE TABLE AM_ALERT_EMAILLIST ( + EMAIL_LIST_ID INT GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + USER_NAME VARCHAR(256) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL , + PRIMARY KEY (EMAIL_LIST_ID), + CONSTRAINT AM_ALERT_EMAILLIST_CONSTRAINT UNIQUE (EMAIL_LIST_ID,USER_NAME,STAKE_HOLDER) +)/ + +CREATE TABLE AM_ALERT_EMAILLIST_DETAILS ( + EMAIL_LIST_ID INTEGER NOT NULL, + EMAIL VARCHAR(255) NOT NULL, + CONSTRAINT AM_ALERT_EMAILLIST_DETAILS_CONSTRAINT UNIQUE (EMAIL_LIST_ID,EMAIL) +)/ + +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalResponseTime', 'publisher')/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalBackendTime', 'publisher')/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalRequestsPerMin', 'subscriber')/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('RequestPatternChanged', 'subscriber')/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('UnusualIPAccessAlert', 'subscriber')/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('AbnormalRefreshAlert', 'subscriber')/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('FrequentTierHittingAlert', 'subscriber')/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('AbnormalTierUsage', 'publisher')/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('healthAvailabilityPerMin', 'publisher')/ + + + +-- AM Throttling tables -- + +CREATE TABLE AM_POLICY_SUBSCRIPTION ( + POLICY_ID INT GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + NAME VARCHAR(512) NOT NULL, + DISPLAY_NAME VARCHAR(512) NULL DEFAULT NULL, + TENANT_ID INT NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + QUOTA_TYPE VARCHAR(25) NOT NULL, + QUOTA INT NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL, + UNIT_TIME INT NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + RATE_LIMIT_COUNT INT NULL DEFAULT NULL, + RATE_LIMIT_TIME_UNIT VARCHAR(25) NULL DEFAULT NULL, + IS_DEPLOYED SMALLINT NOT NULL DEFAULT 0, + CUSTOM_ATTRIBUTES BLOB DEFAULT NULL, + STOP_ON_QUOTA_REACH SMALLINT NOT NULL DEFAULT 0, + BILLING_PLAN VARCHAR(20) NOT NULL, + UUID VARCHAR(256) NOT NULL, + PRIMARY KEY (POLICY_ID), + CONSTRAINT AM_POLICY_SUBSCRIPTION_NAME_TENANT UNIQUE (NAME, TENANT_ID), + UNIQUE (UUID) +)/ + +CREATE TABLE AM_POLICY_APPLICATION ( + POLICY_ID INT GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + NAME VARCHAR(512) NOT NULL, + DISPLAY_NAME VARCHAR(512) NULL DEFAULT NULL, + TENANT_ID INT NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + QUOTA_TYPE VARCHAR(25) NOT NULL, + QUOTA INT NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL DEFAULT NULL, + UNIT_TIME INT NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + IS_DEPLOYED SMALLINT NOT NULL DEFAULT 0, + CUSTOM_ATTRIBUTES BLOB DEFAULT NULL, + UUID VARCHAR(256) NOT NULL, + PRIMARY KEY (POLICY_ID), + CONSTRAINT APP_NAME_TENANT UNIQUE (NAME, TENANT_ID), + UNIQUE (UUID) +)/ + +CREATE TABLE AM_POLICY_HARD_THROTTLING ( + POLICY_ID INT GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + NAME VARCHAR(512) NOT NULL, + TENANT_ID INT NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + QUOTA_TYPE VARCHAR(25) NOT NULL, + QUOTA INT NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL DEFAULT NULL, + UNIT_TIME INT NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + IS_DEPLOYED SMALLINT NOT NULL DEFAULT 0, + PRIMARY KEY (POLICY_ID), + CONSTRAINT POLICY_HARD_NAME_TENANT UNIQUE (NAME, TENANT_ID) +)/ + + +CREATE TABLE AM_API_THROTTLE_POLICY ( + POLICY_ID INT GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + NAME VARCHAR(512) NOT NULL, + DISPLAY_NAME VARCHAR(512) NULL DEFAULT NULL, + TENANT_ID INT NOT NULL, + DESCRIPTION VARCHAR (1024), + DEFAULT_QUOTA_TYPE VARCHAR(25) NOT NULL, + DEFAULT_QUOTA INTEGER NOT NULL, + DEFAULT_QUOTA_UNIT VARCHAR(10) NULL, + DEFAULT_UNIT_TIME INTEGER NOT NULL, + DEFAULT_TIME_UNIT VARCHAR(25) NOT NULL, + APPLICABLE_LEVEL VARCHAR(25) NOT NULL, + IS_DEPLOYED SMALLINT NOT NULL DEFAULT 0, + UUID VARCHAR(256) NOT NULL, + PRIMARY KEY (POLICY_ID), + CONSTRAINT API_NAME_TENANT UNIQUE (NAME, TENANT_ID), + UNIQUE (UUID) +)/ + +CREATE TABLE AM_CONDITION_GROUP ( + CONDITION_GROUP_ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + POLICY_ID INTEGER NOT NULL, + QUOTA_TYPE VARCHAR(25), + QUOTA INTEGER NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL DEFAULT NULL, + UNIT_TIME INTEGER NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + DESCRIPTION VARCHAR (1024) NULL DEFAULT NULL, + PRIMARY KEY (CONDITION_GROUP_ID), + FOREIGN KEY (POLICY_ID) REFERENCES AM_API_THROTTLE_POLICY(POLICY_ID) ON DELETE CASCADE +)/ + +CREATE TABLE AM_QUERY_PARAMETER_CONDITION ( + QUERY_PARAMETER_ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + CONDITION_GROUP_ID INTEGER NOT NULL, + PARAMETER_NAME VARCHAR(255) DEFAULT NULL, + PARAMETER_VALUE VARCHAR(255) DEFAULT NULL, + IS_PARAM_MAPPING SMALLINT DEFAULT 1, + PRIMARY KEY (QUERY_PARAMETER_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE +)/ + +CREATE TABLE AM_HEADER_FIELD_CONDITION ( + HEADER_FIELD_ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + CONDITION_GROUP_ID INTEGER NOT NULL, + HEADER_FIELD_NAME VARCHAR(255) DEFAULT NULL, + HEADER_FIELD_VALUE VARCHAR(255) DEFAULT NULL, + IS_HEADER_FIELD_MAPPING SMALLINT DEFAULT 1, + PRIMARY KEY (HEADER_FIELD_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE +)/ + +CREATE TABLE AM_JWT_CLAIM_CONDITION ( + JWT_CLAIM_ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + CONDITION_GROUP_ID INTEGER NOT NULL, + CLAIM_URI VARCHAR(512) DEFAULT NULL, + CLAIM_ATTRIB VARCHAR(1024) DEFAULT NULL, + IS_CLAIM_MAPPING SMALLINT DEFAULT 1, + PRIMARY KEY (JWT_CLAIM_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE +)/ + +CREATE TABLE AM_IP_CONDITION ( + AM_IP_CONDITION_ID INT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + STARTING_IP VARCHAR(45) NULL, + ENDING_IP VARCHAR(45) NULL, + SPECIFIC_IP VARCHAR(45) NULL, + WITHIN_IP_RANGE SMALLINT DEFAULT 1, + CONDITION_GROUP_ID INT NULL, + PRIMARY KEY (AM_IP_CONDITION_ID), + CONSTRAINT fk_AM_IP_CONDITION_1 FOREIGN KEY (CONDITION_GROUP_ID) + REFERENCES AM_CONDITION_GROUP (CONDITION_GROUP_ID) ON DELETE CASCADE) +/ + +CREATE INDEX fk_AM_IP_CONDITION_1_idx ON AM_IP_CONDITION (CONDITION_GROUP_ID) +/ + +CREATE TABLE AM_POLICY_GLOBAL ( + POLICY_ID INT GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + NAME VARCHAR(512) NOT NULL, + KEY_TEMPLATE VARCHAR(512) NOT NULL, + TENANT_ID INT NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + SIDDHI_QUERY BLOB DEFAULT NULL, + IS_DEPLOYED SMALLINT NOT NULL DEFAULT 0, + UUID VARCHAR(256) NOT NULL, + PRIMARY KEY (POLICY_ID), + UNIQUE (UUID) +)/ + +CREATE TABLE AM_THROTTLE_TIER_PERMISSIONS ( + THROTTLE_TIER_PERMISSIONS_ID INT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + TIER VARCHAR(50) NULL, + PERMISSIONS_TYPE VARCHAR(50) NULL, + ROLES VARCHAR(512) NULL, + TENANT_ID INT NULL, + PRIMARY KEY (THROTTLE_TIER_PERMISSIONS_ID)) +/ + +CREATE TABLE AM_BLOCK_CONDITIONS ( + CONDITION_ID INT NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1 INCREMENT BY 1), + TYPE varchar(45) DEFAULT NULL, + VALUE varchar(45) DEFAULT NULL, + ENABLED varchar(45) DEFAULT NULL, + DOMAIN varchar(45) DEFAULT NULL, + UUID VARCHAR(256) NOT NULL, + PRIMARY KEY (CONDITION_ID), + UNIQUE (UUID) +) / + +-- End of API-MGT Tables -- + +-- Performance indexes start-- + +create index IDX_ITS_LMT on IDN_THRIFT_SESSION (LAST_MODIFIED_TIME)/ +create index IDX_IOAT_AT on IDN_OAUTH2_ACCESS_TOKEN (ACCESS_TOKEN)/ +create index IDX_IOAT_UT on IDN_OAUTH2_ACCESS_TOKEN (USER_TYPE)/ +create index IDX_AAI_CTX on AM_API (CONTEXT)/ +create index IDX_AAKM_CK on AM_APPLICATION_KEY_MAPPING (CONSUMER_KEY)/ +create index IDX_AAUM_AI on AM_API_URL_MAPPING (API_ID)/ +create index IDX_AAUM_TT on AM_API_URL_MAPPING (THROTTLING_TIER)/ +create index IDX_AATP_DQT on AM_API_THROTTLE_POLICY (DEFAULT_QUOTA_TYPE)/ +create index IDX_ACG_QT on AM_CONDITION_GROUP (QUOTA_TYPE)/ +create index IDX_APS_QT on AM_POLICY_SUBSCRIPTION (QUOTA_TYPE)/ +create index IDX_AS_AITIAI on AM_SUBSCRIPTION (API_ID,TIER_ID,APPLICATION_ID)/ +create index IDX_APA_QT on AM_POLICY_APPLICATION (QUOTA_TYPE)/ +create index IDX_AA_AT_CB on AM_APPLICATION (APPLICATION_TIER,CREATED_BY)/ + +-- Performance indexes end-- diff --git a/modules/distribution/src/repository/resources/dbscripts/apimgt/h2.sql b/modules/distribution/src/repository/resources/dbscripts/apimgt/h2.sql index 5e0695be..d4ba2707 100644 --- a/modules/distribution/src/repository/resources/dbscripts/apimgt/h2.sql +++ b/modules/distribution/src/repository/resources/dbscripts/apimgt/h2.sql @@ -17,6 +17,8 @@ CREATE TABLE IF NOT EXISTS IDN_OAUTH_CONSUMER_APPS ( OAUTH_VERSION VARCHAR (128), CALLBACK_URL VARCHAR (1024), GRANT_TYPES VARCHAR (1024), + PKCE_MANDATORY CHAR(1) DEFAULT '0', + PKCE_SUPPORT_PLAIN CHAR(1) DEFAULT '0', CONSTRAINT CONSUMER_KEY_CONSTRAINT UNIQUE (CONSUMER_KEY), PRIMARY KEY (ID) ); @@ -88,6 +90,8 @@ CREATE TABLE IF NOT EXISTS IDN_OAUTH2_AUTHORIZATION_CODE ( STATE VARCHAR (25) DEFAULT 'ACTIVE', TOKEN_ID VARCHAR(255), SUBJECT_IDENTIFIER VARCHAR(255), + PKCE_CODE_CHALLENGE VARCHAR (255), + PKCE_CODE_CHALLENGE_METHOD VARCHAR(128), PRIMARY KEY (CODE_ID), FOREIGN KEY (CONSUMER_KEY_ID) REFERENCES IDN_OAUTH_CONSUMER_APPS(ID) ON DELETE CASCADE ); @@ -199,7 +203,7 @@ CREATE TABLE IDN_AUTH_SESSION_STORE ( SESSION_OBJECT BLOB, TIME_CREATED BIGINT, TENANT_ID INTEGER DEFAULT -1, - PRIMARY KEY (SESSION_ID, SESSION_TYPE, TIME_CREATED, OPERATION) + PRIMARY KEY (SESSION_ID, SESSION_TYPE, TIME_CREATED, OPERATION) ); CREATE TABLE IF NOT EXISTS SP_APP ( ID INTEGER NOT NULL AUTO_INCREMENT, @@ -331,6 +335,7 @@ CREATE TABLE IF NOT EXISTS IDP ( DISPLAY_NAME VARCHAR(255), PRIMARY KEY (ID), UNIQUE (TENANT_ID, NAME)); + INSERT INTO IDP (TENANT_ID, NAME, HOME_REALM_ID) VALUES (-1234, 'LOCAL', 'localhost'); CREATE TABLE IF NOT EXISTS IDP_ROLE ( @@ -410,8 +415,7 @@ CREATE TABLE IF NOT EXISTS IDP_AUTHENTICATOR_PROPERTY ( IS_SECRET CHAR (1) DEFAULT '0', PRIMARY KEY (ID), UNIQUE (TENANT_ID, AUTHENTICATOR_ID, PROPERTY_KEY), - FOREIGN KEY (AUTHENTICATOR_ID) REFERENCES IDP_AUTHENTICATOR(ID) ON DELETE CASCADE -); + FOREIGN KEY (AUTHENTICATOR_ID) REFERENCES IDP_AUTHENTICATOR(ID) ON DELETE CASCADE); INSERT INTO IDP_AUTHENTICATOR_PROPERTY (TENANT_ID, AUTHENTICATOR_ID, PROPERTY_KEY,PROPERTY_VALUE, IS_SECRET ) VALUES (-1234, 1 , 'IdPEntityId', 'localhost', '0'); INSERT INTO IDP_AUTHENTICATOR_PROPERTY (TENANT_ID, AUTHENTICATOR_ID, PROPERTY_KEY,PROPERTY_VALUE, IS_SECRET ) VALUES (-1234, 3 , 'IdPEntityId', 'localhost', '0'); @@ -465,7 +469,6 @@ CREATE TABLE IF NOT EXISTS IDP_LOCAL_CLAIM ( UNIQUE (TENANT_ID, IDP_ID, CLAIM_URI), FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE); - CREATE TABLE IF NOT EXISTS IDN_ASSOCIATED_ID ( ID INTEGER AUTO_INCREMENT, IDP_USER_ID VARCHAR(255) NOT NULL, @@ -508,8 +511,8 @@ CREATE TABLE IF NOT EXISTS WF_REQUEST ( CREATE TABLE IF NOT EXISTS WF_BPS_PROFILE ( PROFILE_NAME VARCHAR(45), - HOST_URL_MANAGER VARCHAR(45), - HOST_URL_WORKER VARCHAR(45), + HOST_URL_MANAGER VARCHAR(255), + HOST_URL_WORKER VARCHAR(255), USERNAME VARCHAR(45), PASSWORD VARCHAR(255), CALLBACK_HOST VARCHAR (45), @@ -613,6 +616,7 @@ CREATE TABLE IF NOT EXISTS AM_API ( API_VERSION VARCHAR(30), CONTEXT VARCHAR(256), CONTEXT_TEMPLATE VARCHAR(256), + API_TIER VARCHAR(256), PRIMARY KEY(API_ID), CREATED_BY VARCHAR(100), CREATED_TIME TIMESTAMP, @@ -777,4 +781,209 @@ CREATE TABLE IF NOT EXISTS AM_API_DEFAULT_VERSION ( CREATE INDEX IDX_SUB_APP_ID ON AM_SUBSCRIPTION (APPLICATION_ID, SUBSCRIPTION_ID); --- End of API-MGT Tables -- \ No newline at end of file + +CREATE TABLE IF NOT EXISTS AM_ALERT_TYPES ( + ALERT_TYPE_ID INTEGER AUTO_INCREMENT, + ALERT_TYPE_NAME VARCHAR(256) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL, + PRIMARY KEY (ALERT_TYPE_ID) +); + +CREATE TABLE IF NOT EXISTS AM_ALERT_TYPES_VALUES ( + ALERT_TYPE_ID INTEGER, + USER_NAME VARCHAR(256) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL , + CONSTRAINT AM_ALERT_TYPES_VALUES_CONSTRAINT UNIQUE (ALERT_TYPE_ID,USER_NAME,STAKE_HOLDER) +); + +CREATE TABLE IF NOT EXISTS AM_ALERT_EMAILLIST ( + EMAIL_LIST_ID INTEGER AUTO_INCREMENT, + USER_NAME VARCHAR(255) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL , + PRIMARY KEY (EMAIL_LIST_ID), + CONSTRAINT AM_ALERT_EMAILLIST_CONSTRAINT UNIQUE (EMAIL_LIST_ID,USER_NAME,STAKE_HOLDER) +); + +CREATE TABLE IF NOT EXISTS AM_ALERT_EMAILLIST_DETAILS ( + EMAIL_LIST_ID INTEGER, + EMAIL VARCHAR(255), + CONSTRAINT AM_ALERT_EMAILLIST_DETAILS_CONSTRAINT UNIQUE (EMAIL_LIST_ID,EMAIL) +); + +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalResponseTime', 'publisher'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalBackendTime', 'publisher'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalRequestsPerMin', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('RequestPatternChanged', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('UnusualIPAccessAlert', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('AbnormalRefreshAlert', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('FrequentTierHittingAlert', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('AbnormalTierUsage', 'publisher'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('healthAvailabilityPerMin', 'publisher'); + + +-- AM Throttling tables -- + +CREATE TABLE IF NOT EXISTS AM_POLICY_SUBSCRIPTION ( + POLICY_ID INT(11) NOT NULL AUTO_INCREMENT, + NAME VARCHAR(512) NOT NULL, + DISPLAY_NAME VARCHAR(512) NULL DEFAULT NULL, + TENANT_ID INT(11) NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + QUOTA_TYPE VARCHAR(25) NOT NULL, + QUOTA INT(11) NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL, + UNIT_TIME INT(11) NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + RATE_LIMIT_COUNT INT(11) NULL DEFAULT NULL, + RATE_LIMIT_TIME_UNIT VARCHAR(25) NULL DEFAULT NULL, + IS_DEPLOYED TINYINT(1) NOT NULL DEFAULT 0, + CUSTOM_ATTRIBUTES BLOB DEFAULT NULL, + STOP_ON_QUOTA_REACH BOOLEAN NOT NULL DEFAULT 0, + BILLING_PLAN VARCHAR(20) NOT NULL, + UUID VARCHAR(256), + PRIMARY KEY (POLICY_ID), + UNIQUE INDEX AM_POLICY_SUBSCRIPTION_NAME_TENANT (NAME, TENANT_ID), + UNIQUE (UUID) +); + +CREATE TABLE IF NOT EXISTS AM_POLICY_APPLICATION ( + POLICY_ID INT(11) NOT NULL AUTO_INCREMENT, + NAME VARCHAR(512) NOT NULL, + DISPLAY_NAME VARCHAR(512) NULL DEFAULT NULL, + TENANT_ID INT(11) NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + QUOTA_TYPE VARCHAR(25) NOT NULL, + QUOTA INT(11) NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL DEFAULT NULL, + UNIT_TIME INT(11) NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + IS_DEPLOYED TINYINT(1) NOT NULL DEFAULT 0, + CUSTOM_ATTRIBUTES BLOB DEFAULT NULL, + UUID VARCHAR(256), + PRIMARY KEY (POLICY_ID), + UNIQUE INDEX APP_NAME_TENANT (NAME, TENANT_ID), + UNIQUE (UUID) +); + +CREATE TABLE IF NOT EXISTS AM_POLICY_HARD_THROTTLING ( + POLICY_ID INT(11) NOT NULL AUTO_INCREMENT, + NAME VARCHAR(512) NOT NULL, + TENANT_ID INT(11) NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + QUOTA_TYPE VARCHAR(25) NOT NULL, + QUOTA INT(11) NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL DEFAULT NULL, + UNIT_TIME INT(11) NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + IS_DEPLOYED TINYINT(1) NOT NULL DEFAULT 0, + PRIMARY KEY (POLICY_ID), + UNIQUE INDEX POLICY_HARD_NAME_TENANT (NAME, TENANT_ID) +); + + +CREATE TABLE IF NOT EXISTS AM_API_THROTTLE_POLICY ( + POLICY_ID INT(11) NOT NULL AUTO_INCREMENT, + NAME VARCHAR(512) NOT NULL, + DISPLAY_NAME VARCHAR(512) NULL DEFAULT NULL, + TENANT_ID INT(11) NOT NULL, + DESCRIPTION VARCHAR (1024), + DEFAULT_QUOTA_TYPE VARCHAR(25) NOT NULL, + DEFAULT_QUOTA INTEGER NOT NULL, + DEFAULT_QUOTA_UNIT VARCHAR(10) NULL, + DEFAULT_UNIT_TIME INTEGER NOT NULL, + DEFAULT_TIME_UNIT VARCHAR(25) NOT NULL, + APPLICABLE_LEVEL VARCHAR(25) NOT NULL, + IS_DEPLOYED TINYINT(1) NOT NULL DEFAULT 0, + UUID VARCHAR(256), + PRIMARY KEY (POLICY_ID), + UNIQUE INDEX API_NAME_TENANT (NAME, TENANT_ID), + UNIQUE (UUID) +); + +CREATE TABLE IF NOT EXISTS AM_CONDITION_GROUP ( + CONDITION_GROUP_ID INTEGER NOT NULL AUTO_INCREMENT, + POLICY_ID INTEGER NOT NULL, + QUOTA_TYPE VARCHAR(25), + QUOTA INTEGER NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL DEFAULT NULL, + UNIT_TIME INTEGER NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + DESCRIPTION VARCHAR (1024) NULL DEFAULT NULL, + PRIMARY KEY (CONDITION_GROUP_ID), + FOREIGN KEY (POLICY_ID) REFERENCES AM_API_THROTTLE_POLICY(POLICY_ID) ON DELETE CASCADE ON UPDATE CASCADE +); + +CREATE TABLE IF NOT EXISTS AM_QUERY_PARAMETER_CONDITION ( + QUERY_PARAMETER_ID INTEGER NOT NULL AUTO_INCREMENT, + CONDITION_GROUP_ID INTEGER NOT NULL, + PARAMETER_NAME VARCHAR(255) DEFAULT NULL, + PARAMETER_VALUE VARCHAR(255) DEFAULT NULL, + IS_PARAM_MAPPING BOOLEAN DEFAULT 1, + PRIMARY KEY (QUERY_PARAMETER_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE +); + +CREATE TABLE IF NOT EXISTS AM_HEADER_FIELD_CONDITION ( + HEADER_FIELD_ID INTEGER NOT NULL AUTO_INCREMENT, + CONDITION_GROUP_ID INTEGER NOT NULL, + HEADER_FIELD_NAME VARCHAR(255) DEFAULT NULL, + HEADER_FIELD_VALUE VARCHAR(255) DEFAULT NULL, + IS_HEADER_FIELD_MAPPING BOOLEAN DEFAULT 1, + PRIMARY KEY (HEADER_FIELD_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE +); + +CREATE TABLE IF NOT EXISTS AM_JWT_CLAIM_CONDITION ( + JWT_CLAIM_ID INTEGER NOT NULL AUTO_INCREMENT, + CONDITION_GROUP_ID INTEGER NOT NULL, + CLAIM_URI VARCHAR(512) DEFAULT NULL, + CLAIM_ATTRIB VARCHAR(1024) DEFAULT NULL, + IS_CLAIM_MAPPING BOOLEAN DEFAULT 1, + PRIMARY KEY (JWT_CLAIM_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE +); + +CREATE TABLE IF NOT EXISTS AM_IP_CONDITION ( + AM_IP_CONDITION_ID INT NOT NULL AUTO_INCREMENT, + STARTING_IP VARCHAR(45) NULL, + ENDING_IP VARCHAR(45) NULL, + SPECIFIC_IP VARCHAR(45) NULL, + WITHIN_IP_RANGE BOOLEAN DEFAULT 1, + CONDITION_GROUP_ID INT NULL, + PRIMARY KEY (AM_IP_CONDITION_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP (CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE); + + +CREATE TABLE IF NOT EXISTS AM_POLICY_GLOBAL ( + POLICY_ID INT(11) NOT NULL AUTO_INCREMENT, + NAME VARCHAR(512) NOT NULL, + KEY_TEMPLATE VARCHAR(512) NOT NULL, + TENANT_ID INT(11) NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + SIDDHI_QUERY BLOB DEFAULT NULL, + IS_DEPLOYED TINYINT(1) NOT NULL DEFAULT 0, + UUID VARCHAR(256), + PRIMARY KEY (POLICY_ID), + UNIQUE (UUID) +); + +CREATE TABLE IF NOT EXISTS AM_THROTTLE_TIER_PERMISSIONS ( + THROTTLE_TIER_PERMISSIONS_ID INT NOT NULL AUTO_INCREMENT, + TIER VARCHAR(50) NULL, + PERMISSIONS_TYPE VARCHAR(50) NULL, + ROLES VARCHAR(512) NULL, + TENANT_ID INT(11) NULL, + PRIMARY KEY (THROTTLE_TIER_PERMISSIONS_ID)); + +CREATE TABLE `AM_BLOCK_CONDITIONS` ( + `CONDITION_ID` int(11) NOT NULL AUTO_INCREMENT, + `TYPE` varchar(45) DEFAULT NULL, + `VALUE` varchar(45) DEFAULT NULL, + `ENABLED` varchar(45) DEFAULT NULL, + `DOMAIN` varchar(45) DEFAULT NULL, + `UUID` VARCHAR(256), + PRIMARY KEY (`CONDITION_ID`), + UNIQUE (UUID) +); + +-- End of API-MGT Tables -- diff --git a/modules/distribution/src/repository/resources/dbscripts/apimgt/mssql.sql b/modules/distribution/src/repository/resources/dbscripts/apimgt/mssql.sql index fff85c55..058d18ff 100644 --- a/modules/distribution/src/repository/resources/dbscripts/apimgt/mssql.sql +++ b/modules/distribution/src/repository/resources/dbscripts/apimgt/mssql.sql @@ -19,6 +19,8 @@ CREATE TABLE IDN_OAUTH_CONSUMER_APPS ( OAUTH_VERSION VARCHAR(128), CALLBACK_URL VARCHAR(1024), GRANT_TYPES VARCHAR(1024), + PKCE_MANDATORY CHAR(1) DEFAULT '0', + PKCE_SUPPORT_PLAIN CHAR(1) DEFAULT '0', CONSTRAINT CONSUMER_KEY_CONSTRAINT UNIQUE (CONSUMER_KEY), PRIMARY KEY (ID) ); @@ -97,6 +99,8 @@ CREATE TABLE IDN_OAUTH2_AUTHORIZATION_CODE ( STATE VARCHAR (25) DEFAULT 'ACTIVE', TOKEN_ID VARCHAR(255), SUBJECT_IDENTIFIER VARCHAR(255), + PKCE_CODE_CHALLENGE VARCHAR (255), + PKCE_CODE_CHALLENGE_METHOD VARCHAR(128), PRIMARY KEY (CODE_ID), FOREIGN KEY (CONSUMER_KEY_ID) REFERENCES IDN_OAUTH_CONSUMER_APPS(ID) ON DELETE CASCADE ); @@ -242,9 +246,8 @@ CREATE TABLE SP_APP ( SUBJECT_CLAIM_URI VARCHAR (512), IS_SAAS_APP CHAR(1) DEFAULT '0', IS_DUMB_MODE CHAR(1) DEFAULT '0', - PRIMARY KEY (ID)); - -ALTER TABLE SP_APP ADD CONSTRAINT APPLICATION_NAME_CONSTRAINT UNIQUE(APP_NAME, TENANT_ID); + PRIMARY KEY (ID), + CONSTRAINT APPLICATION_NAME_CONSTRAINT UNIQUE(APP_NAME, TENANT_ID)); IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[SP_METADATA]') AND TYPE IN (N'U')) CREATE TABLE SP_METADATA ( @@ -267,9 +270,8 @@ CREATE TABLE SP_INBOUND_AUTH ( PROP_NAME VARCHAR (255), PROP_VALUE VARCHAR (1024) , APP_ID INTEGER NOT NULL, - PRIMARY KEY (ID)); - -ALTER TABLE SP_INBOUND_AUTH ADD CONSTRAINT APPLICATION_ID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE; + PRIMARY KEY (ID), + CONSTRAINT APPLICATION_ID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE); IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[SP_AUTH_STEP]') AND TYPE IN (N'U')) CREATE TABLE SP_AUTH_STEP ( @@ -279,18 +281,16 @@ CREATE TABLE SP_AUTH_STEP ( APP_ID INTEGER NOT NULL, IS_SUBJECT_STEP CHAR(1) DEFAULT '0', IS_ATTRIBUTE_STEP CHAR(1) DEFAULT '0', - PRIMARY KEY (ID)); - -ALTER TABLE SP_AUTH_STEP ADD CONSTRAINT APPLICATION_ID_CONSTRAINT_STEP FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE; + PRIMARY KEY (ID), + CONSTRAINT APPLICATION_ID_CONSTRAINT_STEP FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE); IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[SP_FEDERATED_IDP]') AND TYPE IN (N'U')) CREATE TABLE SP_FEDERATED_IDP ( ID INTEGER NOT NULL, TENANT_ID INTEGER NOT NULL, AUTHENTICATOR_ID INTEGER NOT NULL, - PRIMARY KEY (ID, AUTHENTICATOR_ID)); - -ALTER TABLE SP_FEDERATED_IDP ADD CONSTRAINT STEP_ID_CONSTRAINT FOREIGN KEY (ID) REFERENCES SP_AUTH_STEP (ID) ON DELETE CASCADE; + PRIMARY KEY (ID, AUTHENTICATOR_ID), + CONSTRAINT STEP_ID_CONSTRAINT FOREIGN KEY (ID) REFERENCES SP_AUTH_STEP (ID) ON DELETE CASCADE); IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[SP_CLAIM_MAPPING]') AND TYPE IN (N'U')) CREATE TABLE SP_CLAIM_MAPPING ( @@ -301,9 +301,8 @@ CREATE TABLE SP_CLAIM_MAPPING ( APP_ID INTEGER NOT NULL, IS_REQUESTED VARCHAR(128) DEFAULT '0', DEFAULT_VALUE VARCHAR(255), - PRIMARY KEY (ID)); - -ALTER TABLE SP_CLAIM_MAPPING ADD CONSTRAINT CLAIMID_APPID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE; + PRIMARY KEY (ID), + CONSTRAINT CLAIMID_APPID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE); IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[SP_ROLE_MAPPING]') AND TYPE IN (N'U')) CREATE TABLE SP_ROLE_MAPPING ( @@ -311,10 +310,9 @@ CREATE TABLE SP_ROLE_MAPPING ( TENANT_ID INTEGER NOT NULL, IDP_ROLE VARCHAR (255) NOT NULL , SP_ROLE VARCHAR (255) NOT NULL , - APP_ID INTEGER NOT NULL, - PRIMARY KEY (ID)); - -ALTER TABLE SP_ROLE_MAPPING ADD CONSTRAINT ROLEID_APPID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE; + APP_ID INTEGER NOT NULL, + PRIMARY KEY (ID), + CONSTRAINT ROLEID_APPID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE); IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[SP_REQ_PATH_AUTHENTICATOR]') AND TYPE IN (N'U')) CREATE TABLE SP_REQ_PATH_AUTHENTICATOR ( @@ -322,9 +320,8 @@ CREATE TABLE SP_REQ_PATH_AUTHENTICATOR ( TENANT_ID INTEGER NOT NULL, AUTHENTICATOR_NAME VARCHAR (255) NOT NULL , APP_ID INTEGER NOT NULL, - PRIMARY KEY (ID)); - -ALTER TABLE SP_REQ_PATH_AUTHENTICATOR ADD CONSTRAINT REQ_AUTH_APPID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE; + PRIMARY KEY (ID), + CONSTRAINT REQ_AUTH_APPID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE); IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[SP_PROVISIONING_CONNECTOR]') AND TYPE IN (N'U')) CREATE TABLE SP_PROVISIONING_CONNECTOR ( @@ -335,9 +332,8 @@ CREATE TABLE SP_PROVISIONING_CONNECTOR ( APP_ID INTEGER NOT NULL, IS_JIT_ENABLED CHAR(1) NOT NULL DEFAULT '0', BLOCKING CHAR(1) NOT NULL DEFAULT '0', - PRIMARY KEY (ID)); - -ALTER TABLE SP_PROVISIONING_CONNECTOR ADD CONSTRAINT PRO_CONNECTOR_APPID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE; + PRIMARY KEY (ID), + CONSTRAINT PRO_CONNECTOR_APPID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE); IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[IDP]') AND TYPE IN (N'U')) CREATE TABLE IDP ( @@ -361,7 +357,7 @@ CREATE TABLE IDP ( IS_FEDERATION_HUB CHAR(1) NOT NULL DEFAULT '0', IS_LOCAL_CLAIM_DIALECT CHAR(1) NOT NULL DEFAULT '0', PRIMARY KEY (ID), - DISPLAY_NAME VARCHAR(255), + DISPLAY_NAME VARCHAR(255), UNIQUE (TENANT_ID, NAME)); INSERT INTO IDP (TENANT_ID, NAME, HOME_REALM_ID) VALUES (-1234, 'LOCAL', 'localhost'); @@ -555,13 +551,11 @@ CREATE TABLE WF_REQUEST ( IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[WF_BPS_PROFILE]') AND TYPE IN (N'U')) CREATE TABLE WF_BPS_PROFILE ( PROFILE_NAME VARCHAR(45), - HOST_URL_MANAGER VARCHAR(45), - HOST_URL_WORKER VARCHAR(45), + HOST_URL_MANAGER VARCHAR(255), + HOST_URL_WORKER VARCHAR(255), USERNAME VARCHAR(45), PASSWORD VARCHAR(255), CALLBACK_HOST VARCHAR (45), - CALLBACK_USERNAME VARCHAR (45), - CALLBACK_PASSWORD VARCHAR (255), TENANT_ID INTEGER DEFAULT -1, PRIMARY KEY (PROFILE_NAME, TENANT_ID) ); @@ -625,6 +619,7 @@ CREATE TABLE WF_WORKFLOW_REQUEST_RELATION( FOREIGN KEY (REQUEST_ID) REFERENCES WF_REQUEST(UUID)ON DELETE CASCADE ); + -- Start of API-Mgt Tables -- IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[AM_SUBSCRIBER]') AND TYPE IN (N'U')) @@ -674,6 +669,7 @@ CREATE TABLE AM_API ( API_VERSION VARCHAR(30), CONTEXT VARCHAR(256), CONTEXT_TEMPLATE VARCHAR(256), + API_TIER VARCHAR(256), CREATED_BY VARCHAR(100), CREATED_TIME DATETIME, UPDATED_BY VARCHAR(100), @@ -865,4 +861,243 @@ CREATE TABLE AM_API_DEFAULT_VERSION ( ); -CREATE INDEX IDX_SUB_APP_ID ON AM_SUBSCRIPTION (APPLICATION_ID, SUBSCRIPTION_ID); \ No newline at end of file +CREATE INDEX IDX_SUB_APP_ID ON AM_SUBSCRIPTION (APPLICATION_ID, SUBSCRIPTION_ID); + + + +CREATE TABLE AM_ALERT_TYPES ( + ALERT_TYPE_ID INTEGER NOT NULL IDENTITY, + ALERT_TYPE_NAME VARCHAR(255) NOT NULL , + STAKE_HOLDER VARCHAR(10) NOT NULL, + PRIMARY KEY (ALERT_TYPE_ID) +); + +CREATE TABLE AM_ALERT_TYPES_VALUES ( + ALERT_TYPE_ID INTEGER, + USER_NAME VARCHAR(255) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL , + CONSTRAINT AM_ALERT_TYPES_VALUES_CONST UNIQUE (ALERT_TYPE_ID,USER_NAME,STAKE_HOLDER) +); + +CREATE TABLE AM_ALERT_EMAILLIST ( + EMAIL_LIST_ID INTEGER NOT NULL IDENTITY, + USER_NAME VARCHAR(255) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL , + CONSTRAINT AM_ALERT_EMAILLIST_CONST UNIQUE (EMAIL_LIST_ID,USER_NAME,STAKE_HOLDER), + PRIMARY KEY (EMAIL_LIST_ID) +); + +CREATE TABLE AM_ALERT_EMAILLIST_DETAILS ( + EMAIL_LIST_ID INTEGER, + EMAIL VARCHAR(255), + CONSTRAINT AM_ALERT_EMAILLIST_DETAILS_CONST UNIQUE (EMAIL_LIST_ID,EMAIL) +); + +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalResponseTime', 'publisher'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalBackendTime', 'publisher'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalRequestsPerMin', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('RequestPatternChanged', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('UnusualIPAccessAlert', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('AbnormalRefreshAlert', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('FrequentTierHittingAlert', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('AbnormalTierUsage', 'publisher'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('healthAvailabilityPerMin', 'publisher'); + + + +-- AM Throttling tables -- +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[AM_POLICY_SUBSCRIPTION]') AND TYPE IN (N'U')) +CREATE TABLE AM_POLICY_SUBSCRIPTION ( + POLICY_ID INTEGER IDENTITY(1,1), + NAME VARCHAR(512) NOT NULL, + DISPLAY_NAME VARCHAR(512) NULL DEFAULT NULL, + TENANT_ID INTEGER NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + QUOTA_TYPE VARCHAR(25) NOT NULL, + QUOTA INTEGER NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL, + UNIT_TIME INTEGER NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + RATE_LIMIT_COUNT INTEGER NULL DEFAULT NULL, + RATE_LIMIT_TIME_UNIT VARCHAR(25) NULL DEFAULT NULL, + IS_DEPLOYED BIT NOT NULL DEFAULT 0, + CUSTOM_ATTRIBUTES VARBINARY(MAX) DEFAULT NULL, + STOP_ON_QUOTA_REACH BIT NOT NULL DEFAULT 0, + BILLING_PLAN VARCHAR(20) NOT NULL, + UUID VARCHAR(256), + PRIMARY KEY (POLICY_ID), + UNIQUE (NAME, TENANT_ID), + UNIQUE (UUID) +); + +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[AM_POLICY_APPLICATION]') AND TYPE IN (N'U')) +CREATE TABLE AM_POLICY_APPLICATION ( + POLICY_ID INTEGER IDENTITY(1,1), + NAME VARCHAR(512) NOT NULL, + DISPLAY_NAME VARCHAR(512) NULL DEFAULT NULL, + TENANT_ID INTEGER NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + QUOTA_TYPE VARCHAR(25) NOT NULL, + QUOTA INTEGER NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL DEFAULT NULL, + UNIT_TIME INTEGER NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + IS_DEPLOYED BIT NOT NULL DEFAULT 0, + CUSTOM_ATTRIBUTES VARBINARY(MAX) DEFAULT NULL, + UUID VARCHAR(256), + PRIMARY KEY (POLICY_ID), + UNIQUE (NAME, TENANT_ID), + UNIQUE (UUID) +); + +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[AM_POLICY_HARD_THROTTLING]') AND TYPE IN (N'U')) +CREATE TABLE AM_POLICY_HARD_THROTTLING ( + POLICY_ID INTEGER IDENTITY(1,1), + NAME VARCHAR(512) NOT NULL, + TENANT_ID INTEGER NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + QUOTA_TYPE VARCHAR(25) NOT NULL, + QUOTA INTEGER NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL DEFAULT NULL, + UNIT_TIME INTEGER NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + IS_DEPLOYED BIT NOT NULL DEFAULT 0, + PRIMARY KEY (POLICY_ID), + UNIQUE (NAME, TENANT_ID) +); + +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[AM_API_THROTTLE_POLICY]') AND TYPE IN (N'U')) +CREATE TABLE AM_API_THROTTLE_POLICY ( + POLICY_ID INTEGER IDENTITY(1,1), + NAME VARCHAR(512) NOT NULL, + DISPLAY_NAME VARCHAR(512) NULL DEFAULT NULL, + TENANT_ID INTEGER NOT NULL, + DESCRIPTION VARCHAR (1024), + DEFAULT_QUOTA_TYPE VARCHAR(25) NOT NULL, + DEFAULT_QUOTA INTEGER NOT NULL, + DEFAULT_QUOTA_UNIT VARCHAR(10) NULL, + DEFAULT_UNIT_TIME INTEGER NOT NULL, + DEFAULT_TIME_UNIT VARCHAR(25) NOT NULL, + APPLICABLE_LEVEL VARCHAR(25) NOT NULL, + IS_DEPLOYED BIT NOT NULL DEFAULT 0, + UUID VARCHAR(256), + PRIMARY KEY (POLICY_ID), + UNIQUE (NAME, TENANT_ID), + UNIQUE (UUID) +); + +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[AM_CONDITION_GROUP]') AND TYPE IN (N'U')) +CREATE TABLE AM_CONDITION_GROUP ( + CONDITION_GROUP_ID INTEGER IDENTITY(1,1), + POLICY_ID INTEGER NOT NULL, + QUOTA_TYPE VARCHAR(25), + QUOTA INTEGER NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL DEFAULT NULL, + UNIT_TIME INTEGER NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + DESCRIPTION VARCHAR (1024) NULL DEFAULT NULL, + PRIMARY KEY (CONDITION_GROUP_ID), + FOREIGN KEY (POLICY_ID) REFERENCES AM_API_THROTTLE_POLICY(POLICY_ID) ON DELETE CASCADE ON UPDATE CASCADE +); + +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[AM_QUERY_PARAMETER_CONDITION]') AND TYPE IN (N'U')) +CREATE TABLE AM_QUERY_PARAMETER_CONDITION ( + QUERY_PARAMETER_ID INTEGER IDENTITY(1,1), + CONDITION_GROUP_ID INTEGER NOT NULL, + PARAMETER_NAME VARCHAR(255) DEFAULT NULL, + PARAMETER_VALUE VARCHAR(255) DEFAULT NULL, + IS_PARAM_MAPPING BIT DEFAULT 1, + PRIMARY KEY (QUERY_PARAMETER_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE +); + +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[AM_HEADER_FIELD_CONDITION]') AND TYPE IN (N'U')) +CREATE TABLE AM_HEADER_FIELD_CONDITION ( + HEADER_FIELD_ID INTEGER IDENTITY(1,1), + CONDITION_GROUP_ID INTEGER NOT NULL, + HEADER_FIELD_NAME VARCHAR(255) DEFAULT NULL, + HEADER_FIELD_VALUE VARCHAR(255) DEFAULT NULL, + IS_HEADER_FIELD_MAPPING BIT DEFAULT 1, + PRIMARY KEY (HEADER_FIELD_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE +); + +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[AM_JWT_CLAIM_CONDITION]') AND TYPE IN (N'U')) +CREATE TABLE AM_JWT_CLAIM_CONDITION ( + JWT_CLAIM_ID INTEGER IDENTITY(1,1), + CONDITION_GROUP_ID INTEGER NOT NULL, + CLAIM_URI VARCHAR(512) DEFAULT NULL, + CLAIM_ATTRIB VARCHAR(1024) DEFAULT NULL, + IS_CLAIM_MAPPING BIT DEFAULT 1, + PRIMARY KEY (JWT_CLAIM_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE +); + +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[AM_IP_CONDITION]') AND TYPE IN (N'U')) +CREATE TABLE AM_IP_CONDITION ( + AM_IP_CONDITION_ID INTEGER IDENTITY(1,1), + STARTING_IP VARCHAR(45) NULL, + ENDING_IP VARCHAR(45) NULL, + SPECIFIC_IP VARCHAR(45) NULL, + WITHIN_IP_RANGE BIT DEFAULT 1, + CONDITION_GROUP_ID INT NULL, + PRIMARY KEY (AM_IP_CONDITION_ID), + FOREIGN KEY (CONDITION_GROUP_ID) + REFERENCES AM_CONDITION_GROUP (CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE); + +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[AM_POLICY_GLOBAL]') AND TYPE IN (N'U')) +CREATE TABLE AM_POLICY_GLOBAL ( + POLICY_ID INTEGER IDENTITY(1,1), + NAME VARCHAR(512) NOT NULL, + KEY_TEMPLATE VARCHAR(512) NOT NULL, + TENANT_ID INTEGER NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + SIDDHI_QUERY VARBINARY(MAX) DEFAULT NULL, + IS_DEPLOYED BIT NOT NULL DEFAULT 0, + UUID VARCHAR(256), + PRIMARY KEY (POLICY_ID), + UNIQUE (UUID) +); + +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[AM_THROTTLE_TIER_PERMISSIONS]') AND TYPE IN (N'U')) +CREATE TABLE AM_THROTTLE_TIER_PERMISSIONS ( + THROTTLE_TIER_PERMISSIONS_ID INTEGER IDENTITY(1,1), + TIER VARCHAR(50) NULL, + PERMISSIONS_TYPE VARCHAR(50) NULL, + ROLES VARCHAR(512) NULL, + TENANT_ID INTEGER NULL, + PRIMARY KEY (THROTTLE_TIER_PERMISSIONS_ID)); + +IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[AM_BLOCK_CONDITIONS]') AND TYPE IN (N'U')) +CREATE TABLE AM_BLOCK_CONDITIONS ( + CONDITION_ID INTEGER IDENTITY(1,1), + TYPE varchar(45) DEFAULT NULL, + VALUE varchar(45) DEFAULT NULL, + ENABLED varchar(45) DEFAULT NULL, + DOMAIN varchar(45) DEFAULT NULL, + UUID VARCHAR(256), + PRIMARY KEY (CONDITION_ID), + UNIQUE (UUID) +); + +-- End of API-MGT Tables -- + + +--Permance indexes start-- + +create index IDX_ITS_LMT on IDN_THRIFT_SESSION (LAST_MODIFIED_TIME); +create index IDX_IOAT_AT on IDN_OAUTH2_ACCESS_TOKEN (ACCESS_TOKEN); +create index IDX_IOAT_UT on IDN_OAUTH2_ACCESS_TOKEN (USER_TYPE); +create index IDX_AAI_CTX on AM_API (CONTEXT); +create index IDX_AAKM_CK on AM_APPLICATION_KEY_MAPPING (CONSUMER_KEY); +create index IDX_AAUM_AI on AM_API_URL_MAPPING (API_ID); +create index IDX_AAUM_TT on AM_API_URL_MAPPING (THROTTLING_TIER); +create index IDX_AATP_DQT on AM_API_THROTTLE_POLICY (DEFAULT_QUOTA_TYPE); +create index IDX_ACG_QT on AM_CONDITION_GROUP (QUOTA_TYPE); +create index IDX_APS_QT on AM_POLICY_SUBSCRIPTION (QUOTA_TYPE); +create index IDX_AS_AITIAI on AM_SUBSCRIPTION (API_ID,TIER_ID,APPLICATION_ID); +create index IDX_APA_QT on AM_POLICY_APPLICATION (QUOTA_TYPE); +create index IDX_AA_AT_CB on AM_APPLICATION (APPLICATION_TIER,CREATED_BY); + +-- Performance indexes end-- + diff --git a/modules/distribution/src/repository/resources/dbscripts/apimgt/mysql.sql b/modules/distribution/src/repository/resources/dbscripts/apimgt/mysql.sql index 72362b84..35e38d7e 100644 --- a/modules/distribution/src/repository/resources/dbscripts/apimgt/mysql.sql +++ b/modules/distribution/src/repository/resources/dbscripts/apimgt/mysql.sql @@ -18,6 +18,8 @@ CREATE TABLE IF NOT EXISTS IDN_OAUTH_CONSUMER_APPS ( OAUTH_VERSION VARCHAR(128), CALLBACK_URL VARCHAR(1024), GRANT_TYPES VARCHAR (1024), + PKCE_MANDATORY CHAR(1) DEFAULT '0', + PKCE_SUPPORT_PLAIN CHAR(1) DEFAULT '0', CONSTRAINT CONSUMER_KEY_CONSTRAINT UNIQUE (CONSUMER_KEY), PRIMARY KEY (ID) )ENGINE INNODB; @@ -89,6 +91,8 @@ CREATE TABLE IF NOT EXISTS IDN_OAUTH2_AUTHORIZATION_CODE ( STATE VARCHAR (25) DEFAULT 'ACTIVE', TOKEN_ID VARCHAR(255), SUBJECT_IDENTIFIER VARCHAR(255), + PKCE_CODE_CHALLENGE VARCHAR(255), + PKCE_CODE_CHALLENGE_METHOD VARCHAR(128), PRIMARY KEY (CODE_ID), FOREIGN KEY (CONSUMER_KEY_ID) REFERENCES IDN_OAUTH_CONSUMER_APPS(ID) ON DELETE CASCADE )ENGINE INNODB; @@ -517,7 +521,7 @@ CREATE TABLE IF NOT EXISTS FIDO_DEVICE_STORE ( DEVICE_DATA VARCHAR(2048) NOT NULL, PRIMARY KEY (TENANT_ID, DOMAIN_NAME, USER_NAME, KEY_HANDLE) )ENGINE INNODB; - + CREATE TABLE IF NOT EXISTS WF_REQUEST ( UUID VARCHAR (45), CREATED_BY VARCHAR (255), @@ -532,8 +536,8 @@ CREATE TABLE IF NOT EXISTS WF_REQUEST ( CREATE TABLE IF NOT EXISTS WF_BPS_PROFILE ( PROFILE_NAME VARCHAR(45), - HOST_URL_MANAGER VARCHAR(45), - HOST_URL_WORKER VARCHAR(45), + HOST_URL_MANAGER VARCHAR(255), + HOST_URL_WORKER VARCHAR(255), USERNAME VARCHAR(45), PASSWORD VARCHAR(255), CALLBACK_HOST VARCHAR (45), @@ -627,7 +631,7 @@ CREATE TABLE IF NOT EXISTS AM_APPLICATION ( CREATED_TIME TIMESTAMP, UPDATED_BY VARCHAR(100), UPDATED_TIME TIMESTAMP, - UUID VARCHAR(256), + UUID VARCHAR(254), FOREIGN KEY(SUBSCRIBER_ID) REFERENCES AM_SUBSCRIBER(SUBSCRIBER_ID) ON UPDATE CASCADE ON DELETE RESTRICT, PRIMARY KEY(APPLICATION_ID), UNIQUE (NAME,SUBSCRIBER_ID), @@ -641,6 +645,7 @@ CREATE TABLE IF NOT EXISTS AM_API ( API_VERSION VARCHAR(30), CONTEXT VARCHAR(256), CONTEXT_TEMPLATE VARCHAR(256), + API_TIER VARCHAR(256), CREATED_BY VARCHAR(100), CREATED_TIME TIMESTAMP, UPDATED_BY VARCHAR(100), @@ -672,7 +677,7 @@ CREATE TABLE IF NOT EXISTS AM_SUBSCRIPTION ( CREATED_TIME TIMESTAMP, UPDATED_BY VARCHAR(100), UPDATED_TIME TIMESTAMP, - UUID VARCHAR(256), + UUID VARCHAR(254), FOREIGN KEY(APPLICATION_ID) REFERENCES AM_APPLICATION(APPLICATION_ID) ON UPDATE CASCADE ON DELETE RESTRICT, FOREIGN KEY(API_ID) REFERENCES AM_API(API_ID) ON UPDATE CASCADE ON DELETE RESTRICT, PRIMARY KEY (SUBSCRIPTION_ID), @@ -682,7 +687,7 @@ CREATE TABLE IF NOT EXISTS AM_SUBSCRIPTION ( CREATE TABLE IF NOT EXISTS AM_SUBSCRIPTION_KEY_MAPPING ( SUBSCRIPTION_ID INTEGER, ACCESS_TOKEN VARCHAR(255), - KEY_TYPE VARCHAR(512) NOT NULL, + KEY_TYPE VARCHAR(255) NOT NULL, FOREIGN KEY(SUBSCRIPTION_ID) REFERENCES AM_SUBSCRIPTION(SUBSCRIPTION_ID) ON UPDATE CASCADE ON DELETE RESTRICT, PRIMARY KEY(SUBSCRIPTION_ID,ACCESS_TOKEN) )ENGINE INNODB; @@ -690,7 +695,7 @@ CREATE TABLE IF NOT EXISTS AM_SUBSCRIPTION_KEY_MAPPING ( CREATE TABLE IF NOT EXISTS AM_APPLICATION_KEY_MAPPING ( APPLICATION_ID INTEGER, CONSUMER_KEY VARCHAR(255), - KEY_TYPE VARCHAR(512) NOT NULL, + KEY_TYPE VARCHAR(255) NOT NULL, STATE VARCHAR(30) NOT NULL, CREATE_MODE VARCHAR(30) DEFAULT 'CREATED', FOREIGN KEY(APPLICATION_ID) REFERENCES AM_APPLICATION(APPLICATION_ID) ON UPDATE CASCADE ON DELETE RESTRICT, @@ -789,17 +794,246 @@ CREATE TABLE IF NOT EXISTS AM_APPLICATION_REGISTRATION ( CREATE TABLE IF NOT EXISTS AM_API_SCOPES ( API_ID INTEGER NOT NULL, SCOPE_ID INTEGER NOT NULL, - FOREIGN KEY (API_ID) REFERENCES AM_API (API_ID) ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (API_ID) REFERENCES AM_API (API_ID) ON DELETE CASCADE ON UPDATE CASCADE, FOREIGN KEY (SCOPE_ID) REFERENCES IDN_OAUTH2_SCOPE (SCOPE_ID) ON DELETE CASCADE ON UPDATE CASCADE )ENGINE = INNODB; CREATE TABLE IF NOT EXISTS AM_API_DEFAULT_VERSION ( - DEFAULT_VERSION_ID INT AUTO_INCREMENT, + DEFAULT_VERSION_ID INT AUTO_INCREMENT, API_NAME VARCHAR(256) NOT NULL , - API_PROVIDER VARCHAR(256) NOT NULL , - DEFAULT_API_VERSION VARCHAR(30) , + API_PROVIDER VARCHAR(256) NOT NULL , + DEFAULT_API_VERSION VARCHAR(30) , PUBLISHED_DEFAULT_API_VERSION VARCHAR(30) , PRIMARY KEY (DEFAULT_VERSION_ID) -); +)ENGINE = INNODB; + +CREATE INDEX IDX_SUB_APP_ID ON AM_SUBSCRIPTION (APPLICATION_ID, SUBSCRIPTION_ID); + + +CREATE TABLE IF NOT EXISTS AM_ALERT_TYPES ( + ALERT_TYPE_ID INTEGER AUTO_INCREMENT, + ALERT_TYPE_NAME VARCHAR(255) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL, + PRIMARY KEY (ALERT_TYPE_ID) +)ENGINE = INNODB; + +CREATE TABLE IF NOT EXISTS AM_ALERT_TYPES_VALUES ( + ALERT_TYPE_ID INTEGER, + USER_NAME VARCHAR(255) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL , + CONSTRAINT AM_ALERT_TYPES_VALUES_CONSTRAINT UNIQUE (ALERT_TYPE_ID,USER_NAME,STAKE_HOLDER) +)ENGINE = INNODB; + +CREATE TABLE IF NOT EXISTS AM_ALERT_EMAILLIST ( + EMAIL_LIST_ID INTEGER AUTO_INCREMENT, + USER_NAME VARCHAR(255) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL , + PRIMARY KEY (EMAIL_LIST_ID), + CONSTRAINT AM_ALERT_EMAILLIST_CONSTRAINT UNIQUE (EMAIL_LIST_ID,USER_NAME,STAKE_HOLDER) +)ENGINE = INNODB; + +CREATE TABLE IF NOT EXISTS AM_ALERT_EMAILLIST_DETAILS ( + EMAIL_LIST_ID INTEGER, + EMAIL VARCHAR(255), + CONSTRAINT AM_ALERT_EMAILLIST_DETAILS_CONSTRAINT UNIQUE (EMAIL_LIST_ID,EMAIL) +)ENGINE = INNODB; + +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalResponseTime', 'publisher'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalBackendTime', 'publisher'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalRequestsPerMin', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('RequestPatternChanged', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('UnusualIPAccessAlert', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('AbnormalRefreshAlert', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('FrequentTierHittingAlert', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('AbnormalTierUsage', 'publisher'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('healthAvailabilityPerMin', 'publisher'); + + + +-- AM Throttling tables -- + +CREATE TABLE IF NOT EXISTS AM_POLICY_SUBSCRIPTION ( + POLICY_ID INT(11) NOT NULL AUTO_INCREMENT, + NAME VARCHAR(255) NOT NULL, + DISPLAY_NAME VARCHAR(512) NULL DEFAULT NULL, + TENANT_ID INT(11) NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + QUOTA_TYPE VARCHAR(25) NOT NULL, + QUOTA INT(11) NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL, + UNIT_TIME INT(11) NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + RATE_LIMIT_COUNT INT(11) NULL DEFAULT NULL, + RATE_LIMIT_TIME_UNIT VARCHAR(25) NULL DEFAULT NULL, + IS_DEPLOYED TINYINT(1) NOT NULL DEFAULT 0, + CUSTOM_ATTRIBUTES BLOB DEFAULT NULL, + STOP_ON_QUOTA_REACH BOOLEAN NOT NULL DEFAULT 0, + BILLING_PLAN VARCHAR(20) NOT NULL, + UUID VARCHAR(254), + PRIMARY KEY (POLICY_ID), + UNIQUE INDEX AM_POLICY_SUBSCRIPTION_NAME_TENANT (NAME, TENANT_ID), + UNIQUE (UUID) +)ENGINE = InnoDB; + +CREATE TABLE IF NOT EXISTS AM_POLICY_APPLICATION ( + POLICY_ID INT(11) NOT NULL AUTO_INCREMENT, + NAME VARCHAR(255) NOT NULL, + DISPLAY_NAME VARCHAR(512) NULL DEFAULT NULL, + TENANT_ID INT(11) NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + QUOTA_TYPE VARCHAR(25) NOT NULL, + QUOTA INT(11) NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL DEFAULT NULL, + UNIT_TIME INT(11) NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + IS_DEPLOYED TINYINT(1) NOT NULL DEFAULT 0, + CUSTOM_ATTRIBUTES BLOB DEFAULT NULL, + UUID VARCHAR(254), + PRIMARY KEY (POLICY_ID), + UNIQUE INDEX APP_NAME_TENANT (NAME, TENANT_ID), + UNIQUE (UUID) +)ENGINE = InnoDB; + +CREATE TABLE IF NOT EXISTS AM_POLICY_HARD_THROTTLING ( + POLICY_ID INT(11) NOT NULL AUTO_INCREMENT, + NAME VARCHAR(255) NOT NULL, + TENANT_ID INT(11) NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + QUOTA_TYPE VARCHAR(25) NOT NULL, + QUOTA INT(11) NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL DEFAULT NULL, + UNIT_TIME INT(11) NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + IS_DEPLOYED TINYINT(1) NOT NULL DEFAULT 0, + PRIMARY KEY (POLICY_ID), + UNIQUE INDEX POLICY_HARD_NAME_TENANT (NAME, TENANT_ID) +)ENGINE = InnoDB; + + +CREATE TABLE IF NOT EXISTS AM_API_THROTTLE_POLICY ( + POLICY_ID INT(11) NOT NULL AUTO_INCREMENT, + NAME VARCHAR(255) NOT NULL, + DISPLAY_NAME VARCHAR(512) NULL DEFAULT NULL, + TENANT_ID INT(11) NOT NULL, + DESCRIPTION VARCHAR (1024), + DEFAULT_QUOTA_TYPE VARCHAR(25) NOT NULL, + DEFAULT_QUOTA INTEGER NOT NULL, + DEFAULT_QUOTA_UNIT VARCHAR(10) NULL, + DEFAULT_UNIT_TIME INTEGER NOT NULL, + DEFAULT_TIME_UNIT VARCHAR(25) NOT NULL, + APPLICABLE_LEVEL VARCHAR(25) NOT NULL, + IS_DEPLOYED TINYINT(1) NOT NULL DEFAULT 0, + UUID VARCHAR(254), + PRIMARY KEY (POLICY_ID), + UNIQUE INDEX API_NAME_TENANT (NAME, TENANT_ID), + UNIQUE (UUID) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_CONDITION_GROUP ( + CONDITION_GROUP_ID INTEGER NOT NULL AUTO_INCREMENT, + POLICY_ID INTEGER NOT NULL, + QUOTA_TYPE VARCHAR(25), + QUOTA INTEGER NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL DEFAULT NULL, + UNIT_TIME INTEGER NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + DESCRIPTION VARCHAR (1024) NULL DEFAULT NULL, + PRIMARY KEY (CONDITION_GROUP_ID), + FOREIGN KEY (POLICY_ID) REFERENCES AM_API_THROTTLE_POLICY(POLICY_ID) ON DELETE CASCADE ON UPDATE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_QUERY_PARAMETER_CONDITION ( + QUERY_PARAMETER_ID INTEGER NOT NULL AUTO_INCREMENT, + CONDITION_GROUP_ID INTEGER NOT NULL, + PARAMETER_NAME VARCHAR(255) DEFAULT NULL, + PARAMETER_VALUE VARCHAR(255) DEFAULT NULL, + IS_PARAM_MAPPING BOOLEAN DEFAULT 1, + PRIMARY KEY (QUERY_PARAMETER_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_HEADER_FIELD_CONDITION ( + HEADER_FIELD_ID INTEGER NOT NULL AUTO_INCREMENT, + CONDITION_GROUP_ID INTEGER NOT NULL, + HEADER_FIELD_NAME VARCHAR(255) DEFAULT NULL, + HEADER_FIELD_VALUE VARCHAR(255) DEFAULT NULL, + IS_HEADER_FIELD_MAPPING BOOLEAN DEFAULT 1, + PRIMARY KEY (HEADER_FIELD_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_JWT_CLAIM_CONDITION ( + JWT_CLAIM_ID INTEGER NOT NULL AUTO_INCREMENT, + CONDITION_GROUP_ID INTEGER NOT NULL, + CLAIM_URI VARCHAR(512) DEFAULT NULL, + CLAIM_ATTRIB VARCHAR(1024) DEFAULT NULL, + IS_CLAIM_MAPPING BOOLEAN DEFAULT 1, + PRIMARY KEY (JWT_CLAIM_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_IP_CONDITION ( + AM_IP_CONDITION_ID INT NOT NULL AUTO_INCREMENT, + STARTING_IP VARCHAR(45) NULL, + ENDING_IP VARCHAR(45) NULL, + SPECIFIC_IP VARCHAR(45) NULL, + WITHIN_IP_RANGE BOOLEAN DEFAULT 1, + CONDITION_GROUP_ID INT NULL, + PRIMARY KEY (AM_IP_CONDITION_ID), + INDEX fk_AM_IP_CONDITION_1_idx (CONDITION_GROUP_ID ASC), CONSTRAINT fk_AM_IP_CONDITION_1 FOREIGN KEY (CONDITION_GROUP_ID) + REFERENCES AM_CONDITION_GROUP (CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE) +ENGINE = InnoDB; + + +CREATE TABLE IF NOT EXISTS AM_POLICY_GLOBAL ( + POLICY_ID INT(11) NOT NULL AUTO_INCREMENT, + NAME VARCHAR(255) NOT NULL, + KEY_TEMPLATE VARCHAR(512) NOT NULL, + TENANT_ID INT(11) NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + SIDDHI_QUERY BLOB DEFAULT NULL, + IS_DEPLOYED TINYINT(1) NOT NULL DEFAULT 0, + UUID VARCHAR(254), + PRIMARY KEY (POLICY_ID), + UNIQUE (UUID) +)ENGINE INNODB; -CREATE INDEX IDX_SUB_APP_ID ON AM_SUBSCRIPTION (APPLICATION_ID, SUBSCRIPTION_ID); \ No newline at end of file +CREATE TABLE IF NOT EXISTS AM_THROTTLE_TIER_PERMISSIONS ( + THROTTLE_TIER_PERMISSIONS_ID INT NOT NULL AUTO_INCREMENT, + TIER VARCHAR(50) NULL, + PERMISSIONS_TYPE VARCHAR(50) NULL, + ROLES VARCHAR(512) NULL, + TENANT_ID INT(11) NULL, + PRIMARY KEY (THROTTLE_TIER_PERMISSIONS_ID)) +ENGINE = InnoDB; + +CREATE TABLE `AM_BLOCK_CONDITIONS` ( + `CONDITION_ID` int(11) NOT NULL AUTO_INCREMENT, + `TYPE` varchar(45) DEFAULT NULL, + `VALUE` varchar(45) DEFAULT NULL, + `ENABLED` varchar(45) DEFAULT NULL, + `DOMAIN` varchar(45) DEFAULT NULL, + `UUID` VARCHAR(254), + PRIMARY KEY (`CONDITION_ID`), + UNIQUE (`UUID`) +) ENGINE=InnoDB; + +-- End of API-MGT Tables -- + +-- Performance indexes start-- + +create index IDX_ITS_LMT on IDN_THRIFT_SESSION (LAST_MODIFIED_TIME); +create index IDX_IOAT_AT on IDN_OAUTH2_ACCESS_TOKEN (ACCESS_TOKEN); +create index IDX_IOAT_UT on IDN_OAUTH2_ACCESS_TOKEN (USER_TYPE); +create index IDX_AAI_CTX on AM_API (CONTEXT); +create index IDX_AAKM_CK on AM_APPLICATION_KEY_MAPPING (CONSUMER_KEY); +create index IDX_AAUM_AI on AM_API_URL_MAPPING (API_ID); +create index IDX_AAUM_TT on AM_API_URL_MAPPING (THROTTLING_TIER); +create index IDX_AATP_DQT on AM_API_THROTTLE_POLICY (DEFAULT_QUOTA_TYPE); +create index IDX_ACG_QT on AM_CONDITION_GROUP (QUOTA_TYPE); +create index IDX_APS_QT on AM_POLICY_SUBSCRIPTION (QUOTA_TYPE); +create index IDX_AS_AITIAI on AM_SUBSCRIPTION (API_ID,TIER_ID,APPLICATION_ID); +create index IDX_APA_QT on AM_POLICY_APPLICATION (QUOTA_TYPE); +create index IDX_AA_AT_CB on AM_APPLICATION (APPLICATION_TIER,CREATED_BY); + +-- Performance indexes end-- diff --git a/modules/distribution/src/repository/resources/dbscripts/apimgt/mysql5.7.sql b/modules/distribution/src/repository/resources/dbscripts/apimgt/mysql5.7.sql new file mode 100644 index 00000000..c644470c --- /dev/null +++ b/modules/distribution/src/repository/resources/dbscripts/apimgt/mysql5.7.sql @@ -0,0 +1,1038 @@ +-- Start of IDENTITY Tables-- + +CREATE TABLE IF NOT EXISTS IDN_BASE_TABLE ( + PRODUCT_NAME VARCHAR(20), + PRIMARY KEY (PRODUCT_NAME) +)ENGINE INNODB; + +INSERT INTO IDN_BASE_TABLE values ('WSO2 Identity Server'); + +CREATE TABLE IF NOT EXISTS IDN_OAUTH_CONSUMER_APPS ( + ID INTEGER NOT NULL AUTO_INCREMENT, + CONSUMER_KEY VARCHAR(255), + CONSUMER_SECRET VARCHAR(512), + USERNAME VARCHAR(255), + TENANT_ID INTEGER DEFAULT 0, + USER_DOMAIN VARCHAR(50), + APP_NAME VARCHAR(255), + OAUTH_VERSION VARCHAR(128), + CALLBACK_URL VARCHAR(1024), + GRANT_TYPES VARCHAR (1024), + PKCE_MANDATORY CHAR(1) DEFAULT '0', + PKCE_SUPPORT_PLAIN CHAR(1) DEFAULT '0', + CONSTRAINT CONSUMER_KEY_CONSTRAINT UNIQUE (CONSUMER_KEY), + PRIMARY KEY (ID) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDN_OAUTH1A_REQUEST_TOKEN ( + REQUEST_TOKEN VARCHAR(255), + REQUEST_TOKEN_SECRET VARCHAR(512), + CONSUMER_KEY_ID INTEGER, + CALLBACK_URL VARCHAR(1024), + SCOPE VARCHAR(2048), + AUTHORIZED VARCHAR(128), + OAUTH_VERIFIER VARCHAR(512), + AUTHZ_USER VARCHAR(512), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (REQUEST_TOKEN), + FOREIGN KEY (CONSUMER_KEY_ID) REFERENCES IDN_OAUTH_CONSUMER_APPS(ID) ON DELETE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDN_OAUTH1A_ACCESS_TOKEN ( + ACCESS_TOKEN VARCHAR(255), + ACCESS_TOKEN_SECRET VARCHAR(512), + CONSUMER_KEY_ID INTEGER, + SCOPE VARCHAR(2048), + AUTHZ_USER VARCHAR(512), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (ACCESS_TOKEN), + FOREIGN KEY (CONSUMER_KEY_ID) REFERENCES IDN_OAUTH_CONSUMER_APPS(ID) ON DELETE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDN_OAUTH2_ACCESS_TOKEN ( + TOKEN_ID VARCHAR (255), + ACCESS_TOKEN VARCHAR(255), + REFRESH_TOKEN VARCHAR(255), + CONSUMER_KEY_ID INTEGER, + AUTHZ_USER VARCHAR (100), + TENANT_ID INTEGER, + USER_DOMAIN VARCHAR(50), + USER_TYPE VARCHAR (25), + GRANT_TYPE VARCHAR (50), + TIME_CREATED TIMESTAMP, + REFRESH_TOKEN_TIME_CREATED TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + VALIDITY_PERIOD BIGINT, + REFRESH_TOKEN_VALIDITY_PERIOD BIGINT, + TOKEN_SCOPE_HASH VARCHAR(32), + TOKEN_STATE VARCHAR(25) DEFAULT 'ACTIVE', + TOKEN_STATE_ID VARCHAR (128) DEFAULT 'NONE', + SUBJECT_IDENTIFIER VARCHAR(255), + PRIMARY KEY (TOKEN_ID), + FOREIGN KEY (CONSUMER_KEY_ID) REFERENCES IDN_OAUTH_CONSUMER_APPS(ID) ON DELETE CASCADE, + CONSTRAINT CON_APP_KEY UNIQUE (CONSUMER_KEY_ID,AUTHZ_USER,TENANT_ID,USER_DOMAIN,USER_TYPE,TOKEN_SCOPE_HASH, + TOKEN_STATE,TOKEN_STATE_ID) +)ENGINE INNODB; + +CREATE INDEX IDX_AT_CK_AU ON IDN_OAUTH2_ACCESS_TOKEN(CONSUMER_KEY_ID, AUTHZ_USER, TOKEN_STATE, USER_TYPE); + +CREATE INDEX IDX_TC ON IDN_OAUTH2_ACCESS_TOKEN(TIME_CREATED); + +CREATE TABLE IF NOT EXISTS IDN_OAUTH2_AUTHORIZATION_CODE ( + CODE_ID VARCHAR (255), + AUTHORIZATION_CODE VARCHAR(512), + CONSUMER_KEY_ID INTEGER, + CALLBACK_URL VARCHAR(1024), + SCOPE VARCHAR(2048), + AUTHZ_USER VARCHAR (100), + TENANT_ID INTEGER, + USER_DOMAIN VARCHAR(50), + TIME_CREATED TIMESTAMP, + VALIDITY_PERIOD BIGINT, + STATE VARCHAR (25) DEFAULT 'ACTIVE', + TOKEN_ID VARCHAR(255), + SUBJECT_IDENTIFIER VARCHAR(255), + PKCE_CODE_CHALLENGE VARCHAR(255), + PKCE_CODE_CHALLENGE_METHOD VARCHAR(128), + PRIMARY KEY (CODE_ID), + FOREIGN KEY (CONSUMER_KEY_ID) REFERENCES IDN_OAUTH_CONSUMER_APPS(ID) ON DELETE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDN_OAUTH2_ACCESS_TOKEN_SCOPE ( + TOKEN_ID VARCHAR (255), + TOKEN_SCOPE VARCHAR (60), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (TOKEN_ID, TOKEN_SCOPE), + FOREIGN KEY (TOKEN_ID) REFERENCES IDN_OAUTH2_ACCESS_TOKEN(TOKEN_ID) ON DELETE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDN_OAUTH2_SCOPE ( + SCOPE_ID INT(11) NOT NULL AUTO_INCREMENT, + SCOPE_KEY VARCHAR(100) NOT NULL, + NAME VARCHAR(255) NULL, + DESCRIPTION VARCHAR(512) NULL, + TENANT_ID INT(11) NOT NULL DEFAULT 0, + ROLES VARCHAR (500) NULL, + PRIMARY KEY (SCOPE_ID) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDN_OAUTH2_RESOURCE_SCOPE ( + RESOURCE_PATH VARCHAR(255) NOT NULL, + SCOPE_ID INTEGER (11) NOT NULL, + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (RESOURCE_PATH), + FOREIGN KEY (SCOPE_ID) REFERENCES IDN_OAUTH2_SCOPE (SCOPE_ID) ON DELETE CASCADE ON UPDATE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDN_SCIM_GROUP ( + ID INTEGER AUTO_INCREMENT, + TENANT_ID INTEGER NOT NULL, + ROLE_NAME VARCHAR(255) NOT NULL, + ATTR_NAME VARCHAR(1024) NOT NULL, + ATTR_VALUE VARCHAR(1024), + PRIMARY KEY (ID) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDN_OPENID_REMEMBER_ME ( + USER_NAME VARCHAR(255) NOT NULL, + TENANT_ID INTEGER DEFAULT 0, + COOKIE_VALUE VARCHAR(1024), + CREATED_TIME TIMESTAMP, + PRIMARY KEY (USER_NAME, TENANT_ID) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDN_OPENID_USER_RPS ( + USER_NAME VARCHAR(255) NOT NULL, + TENANT_ID INTEGER DEFAULT 0, + RP_URL VARCHAR(255) NOT NULL, + TRUSTED_ALWAYS VARCHAR(128) DEFAULT 'FALSE', + LAST_VISIT DATE NOT NULL, + VISIT_COUNT INTEGER DEFAULT 0, + DEFAULT_PROFILE_NAME VARCHAR(255) DEFAULT 'DEFAULT', + PRIMARY KEY (USER_NAME, TENANT_ID, RP_URL) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDN_OPENID_ASSOCIATIONS ( + HANDLE VARCHAR(255) NOT NULL, + ASSOC_TYPE VARCHAR(255) NOT NULL, + EXPIRE_IN TIMESTAMP NOT NULL, + MAC_KEY VARCHAR(255) NOT NULL, + ASSOC_STORE VARCHAR(128) DEFAULT 'SHARED', + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (HANDLE) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDN_STS_STORE ( + ID INTEGER AUTO_INCREMENT, + TOKEN_ID VARCHAR(255) NOT NULL, + TOKEN_CONTENT BLOB(1024) NOT NULL, + CREATE_DATE TIMESTAMP NOT NULL, + EXPIRE_DATE TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + STATE INTEGER DEFAULT 0, + PRIMARY KEY (ID) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDN_IDENTITY_USER_DATA ( + TENANT_ID INTEGER DEFAULT -1234, + USER_NAME VARCHAR(255) NOT NULL, + DATA_KEY VARCHAR(255) NOT NULL, + DATA_VALUE VARCHAR(255), + PRIMARY KEY (TENANT_ID, USER_NAME, DATA_KEY) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDN_IDENTITY_META_DATA ( + USER_NAME VARCHAR(255) NOT NULL, + TENANT_ID INTEGER DEFAULT -1234, + METADATA_TYPE VARCHAR(255) NOT NULL, + METADATA VARCHAR(255) NOT NULL, + VALID VARCHAR(255) NOT NULL, + PRIMARY KEY (TENANT_ID, USER_NAME, METADATA_TYPE,METADATA) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDN_THRIFT_SESSION ( + SESSION_ID VARCHAR(255) NOT NULL, + USER_NAME VARCHAR(255) NOT NULL, + CREATED_TIME VARCHAR(255) NOT NULL, + LAST_MODIFIED_TIME VARCHAR(255) NOT NULL, + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (SESSION_ID) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDN_AUTH_SESSION_STORE ( + SESSION_ID VARCHAR (100) NOT NULL, + SESSION_TYPE VARCHAR(100) NOT NULL, + OPERATION VARCHAR(10) NOT NULL, + SESSION_OBJECT BLOB, + TIME_CREATED BIGINT, + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (SESSION_ID, SESSION_TYPE, TIME_CREATED, OPERATION) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS SP_APP ( + ID INTEGER NOT NULL AUTO_INCREMENT, + TENANT_ID INTEGER NOT NULL, + APP_NAME VARCHAR (255) NOT NULL , + USER_STORE VARCHAR (255) NOT NULL, + USERNAME VARCHAR (255) NOT NULL , + DESCRIPTION VARCHAR (1024), + ROLE_CLAIM VARCHAR (512), + AUTH_TYPE VARCHAR (255) NOT NULL, + PROVISIONING_USERSTORE_DOMAIN VARCHAR (512), + IS_LOCAL_CLAIM_DIALECT CHAR(1) DEFAULT '1', + IS_SEND_LOCAL_SUBJECT_ID CHAR(1) DEFAULT '0', + IS_SEND_AUTH_LIST_OF_IDPS CHAR(1) DEFAULT '0', + IS_USE_TENANT_DOMAIN_SUBJECT CHAR(1) DEFAULT '1', + IS_USE_USER_DOMAIN_SUBJECT CHAR(1) DEFAULT '1', + SUBJECT_CLAIM_URI VARCHAR (512), + IS_SAAS_APP CHAR(1) DEFAULT '0', + IS_DUMB_MODE CHAR(1) DEFAULT '0', + PRIMARY KEY (ID) +)ENGINE INNODB; + +ALTER TABLE SP_APP ADD CONSTRAINT APPLICATION_NAME_CONSTRAINT UNIQUE(APP_NAME, TENANT_ID); + +CREATE TABLE IF NOT EXISTS SP_METADATA ( + ID INTEGER AUTO_INCREMENT, + SP_ID INTEGER, + NAME VARCHAR(255) NOT NULL, + VALUE VARCHAR(255) NOT NULL, + DISPLAY_NAME VARCHAR(255), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (ID), + CONSTRAINT SP_METADATA_CONSTRAINT UNIQUE (SP_ID, NAME), + FOREIGN KEY (SP_ID) REFERENCES SP_APP(ID) ON DELETE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS SP_INBOUND_AUTH ( + ID INTEGER NOT NULL AUTO_INCREMENT, + TENANT_ID INTEGER NOT NULL, + INBOUND_AUTH_KEY VARCHAR (255), + INBOUND_AUTH_TYPE VARCHAR (255) NOT NULL, + PROP_NAME VARCHAR (255), + PROP_VALUE VARCHAR (1024) , + APP_ID INTEGER NOT NULL, + PRIMARY KEY (ID) +)ENGINE INNODB; + +ALTER TABLE SP_INBOUND_AUTH ADD CONSTRAINT APPLICATION_ID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE; + +CREATE TABLE IF NOT EXISTS SP_AUTH_STEP ( + ID INTEGER NOT NULL AUTO_INCREMENT, + TENANT_ID INTEGER NOT NULL, + STEP_ORDER INTEGER DEFAULT 1, + APP_ID INTEGER NOT NULL , + IS_SUBJECT_STEP CHAR(1) DEFAULT '0', + IS_ATTRIBUTE_STEP CHAR(1) DEFAULT '0', + PRIMARY KEY (ID) +)ENGINE INNODB; + +ALTER TABLE SP_AUTH_STEP ADD CONSTRAINT APPLICATION_ID_CONSTRAINT_STEP FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE; + +CREATE TABLE IF NOT EXISTS SP_FEDERATED_IDP ( + ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + AUTHENTICATOR_ID INTEGER NOT NULL, + PRIMARY KEY (ID, AUTHENTICATOR_ID) +)ENGINE INNODB; + +ALTER TABLE SP_FEDERATED_IDP ADD CONSTRAINT STEP_ID_CONSTRAINT FOREIGN KEY (ID) REFERENCES SP_AUTH_STEP (ID) ON DELETE CASCADE; + +CREATE TABLE IF NOT EXISTS SP_CLAIM_MAPPING ( + ID INTEGER NOT NULL AUTO_INCREMENT, + TENANT_ID INTEGER NOT NULL, + IDP_CLAIM VARCHAR (512) NOT NULL , + SP_CLAIM VARCHAR (512) NOT NULL , + APP_ID INTEGER NOT NULL, + IS_REQUESTED VARCHAR(128) DEFAULT '0', + DEFAULT_VALUE VARCHAR(255), + PRIMARY KEY (ID) +)ENGINE INNODB; + +ALTER TABLE SP_CLAIM_MAPPING ADD CONSTRAINT CLAIMID_APPID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE; + +CREATE TABLE IF NOT EXISTS SP_ROLE_MAPPING ( + ID INTEGER NOT NULL AUTO_INCREMENT, + TENANT_ID INTEGER NOT NULL, + IDP_ROLE VARCHAR (255) NOT NULL , + SP_ROLE VARCHAR (255) NOT NULL , + APP_ID INTEGER NOT NULL, + PRIMARY KEY (ID) +)ENGINE INNODB; + +ALTER TABLE SP_ROLE_MAPPING ADD CONSTRAINT ROLEID_APPID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE; + +CREATE TABLE IF NOT EXISTS SP_REQ_PATH_AUTHENTICATOR ( + ID INTEGER NOT NULL AUTO_INCREMENT, + TENANT_ID INTEGER NOT NULL, + AUTHENTICATOR_NAME VARCHAR (255) NOT NULL , + APP_ID INTEGER NOT NULL, + PRIMARY KEY (ID) +)ENGINE INNODB; + +ALTER TABLE SP_REQ_PATH_AUTHENTICATOR ADD CONSTRAINT REQ_AUTH_APPID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE; + +CREATE TABLE IF NOT EXISTS SP_PROVISIONING_CONNECTOR ( + ID INTEGER NOT NULL AUTO_INCREMENT, + TENANT_ID INTEGER NOT NULL, + IDP_NAME VARCHAR (255) NOT NULL , + CONNECTOR_NAME VARCHAR (255) NOT NULL , + APP_ID INTEGER NOT NULL, + IS_JIT_ENABLED CHAR(1) NOT NULL DEFAULT '0', + BLOCKING CHAR(1) NOT NULL DEFAULT '0', + PRIMARY KEY (ID) +)ENGINE INNODB; + +ALTER TABLE SP_PROVISIONING_CONNECTOR ADD CONSTRAINT PRO_CONNECTOR_APPID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE; + +CREATE TABLE IF NOT EXISTS IDP ( + ID INTEGER AUTO_INCREMENT, + TENANT_ID INTEGER, + NAME VARCHAR(254) NOT NULL, + IS_ENABLED CHAR(1) NOT NULL DEFAULT '1', + IS_PRIMARY CHAR(1) NOT NULL DEFAULT '0', + HOME_REALM_ID VARCHAR(254), + IMAGE MEDIUMBLOB, + CERTIFICATE BLOB, + ALIAS VARCHAR(254), + INBOUND_PROV_ENABLED CHAR (1) NOT NULL DEFAULT '0', + INBOUND_PROV_USER_STORE_ID VARCHAR(254), + USER_CLAIM_URI VARCHAR(254), + ROLE_CLAIM_URI VARCHAR(254), + DESCRIPTION VARCHAR (1024), + DEFAULT_AUTHENTICATOR_NAME VARCHAR(254), + DEFAULT_PRO_CONNECTOR_NAME VARCHAR(254), + PROVISIONING_ROLE VARCHAR(128), + IS_FEDERATION_HUB CHAR(1) NOT NULL DEFAULT '0', + IS_LOCAL_CLAIM_DIALECT CHAR(1) NOT NULL DEFAULT '0', + DISPLAY_NAME VARCHAR(255), + PRIMARY KEY (ID), + UNIQUE (TENANT_ID, NAME) +)ENGINE INNODB; + +INSERT INTO IDP (TENANT_ID, NAME, HOME_REALM_ID) VALUES (-1234, 'LOCAL', 'localhost'); + +CREATE TABLE IF NOT EXISTS IDP_ROLE ( + ID INTEGER AUTO_INCREMENT, + IDP_ID INTEGER, + TENANT_ID INTEGER, + ROLE VARCHAR(254), + PRIMARY KEY (ID), + UNIQUE (IDP_ID, ROLE), + FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDP_ROLE_MAPPING ( + ID INTEGER AUTO_INCREMENT, + IDP_ROLE_ID INTEGER, + TENANT_ID INTEGER, + USER_STORE_ID VARCHAR (253), + LOCAL_ROLE VARCHAR(253), + PRIMARY KEY (ID), + UNIQUE (IDP_ROLE_ID, TENANT_ID, USER_STORE_ID, LOCAL_ROLE), + FOREIGN KEY (IDP_ROLE_ID) REFERENCES IDP_ROLE(ID) ON DELETE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDP_CLAIM ( + ID INTEGER AUTO_INCREMENT, + IDP_ID INTEGER, + TENANT_ID INTEGER, + CLAIM VARCHAR(254), + PRIMARY KEY (ID), + UNIQUE (IDP_ID, CLAIM), + FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDP_CLAIM_MAPPING ( + ID INTEGER AUTO_INCREMENT, + IDP_CLAIM_ID INTEGER, + TENANT_ID INTEGER, + LOCAL_CLAIM VARCHAR(253), + DEFAULT_VALUE VARCHAR(255), + IS_REQUESTED VARCHAR(128) DEFAULT '0', + PRIMARY KEY (ID), + UNIQUE (IDP_CLAIM_ID, TENANT_ID, LOCAL_CLAIM), + FOREIGN KEY (IDP_CLAIM_ID) REFERENCES IDP_CLAIM(ID) ON DELETE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDP_AUTHENTICATOR ( + ID INTEGER AUTO_INCREMENT, + TENANT_ID INTEGER, + IDP_ID INTEGER, + NAME VARCHAR(255) NOT NULL, + IS_ENABLED CHAR (1) DEFAULT '1', + DISPLAY_NAME VARCHAR(255), + PRIMARY KEY (ID), + UNIQUE (TENANT_ID, IDP_ID, NAME), + FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE +)ENGINE INNODB; + +INSERT INTO IDP_AUTHENTICATOR (TENANT_ID, IDP_ID, NAME) VALUES (-1234, 1, 'samlsso'); +INSERT INTO IDP_AUTHENTICATOR (TENANT_ID, IDP_ID, NAME) VALUES (-1234, 1, 'IDPProperties'); +INSERT INTO IDP_AUTHENTICATOR (TENANT_ID, IDP_ID, NAME) VALUES (-1234, 1, 'passivests'); + +CREATE TABLE IF NOT EXISTS IDP_METADATA ( + ID INTEGER AUTO_INCREMENT, + IDP_ID INTEGER, + NAME VARCHAR(255) NOT NULL, + VALUE VARCHAR(255) NOT NULL, + DISPLAY_NAME VARCHAR(255), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (ID), + CONSTRAINT IDP_METADATA_CONSTRAINT UNIQUE (IDP_ID, NAME), + FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE +)ENGINE INNODB; + +INSERT INTO IDP_METADATA (IDP_ID, NAME, VALUE, DISPLAY_NAME) VALUES (1, 'SessionIdleTimeout', '20160', 'Session Idle Timeout'); +INSERT INTO IDP_METADATA (IDP_ID, NAME, VALUE, DISPLAY_NAME) VALUES (1, 'RememberMeTimeout', '15', 'RememberMe Timeout'); + +CREATE TABLE IF NOT EXISTS IDP_AUTHENTICATOR_PROPERTY ( + ID INTEGER AUTO_INCREMENT, + TENANT_ID INTEGER, + AUTHENTICATOR_ID INTEGER, + PROPERTY_KEY VARCHAR(255) NOT NULL, + PROPERTY_VALUE VARCHAR(2047), + IS_SECRET CHAR (1) DEFAULT '0', + PRIMARY KEY (ID), + UNIQUE (TENANT_ID, AUTHENTICATOR_ID, PROPERTY_KEY), + FOREIGN KEY (AUTHENTICATOR_ID) REFERENCES IDP_AUTHENTICATOR(ID) ON DELETE CASCADE +)ENGINE INNODB; + +INSERT INTO IDP_AUTHENTICATOR_PROPERTY (TENANT_ID, AUTHENTICATOR_ID, PROPERTY_KEY,PROPERTY_VALUE, IS_SECRET ) VALUES (-1234, 1 , 'IdPEntityId', 'localhost', '0'); +INSERT INTO IDP_AUTHENTICATOR_PROPERTY (TENANT_ID, AUTHENTICATOR_ID, PROPERTY_KEY,PROPERTY_VALUE, IS_SECRET ) VALUES (-1234, 3 , 'IdPEntityId', 'localhost', '0'); + +CREATE TABLE IF NOT EXISTS IDP_PROVISIONING_CONFIG ( + ID INTEGER AUTO_INCREMENT, + TENANT_ID INTEGER, + IDP_ID INTEGER, + PROVISIONING_CONNECTOR_TYPE VARCHAR(255) NOT NULL, + IS_ENABLED CHAR (1) DEFAULT '0', + IS_BLOCKING CHAR (1) DEFAULT '0', + PRIMARY KEY (ID), + UNIQUE (TENANT_ID, IDP_ID, PROVISIONING_CONNECTOR_TYPE), + FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDP_PROV_CONFIG_PROPERTY ( + ID INTEGER AUTO_INCREMENT, + TENANT_ID INTEGER, + PROVISIONING_CONFIG_ID INTEGER, + PROPERTY_KEY VARCHAR(255) NOT NULL, + PROPERTY_VALUE VARCHAR(2048), + PROPERTY_BLOB_VALUE BLOB, + PROPERTY_TYPE CHAR(32) NOT NULL, + IS_SECRET CHAR (1) DEFAULT '0', + PRIMARY KEY (ID), + UNIQUE (TENANT_ID, PROVISIONING_CONFIG_ID, PROPERTY_KEY), + FOREIGN KEY (PROVISIONING_CONFIG_ID) REFERENCES IDP_PROVISIONING_CONFIG(ID) ON DELETE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDP_PROVISIONING_ENTITY ( + ID INTEGER AUTO_INCREMENT, + PROVISIONING_CONFIG_ID INTEGER, + ENTITY_TYPE VARCHAR(255) NOT NULL, + ENTITY_LOCAL_USERSTORE VARCHAR(255) NOT NULL, + ENTITY_NAME VARCHAR(255) NOT NULL, + ENTITY_VALUE VARCHAR(255), + TENANT_ID INTEGER, + ENTITY_LOCAL_ID VARCHAR(255), + PRIMARY KEY (ID), + UNIQUE (ENTITY_TYPE, TENANT_ID, ENTITY_LOCAL_USERSTORE, ENTITY_NAME, PROVISIONING_CONFIG_ID), + UNIQUE (PROVISIONING_CONFIG_ID, ENTITY_TYPE, ENTITY_VALUE), + FOREIGN KEY (PROVISIONING_CONFIG_ID) REFERENCES IDP_PROVISIONING_CONFIG(ID) ON DELETE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDP_LOCAL_CLAIM ( + ID INTEGER AUTO_INCREMENT, + TENANT_ID INTEGER, + IDP_ID INTEGER, + CLAIM_URI VARCHAR(255) NOT NULL, + DEFAULT_VALUE VARCHAR(255), + IS_REQUESTED VARCHAR(128) DEFAULT '0', + PRIMARY KEY (ID), + UNIQUE (TENANT_ID, IDP_ID, CLAIM_URI), + FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDN_ASSOCIATED_ID ( + ID INTEGER AUTO_INCREMENT, + IDP_USER_ID VARCHAR(255) NOT NULL, + TENANT_ID INTEGER DEFAULT -1234, + IDP_ID INTEGER NOT NULL, + DOMAIN_NAME VARCHAR(255) NOT NULL, + USER_NAME VARCHAR(255) NOT NULL, + PRIMARY KEY (ID), + UNIQUE(IDP_USER_ID, TENANT_ID, IDP_ID), + FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS IDN_USER_ACCOUNT_ASSOCIATION ( + ASSOCIATION_KEY VARCHAR(255) NOT NULL, + TENANT_ID INTEGER, + DOMAIN_NAME VARCHAR(255) NOT NULL, + USER_NAME VARCHAR(255) NOT NULL, + PRIMARY KEY (TENANT_ID, DOMAIN_NAME, USER_NAME) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS FIDO_DEVICE_STORE ( + TENANT_ID INTEGER, + DOMAIN_NAME VARCHAR(255) NOT NULL, + USER_NAME VARCHAR(45) NOT NULL, + TIME_REGISTERED TIMESTAMP, + KEY_HANDLE VARCHAR(200) NOT NULL, + DEVICE_DATA VARCHAR(2048) NOT NULL, + PRIMARY KEY (TENANT_ID, DOMAIN_NAME, USER_NAME, KEY_HANDLE) + )ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS WF_REQUEST ( + UUID VARCHAR (45), + CREATED_BY VARCHAR (255), + TENANT_ID INTEGER DEFAULT -1, + OPERATION_TYPE VARCHAR (50), + CREATED_AT TIMESTAMP, + UPDATED_AT TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + STATUS VARCHAR (30), + REQUEST BLOB, + PRIMARY KEY (UUID) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS WF_BPS_PROFILE ( + PROFILE_NAME VARCHAR(45), + HOST_URL_MANAGER VARCHAR(255), + HOST_URL_WORKER VARCHAR(255), + USERNAME VARCHAR(45), + PASSWORD VARCHAR(255), + CALLBACK_HOST VARCHAR (45), + CALLBACK_USERNAME VARCHAR (45), + CALLBACK_PASSWORD VARCHAR (255), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (PROFILE_NAME, TENANT_ID) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS WF_WORKFLOW( + ID VARCHAR (45), + WF_NAME VARCHAR (45), + DESCRIPTION VARCHAR (255), + TEMPLATE_ID VARCHAR (45), + IMPL_ID VARCHAR (45), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (ID) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS WF_WORKFLOW_ASSOCIATION( + ID INTEGER NOT NULL AUTO_INCREMENT, + ASSOC_NAME VARCHAR (45), + EVENT_ID VARCHAR(45), + ASSOC_CONDITION VARCHAR (2000), + WORKFLOW_ID VARCHAR (45), + IS_ENABLED CHAR (1) DEFAULT '1', + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY(ID), + FOREIGN KEY (WORKFLOW_ID) REFERENCES WF_WORKFLOW(ID)ON DELETE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS WF_WORKFLOW_CONFIG_PARAM( + WORKFLOW_ID VARCHAR (45), + PARAM_NAME VARCHAR (45), + PARAM_VALUE VARCHAR (1000), + PARAM_QNAME VARCHAR (45), + PARAM_HOLDER VARCHAR (45), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (WORKFLOW_ID, PARAM_NAME, PARAM_QNAME, PARAM_HOLDER), + FOREIGN KEY (WORKFLOW_ID) REFERENCES WF_WORKFLOW(ID)ON DELETE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS WF_REQUEST_ENTITY_RELATIONSHIP( + REQUEST_ID VARCHAR (45), + ENTITY_NAME VARCHAR (255), + ENTITY_TYPE VARCHAR (50), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY(REQUEST_ID, ENTITY_NAME, ENTITY_TYPE, TENANT_ID), + FOREIGN KEY (REQUEST_ID) REFERENCES WF_REQUEST(UUID)ON DELETE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS WF_WORKFLOW_REQUEST_RELATION( + RELATIONSHIP_ID VARCHAR (45), + WORKFLOW_ID VARCHAR (45), + REQUEST_ID VARCHAR (45), + UPDATED_AT TIMESTAMP, + STATUS VARCHAR (30), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (RELATIONSHIP_ID), + FOREIGN KEY (WORKFLOW_ID) REFERENCES WF_WORKFLOW(ID)ON DELETE CASCADE, + FOREIGN KEY (REQUEST_ID) REFERENCES WF_REQUEST(UUID)ON DELETE CASCADE +)ENGINE INNODB; + +-- End of IDENTITY Tables-- + +-- Start of API-MGT Tables -- +CREATE TABLE IF NOT EXISTS AM_SUBSCRIBER ( + SUBSCRIBER_ID INTEGER AUTO_INCREMENT, + USER_ID VARCHAR(255) NOT NULL, + TENANT_ID INTEGER NOT NULL, + EMAIL_ADDRESS VARCHAR(256) NULL, + DATE_SUBSCRIBED TIMESTAMP NOT NULL, + PRIMARY KEY (SUBSCRIBER_ID), + CREATED_BY VARCHAR(100), + CREATED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UPDATED_BY VARCHAR(100), + UPDATED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UNIQUE (TENANT_ID,USER_ID) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_APPLICATION ( + APPLICATION_ID INTEGER AUTO_INCREMENT, + NAME VARCHAR(100), + SUBSCRIBER_ID INTEGER, + APPLICATION_TIER VARCHAR(50) DEFAULT 'Unlimited', + CALLBACK_URL VARCHAR(512), + DESCRIPTION VARCHAR(512), + APPLICATION_STATUS VARCHAR(50) DEFAULT 'APPROVED', + GROUP_ID VARCHAR(100), + CREATED_BY VARCHAR(100), + CREATED_TIME TIMESTAMP, + UPDATED_BY VARCHAR(100), + UPDATED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UUID VARCHAR(256), + FOREIGN KEY(SUBSCRIBER_ID) REFERENCES AM_SUBSCRIBER(SUBSCRIBER_ID) ON UPDATE CASCADE ON DELETE RESTRICT, + PRIMARY KEY(APPLICATION_ID), + UNIQUE (NAME,SUBSCRIBER_ID), + UNIQUE (UUID) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_API ( + API_ID INTEGER AUTO_INCREMENT, + API_PROVIDER VARCHAR(200), + API_NAME VARCHAR(200), + API_VERSION VARCHAR(30), + CONTEXT VARCHAR(256), + CONTEXT_TEMPLATE VARCHAR(256), + API_TIER VARCHAR(256), + CREATED_BY VARCHAR(100), + CREATED_TIME TIMESTAMP, + UPDATED_BY VARCHAR(100), + UPDATED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY(API_ID), + UNIQUE (API_PROVIDER,API_NAME,API_VERSION) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_API_URL_MAPPING ( + URL_MAPPING_ID INTEGER AUTO_INCREMENT, + API_ID INTEGER NOT NULL, + HTTP_METHOD VARCHAR(20) NULL, + AUTH_SCHEME VARCHAR(50) NULL, + URL_PATTERN VARCHAR(512) NULL, + THROTTLING_TIER varchar(512) DEFAULT NULL, + MEDIATION_SCRIPT BLOB, + PRIMARY KEY (URL_MAPPING_ID) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_SUBSCRIPTION ( + SUBSCRIPTION_ID INTEGER AUTO_INCREMENT, + TIER_ID VARCHAR(50), + API_ID INTEGER, + LAST_ACCESSED TIMESTAMP NULL, + APPLICATION_ID INTEGER, + SUB_STATUS VARCHAR(50), + SUBS_CREATE_STATE VARCHAR(50) DEFAULT 'SUBSCRIBE', + CREATED_BY VARCHAR(100), + CREATED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UPDATED_BY VARCHAR(100), + UPDATED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + UUID VARCHAR(256), + FOREIGN KEY(APPLICATION_ID) REFERENCES AM_APPLICATION(APPLICATION_ID) ON UPDATE CASCADE ON DELETE RESTRICT, + FOREIGN KEY(API_ID) REFERENCES AM_API(API_ID) ON UPDATE CASCADE ON DELETE RESTRICT, + PRIMARY KEY (SUBSCRIPTION_ID), + UNIQUE (UUID) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_SUBSCRIPTION_KEY_MAPPING ( + SUBSCRIPTION_ID INTEGER, + ACCESS_TOKEN VARCHAR(255), + KEY_TYPE VARCHAR(512) NOT NULL, + FOREIGN KEY(SUBSCRIPTION_ID) REFERENCES AM_SUBSCRIPTION(SUBSCRIPTION_ID) ON UPDATE CASCADE ON DELETE RESTRICT, + PRIMARY KEY(SUBSCRIPTION_ID,ACCESS_TOKEN) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_APPLICATION_KEY_MAPPING ( + APPLICATION_ID INTEGER, + CONSUMER_KEY VARCHAR(255), + KEY_TYPE VARCHAR(512) NOT NULL, + STATE VARCHAR(30) NOT NULL, + CREATE_MODE VARCHAR(30) DEFAULT 'CREATED', + FOREIGN KEY(APPLICATION_ID) REFERENCES AM_APPLICATION(APPLICATION_ID) ON UPDATE CASCADE ON DELETE RESTRICT, + PRIMARY KEY(APPLICATION_ID,KEY_TYPE) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_API_LC_EVENT ( + EVENT_ID INTEGER AUTO_INCREMENT, + API_ID INTEGER NOT NULL, + PREVIOUS_STATE VARCHAR(50), + NEW_STATE VARCHAR(50) NOT NULL, + USER_ID VARCHAR(255) NOT NULL, + TENANT_ID INTEGER NOT NULL, + EVENT_DATE TIMESTAMP NOT NULL, + FOREIGN KEY(API_ID) REFERENCES AM_API(API_ID) ON UPDATE CASCADE ON DELETE RESTRICT, + PRIMARY KEY (EVENT_ID) +)ENGINE INNODB; + +CREATE TABLE AM_APP_KEY_DOMAIN_MAPPING ( + CONSUMER_KEY VARCHAR(255), + AUTHZ_DOMAIN VARCHAR(255) DEFAULT 'ALL', + PRIMARY KEY (CONSUMER_KEY,AUTHZ_DOMAIN) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_API_COMMENTS ( + COMMENT_ID INTEGER AUTO_INCREMENT, + COMMENT_TEXT VARCHAR(512), + COMMENTED_USER VARCHAR(255), + DATE_COMMENTED TIMESTAMP NOT NULL, + API_ID INTEGER NOT NULL, + FOREIGN KEY(API_ID) REFERENCES AM_API(API_ID) ON UPDATE CASCADE ON DELETE RESTRICT, + PRIMARY KEY (COMMENT_ID) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_API_RATINGS ( + RATING_ID INTEGER AUTO_INCREMENT, + API_ID INTEGER, + RATING INTEGER, + SUBSCRIBER_ID INTEGER, + FOREIGN KEY(API_ID) REFERENCES AM_API(API_ID) ON UPDATE CASCADE ON DELETE RESTRICT, + FOREIGN KEY(SUBSCRIBER_ID) REFERENCES AM_SUBSCRIBER(SUBSCRIBER_ID) ON UPDATE CASCADE ON DELETE RESTRICT, +PRIMARY KEY (RATING_ID) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_TIER_PERMISSIONS ( + TIER_PERMISSIONS_ID INTEGER AUTO_INCREMENT, + TIER VARCHAR(50) NOT NULL, + PERMISSIONS_TYPE VARCHAR(50) NOT NULL, + ROLES VARCHAR(512) NOT NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY(TIER_PERMISSIONS_ID) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_EXTERNAL_STORES ( + APISTORE_ID INTEGER AUTO_INCREMENT, + API_ID INTEGER, + STORE_ID VARCHAR(255) NOT NULL, + STORE_DISPLAY_NAME VARCHAR(255) NOT NULL, + STORE_ENDPOINT VARCHAR(255) NOT NULL, + STORE_TYPE VARCHAR(255) NOT NULL, +FOREIGN KEY(API_ID) REFERENCES AM_API(API_ID) ON UPDATE CASCADE ON DELETE RESTRICT, +PRIMARY KEY (APISTORE_ID) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_WORKFLOWS( + WF_ID INTEGER AUTO_INCREMENT, + WF_REFERENCE VARCHAR(255) NOT NULL, + WF_TYPE VARCHAR(255) NOT NULL, + WF_STATUS VARCHAR(255) NOT NULL, + WF_CREATED_TIME TIMESTAMP, + WF_UPDATED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP , + WF_STATUS_DESC VARCHAR(1000), + TENANT_ID INTEGER, + TENANT_DOMAIN VARCHAR(255), + WF_EXTERNAL_REFERENCE VARCHAR(255) NOT NULL, + PRIMARY KEY (WF_ID), + UNIQUE (WF_EXTERNAL_REFERENCE) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_APPLICATION_REGISTRATION ( + REG_ID INT AUTO_INCREMENT, + SUBSCRIBER_ID INT, + WF_REF VARCHAR(255) NOT NULL, + APP_ID INT, + TOKEN_TYPE VARCHAR(30), + TOKEN_SCOPE VARCHAR(256) DEFAULT 'default', + INPUTS VARCHAR(1000), + ALLOWED_DOMAINS VARCHAR(256), + VALIDITY_PERIOD BIGINT, + UNIQUE (SUBSCRIBER_ID,APP_ID,TOKEN_TYPE), + FOREIGN KEY(SUBSCRIBER_ID) REFERENCES AM_SUBSCRIBER(SUBSCRIBER_ID) ON UPDATE CASCADE ON DELETE RESTRICT, + FOREIGN KEY(APP_ID) REFERENCES AM_APPLICATION(APPLICATION_ID) ON UPDATE CASCADE ON DELETE RESTRICT, + PRIMARY KEY (REG_ID) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_API_SCOPES ( + API_ID INTEGER NOT NULL, + SCOPE_ID INTEGER NOT NULL, + FOREIGN KEY (API_ID) REFERENCES AM_API (API_ID) ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (SCOPE_ID) REFERENCES IDN_OAUTH2_SCOPE (SCOPE_ID) ON DELETE CASCADE ON UPDATE CASCADE +)ENGINE = INNODB; + +CREATE TABLE IF NOT EXISTS AM_API_DEFAULT_VERSION ( + DEFAULT_VERSION_ID INT AUTO_INCREMENT, + API_NAME VARCHAR(256) NOT NULL , + API_PROVIDER VARCHAR(256) NOT NULL , + DEFAULT_API_VERSION VARCHAR(30) , + PUBLISHED_DEFAULT_API_VERSION VARCHAR(30) , + PRIMARY KEY (DEFAULT_VERSION_ID) +)ENGINE = INNODB; + +CREATE INDEX IDX_SUB_APP_ID ON AM_SUBSCRIPTION (APPLICATION_ID, SUBSCRIPTION_ID); + + +CREATE TABLE IF NOT EXISTS AM_ALERT_TYPES ( + ALERT_TYPE_ID INTEGER AUTO_INCREMENT, + ALERT_TYPE_NAME VARCHAR(255) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL, + PRIMARY KEY (ALERT_TYPE_ID) +)ENGINE = INNODB; + +CREATE TABLE IF NOT EXISTS AM_ALERT_TYPES_VALUES ( + ALERT_TYPE_ID INTEGER, + USER_NAME VARCHAR(255) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL , + PRIMARY KEY (ALERT_TYPE_ID,USER_NAME,STAKE_HOLDER) +)ENGINE = INNODB; + +CREATE TABLE IF NOT EXISTS AM_ALERT_EMAILLIST ( + EMAIL_LIST_ID INTEGER AUTO_INCREMENT, + USER_NAME VARCHAR(255) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL , + PRIMARY KEY (EMAIL_LIST_ID,USER_NAME,STAKE_HOLDER) +)ENGINE = INNODB; + +CREATE TABLE IF NOT EXISTS AM_ALERT_EMAILLIST_DETAILS ( + EMAIL_LIST_ID INTEGER, + EMAIL VARCHAR(255), + PRIMARY KEY (EMAIL_LIST_ID,EMAIL) +)ENGINE = INNODB; + +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalResponseTime', 'publisher'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalBackendTime', 'publisher'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalRequestsPerMin', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('RequestPatternChanged', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('UnusualIPAccessAlert', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('AbnormalRefreshAlert', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('FrequentTierHittingAlert', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('AbnormalTierUsage', 'publisher'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('healthAvailabilityPerMin', 'publisher'); + + + +-- AM Throttling tables -- + +CREATE TABLE IF NOT EXISTS AM_POLICY_SUBSCRIPTION ( + POLICY_ID INT(11) NOT NULL AUTO_INCREMENT, + NAME VARCHAR(512) NOT NULL, + DISPLAY_NAME VARCHAR(512) NULL DEFAULT NULL, + TENANT_ID INT(11) NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + QUOTA_TYPE VARCHAR(25) NOT NULL, + QUOTA INT(11) NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL, + UNIT_TIME INT(11) NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + RATE_LIMIT_COUNT INT(11) NULL DEFAULT NULL, + RATE_LIMIT_TIME_UNIT VARCHAR(25) NULL DEFAULT NULL, + IS_DEPLOYED TINYINT(1) NOT NULL DEFAULT 0, + CUSTOM_ATTRIBUTES BLOB DEFAULT NULL, + STOP_ON_QUOTA_REACH BOOLEAN NOT NULL DEFAULT 0, + BILLING_PLAN VARCHAR(20) NOT NULL, + UUID VARCHAR(256), + PRIMARY KEY (POLICY_ID), + UNIQUE INDEX AM_POLICY_SUBSCRIPTION_NAME_TENANT (NAME, TENANT_ID), + UNIQUE (UUID) +)ENGINE = InnoDB; + +CREATE TABLE IF NOT EXISTS AM_POLICY_APPLICATION ( + POLICY_ID INT(11) NOT NULL AUTO_INCREMENT, + NAME VARCHAR(512) NOT NULL, + DISPLAY_NAME VARCHAR(512) NULL DEFAULT NULL, + TENANT_ID INT(11) NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + QUOTA_TYPE VARCHAR(25) NOT NULL, + QUOTA INT(11) NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL DEFAULT NULL, + UNIT_TIME INT(11) NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + IS_DEPLOYED TINYINT(1) NOT NULL DEFAULT 0, + CUSTOM_ATTRIBUTES BLOB DEFAULT NULL, + UUID VARCHAR(256), + PRIMARY KEY (POLICY_ID), + UNIQUE INDEX APP_NAME_TENANT (NAME, TENANT_ID), + UNIQUE (UUID) +)ENGINE = InnoDB; + +CREATE TABLE IF NOT EXISTS AM_POLICY_HARD_THROTTLING ( + POLICY_ID INT(11) NOT NULL AUTO_INCREMENT, + NAME VARCHAR(512) NOT NULL, + TENANT_ID INT(11) NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + QUOTA_TYPE VARCHAR(25) NOT NULL, + QUOTA INT(11) NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL DEFAULT NULL, + UNIT_TIME INT(11) NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + IS_DEPLOYED TINYINT(1) NOT NULL DEFAULT 0, + PRIMARY KEY (POLICY_ID), + UNIQUE INDEX POLICY_HARD_NAME_TENANT (NAME, TENANT_ID) +)ENGINE = InnoDB; + + +CREATE TABLE IF NOT EXISTS AM_API_THROTTLE_POLICY ( + POLICY_ID INT(11) NOT NULL AUTO_INCREMENT, + NAME VARCHAR(512) NOT NULL, + DISPLAY_NAME VARCHAR(512) NULL DEFAULT NULL, + TENANT_ID INT(11) NOT NULL, + DESCRIPTION VARCHAR (1024), + DEFAULT_QUOTA_TYPE VARCHAR(25) NOT NULL, + DEFAULT_QUOTA INTEGER NOT NULL, + DEFAULT_QUOTA_UNIT VARCHAR(10) NULL, + DEFAULT_UNIT_TIME INTEGER NOT NULL, + DEFAULT_TIME_UNIT VARCHAR(25) NOT NULL, + APPLICABLE_LEVEL VARCHAR(25) NOT NULL, + IS_DEPLOYED TINYINT(1) NOT NULL DEFAULT 0, + UUID VARCHAR(256), + PRIMARY KEY (POLICY_ID), + UNIQUE INDEX API_NAME_TENANT (NAME, TENANT_ID), + UNIQUE (UUID) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_CONDITION_GROUP ( + CONDITION_GROUP_ID INTEGER NOT NULL AUTO_INCREMENT, + POLICY_ID INTEGER NOT NULL, + QUOTA_TYPE VARCHAR(25), + QUOTA INTEGER NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL DEFAULT NULL, + UNIT_TIME INTEGER NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + DESCRIPTION VARCHAR (1024) NULL DEFAULT NULL, + PRIMARY KEY (CONDITION_GROUP_ID), + FOREIGN KEY (POLICY_ID) REFERENCES AM_API_THROTTLE_POLICY(POLICY_ID) ON DELETE CASCADE ON UPDATE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_QUERY_PARAMETER_CONDITION ( + QUERY_PARAMETER_ID INTEGER NOT NULL AUTO_INCREMENT, + CONDITION_GROUP_ID INTEGER NOT NULL, + PARAMETER_NAME VARCHAR(255) DEFAULT NULL, + PARAMETER_VALUE VARCHAR(255) DEFAULT NULL, + IS_PARAM_MAPPING BOOLEAN DEFAULT 1, + PRIMARY KEY (QUERY_PARAMETER_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_HEADER_FIELD_CONDITION ( + HEADER_FIELD_ID INTEGER NOT NULL AUTO_INCREMENT, + CONDITION_GROUP_ID INTEGER NOT NULL, + HEADER_FIELD_NAME VARCHAR(255) DEFAULT NULL, + HEADER_FIELD_VALUE VARCHAR(255) DEFAULT NULL, + IS_HEADER_FIELD_MAPPING BOOLEAN DEFAULT 1, + PRIMARY KEY (HEADER_FIELD_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_JWT_CLAIM_CONDITION ( + JWT_CLAIM_ID INTEGER NOT NULL AUTO_INCREMENT, + CONDITION_GROUP_ID INTEGER NOT NULL, + CLAIM_URI VARCHAR(512) DEFAULT NULL, + CLAIM_ATTRIB VARCHAR(1024) DEFAULT NULL, + IS_CLAIM_MAPPING BOOLEAN DEFAULT 1, + PRIMARY KEY (JWT_CLAIM_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_IP_CONDITION ( + AM_IP_CONDITION_ID INT NOT NULL AUTO_INCREMENT, + STARTING_IP VARCHAR(45) NULL, + ENDING_IP VARCHAR(45) NULL, + SPECIFIC_IP VARCHAR(45) NULL, + WITHIN_IP_RANGE BOOLEAN DEFAULT 1, + CONDITION_GROUP_ID INT NULL, + PRIMARY KEY (AM_IP_CONDITION_ID), + INDEX fk_AM_IP_CONDITION_1_idx (CONDITION_GROUP_ID ASC), CONSTRAINT fk_AM_IP_CONDITION_1 FOREIGN KEY (CONDITION_GROUP_ID) + REFERENCES AM_CONDITION_GROUP (CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE) +ENGINE = InnoDB; + + +CREATE TABLE IF NOT EXISTS AM_POLICY_GLOBAL ( + POLICY_ID INT(11) NOT NULL AUTO_INCREMENT, + NAME VARCHAR(512) NOT NULL, + KEY_TEMPLATE VARCHAR(512) NOT NULL, + TENANT_ID INT(11) NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + SIDDHI_QUERY BLOB DEFAULT NULL, + IS_DEPLOYED TINYINT(1) NOT NULL DEFAULT 0, + UUID VARCHAR(256), + PRIMARY KEY (POLICY_ID), + UNIQUE (UUID) +)ENGINE INNODB; + +CREATE TABLE IF NOT EXISTS AM_THROTTLE_TIER_PERMISSIONS ( + THROTTLE_TIER_PERMISSIONS_ID INT NOT NULL AUTO_INCREMENT, + TIER VARCHAR(50) NULL, + PERMISSIONS_TYPE VARCHAR(50) NULL, + ROLES VARCHAR(512) NULL, + TENANT_ID INT(11) NULL, + PRIMARY KEY (THROTTLE_TIER_PERMISSIONS_ID)) +ENGINE = InnoDB; + +CREATE TABLE `AM_BLOCK_CONDITIONS` ( + `CONDITION_ID` int(11) NOT NULL AUTO_INCREMENT, + `TYPE` varchar(45) DEFAULT NULL, + `VALUE` varchar(45) DEFAULT NULL, + `ENABLED` varchar(45) DEFAULT NULL, + `DOMAIN` varchar(45) DEFAULT NULL, + `UUID` VARCHAR(256), + PRIMARY KEY (`CONDITION_ID`), + UNIQUE (`UUID`) +) ENGINE=InnoDB; + +-- End of API-MGT Tables -- + +-- Performance indexes start-- + +create index IDX_ITS_LMT on IDN_THRIFT_SESSION (LAST_MODIFIED_TIME); +create index IDX_IOAT_AT on IDN_OAUTH2_ACCESS_TOKEN (ACCESS_TOKEN); +create index IDX_IOAT_UT on IDN_OAUTH2_ACCESS_TOKEN (USER_TYPE); +create index IDX_AAI_CTX on AM_API (CONTEXT); +create index IDX_AAKM_CK on AM_APPLICATION_KEY_MAPPING (CONSUMER_KEY); +create index IDX_AAUM_AI on AM_API_URL_MAPPING (API_ID); +create index IDX_AAUM_TT on AM_API_URL_MAPPING (THROTTLING_TIER); +create index IDX_AATP_DQT on AM_API_THROTTLE_POLICY (DEFAULT_QUOTA_TYPE); +create index IDX_ACG_QT on AM_CONDITION_GROUP (QUOTA_TYPE); +create index IDX_APS_QT on AM_POLICY_SUBSCRIPTION (QUOTA_TYPE); +create index IDX_AS_AITIAI on AM_SUBSCRIPTION (API_ID,TIER_ID,APPLICATION_ID); +create index IDX_APA_QT on AM_POLICY_APPLICATION (QUOTA_TYPE); +create index IDX_AA_AT_CB on AM_APPLICATION (APPLICATION_TIER,CREATED_BY); + +-- Performance indexes end-- diff --git a/modules/distribution/src/repository/resources/dbscripts/apimgt/mysql_cluster.sql b/modules/distribution/src/repository/resources/dbscripts/apimgt/mysql_cluster.sql new file mode 100644 index 00000000..2c6721ff --- /dev/null +++ b/modules/distribution/src/repository/resources/dbscripts/apimgt/mysql_cluster.sql @@ -0,0 +1,1039 @@ +-- Start of IDN Tables -- +CREATE TABLE IF NOT EXISTS IDN_BASE_TABLE ( + PRODUCT_NAME VARCHAR(20), + PRIMARY KEY (PRODUCT_NAME) +)ENGINE NDB; + +INSERT INTO IDN_BASE_TABLE values ('WSO2 Identity Server'); + +CREATE TABLE IF NOT EXISTS IDN_OAUTH_CONSUMER_APPS ( + ID INTEGER NOT NULL AUTO_INCREMENT, + CONSUMER_KEY VARCHAR(255), + CONSUMER_SECRET VARCHAR(512), + USERNAME VARCHAR(255), + TENANT_ID INTEGER DEFAULT 0, + USER_DOMAIN VARCHAR(50), + APP_NAME VARCHAR(255), + OAUTH_VERSION VARCHAR(128), + CALLBACK_URL VARCHAR(1024), + GRANT_TYPES VARCHAR (1024), + PKCE_MANDATORY CHAR(1) DEFAULT '0', + PKCE_SUPPORT_PLAIN CHAR(1) DEFAULT '0', + CONSTRAINT CONSUMER_KEY_CONSTRAINT UNIQUE (CONSUMER_KEY), + PRIMARY KEY (ID) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDN_OAUTH1A_REQUEST_TOKEN ( + REQUEST_TOKEN VARCHAR(255), + REQUEST_TOKEN_SECRET VARCHAR(512), + CONSUMER_KEY_ID INTEGER, + CALLBACK_URL VARCHAR(1024), + SCOPE VARCHAR(2048), + AUTHORIZED VARCHAR(128), + OAUTH_VERIFIER VARCHAR(512), + AUTHZ_USER VARCHAR(512), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (REQUEST_TOKEN), + FOREIGN KEY (CONSUMER_KEY_ID) REFERENCES IDN_OAUTH_CONSUMER_APPS(ID) ON DELETE CASCADE +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDN_OAUTH1A_ACCESS_TOKEN ( + ACCESS_TOKEN VARCHAR(255), + ACCESS_TOKEN_SECRET VARCHAR(512), + CONSUMER_KEY_ID INTEGER, + SCOPE VARCHAR(2048), + AUTHZ_USER VARCHAR(512), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (ACCESS_TOKEN), + FOREIGN KEY (CONSUMER_KEY_ID) REFERENCES IDN_OAUTH_CONSUMER_APPS(ID) ON DELETE CASCADE +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDN_OAUTH2_ACCESS_TOKEN ( + TOKEN_ID VARCHAR (255), + ACCESS_TOKEN VARCHAR(255), + REFRESH_TOKEN VARCHAR(255), + CONSUMER_KEY_ID INTEGER, + AUTHZ_USER VARCHAR (100), + TENANT_ID INTEGER, + USER_DOMAIN VARCHAR(50), + USER_TYPE VARCHAR (25), + GRANT_TYPE VARCHAR (50), + TIME_CREATED TIMESTAMP DEFAULT 0, + REFRESH_TOKEN_TIME_CREATED TIMESTAMP DEFAULT 0, + VALIDITY_PERIOD BIGINT, + REFRESH_TOKEN_VALIDITY_PERIOD BIGINT, + TOKEN_SCOPE_HASH VARCHAR(32), + TOKEN_STATE VARCHAR(25) DEFAULT 'ACTIVE', + TOKEN_STATE_ID VARCHAR (128) DEFAULT 'NONE', + SUBJECT_IDENTIFIER VARCHAR(255), + PRIMARY KEY (TOKEN_ID), + FOREIGN KEY (CONSUMER_KEY_ID) REFERENCES IDN_OAUTH_CONSUMER_APPS(ID) ON DELETE CASCADE, + CONSTRAINT CON_APP_KEY UNIQUE (CONSUMER_KEY_ID,AUTHZ_USER,TENANT_ID,USER_DOMAIN,USER_TYPE,TOKEN_SCOPE_HASH, + TOKEN_STATE,TOKEN_STATE_ID) +)ENGINE NDB; + +CREATE INDEX IDX_AT_CK_AU ON IDN_OAUTH2_ACCESS_TOKEN(CONSUMER_KEY_ID, AUTHZ_USER, TOKEN_STATE, USER_TYPE); + +CREATE INDEX IDX_TC ON IDN_OAUTH2_ACCESS_TOKEN(TIME_CREATED); + +CREATE TABLE IF NOT EXISTS IDN_OAUTH2_AUTHORIZATION_CODE ( + CODE_ID VARCHAR (255), + AUTHORIZATION_CODE VARCHAR(512), + CONSUMER_KEY_ID INTEGER, + CALLBACK_URL VARCHAR(1024), + SCOPE VARCHAR(2048), + AUTHZ_USER VARCHAR (100), + TENANT_ID INTEGER, + USER_DOMAIN VARCHAR(50), + TIME_CREATED TIMESTAMP, + VALIDITY_PERIOD BIGINT, + STATE VARCHAR (25) DEFAULT 'ACTIVE', + TOKEN_ID VARCHAR(255), + SUBJECT_IDENTIFIER VARCHAR(255), + PKCE_CODE_CHALLENGE VARCHAR(255), + PKCE_CODE_CHALLENGE_METHOD VARCHAR(128), + PRIMARY KEY (CODE_ID), + FOREIGN KEY (CONSUMER_KEY_ID) REFERENCES IDN_OAUTH_CONSUMER_APPS(ID) ON DELETE CASCADE +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDN_OAUTH2_ACCESS_TOKEN_SCOPE ( + TOKEN_ID VARCHAR (255), + TOKEN_SCOPE VARCHAR (60), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (TOKEN_ID, TOKEN_SCOPE), + FOREIGN KEY (TOKEN_ID) REFERENCES IDN_OAUTH2_ACCESS_TOKEN(TOKEN_ID) ON DELETE CASCADE +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDN_OAUTH2_SCOPE ( + SCOPE_ID INT(11) NOT NULL AUTO_INCREMENT, + SCOPE_KEY VARCHAR(100) NOT NULL, + NAME VARCHAR(255) NULL, + DESCRIPTION VARCHAR(512) NULL, + TENANT_ID INT(11) NOT NULL DEFAULT 0, + ROLES VARCHAR (500) NULL, + PRIMARY KEY (SCOPE_ID) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDN_OAUTH2_RESOURCE_SCOPE ( + RESOURCE_PATH VARCHAR(255) NOT NULL, + SCOPE_ID INTEGER (11) NOT NULL, + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (RESOURCE_PATH), + FOREIGN KEY (SCOPE_ID) REFERENCES IDN_OAUTH2_SCOPE (SCOPE_ID) ON DELETE CASCADE ON UPDATE CASCADE +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDN_SCIM_GROUP ( + ID INTEGER AUTO_INCREMENT, + TENANT_ID INTEGER NOT NULL, + ROLE_NAME VARCHAR(255) NOT NULL, + ATTR_NAME VARCHAR(1024) NOT NULL, + ATTR_VALUE VARCHAR(1024), + PRIMARY KEY (ID) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDN_OPENID_REMEMBER_ME ( + USER_NAME VARCHAR(255) NOT NULL, + TENANT_ID INTEGER DEFAULT 0, + COOKIE_VALUE VARCHAR(1024), + CREATED_TIME TIMESTAMP, + PRIMARY KEY (USER_NAME, TENANT_ID) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDN_OPENID_USER_RPS ( + USER_NAME VARCHAR(255) NOT NULL, + TENANT_ID INTEGER DEFAULT 0, + RP_URL VARCHAR(255) NOT NULL, + TRUSTED_ALWAYS VARCHAR(128) DEFAULT 'FALSE', + LAST_VISIT DATE NOT NULL, + VISIT_COUNT INTEGER DEFAULT 0, + DEFAULT_PROFILE_NAME VARCHAR(255) DEFAULT 'DEFAULT', + PRIMARY KEY (USER_NAME, TENANT_ID, RP_URL) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDN_OPENID_ASSOCIATIONS ( + HANDLE VARCHAR(255) NOT NULL, + ASSOC_TYPE VARCHAR(255) NOT NULL, + EXPIRE_IN TIMESTAMP NOT NULL, + MAC_KEY VARCHAR(255) NOT NULL, + ASSOC_STORE VARCHAR(128) DEFAULT 'SHARED', + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (HANDLE) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDN_STS_STORE ( + ID INTEGER AUTO_INCREMENT, + TOKEN_ID VARCHAR(255) NOT NULL, + TOKEN_CONTENT BLOB(1024) NOT NULL, + CREATE_DATE TIMESTAMP NOT NULL, + EXPIRE_DATE TIMESTAMP NOT NULL, + STATE INTEGER DEFAULT 0, + PRIMARY KEY (ID) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDN_IDENTITY_USER_DATA ( + TENANT_ID INTEGER DEFAULT -1234, + USER_NAME VARCHAR(255) NOT NULL, + DATA_KEY VARCHAR(255) NOT NULL, + DATA_VALUE VARCHAR(255), + PRIMARY KEY (TENANT_ID, USER_NAME, DATA_KEY) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDN_IDENTITY_META_DATA ( + USER_NAME VARCHAR(255) NOT NULL, + TENANT_ID INTEGER DEFAULT -1234, + METADATA_TYPE VARCHAR(255) NOT NULL, + METADATA VARCHAR(255) NOT NULL, + VALID VARCHAR(255) NOT NULL, + PRIMARY KEY (TENANT_ID, USER_NAME, METADATA_TYPE,METADATA) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDN_THRIFT_SESSION ( + SESSION_ID VARCHAR(255) NOT NULL, + USER_NAME VARCHAR(255) NOT NULL, + CREATED_TIME VARCHAR(255) NOT NULL, + LAST_MODIFIED_TIME VARCHAR(255) NOT NULL, + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (SESSION_ID) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDN_AUTH_SESSION_STORE ( + SESSION_ID VARCHAR (100) NOT NULL, + SESSION_TYPE VARCHAR(100) NOT NULL, + OPERATION VARCHAR(10) NOT NULL, + SESSION_OBJECT BLOB, + TIME_CREATED BIGINT, + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (SESSION_ID, SESSION_TYPE, TIME_CREATED, OPERATION) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS SP_APP ( + ID INTEGER NOT NULL AUTO_INCREMENT, + TENANT_ID INTEGER NOT NULL, + APP_NAME VARCHAR (255) NOT NULL , + USER_STORE VARCHAR (255) NOT NULL, + USERNAME VARCHAR (255) NOT NULL , + DESCRIPTION VARCHAR (1024), + ROLE_CLAIM VARCHAR (512), + AUTH_TYPE VARCHAR (255) NOT NULL, + PROVISIONING_USERSTORE_DOMAIN VARCHAR (512), + IS_LOCAL_CLAIM_DIALECT CHAR(1) DEFAULT '1', + IS_SEND_LOCAL_SUBJECT_ID CHAR(1) DEFAULT '0', + IS_SEND_AUTH_LIST_OF_IDPS CHAR(1) DEFAULT '0', + IS_USE_TENANT_DOMAIN_SUBJECT CHAR(1) DEFAULT '1', + IS_USE_USER_DOMAIN_SUBJECT CHAR(1) DEFAULT '1', + SUBJECT_CLAIM_URI VARCHAR (512), + IS_SAAS_APP CHAR(1) DEFAULT '0', + IS_DUMB_MODE CHAR(1) DEFAULT '0', + PRIMARY KEY (ID) +)ENGINE NDB; + +ALTER TABLE SP_APP ADD CONSTRAINT APPLICATION_NAME_CONSTRAINT UNIQUE(APP_NAME, TENANT_ID); + +CREATE TABLE IF NOT EXISTS SP_METADATA ( + ID INTEGER AUTO_INCREMENT, + SP_ID INTEGER, + NAME VARCHAR(255) NOT NULL, + VALUE VARCHAR(255) NOT NULL, + DISPLAY_NAME VARCHAR(255), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (ID), + CONSTRAINT SP_METADATA_CONSTRAINT UNIQUE (SP_ID, NAME), + FOREIGN KEY (SP_ID) REFERENCES SP_APP(ID) ON DELETE CASCADE +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS SP_INBOUND_AUTH ( + ID INTEGER NOT NULL AUTO_INCREMENT, + TENANT_ID INTEGER NOT NULL, + INBOUND_AUTH_KEY VARCHAR (255), + INBOUND_AUTH_TYPE VARCHAR (255) NOT NULL, + PROP_NAME VARCHAR (255), + PROP_VALUE VARCHAR (1024) , + APP_ID INTEGER NOT NULL, + PRIMARY KEY (ID) +)ENGINE NDB; + +ALTER TABLE SP_INBOUND_AUTH ADD CONSTRAINT APPLICATION_ID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE; + +CREATE TABLE IF NOT EXISTS SP_AUTH_STEP ( + ID INTEGER NOT NULL AUTO_INCREMENT, + TENANT_ID INTEGER NOT NULL, + STEP_ORDER INTEGER DEFAULT 1, + APP_ID INTEGER NOT NULL , + IS_SUBJECT_STEP CHAR(1) DEFAULT '0', + IS_ATTRIBUTE_STEP CHAR(1) DEFAULT '0', + PRIMARY KEY (ID) +)ENGINE NDB; + +ALTER TABLE SP_AUTH_STEP ADD CONSTRAINT APPLICATION_ID_CONSTRAINT_STEP FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE; + +CREATE TABLE IF NOT EXISTS SP_FEDERATED_IDP ( + ID INTEGER NOT NULL, + TENANT_ID INTEGER NOT NULL, + AUTHENTICATOR_ID INTEGER NOT NULL, + PRIMARY KEY (ID, AUTHENTICATOR_ID) +)ENGINE NDB; + +ALTER TABLE SP_FEDERATED_IDP ADD CONSTRAINT STEP_ID_CONSTRAINT FOREIGN KEY (ID) REFERENCES SP_AUTH_STEP (ID) ON DELETE CASCADE; + +CREATE TABLE IF NOT EXISTS SP_CLAIM_MAPPING ( + ID INTEGER NOT NULL AUTO_INCREMENT, + TENANT_ID INTEGER NOT NULL, + IDP_CLAIM VARCHAR (512) NOT NULL , + SP_CLAIM VARCHAR (512) NOT NULL , + APP_ID INTEGER NOT NULL, + IS_REQUESTED VARCHAR(128) DEFAULT '0', + DEFAULT_VALUE VARCHAR(255), + PRIMARY KEY (ID) +)ENGINE NDB; + +ALTER TABLE SP_CLAIM_MAPPING ADD CONSTRAINT CLAIMID_APPID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE; + +CREATE TABLE IF NOT EXISTS SP_ROLE_MAPPING ( + ID INTEGER NOT NULL AUTO_INCREMENT, + TENANT_ID INTEGER NOT NULL, + IDP_ROLE VARCHAR (255) NOT NULL , + SP_ROLE VARCHAR (255) NOT NULL , + APP_ID INTEGER NOT NULL, + PRIMARY KEY (ID) +)ENGINE NDB; + +ALTER TABLE SP_ROLE_MAPPING ADD CONSTRAINT ROLEID_APPID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE; + +CREATE TABLE IF NOT EXISTS SP_REQ_PATH_AUTHENTICATOR ( + ID INTEGER NOT NULL AUTO_INCREMENT, + TENANT_ID INTEGER NOT NULL, + AUTHENTICATOR_NAME VARCHAR (255) NOT NULL , + APP_ID INTEGER NOT NULL, + PRIMARY KEY (ID) +)ENGINE NDB; + +ALTER TABLE SP_REQ_PATH_AUTHENTICATOR ADD CONSTRAINT REQ_AUTH_APPID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE; + +CREATE TABLE IF NOT EXISTS SP_PROVISIONING_CONNECTOR ( + ID INTEGER NOT NULL AUTO_INCREMENT, + TENANT_ID INTEGER NOT NULL, + IDP_NAME VARCHAR (255) NOT NULL , + CONNECTOR_NAME VARCHAR (255) NOT NULL , + APP_ID INTEGER NOT NULL, + IS_JIT_ENABLED CHAR(1) NOT NULL DEFAULT '0', + BLOCKING CHAR(1) NOT NULL DEFAULT '0', + PRIMARY KEY (ID) +)ENGINE NDB; + +ALTER TABLE SP_PROVISIONING_CONNECTOR ADD CONSTRAINT PRO_CONNECTOR_APPID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE; + +CREATE TABLE IF NOT EXISTS IDP ( + ID INTEGER AUTO_INCREMENT, + TENANT_ID INTEGER, + NAME VARCHAR(254) NOT NULL, + IS_ENABLED CHAR(1) NOT NULL DEFAULT '1', + IS_PRIMARY CHAR(1) NOT NULL DEFAULT '0', + HOME_REALM_ID VARCHAR(254), + IMAGE MEDIUMBLOB, + CERTIFICATE BLOB, + ALIAS VARCHAR(254), + INBOUND_PROV_ENABLED CHAR (1) NOT NULL DEFAULT '0', + INBOUND_PROV_USER_STORE_ID VARCHAR(254), + USER_CLAIM_URI VARCHAR(254), + ROLE_CLAIM_URI VARCHAR(254), + DESCRIPTION VARCHAR (1024), + DEFAULT_AUTHENTICATOR_NAME VARCHAR(254), + DEFAULT_PRO_CONNECTOR_NAME VARCHAR(254), + PROVISIONING_ROLE VARCHAR(128), + IS_FEDERATION_HUB CHAR(1) NOT NULL DEFAULT '0', + IS_LOCAL_CLAIM_DIALECT CHAR(1) NOT NULL DEFAULT '0', + DISPLAY_NAME VARCHAR(255), + PRIMARY KEY (ID), + UNIQUE (TENANT_ID, NAME) +)ENGINE NDB; + +INSERT INTO IDP (TENANT_ID, NAME, HOME_REALM_ID) VALUES (-1234, 'LOCAL', 'localhost'); + +CREATE TABLE IF NOT EXISTS IDP_ROLE ( + ID INTEGER AUTO_INCREMENT, + IDP_ID INTEGER, + TENANT_ID INTEGER, + ROLE VARCHAR(254), + PRIMARY KEY (ID), + UNIQUE (IDP_ID, ROLE), + FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDP_ROLE_MAPPING ( + ID INTEGER AUTO_INCREMENT, + IDP_ROLE_ID INTEGER, + TENANT_ID INTEGER, + USER_STORE_ID VARCHAR (253), + LOCAL_ROLE VARCHAR(253), + PRIMARY KEY (ID), + UNIQUE (IDP_ROLE_ID, TENANT_ID, USER_STORE_ID, LOCAL_ROLE), + FOREIGN KEY (IDP_ROLE_ID) REFERENCES IDP_ROLE(ID) ON DELETE CASCADE +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDP_CLAIM ( + ID INTEGER AUTO_INCREMENT, + IDP_ID INTEGER, + TENANT_ID INTEGER, + CLAIM VARCHAR(254), + PRIMARY KEY (ID), + UNIQUE (IDP_ID, CLAIM), + FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDP_CLAIM_MAPPING ( + ID INTEGER AUTO_INCREMENT, + IDP_CLAIM_ID INTEGER, + TENANT_ID INTEGER, + LOCAL_CLAIM VARCHAR(253), + DEFAULT_VALUE VARCHAR(255), + IS_REQUESTED VARCHAR(128) DEFAULT '0', + PRIMARY KEY (ID), + UNIQUE (IDP_CLAIM_ID, TENANT_ID, LOCAL_CLAIM), + FOREIGN KEY (IDP_CLAIM_ID) REFERENCES IDP_CLAIM(ID) ON DELETE CASCADE +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDP_AUTHENTICATOR ( + ID INTEGER AUTO_INCREMENT, + TENANT_ID INTEGER, + IDP_ID INTEGER, + NAME VARCHAR(255) NOT NULL, + IS_ENABLED CHAR (1) DEFAULT '1', + DISPLAY_NAME VARCHAR(255), + PRIMARY KEY (ID), + UNIQUE (TENANT_ID, IDP_ID, NAME), + FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE +)ENGINE NDB; + +INSERT INTO IDP_AUTHENTICATOR (TENANT_ID, IDP_ID, NAME) VALUES (-1234, 1, 'samlsso'); +INSERT INTO IDP_AUTHENTICATOR (TENANT_ID, IDP_ID, NAME) VALUES (-1234, 1, 'IDPProperties'); +INSERT INTO IDP_AUTHENTICATOR (TENANT_ID, IDP_ID, NAME) VALUES (-1234, 1, 'passivests'); + +CREATE TABLE IF NOT EXISTS IDP_METADATA ( + ID INTEGER AUTO_INCREMENT, + IDP_ID INTEGER, + NAME VARCHAR(255) NOT NULL, + VALUE VARCHAR(255) NOT NULL, + DISPLAY_NAME VARCHAR(255), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (ID), + CONSTRAINT IDP_METADATA_CONSTRAINT UNIQUE (IDP_ID, NAME), + FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE +)ENGINE NDB; + +INSERT INTO IDP_METADATA (IDP_ID, NAME, VALUE, DISPLAY_NAME) VALUES (1, 'SessionIdleTimeout', '20160', 'Session Idle Timeout'); +INSERT INTO IDP_METADATA (IDP_ID, NAME, VALUE, DISPLAY_NAME) VALUES (1, 'RememberMeTimeout', '15', 'RememberMe Timeout'); + +CREATE TABLE IF NOT EXISTS IDP_AUTHENTICATOR_PROPERTY ( + ID INTEGER AUTO_INCREMENT, + TENANT_ID INTEGER, + AUTHENTICATOR_ID INTEGER, + PROPERTY_KEY VARCHAR(255) NOT NULL, + PROPERTY_VALUE VARCHAR(2047), + IS_SECRET CHAR (1) DEFAULT '0', + PRIMARY KEY (ID), + UNIQUE (TENANT_ID, AUTHENTICATOR_ID, PROPERTY_KEY), + FOREIGN KEY (AUTHENTICATOR_ID) REFERENCES IDP_AUTHENTICATOR(ID) ON DELETE CASCADE +)ENGINE NDB; + +INSERT INTO IDP_AUTHENTICATOR_PROPERTY (TENANT_ID, AUTHENTICATOR_ID, PROPERTY_KEY,PROPERTY_VALUE, IS_SECRET ) VALUES (-1234, 1 , 'IdPEntityId', 'localhost', '0'); +INSERT INTO IDP_AUTHENTICATOR_PROPERTY (TENANT_ID, AUTHENTICATOR_ID, PROPERTY_KEY,PROPERTY_VALUE, IS_SECRET ) VALUES (-1234, 3 , 'IdPEntityId', 'localhost', '0'); + +CREATE TABLE IF NOT EXISTS IDP_PROVISIONING_CONFIG ( + ID INTEGER AUTO_INCREMENT, + TENANT_ID INTEGER, + IDP_ID INTEGER, + PROVISIONING_CONNECTOR_TYPE VARCHAR(255) NOT NULL, + IS_ENABLED CHAR (1) DEFAULT '0', + IS_BLOCKING CHAR (1) DEFAULT '0', + PRIMARY KEY (ID), + UNIQUE (TENANT_ID, IDP_ID, PROVISIONING_CONNECTOR_TYPE), + FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDP_PROV_CONFIG_PROPERTY ( + ID INTEGER AUTO_INCREMENT, + TENANT_ID INTEGER, + PROVISIONING_CONFIG_ID INTEGER, + PROPERTY_KEY VARCHAR(255) NOT NULL, + PROPERTY_VALUE VARCHAR(2048), + PROPERTY_BLOB_VALUE BLOB, + PROPERTY_TYPE CHAR(32) NOT NULL, + IS_SECRET CHAR (1) DEFAULT '0', + PRIMARY KEY (ID), + UNIQUE (TENANT_ID, PROVISIONING_CONFIG_ID, PROPERTY_KEY), + FOREIGN KEY (PROVISIONING_CONFIG_ID) REFERENCES IDP_PROVISIONING_CONFIG(ID) ON DELETE CASCADE +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDP_PROVISIONING_ENTITY ( + ID INTEGER AUTO_INCREMENT, + PROVISIONING_CONFIG_ID INTEGER, + ENTITY_TYPE VARCHAR(255) NOT NULL, + ENTITY_LOCAL_USERSTORE VARCHAR(255) NOT NULL, + ENTITY_NAME VARCHAR(255) NOT NULL, + ENTITY_VALUE VARCHAR(255), + TENANT_ID INTEGER, + ENTITY_LOCAL_ID VARCHAR(255), + PRIMARY KEY (ID), + UNIQUE (ENTITY_TYPE, TENANT_ID, ENTITY_LOCAL_USERSTORE, ENTITY_NAME, PROVISIONING_CONFIG_ID), + UNIQUE (PROVISIONING_CONFIG_ID, ENTITY_TYPE, ENTITY_VALUE), + FOREIGN KEY (PROVISIONING_CONFIG_ID) REFERENCES IDP_PROVISIONING_CONFIG(ID) ON DELETE CASCADE +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDP_LOCAL_CLAIM ( + ID INTEGER AUTO_INCREMENT, + TENANT_ID INTEGER, + IDP_ID INTEGER, + CLAIM_URI VARCHAR(255) NOT NULL, + DEFAULT_VALUE VARCHAR(255), + IS_REQUESTED VARCHAR(128) DEFAULT '0', + PRIMARY KEY (ID), + UNIQUE (TENANT_ID, IDP_ID, CLAIM_URI), + FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDN_ASSOCIATED_ID ( + ID INTEGER AUTO_INCREMENT, + IDP_USER_ID VARCHAR(255) NOT NULL, + TENANT_ID INTEGER DEFAULT -1234, + IDP_ID INTEGER NOT NULL, + DOMAIN_NAME VARCHAR(255) NOT NULL, + USER_NAME VARCHAR(255) NOT NULL, + PRIMARY KEY (ID), + UNIQUE(IDP_USER_ID, TENANT_ID, IDP_ID), + FOREIGN KEY (IDP_ID) REFERENCES IDP(ID) ON DELETE CASCADE +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS IDN_USER_ACCOUNT_ASSOCIATION ( + ASSOCIATION_KEY VARCHAR(255) NOT NULL, + TENANT_ID INTEGER, + DOMAIN_NAME VARCHAR(255) NOT NULL, + USER_NAME VARCHAR(255) NOT NULL, + PRIMARY KEY (TENANT_ID, DOMAIN_NAME, USER_NAME) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS FIDO_DEVICE_STORE ( + TENANT_ID INTEGER, + DOMAIN_NAME VARCHAR(255) NOT NULL, + USER_NAME VARCHAR(45) NOT NULL, + TIME_REGISTERED TIMESTAMP, + KEY_HANDLE VARCHAR(200) NOT NULL, + DEVICE_DATA VARCHAR(2048) NOT NULL, + PRIMARY KEY (TENANT_ID, DOMAIN_NAME, USER_NAME, KEY_HANDLE) + )ENGINE NDB; + +CREATE TABLE IF NOT EXISTS WF_REQUEST ( + UUID VARCHAR (45), + CREATED_BY VARCHAR (255), + TENANT_ID INTEGER DEFAULT -1, + OPERATION_TYPE VARCHAR (50), + CREATED_AT TIMESTAMP, + UPDATED_AT TIMESTAMP, + STATUS VARCHAR (30), + REQUEST BLOB, + PRIMARY KEY (UUID) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS WF_BPS_PROFILE ( + PROFILE_NAME VARCHAR(45), + HOST_URL_MANAGER VARCHAR(255), + HOST_URL_WORKER VARCHAR(255), + USERNAME VARCHAR(45), + PASSWORD VARCHAR(255), + CALLBACK_HOST VARCHAR (45), + CALLBACK_USERNAME VARCHAR (45), + CALLBACK_PASSWORD VARCHAR (255), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (PROFILE_NAME, TENANT_ID) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS WF_WORKFLOW( + ID VARCHAR (45), + WF_NAME VARCHAR (45), + DESCRIPTION VARCHAR (255), + TEMPLATE_ID VARCHAR (45), + IMPL_ID VARCHAR (45), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (ID) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS WF_WORKFLOW_ASSOCIATION( + ID INTEGER NOT NULL AUTO_INCREMENT, + ASSOC_NAME VARCHAR (45), + EVENT_ID VARCHAR(45), + ASSOC_CONDITION VARCHAR (2000), + WORKFLOW_ID VARCHAR (45), + IS_ENABLED CHAR (1) DEFAULT '1', + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY(ID), + FOREIGN KEY (WORKFLOW_ID) REFERENCES WF_WORKFLOW(ID)ON DELETE CASCADE +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS WF_WORKFLOW_CONFIG_PARAM( + WORKFLOW_ID VARCHAR (45), + PARAM_NAME VARCHAR (45), + PARAM_VALUE VARCHAR (1000), + PARAM_QNAME VARCHAR (45), + PARAM_HOLDER VARCHAR (45), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (WORKFLOW_ID, PARAM_NAME, PARAM_QNAME, PARAM_HOLDER), + FOREIGN KEY (WORKFLOW_ID) REFERENCES WF_WORKFLOW(ID)ON DELETE CASCADE +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS WF_REQUEST_ENTITY_RELATIONSHIP( + REQUEST_ID VARCHAR (45), + ENTITY_NAME VARCHAR (255), + ENTITY_TYPE VARCHAR (50), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY(REQUEST_ID, ENTITY_NAME, ENTITY_TYPE, TENANT_ID), + FOREIGN KEY (REQUEST_ID) REFERENCES WF_REQUEST(UUID)ON DELETE CASCADE +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS WF_WORKFLOW_REQUEST_RELATION( + RELATIONSHIP_ID VARCHAR (45), + WORKFLOW_ID VARCHAR (45), + REQUEST_ID VARCHAR (45), + UPDATED_AT TIMESTAMP, + STATUS VARCHAR (30), + TENANT_ID INTEGER DEFAULT -1, + PRIMARY KEY (RELATIONSHIP_ID), + FOREIGN KEY (WORKFLOW_ID) REFERENCES WF_WORKFLOW(ID)ON DELETE CASCADE, + FOREIGN KEY (REQUEST_ID) REFERENCES WF_REQUEST(UUID)ON DELETE CASCADE +)ENGINE NDB; + +-- End of IDN Tables-- + +-- Start of API-MGT Tables -- +CREATE TABLE IF NOT EXISTS AM_SUBSCRIBER ( + SUBSCRIBER_ID INTEGER AUTO_INCREMENT, + USER_ID VARCHAR(255) NOT NULL, + TENANT_ID INTEGER NOT NULL, + EMAIL_ADDRESS VARCHAR(256) NULL, + DATE_SUBSCRIBED TIMESTAMP NOT NULL, + PRIMARY KEY (SUBSCRIBER_ID), + CREATED_BY VARCHAR(100), + CREATED_TIME TIMESTAMP, + UPDATED_BY VARCHAR(100), + UPDATED_TIME TIMESTAMP, + UNIQUE (TENANT_ID,USER_ID) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS AM_APPLICATION ( + APPLICATION_ID INTEGER AUTO_INCREMENT, + NAME VARCHAR(100), + SUBSCRIBER_ID INTEGER, + APPLICATION_TIER VARCHAR(50) DEFAULT 'Unlimited', + CALLBACK_URL VARCHAR(512), + DESCRIPTION VARCHAR(512), + APPLICATION_STATUS VARCHAR(50) DEFAULT 'APPROVED', + GROUP_ID VARCHAR(100), + CREATED_BY VARCHAR(100), + CREATED_TIME TIMESTAMP, + UPDATED_BY VARCHAR(100), + UPDATED_TIME TIMESTAMP, + UUID VARCHAR(254), + FOREIGN KEY(SUBSCRIBER_ID) REFERENCES AM_SUBSCRIBER(SUBSCRIBER_ID) ON UPDATE CASCADE ON DELETE RESTRICT, + PRIMARY KEY(APPLICATION_ID), + UNIQUE (NAME,SUBSCRIBER_ID), + UNIQUE (UUID) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS AM_API ( + API_ID INTEGER AUTO_INCREMENT, + API_PROVIDER VARCHAR(200), + API_NAME VARCHAR(200), + API_VERSION VARCHAR(30), + CONTEXT VARCHAR(256), + CONTEXT_TEMPLATE VARCHAR(256), + API_TIER VARCHAR(256), + CREATED_BY VARCHAR(100), + CREATED_TIME TIMESTAMP, + UPDATED_BY VARCHAR(100), + UPDATED_TIME TIMESTAMP, + PRIMARY KEY(API_ID), + UNIQUE (API_PROVIDER,API_NAME,API_VERSION) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS AM_API_URL_MAPPING ( + URL_MAPPING_ID INTEGER AUTO_INCREMENT, + API_ID INTEGER NOT NULL, + HTTP_METHOD VARCHAR(20) NULL, + AUTH_SCHEME VARCHAR(50) NULL, + URL_PATTERN VARCHAR(512) NULL, + THROTTLING_TIER varchar(512) DEFAULT NULL, + MEDIATION_SCRIPT BLOB, + PRIMARY KEY (URL_MAPPING_ID) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS AM_SUBSCRIPTION ( + SUBSCRIPTION_ID INTEGER AUTO_INCREMENT, + TIER_ID VARCHAR(50), + API_ID INTEGER, + LAST_ACCESSED TIMESTAMP NULL, + APPLICATION_ID INTEGER, + SUB_STATUS VARCHAR(50), + SUBS_CREATE_STATE VARCHAR(50) DEFAULT 'SUBSCRIBE', + CREATED_BY VARCHAR(100), + CREATED_TIME TIMESTAMP, + UPDATED_BY VARCHAR(100), + UPDATED_TIME TIMESTAMP, + UUID VARCHAR(254), + FOREIGN KEY(APPLICATION_ID) REFERENCES AM_APPLICATION(APPLICATION_ID) ON UPDATE CASCADE ON DELETE RESTRICT, + FOREIGN KEY(API_ID) REFERENCES AM_API(API_ID) ON UPDATE CASCADE ON DELETE RESTRICT, + PRIMARY KEY (SUBSCRIPTION_ID), + UNIQUE (UUID) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS AM_SUBSCRIPTION_KEY_MAPPING ( + SUBSCRIPTION_ID INTEGER, + ACCESS_TOKEN VARCHAR(255), + KEY_TYPE VARCHAR(255) NOT NULL, + FOREIGN KEY(SUBSCRIPTION_ID) REFERENCES AM_SUBSCRIPTION(SUBSCRIPTION_ID) ON UPDATE CASCADE ON DELETE RESTRICT, + PRIMARY KEY(SUBSCRIPTION_ID,ACCESS_TOKEN) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS AM_APPLICATION_KEY_MAPPING ( + APPLICATION_ID INTEGER, + CONSUMER_KEY VARCHAR(255), + KEY_TYPE VARCHAR(255) NOT NULL, + STATE VARCHAR(30) NOT NULL, + CREATE_MODE VARCHAR(30) DEFAULT 'CREATED', + FOREIGN KEY(APPLICATION_ID) REFERENCES AM_APPLICATION(APPLICATION_ID) ON UPDATE CASCADE ON DELETE RESTRICT, + PRIMARY KEY(APPLICATION_ID,KEY_TYPE) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS AM_API_LC_EVENT ( + EVENT_ID INTEGER AUTO_INCREMENT, + API_ID INTEGER NOT NULL, + PREVIOUS_STATE VARCHAR(50), + NEW_STATE VARCHAR(50) NOT NULL, + USER_ID VARCHAR(255) NOT NULL, + TENANT_ID INTEGER NOT NULL, + EVENT_DATE TIMESTAMP NOT NULL, + FOREIGN KEY(API_ID) REFERENCES AM_API(API_ID) ON UPDATE CASCADE ON DELETE RESTRICT, + PRIMARY KEY (EVENT_ID) +)ENGINE NDB; + +CREATE TABLE AM_APP_KEY_DOMAIN_MAPPING ( + CONSUMER_KEY VARCHAR(255), + AUTHZ_DOMAIN VARCHAR(255) DEFAULT 'ALL', + PRIMARY KEY (CONSUMER_KEY,AUTHZ_DOMAIN) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS AM_API_COMMENTS ( + COMMENT_ID INTEGER AUTO_INCREMENT, + COMMENT_TEXT VARCHAR(512), + COMMENTED_USER VARCHAR(255), + DATE_COMMENTED TIMESTAMP NOT NULL, + API_ID INTEGER NOT NULL, + FOREIGN KEY(API_ID) REFERENCES AM_API(API_ID) ON UPDATE CASCADE ON DELETE RESTRICT, + PRIMARY KEY (COMMENT_ID) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS AM_API_RATINGS ( + RATING_ID INTEGER AUTO_INCREMENT, + API_ID INTEGER, + RATING INTEGER, + SUBSCRIBER_ID INTEGER, + FOREIGN KEY(API_ID) REFERENCES AM_API(API_ID) ON UPDATE CASCADE ON DELETE RESTRICT, + FOREIGN KEY(SUBSCRIBER_ID) REFERENCES AM_SUBSCRIBER(SUBSCRIBER_ID) ON UPDATE CASCADE ON DELETE RESTRICT, +PRIMARY KEY (RATING_ID) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS AM_TIER_PERMISSIONS ( + TIER_PERMISSIONS_ID INTEGER AUTO_INCREMENT, + TIER VARCHAR(50) NOT NULL, + PERMISSIONS_TYPE VARCHAR(50) NOT NULL, + ROLES VARCHAR(512) NOT NULL, + TENANT_ID INTEGER NOT NULL, + PRIMARY KEY(TIER_PERMISSIONS_ID) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS AM_EXTERNAL_STORES ( + APISTORE_ID INTEGER AUTO_INCREMENT, + API_ID INTEGER, + STORE_ID VARCHAR(255) NOT NULL, + STORE_DISPLAY_NAME VARCHAR(255) NOT NULL, + STORE_ENDPOINT VARCHAR(255) NOT NULL, + STORE_TYPE VARCHAR(255) NOT NULL, +FOREIGN KEY(API_ID) REFERENCES AM_API(API_ID) ON UPDATE CASCADE ON DELETE RESTRICT, +PRIMARY KEY (APISTORE_ID) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS AM_WORKFLOWS( + WF_ID INTEGER AUTO_INCREMENT, + WF_REFERENCE VARCHAR(255) NOT NULL, + WF_TYPE VARCHAR(255) NOT NULL, + WF_STATUS VARCHAR(255) NOT NULL, + WF_CREATED_TIME TIMESTAMP DEFAULT 0, + WF_UPDATED_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP , + WF_STATUS_DESC VARCHAR(1000), + TENANT_ID INTEGER, + TENANT_DOMAIN VARCHAR(255), + WF_EXTERNAL_REFERENCE VARCHAR(255) NOT NULL, + PRIMARY KEY (WF_ID), + UNIQUE (WF_EXTERNAL_REFERENCE) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS AM_APPLICATION_REGISTRATION ( + REG_ID INT AUTO_INCREMENT, + SUBSCRIBER_ID INT, + WF_REF VARCHAR(255) NOT NULL, + APP_ID INT, + TOKEN_TYPE VARCHAR(30), + TOKEN_SCOPE VARCHAR(256) DEFAULT 'default', + INPUTS VARCHAR(1000), + ALLOWED_DOMAINS VARCHAR(256), + VALIDITY_PERIOD BIGINT, + UNIQUE (SUBSCRIBER_ID,APP_ID,TOKEN_TYPE), + FOREIGN KEY(SUBSCRIBER_ID) REFERENCES AM_SUBSCRIBER(SUBSCRIBER_ID) ON UPDATE CASCADE ON DELETE RESTRICT, + FOREIGN KEY(APP_ID) REFERENCES AM_APPLICATION(APPLICATION_ID) ON UPDATE CASCADE ON DELETE RESTRICT, + PRIMARY KEY (REG_ID) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS AM_API_SCOPES ( + API_ID INTEGER NOT NULL, + SCOPE_ID INTEGER NOT NULL, + FOREIGN KEY (API_ID) REFERENCES AM_API (API_ID) ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (SCOPE_ID) REFERENCES IDN_OAUTH2_SCOPE (SCOPE_ID) ON DELETE CASCADE ON UPDATE CASCADE +)ENGINE = NDB; + +CREATE TABLE IF NOT EXISTS AM_API_DEFAULT_VERSION ( + DEFAULT_VERSION_ID INT AUTO_INCREMENT, + API_NAME VARCHAR(256) NOT NULL , + API_PROVIDER VARCHAR(256) NOT NULL , + DEFAULT_API_VERSION VARCHAR(30) , + PUBLISHED_DEFAULT_API_VERSION VARCHAR(30) , + PRIMARY KEY (DEFAULT_VERSION_ID) +); + +CREATE INDEX IDX_SUB_APP_ID ON AM_SUBSCRIPTION (APPLICATION_ID, SUBSCRIPTION_ID); + + + +CREATE TABLE IF NOT EXISTS AM_ALERT_TYPES ( + ALERT_TYPE_ID INTEGER AUTO_INCREMENT, + ALERT_TYPE_NAME VARCHAR(255) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL, + PRIMARY KEY (ALERT_TYPE_ID) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS AM_ALERT_TYPES_VALUES ( + ALERT_TYPE_ID INTEGER, + USER_NAME VARCHAR(255) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL , + CONSTRAINT AM_ALERT_TYPES_VALUES_CONSTRAINT UNIQUE (ALERT_TYPE_ID,USER_NAME,STAKE_HOLDER) +)ENGINE NDB; + +CREATE TABLE IF NOT EXISTS AM_ALERT_EMAILLIST ( + EMAIL_LIST_ID INTEGER AUTO_INCREMENT, + USER_NAME VARCHAR(255) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL , + PRIMARY KEY (EMAIL_LIST_ID), + CONSTRAINT AM_ALERT_EMAILLIST_CONSTRAINT UNIQUE (EMAIL_LIST_ID,USER_NAME,STAKE_HOLDER) +)ENGINE = NDB; + +CREATE TABLE IF NOT EXISTS AM_ALERT_EMAILLIST_DETAILS ( + EMAIL_LIST_ID INTEGER, + EMAIL VARCHAR(255), + CONSTRAINT AM_ALERT_EMAILLIST_DETAILS_CONSTRAINT UNIQUE (EMAIL_LIST_ID,EMAIL) +)ENGINE = NDB; + +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalResponseTime', 'publisher'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalBackendTime', 'publisher'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalRequestsPerMin', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('RequestPatternChanged', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('UnusualIPAccessAlert', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('AbnormalRefreshAlert', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('FrequentTierHittingAlert', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('AbnormalTierUsage', 'publisher'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('healthAvailabilityPerMin', 'publisher'); + + + +-- AM Throttling tables -- + +CREATE TABLE IF NOT EXISTS AM_POLICY_SUBSCRIPTION ( + POLICY_ID INT(11) NOT NULL AUTO_INCREMENT, + NAME VARCHAR(255) NOT NULL, + DISPLAY_NAME VARCHAR(512) NULL DEFAULT NULL, + TENANT_ID INT(11) NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + QUOTA_TYPE VARCHAR(25) NOT NULL, + QUOTA INT(11) NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL, + UNIT_TIME INT(11) NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + RATE_LIMIT_COUNT INT(11) NULL DEFAULT NULL, + RATE_LIMIT_TIME_UNIT VARCHAR(25) NULL DEFAULT NULL, + IS_DEPLOYED TINYINT(1) NOT NULL DEFAULT 0, + CUSTOM_ATTRIBUTES BLOB DEFAULT NULL, + STOP_ON_QUOTA_REACH BOOLEAN NOT NULL DEFAULT 0, + BILLING_PLAN VARCHAR(20) NOT NULL, + UUID VARCHAR(254), + PRIMARY KEY (POLICY_ID), + UNIQUE INDEX AM_POLICY_SUBSCRIPTION_NAME_TENANT (NAME, TENANT_ID), + UNIQUE (UUID) +)ENGINE = NDB; + +CREATE TABLE IF NOT EXISTS AM_POLICY_APPLICATION ( + POLICY_ID INT(11) NOT NULL AUTO_INCREMENT, + NAME VARCHAR(255) NOT NULL, + DISPLAY_NAME VARCHAR(512) NULL DEFAULT NULL, + TENANT_ID INT(11) NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + QUOTA_TYPE VARCHAR(25) NOT NULL, + QUOTA INT(11) NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL DEFAULT NULL, + UNIT_TIME INT(11) NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + IS_DEPLOYED TINYINT(1) NOT NULL DEFAULT 0, + CUSTOM_ATTRIBUTES BLOB DEFAULT NULL, + UUID VARCHAR(254), + PRIMARY KEY (POLICY_ID), + UNIQUE INDEX APP_NAME_TENANT (NAME, TENANT_ID), + UNIQUE (UUID) +)ENGINE = NDB; + +CREATE TABLE IF NOT EXISTS AM_POLICY_HARD_THROTTLING ( + POLICY_ID INT(11) NOT NULL AUTO_INCREMENT, + NAME VARCHAR(255) NOT NULL, + TENANT_ID INT(11) NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + QUOTA_TYPE VARCHAR(25) NOT NULL, + QUOTA INT(11) NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL DEFAULT NULL, + UNIT_TIME INT(11) NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + IS_DEPLOYED TINYINT(1) NOT NULL DEFAULT 0, + PRIMARY KEY (POLICY_ID), + UNIQUE INDEX POLICY_HARD_NAME_TENANT (NAME, TENANT_ID) +)ENGINE = NDB; + + +CREATE TABLE IF NOT EXISTS AM_API_THROTTLE_POLICY ( + POLICY_ID INT(11) NOT NULL AUTO_INCREMENT, + NAME VARCHAR(255) NOT NULL, + DISPLAY_NAME VARCHAR(512) NULL DEFAULT NULL, + TENANT_ID INT(11) NOT NULL, + DESCRIPTION VARCHAR (1024), + DEFAULT_QUOTA_TYPE VARCHAR(25) NOT NULL, + DEFAULT_QUOTA INTEGER NOT NULL, + DEFAULT_QUOTA_UNIT VARCHAR(10) NULL, + DEFAULT_UNIT_TIME INTEGER NOT NULL, + DEFAULT_TIME_UNIT VARCHAR(25) NOT NULL, + APPLICABLE_LEVEL VARCHAR(25) NOT NULL, + IS_DEPLOYED TINYINT(1) NOT NULL DEFAULT 0, + UUID VARCHAR(254), + PRIMARY KEY (POLICY_ID), + UNIQUE INDEX API_NAME_TENANT (NAME, TENANT_ID), + UNIQUE (UUID) +)ENGINE = NDB; + +CREATE TABLE IF NOT EXISTS AM_CONDITION_GROUP ( + CONDITION_GROUP_ID INTEGER NOT NULL AUTO_INCREMENT, + POLICY_ID INTEGER NOT NULL, + QUOTA_TYPE VARCHAR(25), + QUOTA INTEGER NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL DEFAULT NULL, + UNIT_TIME INTEGER NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + DESCRIPTION VARCHAR (1024) NULL DEFAULT NULL, + PRIMARY KEY (CONDITION_GROUP_ID), + FOREIGN KEY (POLICY_ID) REFERENCES AM_API_THROTTLE_POLICY(POLICY_ID) ON DELETE CASCADE ON UPDATE CASCADE +)ENGINE = NDB; + +CREATE TABLE IF NOT EXISTS AM_QUERY_PARAMETER_CONDITION ( + QUERY_PARAMETER_ID INTEGER NOT NULL AUTO_INCREMENT, + CONDITION_GROUP_ID INTEGER NOT NULL, + PARAMETER_NAME VARCHAR(255) DEFAULT NULL, + PARAMETER_VALUE VARCHAR(255) DEFAULT NULL, + IS_PARAM_MAPPING BOOLEAN DEFAULT 1, + PRIMARY KEY (QUERY_PARAMETER_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE +)ENGINE = NDB; + +CREATE TABLE IF NOT EXISTS AM_HEADER_FIELD_CONDITION ( + HEADER_FIELD_ID INTEGER NOT NULL AUTO_INCREMENT, + CONDITION_GROUP_ID INTEGER NOT NULL, + HEADER_FIELD_NAME VARCHAR(255) DEFAULT NULL, + HEADER_FIELD_VALUE VARCHAR(255) DEFAULT NULL, + IS_HEADER_FIELD_MAPPING BOOLEAN DEFAULT 1, + PRIMARY KEY (HEADER_FIELD_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE +)ENGINE = NDB; + +CREATE TABLE IF NOT EXISTS AM_JWT_CLAIM_CONDITION ( + JWT_CLAIM_ID INTEGER NOT NULL AUTO_INCREMENT, + CONDITION_GROUP_ID INTEGER NOT NULL, + CLAIM_URI VARCHAR(512) DEFAULT NULL, + CLAIM_ATTRIB VARCHAR(1024) DEFAULT NULL, + IS_CLAIM_MAPPING BOOLEAN DEFAULT 1, + PRIMARY KEY (JWT_CLAIM_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE +)ENGINE = NDB; + +CREATE TABLE IF NOT EXISTS AM_IP_CONDITION ( + AM_IP_CONDITION_ID INT NOT NULL AUTO_INCREMENT, + STARTING_IP VARCHAR(45) NULL, + ENDING_IP VARCHAR(45) NULL, + SPECIFIC_IP VARCHAR(45) NULL, + WITHIN_IP_RANGE BOOLEAN DEFAULT 1, + CONDITION_GROUP_ID INT NULL, + PRIMARY KEY (AM_IP_CONDITION_ID), + INDEX fk_AM_IP_CONDITION_1_idx (CONDITION_GROUP_ID ASC), CONSTRAINT fk_AM_IP_CONDITION_1 FOREIGN KEY (CONDITION_GROUP_ID) + REFERENCES AM_CONDITION_GROUP (CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE) +ENGINE = NDB; + + +CREATE TABLE IF NOT EXISTS AM_POLICY_GLOBAL ( + POLICY_ID INT(11) NOT NULL AUTO_INCREMENT, + NAME VARCHAR(255) NOT NULL, + KEY_TEMPLATE VARCHAR(512) NOT NULL, + TENANT_ID INT(11) NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + SIDDHI_QUERY BLOB DEFAULT NULL, + IS_DEPLOYED TINYINT(1) NOT NULL DEFAULT 0, + UUID VARCHAR(254), + PRIMARY KEY (POLICY_ID), + UNIQUE (UUID) +)ENGINE = NDB; + +CREATE TABLE IF NOT EXISTS AM_THROTTLE_TIER_PERMISSIONS ( + THROTTLE_TIER_PERMISSIONS_ID INT NOT NULL AUTO_INCREMENT, + TIER VARCHAR(50) NULL, + PERMISSIONS_TYPE VARCHAR(50) NULL, + ROLES VARCHAR(512) NULL, + TENANT_ID INT(11) NULL, + PRIMARY KEY (THROTTLE_TIER_PERMISSIONS_ID)) +ENGINE = NDB; + +CREATE TABLE `AM_BLOCK_CONDITIONS` ( + `CONDITION_ID` int(11) NOT NULL AUTO_INCREMENT, + `TYPE` varchar(45) DEFAULT NULL, + `VALUE` varchar(45) DEFAULT NULL, + `ENABLED` varchar(45) DEFAULT NULL, + `DOMAIN` varchar(45) DEFAULT NULL, + `UUID` VARCHAR(254), + PRIMARY KEY (`CONDITION_ID`), + UNIQUE (`UUID`) +) ENGINE = NDB; + +-- End of API-MGT Tables -- + +-- Performance indexes start-- + +create index IDX_ITS_LMT on IDN_THRIFT_SESSION (LAST_MODIFIED_TIME); +create index IDX_IOAT_AT on IDN_OAUTH2_ACCESS_TOKEN (ACCESS_TOKEN); +create index IDX_IOAT_UT on IDN_OAUTH2_ACCESS_TOKEN (USER_TYPE); +create index IDX_AAI_CTX on AM_API (CONTEXT); +create index IDX_AAKM_CK on AM_APPLICATION_KEY_MAPPING (CONSUMER_KEY); +create index IDX_AAUM_AI on AM_API_URL_MAPPING (API_ID); +create index IDX_AAUM_TT on AM_API_URL_MAPPING (THROTTLING_TIER); +create index IDX_AATP_DQT on AM_API_THROTTLE_POLICY (DEFAULT_QUOTA_TYPE); +create index IDX_ACG_QT on AM_CONDITION_GROUP (QUOTA_TYPE); +create index IDX_APS_QT on AM_POLICY_SUBSCRIPTION (QUOTA_TYPE); +create index IDX_AS_AITIAI on AM_SUBSCRIPTION (API_ID,TIER_ID,APPLICATION_ID); +create index IDX_APA_QT on AM_POLICY_APPLICATION (QUOTA_TYPE); +create index IDX_AA_AT_CB on AM_APPLICATION (APPLICATION_TIER,CREATED_BY); + +-- Performance indexes end-- diff --git a/modules/distribution/src/repository/resources/dbscripts/apimgt/oracle.sql b/modules/distribution/src/repository/resources/dbscripts/apimgt/oracle.sql index 10137dd9..40b8f1fe 100644 --- a/modules/distribution/src/repository/resources/dbscripts/apimgt/oracle.sql +++ b/modules/distribution/src/repository/resources/dbscripts/apimgt/oracle.sql @@ -24,6 +24,8 @@ CREATE TABLE IDN_OAUTH_CONSUMER_APPS ( OAUTH_VERSION VARCHAR2 (128), CALLBACK_URL VARCHAR2 (1024), GRANT_TYPES VARCHAR (1024), + PKCE_MANDATORY CHAR(1) DEFAULT '0', + PKCE_SUPPORT_PLAIN CHAR(1) DEFAULT '0', CONSTRAINT CONSUMER_KEY_CONSTRAINT UNIQUE (CONSUMER_KEY), PRIMARY KEY (ID)) / @@ -102,6 +104,8 @@ CREATE TABLE IDN_OAUTH2_AUTHORIZATION_CODE ( STATE VARCHAR (25) DEFAULT 'ACTIVE', TOKEN_ID VARCHAR(255), SUBJECT_IDENTIFIER VARCHAR(255), + PKCE_CODE_CHALLENGE VARCHAR (255), + PKCE_CODE_CHALLENGE_METHOD VARCHAR(128), PRIMARY KEY (CODE_ID), FOREIGN KEY (CONSUMER_KEY_ID) REFERENCES IDN_OAUTH_CONSUMER_APPS(ID) ON DELETE CASCADE) / @@ -341,7 +345,7 @@ CREATE OR REPLACE TRIGGER SP_AUTH_STEP_TRIG SELECT SP_AUTH_STEP_SEQ.nextval INTO :NEW.ID FROM dual; END; / -ALTER TABLE SP_AUTH_STEP ADD CONSTRAINT APPLICATION_ID_CONSTRAINT_STEP FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE +ALTER TABLE SP_AUTH_STEP ADD CONSTRAINT APPLICATION_ID_CONST_STEP FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE / CREATE TABLE SP_FEDERATED_IDP ( ID INTEGER NOT NULL, @@ -436,7 +440,7 @@ CREATE OR REPLACE TRIGGER SP_PROV_CONNECTOR_TRIG SELECT SP_PROV_CONNECTOR_SEQ.nextval INTO :NEW.ID FROM dual; END; / -ALTER TABLE SP_PROVISIONING_CONNECTOR ADD CONSTRAINT PRO_CONNECTOR_APPID_CONSTRAINT FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE +ALTER TABLE SP_PROVISIONING_CONNECTOR ADD CONSTRAINT PRO_CONNECTOR_APPID_CONST FOREIGN KEY (APP_ID) REFERENCES SP_APP (ID) ON DELETE CASCADE / CREATE TABLE IDP ( ID INTEGER, @@ -788,8 +792,8 @@ CREATE TABLE WF_REQUEST ( CREATE TABLE WF_BPS_PROFILE ( PROFILE_NAME VARCHAR2(45), - HOST_URL_MANAGER VARCHAR2(45), - HOST_URL_WORKER VARCHAR2(45), + HOST_URL_MANAGER VARCHAR2(255), + HOST_URL_WORKER VARCHAR2(255), USERNAME VARCHAR2(45), PASSWORD VARCHAR2(255), CALLBACK_HOST VARCHAR2 (45), @@ -867,7 +871,7 @@ CREATE TABLE WF_WORKFLOW_REQUEST_RELATION( -- End of IDENTITY Tables-- -- Start of API-MGT Tables-- -CREATE TABLE AM_SUBSCRIBER ( +CREATE TABLE AM_SUBSCRIBER ( SUBSCRIBER_ID INTEGER, USER_ID VARCHAR2(50) NOT NULL, TENANT_ID INTEGER NOT NULL, @@ -936,6 +940,7 @@ CREATE TABLE AM_API ( API_VERSION VARCHAR2(30), CONTEXT VARCHAR2(256), CONTEXT_TEMPLATE VARCHAR2(256), + API_TIER VARCHAR(256), CREATED_BY VARCHAR2(100), CREATED_TIME DATE, UPDATED_BY VARCHAR2(100), @@ -1071,7 +1076,6 @@ CREATE TABLE AM_APP_KEY_DOMAIN_MAPPING ( CONSUMER_KEY VARCHAR(255), AUTHZ_DOMAIN VARCHAR(255) DEFAULT 'ALL', PRIMARY KEY (CONSUMER_KEY,AUTHZ_DOMAIN) - ) / @@ -1258,3 +1262,386 @@ CREATE OR REPLACE TRIGGER AM_API_DEFAULT_VERSION_TRG / CREATE INDEX IDX_SUB_APP_ID ON AM_SUBSCRIPTION (APPLICATION_ID, SUBSCRIPTION_ID) / + + +CREATE TABLE AM_ALERT_TYPES ( + ALERT_TYPE_ID INTEGER, + ALERT_TYPE_NAME VARCHAR(255) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL, + PRIMARY KEY (ALERT_TYPE_ID)) +/ + +CREATE SEQUENCE AM_ALERT_TYPES_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ + +CREATE OR REPLACE TRIGGER AM_ALERT_TYPES_TRIG + BEFORE INSERT + ON AM_ALERT_TYPES + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT AM_ALERT_TYPES_SEQ.nextval INTO :NEW.ALERT_TYPE_ID FROM dual; + END; +/ + + +CREATE TABLE AM_ALERT_TYPES_VALUES ( + ALERT_TYPE_ID INTEGER, + USER_NAME VARCHAR(255) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL , + CONSTRAINT AM_ALERT_TYPES_VALUES_CONST UNIQUE (ALERT_TYPE_ID,USER_NAME,STAKE_HOLDER)) +/ + +CREATE TABLE AM_ALERT_EMAILLIST ( + EMAIL_LIST_ID INTEGER, + USER_NAME VARCHAR(255) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL , + CONSTRAINT AM_ALERT_EMAILLIST_CONST UNIQUE (EMAIL_LIST_ID,USER_NAME,STAKE_HOLDER), + PRIMARY KEY (EMAIL_LIST_ID)) +/ + +CREATE SEQUENCE AM_ALERT_EMAILLIST_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ + +CREATE OR REPLACE TRIGGER AM_ALERT_EMAILLIST_TRIG + BEFORE INSERT + ON AM_ALERT_EMAILLIST + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT AM_ALERT_EMAILLIST_SEQ.nextval INTO :NEW.EMAIL_LIST_ID FROM dual; + END; +/ + +CREATE TABLE AM_ALERT_EMAILLIST_DETAILS ( + EMAIL_LIST_ID INTEGER, + EMAIL VARCHAR(255), + CONSTRAINT AM_ALERT_EMAIL_LIST_DET_CONST UNIQUE (EMAIL_LIST_ID,EMAIL)) +/ + +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalResponseTime', 'publisher') +/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalBackendTime', 'publisher') +/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalRequestsPerMin', 'subscriber') +/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('RequestPatternChanged', 'subscriber') +/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('UnusualIPAccessAlert', 'subscriber') +/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('AbnormalRefreshAlert', 'subscriber') +/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('FrequentTierHittingAlert', 'subscriber') +/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('AbnormalTierUsage', 'publisher') +/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('healthAvailabilityPerMin', 'publisher') +/ + +-- AM Throttling tables -- + +CREATE TABLE AM_POLICY_SUBSCRIPTION ( + POLICY_ID INTEGER NOT NULL, + NAME VARCHAR2(512) NOT NULL, + DISPLAY_NAME VARCHAR2(512) DEFAULT NULL NULL, + TENANT_ID INTEGER NOT NULL, + DESCRIPTION VARCHAR2(1024) DEFAULT NULL NULL, + QUOTA_TYPE VARCHAR2(25) NOT NULL, + QUOTA INTEGER NOT NULL, + QUOTA_UNIT VARCHAR2(10) NULL, + UNIT_TIME INTEGER NOT NULL, + TIME_UNIT VARCHAR2(25) NOT NULL, + RATE_LIMIT_COUNT INTEGER DEFAULT NULL NULL, + RATE_LIMIT_TIME_UNIT VARCHAR2(25) DEFAULT NULL NULL, + IS_DEPLOYED INTEGER DEFAULT 0 NOT NULL, + CUSTOM_ATTRIBUTES BLOB DEFAULT NULL, + STOP_ON_QUOTA_REACH INTEGER DEFAULT 0 NOT NULL, + BILLING_PLAN VARCHAR2(20), + UUID VARCHAR2(256), + PRIMARY KEY (POLICY_ID), + CONSTRAINT SUBSCRIPTION_NAME_TENANT UNIQUE (NAME, TENANT_ID), + UNIQUE (UUID) +) +/ +-- Generate ID using sequence and trigger +CREATE SEQUENCE AM_POLICY_SUBSCRIPTION_seq START WITH 1 INCREMENT BY 1 +/ +CREATE OR REPLACE TRIGGER AM_POLICY_SUBSCRIPTION_seq_tr + BEFORE INSERT ON AM_POLICY_SUBSCRIPTION FOR EACH ROW + WHEN (NEW.POLICY_ID IS NULL) +BEGIN + SELECT AM_POLICY_SUBSCRIPTION_seq.NEXTVAL INTO :NEW.POLICY_ID FROM DUAL; +END; +/ + +CREATE TABLE AM_POLICY_APPLICATION ( + POLICY_ID INTEGER NOT NULL, + NAME VARCHAR2(512) NOT NULL, + DISPLAY_NAME VARCHAR2(512) DEFAULT NULL NULL, + TENANT_ID INTEGER NOT NULL, + DESCRIPTION VARCHAR2(1024) DEFAULT NULL NULL, + QUOTA_TYPE VARCHAR2(25) NOT NULL, + QUOTA INTEGER NOT NULL, + QUOTA_UNIT VARCHAR2(10) DEFAULT NULL NULL, + UNIT_TIME INTEGER NOT NULL, + TIME_UNIT VARCHAR2(25) NOT NULL, + IS_DEPLOYED INTEGER DEFAULT 0 NOT NULL, + CUSTOM_ATTRIBUTES BLOB DEFAULT NULL, + UUID VARCHAR2(256), + PRIMARY KEY (POLICY_ID), + CONSTRAINT AM_POLICY_APP_NAME_TENANT UNIQUE (NAME, TENANT_ID), + UNIQUE (UUID) +) +/ +-- Generate ID using sequence and trigger +CREATE SEQUENCE AM_POLICY_APPLICATION_seq START WITH 1 INCREMENT BY 1 +/ +CREATE OR REPLACE TRIGGER AM_POLICY_APPLICATION_seq_tr + BEFORE INSERT ON AM_POLICY_APPLICATION FOR EACH ROW + WHEN (NEW.POLICY_ID IS NULL) +BEGIN + SELECT AM_POLICY_APPLICATION_seq.NEXTVAL INTO :NEW.POLICY_ID FROM DUAL; +END; +/ + +CREATE TABLE AM_API_THROTTLE_POLICY ( + POLICY_ID INTEGER NOT NULL, + NAME VARCHAR2(512) NOT NULL, + DISPLAY_NAME VARCHAR2(512) DEFAULT NULL NULL, + TENANT_ID INTEGER NOT NULL, + DESCRIPTION VARCHAR2 (1024), + DEFAULT_QUOTA_TYPE VARCHAR2(25) NOT NULL, + DEFAULT_QUOTA INTEGER NOT NULL, + DEFAULT_QUOTA_UNIT VARCHAR2(10) NULL, + DEFAULT_UNIT_TIME INTEGER NOT NULL, + DEFAULT_TIME_UNIT VARCHAR2(25) NOT NULL, + APPLICABLE_LEVEL VARCHAR2(25) NOT NULL, + IS_DEPLOYED INTEGER DEFAULT 0 NOT NULL, + UUID VARCHAR2(256), + PRIMARY KEY (POLICY_ID), + CONSTRAINT API_POLICY_NAME_TENANT UNIQUE (NAME, TENANT_ID), + UNIQUE (UUID) +) +/ +-- Generate ID using sequence and trigger +CREATE SEQUENCE AM_API_THROTTLE_POLICY_seq START WITH 1 INCREMENT BY 1 +/ +CREATE OR REPLACE TRIGGER AM_API_THROTTLE_POLICY_seq_tr + BEFORE INSERT ON AM_API_THROTTLE_POLICY FOR EACH ROW + WHEN (NEW.POLICY_ID IS NULL) +BEGIN + SELECT AM_API_THROTTLE_POLICY_seq.NEXTVAL INTO :NEW.POLICY_ID FROM DUAL; +END; +/ + +CREATE TABLE AM_CONDITION_GROUP ( + CONDITION_GROUP_ID INTEGER NOT NULL, + POLICY_ID INTEGER NOT NULL, + QUOTA_TYPE VARCHAR2(25), + QUOTA INTEGER NOT NULL, + QUOTA_UNIT VARCHAR2(10) DEFAULT NULL NULL, + UNIT_TIME INTEGER NOT NULL, + TIME_UNIT VARCHAR2(25) NOT NULL, + DESCRIPTION VARCHAR2(1024) DEFAULT NULL NULL, + PRIMARY KEY (CONDITION_GROUP_ID), + FOREIGN KEY (POLICY_ID) REFERENCES AM_API_THROTTLE_POLICY(POLICY_ID) ON DELETE CASCADE +) +/ +-- Generate ID using sequence and trigger +CREATE SEQUENCE AM_CONDITION_GROUP_seq START WITH 1 INCREMENT BY 1 +/ +CREATE OR REPLACE TRIGGER AM_CONDITION_GROUP_seq_tr + BEFORE INSERT ON AM_CONDITION_GROUP FOR EACH ROW + WHEN (NEW.CONDITION_GROUP_ID IS NULL) +BEGIN + SELECT AM_CONDITION_GROUP_seq.NEXTVAL INTO :NEW.CONDITION_GROUP_ID FROM DUAL; +END; +/ + +CREATE TABLE AM_QUERY_PARAMETER_CONDITION ( + QUERY_PARAMETER_ID INTEGER NOT NULL, + CONDITION_GROUP_ID INTEGER NOT NULL, + PARAMETER_NAME VARCHAR2(255) DEFAULT NULL, + PARAMETER_VALUE VARCHAR2(255) DEFAULT NULL, + IS_PARAM_MAPPING CHAR(1) DEFAULT 1, + PRIMARY KEY (QUERY_PARAMETER_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE +) +/ +-- Generate ID using sequence and trigger +CREATE SEQUENCE QUERY_PARAMETER_CONDITION_seq START WITH 1 INCREMENT BY 1 +/ +CREATE OR REPLACE TRIGGER QUERY_PARAMETER_CONDITION_tr + BEFORE INSERT ON AM_QUERY_PARAMETER_CONDITION FOR EACH ROW + WHEN (NEW.QUERY_PARAMETER_ID IS NULL) +BEGIN + SELECT QUERY_PARAMETER_CONDITION_seq.NEXTVAL INTO :NEW.QUERY_PARAMETER_ID FROM DUAL; +END; +/ + +CREATE TABLE AM_HEADER_FIELD_CONDITION ( + HEADER_FIELD_ID INTEGER NOT NULL, + CONDITION_GROUP_ID INTEGER NOT NULL, + HEADER_FIELD_NAME VARCHAR2(255) DEFAULT NULL, + HEADER_FIELD_VALUE VARCHAR2(255) DEFAULT NULL, + IS_HEADER_FIELD_MAPPING CHAR(1) DEFAULT 1, + PRIMARY KEY (HEADER_FIELD_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE +) +/ +-- Generate ID using sequence and trigger +CREATE SEQUENCE AM_HEADER_FIELD_CONDITION_seq START WITH 1 INCREMENT BY 1 +/ +CREATE OR REPLACE TRIGGER AM_HEADER_FIELD_CONDITION_tr + BEFORE INSERT ON AM_HEADER_FIELD_CONDITION FOR EACH ROW + WHEN (NEW.HEADER_FIELD_ID IS NULL) +BEGIN + SELECT AM_HEADER_FIELD_CONDITION_seq.NEXTVAL INTO :NEW.HEADER_FIELD_ID FROM DUAL; +END; +/ + +CREATE TABLE AM_JWT_CLAIM_CONDITION ( + JWT_CLAIM_ID INTEGER NOT NULL, + CONDITION_GROUP_ID INTEGER NOT NULL, + CLAIM_URI VARCHAR2(512) DEFAULT NULL, + CLAIM_ATTRIB VARCHAR2(1024) DEFAULT NULL, + IS_CLAIM_MAPPING CHAR(1) DEFAULT 1, + PRIMARY KEY (JWT_CLAIM_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE +) +/ +-- Generate ID using sequence and trigger +CREATE SEQUENCE AM_JWT_CLAIM_CONDITION_seq START WITH 1 INCREMENT BY 1 +/ +CREATE OR REPLACE TRIGGER AM_JWT_CLAIM_CONDITION_seq_tr + BEFORE INSERT ON AM_JWT_CLAIM_CONDITION FOR EACH ROW + WHEN (NEW.JWT_CLAIM_ID IS NULL) +BEGIN + SELECT AM_JWT_CLAIM_CONDITION_seq.NEXTVAL INTO :NEW.JWT_CLAIM_ID FROM DUAL; +END; +/ + +CREATE TABLE AM_IP_CONDITION ( + AM_IP_CONDITION_ID INTEGER NOT NULL, + STARTING_IP VARCHAR2(45) NULL, + ENDING_IP VARCHAR2(45) NULL, + SPECIFIC_IP VARCHAR2(45) NULL, + WITHIN_IP_RANGE CHAR(1) DEFAULT 1, + CONDITION_GROUP_ID INTEGER NULL, + PRIMARY KEY (AM_IP_CONDITION_ID) + , CONSTRAINT fk_AM_IP_CONDITION_1 FOREIGN KEY (CONDITION_GROUP_ID) + REFERENCES AM_CONDITION_GROUP (CONDITION_GROUP_ID) ON DELETE CASCADE ) + +/ +-- Generate ID using sequence and trigger +CREATE SEQUENCE AM_IP_CONDITION_seq START WITH 1 INCREMENT BY 1 +/ +CREATE OR REPLACE TRIGGER AM_IP_CONDITION_seq_tr + BEFORE INSERT ON AM_IP_CONDITION FOR EACH ROW + WHEN (NEW.AM_IP_CONDITION_ID IS NULL) +BEGIN + SELECT AM_IP_CONDITION_seq.NEXTVAL INTO :NEW.AM_IP_CONDITION_ID FROM DUAL; +END; +/ + +CREATE INDEX fk_AM_IP_CONDITION_1_idx ON AM_IP_CONDITION (CONDITION_GROUP_ID ASC) +/ + +CREATE TABLE AM_POLICY_GLOBAL ( + POLICY_ID INTEGER NOT NULL, + NAME VARCHAR2(512) NOT NULL, + KEY_TEMPLATE VARCHAR2(512) NOT NULL, + TENANT_ID INTEGER NOT NULL, + DESCRIPTION VARCHAR2(1024) DEFAULT NULL NULL, + SIDDHI_QUERY BLOB DEFAULT NULL, + IS_DEPLOYED INTEGER DEFAULT 0 NOT NULL, + UUID VARCHAR2(256), + PRIMARY KEY (POLICY_ID), + UNIQUE (UUID) +) +/ +-- Generate ID using sequence and trigger +CREATE SEQUENCE AM_POLICY_GLOBAL_seq START WITH 1 INCREMENT BY 1 +/ +CREATE OR REPLACE TRIGGER AM_POLICY_GLOBAL_seq_tr + BEFORE INSERT ON AM_POLICY_GLOBAL FOR EACH ROW + WHEN (NEW.POLICY_ID IS NULL) +BEGIN + SELECT AM_POLICY_GLOBAL_seq.NEXTVAL INTO :NEW.POLICY_ID FROM DUAL; +END; +/ + +CREATE TABLE AM_THROTTLE_TIER_PERMISSIONS ( + THROTTLE_TIER_PERMISSIONS_ID INTEGER NOT NULL, + TIER VARCHAR2(50) NULL, + PERMISSIONS_TYPE VARCHAR2(50) NULL, + ROLES VARCHAR2(512) NULL, + TENANT_ID INTEGER NULL, + PRIMARY KEY (THROTTLE_TIER_PERMISSIONS_ID)) +/ + +-- Generate ID using sequence and trigger +CREATE SEQUENCE THROTTLE_TIER_PERMISSIONS_seq START WITH 1 INCREMENT BY 1 +/ +CREATE OR REPLACE TRIGGER THROTTLE_TIER_PERMISSIONS_tr + BEFORE INSERT ON AM_THROTTLE_TIER_PERMISSIONS FOR EACH ROW + WHEN (NEW.THROTTLE_TIER_PERMISSIONS_ID IS NULL) +BEGIN + SELECT THROTTLE_TIER_PERMISSIONS_seq.NEXTVAL INTO :NEW.THROTTLE_TIER_PERMISSIONS_ID FROM DUAL; +END; +/ + +CREATE TABLE AM_BLOCK_CONDITIONS ( + CONDITION_ID INTEGER NOT NULL, + TYPE varchar2(45) DEFAULT NULL, + VALUE varchar2(45) DEFAULT NULL, + ENABLED varchar2(45) DEFAULT NULL, + DOMAIN varchar2(45) DEFAULT NULL, + UUID VARCHAR2(256), + PRIMARY KEY (CONDITION_ID), + UNIQUE (UUID) +) +/ +-- Generate ID using sequence and trigger +CREATE SEQUENCE AM_BLOCK_CONDITIONS_seq START WITH 1 INCREMENT BY 1 +/ +CREATE OR REPLACE TRIGGER AM_BLOCK_CONDITIONS_seq_tr + BEFORE INSERT ON AM_BLOCK_CONDITIONS FOR EACH ROW + WHEN (NEW.CONDITION_ID IS NULL) +BEGIN + SELECT AM_BLOCK_CONDITIONS_seq.NEXTVAL INTO :NEW.CONDITION_ID FROM DUAL; +END; +/ + +-- End of API-MGT Tables -- + +--permance indexes start-- +/ +create index IDX_ITS_LMT on IDN_THRIFT_SESSION (LAST_MODIFIED_TIME) +/ +create index IDX_IOAT_AT on IDN_OAUTH2_ACCESS_TOKEN (ACCESS_TOKEN) +/ +create index IDX_IOAT_UT on IDN_OAUTH2_ACCESS_TOKEN (USER_TYPE) +/ +create index IDX_AAI_CTX on AM_API (CONTEXT) +/ +create index IDX_AAKM_CK on AM_APPLICATION_KEY_MAPPING (CONSUMER_KEY) +/ +create index IDX_AAUM_AI on AM_API_URL_MAPPING (API_ID) +/ +create index IDX_AAUM_TT on AM_API_URL_MAPPING (THROTTLING_TIER) +/ +create index IDX_AATP_DQT on AM_API_THROTTLE_POLICY (DEFAULT_QUOTA_TYPE) +/ +create index IDX_ACG_QT on AM_CONDITION_GROUP (QUOTA_TYPE) +/ +create index IDX_APS_QT on AM_POLICY_SUBSCRIPTION (QUOTA_TYPE) +/ +create index IDX_AS_AITIAI on AM_SUBSCRIPTION (API_ID,TIER_ID,APPLICATION_ID) +/ +create index IDX_APA_QT on AM_POLICY_APPLICATION (QUOTA_TYPE) +/ +create index IDX_AA_AT_CB on AM_APPLICATION (APPLICATION_TIER,CREATED_BY) +/ +-- Performance indexes end-- + diff --git a/modules/distribution/src/repository/resources/dbscripts/apimgt/oracle_rac.sql b/modules/distribution/src/repository/resources/dbscripts/apimgt/oracle_rac.sql index 00e07c87..3f0d9d64 100644 --- a/modules/distribution/src/repository/resources/dbscripts/apimgt/oracle_rac.sql +++ b/modules/distribution/src/repository/resources/dbscripts/apimgt/oracle_rac.sql @@ -23,6 +23,8 @@ CREATE TABLE IDN_OAUTH_CONSUMER_APPS ( OAUTH_VERSION VARCHAR2 (128), CALLBACK_URL VARCHAR2 (1024), GRANT_TYPES VARCHAR (1024), + PKCE_MANDATORY CHAR(1) DEFAULT '0', + PKCE_SUPPORT_PLAIN CHAR(1) DEFAULT '0', CONSTRAINT CONSUMER_KEY_CONSTRAINT UNIQUE (CONSUMER_KEY), PRIMARY KEY (ID)) / @@ -101,6 +103,8 @@ CREATE TABLE IDN_OAUTH2_AUTHORIZATION_CODE ( STATE VARCHAR (25) DEFAULT 'ACTIVE', TOKEN_ID VARCHAR(255), SUBJECT_IDENTIFIER VARCHAR(255), + PKCE_CODE_CHALLENGE VARCHAR (255), + PKCE_CODE_CHALLENGE_METHOD VARCHAR(128), PRIMARY KEY (CODE_ID), FOREIGN KEY (CONSUMER_KEY_ID) REFERENCES IDN_OAUTH_CONSUMER_APPS(ID) ON DELETE CASCADE) / @@ -471,6 +475,7 @@ CREATE OR REPLACE TRIGGER IDP_TRIG SELECT IDP_SEQ.nextval INTO :NEW.ID FROM dual; END; / + INSERT INTO IDP (TENANT_ID, NAME, HOME_REALM_ID) VALUES (-1234, 'LOCAL', 'localhost') / CREATE TABLE IDP_ROLE ( @@ -784,8 +789,8 @@ CREATE TABLE WF_REQUEST ( CREATE TABLE WF_BPS_PROFILE ( PROFILE_NAME VARCHAR2(45), - HOST_URL_MANAGER VARCHAR2(45), - HOST_URL_WORKER VARCHAR2(45), + HOST_URL_MANAGER VARCHAR2(255), + HOST_URL_WORKER VARCHAR2(255), USERNAME VARCHAR2(45), PASSWORD VARCHAR2(255), CALLBACK_HOST VARCHAR2 (45), @@ -933,6 +938,7 @@ CREATE TABLE AM_API ( API_VERSION VARCHAR2(30), CONTEXT VARCHAR2(256), CONTEXT_TEMPLATE VARCHAR2(256), + API_TIER VARCHAR(256), CREATED_BY VARCHAR2(100), CREATED_TIME DATE, UPDATED_BY VARCHAR2(100), @@ -1255,3 +1261,387 @@ CREATE OR REPLACE TRIGGER AM_API_DEFAULT_VERSION_TRG / CREATE INDEX IDX_SUB_APP_ID ON AM_SUBSCRIPTION (APPLICATION_ID, SUBSCRIPTION_ID) / + + +CREATE TABLE AM_ALERT_TYPES ( + ALERT_TYPE_ID INTEGER, + ALERT_TYPE_NAME VARCHAR(255) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL, + PRIMARY KEY (ALERT_TYPE_ID)) +/ + +CREATE SEQUENCE AM_ALERT_TYPES_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ + +CREATE OR REPLACE TRIGGER AM_ALERT_TYPES_TRIG + BEFORE INSERT + ON AM_ALERT_TYPES + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT AM_ALERT_TYPES_SEQ.nextval INTO :NEW.ALERT_TYPE_ID FROM dual; + END; +/ + + +CREATE TABLE AM_ALERT_TYPES_VALUES ( + ALERT_TYPE_ID INTEGER, + USER_NAME VARCHAR(255) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL , + CONSTRAINT AM_ALERT_TYPES_VALUES_CONST UNIQUE (ALERT_TYPE_ID,USER_NAME,STAKE_HOLDER)) +/ + +CREATE TABLE AM_ALERT_EMAILLIST ( + EMAIL_LIST_ID INTEGER, + USER_NAME VARCHAR(255) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL , + CONSTRAINT AM_ALERT_EMAILLIST_CONST UNIQUE (EMAIL_LIST_ID,USER_NAME,STAKE_HOLDER), + PRIMARY KEY (EMAIL_LIST_ID)) +/ + +CREATE SEQUENCE AM_ALERT_EMAILLIST_SEQ START WITH 1 INCREMENT BY 1 NOCACHE +/ + +CREATE OR REPLACE TRIGGER AM_ALERT_EMAILLIST_TRIG + BEFORE INSERT + ON AM_ALERT_EMAILLIST + REFERENCING NEW AS NEW + FOR EACH ROW + BEGIN + SELECT AM_ALERT_EMAILLIST_SEQ.nextval INTO :NEW.EMAIL_LIST_ID FROM dual; + END; +/ + +CREATE TABLE AM_ALERT_EMAILLIST_DETAILS ( + EMAIL_LIST_ID INTEGER, + EMAIL VARCHAR(255), + CONSTRAINT AM_ALERT_EMAIL_LIST_DET_CONST UNIQUE (EMAIL_LIST_ID,EMAIL)) +/ + + +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalResponseTime', 'publisher') +/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalBackendTime', 'publisher') +/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalRequestsPerMin', 'subscriber') +/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('RequestPatternChanged', 'subscriber') +/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('UnusualIPAccessAlert', 'subscriber') +/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('AbnormalRefreshAlert', 'subscriber') +/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('FrequentTierHittingAlert', 'subscriber') +/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('AbnormalTierUsage', 'publisher') +/ +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('healthAvailabilityPerMin', 'publisher') +/ + +-- AM Throttling tables -- + +CREATE TABLE AM_POLICY_SUBSCRIPTION ( + POLICY_ID INTEGER NOT NULL, + NAME VARCHAR2(512) NOT NULL, + DISPLAY_NAME VARCHAR2(512) DEFAULT NULL NULL, + TENANT_ID INTEGER NOT NULL, + DESCRIPTION VARCHAR2(1024) DEFAULT NULL NULL, + QUOTA_TYPE VARCHAR2(25) NOT NULL, + QUOTA INTEGER NOT NULL, + QUOTA_UNIT VARCHAR2(10) NULL, + UNIT_TIME INTEGER NOT NULL, + TIME_UNIT VARCHAR2(25) NOT NULL, + RATE_LIMIT_COUNT INTEGER DEFAULT NULL NULL, + RATE_LIMIT_TIME_UNIT VARCHAR2(25) DEFAULT NULL NULL, + IS_DEPLOYED INTEGER DEFAULT 0 NOT NULL, + CUSTOM_ATTRIBUTES BLOB DEFAULT NULL, + STOP_ON_QUOTA_REACH INTEGER DEFAULT 0 NOT NULL, + BILLING_PLAN VARCHAR2(20), + UUID VARCHAR2(256), + PRIMARY KEY (POLICY_ID), + CONSTRAINT SUBSCRIPTION_NAME_TENANT UNIQUE (NAME, TENANT_ID), + UNIQUE (UUID) +) +/ +-- Generate ID using sequence and trigger +CREATE SEQUENCE AM_POLICY_SUBSCRIPTION_seq START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER AM_POLICY_SUBSCRIPTION_seq_tr + BEFORE INSERT ON AM_POLICY_SUBSCRIPTION FOR EACH ROW + WHEN (NEW.POLICY_ID IS NULL) +BEGIN + SELECT AM_POLICY_SUBSCRIPTION_seq.NEXTVAL INTO :NEW.POLICY_ID FROM DUAL; +END; +/ + +CREATE TABLE AM_POLICY_APPLICATION ( + POLICY_ID INTEGER NOT NULL, + NAME VARCHAR2(512) NOT NULL, + DISPLAY_NAME VARCHAR2(512) DEFAULT NULL NULL, + TENANT_ID INTEGER NOT NULL, + DESCRIPTION VARCHAR2(1024) DEFAULT NULL NULL, + QUOTA_TYPE VARCHAR2(25) NOT NULL, + QUOTA INTEGER NOT NULL, + QUOTA_UNIT VARCHAR2(10) DEFAULT NULL NULL, + UNIT_TIME INTEGER NOT NULL, + TIME_UNIT VARCHAR2(25) NOT NULL, + IS_DEPLOYED INTEGER DEFAULT 0 NOT NULL, + CUSTOM_ATTRIBUTES BLOB DEFAULT NULL, + UUID VARCHAR2(256), + PRIMARY KEY (POLICY_ID), + CONSTRAINT AM_POLICY_APP_NAME_TENANT UNIQUE (NAME, TENANT_ID), + UNIQUE (UUID) +) +/ +-- Generate ID using sequence and trigger +CREATE SEQUENCE AM_POLICY_APPLICATION_seq START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER AM_POLICY_APPLICATION_seq_tr + BEFORE INSERT ON AM_POLICY_APPLICATION FOR EACH ROW + WHEN (NEW.POLICY_ID IS NULL) +BEGIN + SELECT AM_POLICY_APPLICATION_seq.NEXTVAL INTO :NEW.POLICY_ID FROM DUAL; +END; +/ + +CREATE TABLE AM_API_THROTTLE_POLICY ( + POLICY_ID INTEGER NOT NULL, + NAME VARCHAR2(512) NOT NULL, + DISPLAY_NAME VARCHAR2(512) DEFAULT NULL NULL, + TENANT_ID INTEGER NOT NULL, + DESCRIPTION VARCHAR2 (1024), + DEFAULT_QUOTA_TYPE VARCHAR2(25) NOT NULL, + DEFAULT_QUOTA INTEGER NOT NULL, + DEFAULT_QUOTA_UNIT VARCHAR2(10) NULL, + DEFAULT_UNIT_TIME INTEGER NOT NULL, + DEFAULT_TIME_UNIT VARCHAR2(25) NOT NULL, + APPLICABLE_LEVEL VARCHAR2(25) NOT NULL, + IS_DEPLOYED INTEGER DEFAULT 0 NOT NULL, + UUID VARCHAR2(256), + PRIMARY KEY (POLICY_ID), + CONSTRAINT API_POLICY_NAME_TENANT UNIQUE (NAME, TENANT_ID), + UNIQUE (UUID) +) +/ +-- Generate ID using sequence and trigger +CREATE SEQUENCE AM_API_THROTTLE_POLICY_seq START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER AM_API_THROTTLE_POLICY_seq_tr + BEFORE INSERT ON AM_API_THROTTLE_POLICY FOR EACH ROW + WHEN (NEW.POLICY_ID IS NULL) +BEGIN + SELECT AM_API_THROTTLE_POLICY_seq.NEXTVAL INTO :NEW.POLICY_ID FROM DUAL; +END; +/ + +CREATE TABLE AM_CONDITION_GROUP ( + CONDITION_GROUP_ID INTEGER NOT NULL, + POLICY_ID INTEGER NOT NULL, + QUOTA_TYPE VARCHAR2(25), + QUOTA INTEGER NOT NULL, + QUOTA_UNIT VARCHAR2(10) DEFAULT NULL NULL, + UNIT_TIME INTEGER NOT NULL, + TIME_UNIT VARCHAR2(25) NOT NULL, + DESCRIPTION VARCHAR2(1024) DEFAULT NULL NULL, + PRIMARY KEY (CONDITION_GROUP_ID), + FOREIGN KEY (POLICY_ID) REFERENCES AM_API_THROTTLE_POLICY(POLICY_ID) ON DELETE CASCADE +) +/ +-- Generate ID using sequence and trigger +CREATE SEQUENCE AM_CONDITION_GROUP_seq START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER AM_CONDITION_GROUP_seq_tr + BEFORE INSERT ON AM_CONDITION_GROUP FOR EACH ROW + WHEN (NEW.CONDITION_GROUP_ID IS NULL) +BEGIN + SELECT AM_CONDITION_GROUP_seq.NEXTVAL INTO :NEW.CONDITION_GROUP_ID FROM DUAL; +END; +/ + +CREATE TABLE AM_QUERY_PARAMETER_CONDITION ( + QUERY_PARAMETER_ID INTEGER NOT NULL, + CONDITION_GROUP_ID INTEGER NOT NULL, + PARAMETER_NAME VARCHAR2(255) DEFAULT NULL, + PARAMETER_VALUE VARCHAR2(255) DEFAULT NULL, + IS_PARAM_MAPPING CHAR(1) DEFAULT 1, + PRIMARY KEY (QUERY_PARAMETER_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE +) +/ +-- Generate ID using sequence and trigger +CREATE SEQUENCE QUERY_PARAMETER_CONDITION_seq START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER QUERY_PARAMETER_CONDITION_tr + BEFORE INSERT ON AM_QUERY_PARAMETER_CONDITION FOR EACH ROW + WHEN (NEW.QUERY_PARAMETER_ID IS NULL) +BEGIN + SELECT AM_QUERY_PARAMETER_CONDITION_seq.NEXTVAL INTO :NEW.QUERY_PARAMETER_ID FROM DUAL; +END; +/ + +CREATE TABLE AM_HEADER_FIELD_CONDITION ( + HEADER_FIELD_ID INTEGER NOT NULL, + CONDITION_GROUP_ID INTEGER NOT NULL, + HEADER_FIELD_NAME VARCHAR2(255) DEFAULT NULL, + HEADER_FIELD_VALUE VARCHAR2(255) DEFAULT NULL, + IS_HEADER_FIELD_MAPPING CHAR(1) DEFAULT 1, + PRIMARY KEY (HEADER_FIELD_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE +) +/ +-- Generate ID using sequence and trigger +CREATE SEQUENCE AM_HEADER_FIELD_CONDITION_seq START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER AM_HEADER_FIELD_CONDITION_tr + BEFORE INSERT ON AM_HEADER_FIELD_CONDITION FOR EACH ROW + WHEN (NEW.HEADER_FIELD_ID IS NULL) +BEGIN + SELECT AM_HEADER_FIELD_CONDITION_seq.NEXTVAL INTO :NEW.HEADER_FIELD_ID FROM DUAL; +END; +/ + +CREATE TABLE AM_JWT_CLAIM_CONDITION ( + JWT_CLAIM_ID INTEGER NOT NULL, + CONDITION_GROUP_ID INTEGER NOT NULL, + CLAIM_URI VARCHAR2(512) DEFAULT NULL, + CLAIM_ATTRIB VARCHAR2(1024) DEFAULT NULL, + IS_CLAIM_MAPPING CHAR(1) DEFAULT 1, + PRIMARY KEY (JWT_CLAIM_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE +) +/ +-- Generate ID using sequence and trigger +CREATE SEQUENCE AM_JWT_CLAIM_CONDITION_seq START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER AM_JWT_CLAIM_CONDITION_seq_tr + BEFORE INSERT ON AM_JWT_CLAIM_CONDITION FOR EACH ROW + WHEN (NEW.JWT_CLAIM_ID IS NULL) +BEGIN + SELECT AM_JWT_CLAIM_CONDITION_seq.NEXTVAL INTO :NEW.JWT_CLAIM_ID FROM DUAL; +END; +/ + +CREATE TABLE AM_IP_CONDITION ( + AM_IP_CONDITION_ID INTEGER NOT NULL, + STARTING_IP VARCHAR2(45) NULL, + ENDING_IP VARCHAR2(45) NULL, + SPECIFIC_IP VARCHAR2(45) NULL, + WITHIN_IP_RANGE CHAR(1) DEFAULT 1, + CONDITION_GROUP_ID INTEGER NULL, + PRIMARY KEY (AM_IP_CONDITION_ID) + , CONSTRAINT fk_AM_IP_CONDITION_1 FOREIGN KEY (CONDITION_GROUP_ID) + REFERENCES AM_CONDITION_GROUP (CONDITION_GROUP_ID) ON DELETE CASCADE ) + +/ +-- Generate ID using sequence and trigger +CREATE SEQUENCE AM_IP_CONDITION_seq START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER AM_IP_CONDITION_seq_tr + BEFORE INSERT ON AM_IP_CONDITION FOR EACH ROW + WHEN (NEW.AM_IP_CONDITION_ID IS NULL) +BEGIN + SELECT AM_IP_CONDITION_seq.NEXTVAL INTO :NEW.AM_IP_CONDITION_ID FROM DUAL; +END; +/ + +CREATE INDEX fk_AM_IP_CONDITION_1_idx ON AM_IP_CONDITION (CONDITION_GROUP_ID ASC) +/ + +CREATE TABLE AM_POLICY_GLOBAL ( + POLICY_ID INTEGER NOT NULL, + NAME VARCHAR2(512) NOT NULL, + KEY_TEMPLATE VARCHAR2(512) NOT NULL, + TENANT_ID INTEGER NOT NULL, + DESCRIPTION VARCHAR2(1024) DEFAULT NULL NULL, + SIDDHI_QUERY BLOB DEFAULT NULL, + IS_DEPLOYED INTEGER DEFAULT 0 NOT NULL, + UUID VARCHAR2(256), + PRIMARY KEY (POLICY_ID), + UNIQUE (UUID) +) +/ +-- Generate ID using sequence and trigger +CREATE SEQUENCE AM_POLICY_GLOBAL_seq START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER AM_POLICY_GLOBAL_seq_tr + BEFORE INSERT ON AM_POLICY_GLOBAL FOR EACH ROW + WHEN (NEW.POLICY_ID IS NULL) +BEGIN + SELECT AM_POLICY_GLOBAL_seq.NEXTVAL INTO :NEW.POLICY_ID FROM DUAL; +END; +/ + +CREATE TABLE AM_THROTTLE_TIER_PERMISSIONS ( + THROTTLE_TIER_PERMISSIONS_ID INTEGER NOT NULL, + TIER VARCHAR2(50) NULL, + PERMISSIONS_TYPE VARCHAR2(50) NULL, + ROLES VARCHAR2(512) NULL, + TENANT_ID INTEGER NULL, + PRIMARY KEY (THROTTLE_TIER_PERMISSIONS_ID)) +/ + +-- Generate ID using sequence and trigger +CREATE SEQUENCE THROTTLE_TIER_PERMISSIONS_seq START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER THROTTLE_TIER_PERMISSIONS_tr + BEFORE INSERT ON AM_THROTTLE_TIER_PERMISSIONS FOR EACH ROW + WHEN (NEW.THROTTLE_TIER_PERMISSIONS_ID IS NULL) +BEGIN + SELECT THROTTLE_TIER_PERMISSIONS_seq.NEXTVAL INTO :NEW.THROTTLE_TIER_PERMISSIONS_ID FROM DUAL; +END; +/ + +CREATE TABLE AM_BLOCK_CONDITIONS ( + CONDITION_ID INTEGER NOT NULL, + TYPE varchar2(45) DEFAULT NULL, + VALUE varchar2(45) DEFAULT NULL, + ENABLED varchar2(45) DEFAULT NULL, + DOMAIN varchar2(45) DEFAULT NULL, + UUID VARCHAR2(256), + PRIMARY KEY (CONDITION_ID), + UNIQUE (UUID) +) +/ +-- Generate ID using sequence and trigger +CREATE SEQUENCE AM_BLOCK_CONDITIONS_seq START WITH 1 INCREMENT BY 1 CACHE 20 ORDER +/ +CREATE OR REPLACE TRIGGER AM_BLOCK_CONDITIONS_seq_tr + BEFORE INSERT ON AM_BLOCK_CONDITIONS FOR EACH ROW + WHEN (NEW.CONDITION_ID IS NULL) +BEGIN + SELECT AM_BLOCK_CONDITIONS_seq.NEXTVAL INTO :NEW.CONDITION_ID FROM DUAL; +END; +/ + +-- End of API-MGT Tables -- + +--permance indexes start-- +/ +create index IDX_ITS_LMT on IDN_THRIFT_SESSION (LAST_MODIFIED_TIME) +/ +create index IDX_IOAT_AT on IDN_OAUTH2_ACCESS_TOKEN (ACCESS_TOKEN) +/ +create index IDX_IOAT_UT on IDN_OAUTH2_ACCESS_TOKEN (USER_TYPE) +/ +create index IDX_AAI_CTX on AM_API (CONTEXT) +/ +create index IDX_AAKM_CK on AM_APPLICATION_KEY_MAPPING (CONSUMER_KEY) +/ +create index IDX_AAUM_AI on AM_API_URL_MAPPING (API_ID) +/ +create index IDX_AAUM_TT on AM_API_URL_MAPPING (THROTTLING_TIER) +/ +create index IDX_AATP_DQT on AM_API_THROTTLE_POLICY (DEFAULT_QUOTA_TYPE) +/ +create index IDX_ACG_QT on AM_CONDITION_GROUP (QUOTA_TYPE) +/ +create index IDX_APS_QT on AM_POLICY_SUBSCRIPTION (QUOTA_TYPE) +/ +create index IDX_AS_AITIAI on AM_SUBSCRIPTION (API_ID,TIER_ID,APPLICATION_ID) +/ +create index IDX_APA_QT on AM_POLICY_APPLICATION (QUOTA_TYPE) +/ +create index IDX_AA_AT_CB on AM_APPLICATION (APPLICATION_TIER,CREATED_BY) +/ +-- Performance indexes end-- + diff --git a/modules/distribution/src/repository/resources/dbscripts/apimgt/postgresql.sql b/modules/distribution/src/repository/resources/dbscripts/apimgt/postgresql.sql index 157bc90a..a8f0a407 100644 --- a/modules/distribution/src/repository/resources/dbscripts/apimgt/postgresql.sql +++ b/modules/distribution/src/repository/resources/dbscripts/apimgt/postgresql.sql @@ -23,6 +23,8 @@ CREATE TABLE IDN_OAUTH_CONSUMER_APPS ( OAUTH_VERSION VARCHAR(128), CALLBACK_URL VARCHAR(1024), GRANT_TYPES VARCHAR (1024), + PKCE_MANDATORY CHAR(1) DEFAULT '0', + PKCE_SUPPORT_PLAIN CHAR(1) DEFAULT '0', CONSTRAINT CONSUMER_KEY_CONSTRAINT UNIQUE (CONSUMER_KEY), PRIMARY KEY (ID) ); @@ -98,6 +100,8 @@ CREATE TABLE IDN_OAUTH2_AUTHORIZATION_CODE ( STATE VARCHAR (25) DEFAULT 'ACTIVE', TOKEN_ID VARCHAR(255), SUBJECT_IDENTIFIER VARCHAR(255), + PKCE_CODE_CHALLENGE VARCHAR (255), + PKCE_CODE_CHALLENGE_METHOD VARCHAR(128), PRIMARY KEY (CODE_ID), FOREIGN KEY (CONSUMER_KEY_ID) REFERENCES IDN_OAUTH_CONSUMER_APPS(ID) ON DELETE CASCADE ); @@ -388,10 +392,11 @@ CREATE TABLE IDP ( PRIMARY KEY (ID), UNIQUE (TENANT_ID, NAME)); -INSERT INTO IDP (TENANT_ID, NAME, HOME_REALM_ID) VALUES (-1234, 'LOCAL', 'localhost'); - DROP TABLE IF EXISTS IDP_ROLE; DROP SEQUENCE IF EXISTS IDP_ROLE_SEQ; + +INSERT INTO IDP (TENANT_ID, NAME, HOME_REALM_ID) VALUES (-1234, 'LOCAL', 'localhost'); + CREATE SEQUENCE IDP_ROLE_SEQ; CREATE TABLE IDP_ROLE ( ID INTEGER DEFAULT NEXTVAL('IDP_ROLE_SEQ'), @@ -604,13 +609,11 @@ CREATE TABLE WF_REQUEST ( DROP TABLE IF EXISTS WF_BPS_PROFILE; CREATE TABLE WF_BPS_PROFILE ( PROFILE_NAME VARCHAR(45), - HOST_URL_MANAGER VARCHAR(45), - HOST_URL_WORKER VARCHAR(45), + HOST_URL_MANAGER VARCHAR(255), + HOST_URL_WORKER VARCHAR(255), USERNAME VARCHAR(45), PASSWORD VARCHAR(255), CALLBACK_HOST VARCHAR (45), - CALLBACK_USERNAME VARCHAR (45), - CALLBACK_PASSWORD VARCHAR (255), TENANT_ID INTEGER DEFAULT -1, PRIMARY KEY (PROFILE_NAME, TENANT_ID) ); @@ -679,7 +682,7 @@ CREATE TABLE WF_WORKFLOW_REQUEST_RELATION( -- End of IDENTITY Tables-- CREATE SEQUENCE AM_SUBSCRIBER_SEQUENCE START WITH 1 INCREMENT BY 1; -CREATE TABLE AM_SUBSCRIBER ( +CREATE TABLE IF NOT EXISTS AM_SUBSCRIBER ( SUBSCRIBER_ID INTEGER DEFAULT nextval('am_subscriber_sequence'), USER_ID VARCHAR(50) NOT NULL, TENANT_ID INTEGER NOT NULL, @@ -695,7 +698,7 @@ CREATE TABLE AM_SUBSCRIBER ( ; CREATE SEQUENCE AM_APPLICATION_SEQUENCE START WITH 1 INCREMENT BY 1 ; -CREATE TABLE AM_APPLICATION ( +CREATE TABLE IF NOT EXISTS AM_APPLICATION ( APPLICATION_ID INTEGER DEFAULT nextval('am_application_sequence'), NAME VARCHAR(100), SUBSCRIBER_ID INTEGER, @@ -717,24 +720,24 @@ CREATE TABLE AM_APPLICATION ( ; CREATE SEQUENCE AM_API_SEQUENCE START WITH 1 INCREMENT BY 1; -CREATE TABLE AM_API ( +CREATE TABLE IF NOT EXISTS AM_API ( API_ID INTEGER DEFAULT nextval('am_api_sequence'), API_PROVIDER VARCHAR(256), API_NAME VARCHAR(256), API_VERSION VARCHAR(30), CONTEXT VARCHAR(256), CONTEXT_TEMPLATE VARCHAR(256), + API_TIER VARCHAR(256), CREATED_BY VARCHAR(100), CREATED_TIME DATE, UPDATED_BY VARCHAR(100), UPDATED_TIME DATE, PRIMARY KEY(API_ID), UNIQUE (API_PROVIDER,API_NAME,API_VERSION) -) -; +); CREATE SEQUENCE AM_API_URL_MAPPING_SEQUENCE START WITH 1 INCREMENT BY 1; -CREATE TABLE AM_API_URL_MAPPING ( +CREATE TABLE IF NOT EXISTS AM_API_URL_MAPPING ( URL_MAPPING_ID INTEGER DEFAULT nextval('am_api_url_mapping_sequence'), API_ID INTEGER NOT NULL, HTTP_METHOD VARCHAR(20) NULL, @@ -747,7 +750,7 @@ CREATE TABLE AM_API_URL_MAPPING ( ; CREATE SEQUENCE AM_SUBSCRIPTION_SEQUENCE START WITH 1 INCREMENT BY 1; -CREATE TABLE AM_SUBSCRIPTION ( +CREATE TABLE IF NOT EXISTS AM_SUBSCRIPTION ( SUBSCRIPTION_ID INTEGER DEFAULT nextval('am_subscription_sequence'), TIER_ID VARCHAR(50), API_ID INTEGER, @@ -767,7 +770,7 @@ CREATE TABLE AM_SUBSCRIPTION ( ) ; -CREATE TABLE AM_SUBSCRIPTION_KEY_MAPPING ( +CREATE TABLE IF NOT EXISTS AM_SUBSCRIPTION_KEY_MAPPING ( SUBSCRIPTION_ID INTEGER, ACCESS_TOKEN VARCHAR(512), KEY_TYPE VARCHAR(512) NOT NULL, @@ -808,7 +811,7 @@ CREATE TABLE IF NOT EXISTS AM_APPLICATION_REGISTRATION ( CREATE SEQUENCE AM_API_LC_EVENT_SEQUENCE START WITH 1 INCREMENT BY 1; -CREATE TABLE AM_API_LC_EVENT ( +CREATE TABLE IF NOT EXISTS AM_API_LC_EVENT ( EVENT_ID INTEGER DEFAULT nextval('am_api_lc_event_sequence'), API_ID INTEGER NOT NULL, PREVIOUS_STATE VARCHAR(50), @@ -821,7 +824,7 @@ CREATE TABLE AM_API_LC_EVENT ( ) ; -CREATE TABLE AM_APP_KEY_DOMAIN_MAPPING ( +CREATE TABLE IF NOT EXISTS AM_APP_KEY_DOMAIN_MAPPING ( CONSUMER_KEY VARCHAR(255), AUTHZ_DOMAIN VARCHAR(255) DEFAULT 'ALL', PRIMARY KEY (CONSUMER_KEY,AUTHZ_DOMAIN) @@ -829,7 +832,7 @@ CREATE TABLE AM_APP_KEY_DOMAIN_MAPPING ( ; CREATE SEQUENCE AM_API_COMMENTS_SEQUENCE START WITH 1 INCREMENT BY 1; -CREATE TABLE AM_API_COMMENTS ( +CREATE TABLE IF NOT EXISTS AM_API_COMMENTS ( COMMENT_ID INTEGER DEFAULT nextval('am_api_comments_sequence'), COMMENT_TEXT VARCHAR(512), COMMENTED_USER VARCHAR(255), @@ -841,7 +844,7 @@ CREATE TABLE AM_API_COMMENTS ( ; CREATE SEQUENCE AM_WORKFLOWS_SEQUENCE START WITH 1 INCREMENT BY 1; -CREATE TABLE AM_WORKFLOWS( +CREATE TABLE IF NOT EXISTS AM_WORKFLOWS( WF_ID INTEGER DEFAULT nextval('am_workflows_sequence'), WF_REFERENCE VARCHAR(255) NOT NULL, WF_TYPE VARCHAR(255) NOT NULL, @@ -858,7 +861,7 @@ CREATE TABLE AM_WORKFLOWS( ; CREATE SEQUENCE AM_API_RATINGS_SEQUENCE START WITH 1 INCREMENT BY 1; -CREATE TABLE AM_API_RATINGS ( +CREATE TABLE IF NOT EXISTS AM_API_RATINGS ( RATING_ID INTEGER DEFAULT nextval('am_api_ratings_sequence'), API_ID INTEGER, RATING INTEGER, @@ -870,7 +873,7 @@ CREATE TABLE AM_API_RATINGS ( ; CREATE SEQUENCE AM_TIER_PERMISSIONS_SEQUENCE START WITH 1 INCREMENT BY 1; -CREATE TABLE AM_TIER_PERMISSIONS ( +CREATE TABLE IF NOT EXISTS AM_TIER_PERMISSIONS ( TIER_PERMISSIONS_ID INTEGER DEFAULT nextval('am_tier_permissions_sequence'), TIER VARCHAR(50) NOT NULL, PERMISSIONS_TYPE VARCHAR(50) NOT NULL, @@ -880,7 +883,7 @@ CREATE TABLE AM_TIER_PERMISSIONS ( ); CREATE SEQUENCE AM_EXTERNAL_STORES_SEQUENCE START WITH 1 INCREMENT BY 1; -CREATE TABLE AM_EXTERNAL_STORES ( +CREATE TABLE IF NOT EXISTS AM_EXTERNAL_STORES ( APISTORE_ID INTEGER DEFAULT nextval('am_external_stores_sequence'), API_ID INTEGER, STORE_ID VARCHAR(255) NOT NULL, @@ -892,7 +895,7 @@ CREATE TABLE AM_EXTERNAL_STORES ( ) ; -DROP TABLE IF EXISTS AM_API_SCOPES; + CREATE TABLE IF NOT EXISTS AM_API_SCOPES ( API_ID INTEGER NOT NULL, SCOPE_ID INTEGER NOT NULL, @@ -900,10 +903,9 @@ CREATE TABLE IF NOT EXISTS AM_API_SCOPES ( FOREIGN KEY (SCOPE_ID) REFERENCES IDN_OAUTH2_SCOPE (SCOPE_ID) ON DELETE CASCADE ON UPDATE CASCADE ); -DROP TABLE IF EXISTS AM_API_DEFAULT_VERSION; -DROP SEQUENCE IF EXISTS AM_API_DEFAULT_VERSION_PK_SEQ; + CREATE SEQUENCE AM_API_DEFAULT_VERSION_PK_SEQ; -CREATE TABLE AM_API_DEFAULT_VERSION ( +CREATE TABLE IF NOT EXISTS AM_API_DEFAULT_VERSION ( DEFAULT_VERSION_ID INTEGER DEFAULT NEXTVAL('am_api_default_version_pk_seq'), API_NAME VARCHAR(256) NOT NULL , API_PROVIDER VARCHAR(256) NOT NULL , @@ -915,4 +917,246 @@ CREATE TABLE AM_API_DEFAULT_VERSION ( CREATE INDEX IDX_SUB_APP_ID ON AM_SUBSCRIPTION (APPLICATION_ID, SUBSCRIPTION_ID) ; -commit; \ No newline at end of file + +CREATE SEQUENCE AM_ALERT_TYPES_SEQ START WITH 1 INCREMENT BY 1; + +CREATE TABLE IF NOT EXISTS AM_ALERT_TYPES ( + ALERT_TYPE_ID INTEGER DEFAULT NEXTVAL('am_alert_types_seq'), + ALERT_TYPE_NAME VARCHAR(255) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL, + PRIMARY KEY (ALERT_TYPE_ID) +); + +CREATE TABLE IF NOT EXISTS AM_ALERT_TYPES_VALUES ( + ALERT_TYPE_ID INTEGER, + USER_NAME VARCHAR(255) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL , + CONSTRAINT AM_ALERT_TYPES_VALUES_CONST UNIQUE (ALERT_TYPE_ID,USER_NAME,STAKE_HOLDER) +); + +CREATE SEQUENCE AM_ALERT_EMAILLIST_SEQ START WITH 1 INCREMENT BY 1; + +CREATE TABLE IF NOT EXISTS AM_ALERT_EMAILLIST ( + EMAIL_LIST_ID INTEGER DEFAULT NEXTVAL('am_alert_emaillist_seq'), + USER_NAME VARCHAR(255) NOT NULL , + STAKE_HOLDER VARCHAR(100) NOT NULL , + CONSTRAINT AM_ALERT_EMAILLIST_CONST UNIQUE (EMAIL_LIST_ID,USER_NAME,STAKE_HOLDER), + PRIMARY KEY (EMAIL_LIST_ID) +); + +CREATE TABLE IF NOT EXISTS AM_ALERT_EMAILLIST_DETAILS ( + EMAIL_LIST_ID INTEGER, + EMAIL VARCHAR(255), + CONSTRAINT AM_ALERT_EMAILLIST_DETAILS_CONST UNIQUE (EMAIL_LIST_ID,EMAIL) +); + +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalResponseTime', 'publisher'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalBackendTime', 'publisher'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('abnormalRequestsPerMin', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('RequestPatternChanged', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('UnusualIPAccessAlert', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('AbnormalRefreshAlert', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('FrequentTierHittingAlert', 'subscriber'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('AbnormalTierUsage', 'publisher'); +INSERT INTO AM_ALERT_TYPES (ALERT_TYPE_NAME, STAKE_HOLDER) VALUES ('healthAvailabilityPerMin', 'publisher'); + + + +-- AM Throttling tables -- +CREATE SEQUENCE AM_POLICY_SUBSCRIPTION_SEQ START WITH 1 INCREMENT BY 1; +CREATE TABLE IF NOT EXISTS AM_POLICY_SUBSCRIPTION ( + POLICY_ID INTEGER DEFAULT NEXTVAL('AM_POLICY_SUBSCRIPTION_SEQ'), + NAME VARCHAR(512) NOT NULL, + DISPLAY_NAME VARCHAR(512) NULL DEFAULT NULL, + TENANT_ID INTEGER NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + QUOTA_TYPE VARCHAR(25) NOT NULL, + QUOTA INTEGER NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL, + UNIT_TIME INTEGER NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + RATE_LIMIT_COUNT INTEGER NULL DEFAULT NULL, + RATE_LIMIT_TIME_UNIT VARCHAR(25) NULL DEFAULT NULL, + IS_DEPLOYED BOOLEAN NOT NULL DEFAULT '0', + CUSTOM_ATTRIBUTES BYTEA DEFAULT NULL, + STOP_ON_QUOTA_REACH BOOLEAN NOT NULL DEFAULT '0', + BILLING_PLAN VARCHAR(20) NOT NULL, + UUID VARCHAR(256), + PRIMARY KEY (POLICY_ID), + UNIQUE (NAME, TENANT_ID), + UNIQUE (UUID) +); + +CREATE SEQUENCE AM_POLICY_APPLICATION_SEQ START WITH 1 INCREMENT BY 1; +CREATE TABLE IF NOT EXISTS AM_POLICY_APPLICATION ( + POLICY_ID INTEGER DEFAULT NEXTVAL('AM_POLICY_APPLICATION_SEQ'), + NAME VARCHAR(512) NOT NULL, + DISPLAY_NAME VARCHAR(512) NULL DEFAULT NULL, + TENANT_ID INTEGER NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + QUOTA_TYPE VARCHAR(25) NOT NULL, + QUOTA INTEGER NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL DEFAULT NULL, + UNIT_TIME INTEGER NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + IS_DEPLOYED BOOLEAN NOT NULL DEFAULT '0', + CUSTOM_ATTRIBUTES BYTEA DEFAULT NULL, + UUID VARCHAR(256), + PRIMARY KEY (POLICY_ID), + UNIQUE (NAME, TENANT_ID), + UNIQUE (UUID) +); + +CREATE SEQUENCE AM_POLICY_HARD_THROTTLING_SEQ START WITH 1 INCREMENT BY 1; +CREATE TABLE IF NOT EXISTS AM_POLICY_HARD_THROTTLING ( + POLICY_ID INTEGER DEFAULT NEXTVAL('AM_POLICY_HARD_THROTTLING_SEQ'), + NAME VARCHAR(512) NOT NULL, + TENANT_ID INTEGER NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + QUOTA_TYPE VARCHAR(25) NOT NULL, + QUOTA INTEGER NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL DEFAULT NULL, + UNIT_TIME INTEGER NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + IS_DEPLOYED BOOLEAN NOT NULL DEFAULT '0', + PRIMARY KEY (POLICY_ID), + UNIQUE (NAME, TENANT_ID) +); + +CREATE SEQUENCE AM_API_THROTTLE_POLICY_SEQ START WITH 1 INCREMENT BY 1; +CREATE TABLE IF NOT EXISTS AM_API_THROTTLE_POLICY ( + POLICY_ID INTEGER DEFAULT NEXTVAL('AM_API_THROTTLE_POLICY_SEQ'), + NAME VARCHAR(512) NOT NULL, + DISPLAY_NAME VARCHAR(512) NULL DEFAULT NULL, + TENANT_ID INTEGER NOT NULL, + DESCRIPTION VARCHAR (1024), + DEFAULT_QUOTA_TYPE VARCHAR(25) NOT NULL, + DEFAULT_QUOTA INTEGER NOT NULL, + DEFAULT_QUOTA_UNIT VARCHAR(10) NULL, + DEFAULT_UNIT_TIME INTEGER NOT NULL, + DEFAULT_TIME_UNIT VARCHAR(25) NOT NULL, + APPLICABLE_LEVEL VARCHAR(25) NOT NULL, + IS_DEPLOYED BOOLEAN NOT NULL DEFAULT '0', + UUID VARCHAR(256), + PRIMARY KEY (POLICY_ID), + UNIQUE (NAME, TENANT_ID), + UNIQUE (UUID) +); + +CREATE SEQUENCE AM_CONDITION_GROUP_SEQ START WITH 1 INCREMENT BY 1; +CREATE TABLE IF NOT EXISTS AM_CONDITION_GROUP ( + CONDITION_GROUP_ID INTEGER DEFAULT NEXTVAL('AM_CONDITION_GROUP_SEQ'), + POLICY_ID INTEGER NOT NULL, + QUOTA_TYPE VARCHAR(25), + QUOTA INTEGER NOT NULL, + QUOTA_UNIT VARCHAR(10) NULL DEFAULT NULL, + UNIT_TIME INTEGER NOT NULL, + TIME_UNIT VARCHAR(25) NOT NULL, + DESCRIPTION VARCHAR (1024) NULL DEFAULT NULL, + PRIMARY KEY (CONDITION_GROUP_ID), + FOREIGN KEY (POLICY_ID) REFERENCES AM_API_THROTTLE_POLICY(POLICY_ID) ON DELETE CASCADE ON UPDATE CASCADE +); + +CREATE SEQUENCE AM_QUERY_PARAMETER_CONDITION_SEQ START WITH 1 INCREMENT BY 1; +CREATE TABLE IF NOT EXISTS AM_QUERY_PARAMETER_CONDITION ( + QUERY_PARAMETER_ID INTEGER DEFAULT NEXTVAL('AM_QUERY_PARAMETER_CONDITION_SEQ'), + CONDITION_GROUP_ID INTEGER NOT NULL, + PARAMETER_NAME VARCHAR(255) DEFAULT NULL, + PARAMETER_VALUE VARCHAR(255) DEFAULT NULL, + IS_PARAM_MAPPING BOOLEAN DEFAULT '1', + PRIMARY KEY (QUERY_PARAMETER_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE +); + +CREATE SEQUENCE AM_HEADER_FIELD_CONDITION_SEQ START WITH 1 INCREMENT BY 1; +CREATE TABLE IF NOT EXISTS AM_HEADER_FIELD_CONDITION ( + HEADER_FIELD_ID INTEGER DEFAULT NEXTVAL('AM_HEADER_FIELD_CONDITION_SEQ'), + CONDITION_GROUP_ID INTEGER NOT NULL, + HEADER_FIELD_NAME VARCHAR(255) DEFAULT NULL, + HEADER_FIELD_VALUE VARCHAR(255) DEFAULT NULL, + IS_HEADER_FIELD_MAPPING BOOLEAN DEFAULT '1', + PRIMARY KEY (HEADER_FIELD_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE +); + +CREATE SEQUENCE AM_JWT_CLAIM_CONDITION_SEQ START WITH 1 INCREMENT BY 1; +CREATE TABLE IF NOT EXISTS AM_JWT_CLAIM_CONDITION ( + JWT_CLAIM_ID INTEGER DEFAULT NEXTVAL('AM_JWT_CLAIM_CONDITION_SEQ'), + CONDITION_GROUP_ID INTEGER NOT NULL, + CLAIM_URI VARCHAR(512) DEFAULT NULL, + CLAIM_ATTRIB VARCHAR(1024) DEFAULT NULL, + IS_CLAIM_MAPPING BOOLEAN DEFAULT '1', + PRIMARY KEY (JWT_CLAIM_ID), + FOREIGN KEY (CONDITION_GROUP_ID) REFERENCES AM_CONDITION_GROUP(CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE +); + +CREATE SEQUENCE AM_IP_CONDITION_SEQ START WITH 1 INCREMENT BY 1; +CREATE TABLE IF NOT EXISTS AM_IP_CONDITION ( + AM_IP_CONDITION_ID INTEGER DEFAULT NEXTVAL('AM_IP_CONDITION_SEQ'), + STARTING_IP VARCHAR(45) NULL, + ENDING_IP VARCHAR(45) NULL, + SPECIFIC_IP VARCHAR(45) NULL, + WITHIN_IP_RANGE BOOLEAN DEFAULT '1', + CONDITION_GROUP_ID INT NULL, + PRIMARY KEY (AM_IP_CONDITION_ID), + FOREIGN KEY (CONDITION_GROUP_ID) + REFERENCES AM_CONDITION_GROUP (CONDITION_GROUP_ID) ON DELETE CASCADE ON UPDATE CASCADE); + +CREATE SEQUENCE AM_POLICY_GLOBAL_SEQ START WITH 1 INCREMENT BY 1; +CREATE TABLE IF NOT EXISTS AM_POLICY_GLOBAL ( + POLICY_ID INTEGER DEFAULT NEXTVAL('AM_POLICY_GLOBAL_SEQ'), + NAME VARCHAR(512) NOT NULL, + KEY_TEMPLATE VARCHAR(512) NOT NULL, + TENANT_ID INTEGER NOT NULL, + DESCRIPTION VARCHAR(1024) NULL DEFAULT NULL, + SIDDHI_QUERY BYTEA DEFAULT NULL, + IS_DEPLOYED BOOLEAN NOT NULL DEFAULT '0', + UUID VARCHAR(256), + PRIMARY KEY (POLICY_ID), + UNIQUE (UUID) +); + +CREATE SEQUENCE AM_THROTTLE_TIER_PERMISSIONS_SEQ START WITH 1 INCREMENT BY 1; +CREATE TABLE IF NOT EXISTS AM_THROTTLE_TIER_PERMISSIONS ( + THROTTLE_TIER_PERMISSIONS_ID INTEGER DEFAULT NEXTVAL('AM_THROTTLE_TIER_PERMISSIONS_SEQ'), + TIER VARCHAR(50) NULL, + PERMISSIONS_TYPE VARCHAR(50) NULL, + ROLES VARCHAR(512) NULL, + TENANT_ID INTEGER NULL, + PRIMARY KEY (THROTTLE_TIER_PERMISSIONS_ID)); + +CREATE SEQUENCE AM_BLOCK_CONDITIONS_SEQ START WITH 1 INCREMENT BY 1; +CREATE TABLE AM_BLOCK_CONDITIONS ( + CONDITION_ID INTEGER DEFAULT NEXTVAL('AM_BLOCK_CONDITIONS_SEQ'), + TYPE varchar(45) DEFAULT NULL, + VALUE varchar(45) DEFAULT NULL, + ENABLED varchar(45) DEFAULT NULL, + DOMAIN varchar(45) DEFAULT NULL, + UUID VARCHAR(256), + PRIMARY KEY (CONDITION_ID), + UNIQUE (UUID) +); + +-- End of API-MGT Tables -- + +-- Performance indexes start-- + +create index IDX_ITS_LMT on IDN_THRIFT_SESSION (LAST_MODIFIED_TIME); +create index IDX_IOAT_AT on IDN_OAUTH2_ACCESS_TOKEN (ACCESS_TOKEN); +create index IDX_IOAT_UT on IDN_OAUTH2_ACCESS_TOKEN (USER_TYPE); +create index IDX_AAI_CTX on AM_API (CONTEXT); +create index IDX_AAKM_CK on AM_APPLICATION_KEY_MAPPING (CONSUMER_KEY); +create index IDX_AAUM_AI on AM_API_URL_MAPPING (API_ID); +create index IDX_AAUM_TT on AM_API_URL_MAPPING (THROTTLING_TIER); +create index IDX_AATP_DQT on AM_API_THROTTLE_POLICY (DEFAULT_QUOTA_TYPE); +create index IDX_ACG_QT on AM_CONDITION_GROUP (QUOTA_TYPE); +create index IDX_APS_QT on AM_POLICY_SUBSCRIPTION (QUOTA_TYPE); +create index IDX_AS_AITIAI on AM_SUBSCRIPTION (API_ID,TIER_ID,APPLICATION_ID); +create index IDX_APA_QT on AM_POLICY_APPLICATION (QUOTA_TYPE); +create index IDX_AA_AT_CB on AM_APPLICATION (APPLICATION_TIER,CREATED_BY); + +-- Performance indexes end-- + + +commit; + From 9a3fcccf6320bd4bdc83ca3e98af2fec32de666f Mon Sep 17 00:00:00 2001 From: warunalakshitha Date: Thu, 29 Sep 2016 00:58:05 +0530 Subject: [PATCH 03/10] Update api-manager.xml to 6.0.5 version --- .../src/repository/conf/api-manager.xml | 52 +++++++------------ 1 file changed, 20 insertions(+), 32 deletions(-) diff --git a/modules/distribution/src/repository/conf/api-manager.xml b/modules/distribution/src/repository/conf/api-manager.xml index 22635c5e..5192aa4f 100755 --- a/modules/distribution/src/repository/conf/api-manager.xml +++ b/modules/distribution/src/repository/conf/api-manager.xml @@ -1,22 +1,4 @@ - - - Synapse + None @@ -94,7 +76,7 @@ jwt token, he needs to enable this parameter. The DefaultClaimsRetriever class adds user claims from the default carbon user store. --> - org.wso2.carbon.apimgt.impl.token.DefaultClaimsRetriever + - http://wso2.org/claims + - SHA256withRSA + - true + - WSClient + ThriftClient 10397 10000 10397 - false + true false - - device_scope - - + + org.wso2.carbon.apimgt.impl.AMDefaultKeyManagerImpl + + https://localhost:${mgt.transport.https.port}${carbon.context}services/ + ${admin.username} + ${admin.password} + https://${carbon.local.ip}:${mgt.transport.https.port}/oauth2/token + https://${carbon.local.ip}:${mgt.transport.https.port}/oauth2/revoke + + + @@ -531,8 +520,7 @@ - https://localhost:9443,http://localhost:9763 - + https://localhost:9443,http://localhost:9763 authorization,Access-Control-Allow-Origin,Content-Type @@ -542,4 +530,4 @@ You can enable this and set preferable Logger name. --> - + \ No newline at end of file From f1777e67ea0084878e111530a7379b69cf98a84c Mon Sep 17 00:00:00 2001 From: warunalakshitha Date: Thu, 29 Sep 2016 00:59:09 +0530 Subject: [PATCH 04/10] Move carbon kernal version to 4.4.9 --- modules/distribution/src/assembly/filter.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/distribution/src/assembly/filter.properties b/modules/distribution/src/assembly/filter.properties index 17cd8aee..cf2d1eac 100644 --- a/modules/distribution/src/assembly/filter.properties +++ b/modules/distribution/src/assembly/filter.properties @@ -21,7 +21,7 @@ product.version=1.0.0-SNAPSHOT product.key=IOT hotdeployment=true hotupdate=true -carbon.version=4.4.3 +carbon.version=4.4.9 default.server.role=IoTServer cep.server.role=ComplexEventProcessor das.server.role=DataAnalyticsServer From 587c792b918cdc921851dd98a4d85e8682445a2d Mon Sep 17 00:00:00 2001 From: warunalakshitha Date: Thu, 29 Sep 2016 01:00:49 +0530 Subject: [PATCH 05/10] Fix hostname verfication issue --- modules/distribution/src/repository/bin/wso2server.bat | 2 +- modules/distribution/src/repository/bin/wso2server.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/distribution/src/repository/bin/wso2server.bat b/modules/distribution/src/repository/bin/wso2server.bat index a7f15691..e4a73f72 100644 --- a/modules/distribution/src/repository/bin/wso2server.bat +++ b/modules/distribution/src/repository/bin/wso2server.bat @@ -162,7 +162,7 @@ set CARBON_CLASSPATH=.\lib;%CARBON_CLASSPATH% set JAVA_ENDORSED=".\lib\endorsed";"%JAVA_HOME%\jre\lib\endorsed";"%JAVA_HOME%\lib\endorsed" -set CMD_LINE_ARGS=-Xbootclasspath/a:%CARBON_XBOOTCLASSPATH% -Xms256m -Xmx1024m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="%CARBON_HOME%\repository\logs\heap-dump.hprof" -Dcom.sun.management.jmxremote -classpath %CARBON_CLASSPATH% %JAVA_OPTS% -Djava.endorsed.dirs=%JAVA_ENDORSED% -Dcarbon.registry.root=/ -Dcarbon.home="%CARBON_HOME%" -Dwso2.server.standalone=true -Djava.command="%JAVA_HOME%\bin\java" -Djava.opts="%JAVA_OPTS%" -Djava.io.tmpdir="%CARBON_HOME%\tmp" -Dcatalina.base="%CARBON_HOME%\lib\tomcat" -Dwso2.carbon.xml=%CARBON_HOME%\repository\conf\carbon.xml -Dwso2.registry.xml="%CARBON_HOME%\repository\conf\registry.xml" -Dwso2.user.mgt.xml="%CARBON_HOME%\repository\conf\user-mgt.xml" -Dwso2.transports.xml="%CARBON_HOME%\repository\conf\mgt-transports.xml" -Djava.util.logging.config.file="%CARBON_HOME%\repository\conf\etc\logging-bridge.properties" -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Dcarbon.config.dir.path="%CARBON_HOME%\repository\conf" -Dcomponents.repo="%CARBON_HOME%\repository\components" -Dconf.location="%CARBON_HOME%\repository\conf" -Dcom.atomikos.icatch.file="%CARBON_HOME%\lib\transactions.properties" -Dcom.atomikos.icatch.hide_init_file_path="true" -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dcom.sun.jndi.ldap.connect.pool.authentication=simple -Dcom.sun.jndi.ldap.connect.pool.timeout=3000 -Dorg.terracotta.quartz.skipUpdateCheck=true -Dcarbon.classpath=%CARBON_CLASSPATH% -Dfile.encoding=UTF8 +set CMD_LINE_ARGS=-Xbootclasspath/a:%CARBON_XBOOTCLASSPATH% -Xms256m -Xmx1024m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="%CARBON_HOME%\repository\logs\heap-dump.hprof" -Dcom.sun.management.jmxremote -classpath %CARBON_CLASSPATH% %JAVA_OPTS% -Djava.endorsed.dirs=%JAVA_ENDORSED% -Dcarbon.registry.root=/ -Dcarbon.home="%CARBON_HOME%" -Dwso2.server.standalone=true -Djava.command="%JAVA_HOME%\bin\java" -Djava.opts="%JAVA_OPTS%" -Djava.io.tmpdir="%CARBON_HOME%\tmp" -Dcatalina.base="%CARBON_HOME%\lib\tomcat" -Dwso2.carbon.xml=%CARBON_HOME%\repository\conf\carbon.xml -Dwso2.registry.xml="%CARBON_HOME%\repository\conf\registry.xml" -Dwso2.user.mgt.xml="%CARBON_HOME%\repository\conf\user-mgt.xml" -Dwso2.transports.xml="%CARBON_HOME%\repository\conf\mgt-transports.xml" -Djava.util.logging.config.file="%CARBON_HOME%\repository\conf\etc\logging-bridge.properties" -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Dcarbon.config.dir.path="%CARBON_HOME%\repository\conf" -Dcomponents.repo="%CARBON_HOME%\repository\components" -Dconf.location="%CARBON_HOME%\repository\conf" -Dcom.atomikos.icatch.file="%CARBON_HOME%\lib\transactions.properties" -Dcom.atomikos.icatch.hide_init_file_path="true" -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false -Dorg.apache.jasper.runtime.BodyContentImpl.LIMIT_BUFFER=true -Dcom.sun.jndi.ldap.connect.pool.authentication=simple -Dcom.sun.jndi.ldap.connect.pool.timeout=3000 -Dorg.terracotta.quartz.skipUpdateCheck=true -Dcarbon.classpath=%CARBON_CLASSPATH% -Dfile.encoding=UTF8 -Dorg.wso2.ignoreHostnameVerification=true :runJava echo JAVA_HOME environment variable is set to %JAVA_HOME% diff --git a/modules/distribution/src/repository/bin/wso2server.sh b/modules/distribution/src/repository/bin/wso2server.sh index b7169060..12bed6e8 100755 --- a/modules/distribution/src/repository/bin/wso2server.sh +++ b/modules/distribution/src/repository/bin/wso2server.sh @@ -304,6 +304,7 @@ do -Djava.net.preferIPv4Stack=true \ -Dcom.ibm.cacheLocalHost=true \ -DworkerNode=false \ + -Dorg.wso2.ignoreHostnameVerification=true \ org.wso2.carbon.bootstrap.Bootstrap $* status=$? done From af5c8869079424e445021c0931c2d4f46ef32a24 Mon Sep 17 00:00:00 2001 From: warunalakshitha Date: Thu, 29 Sep 2016 01:01:55 +0530 Subject: [PATCH 06/10] Add akka reference file and registry-event-broker.xml --- modules/distribution/src/assembly/bin.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/distribution/src/assembly/bin.xml b/modules/distribution/src/assembly/bin.xml index fa2f8f90..65c34dbf 100644 --- a/modules/distribution/src/assembly/bin.xml +++ b/modules/distribution/src/assembly/bin.xml @@ -753,6 +753,13 @@ true 644 + + ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/registry-event-broker.xml + + ${pom.artifactId}-${pom.version}/repository/conf/ + true + 644 + INSTALL.txt ${pom.artifactId}-${pom.version} @@ -1188,6 +1195,15 @@ 755 + + + + ../p2-profile-gen/target/wso2carbon-core-${carbon.kernel.version}/repository/conf/etc/bundle-config/com.typesafe.config/reference.conf + + ${pom.artifactId}-${pom.version}/repository/conf/etc/bundle-config/com.typesafe.config/ + + 644 + From b24ec4e36ae4742cdb5b5a611afd1ff22c1d2d68 Mon Sep 17 00:00:00 2001 From: warunalakshitha Date: Thu, 29 Sep 2016 01:02:43 +0530 Subject: [PATCH 07/10] Upgrade to carbon 4.4.9 --- modules/p2-profile-gen/carbon.product | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/p2-profile-gen/carbon.product b/modules/p2-profile-gen/carbon.product index d57a7d3e..e86f7d12 100644 --- a/modules/p2-profile-gen/carbon.product +++ b/modules/p2-profile-gen/carbon.product @@ -1,7 +1,7 @@ - + @@ -13,7 +13,7 @@ - + From e76129ede3526ab518b55e97f1069795d22fe3af Mon Sep 17 00:00:00 2001 From: warunalakshitha Date: Thu, 29 Sep 2016 01:12:15 +0530 Subject: [PATCH 08/10] Upgrade iot product to carbon 4.4.9 and latest component versions --- pom.xml | 89 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 50 insertions(+), 39 deletions(-) diff --git a/pom.xml b/pom.xml index 19ecdf55..14d8ca24 100644 --- a/pom.xml +++ b/pom.xml @@ -748,12 +748,12 @@ ${wss4j.security.common.version} - org.apache.ws.commons.axiom + org.apache.ws.commons.axiom.wso2 axiom-api ${axiom-api.version} - org.apache.ws.commons.axiom + org.apache.ws.commons.axiom.wso2 axiom-impl ${axiom-api.version} @@ -793,8 +793,8 @@ ${bcpkix-jdk15on.version} - org.bouncycastle - bcprov-jdk15on + org.wso2.orbit.org.bouncycastle + bcpkix-jdk15on ${bcpkix-jdk15on.version} @@ -1026,7 +1026,7 @@ - 4.4.3 + 4.4.9 [4.4.0, 4.5.0) 1.5.4 @@ -1035,7 +1035,7 @@ 1.3 - 0.12.0 + 0.12.6 1.5.2 1.5.2 1.5.2 @@ -1062,43 +1062,55 @@ 1.1.1 - 4.4.9 + 4.5.4 - 4.6.0 + 4.7.0 - 5.0.7 - [5.0.7, 6.0.0) + 5.2.0 + [5.2.0, 6.0.0) + 5.1.1 + 5.1.1 + 5.1.1 + 5.1.2 + 5.1.2 + 5.1.1 + 5.1.2 + 5.1.1 + 5.1.1 + 5.1.2 + + + 1.0.2 - 4.5.0 + 4.6.0 - 4.4.8 - + 4.5.6 - 4.5.8 + 4.6.4 - 1.2.1 - [1.1.3, 2.0.0) + 1.2.2-SNAPSHOT + [1.1.1, 2.0.0) 1.0.0-SNAPSHOT - 2.2.1 + 2.2.2-SNAPSHOT - 5.0.5 - 1.8.10.wso2v2 + 6.0.5 + (5.0.0,7.0.0] - 4.5.1 + 4.6.6 - 5.0.12-alpha + 5.1.3 7.0.59.wso2v1 @@ -1113,23 +1125,24 @@ 1.1.0-wso2v17 - 1.0.6-ALPHA + 1.2.8 1.0.0-wso2v3 - 1.0.18 - 1.0.18 - 2.0.13-alpha - 4.3.4 + 2.0.2 + 2.0.2 + 2.1.4 + 4.3.6 3.1.0.wso2v2 1.6.17 2.0.0 - 1.2.14 + 1.2.11.wso2v10 + 1.2.11.wso2v10 1.2.17 3.0.5.RELEASE 2.1.0.RELEASE 2.2.8 1.3.18 - 1.49 + 1.52.0.wso2v2 3.0.21 1.7 2.2 @@ -1137,17 +1150,18 @@ 1.1.1 2.3.1 + + 1.0.1 + - 1.1.1 - 1.1.1 + 1.2.2 + 1.2.2 - 1.4.1 + 1.4.2 1.0.0-wso2v3 - 4.3.1.wso2v2 - 3.0.4.wso2v1 3.0.4.wso2v1 @@ -1160,12 +1174,9 @@ 3.1.2 1.2.0 - - 1.0.2 - 4.3.1.wso2v2 - [4.3.1, 5.0.0) - 4.3.3.wso2v1 + 4.5.2 + 4.4.1 1.1.wso2v1 0.9.1 @@ -1174,7 +1185,7 @@ 1.0.2 - 1.0.0 + 1.0.1-SNAPSHOT From eaf8da454852af7cc81904ce5e6d1b27a975381f Mon Sep 17 00:00:00 2001 From: warunalakshitha Date: Thu, 29 Sep 2016 01:13:40 +0530 Subject: [PATCH 09/10] Upgrade iot product features to latest identity and carbon version --- modules/p2-profile-gen/pom.xml | 337 ++++++++++++++++----------------- 1 file changed, 168 insertions(+), 169 deletions(-) diff --git a/modules/p2-profile-gen/pom.xml b/modules/p2-profile-gen/pom.xml index 953b694e..73da3a1a 100644 --- a/modules/p2-profile-gen/pom.xml +++ b/modules/p2-profile-gen/pom.xml @@ -249,91 +249,91 @@ - org.wso2.carbon.identity:org.wso2.carbon.security.mgt.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.security.mgt.feature:${carbon.identity.framework.version} - org.wso2.carbon.identity:org.wso2.carbon.um.ws.service.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.um.ws.service.feature:${identity.user.ws.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.oauth.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.oauth.feature:${identity.inbound.auth.oauth.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.provider.server.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.provider.server.feature:${identity.inbound.auth.openid.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.thrift.authentication.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.thrift.authentication.feature:${carbon.identity.framework.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.core.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.core.feature:${carbon.identity.framework.version} - org.wso2.carbon.identity:org.wso2.carbon.idp.mgt.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.idp.mgt.feature:${carbon.identity.framework.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.application.authenticator.basicauth.server.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.application.authenticator.basicauth.server.feature:${identity.local.auth.basicauth.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.application.authentication.framework.server.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.application.authentication.framework.server.feature:${carbon.identity.framework.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.authenticator.saml2.sso.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.authenticator.saml2.sso.feature:${identity.carbon.auth.saml2.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.sso.saml.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.sso.saml.feature:${identity.inbound.auth.saml.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.user.profile.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.user.profile.feature:${carbon.identity.framework.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.application.mgt.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.application.mgt.feature:${carbon.identity.framework.version} - org.wso2.carbon.identity:org.wso2.carbon.claim.mgt.server.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.claim.mgt.server.feature:${carbon.identity.framework.version} - org.wso2.carbon.identity:org.wso2.carbon.claim.mgt.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.claim.mgt.feature:${carbon.identity.framework.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.oauth.ui.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.oauth.ui.feature:${identity.inbound.auth.oauth.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.notification.mgt.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.notification.mgt.feature:${carbon.identity.framework.version} - org.wso2.carbon.identity:org.wso2.carbon.user.mgt.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.user.mgt.feature:${carbon.identity.framework.version} - org.wso2.carbon.identity:org.wso2.carbon.directory.service.mgr.server.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.directory.service.mgr.server.feature:${carbon.identity.framework.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.user.registration.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.user.registration.feature:${carbon.identity.framework.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.xacml.server.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.xacml.server.feature:${carbon.identity.framework.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.application.authenticator.requestpath.basicauth.server.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.application.authenticator.requestpath.basicauth.server.feature:${identity.outbound.auth.requestpath.basicauth.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.application.authenticator.requestpath.oauth.server.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.application.authenticator.requestpath.oauth.server.feature:${identity.outbound.auth.requestpath.oauth.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.application.authenticator.basicauth.server.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.application.authenticator.basicauth.server.feature:${identity.local.auth.basicauth.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.application.authenticator.samlsso.server.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.application.authenticator.samlsso.server.feature:${identity.outbound.auth.samlsso.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.authenticator.saml2.sso.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.authenticator.saml2.sso.feature:${identity.carbon.auth.saml2.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.thrift.authentication.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.thrift.authentication.feature:${carbon.identity.framework.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.authenticator.mutualssl.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.authenticator.mutualssl.feature:${identity.carbon.auth.mutual.ssl.version} @@ -463,25 +463,25 @@ - org.wso2.carbon.identity:org.wso2.carbon.identity.authenticator.saml2.sso.server.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.authenticator.saml2.sso.server.feature:${identity.carbon.auth.saml2.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.authenticator.saml2.sso.ui.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.authenticator.saml2.sso.ui.feature:${identity.carbon.auth.saml2.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.application.mgt.server.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.application.mgt.server.feature:${carbon.identity.framework.version} - org.wso2.carbon.identity:org.wso2.carbon.idp.mgt.server.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.idp.mgt.server.feature:${carbon.identity.framework.version} - org.wso2.carbon.identity:org.wso2.carbon.directory.service.mgr.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.directory.service.mgr.feature:${carbon.identity.framework.version} - org.wso2.carbon.identity:org.wso2.carbon.identity.user.registration.server.feature:${carbon.identity.version} + org.wso2.carbon.identity:org.wso2.carbon.identity.user.registration.server.feature:${carbon.identity.framework.version} @@ -549,15 +549,15 @@ org.wso2.carbon.mediation:org.wso2.carbon.mediation.configadmin.feature:${carbon.mediation.version} - + org.wso2.carbon.mediation:org.wso2.carbon.relay.feature:${carbon.mediation.version} - + org.wso2.carbon.commons:org.wso2.carbon.system.statistics.feature:${carbon.commons.version} @@ -664,7 +664,7 @@ org.wso2.carbon.analytics:org.wso2.carbon.analytics.stream.persistence.server.feature:${carbon.analytics.version} - org.wso2.carbon.analytics-common:org.wso2.carbon.event.execution.manager.feature:${carbon.analytics.common.version} + org.wso2.carbon.analytics-common:org.wso2.carbon.event.template.manager.feature:${carbon.analytics.common.version} org.wso2.carbon.analytics-common:org.wso2.carbon.event.output.adapter.server.feature:${carbon.analytics.common.version} @@ -1023,109 +1023,109 @@ org.wso2.carbon.security.mgt.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.um.ws.service.feature.group - ${carbon.identity.version} + ${identity.user.ws.version} org.wso2.carbon.identity.oauth.server.feature.group - ${carbon.identity.version} + ${identity.inbound.auth.oauth.version} org.wso2.carbon.identity.provider.server.feature.group - ${carbon.identity.version} + ${identity.inbound.auth.openid.version} org.wso2.carbon.identity.thrift.authentication.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.core.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.idp.mgt.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.user.mgt.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.directory.service.mgr.server.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.application.authenticator.basicauth.server.feature.group - ${carbon.identity.version} + ${identity.local.auth.basicauth.version} org.wso2.carbon.identity.application.authentication.framework.server.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.authenticator.saml2.sso.feature.group - ${carbon.identity.version} + ${identity.carbon.auth.saml2.version} org.wso2.carbon.identity.sso.saml.feature.group - ${carbon.identity.version} + ${identity.inbound.auth.saml.version} org.wso2.carbon.identity.user.profile.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.application.mgt.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.claim.mgt.server.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.claim.mgt.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.oauth.ui.feature.group - ${carbon.identity.version} + ${identity.inbound.auth.oauth.version} org.wso2.carbon.identity.notification.mgt.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.xacml.server.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.user.registration.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.application.authenticator.basicauth.server.feature.group - ${carbon.identity.version} + ${identity.local.auth.basicauth.version} org.wso2.carbon.identity.application.authenticator.requestpath.basicauth.server.feature.group - ${carbon.identity.version} + ${identity.outbound.auth.requestpath.basicauth.version} org.wso2.carbon.identity.application.authenticator.requestpath.oauth.server.feature.group - ${carbon.identity.version} + ${identity.outbound.auth.requestpath.oauth.version} org.wso2.carbon.identity.application.authenticator.samlsso.server.feature.group - ${carbon.identity.version} + ${identity.outbound.auth.samlsso.version} @@ -1276,32 +1276,32 @@ org.wso2.carbon.identity.authenticator.saml2.sso.server.feature.group - ${carbon.identity.version} + ${identity.carbon.auth.saml2.version} org.wso2.carbon.identity.authenticator.saml2.sso.ui.feature.group - ${carbon.identity.version} + ${identity.carbon.auth.saml2.version} org.wso2.carbon.identity.application.mgt.server.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.directory.service.mgr.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.idp.mgt.server.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.user.registration.server.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.oauth.feature.group - ${carbon.identity.version} + ${identity.inbound.auth.oauth.version} @@ -1504,7 +1504,7 @@ ${carbon.analytics.version} - org.wso2.carbon.event.execution.manager.feature.group + org.wso2.carbon.event.template.manager.feature.group ${carbon.analytics.common.version} @@ -1613,19 +1613,19 @@ org.wso2.carbon.um.ws.service.feature.group - ${carbon.identity.version} + ${identity.user.ws.version} org.wso2.carbon.user.mgt.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.core.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.core.ui.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.registry.ws.feature.group @@ -1804,10 +1804,10 @@ org.wso2.carbon.mediation.initializer.feature.group ${carbon.mediation.version} - + org.wso2.carbon.mediation.admin.feature.group ${carbon.mediation.version} @@ -1820,10 +1820,10 @@ org.wso2.carbon.mediation.configadmin.feature.group ${carbon.mediation.version} - + org.wso2.carbon.application.mgt.server.feature.group ${carbon.commons.version} @@ -1842,11 +1842,11 @@ org.wso2.carbon.security.mgt.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.security.mgt.server.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.service.mgt.server.feature.group @@ -1898,7 +1898,7 @@ org.wso2.carbon.identity.provider.server.feature.group - ${carbon.identity.version} + ${identity.inbound.auth.openid.version} org.wso2.carbon.registry.community.features.feature.group @@ -1906,11 +1906,11 @@ org.wso2.carbon.identity.oauth.feature.group - ${carbon.identity.version} + ${identity.inbound.auth.oauth.version} org.wso2.carbon.identity.user.registration.server.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.deployment.synchronizer.feature.group @@ -1942,23 +1942,23 @@ org.wso2.carbon.user.mgt.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.core.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.um.ws.service.server.feature.group - ${carbon.identity.version} + ${identity.user.ws.version} org.wso2.carbon.um.ws.service.client.feature.group - ${carbon.identity.version} + ${identity.user.ws.version} org.wso2.carbon.directory.service.mgr.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} @@ -1983,7 +1983,7 @@ org.wso2.carbon.identity.application.authentication.framework.server.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.tenant.mgt.common.server.feature.group @@ -2019,7 +2019,7 @@ org.wso2.carbon.identity.user.profile.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} @@ -2127,15 +2127,15 @@ org.wso2.carbon.identity.notification.mgt.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.xacml.server.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.thrift.authentication.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.tenant.common.feature.group @@ -2156,20 +2156,19 @@ org.wso2.carbon.identity.application.authentication.framework.server.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.tenant.mgt.common.server.feature.group ${carbon.commons.version} - org.wso2.carbon.identity.application.authenticator.basicauth.server.feature.group - - ${carbon.identity.version} + org.wso2.carbon.identity.application.authenticator.basicauth.server.feature.group + ${identity.local.auth.basicauth.version} org.wso2.carbon.identity.application.authenticator.samlsso.server.feature.group - ${carbon.identity.version} + ${identity.outbound.auth.samlsso.version} org.wso2.carbon.core.common.feature.group @@ -2177,7 +2176,7 @@ org.wso2.carbon.identity.application.mgt.server.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.core.server.feature.group @@ -2227,14 +2226,14 @@ org.wso2.carbon.mediation.configadmin.feature.group ${carbon.mediation.version} - + + org.wso2.carbon.application.mgt.server.feature.group ${carbon.commons.version} @@ -2257,11 +2256,11 @@ org.wso2.carbon.security.mgt.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.security.mgt.server.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.service.mgt.server.feature.group @@ -2303,7 +2302,7 @@ org.wso2.carbon.identity.provider.server.feature.group - ${carbon.identity.version} + ${identity.inbound.auth.openid.version} org.wso2.carbon.event.server.feature.group @@ -2323,11 +2322,11 @@ org.wso2.carbon.identity.oauth.feature.group - ${carbon.identity.version} + ${identity.inbound.auth.oauth.version} org.wso2.carbon.identity.user.registration.server.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} @@ -2360,31 +2359,31 @@ org.wso2.carbon.user.mgt.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.core.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.um.ws.service.server.feature.group - ${carbon.identity.version} + ${identity.user.ws.version} org.wso2.carbon.um.ws.service.client.feature.group - ${carbon.identity.version} + ${identity.user.ws.version} org.wso2.carbon.directory.service.mgr.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.authenticator.saml2.sso.server.feature.group - ${carbon.identity.version} + ${identity.carbon.auth.saml2.version} org.wso2.carbon.identity.authenticator.saml2.sso.ui.feature.group - ${carbon.identity.version} + ${identity.carbon.auth.saml2.version} org.wso2.carbon.apimgt.core.feature.group @@ -2408,7 +2407,7 @@ org.wso2.carbon.idp.mgt.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.ndatasource.feature.group @@ -2432,7 +2431,7 @@ org.wso2.carbon.identity.user.profile.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.apimgt.application.extension.feature.group @@ -2627,15 +2626,15 @@ org.wso2.carbon.identity.notification.mgt.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.xacml.server.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.thrift.authentication.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.core.common.feature.group @@ -2643,11 +2642,11 @@ org.wso2.carbon.user.mgt.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.user.profile.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.core.server.feature.group @@ -2714,15 +2713,15 @@ org.wso2.carbon.mediation.configadmin.feature.group ${carbon.mediation.version} - + - + org.wso2.carbon.application.mgt.server.feature.group ${carbon.commons.version} @@ -2745,11 +2744,11 @@ org.wso2.carbon.security.mgt.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.security.mgt.server.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.service.mgt.server.feature.group @@ -2808,24 +2807,24 @@ org.wso2.carbon.identity.provider.server.feature.group - ${carbon.identity.version} + ${identity.inbound.auth.openid.version} org.wso2.carbon.identity.oauth.feature.group - ${carbon.identity.version} + ${identity.inbound.auth.oauth.version} org.wso2.carbon.identity.application.authenticator.basicauth.server.feature.group - ${carbon.identity.version} + ${identity.local.auth.basicauth.version} org.wso2.carbon.identity.application.authenticator.samlsso.server.feature.group - ${carbon.identity.version} + ${identity.outbound.auth.samlsso.version} org.wso2.carbon.identity.application.authentication.framework.server.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.tenant.mgt.common.server.feature.group @@ -2833,7 +2832,7 @@ org.wso2.carbon.identity.user.registration.server.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.deployment.synchronizer.feature.group @@ -2905,35 +2904,35 @@ org.wso2.carbon.user.mgt.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.core.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.um.ws.service.server.feature.group - ${carbon.identity.version} + ${identity.user.ws.version} org.wso2.carbon.um.ws.service.client.feature.group - ${carbon.identity.version} + ${identity.user.ws.version} org.wso2.carbon.directory.service.mgr.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.claim.mgt.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.authenticator.saml2.sso.server.feature.group - ${carbon.identity.version} + ${identity.carbon.auth.saml2.version} org.wso2.carbon.identity.authenticator.saml2.sso.ui.feature.group - ${carbon.identity.version} + ${identity.carbon.auth.saml2.version} org.wso2.carbon.webapp.mgt.feature.group @@ -3171,15 +3170,15 @@ org.wso2.carbon.identity.notification.mgt.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.xacml.server.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.thrift.authentication.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.core.common.feature.group @@ -3187,11 +3186,11 @@ org.wso2.carbon.user.mgt.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.user.profile.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.core.server.feature.group @@ -3258,14 +3257,14 @@ org.wso2.carbon.mediation.configadmin.feature.group ${carbon.mediation.version} - + + org.wso2.carbon.application.mgt.server.feature.group ${carbon.commons.version} @@ -3288,11 +3287,11 @@ org.wso2.carbon.security.mgt.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.security.mgt.server.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.service.mgt.server.feature.group @@ -3348,24 +3347,24 @@ org.wso2.carbon.identity.provider.server.feature.group - ${carbon.identity.version} + ${identity.inbound.auth.openid.version} org.wso2.carbon.identity.oauth.feature.group - ${carbon.identity.version} + ${identity.inbound.auth.oauth.version} org.wso2.carbon.identity.application.authenticator.basicauth.server.feature.group - ${carbon.identity.version} + ${identity.local.auth.basicauth.version} org.wso2.carbon.identity.application.authenticator.samlsso.server.feature.group - ${carbon.identity.version} + ${identity.outbound.auth.samlsso.version} org.wso2.carbon.identity.application.authentication.framework.server.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.tenant.mgt.common.server.feature.group @@ -3373,7 +3372,7 @@ org.wso2.carbon.identity.user.registration.server.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.deployment.synchronizer.feature.group @@ -3445,35 +3444,35 @@ org.wso2.carbon.user.mgt.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.core.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.um.ws.service.server.feature.group - ${carbon.identity.version} + ${identity.user.ws.version} org.wso2.carbon.um.ws.service.client.feature.group - ${carbon.identity.version} + ${identity.user.ws.version} org.wso2.carbon.directory.service.mgr.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.claim.mgt.feature.group - ${carbon.identity.version} + ${carbon.identity.framework.version} org.wso2.carbon.identity.authenticator.saml2.sso.server.feature.group - ${carbon.identity.version} + ${identity.carbon.auth.saml2.version} org.wso2.carbon.identity.authenticator.saml2.sso.ui.feature.group - ${carbon.identity.version} + ${identity.carbon.auth.saml2.version} org.wso2.carbon.webapp.mgt.feature.group From 6ef4bb4a9b7c46167a25f9a55a3b8fb0ac8f2b3d Mon Sep 17 00:00:00 2001 From: warunalakshitha Date: Thu, 29 Sep 2016 01:18:10 +0530 Subject: [PATCH 10/10] Remove org.wso2.carbon.event.server featre from p2 since feature has been removed from carbon commons --- modules/p2-profile-gen/pom.xml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/modules/p2-profile-gen/pom.xml b/modules/p2-profile-gen/pom.xml index 73da3a1a..f0cf6d56 100644 --- a/modules/p2-profile-gen/pom.xml +++ b/modules/p2-profile-gen/pom.xml @@ -212,9 +212,9 @@ org.wso2.carbon.commons:org.wso2.carbon.logging.mgt.feature:${carbon.commons.version} - + org.wso2.carbon.commons:org.wso2.carbon.ntask.feature:${carbon.commons.version} @@ -983,10 +983,10 @@ org.wso2.carbon.logging.mgt.feature.group ${carbon.commons.version} - + org.wso2.carbon.ntask.feature.group ${carbon.commons.version} @@ -1238,10 +1238,10 @@ caramel.feature.group 1.0.1 - - org.wso2.carbon.event.feature.group + org.wso2.carbon.core.feature.group @@ -1884,10 +1884,10 @@ org.wso2.carbon.relay.server.feature.group ${carbon.mediation.version} - + org.wso2.carbon.event.common.feature.group ${carbon.commons.version} @@ -2304,10 +2304,10 @@ org.wso2.carbon.identity.provider.server.feature.group ${identity.inbound.auth.openid.version} - + org.wso2.carbon.event.common.feature.group ${carbon.commons.version} @@ -2789,10 +2789,10 @@ org.wso2.carbon.relay.server.feature.group ${carbon.mediation.version} - + org.wso2.carbon.event.common.feature.group ${carbon.commons.version} @@ -3329,10 +3329,10 @@ org.wso2.carbon.relay.server.feature.group ${carbon.mediation.version} - + org.wso2.carbon.event.common.feature.group ${carbon.commons.version}