: $Workfile:   SecurityServer.sh  $ $Revision:   1.0  $
#**********************************************************************#
#*                                                                    *#
#* Copyright (c) 2002 by Sun Microsystems, Inc.                       *#
#* All rights reserved.                                               *#
#*                                                                    *#
#**********************************************************************#

USAGE="usage: SecurityServer [-s|-r|-t|-p] user-name password"

# params:  s    start the Security Server in a background process
#          r    refresh the active Security Server process
#          t    terminate the active Security Server process
#          p    print statistics from the active Security Server process
#          USER-NAME to be authenticated / authorized for this action
#          PASSWORD for authenticating that user-name

PARAM1=$1
PARAM2=$2
PARAM3=$3
set -- `getopt prst $*`

# make sure any unexpected 'kill' in PasswordReader resets terminal echo, etc.
trap "stty icanon echo" 0

if test  "$1" != "--"
then
    case $1 in
    -s)
        echo starting Security Server...
	java -DEMPSECURITY=$EMPSECURITY -Djava.security.manager \
         -Djava.library.path=$EMPSECURITY/lib:$LD_LIBRARY_PATH \
         com.sun.emp.security.server.DirectSecurityServer $1 $PARAM2 $PARAM3
        ;;
    -r)
        echo refreshing Security Server...
	java -DEMPSECURITY=$EMPSECURITY -Djava.security.manager \
         -Djava.library.path=$EMPSECURITY/lib:$LD_LIBRARY_PATH \
         com.sun.emp.security.server.DirectSecurityServer $1 $PARAM2 $PARAM3
        ;;
    -t)
        echo terminating Security Server...
	java -DEMPSECURITY=$EMPSECURITY -Djava.security.manager \
         -Djava.library.path=$EMPSECURITY/lib:$LD_LIBRARY_PATH \
         com.sun.emp.security.server.DirectSecurityServer $1 $PARAM2 $PARAM3
        ;;
    -p)
        echo printing Security Server statistics...
	java -DEMPSECURITY=$EMPSECURITY -Djava.security.manager \
         -Djava.library.path=$EMPSECURITY/lib:$LD_LIBRARY_PATH \
         com.sun.emp.security.server.DirectSecurityServer $1 $PARAM2 $PARAM3
        ;;
    *)
# illegal option encountered
	echo $USAGE
        exit 1
    esac
else
# no option specified
	echo $USAGE
	exit 2
fi

RET=$?
if test $RET -ne 0
then echo SecurityServer command terminated with error
fi
exit $RET

