#!/bin/sh
#
# $Header: security_src/jsrc/oracle/security/admin/wltmgr/owm.sbs /main/11 2009/03/24 16:03:52 tnallath Exp $
#
# Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved. 
#
#    NAME
#      owm - Shell script to run Oracle Wallet Manager
#
#    DESCRIPTION
#      Runs the Net Assistant Java Application.  This file comes in two
#      forms its original, with a .sbs extension, and its final, without
#      a .sbs extension.  The .sbs version is source for the final
#      version which the Oracle Universal Installer creates by
#      doing variable substitution at install time. Based on
#      /vobs/network_src/utl/netmgr.sbs 01/30/01
#
#    MODIFIED   (MM/DD/YY)
#    tnallath    03/24/09 - bug 8252758: help jar path
#    sturate     07/31/08 - remove dependency on oracle_home
#    skalyana    04/17/08 - bug # 3395525
#    shiahuan    03/21/08 - owm-images.jar
#    tnallath    12/31/07 - bug 6438993: use oemlt-10_1_0.jar
#    tnallath    12/10/07 - 6438993 - new help jar
#    tnallath    09/19/07 - pe 6409707 - lib32 support no longer needed
#    sturate     01/19/07 - adding osdt_core.jar and osdt_cert.jar to classpath
#    sturate     08/02/06 - removing references for oembase.jar
#    tnallath    03/16/06 - use ldapjlibloc 
#    tnallath    12/22/05 - SSL Library migration 
#    akoyfman    11/14/03 - 
#    akoyfman    10/15/03 - using ice 5.06 
#    akoyfman    03/06/03 - updating path
#    nprakash    03/20/03 - Bug 2673557 : Remove classpath
#    akoyfman    12/03/02 - updating jar name to 3_0
#    akoyfman    12/03/02 - updating scripts to use jkd1.3 and fix bug 2472890
#    akoyfman    02/19/02 - adding oembase.jar per bug 2212814
#    akoyfman    02/06/02 - bug 2207792
#    akoyfman    12/19/01 - .
#    supriya     08/19/01 - Fix for bug # 1894011
#    akoyfman    07/19/01 - 1689764
#    akoyfman    07/09/01 - bug 1785217
#    akoyfman    06/11/01 - removing starting message, bug 1775470
#    supriya     04/10/01 - Product line specific merge
#    akoyfman    03/02/01 - adding netcfgName
#    akoyfman    02/27/01 - adding $OWM_HOME
#    akoyfman    02/19/01 - changing libs
#    akoyfman    02/14/01 - fixing header
#    akoyfman    02/13/01 - modifying based on /vobs/network_src/utl/netmgr.sbs

case $ORACLE_HOME in
    "")
    # Get the dir of excecutable, if ORACLE_HOME is not set
    CMDDIR=`dirname $0`

    if [ "$CMDDIR" = "." ]; then
        CMDDIR=`pwd`;
    fi

    # Replace relative path with fully qualified path.
    if [ ! "`echo $CMDDIR|grep '^/'`" ]; then
        CMDDIR=`pwd`/$CMDDIR;
    fi

    # Set ORACLE_HOME
    ORACLE_HOME=$CMDDIR/..
    export ORACLE_HOME
esac

case $DISPLAY in
    "") echo "****DISPLAY environment variable not set!"
        echo "    Oracel Wallet Manager is a GUI tool which"
        echo "    requires that DISPLAY specify a location"
        echo "    where GUI tools can display."
        echo "    Set and export DISPLAY, then re-run."
        exit 1;;
esac

# make sure only user can read their wallets. 
umask 77

unset ORA_SEC_WLT

# Unset any existing JAVA_HOME variable to ensure that only
# the JRE we want to use is used.
unset JAVA_HOME

# External Directory Variables set by the Installer 
JRE_HOME=%s_jreLocation%
JLIBDIR=%s_jlibDir%
LDAPLIBDIR=%s_ldapjlibDir%
OWMLOCATION=%s_owmLocation%
ORACLASSDIR=%s_oracleClasses%
OSDTDIR=%s_osdtDir%

# External File Variables set by the Installer
SHAREJAR=$JLIBDIR/%s_shareName%
EWTJAR=$JLIBDIR/%s_ewtName%
SWINGJAR=$JLIBDIR/%s_swingallName%
HELPJAR=$JLIBDIR/%s_helpName%:$JLIBDIR/%s_helpshareName%:$JLIBDIR/%s_jewtName%
EWTCOMPATJAR=$JLIBDIR/%s_ewtcompatName%:$JLIBDIR/%s_ewtcompat33Name%
#OEMBASEJAR=$JLIBDIR/%s_oemltName%:$JLIBDIR/%s_oembaseName%:$JLIBDIR/%s_icebrowser5Name%
OEMLTJAR=$JLIBDIR/%s_oemltName%:$JLIBDIR/%s_oemlt101Name%:$JLIBDIR/%s_icebrowserName%:$JLIBDIR/%s_icebrowser5Name%
NETCFGJAR=$JLIBDIR/%s_netcfgName%
ORACLEPKIJAR=$JLIBDIR/%s_oraclepkiName%
OSDTCOREJAR=$OSDTDIR/osdt_core.jar
OSDTCERTJAR=$OSDTDIR/osdt_cert.jar

