ranger-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sneet...@apache.org
Subject [1/2] ARGUS-69:Support Oracle database for storing policy and audit information
Date Fri, 19 Sep 2014 03:54:06 GMT
Repository: incubator-argus
Updated Branches:
  refs/heads/master 9660b4e5b -> a0a18007f


http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/scripts/install.sh
----------------------------------------------------------------------
diff --git a/security-admin/scripts/install.sh b/security-admin/scripts/install.sh
index 35eb94e..02848c1 100755
--- a/security-admin/scripts/install.sh
+++ b/security-admin/scripts/install.sh
@@ -4,7 +4,7 @@
 #
 # XASecure PolicyManager Installation Script
 # 
-# This script will install policymanager webapplication under tomcat and also, initialize the mysql database with xasecure users/tables.
+# This script will install policymanager webapplication under tomcat and also, initialize the database with xasecure users/tables.
 #
 # (c) 2013,2014 XASecure
 #
@@ -19,7 +19,7 @@ if [ ! $? = "0" ];then
 	exit 1; 
 fi
 
-MYSQL_HOST="${db_host}"
+DB_HOST="${db_host}"
 
 usage() {
   [ "$*" ] && echo "$0: $*"
@@ -71,8 +71,8 @@ getPropertyFromFile(){
 
 #Update Properties to File
 #$1 -> propertyName $2 -> newPropertyValue $3 -> fileName
-updatePropertyToFile(){		
-	sed -i 's@^'$1'=[^ ]*$@'$1'='$2'@g' $3	
+updatePropertyToFile(){
+	sed -i 's@^'$1'=[^ ]*$@'$1'='$2'@g' $3
 	#validate=`sed -i 's/^'$1'=[^ ]*$/'$1'='$2'/g' $3`	#for validation
 	validate=$(sed '/^\#/d' $3 | grep "^$1"  | tail -n 1 | cut -d "=" -f2-) # for validation
 	#echo 'V1:'$validate
@@ -104,6 +104,14 @@ init_variables(){
 
 	WEBAPP_ROOT=${INSTALL_DIR}/ews/webapp
 	
+	DB_FLAVOR=`echo $DB_FLAVOR | tr '[:lower:]' '[:upper:]'`
+	if [ "${DB_FLAVOR}" == "" ]
+	then
+		DB_FLAVOR="MYSQL"
+	fi
+	log "[I] DB_FLAVOR=${DB_FLAVOR}"
+
+	getPropertyFromFile 'db_root_user' $PROPFILE db_root_user
 	getPropertyFromFile 'db_root_password' $PROPFILE db_user
 	getPropertyFromFile 'db_user' $PROPFILE db_user
 	getPropertyFromFile 'db_password' $PROPFILE db_password
@@ -128,23 +136,46 @@ wait_for_tomcat_shutdown() {
 	done
 }
 
-check_mysql_version() {
-	if is_command ${MYSQL_BIN} ; then
-		log "[I] '${MYSQL_BIN}' command found"
-	else
-		log "[E] '${MYSQL_BIN}' command not found"
+check_db_version() {
+    if [ "${DB_FLAVOR}" == "MYSQL" ]
+    then
+		if is_command ${SQL_COMMAND_INVOKER} ; then
+			log "[I] '${SQL_COMMAND_INVOKER}' command found"
+		else
+			log "[E] '${SQL_COMMAND_INVOKER}' command not found"
 		exit 1;
+		fi
 	fi
+	if [ "${DB_FLAVOR}" == "ORACLE" ]
+    then
+        if is_command ${SQL_COMMAND_INVOKER} ; then
+            log "[I] '${SQL_COMMAND_INVOKER}' command found"
+        else
+            log "[E] '${SQL_COMMAND_INVOKER}' command not found"
+        exit 1;
+        fi
+    fi
 }
 
-check_mysql_connector() {
-	log "[I] Checking MYSQL CONNECTOR FILE : $MYSQL_CONNECTOR_JAR" 
-	if test -f "$MYSQL_CONNECTOR_JAR"; then
-		log "[I] MYSQL CONNECTOR FILE : $MYSQL_CONNECTOR_JAR file found" 
-	else
-		log "[E] MYSQL CONNECTOR FILE : $MYSQL_CONNECTOR_JAR does not exists" ; exit 1;
+check_db_connector() {
+    if [ "${DB_FLAVOR}" == "MYSQL" ]
+	then
+		log "[I] Checking MYSQL CONNECTOR FILE : ${SQL_CONNECTOR_JAR}"
+		if test -f "$SQL_CONNECTOR_JAR"; then
+			log "[I] MYSQL CONNECTOR FILE : $SQL_CONNECTOR_JAR file found"
+		else
+			log "[E] MYSQL CONNECTOR FILE : $SQL_CONNECTOR_JAR does not exists" ; exit 1;
+		fi
 	fi
-
+    if [ "${DB_FLAVOR}" == "ORACLE" ]
+    then
+        log "[I] Checking ORACLE CONNECTOR FILE : ${SQL_CONNECTOR_JAR}"
+        if test -f "${SQL_CONNECTOR_JAR}"; then
+			log "[I] ORACLE CONNECTOR FILE : ${SQL_CONNECTOR_JAR} file found"
+        else
+			log "[E] ORACLE CONNECTOR FILE : ${SQL_CONNECTOR_JAR} does not exists" ; exit 1;
+		fi
+    fi
 }
 check_java_version() {
 	if is_command ${JAVA_BIN} ; then
@@ -180,13 +211,23 @@ sanity_check_files() {
 		log "[I] $war_file file found" 
 	else
 		log "[E] $war_file does not exists" ; exit 1;
+    fi
+	if [ "${DB_FLAVOR}" == "MYSQL" ]
+    then
+		if test -f $mysql_core_file; then
+			log "[I] $mysql_core_file file found"
+		else
+			log "[E] $mysql_core_file does not exists" ; exit 1;
+		fi
+	fi
+	if [ "${DB_FLAVOR}" == "ORACLE" ]
+    then
+        if test -f ${oracle_core_file}; then
+			log "[I] ${oracle_core_file} file found"
+        else
+            log "[E] ${oracle_core_file} does not exists" ; exit 1;
         fi
-
-	if test -f $db_core_file; then
-		log "[I] $db_core_file file found" 
-	else
-		log "[E] $db_core_file does not exists" ; exit 1;
-        fi
+    fi
 }
 
 create_rollback_point() {
@@ -196,69 +237,150 @@ create_rollback_point() {
     cp "$APP" "$BAK_FILE"
 }
 
-create_mysql_user(){
-	check_mysql_password
-	check_mysql_user_password
-
-	log "[I] Creating MySQL user '$db_user' (using root priviledges)"
-	
-	for thost in '%' localhost
-	do
-		usercount=`$MYSQL_BIN -B -u root --password="$db_root_password" -h $MYSQL_HOST --skip-column-names -e "select count(*) from mysql.user where user = '$db_user' and host = '$thost';"`
-		if  [ ${usercount} -eq 0 ]
+create_db_user(){
+	check_db_user_password
+	strError="ERROR"
+    if [ "${DB_FLAVOR}" == "MYSQL" ]
+    then
+		log "[I] Creating ${DB_FLAVOR} user '${db_user}' (using root priviledges)"
+		for thost in '%' localhost
+		do
+			usercount=`$SQL_COMMAND_INVOKER -B -u "$db_root_user" --password="$db_root_password" -h $DB_HOST --skip-column-names -e "select count(*) from mysql.user where user = '$db_user' and host = '$thost';"`
+			if  [ ${usercount} -eq 0 ]
+			then
+				$SQL_COMMAND_INVOKER -B -u "$db_root_user" --password="$db_root_password" -h $DB_HOST -e "create user '$db_user'@'$thost' identified by '$db_password';"
+				log "[I] Creating user '$db_user' for host $thost done"
+			fi
+			dbquery="GRANT ALL ON *.* TO '$db_user'@'$thost' ;
+			grant all privileges on *.* to '$db_user'@'$thost' with grant option;
+			FLUSH PRIVILEGES;"
+			echo "${dbquery}" | $SQL_COMMAND_INVOKER -u "$db_root_user" --password="$db_root_password" -h $DB_HOST
+			check_ret_status $? "'$DB_FLAVOR' create user failed"
+		done
+		log "[I] Creating $DB_FLAVOR user '$db_user' (using root priviledges) DONE"
+	fi
+	if [ "${DB_FLAVOR}" == "ORACLE" ]
+    then
+		#check user exist or not
+		result3=`${SQL_COMMAND_INVOKER} -L -S "${db_root_user}"/"\"${db_root_password}\""@"${DB_HOST}" AS SYSDBA <<< "select UPPER(username) from all_users where UPPER(username)=UPPER('${db_user}');"`
+		username=`echo ${db_user} | tr '[:lower:]' '[:upper:]'`
+		#if does not contains username so create user
+		if test "${result3#*$username}" == "$result3"
 		then
-			$MYSQL_BIN -B -u root --password="$db_root_password" -h $MYSQL_HOST -e "create user '$db_user'@'$thost' identified by '$db_password';"
+			#create user
+			result4=`${SQL_COMMAND_INVOKER} -L -S "${db_root_user}"/"\"${db_root_password}\""@"${DB_HOST}" AS SYSDBA <<< "create user ${db_user} identified by \"${db_password}"\;"`
+			result3=`${SQL_COMMAND_INVOKER} -L -S "${db_root_user}"/"\"${db_root_password}\""@"${DB_HOST}" AS SYSDBA <<< "select UPPER(username) from all_users where UPPER(username)=UPPER('${db_user}');"`
+			username=`echo ${db_user} | tr '[:lower:]' '[:upper:]'`
+			#if user is not created print error message
+			if test "${result3#*$username}" == "$result3"
+			then
+				log "[E] Creating User: ${db_user} Failed";
+				log "[E] $result4"
+				exit 1
+			else
+				log "[I] Creating User: ${db_user} Success";
+			fi
+	    fi
+        result5=`${SQL_COMMAND_INVOKER} -L -S "${db_root_user}"/"\"${db_root_password}\""@"${DB_HOST}" AS SYSDBA <<< "GRANT connect,resource,create view,sysdba TO ${db_user};"`
+        if test "${result5#*$strError}" == "$result5"
+		then
+			log "[I] Granting User: ${db_user} Success";
+		else
+			log "[E] Granting User: ${db_user} Failed";
+			log "[E] $result5"
+			exit 1
 		fi
-		
-		mysqlquery="GRANT ALL ON *.* TO '$db_user'@'$thost' ; 
-		grant all privileges on *.* to '$db_user'@'$thost' with grant option;
-		FLUSH PRIVILEGES;"
-		
-		echo "${mysqlquery}" | $MYSQL_BIN -u root --password="$db_root_password" -h $MYSQL_HOST
-		check_ret_status $? "MySQL create user failed"
-		
-	done
-	log "[I] Creating MySQL user '$db_user' (using root priviledges) DONE"
+		log "[I] Creating $DB_FLAVOR user '${db_user}' (using sysdba priviledges) DONE"
+    fi
 }
-check_mysql_password () {
+
+check_db_admin_password () {
 	count=0
-	log "[I] Checking MYSQL root password"
-	
-	msg=`$MYSQL_BIN -u root --password="$db_root_password" -h $MYSQL_HOST -s -e "select version();" 2>&1`
-	cmdStatus=$?
+	msg=''
+	cmdStatus=''
+	strError="ERROR"
+	if [ "${DB_FLAVOR}" == "MYSQL" ]
+    then
+		log "[I] Checking ${DB_FLAVOR} $db_root_user password"
+		msg=`$SQL_COMMAND_INVOKER -u "$db_root_user" --password="$db_root_password" -h "$DB_HOST" -s -e "select version();" 2>&1`
+		cmdStatus=$?
+    fi
+
+	if [ "${DB_FLAVOR}" == "ORACLE" ]
+    then
+		log "[I] Checking ${DB_FLAVOR} $db_root_user password"
+		msg=`echo "select 1 from dual;" | $SQL_COMMAND_INVOKER  -L -S "${db_root_user}"/"\"${db_root_password}\""@"${DB_HOST}" AS SYSDBA>&1`
+		cmdStatus=$?
+    fi
+	if test "${msg#*$strError}" != "$msg"
+	then
+		cmdStatus=1
+	else
+		cmdStatus=0 # $substring is not in $string
+    fi
 	while :
 	do	
 		if  [  $cmdStatus != 0 ]; then
 			if [ $count != 0 ]
 			then
-				log "[I] COMMAND: mysql -u root --password=..... -h $MYSQL_HOST : FAILED with error message:			      						\n*******************************************\n${msg}\n*******************************************\n"
+				if [ "${DB_FLAVOR}" == "MYSQL" ]
+				then
+					log "[I] COMMAND: mysql -u $db_root_user --password=...... -h $DB_HOST : FAILED with error message:"
+			    fi
+				if [ "${DB_FLAVOR}" == "ORACLE" ]
+	            then
+	                log "[I] COMMAND: sqlplus  $db_root_user/...... @$DB_HOST AS SYSDBA : FAILED with error message:"
+	            fi
+				log "*******************************************${sg}*******************************************"
 			fi
 			if [ $count -gt 2 ]
 			then
-				log "[E] Unable to continue as mysql connectivity fails."
+				log "[E] Unable to continue as db connectivity fails."
 				exit 1
 			fi
 		    trap 'stty echo; exit 1' 2 3 15
-			printf "Please enter password for mysql user-id, root@${MYSQL_HOST} : "
+            if [ "${DB_FLAVOR}" == "MYSQL" ]
+		    then
+				printf "Please enter password for mysql user-id, $db_root_user@${DB_HOST} : "
+            fi
+			if [ "${DB_FLAVOR}" == "ORACLE" ]
+			then
+				log="[msg] ${msg}"
+				printf "Please enter password for oracle user-id, $db_root_user@${DB_HOST} AS SYSDBA: "
+			fi
 			stty -echo
 			read db_root_password
 			stty echo
 			printf "\n"
 			trap '' 2 3 15
 			count=`expr ${count} + 1`
-			msg=`$MYSQL_BIN -u root --password="$db_root_password" -h $MYSQL_HOST -s -e "select version();" 2>&1`
-			cmdStatus=$?
+			if [ "${DB_FLAVOR}" == "MYSQL" ]
+			then
+				msg=`$SQL_COMMAND_INVOKER -u "$db_root_user" --password="$db_root_password" -h "$DB_HOST" -s -e "select version();" 2>&1`
+				cmdStatus=$?
+			fi
+			if [ "${DB_FLAVOR}" == "ORACLE" ]
+			then
+				msg=`echo "select 1 from dual;" | $SQL_COMMAND_INVOKER  -L -S "${db_root_user}"/"\"${db_root_password}\""@"{$DB_HOST}" AS SYSDBA >&1`
+				cmdStatus=$?
+			fi
+			if test "${msg#*$strError}" != "$msg"
+		    then
+				cmdStatus=1
+			else
+				cmdStatus=0 # $substring is not in $string
+		    fi
 	   	else
-			log "[I] Checking MYSQL root password DONE"
+			log "[I] Checking DB password DONE"
 			break;
 		fi
 	done
 	return 0;
 }
 
-check_mysql_user_password() {
+check_db_user_password() {
 	count=0
-	muser=${db_user}@${MYSQL_HOST}
+	muser=${db_user}@${DB_HOST}
 	while [ "${db_password}" = "" ]
 	do
 		if [ $count -gt 0 ]
@@ -281,9 +403,9 @@ check_mysql_user_password() {
 }
 
 
-check_mysql_audit_user_password() {
+check_audit_user_password() {
 	count=0
-	muser=${audit_db_user}@${MYSQL_HOST}
+	muser=${audit_db_user}@${DB_HOST}
 	while [ "${audit_db_password}" = "" ]
 	do
 		if [ $count -gt 0 ]
@@ -307,73 +429,237 @@ check_mysql_audit_user_password() {
 
 upgrade_db() {
 	log "[I] - starting upgradedb ... "
+	if [ "${DB_FLAVOR}" == "MYSQL" ]
+    then
+		DBVERSION_CATALOG_CREATION=db/create_dbversion_catalog.sql
 
-	DBVERSION_CATALOG_CREATION=db/create_dbversion_catalog.sql
+		#mysqlexec="${SQL_COMMAND_INVOKER} -u "${db_user}" --password="${db_password}" -h ${DB_HOST} ${db_name}"
 
-	#mysqlexec="${MYSQL_BIN} -u ${db_user} --password=${db_password} -h ${MYSQL_HOST} -D ${db_name}"
-	
-	if [ -f ${DBVERSION_CATALOG_CREATION} ]
-	then
-		`${MYSQL_BIN} -u "${db_user}" --password="${db_password}" -h ${MYSQL_HOST} -D ${db_name} < ${DBVERSION_CATALOG_CREATION}`
-		check_ret_status $? "Verifying database version catalog table Failed."
+		if [ -f ${DBVERSION_CATALOG_CREATION} ]
+		then
+			log "[I] Verifying database version catalog table .... "
+			${mysqlexec} < ${DBVERSION_CATALOG_CREATION}
+			`${SQL_COMMAND_INVOKER} -u "${db_user}" --password="${db_password}" -h ${DB_HOST} -D ${db_name} < ${DBVERSION_CATALOG_CREATION}`
+			check_ret_status $? "Verifying database version catalog table Failed."
+		fi
+
+		dt=`date '+%s'`
+		tempFile=/tmp/sql_${dt}_$$.sql
+		sqlfiles=`ls -1 db/patches/*.sql 2> /dev/null | awk -F/ '{ print $NF }' | awk -F- '{ print $1, $0 }' | sort -k1 -n | awk '{ printf("db/patches/%s\n",$2) ; }'`
+		for sql in ${sqlfiles}
+		do
+			if [ -f ${sql} ]
+			then
+				bn=`basename ${sql}`
+				version=`echo ${bn} | awk -F'-' '{ print $1 }'`
+				if [ "${version}" != "" ]
+				then
+					c=`${SQL_COMMAND_INVOKER} -u "${db_user}" --password="${db_password}" -h ${DB_HOST} -D ${db_name} -B --skip-column-names -e "select count(id) from x_db_version_h where version = '${version}' and active = 'Y'"`
+					check_ret_status $? "DBVerionCheck - ${version} Failed."
+					if [ ${c} -eq 0 ]
+					then
+						cat ${sql} > ${tempFile}
+						echo >> ${tempFile}
+						echo "insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ( '${version}', now(), user(), now(), user()) ;" >> ${tempFile}
+						log "[I] - patch [${version}] is being applied."
+						`${SQL_COMMAND_INVOKER} -u "${db_user}" --password="${db_password}" -h ${DB_HOST} -D ${db_name} < ${tempFile}`
+						check_ret_status $? "Update patch - ${version} Failed. See sql file : [${tempFile}]"
+						rm -f ${tempFile}
+					else
+						log "[I] - patch [${version}] is already applied. Skipping ..."
+					fi
+				fi
+			fi
+		done
 	fi
-		
-	dt=`date '+%s'`
-	tempFile=/tmp/sql_${dt}_$$.sql
-	sqlfiles=`ls -1 db/patches/*.sql 2> /dev/null | awk -F/ '{ print $NF }' | awk -F- '{ print $1, $0 }' | sort -k1 -n | awk '{ printf("db/patches/%s\n",$2) ; }'`
-	for sql in ${sqlfiles}
-	do
-		if [ -f ${sql} ]
+	####
+	if [ "${DB_FLAVOR}" == "ORACLE" ]
+    then
+		strError="ERROR"
+		DBVERSION_CATALOG_CREATION=db/oracle/create_dbversion_catalog.sql
+		VERSION_TABLE=x_db_version_h
+		log "[I] Verifying table $VERSION_TABLE in database $db_name";
+		if [ -f ${DBVERSION_CATALOG_CREATION} ]
 		then
-			bn=`basename ${sql}`
-			version=`echo ${bn} | awk -F'-' '{ print $1 }'`
-			if [ "${version}" != "" ]
+			result1=`${SQL_COMMAND_INVOKER} -L -S "${db_user}"/"\"${db_password}\""@"${DB_HOST}" <<< "select UPPER(table_name) from all_tables where UPPER(tablespace_name)=UPPER('${db_name}') and UPPER(table_name)=UPPER('${VERSION_TABLE}');"`
+			tablename=`echo $VERSION_TABLE | tr '[:lower:]' '[:upper:]'`
+			if test "${result1#*$tablename}" == "$result1"	#does not contains tablename so create table
 			then
-				c=`${MYSQL_BIN} -u "${db_user}" --password="${db_password}" -h ${MYSQL_HOST} -D ${db_name} -B --skip-column-names -e "select count(id) from x_db_version_h where version = '${version}' and active = 'Y'"`
-				check_ret_status $? "DBVerionCheck - ${version} Failed."
-				if [ ${c} -eq 0 ]
+				log "[I] Importing Version Catalog file: $DBVERSION_CATALOG_CREATION..."
+				result2=`echo "exit"|${SQL_COMMAND_INVOKER} -L -S "${db_user}"/"\"${db_password}\""@"${DB_HOST}" @$DBVERSION_CATALOG_CREATION`
+				if test "${result2#*$strError}" == "$result2"
 				then
-					cat ${sql} > ${tempFile}
-					echo >> ${tempFile}
-					echo "insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ( '${version}', now(), user(), now(), user()) ;" >> ${tempFile}
-					log "[I] - patch [${version}] is being applied."
-					`${MYSQL_BIN} -u "${db_user}" --password="${db_password}" -h ${MYSQL_HOST} -D ${db_name} < ${tempFile}`
-					check_ret_status $? "Update patch - ${version} Failed. See sql file : [${tempFile}]"
-					rm -f ${tempFile}
+					log "[I] Importing Version Catalog file : $DBVERSION_CATALOG_CREATION DONE";
 				else
-					log "[I] - patch [${version}] is already applied. Skipping ..."
+					log "[E] Importing Version Catalog file : $DBVERSION_CATALOG_CREATION Failed";
+					log "[E] $result2"
 				fi
+			else
+				log "[I] Table $VERSION_TABLE already exists in database ${db_name}"
 			fi
 		fi
-	done
+
+		dt=`date '+%s'`
+		tempFile=/tmp/sql_${dt}_$$.sql
+		sqlfiles=`ls -1 db/oracle/patches/*.sql 2> /dev/null | awk -F/ '{ print $NF }' | awk -F- '{ print $1, $0 }' | sort -k1 -n | awk '{ printf("db/oracle/patches/%s\n",$2) ; }'`
+		for sql in ${sqlfiles}
+		do
+			if [ -f ${sql} ]
+			then
+				bn=`basename ${sql}`
+				version=`echo ${bn} | awk -F'-' '{ print $1 }'`
+				if [ "${version}" != "" ]
+				then
+					result2=`${SQL_COMMAND_INVOKER} -L -S "${db_user}"/"\"${db_password}\""@"${DB_HOST}" <<< "select version from x_db_version_h where version = '${version}' and active = 'Y';"`
+					#does not contains record so insert
+					if test "${result2#*$version}" == "$result2"
+					then
+						cat ${sql} > ${tempFile}
+						echo >> ${tempFile}
+						echo "insert into x_db_version_h (id,version, inst_at, inst_by, updated_at, updated_by) values ( X_DB_VERSION_H_SEQ.nextval,'${version}', sysdate, '${db_user}', sysdate, '${db_user}') ;" >> ${tempFile}
+						log "[I] - patch [${version}] is being applied. $tempFile"
+						result3=`echo "exit"|${SQL_COMMAND_INVOKER} -L -S "${db_user}"/"\"${db_password}\""@"${DB_HOST}"  @$tempFile`
+						log "[+]$result3"
+						if test "${result3#*$strError}" == "$result3"
+						then
+							log "[I] Update patch - ${version} applied. See sql file : [${tempFile}]"
+						else
+							log "[E] Update patch - ${version} Failed. See sql file : [${tempFile}]"
+						fi
+						rm -f ${tempFile}
+					elif test "${result2#*$strError}" != "$result2"
+					then
+						log "[E] - patch [${version}] could not applied. Skipping ..."
+						exit 1
+					else
+						log "[I] - patch [${version}] is already applied. Skipping ..."
+					fi
+				fi
+			fi
+		done
+	fi
 	log "[I] - upgradedb completed."
 }
 
-import_db () {
+import_db(){
+	if [ "${DB_FLAVOR}" == "MYSQL" ]
+    then
+		log "[I] Verifying Database: ${db_name}";
+		existdb=`${SQL_COMMAND_INVOKER} -u "${db_user}" --password="${db_password}" -h $DB_HOST -B --skip-column-names -e  "show databases like '${db_name}' ;"`
+		if [ "${existdb}" = "${db_name}" ]
+		then
+			log "[I] - database ${db_name} already exists. Ignoring import_db ..."
+		else
+			log "[I] Creating Database: $db_name";
+			$SQL_COMMAND_INVOKER -u "$db_user" --password="$db_password" -h $DB_HOST -e "create database $db_name"
+			check_ret_status $? "Creating database Failed.."
+			log "[I] Importing Core Database file: $mysql_core_file "
+			$SQL_COMMAND_INVOKER -u "$db_user" --password="$db_password" -h $DB_HOST $db_name < $mysql_core_file
+			check_ret_status $? "Importing Database Failed.."
+			if [ -f "${mysql_asset_file}" ]
+			then
+				$SQL_COMMAND_INVOKER -u "$db_user" --password="$db_password" -h $DB_HOST ${db_name} < ${mysql_asset_file}
+				check_ret_status $? "Reset of DB repositories failed"
+			fi
+			log "[I] Importing Database file : $mysql_core_file DONE";
+		fi
+	fi
+	if [ "${DB_FLAVOR}" == "ORACLE" ]
+    then
+		log "[I] Importing TABLESPACE: ${db_name}";
+		strError="ERROR"
+		existdb="false"
+
+		#Verifying Users
+		log "[I] Verifying DB User: ${db_user}";
+		result3=`${SQL_COMMAND_INVOKER} -L -S "${db_root_user}"/"\"${db_root_password}\""@"${DB_HOST}" AS SYSDBA <<< "select UPPER(username) from all_users where UPPER(username)=UPPER('${db_user}');"`
+		username=`echo ${db_user} | tr '[:lower:]' '[:upper:]'`
+		if test "${result3#*$username}" == "$result3"	#does not contains username so create user
+		then
+			#create user
+			result4=`${SQL_COMMAND_INVOKER} -L -S "${db_root_user}"/"\"${db_root_password}\""@"${DB_HOST}" AS SYSDBA  <<< "create user ${db_user} identified by \"${db_password}\";"`
+			result3=`${SQL_COMMAND_INVOKER} -L -S "${db_root_user}"/"\"${db_root_password}\""@"${DB_HOST}" AS SYSDBA <<< "select UPPER(username) from all_users where UPPER(username)=UPPER('${db_user}');"`
+			username=`echo ${db_user} | tr '[:lower:]' '[:upper:]'`
+			if test "${result3#*$username}" == "$result3"	#does not contains username so create user
+			then
+				log "[E] Creating User: ${db_user} Failed";
+				log "[E] ${result4}";
+				exit 1
+			else
+				log "[I] Creating User: ${db_user} Success";
+			fi
+		else
+			log "[I] User: ${db_user} exist";
+		fi
 
-	log "[I] Verifying Database: $db_name";
-	existdb=`${MYSQL_BIN} -u "${db_user}" --password="${db_password}" -h $MYSQL_HOST -B --skip-column-names -e  "show databases like '${db_name}' ;"`
+		#creating db/tablespace
+		result1=`${SQL_COMMAND_INVOKER} -L -S "${db_root_user}"/"\"${db_root_password}\""@"${DB_HOST}" AS SYSDBA <<< "SELECT DISTINCT UPPER(TABLESPACE_NAME) FROM USER_TABLESPACES where UPPER(TABLESPACE_NAME)=UPPER('${db_name}');"`
+		tablespace=`echo ${db_name} | tr '[:lower:]' '[:upper:]'`
+		if test "${result1#*$tablespace}" == "$result1" #does not contains tablespace so create tablespace
+		then
+			log "[I] Creating TABLESPACE: ${db_name}";
+			result2=`${SQL_COMMAND_INVOKER} -L -S "${db_root_user}"/"\"${db_root_password}\""@"${DB_HOST}" AS SYSDBA <<< "create tablespace ${db_name} datafile '${db_name}.dat' size 10M autoextend on;"`
+			if test "${result2#*$strError}" == "$result2"
+			then
+				log "[I] TABLESPACE ${db_name} created.";
+				existdb="true"
+			else
+				log "[E] Creating TABLESPACE: ${db_name} Failed";
+				log "[E] $result2";
+				exit 1
+			fi
+		else
+			log "[I] TABLESPACE ${db_name} already exists.";
+		fi
 
-	if [ "${existdb}" = "${db_name}" ]
-	then
-		log "[I] - database ${db_name} already exists. Ignoring import_db ..."
-	else
-		log "[I] Creating Database: $db_name";
-		$MYSQL_BIN -u "$db_user" --password="$db_password" -h $MYSQL_HOST -e "create database $db_name"  
-		check_ret_status $? "Creating database Failed.."
-	
-	
-		log "[I] Importing Core Database file: $db_core_file "
-    	$MYSQL_BIN -u "$db_user" --password="$db_password" -h $MYSQL_HOST $db_name < $db_core_file
-    	check_ret_status $? "Importing Database Failed.."
-	
-		if [ -f "${db_asset_file}" ] 
+		#verify table space
+		result1a=`${SQL_COMMAND_INVOKER} -L -S "${db_root_user}"/"\"${db_root_password}\""@"${DB_HOST}" AS SYSDBA <<< "SELECT DISTINCT UPPER(TABLESPACE_NAME) FROM USER_TABLESPACES where UPPER(TABLESPACE_NAME)=UPPER('${db_name}');"`
+		tablespace1a=`echo ${db_name} | tr '[:lower:]' '[:upper:]'`
+		if test "${result1a#*$tablespace1a}" == "$result1a" #does not contains tablespace so exit
+		then
+			log "[E] TABLESPACE: ${db_name} Does not exist!!";
+			exit 1
+		fi
+
+		#verify user
+		result3=`${SQL_COMMAND_INVOKER} -L -S "${db_root_user}"/"\"${db_root_password}\""@"${DB_HOST}" AS SYSDBA <<< "select UPPER(username) from all_users where UPPER(username)=UPPER('${db_user}');"`
+		username=`echo ${db_user} | tr '[:lower:]' '[:upper:]'`
+		if test "${result3#*$username}" == "$result3"	#does not contains username so exit
+		then
+			log "[E] User: ${db_user} Does not exist!!";
+			exit 1
+		fi
+
+		# ASSIGN DEFAULT TABLESPACE ${db_name}
+		result8=`${SQL_COMMAND_INVOKER} -L -S "${db_root_user}"/"\"${db_root_password}\""@"${DB_HOST}" AS SYSDBA  <<< "alter user ${db_user} identified by \"${db_password}\" DEFAULT TABLESPACE ${db_name};"`
+
+	    #grant user
+        result5=`${SQL_COMMAND_INVOKER} -L -S "${db_root_user}"/"\"${db_root_password}\""@"${DB_HOST}" AS SYSDBA <<< "GRANT connect,resource,create view,sysdba TO ${db_user};"`
+        if test "${result5#*$strError}" == "$result5"
 		then
-			$MYSQL_BIN -u "$db_user" --password="$db_password" -h $MYSQL_HOST ${db_name} < ${db_asset_file}
-			check_ret_status $? "Reset of DB repositories failed"
+			log "[I] Granting User: ${db_user} Success";
+		else
+			log "[E] Granting User: ${db_user} Failed";
+			log "[E] $result5";
+			exit 1
 		fi
 
-		log "[I] Importing Database file : $db_core_file DONE";
+		#if does not contains tables create tables
+		if [ "${existdb}" == "true" ]
+		then
+			log "[I] Importing XA Database file: ${oracle_core_file}..."
+			result7=`echo "exit"|${SQL_COMMAND_INVOKER} -L -S "${db_user}"/"\"${db_password}\""@"${DB_HOST}" @${oracle_core_file}`
+			if test "${result7#*$strError}" == "$result7"
+			then
+				log "[I] Importing XA Database file : ${oracle_core_file} DONE";
+			else
+				log "[E] Importing XA Database file : ${oracle_core_file} Failed";
+				log "[E] $result7";
+				exit 1
+			fi
+		else
+			log "[I] - database ${db_name} already exists. Ignoring import_db ..."	;
+		fi
 	fi	
 }
 
@@ -417,37 +703,89 @@ copy_to_webapps (){
 	log "[I] Copying to ${WEBAPP_ROOT} DONE";
 }
 
-copy_mysql_connector(){
-	log "[I] Copying MYSQL Connector to $app_home/WEB-INF/lib ";
-    cp -f $MYSQL_CONNECTOR_JAR $app_home/WEB-INF/lib
-	check_ret_status $? "Copying MYSQL Connector to $app_home/WEB-INF/lib failed"
-	log "[I] Copying MYSQL Connector to $app_home/WEB-INF/lib DONE";
+copy_db_connector(){
+	if [ "${DB_FLAVOR}" == "MYSQL" ]
+	then
+		log "[I] Copying MYSQL Connector to $app_home/WEB-INF/lib ";
+	    cp -f $SQL_CONNECTOR_JAR $app_home/WEB-INF/lib
+		check_ret_status $? "Copying MYSQL Connector to $app_home/WEB-INF/lib failed"
+		log "[I] Copying MYSQL Connector to $app_home/WEB-INF/lib DONE";
+	fi
+	if [ "${DB_FLAVOR}" == "ORACLE" ]
+    then
+        log "[I] Copying ORACLE Connector to $app_home/WEB-INF/lib ";
+        cp -f $SQL_CONNECTOR_JAR $app_home/WEB-INF/lib
+        check_ret_status $? "Copying ORACLE Connector to $app_home/WEB-INF/lib failed"
+        log "[I] Copying ORACLE Connector to $app_home/WEB-INF/lib DONE";
+    fi
 }
 
 update_properties() {
 	newPropertyValue=''
 	to_file=$app_home/WEB-INF/classes/xa_system.properties
-
 	if test -f $to_file; then
 		log "[I] $to_file file found" 
 	else
 		log "[E] $to_file does not exists" ; exit 1;
     fi
+	if [ "${DB_FLAVOR}" == "MYSQL" ]
+	then
+		propertyName=jdbc.url
+		newPropertyValue="jdbc:log4jdbc:mysql://${DB_HOST}/${db_name}"
+		updatePropertyToFile $propertyName $newPropertyValue $to_file
 
-	propertyName=jdbc.url
-	newPropertyValue="jdbc:log4jdbc:mysql://${MYSQL_HOST}:3306/${db_name}"
-	updatePropertyToFile $propertyName $newPropertyValue $to_file	
+		propertyName=auditDB.jdbc.url
+		newPropertyValue="jdbc:log4jdbc:mysql://${DB_HOST}/${audit_db_name}"
+		updatePropertyToFile $propertyName $newPropertyValue $to_file
 
+		propertyName=jdbc.dialect
+		newPropertyValue="org.eclipse.persistence.platform.database.MySQLPlatform"
+		updatePropertyToFile $propertyName $newPropertyValue $to_file
+
+		propertyName=auditDB.jdbc.dialect
+		newPropertyValue="org.eclipse.persistence.platform.database.MySQLPlatform"
+		updatePropertyToFile $propertyName $newPropertyValue $to_file
+
+		propertyName=jdbc.driver
+		newPropertyValue="net.sf.log4jdbc.DriverSpy"
+		updatePropertyToFile $propertyName $newPropertyValue $to_file
+
+		propertyName=auditDB.jdbc.driver
+		newPropertyValue="net.sf.log4jdbc.DriverSpy"
+		updatePropertyToFile $propertyName $newPropertyValue $to_file
+	fi
+	if [ "${DB_FLAVOR}" == "ORACLE" ]
+	then
+		propertyName=jdbc.url
+		newPropertyValue="jdbc:oracle:thin:\@//${DB_HOST}"
+		updatePropertyToFile $propertyName $newPropertyValue $to_file
+
+		propertyName=auditDB.jdbc.url
+		newPropertyValue="jdbc:oracle:thin:\@//${DB_HOST}"
+		updatePropertyToFile $propertyName $newPropertyValue $to_file
+
+		propertyName=jdbc.dialect
+		newPropertyValue="org.eclipse.persistence.platform.database.OraclePlatform"
+		updatePropertyToFile $propertyName $newPropertyValue $to_file
+
+		propertyName=auditDB.jdbc.dialect
+		newPropertyValue="org.eclipse.persistence.platform.database.OraclePlatform"
+		updatePropertyToFile $propertyName $newPropertyValue $to_file
+
+		propertyName=jdbc.driver
+		newPropertyValue="oracle.jdbc.OracleDriver"
+		updatePropertyToFile $propertyName $newPropertyValue $to_file
+
+		propertyName=auditDB.jdbc.driver
+		newPropertyValue="oracle.jdbc.OracleDriver"
+		updatePropertyToFile $propertyName $newPropertyValue $to_file
+	fi
 	propertyName=xa.webapp.url.root
 	newPropertyValue="${policymgr_external_url}"
 	updatePropertyToFile $propertyName $newPropertyValue $to_file
 
 	propertyName=http.enabled
 	newPropertyValue="${policymgr_http_enabled}"
-	updatePropertyToFile $propertyName $newPropertyValue $to_file
-
-	propertyName=auditDB.jdbc.url
-	newPropertyValue="jdbc:log4jdbc:mysql://${MYSQL_HOST}:3306/${audit_db_name}"
 	updatePropertyToFile $propertyName $newPropertyValue $to_file	
 	
 	propertyName=jdbc.user
@@ -536,59 +874,138 @@ update_properties() {
 	
 }
 
-create_audit_mysql_user(){
-
-	check_mysql_audit_user_password
-
+create_audit_db_user(){
+	check_audit_user_password
 	AUDIT_DB="${audit_db_name}"
 	AUDIT_USER="${audit_db_user}"
 	AUDIT_PASSWORD="${audit_db_password}"
-
-	log "[I] Verifying Database: $AUDIT_DB";
-	existdb=`${MYSQL_BIN} -u root --password="$db_root_password" -h $MYSQL_HOST -B --skip-column-names -e  "show databases like '$AUDIT_DB' ;"`
-
-	if [ "${existdb}" = "$AUDIT_DB" ]
-	then
-		log "[I] - database $AUDIT_DB already exists."
-	else
-		log "[I] Creating Database: $audit_db_name";
-		$MYSQL_BIN -u root --password="$db_root_password" -h $MYSQL_HOST -e "create database $AUDIT_DB"  
-		check_ret_status $? "Creating database $AUDIT_DB Failed.."
-	fi	
-
-	for thost in '%' localhost
-	do
-		usercount=`$MYSQL_BIN -B -u root --password="$db_root_password" -h $MYSQL_HOST --skip-column-names -e "select count(*) from mysql.user where user = '$AUDIT_USER' and host = '$thost';"`
-		if  [ ${usercount} -eq 0 ]
+	strError="ERROR"
+	#Verifying Database
+	if [ "${DB_FLAVOR}" == "MYSQL" ]
+    then
+		log "[I] Verifying Database: $AUDIT_DB";
+		existdb=`${SQL_COMMAND_INVOKER} -u "$db_root_user" --password="$db_root_password" -h $DB_HOST -B --skip-column-names -e  "show databases like '$AUDIT_DB' ;"`
+		if [ "${existdb}" = "$AUDIT_DB" ]
 		then
-		  log "[I] Creating MySQL user '$AUDIT_USER'@'$thost' (using root priviledges)"
-		  $MYSQL_BIN -B -u root --password="$db_root_password" -h $MYSQL_HOST -e "create user '$AUDIT_USER'@'$thost' identified by '$AUDIT_PASSWORD';"
-		  check_ret_status $? "MySQL create user failed"
+			log "[I] Database $AUDIT_DB already exists."
+		else
+			log "[I] Creating Database: $audit_db_name";
+			$SQL_COMMAND_INVOKER -u "$db_root_user" --password="$db_root_password" -h $DB_HOST -e "create database $AUDIT_DB"
+			check_ret_status $? "Creating database $AUDIT_DB Failed.."
 		fi
+	fi
+	if [ "${DB_FLAVOR}" == "ORACLE" ]
+    then
+		log "[I] Verifying TABLESPACE: $AUDIT_DB";
+		result1=`${SQL_COMMAND_INVOKER} -L -S "${db_root_user}"/"\"${db_root_password}\""@"${DB_HOST}" AS SYSDBA  <<< "SELECT distinct UPPER(TABLESPACE_NAME) FROM USER_TABLESPACES where UPPER(TABLESPACE_NAME)=UPPER('${AUDIT_DB}');"`
+		tablespace=`echo $AUDIT_DB | tr '[:lower:]' '[:upper:]'`
+		if test "${result1#*$tablespace}" == "$result1" #does not contains tablespace so create tablespace
+		then
+			log "[I] Creating TABLESPACE: $AUDIT_DB";
+			result2=`${SQL_COMMAND_INVOKER} -L -S "${db_root_user}"/"\"${db_root_password}\""@"${DB_HOST}" AS SYSDBA <<< "create tablespace $AUDIT_DB datafile '$AUDIT_DB.dat' size 10M autoextend on;"`
+			if test "${result2#*$strError}" == "$result2"
+			then
+				log "[I] TABLESPACE $AUDIT_DB created."
+			else
+				log "[E] Creating TABLESPACE: $AUDIT_DB Failed";
+				log "[E] $result2"
+				exit 1
+			fi
+		else
+			log "[I] TABLESPACE $AUDIT_DB already exists."
+		fi
+	fi
+	#Verifying Users
+	log "[I] Verifying Audit User: $AUDIT_USER";
+	if [ "${DB_FLAVOR}" == "MYSQL" ]
+    then
+		for thost in '%' localhost
+		do
+			usercount=`$SQL_COMMAND_INVOKER -B -u "$db_root_user" --password="$db_root_password" -h $DB_HOST --skip-column-names -e "select count(*) from mysql.user where user = '$AUDIT_USER' and host = '$thost';"`
+
+			if  [ ${usercount} -eq 0 ]
+			then
+				log "[I] Creating MYSQL user '$AUDIT_USER'@'$thost' (using root priviledges)"
+				$SQL_COMMAND_INVOKER -B -u "$db_root_user" --password="$db_root_password" -h $DB_HOST -e "create user '$AUDIT_USER'@'$thost' identified by '$AUDIT_PASSWORD';"
+				check_ret_status $? "MYSQL create user failed"
+			fi
+			mysqlquery="GRANT ALL ON *.* TO '$AUDIT_USER'@'$thost' ;
+			grant all privileges on *.* to '$AUDIT_USER'@'$thost' with grant option;
+			FLUSH PRIVILEGES;"
 		
-		mysqlquery="GRANT ALL ON $AUDIT_DB.* TO '$AUDIT_USER'@'$thost' ; 
-		grant all privileges on $AUDIT_DB.* to '$AUDIT_USER'@'$thost' with grant option;
-		FLUSH PRIVILEGES;"
-		
-		echo "${mysqlquery}" | $MYSQL_BIN -u root --password="$db_root_password" -h $MYSQL_HOST
-		check_ret_status $? "MySQL query failed: $mysqlquery"
-	done
-	log "[I] Creating MySQL user '$AUDIT_USER' (using root priviledges) DONE"
-	
-	AUDIT_TABLE=xa_access_audit
-	log "[I] Verifying table $AUDIT_TABLE in audit database $AUDIT_DB";
-	existtbl=`${MYSQL_BIN} -u "$AUDIT_USER" --password="$AUDIT_PASSWORD" -D $AUDIT_DB -h $MYSQL_HOST -B --skip-column-names -e  "show tables like '$AUDIT_TABLE' ;"`
+			echo "${mysqlquery}" | $SQL_COMMAND_INVOKER -u "$db_root_user" --password="$db_root_password" -h $DB_HOST
+			check_ret_status $? "'$DB_FLAVOR' create user failed"
+			log "[I] Creating MYSQL user '$AUDIT_USER' for host $thost(using root priviledges) DONE"
+		done
+	fi
+	if [ "${DB_FLAVOR}" == "ORACLE" ]
+    then
 
-	if [ "${existtbl}" != "$AUDIT_TABLE" ]
-	then
-		log "[I] Importing Audit Database file: $db_audit_file..."
-  	$MYSQL_BIN -u "$AUDIT_USER" --password="$AUDIT_PASSWORD" -h $MYSQL_HOST $AUDIT_DB < $db_audit_file
-  	check_ret_status $? "Importing Audit Database Failed.."
+		result3=`${SQL_COMMAND_INVOKER} -L -S "${db_root_user}"/"\"${db_root_password}\""@"${DB_HOST}" AS SYSDBA <<< "select UPPER(username) from all_users where UPPER(username)=UPPER('${AUDIT_USER}');"`
+		username=`echo $AUDIT_USER | tr '[:lower:]' '[:upper:]'`
+		if test "${result3#*$username}" == "$result3"	#does not contains username so create user
+		then
+			#create user
+			result4=`${SQL_COMMAND_INVOKER} -L -S "${db_root_user}"/"\"${db_root_password}\""@"${DB_HOST}" AS SYSDBA <<< "create user ${AUDIT_USER} identified by \"${AUDIT_PASSWORD}\" DEFAULT TABLESPACE ${AUDIT_DB};"`
+			if test "${result4#*$strError}" == "$result4"
+		    then
+				log "[I] Creating User: ${AUDIT_USER} Success";
+			else
+				log "[E] Creating User: ${AUDIT_USER} Failed";
+				log "[E] $result4"
+				exit 1
+		    fi
+			else
+				log "[I] User: ${AUDIT_USER} exist";
+		    fi
+            result5=`${SQL_COMMAND_INVOKER} -L -S "${db_root_user}"/"\"${db_root_password}\""@"${DB_HOST}" AS SYSDBA <<< "GRANT connect,resource,create view TO ${AUDIT_USER};"`
+            if test "${result5#*$strError}" == "$result5"
+			then
+				log "[I] Granting User: $AUDIT_USER Success";
+			else
+				log "[E] Granting User: $AUDIT_USER Failed";
+				log "[E] $result5"
+				exit 1
+			fi
+        fi
 
-		log "[I] Importing Audit Database file : $db_audit_file DONE";
-	else
-		log "[I] - table $AUDIT_TABLE already exists in audit database $AUDIT_DB"
-	fi	
+		AUDIT_TABLE=xa_access_audit
+		log "[I] Verifying table $AUDIT_TABLE in audit database $AUDIT_DB";
+		if [ "${DB_FLAVOR}" == "MYSQL" ]
+		then
+			existtbl=`${SQL_COMMAND_INVOKER} -u "$AUDIT_USER" --password="$AUDIT_PASSWORD" -D $AUDIT_DB -h $DB_HOST -B --skip-column-names -e  "show tables like '$AUDIT_TABLE' ;"`
+
+			if [ "${existtbl}" != "$AUDIT_TABLE" ]
+			then
+				log "[I] Importing Audit Database file: $mysql_audit_file..."
+				$SQL_COMMAND_INVOKER -u "$AUDIT_USER" --password="$AUDIT_PASSWORD" -h $DB_HOST $AUDIT_DB < $mysql_audit_file
+				check_ret_status $? "Importing Audit Database Failed.."
+				log "[I] Importing Audit Database file : $mysql_audit_file DONE";
+			else
+				log "[I] Table $AUDIT_TABLE already exists in audit database $AUDIT_DB"
+			fi
+		fi
+		if [ "${DB_FLAVOR}" == "ORACLE" ]
+		then
+			# ASSIGN DEFAULT TABLESPACE ${db_name}
+			result8=`${SQL_COMMAND_INVOKER} -L -S "${db_root_user}"/"\"${db_root_password}\""@"${DB_HOST}" AS SYSDBA  <<< "alter user ${AUDIT_USER} identified by \"${AUDIT_PASSWORD}\" DEFAULT TABLESPACE ${AUDIT_DB};"`
+			result6=`${SQL_COMMAND_INVOKER} -L -S "${db_root_user}"/"\"${db_root_password}\""@"${DB_HOST}" AS SYSDBA <<< "select UPPER(table_name) from all_tables where tablespace_name='$AUDIT_DB' and UPPER(table_name)=UPPER('${AUDIT_TABLE}');"`
+			tablename=`echo $AUDIT_TABLE | tr '[:lower:]' '[:upper:]'`
+			if test "${result6#*$tablename}" == "$result6"	#does not contains tablename so create table
+			then
+				log "[I] Importing Audit Database file: $oracle_audit_file..."
+				result7=`echo "exit"|${SQL_COMMAND_INVOKER} -L -S "${AUDIT_USER}"/"\"${AUDIT_PASSWORD}\""@"${DB_HOST}" @$oracle_audit_file`
+				if test "${result7#*$strError}" == "$result7"
+				then
+					log "[I] Importing Audit Database file : $oracle_audit_file DONE";
+				else
+					log "[E] Importing Audit Database file : $oracle_audit_file failed";
+					log "[E] $result7"
+				fi
+			else
+				log "[I] Table $AUDIT_TABLE already exists in audit database $AUDIT_DB"
+			fi
+		fi
 }
 
 do_unixauth_setup() {
@@ -617,9 +1034,6 @@ do_unixauth_setup() {
 	group=xasecure
 	chown -R ${owner}:${group} ${XASECURE_JAAS_DIR}
 	chmod -R go-rwx ${XASECURE_JAAS_DIR}
-
-	
-
 }
 do_authentication_setup(){
 	log "[I] Starting setup based on user authentication method=$authentication_method";     
@@ -799,37 +1213,40 @@ restart_policymgr(){
 
 }
 execute_java_patches(){
-	dt=`date '+%s'`
-	tempFile=/tmp/sql_${dt}_$$.sql
-	mysqlexec="${MYSQL_BIN} -u ${db_user} --password="${db_password}" -h ${MYSQL_HOST} ${db_name}"
-	javaFiles=`ls -1 $app_home/WEB-INF/classes/com/xasecure/patch/Patch*.class 2> /dev/null | awk -F/ '{ print $NF }' | awk -F_J '{ print $2, $0 }' | sort -k1 -n | awk '{ printf("%s\n",$2) ; }'`
-	for javaPatch in ${javaFiles}
-	do
-		if test -f "$app_home/WEB-INF/classes/com/xasecure/patch/$javaPatch"; then
-			className=$(basename "$javaPatch" .class)
-			version=`echo ${className} | awk -F'_' '{ print $2 }'`
-			if [ "${version}" != "" ]
-			then
-				c=`${mysqlexec} -B --skip-column-names -e "select count(id) from x_db_version_h where version = '${version}' and active = 'Y'"`
-				check_ret_status $? "DBVerionCheck - ${version} Failed."
-				if [ ${c} -eq 0 ]
+	if [ "${DB_FLAVOR}" == "MYSQL" ]
+	then
+		dt=`date '+%s'`
+		tempFile=/tmp/sql_${dt}_$$.sql
+		mysqlexec="${SQL_COMMAND_INVOKER} -u ${db_user} --password="${db_password}" -h ${DB_HOST} ${db_name}"
+		javaFiles=`ls -1 $app_home/WEB-INF/classes/com/xasecure/patch/Patch*.class 2> /dev/null | awk -F/ '{ print $NF }' | awk -F_J '{ print $2, $0 }' | sort -k1 -n | awk '{ printf("%s\n",$2) ; }'`
+		for javaPatch in ${javaFiles}
+		do
+			if test -f "$app_home/WEB-INF/classes/com/xasecure/patch/$javaPatch"; then
+				className=$(basename "$javaPatch" .class)
+				version=`echo ${className} | awk -F'_' '{ print $2 }'`
+				if [ "${version}" != "" ]
 				then
-					log "[I] patch ${javaPatch} is being applied..";
-					msg=`java -cp "$app_home/WEB-INF/:$app_home/META-INF/:$app_home/WEB-INF/lib/*:$app_home/WEB-INF/classes/:$app_home/WEB-INF/classes/META-INF/" com.xasecure.patch.${className}`
-					check_ret_status $? "Unable to apply patch:$javaPatch"
-					touch ${tempFile}
-					echo >> ${tempFile}
-					echo "insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ( '${version}', now(), user(), now(), user()) ;" >> ${tempFile}
-					${mysqlexec} < ${tempFile}
-					check_ret_status $? "Update patch - ${javaPatch} has failed."
-					rm -f ${tempFile}
-					log "[I] patch ${javaPatch} has been applied!!";
-				else
-					log "[I] - patch [${javaPatch}] is already applied. Skipping ..."
+					c=`${mysqlexec} -B --skip-column-names -e "select count(id) from x_db_version_h where version = '${version}' and active = 'Y'"`
+					check_ret_status $? "DBVerionCheck - ${version} Failed."
+					if [ ${c} -eq 0 ]
+					then
+						log "[I] patch ${javaPatch} is being applied..";
+						msg=`java -cp "$app_home/WEB-INF/:$app_home/META-INF/:$app_home/WEB-INF/lib/*:$app_home/WEB-INF/classes/:$app_home/WEB-INF/classes/META-INF/" com.xasecure.patch.${className}`
+						check_ret_status $? "Unable to apply patch:$javaPatch"
+						touch ${tempFile}
+						echo >> ${tempFile}
+						echo "insert into x_db_version_h (version, inst_at, inst_by, updated_at, updated_by) values ( '${version}', now(), user(), now(), user()) ;" >> ${tempFile}
+						${mysqlexec} < ${tempFile}
+						check_ret_status $? "Update patch - ${javaPatch} has failed."
+						rm -f ${tempFile}
+						log "[I] patch ${javaPatch} has been applied!!";
+					else
+						log "[I] - patch [${javaPatch}] is already applied. Skipping ..."
+					fi
 				fi
 			fi
-	 	fi
-	done
+		done
+	fi
 }
 init_logfiles
 log " --------- Running XASecure PolicyManager Web Application Install Script --------- "
@@ -838,17 +1255,18 @@ log "[I] hostname=`hostname`"
 init_variables
 get_distro
 check_java_version
-check_mysql_version
-check_mysql_connector
+check_db_version
+check_db_connector
 setup_unix_user_group
 setup_install_files
 sanity_check_files
-create_mysql_user
+check_db_admin_password
+create_db_user
 extract_war
-copy_mysql_connector
+copy_db_connector
 import_db
 upgrade_db
-create_audit_mysql_user
+create_audit_db_user
 update_properties
 do_authentication_setup
 copy_to_webapps

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/src/main/java/com/xasecure/common/SearchUtil.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/common/SearchUtil.java b/security-admin/src/main/java/com/xasecure/common/SearchUtil.java
index 452865f..d097a06 100644
--- a/security-admin/src/main/java/com/xasecure/common/SearchUtil.java
+++ b/security-admin/src/main/java/com/xasecure/common/SearchUtil.java
@@ -716,10 +716,10 @@ public class SearchUtil {
 				if (strFieldValue != null) {
 					if (searchField.getSearchType() == SearchField.SEARCH_TYPE.FULL) {
 						query.setParameter(searchField.getClientFieldName(),
-								strFieldValue);
+								strFieldValue.trim().toLowerCase());
 					} else {
 						query.setParameter(searchField.getClientFieldName(),
-								"%" + strFieldValue + "%");
+								"%" + strFieldValue.trim().toLowerCase() + "%");
 					}
 				}
 			} else if (searchField.getDataType() == SearchField.DATA_TYPE.BOOLEAN) {

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/src/main/java/com/xasecure/db/XXGroupDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/db/XXGroupDao.java b/security-admin/src/main/java/com/xasecure/db/XXGroupDao.java
index fc3aa1f..52ddae0 100644
--- a/security-admin/src/main/java/com/xasecure/db/XXGroupDao.java
+++ b/security-admin/src/main/java/com/xasecure/db/XXGroupDao.java
@@ -63,7 +63,7 @@ public class XXGroupDao extends BaseDao<XXGroup> {
 
 			return (XXGroup) getEntityManager()
 					.createNamedQuery("XXGroup.findByGroupName")
-					.setParameter("name", groupName.toLowerCase())
+					.setParameter("name", groupName)
 					.getSingleResult();
 		} catch (Exception e) {
 

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/src/main/java/com/xasecure/db/XXPortalUserDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/db/XXPortalUserDao.java b/security-admin/src/main/java/com/xasecure/db/XXPortalUserDao.java
index b8cdacd..adc7f53 100644
--- a/security-admin/src/main/java/com/xasecure/db/XXPortalUserDao.java
+++ b/security-admin/src/main/java/com/xasecure/db/XXPortalUserDao.java
@@ -39,7 +39,7 @@ public class XXPortalUserDao extends BaseDao<XXPortalUser> {
 		@SuppressWarnings("rawtypes")
 		List resultList = getEntityManager()
 				.createNamedQuery("XXPortalUser.findByLoginId")
-				.setParameter("loginId", loginId.toLowerCase()).getResultList();
+				.setParameter("loginId", loginId).getResultList();
 		if (resultList.size() != 0) {
 			return (XXPortalUser) resultList.get(0);
 		}
@@ -54,7 +54,7 @@ public class XXPortalUserDao extends BaseDao<XXPortalUser> {
 		@SuppressWarnings("rawtypes")
 		List resultList = getEntityManager()
 				.createNamedQuery("XXPortalUser.findByEmailAddress")
-				.setParameter("emailAddress", emailAddress.toLowerCase())
+				.setParameter("emailAddress", emailAddress)
 				.getResultList();
 		if (resultList.size() != 0) {
 			return (XXPortalUser) resultList.get(0);

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/src/main/java/com/xasecure/db/XXUserDao.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/db/XXUserDao.java b/security-admin/src/main/java/com/xasecure/db/XXUserDao.java
index b9bcb66..431bc35 100644
--- a/security-admin/src/main/java/com/xasecure/db/XXUserDao.java
+++ b/security-admin/src/main/java/com/xasecure/db/XXUserDao.java
@@ -43,7 +43,7 @@ public class XXUserDao extends BaseDao<XXUser> {
 		try {
 			return getEntityManager()
 					.createNamedQuery("XXUser.findByUserName", XXUser.class)
-					.setParameter("name", name.trim().toLowerCase())
+					.setParameter("name", name.trim())
 					.getSingleResult();
 		} catch (NoResultException e) {
 			// ignore

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/src/main/java/com/xasecure/entity/XXAccessAudit.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/entity/XXAccessAudit.java b/security-admin/src/main/java/com/xasecure/entity/XXAccessAudit.java
index 3be13eb..e697d29 100644
--- a/security-admin/src/main/java/com/xasecure/entity/XXAccessAudit.java
+++ b/security-admin/src/main/java/com/xasecure/entity/XXAccessAudit.java
@@ -37,8 +37,20 @@ import com.xasecure.entity.*;
 public class XXAccessAudit extends XXDBBase implements java.io.Serializable {
 	private static final long serialVersionUID = 1L;
 
+	@Id
+	@SequenceGenerator(name="X_ACCESS_AUDIT_SEQ",sequenceName="X_ACCESS_AUDIT_SEQ",allocationSize=1)
+	@GeneratedValue(strategy=GenerationType.AUTO,generator="X_ACCESS_AUDIT_SEQ")
+	@Column(name="ID")
+	protected Long id;
 
-
+	@Override
+	public void setId(Long id) {
+		this.id=id;
+	}
+	@Override
+	public Long getId() {
+		return id;
+	}
 	/**
 	 * Repository Type
 	 * <ul>

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/src/main/java/com/xasecure/entity/XXAsset.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/entity/XXAsset.java b/security-admin/src/main/java/com/xasecure/entity/XXAsset.java
index a676861..bd1652b 100644
--- a/security-admin/src/main/java/com/xasecure/entity/XXAsset.java
+++ b/security-admin/src/main/java/com/xasecure/entity/XXAsset.java
@@ -37,8 +37,20 @@ import com.xasecure.entity.*;
 public class XXAsset extends XXDBBase implements java.io.Serializable {
 	private static final long serialVersionUID = 1L;
 
+	@Id
+	@SequenceGenerator(name="X_ASSET_SEQ",sequenceName="X_ASSET_SEQ",allocationSize=1)
+	@GeneratedValue(strategy=GenerationType.AUTO,generator="X_ASSET_SEQ")
+	@Column(name="ID")
+	protected Long id;
 
-
+	@Override
+	public void setId(Long id) {
+		this.id=id;
+	}
+	@Override
+	public Long getId() {
+		return id;
+	}
 	/**
 	 * Name
 	 * <ul>

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/src/main/java/com/xasecure/entity/XXAuditMap.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/entity/XXAuditMap.java b/security-admin/src/main/java/com/xasecure/entity/XXAuditMap.java
index fb31440..900fc76 100644
--- a/security-admin/src/main/java/com/xasecure/entity/XXAuditMap.java
+++ b/security-admin/src/main/java/com/xasecure/entity/XXAuditMap.java
@@ -38,6 +38,20 @@ public class XXAuditMap extends XXDBBase implements java.io.Serializable {
 	private static final long serialVersionUID = 1L;
 
 
+	@Id
+	@SequenceGenerator(name="X_AUDIT_MAP_SEQ",sequenceName="X_AUDIT_MAP_SEQ",allocationSize=1)
+	@GeneratedValue(strategy=GenerationType.AUTO,generator="X_AUDIT_MAP_SEQ")
+	@Column(name="ID")
+	protected Long id;
+	@Override
+	public void setId(Long id) {
+		this.id=id;
+	}
+
+	@Override
+	public Long getId() {
+		return id;
+	}
 
 	/**
 	 * Id of the resource

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/src/main/java/com/xasecure/entity/XXAuthSession.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/entity/XXAuthSession.java b/security-admin/src/main/java/com/xasecure/entity/XXAuthSession.java
index d2ca188..d66fd07 100644
--- a/security-admin/src/main/java/com/xasecure/entity/XXAuthSession.java
+++ b/security-admin/src/main/java/com/xasecure/entity/XXAuthSession.java
@@ -37,6 +37,20 @@ import com.xasecure.entity.*;
 public class XXAuthSession extends XXDBBase implements java.io.Serializable {
 	private static final long serialVersionUID = 1L;
 
+	@Id
+	@SequenceGenerator(name="X_AUTH_SESS_SEQ",sequenceName="X_AUTH_SESS_SEQ",allocationSize=1)
+	@GeneratedValue(strategy=GenerationType.AUTO,generator="X_AUTH_SESS_SEQ")
+	@Column(name="ID")
+	protected Long id;
+	@Override
+	public void setId(Long id) {
+		this.id=id;
+	}
+
+	@Override
+	public Long getId() {
+		return id;
+	}
 	/**
 	 * Enum values for AuthStatus
 	 */

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/src/main/java/com/xasecure/entity/XXCredentialStore.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/entity/XXCredentialStore.java b/security-admin/src/main/java/com/xasecure/entity/XXCredentialStore.java
index bff0c5d..c884421 100644
--- a/security-admin/src/main/java/com/xasecure/entity/XXCredentialStore.java
+++ b/security-admin/src/main/java/com/xasecure/entity/XXCredentialStore.java
@@ -37,8 +37,20 @@ import com.xasecure.entity.*;
 public class XXCredentialStore extends XXDBBase implements java.io.Serializable {
 	private static final long serialVersionUID = 1L;
 
+	@Id
+	@SequenceGenerator(name="X_CRED_STORE_SEQ",sequenceName="X_CRED_STORE_SEQ",allocationSize=1)
+	@GeneratedValue(strategy=GenerationType.AUTO,generator="X_CRED_STORE_SEQ")
+	@Column(name="ID")
+	protected Long id;
 
-
+	@Override
+	public void setId(Long id) {
+		this.id=id;
+	}
+	@Override
+	public Long getId() {
+		return id;
+	}
 	/**
 	 * Name
 	 * <ul>

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/src/main/java/com/xasecure/entity/XXDBBase.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/entity/XXDBBase.java b/security-admin/src/main/java/com/xasecure/entity/XXDBBase.java
index 876340a..b6d2d3c 100644
--- a/security-admin/src/main/java/com/xasecure/entity/XXDBBase.java
+++ b/security-admin/src/main/java/com/xasecure/entity/XXDBBase.java
@@ -33,7 +33,7 @@ import com.xasecure.entity.*;
 
 @MappedSuperclass @EntityListeners( com.xasecure.common.db.JPABeanCallbacks.class)
 @XmlRootElement
-public class XXDBBase extends Object implements java.io.Serializable {
+public abstract class XXDBBase extends Object implements java.io.Serializable {
 	private static final long serialVersionUID = 1L;
 
 
@@ -45,10 +45,6 @@ public class XXDBBase extends Object implements java.io.Serializable {
 	 * </ul>
 	 *
 	 */
-	@Id
-	@GeneratedValue(strategy=GenerationType.IDENTITY)
-	@Column(name="ID"   )
-	protected Long id;
 
 	/**
 	 * Date/Time creation of this user.
@@ -109,17 +105,13 @@ public class XXDBBase extends Object implements java.io.Serializable {
 	 * You cannot set null to the attribute.
 	 * @param id Value to set member attribute <b>id</b>
 	 */
-	public void setId( Long id ) {
-		this.id = id;
-	}
+	public abstract void setId( Long id ) ;
 
 	/**
 	 * Returns the value for the member attribute <b>id</b>
 	 * @return Long - value of member attribute <b>id</b>.
 	 */
-	public Long getId( ) {
-		return this.id;
-	}
+	public abstract Long getId( );
 
 	/**
 	 * This method sets the value to the member attribute <b>createTime</b>.
@@ -198,7 +190,7 @@ public class XXDBBase extends Object implements java.io.Serializable {
 	@Override
 	public String toString( ) {
 		String str = "XXDBBase={";
-		str += "id={" + id + "} ";
+		//`str += "id={" + id + "} ";
 		str += "createTime={" + createTime + "} ";
 		str += "updateTime={" + updateTime + "} ";
 		str += "addedByUserId={" + addedByUserId + "} ";
@@ -214,9 +206,9 @@ public class XXDBBase extends Object implements java.io.Serializable {
 	@Override
 	public boolean equals( Object obj) {
 		XXDBBase other = (XXDBBase) obj;
-        	if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
-            		return false;
-        	}
+//        	if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
+//            		return false;
+//        	}
         	if ((this.createTime == null && other.createTime != null) || (this.createTime != null && !this.createTime.equals(other.createTime))) {
             		return false;
         	}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/src/main/java/com/xasecure/entity/XXGroup.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/entity/XXGroup.java b/security-admin/src/main/java/com/xasecure/entity/XXGroup.java
index b183a2b..64d8e56 100644
--- a/security-admin/src/main/java/com/xasecure/entity/XXGroup.java
+++ b/security-admin/src/main/java/com/xasecure/entity/XXGroup.java
@@ -37,8 +37,19 @@ import com.xasecure.entity.*;
 public class XXGroup extends XXDBBase implements java.io.Serializable {
 	private static final long serialVersionUID = 1L;
 
-
-
+	@Id
+	@SequenceGenerator(name="X_GROUP_SEQ",sequenceName="X_GROUP_SEQ",allocationSize=1)
+	@GeneratedValue(strategy=GenerationType.AUTO,generator="X_GROUP_SEQ")
+	@Column(name="ID")
+	protected Long id;
+	@Override
+	public void setId(Long id) {
+		this.id=id;
+	}
+	@Override
+	public Long getId() {
+		return id;
+	}
 	/**
 	 * Name
 	 * <ul>

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/src/main/java/com/xasecure/entity/XXGroupGroup.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/entity/XXGroupGroup.java b/security-admin/src/main/java/com/xasecure/entity/XXGroupGroup.java
index 8bdc6e4..9c096eb 100644
--- a/security-admin/src/main/java/com/xasecure/entity/XXGroupGroup.java
+++ b/security-admin/src/main/java/com/xasecure/entity/XXGroupGroup.java
@@ -37,8 +37,19 @@ import com.xasecure.entity.*;
 public class XXGroupGroup extends XXDBBase implements java.io.Serializable {
 	private static final long serialVersionUID = 1L;
 
-
-
+	@Id
+	@SequenceGenerator(name="X_GROUP_GROUPS_SEQ",sequenceName="X_GROUP_GROUPS_SEQ",allocationSize=1)
+	@GeneratedValue(strategy=GenerationType.AUTO,generator="X_GROUP_GROUPS_SEQ")
+	@Column(name="ID")
+	protected Long id;
+	@Override
+	public void setId(Long id) {
+		this.id=id;
+	}
+	@Override
+	public Long getId() {
+		return id;
+	}
 	/**
 	 * Name
 	 * <ul>

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/src/main/java/com/xasecure/entity/XXGroupUser.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/entity/XXGroupUser.java b/security-admin/src/main/java/com/xasecure/entity/XXGroupUser.java
index 9eabc49..d8231e3 100644
--- a/security-admin/src/main/java/com/xasecure/entity/XXGroupUser.java
+++ b/security-admin/src/main/java/com/xasecure/entity/XXGroupUser.java
@@ -38,6 +38,20 @@ public class XXGroupUser extends XXDBBase implements java.io.Serializable {
 	private static final long serialVersionUID = 1L;
 
 
+	@Id
+	@SequenceGenerator(name="X_GROUP_USERS_SEQ",sequenceName="X_GROUP_USERS_SEQ",allocationSize=1)
+	@GeneratedValue(strategy=GenerationType.AUTO,generator="X_GROUP_USERS_SEQ")
+	@Column(name="ID")
+	protected Long id;
+	@Override
+	public void setId(Long id) {
+		this.id=id;
+	}
+
+	@Override
+	public Long getId() {
+		return id;
+	}
 
 	/**
 	 * Name

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/src/main/java/com/xasecure/entity/XXPermMap.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/entity/XXPermMap.java b/security-admin/src/main/java/com/xasecure/entity/XXPermMap.java
index f7f9b2c..e211198 100644
--- a/security-admin/src/main/java/com/xasecure/entity/XXPermMap.java
+++ b/security-admin/src/main/java/com/xasecure/entity/XXPermMap.java
@@ -38,6 +38,20 @@ public class XXPermMap extends XXDBBase implements java.io.Serializable {
 	private static final long serialVersionUID = 1L;
 
 
+	@Id
+	@SequenceGenerator(name="X_PERM_MAP_SEQ",sequenceName="X_PERM_MAP_SEQ",allocationSize=1)
+	@GeneratedValue(strategy=GenerationType.AUTO,generator="X_PERM_MAP_SEQ")
+	@Column(name="ID")
+	protected Long id;
+	@Override
+	public void setId(Long id) {
+		this.id=id;
+	}
+
+	@Override
+	public Long getId() {
+		return id;
+	}
 
 	/**
 	 * Group to which the permission belongs to

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/src/main/java/com/xasecure/entity/XXPolicyExportAudit.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/entity/XXPolicyExportAudit.java b/security-admin/src/main/java/com/xasecure/entity/XXPolicyExportAudit.java
index c8aed91..f96fec9 100644
--- a/security-admin/src/main/java/com/xasecure/entity/XXPolicyExportAudit.java
+++ b/security-admin/src/main/java/com/xasecure/entity/XXPolicyExportAudit.java
@@ -38,6 +38,20 @@ public class XXPolicyExportAudit extends XXDBBase implements java.io.Serializabl
 	private static final long serialVersionUID = 1L;
 
 
+	@Id
+	@SequenceGenerator(name="X_POLICY_EXPORT_SEQ",sequenceName="X_POLICY_EXPORT_SEQ",allocationSize=1)
+	@GeneratedValue(strategy=GenerationType.AUTO,generator="X_POLICY_EXPORT_SEQ")
+	@Column(name="ID")
+	protected Long id;
+	@Override
+	public void setId(Long id) {
+		this.id=id;
+	}
+
+	@Override
+	public Long getId() {
+		return id;
+	}
 
 	/**
 	 * XA Agent IP Address

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/src/main/java/com/xasecure/entity/XXPortalUser.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/entity/XXPortalUser.java b/security-admin/src/main/java/com/xasecure/entity/XXPortalUser.java
index a2f05b0..5b9c45e 100644
--- a/security-admin/src/main/java/com/xasecure/entity/XXPortalUser.java
+++ b/security-admin/src/main/java/com/xasecure/entity/XXPortalUser.java
@@ -37,8 +37,21 @@ import com.xasecure.entity.*;
 public class XXPortalUser extends XXDBBase implements java.io.Serializable {
 	private static final long serialVersionUID = 1L;
 
-
-
+	@Id
+	@SequenceGenerator(name="X_PORTAL_USER_SEQ",sequenceName="X_PORTAL_USER_SEQ",allocationSize=1)
+	@GeneratedValue(strategy=GenerationType.AUTO,generator="X_PORTAL_USER_SEQ")
+	@Column(name="ID")
+	protected Long id;
+		@Override
+	public void setId(Long id) {
+		// TODO Auto-generated method stub
+		this.id=id;
+	}
+	@Override
+	public Long getId() {
+		// TODO Auto-generated method stub
+		return id;
+	}
 	/**
 	 * First name of the user
 	 * <ul>

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/src/main/java/com/xasecure/entity/XXPortalUserRole.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/entity/XXPortalUserRole.java b/security-admin/src/main/java/com/xasecure/entity/XXPortalUserRole.java
index 771b697..8dbd912 100644
--- a/security-admin/src/main/java/com/xasecure/entity/XXPortalUserRole.java
+++ b/security-admin/src/main/java/com/xasecure/entity/XXPortalUserRole.java
@@ -38,7 +38,19 @@ public class XXPortalUserRole extends XXDBBase implements java.io.Serializable {
 	private static final long serialVersionUID = 1L;
 
 
-
+	@Id
+	@SequenceGenerator(name="X_PORTAL_USER_ROLE_SEQ",sequenceName="X_PORTAL_USER_ROLE_SEQ",allocationSize=1)
+	@GeneratedValue(strategy=GenerationType.AUTO,generator="X_PORTAL_USER_ROLE_SEQ")
+	@Column(name="ID")
+	protected Long id;
+	@Override
+	public void setId(Long id) {
+		this.id=id;
+	}
+	@Override
+	public Long getId() {
+		return id;
+	}
 	/**
 	 * Id of the user
 	 * <ul>

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/src/main/java/com/xasecure/entity/XXResource.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/entity/XXResource.java b/security-admin/src/main/java/com/xasecure/entity/XXResource.java
index af5853c..5b38d93 100644
--- a/security-admin/src/main/java/com/xasecure/entity/XXResource.java
+++ b/security-admin/src/main/java/com/xasecure/entity/XXResource.java
@@ -38,7 +38,19 @@ public class XXResource extends XXDBBase implements java.io.Serializable {
 	private static final long serialVersionUID = 1L;
 
 
-
+	@Id
+	@SequenceGenerator(name="X_RESOURCE_SEQ",sequenceName="X_RESOURCE_SEQ",allocationSize=1)
+	@GeneratedValue(strategy=GenerationType.AUTO,generator="X_RESOURCE_SEQ")
+	@Column(name="ID")
+	protected Long id;
+	@Override
+	public void setId(Long id) {
+		this.id=id;
+	}
+	@Override
+	public Long getId() {
+		return id;
+	}
 	/**
 	 * Name
 	 * <ul>

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/src/main/java/com/xasecure/entity/XXTrxLog.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/entity/XXTrxLog.java b/security-admin/src/main/java/com/xasecure/entity/XXTrxLog.java
index d89ff00..c91e803 100644
--- a/security-admin/src/main/java/com/xasecure/entity/XXTrxLog.java
+++ b/security-admin/src/main/java/com/xasecure/entity/XXTrxLog.java
@@ -37,8 +37,19 @@ import com.xasecure.entity.*;
 public class XXTrxLog extends XXDBBase implements java.io.Serializable {
 	private static final long serialVersionUID = 1L;
 
-
-
+	@Id
+	@SequenceGenerator(name="X_TRX_LOG_SEQ",sequenceName="X_TRX_LOG_SEQ",allocationSize=1)
+	@GeneratedValue(strategy=GenerationType.AUTO,generator="X_TRX_LOG_SEQ")
+	@Column(name="ID")
+	protected Long id;
+	@Override
+	public void setId(Long id) {
+		this.id=id;
+	}
+	@Override
+	public Long getId() {
+		return id;
+	}
 	/**
 	 * Name of the class to which the object id belongs to
 	 * <ul>

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/src/main/java/com/xasecure/entity/XXUser.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/entity/XXUser.java b/security-admin/src/main/java/com/xasecure/entity/XXUser.java
index 95cec58..bc5817a 100644
--- a/security-admin/src/main/java/com/xasecure/entity/XXUser.java
+++ b/security-admin/src/main/java/com/xasecure/entity/XXUser.java
@@ -38,7 +38,19 @@ public class XXUser extends XXDBBase implements java.io.Serializable {
 	private static final long serialVersionUID = 1L;
 
 
-
+	@Id
+	@SequenceGenerator(name="X_USER_SEQ",sequenceName="X_USER_SEQ",allocationSize=1)
+	@GeneratedValue(strategy=GenerationType.AUTO,generator="X_USER_SEQ")
+	@Column(name="ID")
+	protected Long id;
+	@Override
+	public void setId(Long id) {
+		this.id=id;
+	}
+	@Override
+	public Long getId() {
+		return id;
+	}
 	/**
 	 * Name
 	 * <ul>

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/src/main/java/com/xasecure/entity/view/VXXTrxLog.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/entity/view/VXXTrxLog.java b/security-admin/src/main/java/com/xasecure/entity/view/VXXTrxLog.java
index 7fc52f5..5865f5b 100644
--- a/security-admin/src/main/java/com/xasecure/entity/view/VXXTrxLog.java
+++ b/security-admin/src/main/java/com/xasecure/entity/view/VXXTrxLog.java
@@ -38,7 +38,8 @@ public class VXXTrxLog implements java.io.Serializable {
 	public static final int SHARE_PREF_DEFAULT = 0;
 
 	@Id
-	@GeneratedValue(strategy=GenerationType.IDENTITY)
+	@SequenceGenerator(name="V_TRX_LOG_SEQ",sequenceName="V_TRX_LOG_SEQ",allocationSize=1)
+	@GeneratedValue(strategy=GenerationType.AUTO,generator="V_TRX_LOG_SEQ")
 	@Column(name="ID")
 	protected Long id;
 

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/src/main/java/com/xasecure/rest/AssetREST.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/rest/AssetREST.java b/security-admin/src/main/java/com/xasecure/rest/AssetREST.java
index 1453ef9..2dd044b 100644
--- a/security-admin/src/main/java/com/xasecure/rest/AssetREST.java
+++ b/security-admin/src/main/java/com/xasecure/rest/AssetREST.java
@@ -334,7 +334,7 @@ public class AssetREST {
 		// searchUtil.addSearchGroup(searchCriteria, outerGroup);
 		//
 		// }
-		searchCriteria.setDistinct(true);
+		//searchCriteria.setDistinct(true);
 
 		return assetMgr.searchXResources(searchCriteria);
 	}

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/security-admin/src/main/java/com/xasecure/service/AbstractBaseResourceService.java
----------------------------------------------------------------------
diff --git a/security-admin/src/main/java/com/xasecure/service/AbstractBaseResourceService.java b/security-admin/src/main/java/com/xasecure/service/AbstractBaseResourceService.java
index cdd52a6..e5ccaac 100644
--- a/security-admin/src/main/java/com/xasecure/service/AbstractBaseResourceService.java
+++ b/security-admin/src/main/java/com/xasecure/service/AbstractBaseResourceService.java
@@ -41,6 +41,7 @@ import javax.persistence.criteria.Root;
 import com.xasecure.biz.XABizUtil;
 import com.xasecure.common.ContextUtil;
 import com.xasecure.common.DateUtil;
+import com.xasecure.common.SortField.SORT_ORDER;
 import com.xasecure.common.UserSessionBase;
 import com.xasecure.common.XAConfigUtil;
 import com.xasecure.common.MessageEnums;
@@ -241,7 +242,7 @@ public abstract class AbstractBaseResourceService<T extends XXDBBase, V extends
 		distinctCountQueryStr = "SELECT COUNT(distinct obj.id) FROM "
 				+ tEntityClass.getName() + " obj ";
 		distinctQueryStr = "SELECT distinct obj FROM " + className + " obj ";
-
+		sortFields.add(new SortField("id", "obj.id",true,SORT_ORDER.ASC));
 		registerService(this);
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/storm-agent/conf/xasecure-audit-changes.cfg
----------------------------------------------------------------------
diff --git a/storm-agent/conf/xasecure-audit-changes.cfg b/storm-agent/conf/xasecure-audit-changes.cfg
index a8d053e..f0c1050 100644
--- a/storm-agent/conf/xasecure-audit-changes.cfg
+++ b/storm-agent/conf/xasecure-audit-changes.cfg
@@ -1,5 +1,6 @@
-xasecure.audit.jpa.javax.persistence.jdbc.url		jdbc:mysql://%XAAUDIT.DB.HOSTNAME%/%XAAUDIT.DB.DATABASE_NAME%	mod create-if-not-exists
+xasecure.audit.jpa.javax.persistence.jdbc.url		%XAAUDIT.DB.JDBC_URL%											mod create-if-not-exists
 xasecure.audit.jpa.javax.persistence.jdbc.user		%XAAUDIT.DB.USER_NAME% 											mod create-if-not-exists
 xasecure.audit.jpa.javax.persistence.jdbc.password	crypted	 														mod create-if-not-exists
 xasecure.audit.repository.name						%REPOSITORY_NAME% 												mod create-if-not-exists
 xasecure.audit.credential.provider.file     		jceks://file%CREDENTIAL_PROVIDER_FILE% 							mod create-if-not-exists
+xasecure.audit.jpa.javax.persistence.jdbc.driver	%XAAUDIT.DB.JDBC_DRIVER% 										mod create-if-not-exists

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/storm-agent/scripts/install.properties
----------------------------------------------------------------------
diff --git a/storm-agent/scripts/install.properties b/storm-agent/scripts/install.properties
index 1a1ec6a..359f66b 100644
--- a/storm-agent/scripts/install.properties
+++ b/storm-agent/scripts/install.properties
@@ -8,10 +8,17 @@
 
 POLICY_MGR_URL=
 
+# Example:
+# XAAUDIT.DB.FLAVOUR=MYSQL
+# XAAUDIT.DB.FLAVOUR=ORACLE
+XAAUDIT.DB.FLAVOUR=MYSQL
+
 #
-# Location of mysql client library (please check the location of the jar file)
+# Location of db client library (please check the location of the jar file)
 #
-MYSQL_CONNECTOR_JAR=/usr/share/java/mysql-connector-java.jar
+#SQL_CONNECTOR_JAR=/usr/share/java/mysql-connector-java.jar
+#SQL_CONNECTOR_JAR=/usr/share/java/ojdbc6.jar
+SQL_CONNECTOR_JAR=/usr/share/java/mysql-connector-java.jar
 
 #
 # This is the repository name created within policy manager
@@ -76,3 +83,15 @@ SSL_KEYSTORE_FILE_PATH=agentKey.jks
 SSL_KEYSTORE_PASSWORD=myKeyFilePassword
 SSL_TRUSTSTORE_FILE_PATH=cacert
 SSL_TRUSTSTORE_PASSWORD=changeit
+
+# do not change value of below given properties as value will be assigned by system based on above settings.
+# Example:
+# MySQL:
+# XAAUDIT.DB.JDBC_URL=jdbc:mysql://localhost:3306/xasecure
+# XAAUDIT.DB.JDBC_DRIVER=com.mysql.jdbc.Driver
+# Oracle:
+# XAAUDIT.DB.JDBC_URL=jdbc:oracle:thin:@//127.0.0.1:1521/XE
+# XAAUDIT.DB.JDBC_DRIVER=oracle.jdbc.OracleDriver
+
+XAAUDIT.DB.JDBC_URL=jdbc:mysql://localhost:3306/xasecure
+XAAUDIT.DB.JDBC_DRIVER=com.mysql.jdbc.Driver

http://git-wip-us.apache.org/repos/asf/incubator-argus/blob/a0a18007/storm-agent/scripts/install.sh
----------------------------------------------------------------------
diff --git a/storm-agent/scripts/install.sh b/storm-agent/scripts/install.sh
index 5de6106..e45db1f 100644
--- a/storm-agent/scripts/install.sh
+++ b/storm-agent/scripts/install.sh
@@ -14,6 +14,17 @@ create_jceks()
 	fi
 }
 
+#Update Properties to File
+#$1 -> propertyName $2 -> newPropertyValue $3 -> fileName
+updatePropertyToFile(){
+	sed -i 's@^'$1'=[^ ]*$@'$1'='$2'@g' $3
+	#validate=`sed -i 's/^'$1'=[^ ]*$/'$1'='$2'/g' $3`	#for validation
+	validate=$(sed '/^\#/d' $3 | grep "^$1"  | tail -n 1 | cut -d "=" -f2-) # for validation
+	#echo 'V1:'$validate
+	if test -z "$validate" ; then echo "[E] '$1' not found in $3 file while Updating....!!"; exit 1; fi
+	echo "[I] File $3 Updated successfully : {'$1'}"
+}
+
 storm_dir=/usr/lib/storm
 storm_lib_dir=${storm_dir}/lib
 storm_conf_dir=/etc/storm/conf
@@ -29,16 +40,17 @@ install_dir=`dirname $0`
 [ "${install_dir}" = "." ] && install_dir=`pwd`
 
 
-#verify mysql-connector path is valid
-MYSQL_CONNECTOR_JAR=`grep '^MYSQL_CONNECTOR_JAR'  ${install_dir}/install.properties | awk -F= '{ print $2 }'`
-echo "[I] Checking MYSQL CONNECTOR FILE : $MYSQL_CONNECTOR_JAR"
-if test -f "$MYSQL_CONNECTOR_JAR"; then
-    echo "[I] MYSQL CONNECTOR FILE : $MYSQL_CONNECTOR_JAR file found"
+#verify sql-connector path is valid
+SQL_CONNECTOR_JAR=`grep '^SQL_CONNECTOR_JAR'  ${install_dir}/install.properties | awk -F= '{ print $2 }'`
+echo "[I] Checking SQL CONNECTOR FILE : $SQL_CONNECTOR_JAR"
+if test -f "$SQL_CONNECTOR_JAR"; then
+	echo "[I] SQL CONNECTOR FILE : $SQL_CONNECTOR_JAR file found"
 else
-    echo "[E] MYSQL CONNECTOR FILE : $MYSQL_CONNECTOR_JAR does not exists" ; exit 1;
+	echo "[E] SQL CONNECTOR FILE : $SQL_CONNECTOR_JAR not found, aborting installation"
+  exit 1
 fi
-#copying mysql connector jar file to lib directory
-cp ${MYSQL_CONNECTOR_JAR} ${install_dir}/lib
+#copying sql connector jar file to lib directory
+cp $SQL_CONNECTOR_JAR ${install_dir}/lib
 
 #echo "Current Install Directory: [${install_dir}]"
 
@@ -174,10 +186,43 @@ chown ${CONFIG_FILE_OWNER} ${CredFile}
 
 PROP_ARGS="-p  ${install_dir}/install.properties"
 
+to_file="${install_dir}/install.properties"
+DB_FLAVOR=`grep '^XAAUDIT.DB.FLAVOUR'  ${install_dir}/install.properties | awk -F= '{ print $2 }'`
+DB_FLAVOR=`echo $DB_FLAVOR | tr '[:lower:]' '[:upper:]'`
+if [ "${DB_FLAVOR}" == "" ]
+then
+	$DB_FLAVOR="MYSQL"
+fi
+echo "[I] Updating install.properites setting for : $DB_FLAVOR"
+
+if [ "${DB_FLAVOR}" == "MYSQL" ]
+then
+	audit_db_hostname=`grep '^XAAUDIT.DB.HOSTNAME'  ${install_dir}/install.properties | awk -F= '{ print $2 }'`
+	audit_db_name=`grep '^XAAUDIT.DB.DATABASE_NAME'  ${install_dir}/install.properties | awk -F= '{ print $2 }'`
+	propertyName=XAAUDIT.DB.JDBC_URL
+	newPropertyValue="jdbc:mysql://${audit_db_hostname}/${audit_db_name}"
+	updatePropertyToFile $propertyName $newPropertyValue $to_file
+
+	propertyName=XAAUDIT.DB.JDBC_DRIVER
+	newPropertyValue="com.mysql.jdbc.Driver"
+	updatePropertyToFile $propertyName $newPropertyValue $to_file
+fi
+
+if [ "${DB_FLAVOR}" == "ORACLE" ]
+then
+	audit_db_hostname=`grep '^XAAUDIT.DB.HOSTNAME'  ${install_dir}/install.properties | awk -F= '{ print $2 }'`
+	propertyName=XAAUDIT.DB.JDBC_URL
+	newPropertyValue="jdbc:oracle:thin:\@//${audit_db_hostname}"
+	updatePropertyToFile $propertyName $newPropertyValue $to_file
+
+	propertyName=XAAUDIT.DB.JDBC_DRIVER
+	newPropertyValue="oracle.jdbc.OracleDriver"
+	updatePropertyToFile $propertyName $newPropertyValue $to_file
+fi
 for f in ${install_dir}/installer/conf/*-changes.cfg
 do
         if [ -f ${f} ]
-        then
+	then
                 fn=`basename $f`
                 orgfn=`echo $fn | sed -e 's:-changes.cfg:.xml:'`
                 fullpathorgfn="${storm_conf_dir}/${orgfn}"


Mime
View raw message