#!/bin/ksh 
#ident "%W%"

# (C) Copyright 2004 The SCO Group, Inc. All rights reserved.

trap 'exit 3' 15

# This must be installed on top of Java 1.4.2, any patch level

pkginfo -i j2jre142 > /dev/null 2>&1
if [ "$?" != "0" ]
then
	echo " "
	echo "\tThis package requires Java 1.4.2 (package j2jre142)"
	echo "\tto be installed."
	exit 1
fi

# The /usr/java/ symbolic link must be pointing to Java 1.4.2

USRJAVA=
if [ -h /usr/java ]
then
	USRJAVA=`ls -l /usr/java | awk '{ print $11 }'`
fi
if [ "$USRJAVA" != "/opt/java2-1.4.2" ]
then
	echo " "
	echo "\tThis package requires /usr/java to point to Java 1.4.2"
	exit 1
fi

# If old "SCOx CD" javasoap package is installed in Java 1.4.2 as part
# of uw713up4, no matter, this one will supercede it.  

# But if old "SCOx CD" javajsse package is installed in /usr/java/ 
# as part of uw713up4, we must alert user to remove it (obsolete and 
# harmful in Java 1.4.2 context, which now includes JSSE itself).

pkginfo -i javajsse > /dev/null 2>&1
if [ $? -eq 0 ]
then
	# javajsse might be installed against Java 1.3.1 (no problem),
	# so test for a jar file here that's not in the built-in JSSE
	if [ -f /usr/java/jre/lib/ext/jcert.jar ]
	then
		echo " "
		echo "\tYou have JSSE package javajsse installed against"
		echo "\tJava 1.4.2.  This is obsolete, since Java 1.4.2"
		echo "\tcontains a built-in JSSE.  You must remove it."
		#pkgrm -X -n javajsse
		#if [ "$?" != "0" ]
		#then
		#	echo " "
		#	echo "\tRemoval of obsolete package javajsse failed"
		#	exit 1
		#fi

		if [ -z "`grep security.provider.5=sun.security.jgss.SunProvider /usr/java/jre/lib/security/java.security 2> /dev/null `" ]
		then
			echo " "
			echo "\tYour /usr/java/jre/lib/security/java.security"
			echo "\tfile has incorrect contents, probably as a"
			echo "\tresult of previously installing obsolete"
			echo "\tpackage javajsse.  You must remove that"
			echo "\tpackage, re-install package j2jre142,"
			echo "\tand then install this package."
		fi

		exit 1
	fi

fi

# If javajsse already removed, java.security is likely missing
if [ ! -f /usr/java/jre/lib/security/java.security ]
then
	echo " "
	echo "\tYour /usr/java/jre/lib/security/java.security"
	echo "\tfile is missing, probably as a result of"
	echo "\tpreviously removing obsolete package javajsse."
	echo "\tYou must re-install package j2jre142,"
	echo "\tthen install this package."
	exit 1
fi

# Packages having request scripts, installed within set, need a response file
> $1

exit 0
