提交 fe6868a5 编写于 作者: S sherman

Merge

...@@ -24,3 +24,4 @@ d8eb2738db6b148911177d9bcfe888109b7f2f71 jdk7-b44 ...@@ -24,3 +24,4 @@ d8eb2738db6b148911177d9bcfe888109b7f2f71 jdk7-b44
b4ac413b1f129eeef0acab3f31081c1b7dfe3b27 jdk7-b47 b4ac413b1f129eeef0acab3f31081c1b7dfe3b27 jdk7-b47
5fbd9ea7def17186693b6f7099b5d0dc73903eee jdk7-b48 5fbd9ea7def17186693b6f7099b5d0dc73903eee jdk7-b48
8311105ea7a3db7bcbcb2b696459127c7f2297a4 jdk7-b49 8311105ea7a3db7bcbcb2b696459127c7f2297a4 jdk7-b49
58ba2cd5a25053684ec53205d95edeeaa0006f13 jdk7-b50
...@@ -41,7 +41,15 @@ include $(BUILDDIR)/common/Defs.gmk ...@@ -41,7 +41,15 @@ include $(BUILDDIR)/common/Defs.gmk
# Note : some targets are double colon rules and some single colon rules # Note : some targets are double colon rules and some single colon rules
# within common included gmk files : that is why the following for loop # within common included gmk files : that is why the following for loop
# has been duplicated. # has been duplicated.
SUBDIRS = snmp
# When building the openjdk, build snmp only if importing binary plugs,
ifdef OPENJDK
ifeq ($(IMPORT_BINARY_PLUGS),true)
SUBDIRS = snmp
endif
else
SUBDIRS = snmp
endif
all build: all build:
$(SUBDIRS-loop) $(SUBDIRS-loop)
......
...@@ -116,6 +116,14 @@ LDFLAGS_COMMON_sparc += -m32 -mcpu=v9 ...@@ -116,6 +116,14 @@ LDFLAGS_COMMON_sparc += -m32 -mcpu=v9
CFLAGS_REQUIRED = $(CFLAGS_REQUIRED_$(ARCH)) CFLAGS_REQUIRED = $(CFLAGS_REQUIRED_$(ARCH))
LDFLAGS_COMMON += $(LDFLAGS_COMMON_$(ARCH)) LDFLAGS_COMMON += $(LDFLAGS_COMMON_$(ARCH))
# If this is a --hash-style=gnu system, use --hash-style=both
# The gnu .hash section won't work on some Linux systems like SuSE 10.
_HAS_HASH_STYLE_GNU:=$(shell $(CC) -dumpspecs | $(GREP) -- '--hash-style=gnu')
ifneq ($(_HAS_HASH_STYLE_GNU),)
LDFLAGS_HASH_STYLE = -Wl,--hash-style=both
endif
LDFLAGS_COMMON += $(LDFLAGS_HASH_STYLE)
# #
# Selection of warning messages # Selection of warning messages
# #
......
...@@ -68,24 +68,6 @@ ifeq ($(PLATFORM), linux) ...@@ -68,24 +68,6 @@ ifeq ($(PLATFORM), linux)
else else
CXX = $(COMPILER_PATH)g++ CXX = $(COMPILER_PATH)g++
endif endif
ifneq ("$(findstring sparc,$(ARCH))", "")
# sparc or sparcv9
REQUIRED_CC_VER = 4.0
REQUIRED_GCC_VER = 4.0.*
else
REQUIRED_CC_VER = 3.2
ifeq ($(ARCH_DATA_MODEL), 32)
REQUIRED_GCC_VER = 3.2.1*
REQUIRED_GCC_VER_INT = 3.2.1-7a
else
ifeq ($(ARCH), amd64)
REQUIRED_GCC_VER = 3.2.*
endif
ifeq ($(ARCH), ia64)
REQUIRED_GCC_VER = 2.9[56789].*
endif
endif
endif
# Option used to create a shared library # Option used to create a shared library
SHARED_LIBRARY_FLAG = -shared -mimpure-text SHARED_LIBRARY_FLAG = -shared -mimpure-text
SUN_COMP_VER := $(shell $(CC) --verbose 2>&1 ) SUN_COMP_VER := $(shell $(CC) --verbose 2>&1 )
...@@ -98,17 +80,9 @@ ifeq ($(PLATFORM), solaris) ...@@ -98,17 +80,9 @@ ifeq ($(PLATFORM), solaris)
CC = $(COMPILER_PATH)gcc CC = $(COMPILER_PATH)gcc
CPP = $(COMPILER_PATH)gcc -E CPP = $(COMPILER_PATH)gcc -E
CXX = $(COMPILER_PATH)g++ CXX = $(COMPILER_PATH)g++
REQUIRED_CC_VER = 3.2
# Option used to create a shared library # Option used to create a shared library
SHARED_LIBRARY_FLAG = -G SHARED_LIBRARY_FLAG = -G
# But gcc is still needed no matter what on 32bit
ifeq ($(ARCH_DATA_MODEL), 32)
REQUIRED_GCC_VER = 2.95
GCC =$(GCC_COMPILER_PATH)gcc
_GCC_VER :=$(shell $(GCC) -dumpversion 2>&1 )
GCC_VER :=$(call GetVersion,"$(_GCC_VER)")
endif
endif endif
......
...@@ -41,8 +41,6 @@ ifeq ($(PLATFORM), windows) ...@@ -41,8 +41,6 @@ ifeq ($(PLATFORM), windows)
# Fill in unknown values # Fill in unknown values
COMPILER_NAME=Unknown MSVC Compiler COMPILER_NAME=Unknown MSVC Compiler
COMPILER_VERSION= COMPILER_VERSION=
REQUIRED_CC_VER=
REQUIRED_LINK_VER=
# unset any GNU Make settings of MFLAGS and MAKEFLAGS which may mess up nmake # unset any GNU Make settings of MFLAGS and MAKEFLAGS which may mess up nmake
NMAKE = MFLAGS= MAKEFLAGS= $(COMPILER_PATH)nmake -nologo NMAKE = MFLAGS= MAKEFLAGS= $(COMPILER_PATH)nmake -nologo
...@@ -56,8 +54,6 @@ ifeq ($(PLATFORM), windows) ...@@ -56,8 +54,6 @@ ifeq ($(PLATFORM), windows)
CC_MAJORVER :=$(call MajorVersion,$(CC_VER)) CC_MAJORVER :=$(call MajorVersion,$(CC_VER))
ifeq ($(CC_MAJORVER), 13) ifeq ($(CC_MAJORVER), 13)
# This should be: CC_VER=13.10.3077 LINK_VER=7.10.3077 # This should be: CC_VER=13.10.3077 LINK_VER=7.10.3077
REQUIRED_CC_VER = 13.10.3077
REQUIRED_LINK_VER = 7.10.3077
COMPILER_NAME=Visual Studio .NET 2003 Professional C++ COMPILER_NAME=Visual Studio .NET 2003 Professional C++
COMPILER_VERSION=VS2003 COMPILER_VERSION=VS2003
REBASE = $(COMPILER_PATH)../../Common7/Tools/Bin/rebase REBASE = $(COMPILER_PATH)../../Common7/Tools/Bin/rebase
...@@ -67,9 +63,6 @@ ifeq ($(PLATFORM), windows) ...@@ -67,9 +63,6 @@ ifeq ($(PLATFORM), windows)
endif endif
endif endif
ifeq ($(CC_MAJORVER), 14) ifeq ($(CC_MAJORVER), 14)
# This should be: CC_VER=14.00.50727.42 LINK_VER=8.00.50727.42
REQUIRED_CC_VER = 14.00.50727.42
REQUIRED_LINK_VER = 8.00.50727.42
COMPILER_NAME=Visual Studio 8 COMPILER_NAME=Visual Studio 8
COMPILER_VERSION=VS2005 COMPILER_VERSION=VS2005
REBASE = $(COMPILER_PATH)../../Common8/Tools/Bin/rebase REBASE = $(COMPILER_PATH)../../Common8/Tools/Bin/rebase
...@@ -80,9 +73,6 @@ ifeq ($(PLATFORM), windows) ...@@ -80,9 +73,6 @@ ifeq ($(PLATFORM), windows)
endif endif
endif endif
ifeq ($(CC_MAJORVER), 15) ifeq ($(CC_MAJORVER), 15)
# This should be: CC_VER=15.00.21022.08 LINK_VER=9.00.21022.08
REQUIRED_CC_VER = 15.00.21022.08
REQUIRED_LINK_VER = 9.00.21022.08
COMPILER_NAME=Visual Studio 9 COMPILER_NAME=Visual Studio 9
COMPILER_VERSION=VS2008 COMPILER_VERSION=VS2008
#rebase and midl moved out of Visual Studio into the SDK: #rebase and midl moved out of Visual Studio into the SDK:
...@@ -99,14 +89,6 @@ ifeq ($(PLATFORM), windows) ...@@ -99,14 +89,6 @@ ifeq ($(PLATFORM), windows)
CC_MAJORVER :=$(call MajorVersion,$(CC_VER)) CC_MAJORVER :=$(call MajorVersion,$(CC_VER))
CC_MINORVER :=$(call MinorVersion,$(CC_VER)) CC_MINORVER :=$(call MinorVersion,$(CC_VER))
CC_MICROVER :=$(call MicroVersion,$(CC_VER)) CC_MICROVER :=$(call MicroVersion,$(CC_VER))
ifeq ($(ARCH), ia64)
REQUIRED_CC_VER = 13.00.9337.7
REQUIRED_LINK_VER = 7.00.9337.7
endif
ifeq ($(ARCH), amd64)
REQUIRED_CC_VER = 14.00.40310.41
REQUIRED_LINK_VER = 8.00.40310.39
endif
ifeq ($(CC_MAJORVER), 13) ifeq ($(CC_MAJORVER), 13)
ifeq ($(ARCH), ia64) ifeq ($(ARCH), ia64)
# This should be: CC_VER=13.00.9337.7 LINK_VER=7.00.9337.7 # This should be: CC_VER=13.00.9337.7 LINK_VER=7.00.9337.7
......
...@@ -32,27 +32,19 @@ COMPILER_NAME=Sun Studio ...@@ -32,27 +32,19 @@ COMPILER_NAME=Sun Studio
# Sun Studio Compiler settings specific to Solaris # Sun Studio Compiler settings specific to Solaris
ifeq ($(PLATFORM), solaris) ifeq ($(PLATFORM), solaris)
COMPILER_VERSION=SS12 COMPILER_VERSION=SS12
REQUIRED_CC_VER=5.9
CC = $(COMPILER_PATH)cc CC = $(COMPILER_PATH)cc
CPP = $(COMPILER_PATH)cc -E CPP = $(COMPILER_PATH)cc -E
CXX = $(COMPILER_PATH)CC CXX = $(COMPILER_PATH)CC
LINT = $(COMPILER_PATH)lint LINT = $(COMPILER_PATH)lint
# Option used to create a shared library # Option used to create a shared library
SHARED_LIBRARY_FLAG = -G SHARED_LIBRARY_FLAG = -G
# But gcc is still needed no matter what on 32bit
ifeq ($(ARCH_DATA_MODEL), 32)
REQUIRED_GCC_VER = 2.95
GCC =$(GCC_COMPILER_PATH)gcc GCC =$(GCC_COMPILER_PATH)gcc
_GCC_VER :=$(shell $(GCC) -dumpversion 2>&1 )
GCC_VER :=$(call GetVersion,"$(_GCC_VER)")
endif
endif endif
# Sun Studio Compiler settings specific to Linux # Sun Studio Compiler settings specific to Linux
ifeq ($(PLATFORM), linux) ifeq ($(PLATFORM), linux)
# This has not been tested # This has not been tested
COMPILER_VERSION=SS12 COMPILER_VERSION=SS12
REQUIRED_CC_VER=5.9
CC = $(COMPILER_PATH)cc CC = $(COMPILER_PATH)cc
CPP = $(COMPILER_PATH)cc -E CPP = $(COMPILER_PATH)cc -E
CXX = $(COMPILER_PATH)CC CXX = $(COMPILER_PATH)CC
......
#
# Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License version 2 only, as
# published by the Free Software Foundation. Sun designates this
# particular file as subject to the "Classpath" exception as provided
# by Sun in the LICENSE file that accompanied this code.
#
# 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
#
# WARNING: This file is shared with other workspaces.
#
# This file needs these set: CC_VERSION, PLATFORM, ARCH_FAMILY, and ARCH_DATA_MODEL.
##########################################################################
#
# List of JDK official minimum, expected, or required versions:
#
# REQUIRED_ALSA_VERSION
# Linux only: The ALSA sound library version expected.
#
# REQUIRED_ANT_VER
# The minimum 'ant' version.
#
# REQUIRED_BOOT_VER
# The minimum boot jdk version.
#
# REQUIRED_CC_VER
# The primary C compiler version expected.
#
# REQUIRED_CYGWIN_VER
# Windows only: If CYGWIN is used, the minimum CYGWIN version.
#
# REQUIRED_DXSDK_VER
# Windows only: The version of DirectX SDK expected.
#
# REQUIRED_FREE_SPACE
# The minimum disk space needed as determined by running 'du -sk' on a fully
# built workspace.
#
# REQUIRED_FREETYPE_VERSION
# If we are using freetype, the freetype version expected.
#
# REQUIRED_GCC_VER
# Solaris and Linux only. The required version of gcc/g++ for the plugin.
#
# REQUIRED_LINK_VER
# Windows only: The version of link.exe expected.
#
# REQUIRED_MAKE_VER
# The minimum version of GNU make.
#
# REQUIRED_MKS_VER
# Windows only: If MKS used instead of CYGWIN, the minimum version of MKS.
#
# REQUIRED_OS_VARIANT_NAME
# The OS variation name required.
# Solaris: Solaris or OpenSolaris
# Windows: Windows2000, WindowsXP, Windows2003, etc.
# Linux: Fedora, RedHat, SuSE, Ubuntu, etc.
#
# REQUIRED_OS_VARIANT_VERSION
# The version number associated with the above OS variant name.
# Solaris: output of uname -r
# Windows: 5.0 for Windows2000, 5.1 for WindowsXP, 5.2 for Windows2003, etc.
# Linux: number for the variant, e.g. 9 for Fedora 9
#
# REQUIRED_OS_VERSION
# The formal OS version number.
# Solaris & Windows: same as REQUIRED_OS_VARIANT_VERSION
# Linux: the kernel version, or output of uname -r
#
# REQUIRED_UNZIP_VER
# The minimum version of unzip.
#
# REQUIRED_ZIP_VER
# The minimum version of unzip.
#
###########
#
# Differences in the build platform from these versions may trigger warnings
# messages during the sanity checking when building the JDK.
#
# When building the OpenJDK most of these required or expected versions are
# ignored or allowed to vary widely to accomodate the many build situations
# of the OpenJDK.
#
##########################################################################
# Solaris specific
ifeq ($(PLATFORM), solaris)
REQUIRED_OS_VERSION = 5.10
REQUIRED_OS_VARIANT_NAME = Solaris
REQUIRED_OS_VARIANT_VERSION = $(REQUIRED_OS_VERSION)
ifeq ($(ARCH_FAMILY), sparc)
REQUIRED_FREE_SPACE = 1300000
else
REQUIRED_FREE_SPACE = 1040000
endif
ifeq ($(CC_VERSION),sun)
REQUIRED_CC_VER = 5.9
endif
ifeq ($(CC_VERSION),gcc)
REQUIRED_CC_VER = 3.4.3
endif
REQUIRED_GCC_VER = 2.95.2
endif
# Linux specific
ifeq ($(PLATFORM), linux)
REQUIRED_OS_VERSION = 2.6
REQUIRED_OS_VARIANT_NAME = Fedora
REQUIRED_OS_VARIANT_VERSION = 9
REQUIRED_FREE_SPACE = 1460000
REQUIRED_ALSA_VERSION = 0.9.1
REQUIRED_GCC_VER = 2.95
ifeq ($(CC_VERSION),gcc)
REQUIRED_CC_VER = 4.3.0
endif
ifeq ($(CC_VERSION),sun)
REQUIRED_CC_VER = 5.9
endif
endif
# Windows specific
ifeq ($(PLATFORM), windows)
ifeq ($(ARCH_DATA_MODEL),64)
REQUIRED_OS_VERSION = 5.2
REQUIRED_OS_VARIANT_NAME = Windows2003
else
REQUIRED_OS_VERSION = 5.1
REQUIRED_OS_VARIANT_NAME = WindowsXP
endif
REQUIRED_OS_VARIANT_VERSION = $(REQUIRED_OS_VERSION)
REQUIRED_CYGWIN_VER = 4.0
REQUIRED_MKS_VER = 6.1
REQUIRED_FREE_SPACE = 500000
REQUIRED_DXSDK_VER = 0x0900
ifeq ($(CC_VERSION),msvc)
ifeq ($(ARCH_DATA_MODEL), 32)
REQUIRED_CC_VER = 15.00.21022.08
REQUIRED_LINK_VER = 9.00.21022.08
else
ifeq ($(ARCH), ia64)
REQUIRED_CC_VER = 13.00.9337.7
REQUIRED_LINK_VER = 7.00.9337.7
endif
ifeq ($(ARCH), amd64)
REQUIRED_CC_VER = 14.00.40310.41
REQUIRED_LINK_VER = 8.00.40310.39
endif
endif
endif
ifeq ($(CC_VERSION),gcc)
REQUIRED_CC_VER = 3.4.3
endif
endif
# Generic
REQUIRED_ANT_VER = 1.6.3
REQUIRED_BOOT_VER = 1.5
REQUIRED_FREETYPE_VERSION = 2.3.0
REQUIRED_MAKE_VER = 3.78
REQUIRED_UNZIP_VER = 5.12
REQUIRED_ZIP_VER = 2.2
...@@ -136,10 +136,7 @@ endif ...@@ -136,10 +136,7 @@ endif
UNIXCOMMAND_PATH:=$(call AltCheckSpaces,UNIXCOMMAND_PATH) UNIXCOMMAND_PATH:=$(call AltCheckSpaces,UNIXCOMMAND_PATH)
# Get version of MKS or CYGWIN # Get version of MKS or CYGWIN
ifdef USING_CYGWIN ifndef USING_CYGWIN
_CYGWIN_VER :=$(shell $(UNAME))
CYGWIN_VER :=$(call GetVersion,$(_CYGWIN_VER))
else # MKS
_MKS_VER :=$(shell $(MKSINFO) 2>&1 | $(GREP) Release | $(TAIL) -1 | $(SED) -e 's@.*\(Release.*\)@\1@') _MKS_VER :=$(shell $(MKSINFO) 2>&1 | $(GREP) Release | $(TAIL) -1 | $(SED) -e 's@.*\(Release.*\)@\1@')
MKS_VER :=$(call GetVersion,$(_MKS_VER)) MKS_VER :=$(call GetVersion,$(_MKS_VER))
# At this point, we can re-define FullPath to use DOSNAME_CMD # At this point, we can re-define FullPath to use DOSNAME_CMD
......
...@@ -116,9 +116,9 @@ $(shell \ ...@@ -116,9 +116,9 @@ $(shell \
fi) fi)
endef endef
# Given a line of text, get the major.minor version number from it # Given a line of text, get the version number from it
define GetVersion define GetVersion
$(shell echo $1 | sed -e 's@[^1-9]*\([1-9][0-9]*\.[0-9][0-9]*\).*@\1@' ) $(shell echo $1 | sed -e 's@[^0-9]*\([0-9][0-9]*\.[0-9][.0-9]*\).*@\1@' )
endef endef
# Given a major.minor.micro version, return the major, minor, or micro number # Given a major.minor.micro version, return the major, minor, or micro number
...@@ -133,26 +133,26 @@ $(if $(word 3, $(subst ., ,$1)),$(word 3, $(subst ., ,$1)),0) ...@@ -133,26 +133,26 @@ $(if $(word 3, $(subst ., ,$1)),$(word 3, $(subst ., ,$1)),0)
endef endef
# Macro that returns missing, same, newer, or older $1=version $2=required # Macro that returns missing, same, newer, or older $1=version $2=required
# (currently does not check the micro number)
define CheckVersions define CheckVersions
$(shell \ $(shell \
if [ "$1" = "" -o "$2" = "" ]; then \ if [ "$1" = "" -o "$2" = "" ]; then \
echo missing; \ echo missing; \
else \ elif [ "$1" = "$2" ]; then \
if [ "$1" = "$2" ]; then \
echo same; \ echo same; \
else \ elif [ $(call MajorVersion,$1) -lt $(call MajorVersion,$2) ] ; then \
if [ $(call MajorVersion,$1) -lt $(call MajorVersion,$2) ] ; then \
echo older; \ echo older; \
else \ elif [ $(call MajorVersion,$1) -gt $(call MajorVersion,$2) ] ; then \
if [ $(call MajorVersion,$1) -eq $(call MajorVersion,$2) -a \ echo newer; \
$(call MinorVersion,$1) -lt $(call MinorVersion,$2) ]; then \ elif [ $(call MinorVersion,$1) -lt $(call MinorVersion,$2) ]; then \
echo older; \ echo older; \
else \ elif [ $(call MinorVersion,$1) -gt $(call MinorVersion,$2) ]; then \
echo newer; \ echo newer; \
fi; \ elif [ $(call MicroVersion,$1) -lt $(call MicroVersion,$2) ]; then \
fi; \ echo older; \
fi; \ elif [ $(call MicroVersion,$1) -gt $(call MicroVersion,$2) ]; then \
echo newer; \
else \
echo same; \
fi) fi)
endef endef
...@@ -561,3 +561,6 @@ endif ...@@ -561,3 +561,6 @@ endif
# Get shared compiler settings # Get shared compiler settings
include $(JDK_MAKE_SHARED_DIR)/Compiler.gmk include $(JDK_MAKE_SHARED_DIR)/Compiler.gmk
# Get the REQUIRED versions
include $(JDK_MAKE_SHARED_DIR)/Defs-versions.gmk
...@@ -51,9 +51,6 @@ PLATFORM_SHARED=done ...@@ -51,9 +51,6 @@ PLATFORM_SHARED=done
# USER login name of user (minus blanks) # USER login name of user (minus blanks)
# PLATFORM windows, solaris, or linux # PLATFORM windows, solaris, or linux
# VARIANT OPT or DBG, OPT is the default # VARIANT OPT or DBG, OPT is the default
# OS_NAME solaris, linux, or nt
# OS_VERSION specific version of os, 5.10, 2.4.9-e.3, etc.
# OS_VENDOR company name
# TEMP_DISK /tmp or C:/temp # TEMP_DISK /tmp or C:/temp
# ARCH_DATA_MODEL 32 or 64 # ARCH_DATA_MODEL 32 or 64
# ARCH sparc, sparcv9, i586, amd64, or ia64 # ARCH sparc, sparcv9, i586, amd64, or ia64
...@@ -72,29 +69,11 @@ PLATFORM_SHARED=done ...@@ -72,29 +69,11 @@ PLATFORM_SHARED=done
# ISA_DIR solaris only: /sparcv9 or /amd64 # ISA_DIR solaris only: /sparcv9 or /amd64
# LIBARCH32 solaris only: sparc or i386 # LIBARCH32 solaris only: sparc or i386
# LIBARCH64 solaris only: sparcv9 or amd64 # LIBARCH64 solaris only: sparcv9 or amd64
# REQUIRED_WINDOWS_VERSION windows only: specific version of windows
# USING_CYGWIN windows only: true or false # USING_CYGWIN windows only: true or false
# WINDOWS_NT_VERSION_STRING windows only: long version name
# REQUIRED_OS_VERSION required OS version, e.g. 5.10, 2.4
# REQUIRED_FREE_SPACE minimum disk space needed for outputdir
# ISHIELD_TEMP_MIN windows only: minimum disk space in temp area # ISHIELD_TEMP_MIN windows only: minimum disk space in temp area
# REQUIRED_ZIP_VER required version of zip
# REQUIRED_UNZIP_VER required version of unzip
# REQUIRED_DXSDK_VER windows only: required version of DirectX
# LINUX_VERSION_INFO linux only: location of linux release file
# REQUIRED_LINUX_VER linux only: required version of linux
# REQUIRED_LINUX_FULLVER linux only: required full version of linux
# REQUIRED_ALSA_VERSION linux only: required version of ALSA
# REQUIRED_FREETYPE_VERSION openjdk only: required version of freetype
SYSTEM_UNAME := $(shell uname) SYSTEM_UNAME := $(shell uname)
# Normal boot jdk is previous release, but a hard requirement is a 1.5 boot
REQUIRED_BOOT_VER = 1.5
# If we are using freetype, this is the required version
REQUIRED_FREETYPE_VERSION=2.3.0
# #
# Prune out all known SCM (Source Code Management) directories # Prune out all known SCM (Source Code Management) directories
# so they will not be included when copying directory trees # so they will not be included when copying directory trees
...@@ -113,8 +92,6 @@ endif ...@@ -113,8 +92,6 @@ endif
# Platform settings specific to Solaris # Platform settings specific to Solaris
ifeq ($(SYSTEM_UNAME), SunOS) ifeq ($(SYSTEM_UNAME), SunOS)
PLATFORM = solaris PLATFORM = solaris
OS_NAME = solaris
OS_VERSION := $(shell uname -r)
# Solaris sparc build can be either 32-bit or 64-bit. # Solaris sparc build can be either 32-bit or 64-bit.
# Default to 32, but allow explicit setting to 32 or 64. # Default to 32, but allow explicit setting to 32 or 64.
ifndef ARCH_DATA_MODEL ifndef ARCH_DATA_MODEL
...@@ -166,16 +143,6 @@ ifeq ($(SYSTEM_UNAME), SunOS) ...@@ -166,16 +143,6 @@ ifeq ($(SYSTEM_UNAME), SunOS)
endif endif
# Suffix for file bundles used in previous release # Suffix for file bundles used in previous release
BUNDLE_FILE_SUFFIX=.tar BUNDLE_FILE_SUFFIX=.tar
OS_VENDOR = Sun Microsystems
# Required Solaris version
REQUIRED_OS_VERSION = 5.10
# Minimum disk space needed as determined by running 'du -sk' on
# a fully built workspace.
ifeq ($(ARCH_FAMILY), sparc)
REQUIRED_FREE_SPACE=1300000
else
REQUIRED_FREE_SPACE=1040000
endif
# How much RAM does this machine have: # How much RAM does this machine have:
MB_OF_MEMORY=$(shell /etc/prtconf | fgrep 'Memory size:' | expand | cut -d' ' -f3) MB_OF_MEMORY=$(shell /etc/prtconf | fgrep 'Memory size:' | expand | cut -d' ' -f3)
endif endif
...@@ -183,8 +150,6 @@ endif ...@@ -183,8 +150,6 @@ endif
# Platform settings specific to Linux # Platform settings specific to Linux
ifeq ($(SYSTEM_UNAME), Linux) ifeq ($(SYSTEM_UNAME), Linux)
PLATFORM = linux PLATFORM = linux
OS_NAME = linux
OS_VERSION := $(shell uname -r)
# Arch and OS name/version # Arch and OS name/version
mach := $(shell uname -m) mach := $(shell uname -m)
archExpr = case "$(mach)" in \ archExpr = case "$(mach)" in \
...@@ -242,32 +207,6 @@ ifeq ($(SYSTEM_UNAME), Linux) ...@@ -242,32 +207,6 @@ ifeq ($(SYSTEM_UNAME), Linux)
# Suffix for file bundles used in previous release # Suffix for file bundles used in previous release
BUNDLE_FILE_SUFFIX=.tar.gz BUNDLE_FILE_SUFFIX=.tar.gz
# Minimum disk space needed as determined by running 'du -sk' on
# a fully built workspace.
REQUIRED_FREE_SPACE=1460000
LINUX_VERSION_INFO = /etc/redhat-release
OS_VENDOR = Red Hat
ifeq ($(ARCH_DATA_MODEL), 32)
REQUIRED_LINUX_VER = Advanced Server
REQUIRED_LINUX_FULLVER = Advanced Server release 2.1AS
REQUIRED_OS_VERSION = 2.4.9-e.3
else
ifeq ($(ARCH), amd64)
LINUX_VERSION_INFO = /etc/SuSE-release
OS_VENDOR = SuSE Enterprise
REQUIRED_LINUX_VER = 8.1
REQUIRED_LINUX_FULLVER = $(REQUIRED_LINUX_VER) SLSE AMD64
REQUIRED_OS_VERSION = 2.4.19-SMP
else
REQUIRED_LINUX_VER = Advanced Server
REQUIRED_LINUX_FULLVER = Advanced Server release 2.1AS 64 bit
REQUIRED_OS_VERSION = 2.4.19-SMP
endif
endif
ifneq ($(ARCH), ia64)
# ALSA 0.9.1 and above
REQUIRED_ALSA_VERSION = ^((0[.]9[.][1-9])|(1[.]0[.][0-9]))[0-9]*
endif
# How much RAM does this machine have: # How much RAM does this machine have:
MB_OF_MEMORY := $(shell free -m | fgrep Mem: | awk '{print $$2;}' ) MB_OF_MEMORY := $(shell free -m | fgrep Mem: | awk '{print $$2;}' )
endif endif
...@@ -275,23 +214,15 @@ endif ...@@ -275,23 +214,15 @@ endif
# Windows with and without CYGWIN will be slightly different # Windows with and without CYGWIN will be slightly different
ifeq ($(SYSTEM_UNAME), Windows_NT) ifeq ($(SYSTEM_UNAME), Windows_NT)
PLATFORM = windows PLATFORM = windows
OS_VERSION := $(shell uname -r)
WINDOWS_NT_VERSION_STRING=Windows_NT
REQUIRED_MKS_VER=6.1
endif endif
ifneq (,$(findstring CYGWIN,$(SYSTEM_UNAME))) ifneq (,$(findstring CYGWIN,$(SYSTEM_UNAME)))
PLATFORM = windows PLATFORM = windows
OS_VERSION := 5
USING_CYGWIN = true USING_CYGWIN = true
export USING_CYGWIN export USING_CYGWIN
WINDOWS_NT_VERSION_STRING=CYGWIN_NT
REQUIRED_CYGWIN_VER=4.0
endif endif
# Platform settings specific to Windows # Platform settings specific to Windows
ifeq ($(PLATFORM), windows) ifeq ($(PLATFORM), windows)
OS_NAME = nt
REQUIRED_OS_VERSION=5
# Windows builds default to the appropriate for the underlaying # Windows builds default to the appropriate for the underlaying
# architecture. # architecture.
# Temporary disk area # Temporary disk area
...@@ -314,7 +245,6 @@ ifeq ($(PLATFORM), windows) ...@@ -314,7 +245,6 @@ ifeq ($(PLATFORM), windows)
# If the user wants to perform a cross compile build then they must # If the user wants to perform a cross compile build then they must
# - set ARCH_DATA_MODEL=64 and either # - set ARCH_DATA_MODEL=64 and either
# + set ARCH to ia64 or amd64, or # + set ARCH to ia64 or amd64, or
REQUIRED_WINDOWS_VERSION=Server 2003 Enterprise x64 Edition
ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)), AMD64) ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)), AMD64)
ARCH=amd64 ARCH=amd64
else else
...@@ -324,8 +254,6 @@ ifeq ($(PLATFORM), windows) ...@@ -324,8 +254,6 @@ ifeq ($(PLATFORM), windows)
# Value of Java os.arch property # Value of Java os.arch property
ARCHPROP=$(LIBARCH) ARCHPROP=$(LIBARCH)
else else
REQUIRED_WINDOWS_VERSION=2000 or Unknown
#REQUIRED_WINDOWS_VERSION=XP Professional
# LIBARCH is used to preserve the jre/lib/i386 directory name for 32-bit intel # LIBARCH is used to preserve the jre/lib/i386 directory name for 32-bit intel
ARCH=i586 ARCH=i586
LIBARCH=i386 LIBARCH=i386
...@@ -364,14 +292,9 @@ ifeq ($(PLATFORM), windows) ...@@ -364,14 +292,9 @@ ifeq ($(PLATFORM), windows)
ARCH_VM_SUBDIR=jre/bin ARCH_VM_SUBDIR=jre/bin
# Suffix for file bundles used in previous release # Suffix for file bundles used in previous release
BUNDLE_FILE_SUFFIX=.tar BUNDLE_FILE_SUFFIX=.tar
# Minimum disk space needed as determined by running 'du -sk' on
# a fully built workspace.
REQUIRED_FREE_SPACE=500000
# ISHIELD_TEMP_MIN is the difference of an empty C:\TEMP vs. one after a # ISHIELD_TEMP_MIN is the difference of an empty C:\TEMP vs. one after a
# bundles build on windows. # bundles build on windows.
ISHIELD_TEMP_MIN=250000 ISHIELD_TEMP_MIN=250000
REQUIRED_DXSDK_VER = 0x0900
OS_VENDOR = Microsoft
# How much RAM does this machine have: # How much RAM does this machine have:
ifeq ($(JDK_HAS_MEM_INFO),) ifeq ($(JDK_HAS_MEM_INFO),)
ifeq ($(USING_CYGWIN),true) ifeq ($(USING_CYGWIN),true)
...@@ -410,10 +333,6 @@ ifeq ($(PLATFORM), windows) ...@@ -410,10 +333,6 @@ ifeq ($(PLATFORM), windows)
endif endif
endif endif
REQUIRED_ZIP_VER = 2.2
REQUIRED_UNZIP_VER = 5.12
REQUIRED_MAKE_VER = 3.78
# Unix type settings (same for all unix platforms) # Unix type settings (same for all unix platforms)
ifneq ($(PLATFORM), windows) ifneq ($(PLATFORM), windows)
# Temporary disk area # Temporary disk area
......
...@@ -167,8 +167,6 @@ ALL_SETTINGS+=$(call addRequiredSetting,ARCHPROP) ...@@ -167,8 +167,6 @@ ALL_SETTINGS+=$(call addRequiredSetting,ARCHPROP)
ifeq ($(PLATFORM),windows) ifeq ($(PLATFORM),windows)
ALL_SETTINGS+=$(call addRequiredSetting,PROCESSOR_ARCHITECTURE) ALL_SETTINGS+=$(call addRequiredSetting,PROCESSOR_ARCHITECTURE)
ALL_SETTINGS+=$(call addRequiredSetting,PROCESSOR_IDENTIFIER) ALL_SETTINGS+=$(call addRequiredSetting,PROCESSOR_IDENTIFIER)
ALL_SETTINGS+=$(call addRequiredSetting,WINDOWS_VERSION)
ALL_SETTINGS+=$(call addRequiredSetting,WINDOWS_NT_VERSION_STRING)
ifdef USING_CYGWIN ifdef USING_CYGWIN
ALL_SETTINGS+=$(call addRequiredSetting,USING_CYGWIN) ALL_SETTINGS+=$(call addRequiredSetting,USING_CYGWIN)
ALL_SETTINGS+=$(call addRequiredVersionSetting,CYGWIN_VER) ALL_SETTINGS+=$(call addRequiredVersionSetting,CYGWIN_VER)
...@@ -179,13 +177,11 @@ ifeq ($(PLATFORM),windows) ...@@ -179,13 +177,11 @@ ifeq ($(PLATFORM),windows)
endif endif
endif endif
ifeq ($(PLATFORM),linux) ifeq ($(PLATFORM),linux)
ALL_SETTINGS+=$(call addRequiredSetting,LINUX_VERSION)
ifneq ($(ARCH), ia64)
ALL_SETTINGS+=$(call addRequiredSetting,ALSA_VERSION) ALL_SETTINGS+=$(call addRequiredSetting,ALSA_VERSION)
endif
endif endif
ALL_SETTINGS+=$(call addRequiredVersionSetting,OS_VERSION) ALL_SETTINGS+=$(call addRequiredVersionSetting,OS_VERSION)
ALL_SETTINGS+=$(call addRequiredSetting,OS_NAME) ALL_SETTINGS+=$(call addOptionalSetting,OS_VARIANT_NAME)
ALL_SETTINGS+=$(call addOptionalSetting,OS_VARIANT_VERSION)
ALL_SETTINGS+=$(call addRequiredSetting,TEMP_FREE_SPACE) ALL_SETTINGS+=$(call addRequiredSetting,TEMP_FREE_SPACE)
ALL_SETTINGS+=$(call addRequiredSetting,FREE_SPACE) ALL_SETTINGS+=$(call addRequiredSetting,FREE_SPACE)
ALL_SETTINGS+=$(call addRequiredSetting,MB_OF_MEMORY) ALL_SETTINGS+=$(call addRequiredSetting,MB_OF_MEMORY)
......
...@@ -38,60 +38,106 @@ ...@@ -38,60 +38,106 @@
SANITY_FILES = $(ERROR_FILE) $(WARNING_FILE) $(MESSAGE_FILE) SANITY_FILES = $(ERROR_FILE) $(WARNING_FILE) $(MESSAGE_FILE)
# How to say "The Release Engineering people use this" # How to say "The Release Engineering people use this"
THE_OFFICIAL_USES=The official $(PLATFORM) builds use THE_OFFICIAL_USES=The official builds on $(PLATFORM) use
# How to say "You are using:" # How to say "You are using:"
YOU_ARE_USING=You appear to be using YOU_ARE_USING=You appear to be using
# Error message
define SanityError
$(ECHO) "ERROR: $1\n" >> $(ERROR_FILE)
endef
# Warning message
define SanityWarning
$(ECHO) "WARNING: $1\n" >> $(WARNING_FILE)
endef
# Official version error message: name version required_version
define OfficialErrorMessage
$(call SanityError,\
$(THE_OFFICIAL_USES) $1 $3. Your $1 $(if $2,undefined,$2) will not work.)
endef
# Official version warning message: name version required_version
define OfficialWarningMessage
$(call SanityWarning,\
$(THE_OFFICIAL_USES) $1 $3. $(YOU_ARE_USING) $1 $2.)
endef
# Settings and rules to validate the JDK build environment. # Settings and rules to validate the JDK build environment.
ifeq ($(PLATFORM), solaris) ifeq ($(PLATFORM), solaris)
FREE_SPACE := $(shell $(DF) -b $(OUTPUTDIR) | $(TAIL) -1 | $(NAWK) '{print $$2;}') FREE_SPACE := $(shell $(DF) -b $(OUTPUTDIR) | $(TAIL) -1 | $(NAWK) '{print $$2;}')
TEMP_FREE_SPACE := $(shell $(DF) -b $(TEMP_DISK) | $(TAIL) -1 | $(NAWK) '{print $$2;}') TEMP_FREE_SPACE := $(shell $(DF) -b $(TEMP_DISK) | $(TAIL) -1 | $(NAWK) '{print $$2;}')
# What kind of system we are using (Variations are Solaris and OpenSolaris)
OS_VERSION := $(shell uname -r)
OS_VARIANT_NAME := $(strip $(shell head -1 /etc/release | awk '{print $$1;}') )
OS_VARIANT_VERSION := $(OS_VERSION)
REQ_PATCH_LIST = $(JDK_TOPDIR)/make/PatchList.solaris REQ_PATCH_LIST = $(JDK_TOPDIR)/make/PatchList.solaris
ifeq ($(ARCH_FAMILY), sparc) ifeq ($(ARCH_FAMILY), sparc)
PATCH_POSITION = $$4 PATCH_POSITION = $$4
else else
PATCH_POSITION = $$6 PATCH_POSITION = $$6
endif endif
ifndef OPENJDK
_GCC_VER :=$(shell $(GCC) -dumpversion 2>&1 )
GCC_VER :=$(call GetVersion,"$(_GCC_VER)")
endif
endif endif
ifeq ($(PLATFORM), linux) ifeq ($(PLATFORM), linux)
FREE_SPACE := $(shell $(DF) --sync -kP $(OUTPUTDIR) | $(TAIL) -1 | $(NAWK) '{print $$4;}') FREE_SPACE := $(shell $(DF) --sync -kP $(OUTPUTDIR) | $(TAIL) -1 | $(NAWK) '{print $$4;}')
TEMP_FREE_SPACE := $(shell $(DF) --sync -kP $(TEMP_DISK) | $(TAIL) -1 | $(NAWK) '{print $$4;}') TEMP_FREE_SPACE := $(shell $(DF) --sync -kP $(TEMP_DISK) | $(TAIL) -1 | $(NAWK) '{print $$4;}')
ifeq ($(ARCH), amd64) # What kind of system we are using (Variation is the Linux vendor)
LINUX_VERSION := $(shell \ OS_VERSION := $(shell uname -r)
if [ -r "$(LINUX_VERSION_INFO)" ] ; then \ OS_VARIANT_NAME := $(shell \
$(CAT) $(LINUX_VERSION_INFO) | $(TAIL) -1 | $(NAWK) '{ print $$3; }';\ if [ -f /etc/fedora-release ] ; then \
echo "Fedora"; \
elif [ -f /etc/redhat-release ] ; then \
echo "RedHat"; \
elif [ -f /etc/SuSE-release ] ; then \
echo "SuSE"; \
else \ else \
$(ECHO) "Unknown linux"; \ echo "Unknown"; \
fi ) fi)
else OS_VARIANT_VERSION := $(shell \
LINUX_VERSION := $(shell \ if [ "$(OS_VARIANT_NAME)" = "Fedora" ] ; then \
if [ -r "$(LINUX_VERSION_INFO)" ] ; then \ $(CAT) /etc/fedora-release | $(HEAD) -1 | $(NAWK) '{ print $$3; }' ; \
$(NAWK) '{ print $$4" "$$5; }' $(LINUX_VERSION_INFO) ; \ fi)
else \ ALSA_INCLUDE=/usr/include/alsa/version.h
$(ECHO) "Unknown linux"; \ ALSA_LIBRARY=/usr/lib/libasound.so
fi ) _ALSA_VERSION := $(shell $(EGREP) SND_LIB_VERSION_STR $(ALSA_INCLUDE) | \
endif $(SED) -e 's@.*\"\(.*\)\".*@\1@' )
ifneq ($(ARCH), ia64) ALSA_VERSION := $(call GetVersion,$(_ALSA_VERSION))
# dummy program that outputs ALSA's version (created in target sane-alsa-versioncheck)
ALSA_VERSION_CHECK = $(TEMPDIR)/alsaversioncheck
ALSA_VERSION = `if [ -f "$(ALSA_VERSION_CHECK)" ] ; then $(ALSA_VERSION_CHECK) ; fi`
endif
endif endif
ifeq ($(PLATFORM), windows) ifeq ($(PLATFORM), windows)
FREE_SPACE := $(shell $(DF) -kP $(OUTPUTDIR) | $(TAIL) -1 | $(NAWK) '{print $$4;}') FREE_SPACE := $(shell $(DF) -kP $(OUTPUTDIR) | $(TAIL) -1 | $(NAWK) '{print $$4;}')
TEMP_FREE_SPACE := $(shell $(DF) -kP $(TEMP_DISK) | $(TAIL) -1 | $(NAWK) '{print $$4;}') TEMP_FREE_SPACE := $(shell $(DF) -kP $(TEMP_DISK) | $(TAIL) -1 | $(NAWK) '{print $$4;}')
# Localized systeminfo has localized labels, but not localized values. # Windows 2000 is 5.0, Windows XP is 5.1, Windows 2003 is 5.2
_WINDOWS_VERSION := \ # Assume 5.0 (Windows 2000) if systeminfo does not help
$(shell systeminfo 2> $(DEV_NULL) | grep 'Microsoft' | grep 'Windows' | \ WINDOWS_MAPPING-5.0 := Windows2000
cut -d':' -f2) WINDOWS_MAPPING-5.1 := WindowsXP
ifeq ($(_WINDOWS_VERSION),) WINDOWS_MAPPING-5.2 := Windows2003
_WINDOWS_VERSION := Windows 2000 or Unknown (no systeminfo utility) # What kind of system we are using (Variation is the common name)
_OS_VERSION := \
$(shell systeminfo 2> $(DEV_NULL) | \
egrep '^OS Version:' | \
awk '{print $$3;}' )
ifeq ($(_OS_VERSION),)
OS_VERSION = 5.0
else
OS_VERSION = $(_OS_VERSION)
endif
OS_VARIANT_NAME := $(WINDOWS_MAPPING-$(OS_VERSION))
OS_VARIANT_VERSION := $(OS_VERSION)
ifdef USING_CYGWIN
# CYGWIN version
_CYGWIN_VER := $(SYSTEM_UNAME)
CYGWIN_VER :=$(call GetVersion,$(_CYGWIN_VER))
endif endif
WINDOWS_VERSION := $(strip $(_WINDOWS_VERSION))
DXSDK_VER := $(shell $(EGREP) DIRECT3D_VERSION $(DXSDK_INCLUDE_PATH)/d3d9.h 2>&1 | \ DXSDK_VER := $(shell $(EGREP) DIRECT3D_VERSION $(DXSDK_INCLUDE_PATH)/d3d9.h 2>&1 | \
$(EGREP) "\#define" | $(NAWK) '{print $$3}') $(EGREP) "\#define" | $(NAWK) '{print $$3}')
endif endif
...@@ -106,7 +152,6 @@ ZIP_VER :=$(call GetVersion,"$(_ZIP_VER)") ...@@ -106,7 +152,6 @@ ZIP_VER :=$(call GetVersion,"$(_ZIP_VER)")
UNZIP_VER :=$(call GetVersion,"$(_UNZIP_VER)") UNZIP_VER :=$(call GetVersion,"$(_UNZIP_VER)")
BOOT_VER :=$(call GetVersion,"$(_BOOT_VER)") BOOT_VER :=$(call GetVersion,"$(_BOOT_VER)")
REQUIRED_ANT_VER := 1.6.3
_ANT_VER:=$(shell $(ANT) -version 2>&1 ) _ANT_VER:=$(shell $(ANT) -version 2>&1 )
ANT_VER:=$(call GetVersion,"$(_ANT_VER)") ANT_VER:=$(call GetVersion,"$(_ANT_VER)")
...@@ -167,7 +212,6 @@ include $(JDK_MAKE_SHARED_DIR)/Sanity-Settings.gmk ...@@ -167,7 +212,6 @@ include $(JDK_MAKE_SHARED_DIR)/Sanity-Settings.gmk
sane-compiler \ sane-compiler \
sane-link \ sane-link \
sane-cacerts \ sane-cacerts \
sane-alsa-versioncheck \
sane-alsa-headers \ sane-alsa-headers \
sane-ant_version \ sane-ant_version \
sane-zip_version \ sane-zip_version \
...@@ -239,35 +283,29 @@ sane-arch_data_model: ...@@ -239,35 +283,29 @@ sane-arch_data_model:
# generate a fatal sanity error, and a warning about the official # generate a fatal sanity error, and a warning about the official
# build platform just becomes clutter. # build platform just becomes clutter.
###################################################### ######################################################
OS_CHECK :=$(call CheckVersions,$(OS_VERSION),$(REQUIRED_OS_VERSION)) ifndef OPENJDK
OS_VERSION_CHECK := \
$(call CheckVersions,$(OS_VERSION),$(REQUIRED_OS_VERSION))
ifeq ($(OS_VARIANT_NAME),$(REQUIRED_OS_VARIANT_NAME))
OS_VARIANT_VERSION_CHECK := \
$(call CheckVersions,$(OS_VARIANT_VERSION),$(REQUIRED_OS_VARIANT_VERSION))
endif
endif
sane-os_version:: sane-arch_data_model sane-memory_check sane-locale sane-os_patch_level sane-os_version:: sane-arch_data_model sane-memory_check sane-locale sane-os_patch_level
ifndef OPENJDK ifndef OPENJDK
@if [ "$(OS_CHECK)" = "missing" ]; then \ ifneq ($(OS_VARIANT_NAME),$(REQUIRED_OS_VARIANT_NAME))
$(ECHO) "ERROR: The $(PLATFORM) OS version is undefined (Try: uname -r). \n" \ ifeq ($(OS_VERSION_CHECK),missing)
"" >> $(ERROR_FILE) ; \ @$(call OfficialErrorMessage,OS version,$(OS_VERSION),$(REQUIRED_OS_VERSION))
fi endif
@if [ "$(OS_CHECK)" != "same" ]; then \ ifneq ($(OS_VERSION_CHECK),same)
$(ECHO) "WARNING: $(THE_OFFICIAL_USES) OS version $(REQUIRED_OS_VERSION). \n" \ @$(call OfficialWarningMessage,OS version,$(OS_VERSION),$(REQUIRED_OS_VERSION))
" $(YOU_ARE_USING) OS version $(OS_VERSION). \n" \ endif
"" >> $(WARNING_FILE) ; \ @$(call OfficialWarningMessage,OS variant,$(OS_VARIANT_NAME),$(REQUIRED_OS_VARIANT_NAME))
fi else
ifeq ($(PLATFORM), windows) ifneq ($(OS_VARIANT_VERSION_CHECK),same)
@if [ "$(findstring $(REQUIRED_WINDOWS_VERSION),$(WINDOWS_VERSION))" = "" ]; then \ @$(call OfficialWarningMessage,$(OS_VARIANT_NAME) version,$(OS_VARIANT_VERSION),$(REQUIRED_OS_VARIANT_VERSION))
$(ECHO) "WARNING: $(YOU_ARE_USING) an unknown version of Windows. \n" \ endif
" The required version is $(REQUIRED_WINDOWS_VERSION). \n" \ endif
" $(YOU_ARE_USING) $(WINDOWS_VERSION) \n" \
"" >> $(WARNING_FILE) ; \
fi
endif # windows
ifeq ($(PLATFORM), linux)
@if [ `$(ECHO) "$(LINUX_VERSION)" | $(EGREP) -c '$(REQUIRED_LINUX_VER)'` -ne 1 ]; then \
$(ECHO) "WARNING: The build is being done on Linux $(LINUX_VERSION). \n" \
" $(THE_OFFICIAL_USES) Linux $(REQUIRED_LINUX_VER), \n" \
" specifically Linux $(REQUIRED_LINUX_FULLVER). \n" \
" The version found was '$(OS_VERSION)'. \n" \
"" >> $(WARNING_FILE) ; \
fi
endif # linux
endif # OPENJDK endif # OPENJDK
ifeq ($(PLATFORM), windows) ifeq ($(PLATFORM), windows)
...@@ -308,16 +346,12 @@ ifeq ($(PLATFORM), windows) ...@@ -308,16 +346,12 @@ ifeq ($(PLATFORM), windows)
CYGWIN_CHECK :=$(call CheckVersions,$(CYGWIN_VER),$(REQUIRED_CYGWIN_VER)) CYGWIN_CHECK :=$(call CheckVersions,$(CYGWIN_VER),$(REQUIRED_CYGWIN_VER))
sane-cygwin: sane-cygwin:
ifdef USING_CYGWIN ifdef USING_CYGWIN
@if [ "$(CYGWIN_CHECK)" = "missing" ]; then \ ifeq ($(CYGWIN_CHECK),missing)
$(ECHO) "ERROR: The CYGWIN version is undefined. \n" \ @$(call OfficialErrorMessage,CYGWIN version,$(CYGWIN_VER),$(REQUIRED_CYGWIN_VER))
" $(THE_OFFICIAL_USES) CYGWIN $(REQUIRED_CYGWIN_VER). \n" \ endif
"" >> $(ERROR_FILE) ; \ ifeq ($(CYGWIN_CHECK),older)
fi @$(call OfficialWarningMessage,CYGWIN version,$(CYGWIN_VER),$(REQUIRED_CYGWIN_VER))
@if [ "$(CYGWIN_CHECK)" = "older" ]; then \ endif
$(ECHO) "ERROR: The build cannot be done on CYGWIN $(CYGWIN_VER). \n" \
" Use CYGWIN $(REQUIRED_CYGWIN_VER) or higher. \n" \
"" >> $(ERROR_FILE) ; \
fi
endif endif
endif endif
...@@ -345,16 +379,12 @@ ifeq ($(PLATFORM), windows) ...@@ -345,16 +379,12 @@ ifeq ($(PLATFORM), windows)
MKS_CHECK :=$(call CheckVersions,$(MKS_VER),$(REQUIRED_MKS_VER)) MKS_CHECK :=$(call CheckVersions,$(MKS_VER),$(REQUIRED_MKS_VER))
sane-mks: sane-mks:
ifndef USING_CYGWIN ifndef USING_CYGWIN
@if [ "$(MKS_CHECK)" = "missing" ]; then \ ifeq ($(MKS_CHECK),missing)
$(ECHO) "ERROR: The MKS version is undefined. \n" \ @$(call OfficialErrorMessage,MKS version,$(MKS_VER),$(REQUIRED_MKS_VER))
" $(THE_OFFICIAL_USES) MKS $(REQUIRED_MKS_VER). \n" \ endif
"" >> $(ERROR_FILE) ; \ ifeq ($(MKS_CHECK),older)
fi @$(call OfficialErrorMessage,MKS version,$(MKS_VER),$(REQUIRED_MKS_VER))
@if [ "$(MKS_CHECK)" = "older" ]; then \ endif
$(ECHO) "ERROR: The build cannot be done on MKS $(MKS_VER). \n" \
" Use MKS $(REQUIRED_MKS_VER) or higher. \n" \
"" >> $(ERROR_FILE) ; \
fi
endif endif
endif endif
...@@ -1295,11 +1325,6 @@ endif ...@@ -1295,11 +1325,6 @@ endif
# Check the compiler version(s) # Check the compiler version(s)
###################################################### ######################################################
CC_CHECK :=$(call CheckVersions,$(CC_VER),$(REQUIRED_CC_VER)) CC_CHECK :=$(call CheckVersions,$(CC_VER),$(REQUIRED_CC_VER))
ifeq ($(PLATFORM), solaris)
ifeq ($(ARCH_DATA_MODEL), 32)
GCC_CHECK :=$(call CheckVersions,$(GCC_VER),$(REQUIRED_GCC_VER))
endif
endif
sane-compiler: sane-link sane-compiler: sane-link
@if [ "$(CC_CHECK)" = "missing" ]; then \ @if [ "$(CC_CHECK)" = "missing" ]; then \
$(ECHO) "ERROR: The Compiler version is undefined. \n" \ $(ECHO) "ERROR: The Compiler version is undefined. \n" \
...@@ -1314,16 +1339,6 @@ ifndef OPENJDK ...@@ -1314,16 +1339,6 @@ ifndef OPENJDK
" $(COMPILER_PATH) \n" \ " $(COMPILER_PATH) \n" \
"" >> $(WARNING_FILE) ; \ "" >> $(WARNING_FILE) ; \
fi fi
ifdef GCC_CHECK
@if [ "$(GCC_CHECK)" != "same" ]; then \
$(ECHO) "WARNING: The $(PLATFORM) GCC compiler must be version $(REQUIRED_GCC_VER) \n" \
" $(YOU_ARE_USING) compiler version: $(GCC_VER) \n" \
" The compiler was obtained from the following location: \n" \
" $(GCC_COMPILER_PATH) \n" \
" Please change your compiler. \n" \
"" >> $(WARNING_FILE) ; \
fi
endif
ifeq ($(PLATFORM), windows) ifeq ($(PLATFORM), windows)
ifeq ($(ARCH_DATA_MODEL), 64) ifeq ($(ARCH_DATA_MODEL), 64)
ifneq ($(COMPILER_VERSION), VS2005) ifneq ($(COMPILER_VERSION), VS2005)
...@@ -1337,39 +1352,24 @@ endif ...@@ -1337,39 +1352,24 @@ endif
###################################################### ######################################################
# Check that ALSA headers and libs are installed and # Check that ALSA headers and libs are installed and
# that the header has the right version. We only # that the header has the right version. We only
# need /usr/include/alsa/*.h and /usr/lib/libasound.so # need /usr/include/alsa/version.h and /usr/lib/libasound.so
###################################################### ######################################################
ifdef ALSA_VERSION_CHECK ifdef REQUIRED_ALSA_VERSION
$(ALSA_VERSION_CHECK): $(ALSA_VERSION_CHECK).c ALSA_CHECK := $(call CheckVersions,$(ALSA_VERSION),$(REQUIRED_ALSA_VERSION))
@$(prep-target)
@$(CC) -lasound -o $@ $<
$(ALSA_VERSION_CHECK).c:
@$(prep-target)
@$(ECHO) "#include <alsa/asoundlib.h>\n" \
"#include <stdio.h>\n" \
"int main(int argc, char** argv) {\n" \
" printf(\"%s\", SND_LIB_VERSION_STR);\n" \
" return 0;\n" \
"}\n" \
> $@
endif endif
sane-alsa-headers:
sane-alsa-versioncheck: $(ALSA_VERSION_CHECK) ifdef REQUIRED_ALSA_VERSION
sane-alsa-headers: sane-alsa-versioncheck if [ "$(ALSA_CHECK)" != "same" -a "$(ALSA_CHECK)" != "newer" ] ; then \
ifdef ALSA_VERSION_CHECK $(ECHO) "ERROR: The ALSA version must be $(REQUIRED_ALSA_VERSION) or higher. \n" \
@if [ -f "$(ALSA_VERSION_CHECK)" ]; then \ " You have the following ALSA version installed: $${alsa_version) \n" \
if [ `$(ALSA_VERSION_CHECK) | $(EGREP) -c '$(REQUIRED_ALSA_VERSION)'` -ne 1 ] ; then \
$(ECHO) "ERROR: The ALSA version must be 0.9.1 or higher. \n" \
" You have the following ALSA version installed: $(ALSA_VERSION) \n" \
" Please reinstall ALSA (drivers and lib). You can download \n" \ " Please reinstall ALSA (drivers and lib). You can download \n" \
" the source distribution from http://www.alsa-project.org \n" \ " the source distribution from http://www.alsa-project.org \n" \
" or go to http://www.freshrpms.net/docs/alsa/ for precompiled RPM packages. \n" \ " or go to http://www.freshrpms.net/docs/alsa/ for precompiled RPM packages. \n" \
"" >> $(ERROR_FILE) ; \ "" >> $(ERROR_FILE) ; \
fi \ fi \
else \ else \
$(ECHO) "ERROR: You seem to not have installed ALSA 0.9.1 or higher. \n" \ $(ECHO) "ERROR: You seem to not have installed ALSA $(REQUIRED_ALSA_VERSION) or higher. \n" \
" Please install ALSA (drivers and lib). You can download the \n" \ " Please install ALSA (drivers and lib). You can download the \n" \
" source distribution from http://www.alsa-project.org or go to \n" \ " source distribution from http://www.alsa-project.org or go to \n" \
" http://www.freshrpms.net/docs/alsa/ for precompiled RPM packages. \n" \ " http://www.freshrpms.net/docs/alsa/ for precompiled RPM packages. \n" \
...@@ -1384,7 +1384,7 @@ $(SANITY_FILES): ...@@ -1384,7 +1384,7 @@ $(SANITY_FILES):
###################################################### ######################################################
# dump out the variable settings... # dump out the variable settings...
###################################################### ######################################################
sane-settings:: sane-alsa-versioncheck sane-settings::
@$(ECHO) >> $(MESSAGE_FILE) @$(ECHO) >> $(MESSAGE_FILE)
@$(ECHO) $(ALL_SETTINGS) >> $(MESSAGE_FILE) @$(ECHO) $(ALL_SETTINGS) >> $(MESSAGE_FILE)
@$(ECHO) >> $(MESSAGE_FILE) @$(ECHO) >> $(MESSAGE_FILE)
...@@ -1453,8 +1453,8 @@ sane-gcc-compiler: ...@@ -1453,8 +1453,8 @@ sane-gcc-compiler:
ifeq ($(PLATFORM), solaris) ifeq ($(PLATFORM), solaris)
ifndef OPENJDK ifndef OPENJDK
@if [ -r $(GCC_COMPILER_PATH) ]; then \ @if [ -r $(GCC_COMPILER_PATH) ]; then \
if [ ! "$(GCC_VER)" = 2.95.2 ]; then \ if [ ! "$(GCC_VER)" = $(REQUIRED_GCC_VERSION) ]; then \
$(ECHO) "ERROR: The Solaris GCC compiler version must be 2.95.2. \n" \ $(ECHO) "ERROR: The Solaris GCC compiler version must be $(REQUIRED_GCC_VERSION). \n" \
" You are using the following compiler version: $(GCC_VER) \n" \ " You are using the following compiler version: $(GCC_VER) \n" \
" The compiler was obtained from the following location: \n" \ " The compiler was obtained from the following location: \n" \
" $(GCC_COMPILER_PATH) \n" \ " $(GCC_COMPILER_PATH) \n" \
......
# #
# Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. # Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -204,6 +204,9 @@ JDI_DOCTITLE = "Java$(TRADEMARK) Debug Interface" ...@@ -204,6 +204,9 @@ JDI_DOCTITLE = "Java$(TRADEMARK) Debug Interface"
JDI_HEADER = "Java Debug Interface" JDI_HEADER = "Java Debug Interface"
# JDI_PKGS is located in NON_CORE_PKGS.gmk # JDI_PKGS is located in NON_CORE_PKGS.gmk
# Variables used by security components
SECURITYAPI_JAVADOCBOTTOM = '<font size="-1"><a href="http://bugs.sun.com/services/bugreport/index.jsp">Report a bug or request a feature.</a><br>Copyright $(THIS_YEAR) Sun Microsystems, Inc. All Rights Reserved. Use is subject to license terms.</font>'
# #
# Variables used by JAAS target # Variables used by JAAS target
# #
...@@ -221,6 +224,7 @@ JAAS_JAVADOCFLAGS = $(COMMON_JAVADOCFLAGS) \ ...@@ -221,6 +224,7 @@ JAAS_JAVADOCFLAGS = $(COMMON_JAVADOCFLAGS) \
-windowtitle $(JAAS_WINDOWTITLE) \ -windowtitle $(JAAS_WINDOWTITLE) \
-doctitle $(JAAS_DOCTITLE) \ -doctitle $(JAAS_DOCTITLE) \
-header $(JAAS_JAVADOCHEADER) \ -header $(JAAS_JAVADOCHEADER) \
-bottom $(SECURITYAPI_JAVADOCBOTTOM) \
-linkoffline ../../../../../api $(DOCSDIR)/api/ \ -linkoffline ../../../../../api $(DOCSDIR)/api/ \
-overview $(TOPDIR)/src/share/classes/com/sun/security/auth/jaas-overview.html -overview $(TOPDIR)/src/share/classes/com/sun/security/auth/jaas-overview.html
JAAS_WINDOWTITLE = "Java Authentication and Authorization Service " JAAS_WINDOWTITLE = "Java Authentication and Authorization Service "
...@@ -243,6 +247,7 @@ JGSS_JAVADOCFLAGS = $(COMMON_JAVADOCFLAGS) \ ...@@ -243,6 +247,7 @@ JGSS_JAVADOCFLAGS = $(COMMON_JAVADOCFLAGS) \
-windowtitle $(JGSS_WINDOWTITLE) \ -windowtitle $(JGSS_WINDOWTITLE) \
-doctitle $(JGSS_DOCTITLE) \ -doctitle $(JGSS_DOCTITLE) \
-header $(JGSS_JAVADOCHEADER) \ -header $(JGSS_JAVADOCHEADER) \
-bottom $(SECURITYAPI_JAVADOCBOTTOM) \
-linkoffline ../../../../../api $(DOCSDIR)/api/ \ -linkoffline ../../../../../api $(DOCSDIR)/api/ \
-overview $(JGSS_SOURCEPATH)/com/sun/security/jgss/jgss-overview.html -overview $(JGSS_SOURCEPATH)/com/sun/security/jgss/jgss-overview.html
...@@ -266,6 +271,7 @@ SMARTCARDIO_JAVADOCFLAGS = $(COMMON_JAVADOCFLAGS) \ ...@@ -266,6 +271,7 @@ SMARTCARDIO_JAVADOCFLAGS = $(COMMON_JAVADOCFLAGS) \
-windowtitle $(SMARTCARDIO_WINDOWTITLE) \ -windowtitle $(SMARTCARDIO_WINDOWTITLE) \
-doctitle $(SMARTCARDIO_DOCTITLE) \ -doctitle $(SMARTCARDIO_DOCTITLE) \
-header $(SMARTCARDIO_JAVADOCHEADER) \ -header $(SMARTCARDIO_JAVADOCHEADER) \
-bottom $(SECURITYAPI_JAVADOCBOTTOM) \
-linkoffline ../../../../../api $(DOCSDIR)/api/ -linkoffline ../../../../../api $(DOCSDIR)/api/
SMARTCARDIO_WINDOWTITLE = "Java Smart Card I/O" SMARTCARDIO_WINDOWTITLE = "Java Smart Card I/O"
......
...@@ -449,7 +449,6 @@ JAVA_JAVA_java = \ ...@@ -449,7 +449,6 @@ JAVA_JAVA_java = \
sun/misc/Service.java \ sun/misc/Service.java \
sun/misc/JavaLangAccess.java \ sun/misc/JavaLangAccess.java \
sun/misc/JavaIOAccess.java \ sun/misc/JavaIOAccess.java \
sun/misc/JavaIODeleteOnExitAccess.java \
sun/misc/JavaIOFileDescriptorAccess.java \ sun/misc/JavaIOFileDescriptorAccess.java \
sun/misc/JavaNioAccess.java sun/misc/JavaNioAccess.java
......
...@@ -46,6 +46,8 @@ include $(BUILDDIR)/common/Mapfile-vers.gmk ...@@ -46,6 +46,8 @@ include $(BUILDDIR)/common/Mapfile-vers.gmk
# #
include FILES_c.gmk include FILES_c.gmk
# We don't need snmp here.
AUTO_JAVA_PRUNE = snmp
AUTO_FILES_JAVA_DIRS = java/lang/management com/sun/management sun/management AUTO_FILES_JAVA_DIRS = java/lang/management com/sun/management sun/management
include Exportedfiles.gmk include Exportedfiles.gmk
......
...@@ -35,6 +35,7 @@ include $(BUILDDIR)/common/Defs.gmk ...@@ -35,6 +35,7 @@ include $(BUILDDIR)/common/Defs.gmk
# #
# Files to compile # Files to compile
# #
AUTO_JAVA_PRUNE = snmp
AUTO_FILES_JAVA_DIRS = javax/management com/sun/jmx com/sun/management/jmx AUTO_FILES_JAVA_DIRS = javax/management com/sun/jmx com/sun/management/jmx
# #
......
...@@ -35,7 +35,16 @@ MGMT_LIB_SRC = $(SHARE_SRC)/lib/management ...@@ -35,7 +35,16 @@ MGMT_LIB_SRC = $(SHARE_SRC)/lib/management
all build:: properties aclfile jmxremotefiles all build:: properties aclfile jmxremotefiles
SUBDIRS = snmp jmxremote # When building the openjdk, build snmp only if importing binary plugs,
ifdef OPENJDK
ifeq ($(IMPORT_BINARY_PLUGS),true)
SUBDIRS = snmp
endif
else
SUBDIRS = snmp
endif
SUBDIRS += jmxremote
all build clean clobber:: all build clean clobber::
$(SUBDIRS-loop) $(SUBDIRS-loop)
......
...@@ -503,28 +503,29 @@ public final class Console implements Flushable ...@@ -503,28 +503,29 @@ public final class Console implements Flushable
// Set up JavaIOAccess in SharedSecrets // Set up JavaIOAccess in SharedSecrets
static { static {
sun.misc.SharedSecrets.setJavaIOAccess(new sun.misc.JavaIOAccess() {
public Console console() {
if (istty()) {
if (cons == null)
cons = new Console();
return cons;
}
return null;
}
// Add a shutdown hook to restore console's echo state should // Add a shutdown hook to restore console's echo state should
// it be necessary. // it be necessary.
public Runnable consoleRestoreHook() { sun.misc.SharedSecrets.getJavaLangAccess()
return new Runnable() { .registerShutdownHook(0 /* shutdown hook invocation order */,
new Runnable() {
public void run() { public void run() {
try { try {
if (echoOff) { if (echoOff) {
echo(true); echo(true);
} }
} catch (IOException x) {} } catch (IOException x) { }
} }
}; });
sun.misc.SharedSecrets.setJavaIOAccess(new sun.misc.JavaIOAccess() {
public Console console() {
if (istty()) {
if (cons == null)
cons = new Console();
return cons;
}
return null;
} }
public Charset charset() { public Charset charset() {
......
...@@ -34,17 +34,18 @@ import java.io.File; ...@@ -34,17 +34,18 @@ import java.io.File;
*/ */
class DeleteOnExitHook { class DeleteOnExitHook {
private static DeleteOnExitHook instance = null; static {
sun.misc.SharedSecrets.getJavaLangAccess()
.registerShutdownHook(2 /* Shutdown hook invocation order */,
new Runnable() {
public void run() {
runHooks();
}
});
}
private static LinkedHashSet<String> files = new LinkedHashSet<String>(); private static LinkedHashSet<String> files = new LinkedHashSet<String>();
static DeleteOnExitHook hook() {
if (instance == null)
instance = new DeleteOnExitHook();
return instance;
}
private DeleteOnExitHook() {} private DeleteOnExitHook() {}
static synchronized void add(String file) { static synchronized void add(String file) {
...@@ -54,7 +55,7 @@ class DeleteOnExitHook { ...@@ -54,7 +55,7 @@ class DeleteOnExitHook {
files.add(file); files.add(file);
} }
void run() { static void runHooks() {
LinkedHashSet<String> theFiles; LinkedHashSet<String> theFiles;
synchronized (DeleteOnExitHook.class) { synchronized (DeleteOnExitHook.class) {
......
...@@ -2147,18 +2147,6 @@ public class File ...@@ -2147,18 +2147,6 @@ public class File
/** use serialVersionUID from JDK 1.0.2 for interoperability */ /** use serialVersionUID from JDK 1.0.2 for interoperability */
private static final long serialVersionUID = 301077366599181567L; private static final long serialVersionUID = 301077366599181567L;
// Set up JavaIODeleteOnExitAccess in SharedSecrets
// Added here as DeleteOnExitHook is package-private and SharedSecrets cannot easily access it.
static {
sun.misc.SharedSecrets.setJavaIODeleteOnExitAccess(
new sun.misc.JavaIODeleteOnExitAccess() {
public void run() {
DeleteOnExitHook.hook().run();
}
}
);
}
// -- Integration with java.nio.file -- // -- Integration with java.nio.file --
private volatile transient Path filePath; private volatile transient Path filePath;
......
...@@ -34,19 +34,19 @@ import java.util.*; ...@@ -34,19 +34,19 @@ import java.util.*;
* @see java.lang.Runtime#removeShutdownHook * @see java.lang.Runtime#removeShutdownHook
*/ */
class ApplicationShutdownHooks implements Runnable { class ApplicationShutdownHooks {
private static ApplicationShutdownHooks instance = null; static {
Shutdown.add(1 /* shutdown hook invocation order */,
new Runnable() {
public void run() {
runHooks();
}
});
}
/* The set of registered hooks */ /* The set of registered hooks */
private static IdentityHashMap<Thread, Thread> hooks = new IdentityHashMap<Thread, Thread>(); private static IdentityHashMap<Thread, Thread> hooks = new IdentityHashMap<Thread, Thread>();
static synchronized ApplicationShutdownHooks hook() {
if (instance == null)
instance = new ApplicationShutdownHooks();
return instance;
}
private ApplicationShutdownHooks() {} private ApplicationShutdownHooks() {}
/* Add a new shutdown hook. Checks the shutdown state and the hook itself, /* Add a new shutdown hook. Checks the shutdown state and the hook itself,
...@@ -82,7 +82,7 @@ class ApplicationShutdownHooks implements Runnable { ...@@ -82,7 +82,7 @@ class ApplicationShutdownHooks implements Runnable {
* to run in. Hooks are run concurrently and this method waits for * to run in. Hooks are run concurrently and this method waits for
* them to finish. * them to finish.
*/ */
public void run() { static void runHooks() {
Collection<Thread> threads; Collection<Thread> threads;
synchronized(ApplicationShutdownHooks.class) { synchronized(ApplicationShutdownHooks.class) {
threads = hooks.keySet(); threads = hooks.keySet();
......
...@@ -25,8 +25,6 @@ ...@@ -25,8 +25,6 @@
package java.lang; package java.lang;
import java.util.ArrayList;
/** /**
* Package-private utility class containing data structures and logic * Package-private utility class containing data structures and logic
...@@ -47,8 +45,13 @@ class Shutdown { ...@@ -47,8 +45,13 @@ class Shutdown {
/* Should we run all finalizers upon exit? */ /* Should we run all finalizers upon exit? */
private static boolean runFinalizersOnExit = false; private static boolean runFinalizersOnExit = false;
/* The set of registered, wrapped hooks, or null if there aren't any */ // The system shutdown hooks are registered with a predefined slot.
private static ArrayList<Runnable> hooks = new ArrayList<Runnable>(); // The list of shutdown hooks is as follows:
// (0) Console restore hook
// (1) Application hooks
// (2) DeleteOnExit hook
private static final int MAX_SYSTEM_HOOKS = 10;
private static final Runnable[] hooks = new Runnable[MAX_SYSTEM_HOOKS];
/* The preceding static fields are protected by this lock */ /* The preceding static fields are protected by this lock */
private static class Lock { }; private static class Lock { };
...@@ -68,32 +71,17 @@ class Shutdown { ...@@ -68,32 +71,17 @@ class Shutdown {
/* Add a new shutdown hook. Checks the shutdown state and the hook itself, /* Add a new shutdown hook. Checks the shutdown state and the hook itself,
* but does not do any security checks. * but does not do any security checks.
*/ */
static void add(Runnable hook) { static void add(int slot, Runnable hook) {
synchronized (lock) { synchronized (lock) {
if (state > RUNNING) if (state > RUNNING)
throw new IllegalStateException("Shutdown in progress"); throw new IllegalStateException("Shutdown in progress");
hooks.add(hook); if (hooks[slot] != null)
} throw new InternalError("Shutdown hook at slot " + slot + " already registered");
}
/* Remove a previously-registered hook. Like the add method, this method hooks[slot] = hook;
* does not do any security checks.
*/
static boolean remove(Runnable hook) {
synchronized (lock) {
if (state > RUNNING)
throw new IllegalStateException("Shutdown in progress");
if (hook == null) throw new NullPointerException();
if (hooks == null) {
return false;
} else {
return hooks.remove(hook);
} }
} }
}
/* Run all registered shutdown hooks /* Run all registered shutdown hooks
*/ */
...@@ -103,7 +91,7 @@ class Shutdown { ...@@ -103,7 +91,7 @@ class Shutdown {
*/ */
for (Runnable hook : hooks) { for (Runnable hook : hooks) {
try { try {
hook.run(); if (hook != null) hook.run();
} catch(Throwable t) { } catch(Throwable t) {
if (t instanceof ThreadDeath) { if (t instanceof ThreadDeath) {
ThreadDeath td = (ThreadDeath)t; ThreadDeath td = (ThreadDeath)t;
......
...@@ -34,7 +34,6 @@ import java.security.AllPermission; ...@@ -34,7 +34,6 @@ import java.security.AllPermission;
import java.nio.channels.Channel; import java.nio.channels.Channel;
import java.nio.channels.spi.SelectorProvider; import java.nio.channels.spi.SelectorProvider;
import sun.nio.ch.Interruptible; import sun.nio.ch.Interruptible;
import sun.net.InetAddressCachePolicy;
import sun.reflect.Reflection; import sun.reflect.Reflection;
import sun.security.util.SecurityConstants; import sun.security.util.SecurityConstants;
import sun.reflect.annotation.AnnotationType; import sun.reflect.annotation.AnnotationType;
...@@ -310,7 +309,6 @@ public final class System { ...@@ -310,7 +309,6 @@ public final class System {
} }
security = s; security = s;
InetAddressCachePolicy.setIfNotSet(InetAddressCachePolicy.FOREVER);
} }
/** /**
...@@ -1121,14 +1119,6 @@ public final class System { ...@@ -1121,14 +1119,6 @@ public final class System {
// Setup Java signal handlers for HUP, TERM, and INT (where available). // Setup Java signal handlers for HUP, TERM, and INT (where available).
Terminator.setup(); Terminator.setup();
// The order in with the hooks are added here is important as it
// determines the order in which they are run.
// (1)Console restore hook needs to be called first.
// (2)Application hooks must be run before calling deleteOnExitHook.
Shutdown.add(sun.misc.SharedSecrets.getJavaIOAccess().consoleRestoreHook());
Shutdown.add(ApplicationShutdownHooks.hook());
Shutdown.add(sun.misc.SharedSecrets.getJavaIODeleteOnExitAccess());
// Initialize any miscellenous operating system settings that need to be // Initialize any miscellenous operating system settings that need to be
// set for the class libraries. Currently this is no-op everywhere except // set for the class libraries. Currently this is no-op everywhere except
// for Windows where the process-wide error mode is set before the java.io // for Windows where the process-wide error mode is set before the java.io
...@@ -1174,6 +1164,9 @@ public final class System { ...@@ -1174,6 +1164,9 @@ public final class System {
public void blockedOn(Thread t, Interruptible b) { public void blockedOn(Thread t, Interruptible b) {
t.blockedOn(b); t.blockedOn(b);
} }
public void registerShutdownHook(int slot, Runnable r) {
Shutdown.add(slot, r);
}
}); });
} }
......
/* /*
* Copyright 1994-2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1994-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as * under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this * published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classname" exception as provided * particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code. * by Sun in the LICENSE file that accompanied this code.
* *
* This code is distributed in the hope that it will be useful, but WITHOUT * This code is distributed in the hope that it will be useful, but WITHOUT
......
/* /*
* Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* Copyright 1999-2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1999-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
...@@ -31,9 +31,9 @@ import java.io.FileInputStream; ...@@ -31,9 +31,9 @@ import java.io.FileInputStream;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.Properties; import java.util.Properties;
import java.util.Enumeration;
import java.util.ResourceBundle; import java.util.ResourceBundle;
import java.util.MissingResourceException; import java.util.MissingResourceException;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
...@@ -41,7 +41,6 @@ import java.lang.reflect.Method; ...@@ -41,7 +41,6 @@ import java.lang.reflect.Method;
import javax.management.remote.JMXConnectorServer; import javax.management.remote.JMXConnectorServer;
import sun.management.snmp.AdaptorBootstrap;
import sun.management.jmxremote.ConnectorBootstrap; import sun.management.jmxremote.ConnectorBootstrap;
import static sun.management.AgentConfigurationError.*; import static sun.management.AgentConfigurationError.*;
import sun.misc.VMSupport; import sun.misc.VMSupport;
...@@ -69,6 +68,9 @@ public class Agent { ...@@ -69,6 +68,9 @@ public class Agent {
private static final String LOCAL_CONNECTOR_ADDRESS_PROP = private static final String LOCAL_CONNECTOR_ADDRESS_PROP =
"com.sun.management.jmxremote.localConnectorAddress"; "com.sun.management.jmxremote.localConnectorAddress";
private static final String SNMP_ADAPTOR_BOOTSTRAP_CLASS_NAME =
"sun.management.snmp.AdaptorBootstrap";
// invoked by -javaagent or -Dcom.sun.management.agent.class // invoked by -javaagent or -Dcom.sun.management.agent.class
public static void premain(String args) throws Exception { public static void premain(String args) throws Exception {
agentmain(args); agentmain(args);
...@@ -128,7 +130,7 @@ public class Agent { ...@@ -128,7 +130,7 @@ public class Agent {
try { try {
if (snmpPort != null) { if (snmpPort != null) {
AdaptorBootstrap.initialize(snmpPort, props); loadSnmpAgent(snmpPort, props);
} }
/* /*
...@@ -204,6 +206,36 @@ public class Agent { ...@@ -204,6 +206,36 @@ public class Agent {
return mgmtProps; return mgmtProps;
} }
private static void loadSnmpAgent(String snmpPort, Properties props) {
try {
// invoke the following through reflection:
// AdaptorBootstrap.initialize(snmpPort, props);
final Class<?> adaptorClass =
Class.forName(SNMP_ADAPTOR_BOOTSTRAP_CLASS_NAME,true,null);
final Method initializeMethod =
adaptorClass.getMethod("initialize",
String.class, Properties.class);
initializeMethod.invoke(null,snmpPort,props);
} catch (ClassNotFoundException x) {
// The SNMP packages are not present: throws an exception.
throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,x);
} catch (NoSuchMethodException x) {
// should not happen...
throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,x);
} catch (InvocationTargetException x) {
final Throwable cause = x.getCause();
if (cause instanceof RuntimeException)
throw (RuntimeException) cause;
else if (cause instanceof Error)
throw (Error) cause;
// should not happen...
throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,cause);
} catch (IllegalAccessException x) {
// should not happen...
throw new UnsupportedOperationException("Unsupported management property: " + SNMP_PORT,x);
}
}
// read config file and initialize the properties // read config file and initialize the properties
private static void readConfiguration(String fname, Properties p) { private static void readConfiguration(String fname, Properties p) {
if (fname == null) { if (fname == null) {
......
...@@ -29,6 +29,5 @@ import java.nio.charset.Charset; ...@@ -29,6 +29,5 @@ import java.nio.charset.Charset;
public interface JavaIOAccess { public interface JavaIOAccess {
public Console console(); public Console console();
public Runnable consoleRestoreHook();
public Charset charset(); public Charset charset();
} }
/*
* Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.misc;
public interface JavaIODeleteOnExitAccess extends Runnable {
public void run();
}
...@@ -54,4 +54,7 @@ public interface JavaLangAccess { ...@@ -54,4 +54,7 @@ public interface JavaLangAccess {
/** Set thread's blocker field. */ /** Set thread's blocker field. */
void blockedOn(Thread t, Interruptible b); void blockedOn(Thread t, Interruptible b);
/** register shutdown hook */
void registerShutdownHook(int slot, Runnable r);
} }
...@@ -44,7 +44,6 @@ public class SharedSecrets { ...@@ -44,7 +44,6 @@ public class SharedSecrets {
private static JavaUtilJarAccess javaUtilJarAccess; private static JavaUtilJarAccess javaUtilJarAccess;
private static JavaLangAccess javaLangAccess; private static JavaLangAccess javaLangAccess;
private static JavaIOAccess javaIOAccess; private static JavaIOAccess javaIOAccess;
private static JavaIODeleteOnExitAccess javaIODeleteOnExitAccess;
private static JavaNetAccess javaNetAccess; private static JavaNetAccess javaNetAccess;
private static JavaNioAccess javaNioAccess; private static JavaNioAccess javaNioAccess;
private static JavaIOFileDescriptorAccess javaIOFileDescriptorAccess; private static JavaIOFileDescriptorAccess javaIOFileDescriptorAccess;
...@@ -103,17 +102,6 @@ public class SharedSecrets { ...@@ -103,17 +102,6 @@ public class SharedSecrets {
return javaIOAccess; return javaIOAccess;
} }
public static void setJavaIODeleteOnExitAccess(JavaIODeleteOnExitAccess jida) {
javaIODeleteOnExitAccess = jida;
}
public static JavaIODeleteOnExitAccess getJavaIODeleteOnExitAccess() {
if (javaIODeleteOnExitAccess == null) {
unsafe.ensureClassInitialized(File.class);
}
return javaIODeleteOnExitAccess;
}
public static void setJavaIOFileDescriptorAccess(JavaIOFileDescriptorAccess jiofda) { public static void setJavaIOFileDescriptorAccess(JavaIOFileDescriptorAccess jiofda) {
javaIOFileDescriptorAccess = jiofda; javaIOFileDescriptorAccess = jiofda;
} }
......
/* /*
* Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -66,11 +66,11 @@ public class NegTokenInit extends SpNegoToken { ...@@ -66,11 +66,11 @@ public class NegTokenInit extends SpNegoToken {
private byte[] mechTypes = null; private byte[] mechTypes = null;
private Oid[] mechTypeList = null; private Oid[] mechTypeList = null;
private byte[] reqFlags = null; private BitArray reqFlags = null;
private byte[] mechToken = null; private byte[] mechToken = null;
private byte[] mechListMIC = null; private byte[] mechListMIC = null;
NegTokenInit(byte[] mechTypes, byte[] flags, NegTokenInit(byte[] mechTypes, BitArray flags,
byte[] token, byte[] mechListMIC) byte[] token, byte[] mechListMIC)
{ {
super(NEG_TOKEN_INIT_ID); super(NEG_TOKEN_INIT_ID);
...@@ -101,7 +101,7 @@ public class NegTokenInit extends SpNegoToken { ...@@ -101,7 +101,7 @@ public class NegTokenInit extends SpNegoToken {
// write context flags with CONTEXT 01 // write context flags with CONTEXT 01
if (reqFlags != null) { if (reqFlags != null) {
DerOutputStream flags = new DerOutputStream(); DerOutputStream flags = new DerOutputStream();
flags.putBitString(reqFlags); flags.putUnalignedBitString(reqFlags);
initToken.write(DerValue.createTag(DerValue.TAG_CONTEXT, initToken.write(DerValue.createTag(DerValue.TAG_CONTEXT,
true, (byte) 0x01), flags); true, (byte) 0x01), flags);
} }
...@@ -237,7 +237,7 @@ public class NegTokenInit extends SpNegoToken { ...@@ -237,7 +237,7 @@ public class NegTokenInit extends SpNegoToken {
return mechTypeList; return mechTypeList;
} }
byte[] getReqFlags() { BitArray getReqFlags() {
return reqFlags; return reqFlags;
} }
......
/* /*
* Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -53,13 +53,6 @@ public class SpNegoContext implements GSSContextSpi { ...@@ -53,13 +53,6 @@ public class SpNegoContext implements GSSContextSpi {
private int state = STATE_NEW; private int state = STATE_NEW;
private static final int CHECKSUM_DELEG_FLAG = 1;
private static final int CHECKSUM_MUTUAL_FLAG = 2;
private static final int CHECKSUM_REPLAY_FLAG = 4;
private static final int CHECKSUM_SEQUENCE_FLAG = 8;
private static final int CHECKSUM_CONF_FLAG = 16;
private static final int CHECKSUM_INTEG_FLAG = 32;
/* /*
* Optional features that the application can set and their default * Optional features that the application can set and their default
* values. * values.
...@@ -697,25 +690,17 @@ public class SpNegoContext implements GSSContextSpi { ...@@ -697,25 +690,17 @@ public class SpNegoContext implements GSSContextSpi {
/** /**
* get the context flags * get the context flags
*/ */
private byte[] getContextFlags() { private BitArray getContextFlags() {
int flags = 0; BitArray out = new BitArray(7);
if (getCredDelegState()) if (getCredDelegState()) out.set(0, true);
flags |= CHECKSUM_DELEG_FLAG; if (getMutualAuthState()) out.set(1, true);
if (getMutualAuthState()) if (getReplayDetState()) out.set(2, true);
flags |= CHECKSUM_MUTUAL_FLAG; if (getSequenceDetState()) out.set(3, true);
if (getReplayDetState()) if (getConfState()) out.set(5, true);
flags |= CHECKSUM_REPLAY_FLAG; if (getIntegState()) out.set(6, true);
if (getSequenceDetState())
flags |= CHECKSUM_SEQUENCE_FLAG; return out;
if (getIntegState())
flags |= CHECKSUM_INTEG_FLAG;
if (getConfState())
flags |= CHECKSUM_CONF_FLAG;
byte[] temp = new byte[1];
temp[0] = (byte)(flags & 0xff);
return temp;
} }
private void setContextFlags() { private void setContextFlags() {
......
/* /*
* Portions Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved. * Portions Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
package sun.security.pkcs11; package sun.security.pkcs11;
import java.io.*; import java.io.*;
import java.lang.ref.*;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.*; import java.util.*;
...@@ -67,9 +68,6 @@ abstract class P11Key implements Key { ...@@ -67,9 +68,6 @@ abstract class P11Key implements Key {
// type of key, one of (PUBLIC, PRIVATE, SECRET) // type of key, one of (PUBLIC, PRIVATE, SECRET)
final String type; final String type;
// session in which the key was created, relevant for session objects
final Session session;
// token instance // token instance
final Token token; final Token token;
...@@ -85,10 +83,12 @@ abstract class P11Key implements Key { ...@@ -85,10 +83,12 @@ abstract class P11Key implements Key {
// flags indicating whether the key is a token object, sensitive, extractable // flags indicating whether the key is a token object, sensitive, extractable
final boolean tokenObject, sensitive, extractable; final boolean tokenObject, sensitive, extractable;
// weak reference notification clean up for session keys
private final SessionKeyRef sessionKeyRef;
P11Key(String type, Session session, long keyID, String algorithm, P11Key(String type, Session session, long keyID, String algorithm,
int keyLength, CK_ATTRIBUTE[] attributes) { int keyLength, CK_ATTRIBUTE[] attributes) {
this.type = type; this.type = type;
this.session = session;
this.token = session.token; this.token = session.token;
this.keyID = keyID; this.keyID = keyID;
this.algorithm = algorithm; this.algorithm = algorithm;
...@@ -111,7 +111,9 @@ abstract class P11Key implements Key { ...@@ -111,7 +111,9 @@ abstract class P11Key implements Key {
this.sensitive = sensitive; this.sensitive = sensitive;
this.extractable = extractable; this.extractable = extractable;
if (tokenObject == false) { if (tokenObject == false) {
session.addObject(); sessionKeyRef = new SessionKeyRef(this, keyID, session);
} else {
sessionKeyRef = null;
} }
} }
...@@ -236,24 +238,6 @@ abstract class P11Key implements Key { ...@@ -236,24 +238,6 @@ abstract class P11Key implements Key {
} }
} }
protected void finalize() throws Throwable {
if (tokenObject || (token.isValid() == false)) {
super.finalize();
return;
}
Session newSession = null;
try {
newSession = token.getOpSession();
token.p11.C_DestroyObject(newSession.id(), keyID);
} catch (PKCS11Exception e) {
// ignore
} finally {
token.releaseSession(newSession);
session.removeObject();
super.finalize();
}
}
private final static CK_ATTRIBUTE[] A0 = new CK_ATTRIBUTE[0]; private final static CK_ATTRIBUTE[] A0 = new CK_ATTRIBUTE[0];
private static CK_ATTRIBUTE[] getAttributes(Session session, long keyID, private static CK_ATTRIBUTE[] getAttributes(Session session, long keyID,
...@@ -1055,5 +1039,65 @@ abstract class P11Key implements Key { ...@@ -1055,5 +1039,65 @@ abstract class P11Key implements Key {
+ "\n parameters: " + params; + "\n parameters: " + params;
} }
} }
}
final class SessionKeyRef extends WeakReference<P11Key>
implements Comparable<SessionKeyRef> {
private static ReferenceQueue<P11Key> refQueue =
new ReferenceQueue<P11Key>();
private static Set<SessionKeyRef> refList =
Collections.synchronizedSortedSet(new TreeSet<SessionKeyRef>());
static ReferenceQueue<P11Key> referenceQueue() {
return refQueue;
}
static final private int MAX_ITERATIONS = 2;
private static void drainRefQueueBounded() {
int iterations = 0;
while (iterations < MAX_ITERATIONS) {
SessionKeyRef next = (SessionKeyRef) refQueue.poll();
if (next != null) next.dispose();
++iterations;
}
}
// handle to the native key
private long keyID;
private Session session;
SessionKeyRef(P11Key key , long keyID, Session session) {
super(key, refQueue);
this.keyID = keyID;
this.session = session;
this.session.addObject();
refList.add(this);
// TBD: run at some interval and not every time?
drainRefQueueBounded();
}
void dispose() {
refList.remove(this);
if (session.token.isValid()) {
Session newSession = null;
try {
newSession = session.token.getOpSession();
session.token.p11.C_DestroyObject(newSession.id(), keyID);
} catch (PKCS11Exception e) {
// ignore
} finally {
session.token.releaseSession(newSession);
session.removeObject();
}
}
}
public int compareTo(SessionKeyRef other) {
if (this.keyID == other.keyID) {
return 0;
} else {
return (this.keyID < other.keyID) ? -1 : 1;
}
}
} }
/* /*
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -191,7 +191,9 @@ final class P11RSACipher extends CipherSpi { ...@@ -191,7 +191,9 @@ final class P11RSACipher extends CipherSpi {
throw new InvalidKeyException throw new InvalidKeyException
("Unwrap has to be used with private keys"); ("Unwrap has to be used with private keys");
} }
encrypt = false; // No further setup needed for C_Unwrap(). We'll initialize later
// if we can't use C_Unwrap().
return;
} else { } else {
throw new InvalidKeyException("Unsupported mode: " + opmode); throw new InvalidKeyException("Unsupported mode: " + opmode);
} }
...@@ -452,7 +454,7 @@ final class P11RSACipher extends CipherSpi { ...@@ -452,7 +454,7 @@ final class P11RSACipher extends CipherSpi {
long keyID = token.p11.C_UnwrapKey(s.id(), long keyID = token.p11.C_UnwrapKey(s.id(),
new CK_MECHANISM(mechanism), p11Key.keyID, wrappedKey, new CK_MECHANISM(mechanism), p11Key.keyID, wrappedKey,
attributes); attributes);
return P11Key.secretKey(session, keyID, algorithm, 48 << 3, return P11Key.secretKey(s, keyID, algorithm, 48 << 3,
attributes); attributes);
} catch (PKCS11Exception e) { } catch (PKCS11Exception e) {
throw new InvalidKeyException("unwrap() failed", e); throw new InvalidKeyException("unwrap() failed", e);
...@@ -461,6 +463,7 @@ final class P11RSACipher extends CipherSpi { ...@@ -461,6 +463,7 @@ final class P11RSACipher extends CipherSpi {
} }
} }
// XXX implement unwrap using C_Unwrap() for all keys // XXX implement unwrap using C_Unwrap() for all keys
implInit(Cipher.DECRYPT_MODE, p11Key);
if (wrappedKey.length > maxInputSize) { if (wrappedKey.length > maxInputSize) {
throw new InvalidKeyException("Key is too long for unwrapping"); throw new InvalidKeyException("Key is too long for unwrapping");
} }
......
...@@ -151,7 +151,7 @@ final class P11SecretKeyFactory extends SecretKeyFactorySpi { ...@@ -151,7 +151,7 @@ final class P11SecretKeyFactory extends SecretKeyFactorySpi {
session = token.getObjSession(); session = token.getObjSession();
long newKeyID = token.p11.C_CopyObject(session.id(), long newKeyID = token.p11.C_CopyObject(session.id(),
p11Key.keyID, extraAttrs); p11Key.keyID, extraAttrs);
p11Key = (P11Key) (P11Key.secretKey(p11Key.session, p11Key = (P11Key) (P11Key.secretKey(session,
newKeyID, p11Key.algorithm, p11Key.keyLength, newKeyID, p11Key.algorithm, p11Key.keyLength,
extraAttrs)); extraAttrs));
} catch (PKCS11Exception p11e) { } catch (PKCS11Exception p11e) {
......
/* /*
* Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -28,8 +28,6 @@ package sun.security.provider.certpath; ...@@ -28,8 +28,6 @@ package sun.security.provider.certpath;
import java.io.*; import java.io.*;
import java.math.BigInteger; import java.math.BigInteger;
import java.security.*; import java.security.*;
import java.security.cert.Certificate;
import java.security.cert.CertificateFactory;
import java.security.cert.CertPathValidatorException; import java.security.cert.CertPathValidatorException;
import java.security.cert.CRLReason; import java.security.cert.CRLReason;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
...@@ -335,7 +333,7 @@ class OCSPResponse { ...@@ -335,7 +333,7 @@ class OCSPResponse {
// Check whether the cert returned by the responder is trusted // Check whether the cert returned by the responder is trusted
if (x509Certs != null && x509Certs[0] != null) { if (x509Certs != null && x509Certs[0] != null) {
X509Certificate cert = x509Certs[0]; X509CertImpl cert = x509Certs[0];
// First check if the cert matches the responder cert which // First check if the cert matches the responder cert which
// was set locally. // was set locally.
...@@ -344,8 +342,8 @@ class OCSPResponse { ...@@ -344,8 +342,8 @@ class OCSPResponse {
// Next check if the cert was issued by the responder cert // Next check if the cert was issued by the responder cert
// which was set locally. // which was set locally.
} else if (cert.getIssuerDN().equals( } else if (cert.getIssuerX500Principal().equals(
responderCert.getSubjectDN())) { responderCert.getSubjectX500Principal())) {
// Check for the OCSPSigning key purpose // Check for the OCSPSigning key purpose
List<String> keyPurposes = cert.getExtendedKeyUsage(); List<String> keyPurposes = cert.getExtendedKeyUsage();
...@@ -360,6 +358,43 @@ class OCSPResponse { ...@@ -360,6 +358,43 @@ class OCSPResponse {
"OCSP responses"); "OCSP responses");
} }
// check the validity
try {
Date dateCheckedAgainst = params.getDate();
if (dateCheckedAgainst == null) {
cert.checkValidity();
} else {
cert.checkValidity(dateCheckedAgainst);
}
} catch (GeneralSecurityException e) {
if (DEBUG != null) {
DEBUG.println("Responder's certificate is not " +
"within the validity period.");
}
throw new CertPathValidatorException(
"Responder's certificate not within the " +
"validity period");
}
// check for revocation
//
// A CA may specify that an OCSP client can trust a
// responder for the lifetime of the responder's
// certificate. The CA does so by including the
// extension id-pkix-ocsp-nocheck.
//
Extension noCheck =
cert.getExtension(PKIXExtensions.OCSPNoCheck_Id);
if (noCheck != null) {
if (DEBUG != null) {
DEBUG.println("Responder's certificate includes " +
"the extension id-pkix-ocsp-nocheck.");
}
} else {
// we should do the revocating checking of the
// authorized responder in a future update.
}
// verify the signature // verify the signature
try { try {
cert.verify(responderCert.getPublicKey()); cert.verify(responderCert.getPublicKey());
...@@ -369,6 +404,14 @@ class OCSPResponse { ...@@ -369,6 +404,14 @@ class OCSPResponse {
} catch (GeneralSecurityException e) { } catch (GeneralSecurityException e) {
responderCert = null; responderCert = null;
} }
} else {
if (DEBUG != null) {
DEBUG.println("Responder's certificate is not " +
"authorized to sign OCSP responses.");
}
throw new CertPathValidatorException(
"Responder's certificate not authorized to sign " +
"OCSP responses");
} }
} }
......
/* /*
* Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -143,12 +143,16 @@ class PKIXMasterCertPathValidator { ...@@ -143,12 +143,16 @@ class PKIXMasterCertPathValidator {
} }
} catch (CertPathValidatorException cpve) { } catch (CertPathValidatorException cpve) {
// Throw the saved OCSP exception // Throw the saved OCSP exception unless the CRL
// (when the CRL check has also failed) // checker has determined that the cert is revoked
if (ocspCause != null && if (ocspCause != null &&
currChecker instanceof CrlRevocationChecker) { currChecker instanceof CrlRevocationChecker) {
if (cpve.getReason() == BasicReason.REVOKED) {
throw cpve;
} else {
throw ocspCause; throw ocspCause;
} }
}
/* /*
* Handle failover from OCSP to CRLs * Handle failover from OCSP to CRLs
*/ */
......
...@@ -875,6 +875,18 @@ public final class KeyTool { ...@@ -875,6 +875,18 @@ public final class KeyTool {
if (filename != null) { if (filename != null) {
inStream = new FileInputStream(filename); inStream = new FileInputStream(filename);
} }
// Read the full stream before feeding to X509Factory,
// otherwise, keytool -gencert | keytool -importcert
// might not work properly, since -gencert is slow
// and there's no data in the pipe at the beginning.
ByteArrayOutputStream bout = new ByteArrayOutputStream();
byte[] b = new byte[4096];
while (true) {
int len = inStream.read(b);
if (len < 0) break;
bout.write(b, 0, len);
}
inStream = new ByteArrayInputStream(bout.toByteArray());
try { try {
String importAlias = (alias!=null)?alias:keyAlias; String importAlias = (alias!=null)?alias:keyAlias;
if (keyStore.entryInstanceOf(importAlias, KeyStore.PrivateKeyEntry.class)) { if (keyStore.entryInstanceOf(importAlias, KeyStore.PrivateKeyEntry.class)) {
...@@ -1910,7 +1922,9 @@ public final class KeyTool { ...@@ -1910,7 +1922,9 @@ public final class KeyTool {
ObjectIdentifier oid = attr.getAttributeId(); ObjectIdentifier oid = attr.getAttributeId();
if (oid.equals(PKCS9Attribute.EXTENSION_REQUEST_OID)) { if (oid.equals(PKCS9Attribute.EXTENSION_REQUEST_OID)) {
CertificateExtensions exts = (CertificateExtensions)attr.getAttributeValue(); CertificateExtensions exts = (CertificateExtensions)attr.getAttributeValue();
if (exts != null) {
printExtensions(rb.getString("Extension Request:"), exts, out); printExtensions(rb.getString("Extension Request:"), exts, out);
}
} else { } else {
out.println(attr.getAttributeId()); out.println(attr.getAttributeId());
out.println(attr.getAttributeValue()); out.println(attr.getAttributeValue());
...@@ -2495,9 +2509,11 @@ public final class KeyTool { ...@@ -2495,9 +2509,11 @@ public final class KeyTool {
X509CertImpl.INFO); X509CertImpl.INFO);
CertificateExtensions exts = (CertificateExtensions) CertificateExtensions exts = (CertificateExtensions)
certInfo.get(X509CertInfo.EXTENSIONS); certInfo.get(X509CertInfo.EXTENSIONS);
if (exts != null) {
printExtensions(rb.getString("Extensions: "), exts, out); printExtensions(rb.getString("Extensions: "), exts, out);
} }
} }
}
private static void printExtensions(String title, CertificateExtensions exts, PrintStream out) private static void printExtensions(String title, CertificateExtensions exts, PrintStream out)
throws Exception { throws Exception {
......
/* /*
* Copyright 2004-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2004-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/*
* Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.security.x509;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Enumeration;
import sun.security.util.*;
/**
* Represent the OCSP NoCheck Extension from RFC2560.
* <p>
* A CA may specify that an OCSP client can trust a responder for the
* lifetime of the responder's certificate. The CA does so by including
* the extension id-pkix-ocsp-nocheck. This SHOULD be a non-critical
* extension. The value of the extension should be NULL. CAs issuing
* such a certificate should realized that a compromise of the
* responder's key, is as serious as the compromise of a CA key used to
* sign CRLs, at least for the validity period of this certificate. CA's
* may choose to issue this type of certificate with a very short
* lifetime and renew it frequently.
* <pre>
* id-pkix-ocsp-nocheck OBJECT IDENTIFIER ::= { id-pkix-ocsp 5 }
* </pre>
*
* @author Xuelei Fan
* @see Extension
* @see CertAttrSet
*/
public class OCSPNoCheckExtension extends Extension
implements CertAttrSet<String> {
/**
* Identifier for this attribute, to be used with the
* get, set, delete methods of Certificate, x509 type.
*/
public static final String IDENT =
"x509.info.extensions.OCSPNoCheck";
/**
* Attribute names.
*/
public static final String NAME = "OCSPNoCheck";
/**
* Create a OCSPNoCheckExtension
*/
public OCSPNoCheckExtension() throws IOException {
this.extensionId = PKIXExtensions.OCSPNoCheck_Id;
this.critical = false;
this.extensionValue = new byte[0];
}
/**
* Create the extension from the passed DER encoded value.
*
* @param critical true if the extension is to be treated as critical.
* @param value an array of DER encoded bytes of the actual value.
* @exception IOException on error.
*/
public OCSPNoCheckExtension(Boolean critical, Object value)
throws IOException {
this.extensionId = PKIXExtensions.OCSPNoCheck_Id;
this.critical = critical.booleanValue();
// the value should be null, just ignore it here.
this.extensionValue = new byte[0];
}
/**
* Set the attribute value.
*/
public void set(String name, Object obj) throws IOException {
throw new IOException("No attribute is allowed by " +
"CertAttrSet:OCSPNoCheckExtension.");
}
/**
* Get the attribute value.
*/
public Object get(String name) throws IOException {
throw new IOException("No attribute is allowed by " +
"CertAttrSet:OCSPNoCheckExtension.");
}
/**
* Delete the attribute value.
*/
public void delete(String name) throws IOException {
throw new IOException("No attribute is allowed by " +
"CertAttrSet:OCSPNoCheckExtension.");
}
/**
* Return an enumeration of names of attributes existing within this
* attribute.
*/
public Enumeration<String> getElements() {
return (new AttributeNameEnumeration()).elements();
}
/**
* Return the name of this attribute.
*/
public String getName() {
return NAME;
}
}
...@@ -100,6 +100,8 @@ public class OIDMap { ...@@ -100,6 +100,8 @@ public class OIDMap {
DeltaCRLIndicatorExtension.NAME; DeltaCRLIndicatorExtension.NAME;
private static final String FRESHEST_CRL = ROOT + "." + private static final String FRESHEST_CRL = ROOT + "." +
FreshestCRLExtension.NAME; FreshestCRLExtension.NAME;
private static final String OCSPNOCHECK = ROOT + "." +
OCSPNoCheckExtension.NAME;
private static final int NetscapeCertType_data[] = private static final int NetscapeCertType_data[] =
{ 2, 16, 840, 1, 113730, 1, 1 }; { 2, 16, 840, 1, 113730, 1, 1 };
...@@ -161,6 +163,8 @@ public class OIDMap { ...@@ -161,6 +163,8 @@ public class OIDMap {
"sun.security.x509.DeltaCRLIndicatorExtension"); "sun.security.x509.DeltaCRLIndicatorExtension");
addInternal(FRESHEST_CRL, PKIXExtensions.FreshestCRL_Id, addInternal(FRESHEST_CRL, PKIXExtensions.FreshestCRL_Id,
"sun.security.x509.FreshestCRLExtension"); "sun.security.x509.FreshestCRLExtension");
addInternal(OCSPNOCHECK, PKIXExtensions.OCSPNoCheck_Id,
"sun.security.x509.OCSPNoCheckExtension");
} }
/** /**
......
/* /*
* Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -74,6 +74,8 @@ public class PKIXExtensions { ...@@ -74,6 +74,8 @@ public class PKIXExtensions {
private static final int AuthInfoAccess_data [] = { 1, 3, 6, 1, 5, 5, 7, 1, 1}; private static final int AuthInfoAccess_data [] = { 1, 3, 6, 1, 5, 5, 7, 1, 1};
private static final int SubjectInfoAccess_data [] = { 1, 3, 6, 1, 5, 5, 7, 1, 11}; private static final int SubjectInfoAccess_data [] = { 1, 3, 6, 1, 5, 5, 7, 1, 11};
private static final int FreshestCRL_data [] = { 2, 5, 29, 46 }; private static final int FreshestCRL_data [] = { 2, 5, 29, 46 };
private static final int OCSPNoCheck_data [] = { 1, 3, 6, 1, 5, 5, 7,
48, 1, 5};
/** /**
* Identifies the particular public key used to sign the certificate. * Identifies the particular public key used to sign the certificate.
...@@ -216,6 +218,12 @@ public class PKIXExtensions { ...@@ -216,6 +218,12 @@ public class PKIXExtensions {
*/ */
public static final ObjectIdentifier FreshestCRL_Id; public static final ObjectIdentifier FreshestCRL_Id;
/**
* Identifies the OCSP client can trust the responder for the
* lifetime of the responder's certificate.
*/
public static final ObjectIdentifier OCSPNoCheck_Id;
static { static {
AuthorityKey_Id = ObjectIdentifier.newInternal(AuthorityKey_data); AuthorityKey_Id = ObjectIdentifier.newInternal(AuthorityKey_data);
SubjectKey_Id = ObjectIdentifier.newInternal(SubjectKey_data); SubjectKey_Id = ObjectIdentifier.newInternal(SubjectKey_data);
...@@ -257,5 +265,6 @@ public class PKIXExtensions { ...@@ -257,5 +265,6 @@ public class PKIXExtensions {
SubjectInfoAccess_Id = SubjectInfoAccess_Id =
ObjectIdentifier.newInternal(SubjectInfoAccess_data); ObjectIdentifier.newInternal(SubjectInfoAccess_data);
FreshestCRL_Id = ObjectIdentifier.newInternal(FreshestCRL_data); FreshestCRL_Id = ObjectIdentifier.newInternal(FreshestCRL_data);
OCSPNoCheck_Id = ObjectIdentifier.newInternal(OCSPNoCheck_data);
} }
} }
...@@ -15,7 +15,8 @@ grant { ...@@ -15,7 +15,8 @@ grant {
// It is strongly recommended that you either remove this permission // It is strongly recommended that you either remove this permission
// from this policy file or further restrict it to code sources // from this policy file or further restrict it to code sources
// that you specify, because Thread.stop() is potentially unsafe. // that you specify, because Thread.stop() is potentially unsafe.
// See "http://java.sun.com/notes" for more information. // See the API specification of java.lang.Thread.stop() for more
// information.
permission java.lang.RuntimePermission "stopThread"; permission java.lang.RuntimePermission "stopThread";
// allows anyone to listen on un-privileged ports // allows anyone to listen on un-privileged ports
......
/* /*
* Copyright 1995-2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1995-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* Copyright 1995-2006 Sun Microsystems, Inc. All Rights Reserved. * Copyright 1995-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
/* /*
* Portions Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. * Portions Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
*/ */
/* Copyright (c) 2002 Graz University of Technology. All rights reserved. /* Copyright (c) 2002 Graz University of Technology. All rights reserved.
...@@ -81,6 +81,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1EncryptInit ...@@ -81,6 +81,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1EncryptInit
ckSessionHandle = jLongToCKULong(jSessionHandle); ckSessionHandle = jLongToCKULong(jSessionHandle);
ckKeyHandle = jLongToCKULong(jKeyHandle); ckKeyHandle = jLongToCKULong(jKeyHandle);
jMechanismToCKMechanism(env, jMechanism, &ckMechanism); jMechanismToCKMechanism(env, jMechanism, &ckMechanism);
if ((*env)->ExceptionCheck(env)) { return; }
rv = (*ckpFunctions->C_EncryptInit)(ckSessionHandle, &ckMechanism, rv = (*ckpFunctions->C_EncryptInit)(ckSessionHandle, &ckMechanism,
ckKeyHandle); ckKeyHandle);
...@@ -126,14 +127,29 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1Encrypt ...@@ -126,14 +127,29 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1Encrypt
if (jInLen > MAX_STACK_BUFFER_LEN) { if (jInLen > MAX_STACK_BUFFER_LEN) {
inBufP = (CK_BYTE_PTR)malloc((size_t)jInLen); inBufP = (CK_BYTE_PTR)malloc((size_t)jInLen);
if (inBufP == NULL) {
JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
} else { } else {
inBufP = IBUF; inBufP = IBUF;
} }
(*env)->GetByteArrayRegion(env, jIn, jInOfs, jInLen, (jbyte *)inBufP); (*env)->GetByteArrayRegion(env, jIn, jInOfs, jInLen, (jbyte *)inBufP);
if ((*env)->ExceptionCheck(env)) {
if (inBufP != IBUF) { free(inBufP); }
return 0;
}
ckEncryptedPartLen = jOutLen; ckEncryptedPartLen = jOutLen;
if (jOutLen > MAX_STACK_BUFFER_LEN) { if (jOutLen > MAX_STACK_BUFFER_LEN) {
outBufP = (CK_BYTE_PTR)malloc((size_t)jOutLen); outBufP = (CK_BYTE_PTR)malloc((size_t)jOutLen);
if (outBufP == NULL) {
if (inBufP != IBUF) {
free(inBufP);
}
JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
} else { } else {
outBufP = OBUF; outBufP = OBUF;
} }
...@@ -193,10 +209,18 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1EncryptUpdate ...@@ -193,10 +209,18 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1EncryptUpdate
} else { } else {
if (jInLen > MAX_STACK_BUFFER_LEN) { if (jInLen > MAX_STACK_BUFFER_LEN) {
inBufP = (CK_BYTE_PTR)malloc((size_t)jInLen); inBufP = (CK_BYTE_PTR)malloc((size_t)jInLen);
if (inBufP == NULL) {
JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
} else { } else {
inBufP = IBUF; inBufP = IBUF;
} }
(*env)->GetByteArrayRegion(env, jIn, jInOfs, jInLen, (jbyte *)inBufP); (*env)->GetByteArrayRegion(env, jIn, jInOfs, jInLen, (jbyte *)inBufP);
if ((*env)->ExceptionCheck(env)) {
if (directIn == 0 && inBufP != IBUF) { free(inBufP); }
return 0;
}
} }
ckEncryptedPartLen = jOutLen; ckEncryptedPartLen = jOutLen;
...@@ -205,6 +229,13 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1EncryptUpdate ...@@ -205,6 +229,13 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1EncryptUpdate
} else { } else {
if (jOutLen > MAX_STACK_BUFFER_LEN) { if (jOutLen > MAX_STACK_BUFFER_LEN) {
outBufP = (CK_BYTE_PTR)malloc((size_t)jOutLen); outBufP = (CK_BYTE_PTR)malloc((size_t)jOutLen);
if (outBufP == NULL) {
if (directIn == 0 && inBufP != IBUF) {
free(inBufP);
}
JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
} else { } else {
outBufP = OBUF; outBufP = OBUF;
} }
...@@ -317,6 +348,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptInit ...@@ -317,6 +348,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptInit
ckSessionHandle = jLongToCKULong(jSessionHandle); ckSessionHandle = jLongToCKULong(jSessionHandle);
ckKeyHandle = jLongToCKULong(jKeyHandle); ckKeyHandle = jLongToCKULong(jKeyHandle);
jMechanismToCKMechanism(env, jMechanism, &ckMechanism); jMechanismToCKMechanism(env, jMechanism, &ckMechanism);
if ((*env)->ExceptionCheck(env)) { return; }
rv = (*ckpFunctions->C_DecryptInit)(ckSessionHandle, &ckMechanism, rv = (*ckpFunctions->C_DecryptInit)(ckSessionHandle, &ckMechanism,
ckKeyHandle); ckKeyHandle);
...@@ -362,14 +394,29 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1Decrypt ...@@ -362,14 +394,29 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1Decrypt
if (jInLen > MAX_STACK_BUFFER_LEN) { if (jInLen > MAX_STACK_BUFFER_LEN) {
inBufP = (CK_BYTE_PTR)malloc((size_t)jInLen); inBufP = (CK_BYTE_PTR)malloc((size_t)jInLen);
if (inBufP == NULL) {
JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
} else { } else {
inBufP = IBUF; inBufP = IBUF;
} }
(*env)->GetByteArrayRegion(env, jIn, jInOfs, jInLen, (jbyte *)inBufP); (*env)->GetByteArrayRegion(env, jIn, jInOfs, jInLen, (jbyte *)inBufP);
if ((*env)->ExceptionCheck(env)) {
if (inBufP != IBUF) { free(inBufP); }
return 0;
}
ckPartLen = jOutLen; ckPartLen = jOutLen;
if (jOutLen > MAX_STACK_BUFFER_LEN) { if (jOutLen > MAX_STACK_BUFFER_LEN) {
outBufP = (CK_BYTE_PTR)malloc((size_t)jOutLen); outBufP = (CK_BYTE_PTR)malloc((size_t)jOutLen);
if (outBufP == NULL) {
if (inBufP != IBUF) {
free(inBufP);
}
JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
} else { } else {
outBufP = OBUF; outBufP = OBUF;
} }
...@@ -429,10 +476,18 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptUpdate ...@@ -429,10 +476,18 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptUpdate
} else { } else {
if (jInLen > MAX_STACK_BUFFER_LEN) { if (jInLen > MAX_STACK_BUFFER_LEN) {
inBufP = (CK_BYTE_PTR)malloc((size_t)jInLen); inBufP = (CK_BYTE_PTR)malloc((size_t)jInLen);
if (inBufP == NULL) {
JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
} else { } else {
inBufP = IBUF; inBufP = IBUF;
} }
(*env)->GetByteArrayRegion(env, jIn, jInOfs, jInLen, (jbyte *)inBufP); (*env)->GetByteArrayRegion(env, jIn, jInOfs, jInLen, (jbyte *)inBufP);
if ((*env)->ExceptionCheck(env)) {
if (directIn == 0 && inBufP != IBUF) { free(inBufP); }
return 0;
}
} }
ckDecryptedPartLen = jOutLen; ckDecryptedPartLen = jOutLen;
...@@ -441,6 +496,13 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptUpdate ...@@ -441,6 +496,13 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptUpdate
} else { } else {
if (jOutLen > MAX_STACK_BUFFER_LEN) { if (jOutLen > MAX_STACK_BUFFER_LEN) {
outBufP = (CK_BYTE_PTR)malloc((size_t)jOutLen); outBufP = (CK_BYTE_PTR)malloc((size_t)jOutLen);
if (outBufP == NULL) {
if (directIn == 0 && inBufP != IBUF) {
free(inBufP);
}
JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
} else { } else {
outBufP = OBUF; outBufP = OBUF;
} }
......
/* /*
* Portions Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * Portions Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
*/ */
/* Copyright (c) 2002 Graz University of Technology. All rights reserved. /* Copyright (c) 2002 Graz University of Technology. All rights reserved.
...@@ -75,6 +75,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestInit ...@@ -75,6 +75,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestInit
ckSessionHandle = jLongToCKULong(jSessionHandle); ckSessionHandle = jLongToCKULong(jSessionHandle);
jMechanismToCKMechanism(env, jMechanism, &ckMechanism); jMechanismToCKMechanism(env, jMechanism, &ckMechanism);
if ((*env)->ExceptionCheck(env)) { return; }
rv = (*ckpFunctions->C_DigestInit)(ckSessionHandle, &ckMechanism); rv = (*ckpFunctions->C_DigestInit)(ckSessionHandle, &ckMechanism);
...@@ -82,7 +83,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestInit ...@@ -82,7 +83,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestInit
free(ckMechanism.pParameter); free(ckMechanism.pParameter);
} }
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; } if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; }
} }
#endif #endif
...@@ -114,6 +115,7 @@ JNIEXPORT jint JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestSingle ...@@ -114,6 +115,7 @@ JNIEXPORT jint JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestSingle
ckSessionHandle = jLongToCKULong(jSessionHandle); ckSessionHandle = jLongToCKULong(jSessionHandle);
jMechanismToCKMechanism(env, jMechanism, &ckMechanism); jMechanismToCKMechanism(env, jMechanism, &ckMechanism);
if ((*env)->ExceptionCheck(env)) { return 0; }
rv = (*ckpFunctions->C_DigestInit)(ckSessionHandle, &ckMechanism); rv = (*ckpFunctions->C_DigestInit)(ckSessionHandle, &ckMechanism);
...@@ -121,29 +123,32 @@ JNIEXPORT jint JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestSingle ...@@ -121,29 +123,32 @@ JNIEXPORT jint JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestSingle
free(ckMechanism.pParameter); free(ckMechanism.pParameter);
} }
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return 0; } if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return 0; }
if (jInLen <= MAX_STACK_BUFFER_LEN) { if (jInLen <= MAX_STACK_BUFFER_LEN) {
bufP = BUF; bufP = BUF;
} else { } else {
/* always use single part op, even for large data */ /* always use single part op, even for large data */
bufP = (CK_BYTE_PTR)malloc((size_t)jInLen); bufP = (CK_BYTE_PTR) malloc((size_t)jInLen);
if (bufP == NULL) {
JNU_ThrowOutOfMemoryError(env, 0);
return 0;
}
} }
(*env)->GetByteArrayRegion(env, jIn, jInOfs, jInLen, (jbyte *)bufP); (*env)->GetByteArrayRegion(env, jIn, jInOfs, jInLen, (jbyte *)bufP);
rv = (*ckpFunctions->C_Digest)(ckSessionHandle, bufP, jInLen, DIGESTBUF, &ckDigestLength); if ((*env)->ExceptionCheck(env)) {
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { if (bufP != BUF) { free(bufP); }
if (bufP != BUF) {
free(bufP);
}
return 0; return 0;
} }
rv = (*ckpFunctions->C_Digest)(ckSessionHandle, bufP, jInLen, DIGESTBUF, &ckDigestLength);
if (ckAssertReturnValueOK(env, rv) == CK_ASSERT_OK) {
(*env)->SetByteArrayRegion(env, jDigest, jDigestOfs, ckDigestLength, (jbyte *)DIGESTBUF); (*env)->SetByteArrayRegion(env, jDigest, jDigestOfs, ckDigestLength, (jbyte *)DIGESTBUF);
if (bufP != BUF) {
free(bufP);
} }
if (bufP != BUF) { free(bufP); }
return ckDigestLength; return ckDigestLength;
} }
#endif #endif
...@@ -183,17 +188,23 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestUpdate ...@@ -183,17 +188,23 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestUpdate
bufP = BUF; bufP = BUF;
} else { } else {
bufLen = min(MAX_HEAP_BUFFER_LEN, jInLen); bufLen = min(MAX_HEAP_BUFFER_LEN, jInLen);
bufP = (CK_BYTE_PTR)malloc((size_t)bufLen); bufP = (CK_BYTE_PTR) malloc((size_t)bufLen);
if (bufP == NULL) {
JNU_ThrowOutOfMemoryError(env, 0);
return;
}
} }
while (jInLen > 0) { while (jInLen > 0) {
jsize chunkLen = min(bufLen, jInLen); jsize chunkLen = min(bufLen, jInLen);
(*env)->GetByteArrayRegion(env, jIn, jInOfs, chunkLen, (jbyte *)bufP); (*env)->GetByteArrayRegion(env, jIn, jInOfs, chunkLen, (jbyte *)bufP);
rv = (*ckpFunctions->C_DigestUpdate)(ckSessionHandle, bufP, chunkLen); if ((*env)->ExceptionCheck(env)) {
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { if (bufP != BUF) { free(bufP); }
if (bufP != BUF) { return;
free(bufP);
} }
rv = (*ckpFunctions->C_DigestUpdate)(ckSessionHandle, bufP, chunkLen);
if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) {
if (bufP != BUF) { free(bufP); }
return; return;
} }
jInOfs += chunkLen; jInOfs += chunkLen;
...@@ -229,7 +240,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestKey ...@@ -229,7 +240,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestKey
ckKeyHandle = jLongToCKULong(jKeyHandle); ckKeyHandle = jLongToCKULong(jKeyHandle);
rv = (*ckpFunctions->C_DigestKey)(ckSessionHandle, ckKeyHandle); rv = (*ckpFunctions->C_DigestKey)(ckSessionHandle, ckKeyHandle);
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; } if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; }
} }
#endif #endif
...@@ -257,10 +268,9 @@ JNIEXPORT jint JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestFinal ...@@ -257,10 +268,9 @@ JNIEXPORT jint JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestFinal
ckSessionHandle = jLongToCKULong(jSessionHandle); ckSessionHandle = jLongToCKULong(jSessionHandle);
rv = (*ckpFunctions->C_DigestFinal)(ckSessionHandle, BUF, &ckDigestLength); rv = (*ckpFunctions->C_DigestFinal)(ckSessionHandle, BUF, &ckDigestLength);
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return 0 ; } if (ckAssertReturnValueOK(env, rv) == CK_ASSERT_OK) {
(*env)->SetByteArrayRegion(env, jDigest, jDigestOfs, ckDigestLength, (jbyte *)BUF); (*env)->SetByteArrayRegion(env, jDigest, jDigestOfs, ckDigestLength, (jbyte *)BUF);
}
return ckDigestLength; return ckDigestLength;
} }
#endif #endif
...@@ -288,12 +298,13 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SeedRandom ...@@ -288,12 +298,13 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SeedRandom
ckSessionHandle = jLongToCKULong(jSessionHandle); ckSessionHandle = jLongToCKULong(jSessionHandle);
jByteArrayToCKByteArray(env, jSeed, &ckpSeed, &ckSeedLength); jByteArrayToCKByteArray(env, jSeed, &ckpSeed, &ckSeedLength);
if ((*env)->ExceptionCheck(env)) { return; }
rv = (*ckpFunctions->C_SeedRandom)(ckSessionHandle, ckpSeed, ckSeedLength); rv = (*ckpFunctions->C_SeedRandom)(ckSessionHandle, ckpSeed, ckSeedLength);
free(ckpSeed); free(ckpSeed);
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; } if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; }
} }
#endif #endif
...@@ -322,6 +333,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GenerateRandom ...@@ -322,6 +333,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GenerateRandom
jRandomBufferLength = (*env)->GetArrayLength(env, jRandomData); jRandomBufferLength = (*env)->GetArrayLength(env, jRandomData);
jRandomBuffer = (*env)->GetByteArrayElements(env, jRandomData, NULL); jRandomBuffer = (*env)->GetByteArrayElements(env, jRandomData, NULL);
if (jRandomBuffer == NULL) { return; }
rv = (*ckpFunctions->C_GenerateRandom)(ckSessionHandle, rv = (*ckpFunctions->C_GenerateRandom)(ckSessionHandle,
(CK_BYTE_PTR) jRandomBuffer, (CK_BYTE_PTR) jRandomBuffer,
...@@ -330,6 +342,6 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GenerateRandom ...@@ -330,6 +342,6 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GenerateRandom
/* copy back generated bytes */ /* copy back generated bytes */
(*env)->ReleaseByteArrayElements(env, jRandomData, jRandomBuffer, 0); (*env)->ReleaseByteArrayElements(env, jRandomData, jRandomBuffer, 0);
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; } if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; }
} }
#endif #endif
/* /*
* Portions Copyright 2003-2007 Sun Microsystems, Inc. All Rights Reserved. * Portions Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
*/ */
/* Copyright (c) 2002 Graz University of Technology. All rights reserved. /* Copyright (c) 2002 Graz University of Technology. All rights reserved.
...@@ -73,7 +73,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestEn ...@@ -73,7 +73,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestEn
CK_SESSION_HANDLE ckSessionHandle; CK_SESSION_HANDLE ckSessionHandle;
CK_BYTE_PTR ckpPart = NULL_PTR, ckpEncryptedPart; CK_BYTE_PTR ckpPart = NULL_PTR, ckpEncryptedPart;
CK_ULONG ckPartLength, ckEncryptedPartLength = 0; CK_ULONG ckPartLength, ckEncryptedPartLength = 0;
jbyteArray jEncryptedPart; jbyteArray jEncryptedPart = NULL;
CK_RV rv; CK_RV rv;
CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj); CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
...@@ -81,20 +81,28 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestEn ...@@ -81,20 +81,28 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DigestEn
ckSessionHandle = jLongToCKULong(jSessionHandle); ckSessionHandle = jLongToCKULong(jSessionHandle);
jByteArrayToCKByteArray(env, jPart, &ckpPart, &ckPartLength); jByteArrayToCKByteArray(env, jPart, &ckpPart, &ckPartLength);
if ((*env)->ExceptionCheck(env)) { return NULL; }
rv = (*ckpFunctions->C_DigestEncryptUpdate)(ckSessionHandle, ckpPart, ckPartLength, NULL_PTR, &ckEncryptedPartLength); rv = (*ckpFunctions->C_DigestEncryptUpdate)(ckSessionHandle, ckpPart, ckPartLength, NULL_PTR, &ckEncryptedPartLength);
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return NULL ; } if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) {
free(ckpPart);
return NULL;
}
ckpEncryptedPart = (CK_BYTE_PTR) malloc(ckEncryptedPartLength * sizeof(CK_BYTE)); ckpEncryptedPart = (CK_BYTE_PTR) malloc(ckEncryptedPartLength * sizeof(CK_BYTE));
if (ckpEncryptedPart == NULL) {
free(ckpPart);
JNU_ThrowOutOfMemoryError(env, 0);
return NULL;
}
rv = (*ckpFunctions->C_DigestEncryptUpdate)(ckSessionHandle, ckpPart, ckPartLength, ckpEncryptedPart, &ckEncryptedPartLength); rv = (*ckpFunctions->C_DigestEncryptUpdate)(ckSessionHandle, ckpPart, ckPartLength, ckpEncryptedPart, &ckEncryptedPartLength);
if (ckAssertReturnValueOK(env, rv) == CK_ASSERT_OK) {
jEncryptedPart = ckByteArrayToJByteArray(env, ckpEncryptedPart, ckEncryptedPartLength); jEncryptedPart = ckByteArrayToJByteArray(env, ckpEncryptedPart, ckEncryptedPartLength);
}
free(ckpPart); free(ckpPart);
free(ckpEncryptedPart); free(ckpEncryptedPart);
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return NULL ; }
return jEncryptedPart ; return jEncryptedPart ;
} }
#endif #endif
...@@ -117,7 +125,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptD ...@@ -117,7 +125,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptD
CK_SESSION_HANDLE ckSessionHandle; CK_SESSION_HANDLE ckSessionHandle;
CK_BYTE_PTR ckpPart, ckpEncryptedPart = NULL_PTR; CK_BYTE_PTR ckpPart, ckpEncryptedPart = NULL_PTR;
CK_ULONG ckPartLength = 0, ckEncryptedPartLength; CK_ULONG ckPartLength = 0, ckEncryptedPartLength;
jbyteArray jPart; jbyteArray jPart = NULL;
CK_RV rv; CK_RV rv;
CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj); CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
...@@ -125,19 +133,27 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptD ...@@ -125,19 +133,27 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptD
ckSessionHandle = jLongToCKULong(jSessionHandle); ckSessionHandle = jLongToCKULong(jSessionHandle);
jByteArrayToCKByteArray(env, jEncryptedPart, &ckpEncryptedPart, &ckEncryptedPartLength); jByteArrayToCKByteArray(env, jEncryptedPart, &ckpEncryptedPart, &ckEncryptedPartLength);
if ((*env)->ExceptionCheck(env)) { return NULL; }
rv = (*ckpFunctions->C_DecryptDigestUpdate)(ckSessionHandle, ckpEncryptedPart, ckEncryptedPartLength, NULL_PTR, &ckPartLength); rv = (*ckpFunctions->C_DecryptDigestUpdate)(ckSessionHandle, ckpEncryptedPart, ckEncryptedPartLength, NULL_PTR, &ckPartLength);
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return NULL; } if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) {
free(ckpEncryptedPart);
return NULL;
}
ckpPart = (CK_BYTE_PTR) malloc(ckPartLength * sizeof(CK_BYTE)); ckpPart = (CK_BYTE_PTR) malloc(ckPartLength * sizeof(CK_BYTE));
if (ckpPart == NULL) {
free(ckpEncryptedPart);
JNU_ThrowOutOfMemoryError(env, 0);
return NULL;
}
rv = (*ckpFunctions->C_DecryptDigestUpdate)(ckSessionHandle, ckpEncryptedPart, ckEncryptedPartLength, ckpPart, &ckPartLength); rv = (*ckpFunctions->C_DecryptDigestUpdate)(ckSessionHandle, ckpEncryptedPart, ckEncryptedPartLength, ckpPart, &ckPartLength);
if (ckAssertReturnValueOK(env, rv) == CK_ASSERT_OK) {
jPart = ckByteArrayToJByteArray(env, ckpPart, ckPartLength); jPart = ckByteArrayToJByteArray(env, ckpPart, ckPartLength);
free(ckpPart); }
free(ckpEncryptedPart); free(ckpEncryptedPart);
free(ckpPart);
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return NULL ; }
return jPart ; return jPart ;
} }
...@@ -161,7 +177,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SignEncr ...@@ -161,7 +177,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SignEncr
CK_SESSION_HANDLE ckSessionHandle; CK_SESSION_HANDLE ckSessionHandle;
CK_BYTE_PTR ckpPart = NULL_PTR, ckpEncryptedPart; CK_BYTE_PTR ckpPart = NULL_PTR, ckpEncryptedPart;
CK_ULONG ckPartLength, ckEncryptedPartLength = 0; CK_ULONG ckPartLength, ckEncryptedPartLength = 0;
jbyteArray jEncryptedPart; jbyteArray jEncryptedPart = NULL;
CK_RV rv; CK_RV rv;
CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj); CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
...@@ -169,20 +185,28 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SignEncr ...@@ -169,20 +185,28 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SignEncr
ckSessionHandle = jLongToCKULong(jSessionHandle); ckSessionHandle = jLongToCKULong(jSessionHandle);
jByteArrayToCKByteArray(env, jPart, &ckpPart, &ckPartLength); jByteArrayToCKByteArray(env, jPart, &ckpPart, &ckPartLength);
if ((*env)->ExceptionCheck(env)) { return NULL; }
rv = (*ckpFunctions->C_SignEncryptUpdate)(ckSessionHandle, ckpPart, ckPartLength, NULL_PTR, &ckEncryptedPartLength); rv = (*ckpFunctions->C_SignEncryptUpdate)(ckSessionHandle, ckpPart, ckPartLength, NULL_PTR, &ckEncryptedPartLength);
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return NULL ; } if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) {
free(ckpPart);
return NULL;
}
ckpEncryptedPart = (CK_BYTE_PTR) malloc(ckEncryptedPartLength * sizeof(CK_BYTE)); ckpEncryptedPart = (CK_BYTE_PTR) malloc(ckEncryptedPartLength * sizeof(CK_BYTE));
if (ckpEncryptedPart == NULL) {
free(ckpPart);
JNU_ThrowOutOfMemoryError(env, 0);
return NULL;
}
rv = (*ckpFunctions->C_SignEncryptUpdate)(ckSessionHandle, ckpPart, ckPartLength, ckpEncryptedPart, &ckEncryptedPartLength); rv = (*ckpFunctions->C_SignEncryptUpdate)(ckSessionHandle, ckpPart, ckPartLength, ckpEncryptedPart, &ckEncryptedPartLength);
if (ckAssertReturnValueOK(env, rv) == CK_ASSERT_OK) {
jEncryptedPart = ckByteArrayToJByteArray(env, ckpEncryptedPart, ckEncryptedPartLength); jEncryptedPart = ckByteArrayToJByteArray(env, ckpEncryptedPart, ckEncryptedPartLength);
}
free(ckpPart); free(ckpPart);
free(ckpEncryptedPart); free(ckpEncryptedPart);
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return NULL ; }
return jEncryptedPart ; return jEncryptedPart ;
} }
#endif #endif
...@@ -205,7 +229,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptV ...@@ -205,7 +229,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptV
CK_SESSION_HANDLE ckSessionHandle; CK_SESSION_HANDLE ckSessionHandle;
CK_BYTE_PTR ckpPart, ckpEncryptedPart = NULL_PTR; CK_BYTE_PTR ckpPart, ckpEncryptedPart = NULL_PTR;
CK_ULONG ckPartLength = 0, ckEncryptedPartLength; CK_ULONG ckPartLength = 0, ckEncryptedPartLength;
jbyteArray jPart; jbyteArray jPart = NULL;
CK_RV rv; CK_RV rv;
CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj); CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
...@@ -213,19 +237,28 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptV ...@@ -213,19 +237,28 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptV
ckSessionHandle = jLongToCKULong(jSessionHandle); ckSessionHandle = jLongToCKULong(jSessionHandle);
jByteArrayToCKByteArray(env, jEncryptedPart, &ckpEncryptedPart, &ckEncryptedPartLength); jByteArrayToCKByteArray(env, jEncryptedPart, &ckpEncryptedPart, &ckEncryptedPartLength);
if ((*env)->ExceptionCheck(env)) { return NULL; }
rv = (*ckpFunctions->C_DecryptVerifyUpdate)(ckSessionHandle, ckpEncryptedPart, ckEncryptedPartLength, NULL_PTR, &ckPartLength); rv = (*ckpFunctions->C_DecryptVerifyUpdate)(ckSessionHandle, ckpEncryptedPart, ckEncryptedPartLength, NULL_PTR, &ckPartLength);
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return NULL ; } if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) {
free(ckpEncryptedPart);
return NULL;
}
ckpPart = (CK_BYTE_PTR) malloc(ckPartLength * sizeof(CK_BYTE)); ckpPart = (CK_BYTE_PTR) malloc(ckPartLength * sizeof(CK_BYTE));
if (ckpPart == NULL) {
free(ckpEncryptedPart);
JNU_ThrowOutOfMemoryError(env, 0);
return NULL;
}
rv = (*ckpFunctions->C_DecryptVerifyUpdate)(ckSessionHandle, ckpEncryptedPart, ckEncryptedPartLength, ckpPart, &ckPartLength); rv = (*ckpFunctions->C_DecryptVerifyUpdate)(ckSessionHandle, ckpEncryptedPart, ckEncryptedPartLength, ckpPart, &ckPartLength);
if (ckAssertReturnValueOK(env, rv) == CK_ASSERT_OK) {
jPart = ckByteArrayToJByteArray(env, ckpPart, ckPartLength); jPart = ckByteArrayToJByteArray(env, ckpPart, ckPartLength);
free(ckpPart); }
free(ckpEncryptedPart); free(ckpEncryptedPart);
free(ckpPart);
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return NULL ; }
return jPart ; return jPart ;
} }
...@@ -252,7 +285,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetFunctionSta ...@@ -252,7 +285,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetFunctionSta
/* C_GetFunctionStatus should always return CKR_FUNCTION_NOT_PARALLEL */ /* C_GetFunctionStatus should always return CKR_FUNCTION_NOT_PARALLEL */
rv = (*ckpFunctions->C_GetFunctionStatus)(ckSessionHandle); rv = (*ckpFunctions->C_GetFunctionStatus)(ckSessionHandle);
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; } if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; }
} }
#endif #endif
...@@ -277,6 +310,6 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1CancelFunction ...@@ -277,6 +310,6 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1CancelFunction
/* C_GetFunctionStatus should always return CKR_FUNCTION_NOT_PARALLEL */ /* C_GetFunctionStatus should always return CKR_FUNCTION_NOT_PARALLEL */
rv = (*ckpFunctions->C_CancelFunction)(ckSessionHandle); rv = (*ckpFunctions->C_CancelFunction)(ckSessionHandle);
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; } if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; }
} }
#endif #endif
/* /*
* Portions Copyright 2003 Sun Microsystems, Inc. All Rights Reserved. * Portions Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
*/ */
/* Copyright (c) 2002 Graz University of Technology. All rights reserved. /* Copyright (c) 2002 Graz University of Technology. All rights reserved.
...@@ -97,6 +97,10 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1OpenSession ...@@ -97,6 +97,10 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1OpenSession
#ifndef NO_CALLBACKS #ifndef NO_CALLBACKS
if (jNotify != NULL) { if (jNotify != NULL) {
notifyEncapsulation = (NotifyEncapsulation *) malloc(sizeof(NotifyEncapsulation)); notifyEncapsulation = (NotifyEncapsulation *) malloc(sizeof(NotifyEncapsulation));
if (notifyEncapsulation == NULL) {
JNU_ThrowOutOfMemoryError(env, 0);
return 0L;
}
notifyEncapsulation->jApplicationData = (jApplication != NULL) notifyEncapsulation->jApplicationData = (jApplication != NULL)
? (*env)->NewGlobalRef(env, jApplication) ? (*env)->NewGlobalRef(env, jApplication)
: NULL; : NULL;
...@@ -118,7 +122,18 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1OpenSession ...@@ -118,7 +122,18 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1OpenSession
TRACE0(" ... "); TRACE0(" ... ");
rv = (*ckpFunctions->C_OpenSession)(ckSlotID, ckFlags, ckpApplication, ckNotify, &ckSessionHandle); rv = (*ckpFunctions->C_OpenSession)(ckSlotID, ckFlags, ckpApplication, ckNotify, &ckSessionHandle);
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return 0L ; } if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) {
#ifndef NO_CALLBACKS
if (notifyEncapsulation != NULL) {
if (notifyEncapsulation->jApplicationData != NULL) {
(*env)->DeleteGlobalRef(env, jApplication);
}
(*env)->DeleteGlobalRef(env, jNotify);
free(notifyEncapsulation);
}
#endif /* NO_CALLBACKS */
return 0L;
}
TRACE0("got session"); TRACE0("got session");
TRACE1(", SessionHandle=%u", ckSessionHandle); TRACE1(", SessionHandle=%u", ckSessionHandle);
...@@ -163,7 +178,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1CloseSession ...@@ -163,7 +178,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1CloseSession
ckSessionHandle = jLongToCKULong(jSessionHandle); ckSessionHandle = jLongToCKULong(jSessionHandle);
rv = (*ckpFunctions->C_CloseSession)(ckSessionHandle); rv = (*ckpFunctions->C_CloseSession)(ckSessionHandle);
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; } if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; }
#ifndef NO_CALLBACKS #ifndef NO_CALLBACKS
notifyEncapsulation = removeNotifyEntry(env, ckSessionHandle); notifyEncapsulation = removeNotifyEntry(env, ckSessionHandle);
...@@ -208,7 +223,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1CloseAllSessio ...@@ -208,7 +223,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1CloseAllSessio
ckSlotID = jLongToCKULong(jSlotID); ckSlotID = jLongToCKULong(jSlotID);
rv = (*ckpFunctions->C_CloseAllSessions)(ckSlotID); rv = (*ckpFunctions->C_CloseAllSessions)(ckSlotID);
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; } if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; }
#ifndef NO_CALLBACKS #ifndef NO_CALLBACKS
/* Remove all notify callback helper objects. */ /* Remove all notify callback helper objects. */
...@@ -250,10 +265,9 @@ JNIEXPORT jobject JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetSessionI ...@@ -250,10 +265,9 @@ JNIEXPORT jobject JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetSessionI
ckSessionHandle = jLongToCKULong(jSessionHandle); ckSessionHandle = jLongToCKULong(jSessionHandle);
rv = (*ckpFunctions->C_GetSessionInfo)(ckSessionHandle, &ckSessionInfo); rv = (*ckpFunctions->C_GetSessionInfo)(ckSessionHandle, &ckSessionInfo);
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return NULL ; } if (ckAssertReturnValueOK(env, rv) == CK_ASSERT_OK) {
jSessionInfo = ckSessionInfoPtrToJSessionInfo(env, &ckSessionInfo); jSessionInfo = ckSessionInfoPtrToJSessionInfo(env, &ckSessionInfo);
}
return jSessionInfo ; return jSessionInfo ;
} }
#endif #endif
...@@ -274,7 +288,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetOpera ...@@ -274,7 +288,7 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetOpera
CK_SESSION_HANDLE ckSessionHandle; CK_SESSION_HANDLE ckSessionHandle;
CK_BYTE_PTR ckpState; CK_BYTE_PTR ckpState;
CK_ULONG ckStateLength; CK_ULONG ckStateLength;
jbyteArray jState; jbyteArray jState = NULL;
CK_RV rv; CK_RV rv;
CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj); CK_FUNCTION_LIST_PTR ckpFunctions = getFunctionList(env, obj);
...@@ -283,17 +297,20 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetOpera ...@@ -283,17 +297,20 @@ JNIEXPORT jbyteArray JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1GetOpera
ckSessionHandle = jLongToCKULong(jSessionHandle); ckSessionHandle = jLongToCKULong(jSessionHandle);
rv = (*ckpFunctions->C_GetOperationState)(ckSessionHandle, NULL_PTR, &ckStateLength); rv = (*ckpFunctions->C_GetOperationState)(ckSessionHandle, NULL_PTR, &ckStateLength);
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return NULL ; } if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return NULL ; }
ckpState = (CK_BYTE_PTR) malloc(ckStateLength); ckpState = (CK_BYTE_PTR) malloc(ckStateLength);
if (ckpState == NULL) {
JNU_ThrowOutOfMemoryError(env, 0);
return NULL;
}
rv = (*ckpFunctions->C_GetOperationState)(ckSessionHandle, ckpState, &ckStateLength); rv = (*ckpFunctions->C_GetOperationState)(ckSessionHandle, ckpState, &ckStateLength);
if (ckAssertReturnValueOK(env, rv) == CK_ASSERT_OK) {
jState = ckByteArrayToJByteArray(env, ckpState, ckStateLength); jState = ckByteArrayToJByteArray(env, ckpState, ckStateLength);
}
free(ckpState); free(ckpState);
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return NULL ; }
return jState ; return jState ;
} }
#endif #endif
...@@ -325,6 +342,8 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SetOperationSt ...@@ -325,6 +342,8 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SetOperationSt
ckSessionHandle = jLongToCKULong(jSessionHandle); ckSessionHandle = jLongToCKULong(jSessionHandle);
jByteArrayToCKByteArray(env, jOperationState, &ckpState, &ckStateLength); jByteArrayToCKByteArray(env, jOperationState, &ckpState, &ckStateLength);
if ((*env)->ExceptionCheck(env)) { return; }
ckEncryptionKeyHandle = jLongToCKULong(jEncryptionKeyHandle); ckEncryptionKeyHandle = jLongToCKULong(jEncryptionKeyHandle);
ckAuthenticationKeyHandle = jLongToCKULong(jAuthenticationKeyHandle); ckAuthenticationKeyHandle = jLongToCKULong(jAuthenticationKeyHandle);
...@@ -332,7 +351,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SetOperationSt ...@@ -332,7 +351,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1SetOperationSt
free(ckpState); free(ckpState);
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; } if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; }
} }
#endif #endif
...@@ -362,12 +381,13 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1Login ...@@ -362,12 +381,13 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1Login
ckSessionHandle = jLongToCKULong(jSessionHandle); ckSessionHandle = jLongToCKULong(jSessionHandle);
ckUserType = jLongToCKULong(jUserType); ckUserType = jLongToCKULong(jUserType);
jCharArrayToCKCharArray(env, jPin, &ckpPinArray, &ckPinLength); jCharArrayToCKCharArray(env, jPin, &ckpPinArray, &ckPinLength);
if ((*env)->ExceptionCheck(env)) { return; }
rv = (*ckpFunctions->C_Login)(ckSessionHandle, ckUserType, ckpPinArray, ckPinLength); rv = (*ckpFunctions->C_Login)(ckSessionHandle, ckUserType, ckpPinArray, ckPinLength);
free(ckpPinArray); free(ckpPinArray);
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; } if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; }
} }
#endif #endif
...@@ -391,7 +411,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1Logout ...@@ -391,7 +411,7 @@ JNIEXPORT void JNICALL Java_sun_security_pkcs11_wrapper_PKCS11_C_1Logout
ckSessionHandle = jLongToCKULong(jSessionHandle); ckSessionHandle = jLongToCKULong(jSessionHandle);
rv = (*ckpFunctions->C_Logout)(ckSessionHandle); rv = (*ckpFunctions->C_Logout)(ckSessionHandle);
if(ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; } if (ckAssertReturnValueOK(env, rv) != CK_ASSERT_OK) { return; }
} }
#endif #endif
...@@ -410,10 +430,14 @@ void putNotifyEntry(JNIEnv *env, CK_SESSION_HANDLE hSession, NotifyEncapsulation ...@@ -410,10 +430,14 @@ void putNotifyEntry(JNIEnv *env, CK_SESSION_HANDLE hSession, NotifyEncapsulation
NotifyListNode *currentNode, *newNode; NotifyListNode *currentNode, *newNode;
if (notifyEncapsulation == NULL) { if (notifyEncapsulation == NULL) {
return ; return;
} }
newNode = (NotifyListNode *) malloc(sizeof(NotifyListNode)); newNode = (NotifyListNode *) malloc(sizeof(NotifyListNode));
if (newNode == NULL) {
JNU_ThrowOutOfMemoryError(env, 0);
return;
}
newNode->hSession = hSession; newNode->hSession = hSession;
newNode->notifyEncapsulation = notifyEncapsulation; newNode->notifyEncapsulation = notifyEncapsulation;
newNode->next = NULL; newNode->next = NULL;
...@@ -578,9 +602,10 @@ CK_RV notifyCallback( ...@@ -578,9 +602,10 @@ CK_RV notifyCallback(
jEvent = ckULongToJLong(event); jEvent = ckULongToJLong(event);
ckNotifyClass = (*env)->FindClass(env, CLASS_NOTIFY); ckNotifyClass = (*env)->FindClass(env, CLASS_NOTIFY);
assert(ckNotifyClass != 0); if (ckNotifyClass == NULL) { return rv; }
jmethod = (*env)->GetMethodID(env, ckNotifyClass, "CK_NOTIFY", "(JJLjava/lang/Object;)V"); jmethod = (*env)->GetMethodID(env, ckNotifyClass, "CK_NOTIFY", "(JJLjava/lang/Object;)V");
assert(jmethod != 0); if (jmethod == NULL) { return rv; }
(*env)->CallVoidMethod(env, notifyEncapsulation->jNotifyObject, jmethod, (*env)->CallVoidMethod(env, notifyEncapsulation->jNotifyObject, jmethod,
jSessionHandle, jEvent, notifyEncapsulation->jApplicationData); jSessionHandle, jEvent, notifyEncapsulation->jApplicationData);
...@@ -588,10 +613,14 @@ CK_RV notifyCallback( ...@@ -588,10 +613,14 @@ CK_RV notifyCallback(
pkcs11Exception = (*env)->ExceptionOccurred(env); pkcs11Exception = (*env)->ExceptionOccurred(env);
if (pkcs11Exception != NULL) { if (pkcs11Exception != NULL) {
/* TBD: clear the pending exception with ExceptionClear? */
/* The was an exception thrown, now we get the error-code from it */ /* The was an exception thrown, now we get the error-code from it */
pkcs11ExceptionClass = (*env)->FindClass(env, CLASS_PKCS11EXCEPTION); pkcs11ExceptionClass = (*env)->FindClass(env, CLASS_PKCS11EXCEPTION);
if (pkcs11ExceptionClass == NULL) { return rv; }
jmethod = (*env)->GetMethodID(env, pkcs11ExceptionClass, "getErrorCode", "()J"); jmethod = (*env)->GetMethodID(env, pkcs11ExceptionClass, "getErrorCode", "()J");
assert(jmethod != 0); if (jmethod == NULL) { return rv; }
errorCode = (*env)->CallLongMethod(env, pkcs11Exception, jmethod); errorCode = (*env)->CallLongMethod(env, pkcs11Exception, jmethod);
rv = jLongToCKULong(errorCode); rv = jLongToCKULong(errorCode);
} }
......
/* /*
* Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved. * Copyright 2000-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册