PATH=$JRE_HOME/bin:$PATH
export PATH

# Set JRE Classpath
JRE_CLASSPATH=$JRE_HOME/lib:$JRE_HOME/lib/rt.jar:$JRE_HOME/lib/i18n.jar
export JRE_CLASSPATH


# Set SDK Classpath
SDK_CLASSPATH=$EWTJAR:$EWTCOMPATJAR:$HELPJAR:$SHAREJAR:$SWINGJAR:$NETCFGJAR:$ORACLEPKIJAR
export SDK_CLASSPATH

# Set ELA Classpath
#ELA_CLASSPATH=$ORACLE_HOME/network/jsrc/oracle/security/wallet/ela1.jar:$ORACLE_HOME/network/jsrc/oracle/security/wallet/ela2.jar

#Set Class Creation Path
OWM_CLASS=$OWMLOCATION/owm-3_0.jar:$OWMLOCATION/owm-images.jar:$OWMLOCATION/owm_help.jar
export OWM_CLASS

# Set Classpath for the oracle wallet manager
# Set Full classpath [Current dir+Source dir+JRE+SDK]
#CLASSPATH=$JRE_CLASSPATH:$SDK_CLASSPATH:$OEMBASEJAR:$ORACLASSDIR:$OWM_CLASS
CLASSPATH=$JRE_CLASSPATH:$SDK_CLASSPATH:$OEMLTJAR:$ORACLASSDIR:$OWM_CLASS:$OSDTCOREJAR:$OSDTCERTJAR
export CLASSPATH

# Get the platform
PLATFORM=`uname`

# Some platforms may need other JVM environment variables set
# or unset as appropriate.
case $PLATFORM in "AIX")
   JAVA_COMPILER=NONE
   export JAVA_COMPILER
esac

# Linux platform uses native threads.
SET_DEFAULT=YES
case $PLATFORM in "Linux")
   SET_DEFAULT=NO
   THREADS_FLAG=native 
   export THREADS_FLAG
esac
case $SET_DEFAULT in "YES")
#  we only use green threads for the other platforms
   THREADS_TYPE=green_threads
   export THREADS_TYPE
esac

# Set the shared library path for JNI shared libraries
# A few platforms use an environment variable other than LD_LIBRARY_PATH
SET_DEFAULT_VAR=YES
SLLIBDIRNAME=lib

# for Sparc64, HP-PA, HPI invoke java with -d64 option to run in 64-bit mode.
JAVAMODE=
# for specific platforms reset variables and set others as needed.
case $PLATFORM in "HP-UX")
   JAVAMODE=-d64
esac
case $PLATFORM in "AIX")
   SET_DEFAULT_VAR=NO
   LIBPATH=$ORACLE_HOME/$SLLIBDIRNAME:$ORACLE_HOME/ldap/$SLLIBDIRNAME:$LIBPATH
   export LIBPATH
esac
case $PLATFORM in "SunOS")
   PLATFORM_ARCH=`uname -p`
   case $PLATFORM_ARCH in "sparc")
       JAVAMODE=-d64
       JRE_CLASSPATH=$JRE_HOME/lib/sparcv9:$JRE_HOME/lib/rt.jar:$JRE_HOME/lib/i18n.jar
   esac
esac
# if still selected, set the default variable name:LD_LIBRARY_PATH.
case $SET_DEFAULT_VAR in "YES")
   LD_LIBRARY_PATH=$ORACLE_HOME/$SLLIBDIRNAME:$ORACLE_HOME/ldap/$SLLIBDIRNAME:$LD_LIBRARY_PATH
   export LD_LIBRARY_PATH
esac

if [ x$ARGUMENT1 = x"-pkcs11" ]; then
   LD_LIBRARY_PATH_64=$ORACLE_HOME/lib:$ORACLE_HOME/ldap/lib:$LD_LIBRARY_PATH_64
   export LD_LIBRARY_PATH_64
fi

# Run the wallet manager tool
$JRE_HOME/bin/java $JAVAMODE -Dsun.java2d.font.DisableAlgorithmicStyles=true -DORACLE_HOME=$ORACLE_HOME -DOWM_HOME=%s_owmHome% -cp $CLASSPATH oracle.security.admin.wltmgr.owma.OwmaApp oracle.security.admin.wltmgr.owma.OwmaApp

echo "Done."
