#
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation.
#
# This code is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# version 2 for more details (a copy is included in the LICENSE file that
# accompanied this code).
#
# You should have received a copy of the GNU General Public License version
# 2 along with this work; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
# or visit www.oracle.com if you need additional information or have any
# questions.
#
# @test
# @bug 6802846
# @summary jarsigner needs enhanced cert validation(options)
#
# @run shell concise_jarsigner.sh
#
if [ "${TESTJAVA}" = "" ] ; then
TESTJAVA=`dirname $JAVAC_CMD`/..
fi
# set platform-dependent variables
Windows_* )
FS="\\"
;;
* )
FS="/"
;;
esac
# ==========================================================
# First part: output format
# ==========================================================
# a.jar includes 8 unsigned, 2 signed by a1 and a2, 2 signed by a3
# Verify OK
[ $? = 0 ] || exit $LINENO
# 4(chainNotValidated)+16(hasUnsignedEntry)
[ $? = 20 ] || exit $LINENO
# 16(hasUnsignedEntry)
[ $? = 16 ] || exit $LINENO
# 16(hasUnsignedEntry)+32(notSignedByAlias)
[ $? = 48 ] || exit $LINENO
# 16(hasUnsignedEntry)
[ $? = 16 ] || exit $LINENO
# 12 entries all together
# 12 entries all listed
# 4 groups: MANIFST, unrelated, signed, unsigned
# still 4 groups, but MANIFEST group has no other file
# still 5 groups, but MANIFEST group has no other file
# ==========================================================
# Second part: exit code 2, 4, 8
# 16 and 32 already covered in the first part
# ==========================================================
# badchain signed by ca, but ca is removed later
[ $? = 2 ] || exit $LINENO
[ $? = 4 ] || exit $LINENO
[ $? = 4 ] || exit $LINENO
[ $? = 8 ] || exit $LINENO
[ $? = 8 ] || exit $LINENO
[ $? = 0 ] || exit $LINENO
[ $? = 0 ] || exit $LINENO
[ $? = 4 ] || exit $LINENO
[ $? = 0 ] || exit $LINENO
# ==========================================================
# Third part: -certchain test
# ==========================================================
# altchain signed by ca2, but ca2 is removed later
# Now altchain is still self-signed
[ $? = 0 ] || exit $LINENO
# If -certchain is used, then it's bad
[ $? = 4 ] || exit $LINENO
[ $? = 0 ] || exit $LINENO
echo OK
exit 0