This commit is contained in:
J. Duke 2017-07-05 16:42:37 +02:00
commit 3cee35d8ec
667 changed files with 30402 additions and 15670 deletions

View File

@ -11,3 +11,4 @@ bb1ef4ee3d2c8cbf43a37d372325a7952be590b9 jdk7-b33
46a989ab932992b2084b946eeb322fa99b9fee6c jdk7-b34
143c1abedb7d3095eff0f9ee5fec9bf48e3490fc jdk7-b35
4b4f5fea8d7d0743f0c30d91fcd9bf9d96e5d2ad jdk7-b36
744554f5a3290e11c71cd2ddb1aff49e431f9ed0 jdk7-b37

View File

@ -11,3 +11,4 @@ ef6af34d75a7b44e77083f1d4ee47631fa09d3b4 jdk7-b31
0a812b9824e5d17b073765d1505594b49ff88a10 jdk7-b34
3867c4d14a5bfdbb37c97b4874ccb0ee5343111c jdk7-b35
0723891eb8d1c27e67c54163af0b4cea05a4e036 jdk7-b36
59d5848bdedebe91cc2753acce78911bcb4a66db jdk7-b37

View File

@ -58,11 +58,24 @@ PLATFORM_INCLUDE = $(INCLUDEDIR)/$(PLATFORM_INCLUDE_NAME)
# The following DLL's are considered MS runtime libraries and should
# not to be REBASEd, see deploy/make/common/Release.gmk.
# msvcrt.dll, msvcr71.dll: Microsoft runtimes
# msvcrt.dll, msvcrnn.dll [msvcr71 or msvcr80 or msvcr90] : Microsoft runtimes
MS_RUNTIME_LIBRARIES = msvcrt.dll
MSVCRNN_DLL =
ifeq ($(ARCH_DATA_MODEL), 32)
ifeq ($(COMPILER_VERSION), VS2003)
MS_RUNTIME_LIBRARIES += msvcr71.dll
MSVCRNN_DLL = msvcr71.dll
MSVCPNN_DLL = msvcp71.dll
MS_RUNTIME_LIBRARIES += $(MSVCRNN_DLL)
endif
ifeq ($(COMPILER_VERSION), VS2005)
MSVCRNN_DLL = msvcr80.dll
MSVCPNN_DLL = msvcp80.dll
MS_RUNTIME_LIBRARIES += $(MSVCRNN_DLL)
endif
ifeq ($(COMPILER_VERSION), VS2008)
MSVCRNN_DLL = msvcr90.dll
MSVCPNN_DLL = msvcp90.dll
MS_RUNTIME_LIBRARIES += $(MSVCRNN_DLL)
endif
endif
@ -148,6 +161,20 @@ ifeq ($(CC_VERSION),msvc)
CC_LOWER_OPT = -O1
endif
endif
ifeq ($(COMPILER_VERSION), VS2008)
# Automatic precompiled header option to use (if COMPILE_APPROACH=batch)
AUTOMATIC_PCH_OPTION =
GX_OPTION = -EHsc
ifeq ($(ARCH_DATA_MODEL), 32)
CC_HIGHEST_OPT = -O2
CC_HIGHER_OPT = -O1
CC_LOWER_OPT = -O1
else
CC_HIGHEST_OPT = -O2
CC_HIGHER_OPT = -O1
CC_LOWER_OPT = -O1
endif
endif
CC_NO_OPT = -Od
else # CC_VERSION
# GCC not supported, but left for historical reference...
@ -179,7 +206,7 @@ endif
# -MTd Use static debug version (better than -MDd, no runtime issues)
# -D_DEBUG Change use of malloc/free/etc to use special debug ones (-MTd)
#
# NOTE: We also will use /D _STATIC_CPPLIB so we don't need msvcp71.dll
# NOTE: We also will use /D _STATIC_CPPLIB so we don't need msvcpnn.dll
#
ifeq ($(MS_RUNTIME_STATIC),true)
MS_RUNTIME_OPTION=-MT
@ -217,7 +244,7 @@ ifeq ($(CC_VERSION),msvc)
# -YX -Fp/.../foobar.pch Use precompiled headers (try someday?)
# -nologo Don't print out startup message
# /D _STATIC_CPPLIB
# Use static link for the C++ runtime (so msvcp71.dll not needed)
# Use static link for the C++ runtime (so msvcpnn.dll not needed)
#
CFLAGS_COMMON += -Zi -nologo
CFLAGS_OPT = $(POPT)

View File

@ -47,24 +47,17 @@ ifeq ($(PLATFORM), windows)
# unset any GNU Make settings of MFLAGS and MAKEFLAGS which may mess up nmake
NMAKE = MFLAGS= MAKEFLAGS= $(COMPILER_PATH)nmake -nologo
# Compiler version and type (Always get word after "Version")
CC_VER := $(shell $(CC) 2>&1 | $(HEAD) -n 1 | $(SED) 's/.*\(Version.*\)/\1/' | $(NAWK) '{print $$2}')
# SDK-64 and MSVC6 put REBASE.EXE in a different places - go figure...
ifeq ($(ARCH_DATA_MODEL), 32)
CC_VER := $(shell $(CC) 2>&1 | $(HEAD) -n 1 | $(NAWK) '{print $$8}')
LINK_VER := $(shell $(LINK) | $(HEAD) -n 1 | $(NAWK) '{print $$6}')
CC_TYPE := $(shell $(CC) 2>&1 | $(HEAD) -n 1 | $(NAWK) '{print $$5}')
CC_MAJORVER :=$(call MajorVersion,$(CC_VER))
REQUIRED_CCTYPE = Optimizing
REQUIRED_CC_VER = 13.10.3077
REQUIRED_LINK_VER = 7.10.3077
ifeq ($(CC_MAJORVER), 12)
# This should be: CC_VER=12.00.8168 LINK_VER=6.00.8447
COMPILER_NAME=Visual C++ 6.0 Professional + VC6-SP 3
COMPILER_VERSION=VC6
REBASE = $(COMPILER_PATH)rebase
MTL = $(COMPILER_PATH)midl
endif
ifeq ($(CC_MAJORVER), 13)
# 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_VERSION=VS2003
REBASE = $(COMPILER_PATH)../../Common7/Tools/Bin/rebase
@ -74,9 +67,10 @@ ifeq ($(PLATFORM), windows)
endif
endif
ifeq ($(CC_MAJORVER), 14)
# This should be: CC_VER=14.00.0000 LINK_VER=8.00.0000
# NOTE: This compiler has not been tried yet on 32bit systems
COMPILER_NAME=Visual Studio .NET 2005
# 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_VERSION=VS2005
REBASE = $(COMPILER_PATH)../../Common8/Tools/Bin/rebase
MTL = $(COMPILER_PATH)../../Common8/Tools/Bin/midl
@ -84,10 +78,22 @@ ifeq ($(PLATFORM), windows)
COMPILER_PATH := $(error COMPILER_PATH cannot be empty here)
endif
endif
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_VERSION=VS2008
#rebase and midl moved out of Visual Studio into the SDK:
REBASE = $(MSDEVTOOLS_PATH)/rebase
MTL = $(MSDEVTOOLS_PATH)/midl.exe
ifndef COMPILER_PATH
COMPILER_PATH := $(error COMPILER_PATH cannot be empty here)
endif
endif
else
CC_VER := $(shell $(CC) 2>&1 | $(HEAD) -n 1 | $(NAWK) '{print $$7}')
# else ARCH_DATA_MODEL is 64
LINK_VER := $(shell $(LINK) | $(HEAD) -n 1 | $(NAWK) '{print $$6}')
CC_TYPE := $(shell $(CC) 2>&1 | $(HEAD) -n 1 | $(NAWK) '{print $$4}')
CC_MAJORVER :=$(call MajorVersion,$(CC_VER))
CC_MINORVER :=$(call MinorVersion,$(CC_VER))
CC_MICROVER :=$(call MicroVersion,$(CC_VER))

View File

@ -11,3 +11,4 @@ b727c32788a906c04839516ae7443a085185a300 jdk7-b32
5251a9cd8eb8743eee647365bee1c8afdc131556 jdk7-b34
5fa96a5a7e76da7c8dad12486293a0456c2c116c jdk7-b35
e91159f921a58af3698e6479ea1fc5818da66d09 jdk7-b36
9ee9cf798b59e7d51f8c0a686959f313867a55d6 jdk7-b37

View File

@ -11,3 +11,4 @@ b996318955c0ad8e9fa0ffb56c74f626786e863f jdk7-b28
01facdf8cabdeaaf68cca037aef56cc5f074897f jdk7-b34
eac46d1eb7f0935ba04f1c7929ec15423fd0309e jdk7-b35
c84ca638db42a8b6b227b4e3b63bca192c5ca634 jdk7-b36
af49591bc486d82aa04b832257de0d18adc9af52 jdk7-b37

View File

@ -11,3 +11,4 @@ e6daca2eced9d84b01255cabcfcc49164c26405e jdk7-b32
7a9f629cd957e3169a1a769f763fe060d078785c jdk7-b34
b0f01c2508b690dd225298edfec70b5e8b8dc367 jdk7-b35
f60187f44a0d62906a5e2f6bd0989b5b24c1ca1e jdk7-b36
a2a6f9edf761934faf59ea60d7fe7178371302cd jdk7-b37

View File

@ -11,3 +11,4 @@ fa4c0a6cdd25d97d4e6f5d7aa180bcbb0e0d56af jdk7-b33
434055a0716ee44bca712ebca02fc04b20e6e288 jdk7-b34
cf4894b78ceb966326e93bf221db0c2d14d59218 jdk7-b35
134fd1a656ea85acd1f97f6700f75029b9b472a0 jdk7-b36
14f50aee4989b75934d385c56a83da0c23d2f68b jdk7-b37

View File

@ -41,7 +41,7 @@ endif
# Omit mirror since it's built with the apt tool.
SUBDIRS = $(SCRIPT_SUBDIR) image security crypto/provider jndi jmx \
java inputmethods org xml rowset net/httpserver net/ssl demo \
tools jarsigner tracing
tools jarsigner tracing servicetag
all build clean clobber::
$(SUBDIRS-loop)

View File

@ -0,0 +1,80 @@
# Copyright 2008 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.
BUILDDIR = ../../..
PACKAGE = com.sun.servicetag
PRODUCT = sun
include $(BUILDDIR)/common/Defs.gmk
#
# Files to compile
#
AUTO_FILES_JAVA_DIRS = com/sun/servicetag
#
# Rules
#
include $(BUILDDIR)/common/Classes.gmk
SERVICETAG_LIBDIR = $(LIBDIR)/servicetag
SERVICETAG_RESOURCES_DIR = $(CLASSDESTDIR)/com/sun/servicetag/resources
FILES_copy = $(SERVICETAG_RESOURCES_DIR)/product_registration.xsd \
$(SERVICETAG_RESOURCES_DIR)/register.html \
$(SERVICETAG_RESOURCES_DIR)/register_ja.html \
$(SERVICETAG_RESOURCES_DIR)/register_zh_CN.html \
$(SERVICETAG_LIBDIR)/jdk_header.png
# Add all properties files to the FILES_copy list
SWORDFISH_properties := $(shell \
$(CD) $(SHARE_SRC)/classes/com/sun/servicetag/resources; \
$(FIND) . -name 'javase_*_swordfish.properties' -print ; \
)
FILES_copy += $(shell \
for f in $(SWORDFISH_properties) ; do \
echo $(SERVICETAG_RESOURCES_DIR)/$$f ; \
done \
)
#
#OTHER_JAVACFLAGS += -Xlint:unchecked
build: install-servicetag-lib copy-files
copy-files: $(FILES_copy)
$(CLASSBINDIR)/%: $(SHARE_SRC)/classes/%
$(install-file)
$(SERVICETAG_LIBDIR)/jdk_header.png: $(SHARE_SRC)/classes/com/sun/servicetag/resources/jdk_header.png
$(install-file)
$(CHMOD) 444 $@
install-servicetag-lib:
@$(RM) -rf $(SERVICETAG_LIBDIR)
$(MKDIR) $(SERVICETAG_LIBDIR)
clean clobber::
@$(RM) $(FILES_copy)
.PHONY: copy-files

View File

@ -209,6 +209,7 @@ JAVA_JAVA_java = \
sun/util/TimeZoneNameUtility.java \
sun/util/calendar/ZoneInfo.java \
sun/util/calendar/ZoneInfoFile.java \
sun/util/calendar/TzIDOldMapping.java \
java/util/TooManyListenersException.java \
java/util/Comparator.java \
java/util/Collections.java \

View File

@ -33,7 +33,7 @@ include $(BUILDDIR)/common/Defs.gmk
# Files
#
include FILES.gmk
AUTO_FILES_JAVA_DIRS = javax/swing sun/swing
AUTO_FILES_JAVA_DIRS = javax/swing sun/swing com/sun/java/swing
AUTO_JAVA_PRUNE = plaf
SUBDIRS = html32dtd plaf

View File

@ -21,4 +21,4 @@
# CA 95054 USA or visit www.sun.com if you need additional information or
# have any questions.
#
tzdata2007h
tzdata2008e

View File

@ -409,9 +409,63 @@ Zone Africa/Nouakchott -1:03:48 - LMT 1912
0:00 - GMT
# Mauritius
# From Steffen Thorsen (2008-06-25):
# Mauritius plans to observe DST from 2008-11-01 to 2009-03-31 on a trial
# basis....
# It seems that Mauritius observed daylight saving time from 1982-10-10 to
# 1983-03-20 as well, but that was not successful....
# http://www.timeanddate.com/news/time/mauritius-daylight-saving-time.html
# From Alex Krivenyshev (2008-06-25):
# http://economicdevelopment.gov.mu/portal/site/Mainhomepage/menuitem.a42b24128104d9845dabddd154508a0c/?content_id=0a7cee8b5d69a110VgnVCM1000000a04a8c0RCRD
# From Arthur David Olson (2008-06-30):
# The www.timeanddate.com article cited by Steffen Thorsen notes that "A
# final decision has yet to be made on the times that daylight saving
# would begin and end on these dates." As a place holder, use midnight.
# From Paul Eggert (2008-06-30):
# Follow Thorsen on DST in 1982/1983, instead of Shanks & Pottenger.
# From Steffen Thorsen (2008-07-10):
# According to
# <a href="http://www.lexpress.mu/display_article.php?news_id=111216">
# http://www.lexpress.mu/display_article.php?news_id=111216
# </a>
# (in French), Mauritius will start and end their DST a few days earlier
# than previously announced (2008-11-01 to 2009-03-31). The new start
# date is 2008-10-26 at 02:00 and the new end date is 2009-03-27 (no time
# given, but it is probably at either 2 or 3 wall clock time).
#
# A little strange though, since the article says that they moved the date
# to align itself with Europe and USA which also change time on that date,
# but that means they have not paid attention to what happened in
# USA/Canada last year (DST ends first Sunday in November). I also wonder
# why that they end on a Friday, instead of aligning with Europe which
# changes two days later.
# From Alex Krivenyshev (2008-07-11):
# Seems that English language article "The revival of daylight saving
# time: Energy conservation?"-# No. 16578 (07/11/2008) was originally
# published on Monday, June 30, 2008...
#
# I guess that article in French "Le gouvernement avance l'introduction
# de l'heure d'ete" stating that DST in Mauritius starting on October 26
# and ending on March 27, 2009 is the most recent one.
# ...
# <a href="http://www.worldtimezone.com/dst_news/dst_news_mauritius02.html">
# http://www.worldtimezone.com/dst_news/dst_news_mauritius02.html
# </a>
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Mauritius 1982 only - Oct 10 0:00 1:00 S
Rule Mauritius 1983 only - Mar 21 0:00 0 -
Rule Mauritius 2008 only - Oct 26 2:00s 1:00 S
Rule Mauritius 2009 only - Mar 27 2:00s 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Indian/Mauritius 3:50:00 - LMT 1907 # Port Louis
4:00 - MUT # Mauritius Time
4:00 Mauritius MU%sT # Mauritius Time
# Agalega Is, Rodriguez
# no information; probably like Indian/Mauritius
@ -422,6 +476,77 @@ Zone Indian/Mayotte 3:00:56 - LMT 1911 Jul # Mamoutzou
# Morocco
# See the `europe' file for Spanish Morocco (Africa/Ceuta).
# From Alex Krivenyshev (2008-05-09):
# Here is an article that Morocco plan to introduce Daylight Saving Time between
# 1 June, 2008 and 27 September, 2008.
#
# "... Morocco is to save energy by adjusting its clock during summer so it will
# be one hour ahead of GMT between 1 June and 27 September, according to
# Communication Minister and Gov ernment Spokesman, Khalid Naciri...."
#
# <a href="http://www.worldtimezone.net/dst_news/dst_news_morocco01.html">
# http://www.worldtimezone.net/dst_news/dst_news_morocco01.html
# </a>
# OR
# <a href="http://en.afrik.com/news11892.html">
# http://en.afrik.com/news11892.html
# </a>
# From Alex Krivenyshev (2008-05-09):
# The Morocco time change can be confirmed on Morocco web site Maghreb Arabe Presse:
# <a href="http://www.map.ma/eng/sections/box3/morocco_shifts_to_da/view">
# http://www.map.ma/eng/sections/box3/morocco_shifts_to_da/view
# </a>
#
# Morocco shifts to daylight time on June 1st through September 27, Govt.
# spokesman.
# From Patrice Scattolin (2008-05-09):
# According to this article:
# <a href="http://www.avmaroc.com/actualite/heure-dete-comment-a127896.html">
# http://www.avmaroc.com/actualite/heure-dete-comment-a127896.html
# </a>
# (and republished here:
# <a href="http://www.actu.ma/heure-dete-comment_i127896_0.html">
# http://www.actu.ma/heure-dete-comment_i127896_0.html
# </a>
# )
# the changes occurs at midnight:
#
# saturday night may 31st at midnight (which in french is to be
# intrepreted as the night between saturday and sunday)
# sunday night the 28th at midnight
#
# Seeing that the 28th is monday, I am guessing that she intends to say
# the midnight of the 28th which is the midnight between sunday and
# monday, which jives with other sources that say that it's inclusive
# june1st to sept 27th.
#
# The decision was taken by decree *2-08-224 *but I can't find the decree
# published on the web.
#
# It's also confirmed here:
# <a href="http://www.maroc.ma/NR/exeres/FACF141F-D910-44B0-B7FA-6E03733425D1.htm">
# http://www.maroc.ma/NR/exeres/FACF141F-D910-44B0-B7FA-6E03733425D1.htm
# </a>
# on a government portal as being between june 1st and sept 27th (not yet
# posted in english).
#
# The following google query will generate many relevant hits:
# <a href="http://www.google.com/search?hl=en&q=Conseil+de+gouvernement+maroc+heure+avance&btnG=Search">
# http://www.google.com/search?hl=en&q=Conseil+de+gouvernement+maroc+heure+avance&btnG=Search
# </a>
# From Alex Krivenyshev (2008-05-09):
# Is Western Sahara (part which administrated by Morocco) going to follow
# Morocco DST changes? Any information? What about other part of
# Western Sahara - under administration of POLISARIO Front (also named
# SADR Saharawi Arab Democratic Republic)?
# From Arthur David Olson (2008-05-09):
# XXX--guess that it is only Morocco for now; guess only 2008 for now.
# RULE NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Morocco 1939 only - Sep 12 0:00 1:00 S
Rule Morocco 1939 only - Nov 19 0:00 0 -
@ -438,11 +563,13 @@ Rule Morocco 1976 only - Aug 1 0:00 0 -
Rule Morocco 1977 only - Sep 28 0:00 0 -
Rule Morocco 1978 only - Jun 1 0:00 1:00 S
Rule Morocco 1978 only - Aug 4 0:00 0 -
Rule Morocco 2008 only - Jun 1 0:00 1:00 S
Rule Morocco 2008 only - Sep 28 0:00 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Africa/Casablanca -0:30:20 - LMT 1913 Oct 26
0:00 Morocco WE%sT 1984 Mar 16
1:00 - CET 1986
0:00 - WET
0:00 Morocco WE%sT
# Western Sahara
Zone Africa/El_Aaiun -0:52:48 - LMT 1934 Jan
-1:00 - WAT 1976 Apr 14

View File

@ -251,6 +251,28 @@ Rule PRC 1987 1991 - Apr Sun>=10 0:00 1:00 D
# (could be true), for the moment I am assuming that those two
# counties are mistakes in the astro.com data.
# From Paul Eggert (2008-02-11):
# I just now checked Google News for western news sources that talk
# about China's single time zone, and couldn't find anything before 1986
# talking about China being in one time zone. (That article was: Jim
# Mann, "A clumsy embrace for another western custom: China on daylight
# time--sort of", Los Angeles Times, 1986-05-05. By the way, this
# article confirms the tz database's data claiming that China began
# observing daylight saving time in 1986.
#
# From Thomas S. Mullaney (2008-02-11):
# I think you're combining two subjects that need to treated
# separately: daylight savings (which, you're correct, wasn't
# implemented until the 1980s) and the unified time zone centered near
# Beijing (which was implemented in 1949). Briefly, there was also a
# "Lhasa Time" in Tibet and "Urumqi Time" in Xinjiang. The first was
# ceased, and the second eventually recognized (again, in the 1980s).
#
# From Paul Eggert (2008-06-30):
# There seems to be a good chance China switched to a single time zone in 1949
# rather than in 1980 as Shanks & Pottenger have it, but we don't have a
# reliable documentary source saying so yet, so for now we still go with
# Shanks & Pottenger.
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
# Changbai Time ("Long-white Time", Long-white = Heilongjiang area)
@ -468,13 +490,13 @@ Zone Asia/Dili 8:22:20 - LMT 1912
# India
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Asia/Calcutta 5:53:28 - LMT 1880 # Kolkata
Zone Asia/Kolkata 5:53:28 - LMT 1880 # Kolkata
5:53:20 - HMT 1941 Oct # Howrah Mean Time?
6:30 - BURT 1942 May 15 # Burma Time
5:30 - IST 1942 Sep
5:30 1:00 IST 1945 Oct 15
5:30 - IST
# The following are like Asia/Calcutta:
# The following are like Asia/Kolkata:
# Andaman Is
# Lakshadweep (Laccadive, Minicoy and Amindivi Is)
# Nicobar Is
@ -599,6 +621,15 @@ Zone Asia/Jayapura 9:22:48 - LMT 1932 Nov
# daylight saving time ...
# http://uk.reuters.com/article/oilRpt/idUKBLA65048420070916
#
# From Roozbeh Pournader (2007-11-05):
# This is quoted from Official Gazette of the Islamic Republic of
# Iran, Volume 63, Number 18242, dated Tuesday 1386/6/24
# [2007-10-16]. I am doing the best translation I can:...
# The official time of the country will be moved forward for one hour
# on the 24 hours of the first day of the month of Farvardin and will
# be changed back to its previous state on the 24 hours of the
# thirtieth day of Shahrivar.
#
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Iran 1978 1980 - Mar 21 0:00 1:00 D
Rule Iran 1978 only - Oct 21 0:00 0 S
@ -673,6 +704,21 @@ Zone Asia/Tehran 3:25:44 - LMT 1916
#
# So we'll ignore the Economist's claim.
# From Steffen Thorsen (2008-03-10):
# The cabinet in Iraq abolished DST last week, according to the following
# news sources (in Arabic):
# <a href="http://www.aljeeran.net/wesima_articles/news-20080305-98602.html">
# http://www.aljeeran.net/wesima_articles/news-20080305-98602.html
# </a>
# <a href="http://www.aswataliraq.info/look/article.tpl?id=2047&IdLanguage=17&IdPublication=4&NrArticle=71743&NrIssue=1&NrSection=10">
# http://www.aswataliraq.info/look/article.tpl?id=2047&IdLanguage=17&IdPublication=4&NrArticle=71743&NrIssue=1&NrSection=10
# </a>
#
# We have published a short article in English about the change:
# <a href="http://www.timeanddate.com/news/time/iraq-dumps-daylight-saving.html">
# http://www.timeanddate.com/news/time/iraq-dumps-daylight-saving.html
# </a>
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Iraq 1982 only - May 1 0:00 1:00 D
Rule Iraq 1982 1984 - Oct 1 0:00 0 S
@ -683,8 +729,8 @@ Rule Iraq 1986 1990 - Mar lastSun 1:00s 1:00 D
# IATA SSIM (1991/1996) says Apr 1 12:01am UTC; guess the `:01' is a typo.
# Shanks & Pottenger say Iraq did not observe DST 1992/1997; ignore this.
#
Rule Iraq 1991 max - Apr 1 3:00s 1:00 D
Rule Iraq 1991 max - Oct 1 3:00s 0 S
Rule Iraq 1991 2007 - Apr 1 3:00s 1:00 D
Rule Iraq 1991 2007 - Oct 1 3:00s 0 S
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Asia/Baghdad 2:57:40 - LMT 1890
2:57:36 - BMT 1918 # Baghdad Mean Time?
@ -1374,6 +1420,42 @@ Zone Indian/Maldives 4:54:00 - LMT 1880 # Male
# They decided not to adopt daylight-saving time....
# http://www.mongolnews.mn/index.php?module=unuudur&sec=view&id=15742
# From Deborah Goldsmith (2008-03-30):
# We received a bug report claiming that the tz database UTC offset for
# Asia/Choibalsan (GMT+09:00) is incorrect, and that it should be GMT
# +08:00 instead. Different sources appear to disagree with the tz
# database on this, e.g.:
#
# <a href="http://www.timeanddate.com/worldclock/city.html?n=1026">
# http://www.timeanddate.com/worldclock/city.html?n=1026
# </a>
# <a href="http://www.worldtimeserver.com/current_time_in_MN.aspx">
# http://www.worldtimeserver.com/current_time_in_MN.aspx
# </a>
#
# both say GMT+08:00.
# From Steffen Thorsen (2008-03-31):
# eznis airways, which operates several domestic flights, has a flight
# schedule here:
# <a href="http://www.eznis.com/Container.jsp?id=112">
# http://www.eznis.com/Container.jsp?id=112
# </a>
# (click the English flag for English)
#
# There it appears that flights between Choibalsan and Ulaanbatar arrive
# about 1:35 - 1:50 hours later in local clock time, no matter the
# direction, while Ulaanbaatar-Khvod takes 2 hours in the Eastern
# direction and 3:35 back, which indicates that Ulaanbatar and Khvod are
# in different time zones (like we know about), while Choibalsan and
# Ulaanbatar are in the same time zone (correction needed).
# From Arthur David Olson (2008-05-19):
# Assume that Choibalsan is indeed offset by 8:00.
# XXX--in the absence of better information, assume that transition
# was at the start of 2008-03-31 (the day of Steffen Thorsen's report);
# this is almost surely wrong.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Mongol 1983 1984 - Apr 1 0:00 1:00 S
Rule Mongol 1983 only - Oct 1 0:00 0 -
@ -1409,7 +1491,8 @@ Zone Asia/Ulaanbaatar 7:07:32 - LMT 1905 Aug
Zone Asia/Choibalsan 7:38:00 - LMT 1905 Aug
7:00 - ULAT 1978
8:00 - ULAT 1983 Apr
9:00 Mongol CHO%sT # Choibalsan Time
9:00 Mongol CHO%sT 2008 Mar 31 # Choibalsan Time
8:00 Mongol CHO%sT
# Nepal
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
@ -1459,10 +1542,32 @@ Zone Asia/Muscat 3:54:20 - LMT 1920
# The minister told a news conference that the experiment had rather
# shown 8 per cent higher consumption of electricity.
# From Alex Krivenyshev (2008-05-15):
#
# Here is an article that Pakistan plan to introduce Daylight Saving Time
# on June 1, 2008 for 3 months.
#
# "... The federal cabinet on Wednesday announced a new conservation plan to help
# reduce load shedding by approving the closure of commercial centres at 9pm and
# moving clocks forward by one hour for the next three months.
# ...."
#
# <a href="http://www.worldtimezone.net/dst_news/dst_news_pakistan01.html">
# http://www.worldtimezone.net/dst_news/dst_news_pakistan01.html
# </a>
# OR
# <a href="http://www.dailytimes.com.pk/default.asp?page=2008%5C05%5C15%5Cstory_15-5-2008_pg1_4">
# http://www.dailytimes.com.pk/default.asp?page=2008%5C05%5C15%5Cstory_15-5-2008_pg1_4
# </a>
# From Arthur David Olson (2008-05-19):
# XXX--midnight transitions is a guess; 2008 only is a guess.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Pakistan 2002 only - Apr Sun>=2 0:01 1:00 S
Rule Pakistan 2002 only - Oct Sun>=2 0:01 0 -
Rule Pakistan 2008 only - Jun 1 0:00 1:00 S
Rule Pakistan 2008 only - Sep 1 0:00 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Asia/Karachi 4:28:12 - LMT 1907
5:30 - IST 1942 Sep
@ -1700,7 +1805,7 @@ Zone Asia/Singapore 6:55:25 - LMT 1901 Jan 1
# kept their clocks set five and a half hours ahead of Greenwich Mean
# Time (GMT), in line with neighbor India.
# From Paul Eggert (2006-04-18):
# People who live in regions under Tamil control can use TZ='Asia/Calcutta',
# People who live in regions under Tamil control can use [TZ='Asia/Kolkata'],
# as that zone has agreed with the Tamil areas since our cutoff date of 1970.
# From K Sethu (2006-04-25):
@ -1790,10 +1895,62 @@ Rule Syria 2006 only - Sep 22 0:00 0 -
# From Paul Eggert (2007-03-29):
# Today the AP reported "Syria will switch to summertime at midnight Thursday."
# http://www.iht.com/articles/ap/2007/03/29/africa/ME-GEN-Syria-Time-Change.php
# For lack of better info, assume the rule changed to "last Friday in March"
# this year.
Rule Syria 2007 max - Mar lastFri 0:00 1:00 S
Rule Syria 2007 max - Oct 1 0:00 0 -
Rule Syria 2007 only - Mar lastFri 0:00 1:00 S
# From Jesper Norgard (2007-10-27):
# The sister center ICARDA of my work CIMMYT is confirming that Syria DST will
# not take place 1.st November at 0:00 o'clock but 1.st November at 24:00 or
# rather Midnight between Thursday and Friday. This does make more sence than
# having it between Wednesday and Thursday (two workdays in Syria) since the
# weekend in Syria is not Saturday and Sunday, but Friday and Saturday. So now
# it is implemented at midnight of the last workday before weekend...
#
# From Steffen Thorsen (2007-10-27):
# Jesper Norgaard Welen wrote:
#
# > "Winter local time in Syria will be observed at midnight of Thursday 1
# > November 2007, and the clock will be put back 1 hour."
#
# I found confirmation on this in this gov.sy-article (Arabic):
# http://wehda.alwehda.gov.sy/_print_veiw.asp?FileName=12521710520070926111247
#
# which using Google's translate tools says:
# Council of Ministers also approved the commencement of work on
# identifying the winter time as of Friday, 2/11/2007 where the 60th
# minute delay at midnight Thursday 1/11/2007.
Rule Syria 2007 only - Nov Fri>=1 0:00 0 -
# From Stephen Colebourne (2008-03-17):
# For everyone's info, I saw an IATA time zone change for [Syria] for
# this month (March 2008) in the last day or so...This is the data IATA
# are now using:
# Country Time Standard --- DST Start --- --- DST End --- DST
# Name Zone Variation Time Date Time Date
# Variation
# Syrian Arab
# Republic SY +0200 2200 03APR08 2100 30SEP08 +0300
# 2200 02APR09 2100 30SEP09 +0300
# 2200 01APR10 2100 30SEP10 +0300
# From Arthur David Olson (2008-03-17):
# Here's a link to English-language coverage by the Syrian Arab News
# Agency (SANA)...
# <a href="http://www.sana.sy/eng/21/2008/03/11/165173.htm">
# http://www.sana.sy/eng/21/2008/03/11/165173.htm
# </a>...which reads (in part) "The Cabinet approved the suggestion of the
# Ministry of Electricity to begin daylight savings time on Friday April
# 4th, advancing clocks one hour ahead on midnight of Thursday April 3rd."
# Since Syria is two hours east of UTC, the 2200 and 2100 transition times
# shown above match up with midnight in Syria.
# From Arthur David Olson (2008-03-18):
# My buest guess at a Syrian rule is "the Friday nearest April 1";
# coding that involves either using a "Mar Fri>=29" construct that old time zone
# compilers can't handle or having multiple Rules (a la Israel).
# For now, use "Apr Fri>=1", and go with IATA on a uniform Sep 30 end.
Rule Syria 2008 max - Apr Fri>=1 0:00 1:00 S
Rule Syria 2008 max - Oct 1 0:00 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Asia/Damascus 2:25:12 - LMT 1920 # Dimashq
2:00 Syria EE%sT
@ -1847,13 +2004,13 @@ Zone Asia/Tashkent 4:37:12 - LMT 1924 May 2
# Vietnam
# From Paul Eggert (1993-11-18):
# Saigon's official name is Thanh-Pho Ho Chi Minh, but it's too long.
# We'll stick with the traditional name for now.
# From Arthur David Olson (2008-03-18):
# The English-language name of Vietnam's most populous city is "Ho Chi Min City";
# we use Ho_Chi_Minh below to avoid a name of more than 14 characters.
# From Shanks & Pottenger:
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Asia/Saigon 7:06:40 - LMT 1906 Jun 9
Zone Asia/Ho_Chi_Minh 7:06:40 - LMT 1906 Jun 9
7:06:20 - SMT 1911 Mar 11 0:01 # Saigon MT?
7:00 - ICT 1912 May
8:00 - ICT 1931 May

View File

@ -1368,7 +1368,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901
# * Tonga will introduce DST in November
#
# I was given this link by John Letts:
# <a hef="http://news.bbc.co.uk/hi/english/world/asia-pacific/newsid_424000/424764.stm">
# <a href="http://news.bbc.co.uk/hi/english/world/asia-pacific/newsid_424000/424764.stm">
# http://news.bbc.co.uk/hi/english/world/asia-pacific/newsid_424000/424764.stm
# </a>
#
@ -1378,7 +1378,7 @@ Zone Pacific/Wallis 12:15:20 - LMT 1901
# (12 + 1 hour DST).
# From Arthur David Olson (1999-09-20):
# According to <a href="http://www.tongaonline.com/news/sept1799.html>
# According to <a href="http://www.tongaonline.com/news/sept1799.html">
# http://www.tongaonline.com/news/sept1799.html
# </a>:
# "Daylight Savings Time will take effect on Oct. 2 through April 15, 2000

View File

@ -46,12 +46,15 @@ Link America/St_Thomas America/Virgin
Link Asia/Ashgabat Asia/Ashkhabad
Link Asia/Chongqing Asia/Chungking
Link Asia/Dhaka Asia/Dacca
Link Asia/Kolkata Asia/Calcutta
Link Asia/Macau Asia/Macao
Link Asia/Jerusalem Asia/Tel_Aviv
Link Asia/Ho_Chi_Minh Asia/Saigon
Link Asia/Thimphu Asia/Thimbu
Link Asia/Makassar Asia/Ujung_Pandang
Link Asia/Ulaanbaatar Asia/Ulan_Bator
Link Atlantic/Faroe Atlantic/Faeroe
Link Europe/Oslo Atlantic/Jan_Mayen
Link Australia/Sydney Australia/ACT
Link Australia/Sydney Australia/Canberra
Link Australia/Lord_Howe Australia/LHI

View File

@ -479,7 +479,7 @@ Rule EU 1979 1995 - Sep lastSun 1:00u 0 -
Rule EU 1981 max - Mar lastSun 1:00u 1:00 S
Rule EU 1996 max - Oct lastSun 1:00u 0 -
# The most recent directive covers the years starting in 2002. See:
# <a href="http://europa.eu.int/eur-lex/en/lif/dat/2000/en_300L0084.html"
# <a href="http://europa.eu.int/eur-lex/en/lif/dat/2000/en_300L0084.html">
# Directive 2000/84/EC of the European Parliament and of the Council
# of 19 January 2001 on summer-time arrangements.
# </a>
@ -502,9 +502,48 @@ Rule C-Eur 1940 only - Apr 1 2:00s 1:00 S
Rule C-Eur 1942 only - Nov 2 2:00s 0 -
Rule C-Eur 1943 only - Mar 29 2:00s 1:00 S
Rule C-Eur 1943 only - Oct 4 2:00s 0 -
Rule C-Eur 1944 only - Apr 3 2:00s 1:00 S
Rule C-Eur 1944 1945 - Apr Mon>=1 2:00s 1:00 S
# Whitman gives 1944 Oct 7; go with Shanks & Pottenger.
Rule C-Eur 1944 only - Oct 2 2:00s 0 -
# From Jesper Norgaard Welen (2008-07-13):
#
# I found what is probably a typo of 2:00 which should perhaps be 2:00s
# in the C-Eur rule from tz database version 2008d (this part was
# corrected in version 2008d). The circumstancial evidence is simply the
# tz database itself, as seen below:
#
# Zone Europe/Paris 0:09:21 - LMT 1891 Mar 15 0:01
# 0:00 France WE%sT 1945 Sep 16 3:00
#
# Zone Europe/Monaco 0:29:32 - LMT 1891 Mar 15
# 0:00 France WE%sT 1945 Sep 16 3:00
#
# Zone Europe/Belgrade 1:22:00 - LMT 1884
# 1:00 1:00 CEST 1945 Sep 16 2:00s
#
# Rule France 1945 only - Sep 16 3:00 0 -
# Rule Belgium 1945 only - Sep 16 2:00s 0 -
# Rule Neth 1945 only - Sep 16 2:00s 0 -
#
# The rule line to be changed is:
#
# Rule C-Eur 1945 only - Sep 16 2:00 0 -
#
# It seems that Paris, Monaco, Rule France, Rule Belgium all agree on
# 2:00 standard time, e.g. 3:00 local time. However there are no
# countries that use C-Eur rules in September 1945, so the only items
# affected are apparently these ficticious zones that translates acronyms
# CET and MET:
#
# Zone CET 1:00 C-Eur CE%sT
# Zone MET 1:00 C-Eur ME%sT
#
# It this is right then the corrected version would look like:
#
# Rule C-Eur 1945 only - Sep 16 2:00s 0 -
#
# A small step for mankind though 8-)
Rule C-Eur 1945 only - Sep 16 2:00s 0 -
Rule C-Eur 1977 1980 - Apr Sun>=1 2:00s 1:00 S
Rule C-Eur 1977 only - Sep lastSun 2:00s 0 -
Rule C-Eur 1978 only - Oct 1 2:00s 0 -
@ -747,7 +786,8 @@ Rule Bulg 1981 only - Sep 27 2:00 0 -
Zone Europe/Sofia 1:33:16 - LMT 1880
1:56:56 - IMT 1894 Nov 30 # Istanbul MT?
2:00 - EET 1942 Nov 2 3:00
1:00 C-Eur CE%sT 1945 Apr 2 3:00
1:00 C-Eur CE%sT 1945
1:00 - CET 1945 Apr 2 3:00
2:00 - EET 1979 Mar 31 23:00
2:00 Bulg EE%sT 1982 Sep 26 2:00
2:00 C-Eur EE%sT 1991
@ -1115,33 +1155,40 @@ Zone Europe/Paris 0:09:21 - LMT 1891 Mar 15 0:01
# [See tz-link.htm for the URL.]
# From Joerg Schilling (2002-10-23):
# In 1945, Berlin was switched to Moscow Summer time (GMT+4) by <a
# href="http://www.dhm.de/lemo/html/biografien/BersarinNikolai/">
# In 1945, Berlin was switched to Moscow Summer time (GMT+4) by
# <a href="http://www.dhm.de/lemo/html/biografien/BersarinNikolai/">
# General [Nikolai] Bersarin</a>.
# From Paul Eggert (2003-03-08):
# <a href="http://www.parlament-berlin.de/pds-fraktion.nsf/727459127c8b66ee8525662300459099/defc77cb784f180ac1256c2b0030274b/$FILE/bersarint.pdf">
# http://www.parlament-berlin.de/pds-fraktion.nsf/727459127c8b66ee8525662300459099/defc77cb784f180ac1256c2b0030274b/$FILE/bersarint.pdf
# </a>
# says that Bersarin issued an order to use Moscow time on May 20.
# However, Moscow did not observe daylight saving in 1945, so
# this was equivalent to CEMT (GMT+3), not GMT+4.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Germany 1945 only - Apr 2 2:00s 1:00 S
Rule Germany 1945 only - May 24 2:00 2:00 M # Midsummer
Rule Germany 1945 only - Sep 24 3:00 1:00 S
Rule Germany 1945 only - Nov 18 2:00s 0 -
Rule Germany 1946 only - Apr 14 2:00s 1:00 S
Rule Germany 1946 only - Oct 7 2:00s 0 -
Rule Germany 1947 1949 - Oct Sun>=1 2:00s 0 -
Rule Germany 1947 only - Apr 6 2:00s 1:00 S
# http://www.ptb.de/de/org/4/44/441/salt.htm says the following transition
# occurred at 3:00 MEZ, not the 2:00 MEZ given in Shanks & Pottenger.
# Go with the PTB.
Rule Germany 1947 only - Apr 6 3:00s 1:00 S
Rule Germany 1947 only - May 11 2:00s 2:00 M
Rule Germany 1947 only - Jun 29 3:00 1:00 S
Rule Germany 1948 only - Apr 18 2:00s 1:00 S
Rule Germany 1949 only - Apr 10 2:00s 1:00 S
Rule SovietZone 1945 only - May 24 2:00 2:00 M # Midsummer
Rule SovietZone 1945 only - Sep 24 3:00 1:00 S
Rule SovietZone 1945 only - Nov 18 2:00s 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Europe/Berlin 0:53:28 - LMT 1893 Apr
1:00 C-Eur CE%sT 1945 Apr 2 2:00
1:00 C-Eur CE%sT 1945 May 24 2:00
1:00 SovietZone CE%sT 1946
1:00 Germany CE%sT 1980
1:00 EU CE%sT
@ -1218,7 +1265,7 @@ Rule Hungary 1980 only - Apr 6 1:00 1:00 S
Zone Europe/Budapest 1:16:20 - LMT 1890 Oct
1:00 C-Eur CE%sT 1918
1:00 Hungary CE%sT 1941 Apr 6 2:00
1:00 C-Eur CE%sT 1945 May 1 23:00
1:00 C-Eur CE%sT 1945
1:00 Hungary CE%sT 1980 Sep 28 2:00s
1:00 EU CE%sT
@ -1736,7 +1783,6 @@ Zone Europe/Oslo 0:43:00 - LMT 1895 Jan 1
# come up with more definitive info about the timekeeping during the
# war years it's probably best just do do the following for now:
Link Europe/Oslo Arctic/Longyearbyen
Link Europe/Oslo Atlantic/Jan_Mayen
# Poland
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
@ -2136,7 +2182,8 @@ Zone Asia/Anadyr 11:49:56 - LMT 1924 May 2
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Europe/Belgrade 1:22:00 - LMT 1884
1:00 - CET 1941 Apr 18 23:00
1:00 C-Eur CE%sT 1945 May 8 2:00s
1:00 C-Eur CE%sT 1945
1:00 - CET 1945 May 8 2:00s
1:00 1:00 CEST 1945 Sep 16 2:00s
# Metod Kozelj reports that the legal date of
# transition to EU rules was 1982-11-27, for all of Yugoslavia at the time.

View File

@ -28,7 +28,7 @@
#
# This file contains a table with the following columns:
# 1. ISO 3166-1 alpha-2 country code, current as of
# ISO 3166-1 Newsletter No. V-12 (2006-09-26). See:
# ISO 3166-1 Newsletter VI-1 (2007-09-21). See:
# <a href="http://www.iso.org/iso/en/prods-services/iso3166ma/index.html">
# ISO 3166 Maintenance agency (ISO 3166/MA)
# </a>.
@ -69,6 +69,7 @@ BG Bulgaria
BH Bahrain
BI Burundi
BJ Benin
BL St Barthelemy
BM Bermuda
BN Brunei
BO Bolivia
@ -181,6 +182,7 @@ MA Morocco
MC Monaco
MD Moldova
ME Montenegro
MF St Martin (French part)
MG Madagascar
MH Marshall Islands
MK Macedonia

View File

@ -66,8 +66,10 @@ Leap 1995 Dec 31 23:59:60 + S
Leap 1997 Jun 30 23:59:60 + S
Leap 1998 Dec 31 23:59:60 + S
Leap 2005 Dec 31 23:59:60 + S
Leap 2008 Dec 31 23:59:60 + S
# INTERNATIONAL EARTH ROTATION AND REFERENCE SYSTEMS SERVICE (IERS)
#
# SERVICE INTERNATIONAL DE LA ROTATION TERRESTRE ET DES SYSTEMES DE REFERENCE
#
# SERVICE DE LA ROTATION TERRESTRE
@ -75,30 +77,38 @@ Leap 2005 Dec 31 23:59:60 + S
# 61, Av. de l'Observatoire 75014 PARIS (France)
# Tel. : 33 (0) 1 40 51 22 26
# FAX : 33 (0) 1 40 51 22 91
# Internet : services.iers@obspm.fr
# e-mail : services.iers@obspm.fr
# http://hpiers.obspm.fr/eop-pc
#
# Paris, 28 June 2007
# Paris, 4 July 2008
#
# Bulletin C 34
# Bulletin C 36
#
# To authorities responsible
# for the measurement and
# distribution of time
#
# INFORMATION ON UTC - TAI
# UTC TIME STEP
# on the 1st of January 2009
#
# NO positive leap second will be introduced at the end of December 2007.
# The difference between Coordinated Universal Time UTC and the
# International Atomic Time TAI is :
# A positive leap second will be introduced at the end of December 2008.
# The sequence of dates of the UTC second markers will be:
#
# from 2006 January 1, 0h UTC, until further notice : UTC-TAI = -33 s
# 2008 December 31, 23h 59m 59s
# 2008 December 31, 23h 59m 60s
# 2009 January 1, 0h 0m 0s
#
# The difference between UTC and the International Atomic Time TAI is:
#
# from 2006 January 1, 0h UTC, to 2009 January 1 0h UTC : UTC-TAI = - 33s
# from 2009 January 1, 0h UTC, until further notice : UTC-TAI = - 34s
#
# Leap seconds can be introduced in UTC at the end of the months of December
# or June, depending on the evolution of UT1-TAI. Bulletin C is mailed every
# six months, either to announce a time step in UTC, or to confirm that there
# or June, depending on the evolution of UT1-TAI. Bulletin C is mailed every
# six months, either to announce a time step in UTC or to confirm that there
# will be no time step at the next possible date.
#
# Daniel GAMBIS
# Director
# Head
# Earth Orientation Center of IERS
# Observatoire de Paris, France

View File

@ -2098,8 +2098,8 @@ Zone America/Antigua -4:07:12 - LMT 1912 Mar 2
# http://www.jonesbahamas.com/?c=45&a=10412
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Bahamas 1964 2006 - Oct lastSun 2:00 0 S
Rule Bahamas 1964 1986 - Apr lastSun 2:00 1:00 D
Rule Bahamas 1964 1975 - Oct lastSun 2:00 0 S
Rule Bahamas 1964 1975 - Apr lastSun 2:00 1:00 D
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone America/Nassau -5:09:24 - LMT 1912 Mar 2
-5:00 Bahamas E%sT 1976
@ -2209,6 +2209,69 @@ Zone America/Costa_Rica -5:36:20 - LMT 1890 # San Jose
# says Cuban clocks will advance at midnight on March 10.
# For lack of better information, assume Cuba will use US rules,
# except that it switches at midnight standard time as usual.
#
# From Steffen Thorsen (2007-10-25):
# Carlos Alberto Fonseca Arauz informed me that Cuba will end DST one week
# earlier - on the last Sunday of October, just like in 2006.
#
# He supplied these references:
#
# http://www.prensalatina.com.mx/article.asp?ID=%7B4CC32C1B-A9F7-42FB-8A07-8631AFC923AF%7D&language=ES
# http://actualidad.terra.es/sociedad/articulo/cuba_llama_ahorrar_energia_cambio_1957044.htm
#
# From Alex Kryvenishev (2007-10-25):
# Here is also article from Granma (Cuba):
#
# [Regira] el Horario Normal desde el [proximo] domingo 28 de octubre
# http://www.granma.cubaweb.cu/2007/10/24/nacional/artic07.html
#
# http://www.worldtimezone.com/dst_news/dst_news_cuba03.html
# From Arthur David Olson (2008-03-09):
# I'm in Maryland which is now observing United States Eastern Daylight
# Time. At 9:44 local time I used RealPlayer to listen to
# <a href="http://media.enet.cu/radioreloj">
# http://media.enet.cu/radioreloj
# </a>, a Cuban information station, and heard
# the time announced as "ocho cuarenta y cuatro" ("eight forty-four"),
# indicating that Cuba is still on standard time.
# From Steffen Thorsen (2008-03-12):
# It seems that Cuba will start DST on Sunday, 2007-03-16...
# It was announced yesterday, according to this source (in Spanish):
# <a href="http://www.nnc.cubaweb.cu/marzo-2008/cien-1-11-3-08.htm">
# http://www.nnc.cubaweb.cu/marzo-2008/cien-1-11-3-08.htm
# </a>
#
# Some more background information is posted here:
# <a href="http://www.timeanddate.com/news/time/cuba-starts-dst-march-16.html">
# http://www.timeanddate.com/news/time/cuba-starts-dst-march-16.html
# </a>
#
# The article also says that Cuba has been observing DST since 1963,
# while Shanks (and tzdata) has 1965 as the first date (except in the
# 1940's). Many other web pages in Cuba also claim that it has been
# observed since 1963, but with the exception of 1970 - an exception
# which is not present in tzdata/Shanks. So there is a chance we need to
# change some historic records as well.
#
# One example:
# <a href="http://www.radiohc.cu/espanol/noticias/mar07/11mar/hor.htm">
# http://www.radiohc.cu/espanol/noticias/mar07/11mar/hor.htm
# </a>
# From Jesper Norgaard Welen (2008-03-13):
# The Cuban time change has just been confirmed on the most authoritative
# web site, the Granma. Please check out
# <a href="http://www.granma.cubaweb.cu/2008/03/13/nacional/artic10.html">
# http://www.granma.cubaweb.cu/2008/03/13/nacional/artic10.html
# </a>
#
# Basically as expected after Steffen Thorsens information, the change
# will take place midnight between Saturday and Sunday.
# From Arthur David Olson (2008-03-12):
# Assume Sun>=15 (third Sunday) going forward.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Cuba 1928 only - Jun 10 0:00 1:00 D
@ -2240,9 +2303,9 @@ Rule Cuba 1997 only - Oct 12 0:00s 0 S
Rule Cuba 1998 1999 - Mar lastSun 0:00s 1:00 D
Rule Cuba 1998 2003 - Oct lastSun 0:00s 0 S
Rule Cuba 2000 2006 - Apr Sun>=1 0:00s 1:00 D
Rule Cuba 2006 only - Oct lastSun 0:00s 0 S
Rule Cuba 2007 max - Mar Sun>=8 0:00s 1:00 D
Rule Cuba 2007 max - Nov Sun>=1 0:00s 0 S
Rule Cuba 2006 max - Oct lastSun 0:00s 0 S
Rule Cuba 2007 only - Mar Sun>=8 0:00s 1:00 D
Rule Cuba 2008 max - Mar Sun>=15 0:00s 1:00 D
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone America/Havana -5:29:28 - LMT 1890
@ -2309,6 +2372,10 @@ Zone America/Grenada -4:07:00 - LMT 1911 Jul # St George's
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone America/Guadeloupe -4:06:08 - LMT 1911 Jun 8 # Pointe a Pitre
-4:00 - AST
# St Barthelemy
Link America/Guadeloupe America/St_Barthelemy
# St Martin (French part)
Link America/Guadeloupe America/Marigot
# Guatemala
#

View File

@ -127,7 +127,11 @@ Rule Arg 1989 1992 - Oct Sun>=15 0:00 1:00 S
# which did not result in the switch of a time zone, as they stayed 9 hours
# from the International Date Line.
Rule Arg 1999 only - Oct Sun>=1 0:00 1:00 S
Rule Arg 2000 only - Mar Sun>=1 0:00 0 -
# From Paul Eggert (2007-12-28):
# DST was set to expire on March 5, not March 3, but since it was converted
# to standard time on March 3 it's more convenient for us to pretend that
# it ended on March 3.
Rule Arg 2000 only - Mar 3 0:00 0 -
#
# From Peter Gradelski via Steffen Thorsen (2000-03-01):
# We just checked with our Sao Paulo office and they say the government of
@ -162,6 +166,30 @@ Rule Arg 2000 only - Mar Sun>=1 0:00 0 -
# This kind of things had always been done this way in Argentina.
# We are still -03:00 all year round in all of the country.
#
# From Steffen Thorsen (2007-12-21):
# A user (Leonardo Chaim) reported that Argentina will adopt DST....
# all of the country (all Zone-entries) are affected. News reports like
# http://www.lanacion.com.ar/opinion/nota.asp?nota_id=973037 indicate
# that Argentina will use DST next year as well, from October to
# March, although exact rules are not given.
#
# From Jesper Norgaard Welen (2007-12-26)
# The last hurdle of Argentina DST is over, the proposal was approved in
# the lower chamber too (Deputados) with a vote 192 for and 2 against.
# By the way thanks to Mariano Absatz and Daniel Mario Vega for the link to
# the original scanned proposal, where the dates and the zero hours are
# clear and unambiguous...This is the article about final approval:
# <a href="http://www.lanacion.com.ar/politica/nota.asp?nota_id=973996">
# http://www.lanacion.com.ar/politica/nota.asp?nota_id=973996
# </a>
#
# From Paul Eggert (2007-12-22):
# For dates after mid-2008, the following rules are my guesses and
# are quite possibly wrong, but are more likely than no DST at all.
Rule Arg 2007 only - Dec 30 0:00 1:00 S
Rule Arg 2008 max - Mar Sun>=15 0:00 0 -
Rule Arg 2008 max - Oct Sun>=1 0:00 1:00 S
# From Mariano Absatz (2004-05-21):
# Today it was officially published that the Province of Mendoza is changing
# its timezone this winter... starting tomorrow night....
@ -222,10 +250,80 @@ Rule Arg 2000 only - Mar Sun>=1 0:00 0 -
# http://www.sanjuan.gov.ar/prensa/archivo/000426.html
# http://www.sanjuan.gov.ar/prensa/archivo/000441.html
# From Alex Krivenyshev (2008-01-17):
# Here are articles that Argentina Province San Luis is planning to end DST
# as earlier as upcoming Monday January 21, 2008 or February 2008:
#
# Provincia argentina retrasa reloj y marca diferencia con resto del pais
# (Argentine Province delayed clock and mark difference with the rest of the
# country)
# <a href="http://cl.invertia.com/noticias/noticia.aspx?idNoticia=200801171849_EFE_ET4373&idtel">
# http://cl.invertia.com/noticias/noticia.aspx?idNoticia=200801171849_EFE_ET4373&idtel
# </a>
#
# Es inminente que en San Luis atrasen una hora los relojes
# (It is imminent in San Luis clocks one hour delay)
# <a href="http://www.lagaceta.com.ar/vernotae.asp?id_nota=253414">
# http://www.lagaceta.com.ar/vernotae.asp?id_nota=253414
# </a>
#
# <a href="http://www.worldtimezone.net/dst_news/dst_news_argentina02.html">
# http://www.worldtimezone.net/dst_news/dst_news_argentina02.html
# </a>
# From Jesper Norgaard Welen (2008-01-18):
# The page of the San Luis provincial government
# <a href="http://www.sanluis.gov.ar/notas.asp?idCanal=0&id=22812">
# http://www.sanluis.gov.ar/notas.asp?idCanal=0&id=22812
# </a>
# confirms what Alex Krivenyshev has earlier sent to the tz
# emailing list about that San Luis plans to return to standard
# time much earlier than the rest of the country. It also
# confirms that upon request the provinces San Juan and Mendoza
# refused to follow San Luis in this change.
#
# The change is supposed to take place Monday the 21.st at 0:00
# hours. As far as I understand it if this goes ahead, we need
# a new timezone for San Luis (although there are also documented
# independent changes in the southamerica file of San Luis in
# 1990 and 1991 which has not been confirmed).
# From Jesper Norgaard Welen (2008-01-25):
# Unfortunately the below page has become defunct, about the San Luis
# time change. Perhaps because it now is part of a group of pages "Most
# important pages of 2008."
#
# You can use
# <a href="http://www.sanluis.gov.ar/notas.asp?idCanal=8141&id=22834">
# http://www.sanluis.gov.ar/notas.asp?idCanal=8141&id=22834
# </a>
# instead it seems. Or use "Buscador" from the main page of the San Luis
# government, and fill in "huso" and click OK, and you will get 3 pages
# from which the first one is identical to the above.
# From Mariano Absatz (2008-01-28):
# I can confirm that the Province of San Luis (and so far only that
# province) decided to go back to UTC-3 effective midnight Jan 20th 2008
# (that is, Monday 21st at 0:00 is the time the clocks were delayed back
# 1 hour), and they intend to keep UTC-3 as their timezone all year round
# (that is, unless they change their mind any minute now).
#
# So we'll have to add yet another city to 'southamerica' (I think San
# Luis city is the mos populated city in the Province, so it'd be
# America/Argentina/San_Luis... of course I can't remember if San Luis's
# history of particular changes goes along with Mendoza or San Juan :-(
# (I only remember not being able to collect hard facts about San Luis
# back in 2004, when these provinces changed to UTC-4 for a few days, I
# mailed them personally and never got an answer).
# From Paul Eggert (2008-06-30):
# Unless otherwise specified, data are from Shanks & Pottenger through 1992,
# from the IATA otherwise. As noted below, Shanks & Pottenger say that
# America/Cordoba split into 6 subregions during 1991/1992, but we
# haven't verified this yet so for now we'll keep it a single region.
# America/Cordoba split into 6 subregions during 1991/1992, one of which
# was America/San_Luis, but we haven't verified this yet so for now we'll
# keep America/Cordoba a single region rather than splitting it into the
# other 5 subregions.
#
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
#
@ -236,18 +334,16 @@ Zone America/Argentina/Buenos_Aires -3:53:48 - LMT 1894 Oct 31
-4:00 Arg AR%sT 1969 Oct 5
-3:00 Arg AR%sT 1999 Oct 3
-4:00 Arg AR%sT 2000 Mar 3
-3:00 - ART
-3:00 Arg AR%sT
#
# Santa Fe (SF), Entre Rios (ER), Corrientes (CN), Misiones (MN), Chaco (CC),
# Formosa (FM), Salta (SA), Santiago del Estero (SE), Cordoba (CB),
# San Luis (SL), La Pampa (LP), Neuquen (NQ), Rio Negro (RN)
# La Pampa (LP), Neuquen (NQ), Rio Negro (RN)
#
# Shanks & Pottenger also make the following claims, which we haven't verified:
# - Formosa switched to -3:00 on 1991-01-07.
# - Misiones switched to -3:00 on 1990-12-29.
# - Chaco switched to -3:00 on 1991-01-04.
# - San Luis switched to -4:00 on 1990-03-14, then to -3:00 on 1990-10-15,
# then to -4:00 on 1991-03-01, then to -3:00 on 1991-06-01.
# - Santiago del Estero switched to -4:00 on 1991-04-01,
# then to -3:00 on 1991-04-26.
#
@ -259,7 +355,7 @@ Zone America/Argentina/Cordoba -4:16:48 - LMT 1894 Oct 31
-4:00 - WART 1991 Oct 20
-3:00 Arg AR%sT 1999 Oct 3
-4:00 Arg AR%sT 2000 Mar 3
-3:00 - ART
-3:00 Arg AR%sT
#
# Tucuman (TM)
Zone America/Argentina/Tucuman -4:20:52 - LMT 1894 Oct 31
@ -272,7 +368,7 @@ Zone America/Argentina/Tucuman -4:20:52 - LMT 1894 Oct 31
-4:00 Arg AR%sT 2000 Mar 3
-3:00 - ART 2004 Jun 1
-4:00 - WART 2004 Jun 13
-3:00 - ART
-3:00 Arg AR%sT
#
# La Rioja (LR)
Zone America/Argentina/La_Rioja -4:27:24 - LMT 1894 Oct 31
@ -285,7 +381,7 @@ Zone America/Argentina/La_Rioja -4:27:24 - LMT 1894 Oct 31
-4:00 Arg AR%sT 2000 Mar 3
-3:00 - ART 2004 Jun 1
-4:00 - WART 2004 Jun 20
-3:00 - ART
-3:00 Arg AR%sT
#
# San Juan (SJ)
Zone America/Argentina/San_Juan -4:34:04 - LMT 1894 Oct 31
@ -298,7 +394,7 @@ Zone America/Argentina/San_Juan -4:34:04 - LMT 1894 Oct 31
-4:00 Arg AR%sT 2000 Mar 3
-3:00 - ART 2004 May 31
-4:00 - WART 2004 Jul 25
-3:00 - ART
-3:00 Arg AR%sT
#
# Jujuy (JY)
Zone America/Argentina/Jujuy -4:21:12 - LMT 1894 Oct 31
@ -312,7 +408,7 @@ Zone America/Argentina/Jujuy -4:21:12 - LMT 1894 Oct 31
-3:00 1:00 ARST 1992
-3:00 Arg AR%sT 1999 Oct 3
-4:00 Arg AR%sT 2000 Mar 3
-3:00 - ART
-3:00 Arg AR%sT
#
# Catamarca (CT), Chubut (CH)
Zone America/Argentina/Catamarca -4:23:08 - LMT 1894 Oct 31
@ -325,7 +421,7 @@ Zone America/Argentina/Catamarca -4:23:08 - LMT 1894 Oct 31
-4:00 Arg AR%sT 2000 Mar 3
-3:00 - ART 2004 Jun 1
-4:00 - WART 2004 Jun 20
-3:00 - ART
-3:00 Arg AR%sT
#
# Mendoza (MZ)
Zone America/Argentina/Mendoza -4:35:16 - LMT 1894 Oct 31
@ -342,6 +438,23 @@ Zone America/Argentina/Mendoza -4:35:16 - LMT 1894 Oct 31
-4:00 Arg AR%sT 2000 Mar 3
-3:00 - ART 2004 May 23
-4:00 - WART 2004 Sep 26
-3:00 Arg AR%sT
#
# San Luis (SL)
Zone America/Argentina/San_Luis -4:25:24 - LMT 1894 Oct 31
-4:16:48 - CMT 1920 May
-4:00 - ART 1930 Dec
-4:00 Arg AR%sT 1969 Oct 5
-3:00 Arg AR%sT 1990
-3:00 1:00 ARST 1990 Mar 14
-4:00 - WART 1990 Oct 15
-4:00 1:00 WARST 1991 Mar 1
-4:00 - WART 1991 Jun 1
-3:00 - ART 1999 Oct 3
-4:00 1:00 WARST 2000 Mar 3
-3:00 - ART 2004 May 31
-4:00 - WART 2004 Jul 25
-3:00 Arg AR%sT 2008 Jan 21
-3:00 - ART
#
# Santa Cruz (SC)
@ -353,7 +466,7 @@ Zone America/Argentina/Rio_Gallegos -4:36:52 - LMT 1894 Oct 31
-4:00 Arg AR%sT 2000 Mar 3
-3:00 - ART 2004 Jun 1
-4:00 - WART 2004 Jun 20
-3:00 - ART
-3:00 Arg AR%sT
#
# Tierra del Fuego, Antartida e Islas del Atlantico Sur (TF)
Zone America/Argentina/Ushuaia -4:33:12 - LMT 1894 Oct 31
@ -364,7 +477,7 @@ Zone America/Argentina/Ushuaia -4:33:12 - LMT 1894 Oct 31
-4:00 Arg AR%sT 2000 Mar 3
-3:00 - ART 2004 May 30
-4:00 - WART 2004 Jun 20
-3:00 - ART
-3:00 Arg AR%sT
# Aruba
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
@ -450,6 +563,50 @@ Zone America/La_Paz -4:32:36 - LMT 1890
# Brazil will start DST on 2007-10-14 00:00 and end on 2008-02-17 00:00:
# http://www.mme.gov.br/site/news/detail.do;jsessionid=BBA06811AFCAAC28F0285210913513DA?newsId=13975
# From Paul Schulze (2008-06-24):
# ...by law number 11.662 of April 24, 2008 (published in the "Diario
# Oficial da Uniao"...) in Brazil there are changes in the timezones,
# effective today (00:00am at June 24, 2008) as follows:
#
# a) The timezone UTC+5 is e[x]tinguished, with all the Acre state and the
# part of the Amazonas state that had this timezone now being put to the
# timezone UTC+4
# b) The whole Para state now is put at timezone UTC+3, instead of just
# part of it, as was before.
#
# This change follows a proposal of senator Tiao Viana of Acre state, that
# proposed it due to concerns about open television channels displaying
# programs inappropriate to youths in the states that had the timezone
# UTC+5 too early in the night. In the occasion, some more corrections
# were proposed, trying to unify the timezones of any given state. This
# change modifies timezone rules defined in decree 2.784 of 18 June,
# 1913.
# From Rodrigo Severo (2008-06-24):
# Just correcting the URL:
# <a href="https://www.in.gov.br/imprensa/visualiza/index.jsp?jornal=3Ddo&secao=3D1&pagina=3D1&data=3D25/04/2008">
# https://www.in.gov.br/imprensa/visualiza/index.jsp?jornal=3Ddo&secao=3D1&pagina=3D1&data=3D25/04/2008
# </a>
#
# As a result of the above Decree I believe the America/Rio_Branco
# timezone shall be modified from UTC-5 to UTC-4 and a new timezone shall
# be created to represent the the west side of the Para State. I
# suggest this new timezone be called Santarem as the most
# important/populated city in the affected area.
#
# This new timezone would be the same as the Rio_Branco timezone up to
# the 2008/06/24 change which would be to UTC-3 instead of UTC-4.
# From Alex Krivenyshev (2008-06-24):
# This is a quick reference page for New and Old Brazil Time Zones map.
# <a href="http://www.worldtimezone.com/brazil-time-new-old.php">
# http://www.worldtimezone.com/brazil-time-new-old.php
# </a>
#
# - 4 time zones replaced by 3 time zones-eliminating time zone UTC- 05
# (state Acre and the part of the Amazonas will be UTC/GMT- 04) - western
# part of Par state is moving to one timezone UTC- 03 (from UTC -04).
# From Paul Eggert (2002-10-10):
# The official decrees referenced below are mostly taken from
# <a href="http://pcdsh01.on.br/DecHV.html">
@ -572,13 +729,13 @@ Rule Brazil 2000 only - Feb 27 0:00 0 -
Rule Brazil 2000 2001 - Oct Sun>=8 0:00 1:00 S
Rule Brazil 2001 2006 - Feb Sun>=15 0:00 0 -
# Decree 4,399 (2002-10-01) repeals DST in AL, CE, MA, PB, PE, PI, RN, SE.
# <a href="http://www.presidencia.gov.br/CCIVIL/decreto/2002/D4399.htm"></a>
# <a href="http://www.presidencia.gov.br/CCIVIL/decreto/2002/D4399.htm">4,399</a>
Rule Brazil 2002 only - Nov 3 0:00 1:00 S
# Decree 4,844 (2003-09-24; corrected 2003-09-26) repeals DST in BA, MT, TO.
# <a href="http://www.presidencia.gov.br/CCIVIL/decreto/2003/D4844.htm"></a>
# <a href="http://www.presidencia.gov.br/CCIVIL/decreto/2003/D4844.htm">4,844</a>
Rule Brazil 2003 only - Oct 19 0:00 1:00 S
# Decree 5,223 (2004-10-01) reestablishes DST in MT.
# <a href="http://www.planalto.gov.br/ccivil_03/_Ato2004-2006/2004/Decreto/D5223.htm"></a>
# <a href="http://www.planalto.gov.br/ccivil_03/_Ato2004-2006/2004/Decreto/D5223.htm">5,223</a>
Rule Brazil 2004 only - Nov 2 0:00 1:00 S
# Decree <a href="http://pcdsh01.on.br/DecHV5539.gif">5,539</a> (2005-09-19),
# adopted by the same states as before.
@ -587,9 +744,8 @@ Rule Brazil 2005 only - Oct 16 0:00 1:00 S
# adopted by the same states as before.
Rule Brazil 2006 only - Nov 5 0:00 1:00 S
Rule Brazil 2007 only - Feb 25 0:00 0 -
# (Decree number not yet known)
# http://www.brasil.gov.br/noticias/ultimas_noticias/horario_verao070920/
# (2007-09-20) after a heads-up from Steffen Thorsen:
# Decree <a href="http://pcdsh01.on.br/DecHV6212.gif">6,212</a> (2007-09-26),
# adopted by the same states as before.
Rule Brazil 2007 max - Oct Sun>=8 0:00 1:00 S
Rule Brazil 2008 max - Feb Sun>=15 0:00 0 -
# The latest ruleset listed above says that the following states observe DST:
@ -597,7 +753,6 @@ Rule Brazil 2008 max - Feb Sun>=15 0:00 0 -
# For dates after mid-2008, the above rules with TO="max" are guesses
# and are quite possibly wrong, but are more likely than no DST at all.
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
#
# Fernando de Noronha (administratively part of PE)
@ -623,6 +778,13 @@ Zone America/Belem -3:13:56 - LMT 1914
-3:00 Brazil BR%sT 1988 Sep 12
-3:00 - BRT
#
# west Para (PA)
# West Para includes Altamira, Oribidos, Prainha, Oriximina, and Santarem.
Zone America/Santarem -3:38:48 - LMT 1914
-4:00 Brazil AM%sT 1988 Sep 12
-4:00 - AMT 2008 Jun 24 00:00
-3:00 - BRT
#
# Maranhao (MA), Piaui (PI), Ceara (CE), Rio Grande do Norte (RN),
# Paraiba (PB)
Zone America/Fortaleza -2:34:00 - LMT 1914
@ -685,8 +847,7 @@ Zone America/Cuiaba -3:44:20 - LMT 1914
-4:00 - AMT 2004 Oct 1
-4:00 Brazil AM%sT
#
# west Para (PA), Rondonia (RO)
# West Para includes Altamira, Oribidos, Prainha, Oriximina, and Santarem.
# Rondonia (RO)
Zone America/Porto_Velho -4:15:36 - LMT 1914
-4:00 Brazil AM%sT 1988 Sep 12
-4:00 - AMT
@ -713,13 +874,14 @@ Zone America/Eirunepe -4:39:28 - LMT 1914
-5:00 Brazil AC%sT 1988 Sep 12
-5:00 - ACT 1993 Sep 28
-5:00 Brazil AC%sT 1994 Sep 22
-5:00 - ACT
-5:00 - ACT 2008 Jun 24 00:00
-4:00 - AMT
#
# Acre (AC)
Zone America/Rio_Branco -4:31:12 - LMT 1914
-5:00 Brazil AC%sT 1988 Sep 12
-5:00 - ACT
-5:00 - ACT 2008 Jun 24 00:00
-4:00 - AMT
# Chile
@ -753,6 +915,26 @@ Zone America/Rio_Branco -4:31:12 - LMT 1914
# America/Santiago. The pre-1980 Pacific/Easter data are dubious,
# but we have no other source.
# From German Poo-Caaman~o (2008-03-03):
# Due to drought, Chile extends Daylight Time in three weeks. This
# is one-time change (Saturday 3/29 at 24:00 for America/Santiago
# and Saturday 3/29 at 22:00 for Pacific/Easter)
# The Supreme Decree is located at
# <a href="http://www.shoa.cl/servicios/supremo316.pdf">
# http://www.shoa.cl/servicios/supremo316.pdf
# </a>
# and the instructions for 2008 are located in:
# <a href="http://www.horaoficial.cl/cambio.htm">
# http://www.horaoficial.cl/cambio.htm
# </a>.
# From Jose Miguel Garrido (2008-03-05):
# ...
# You could see the announces of the change on
# <a href="http://www.shoa.cl/noticias/2008/04hora/hora.htm">
# http://www.shoa.cl/noticias/2008/04hora/hora.htm
# </a>.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Chile 1927 1932 - Sep 1 0:00 1:00 S
Rule Chile 1928 1932 - Apr 1 0:00 0 -
@ -783,7 +965,11 @@ Rule Chile 1998 only - Mar Sun>=9 3:00u 0 -
Rule Chile 1998 only - Sep 27 4:00u 1:00 S
Rule Chile 1999 only - Apr 4 3:00u 0 -
Rule Chile 1999 max - Oct Sun>=9 4:00u 1:00 S
Rule Chile 2000 max - Mar Sun>=9 3:00u 0 -
Rule Chile 2000 2007 - Mar Sun>=9 3:00u 0 -
# N.B.: the end of March 29 in Chile is March 30 in Universal time,
# which is used below in specifying the transition.
Rule Chile 2008 only - Mar 30 3:00u 0 -
Rule Chile 2009 max - Mar Sun>=9 3:00u 0 -
# IATA SSIM anomalies: (1992-02) says 1992-03-14;
# (1996-09) says 1998-03-08. Ignore these.
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
@ -1129,19 +1315,17 @@ Zone America/Montevideo -3:44:44 - LMT 1898 Jun 28
# Venezuela
#
# From Kiraz Janicke (2007-09-25), in
# http://www.venezuelanalysis.com/analysis/2645:
# The proposal ... involves turning the clock back half an hour from
# +4.00 Greenwich Mean Time (GMT), to +4.30GMT, the time zone
# Venezuela had until December 31, 1964, when the current time zone
# was adopted. The change was due to take place on September 17 and
# then on September 24, but has since been postponed until December
# 31, to allow for compliance with international organizations, such
# as the International Office of Weights and Measures.
# From John Stainforth (2007-11-28):
# ... the change for Venezuela originally expected for 2007-12-31 has
# been brought forward to 2007-12-09. The official announcement was
# published today in the "Gaceta Oficial de la Republica Bolivariana
# de Venezuela, numero 38.819" (official document for all laws or
# resolution publication)
# http://www.globovision.com/news.php?nid=72208
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone America/Caracas -4:27:44 - LMT 1890
-4:27:40 - CMT 1912 Feb 12 # Caracas Mean Time?
-4:30 - VET 1965 # Venezuela Time
-4:00 - VET 2008
-4:00 - VET 2007 Dec 9 03:00
-4:30 - VET

View File

@ -64,7 +64,8 @@ AQ -7824+10654 Antarctica/Vostok Vostok Station, S Magnetic Pole
AQ -6640+14001 Antarctica/DumontDUrville Dumont-d'Urville Station, Terre Adelie
AQ -690022+0393524 Antarctica/Syowa Syowa Station, E Ongul I
AR -3436-05827 America/Argentina/Buenos_Aires Buenos Aires (BA, CF)
AR -3124-06411 America/Argentina/Cordoba most locations (CB, CC, CN, ER, FM, LP, MN, NQ, RN, SA, SE, SF, SL)
AR -3124-06411 America/Argentina/Cordoba most locations (CB, CC, CN, ER, FM, LP, MN, NQ, RN, SA, SE, SF)
AR -3319-06621 America/Argentina/San_Luis San Luis (SL)
AR -2411-06518 America/Argentina/Jujuy Jujuy (JY)
AR -2649-06513 America/Argentina/Tucuman Tucuman (TM)
AR -2828-06547 America/Argentina/Catamarca Catamarca (CT), Chubut (CH)
@ -99,6 +100,7 @@ BG +4241+02319 Europe/Sofia
BH +2623+05035 Asia/Bahrain
BI -0323+02922 Africa/Bujumbura
BJ +0629+00237 Africa/Porto-Novo
BL +1753-06251 America/St_Barthelemy
BM +3217-06446 Atlantic/Bermuda
BN +0456+11455 Asia/Brunei
BO -1630-06809 America/La_Paz
@ -112,7 +114,8 @@ BR -1259-03831 America/Bahia Bahia
BR -2332-04637 America/Sao_Paulo S & SE Brazil (GO, DF, MG, ES, RJ, SP, PR, SC, RS)
BR -2027-05437 America/Campo_Grande Mato Grosso do Sul
BR -1535-05605 America/Cuiaba Mato Grosso
BR -0846-06354 America/Porto_Velho W Para, Rondonia
BR -0226-05452 America/Santarem W Para
BR -0846-06354 America/Porto_Velho Rondonia
BR +0249-06040 America/Boa_Vista Roraima
BR -0308-06001 America/Manaus E Amazonas
BR -0640-06952 America/Eirunepe W Amazonas
@ -230,7 +233,7 @@ ID -0232+14042 Asia/Jayapura Irian Jaya & the Moluccas
IE +5320-00615 Europe/Dublin
IL +3146+03514 Asia/Jerusalem
IM +5409-00428 Europe/Isle_of_Man
IN +2232+08822 Asia/Calcutta
IN +2232+08822 Asia/Kolkata
IO -0720+07225 Indian/Chagos
IQ +3321+04425 Asia/Baghdad
IR +3540+05126 Asia/Tehran
@ -272,6 +275,7 @@ MA +3339-00735 Africa/Casablanca
MC +4342+00723 Europe/Monaco
MD +4700+02850 Europe/Chisinau
ME +4226+01916 Europe/Podgorica
MF +1804-06305 America/Marigot
MG -1855+04731 Indian/Antananarivo
MH +0709+17112 Pacific/Majuro most locations
MH +0905+16720 Pacific/Kwajalein Kwajalein
@ -361,8 +365,7 @@ SE +5920+01803 Europe/Stockholm
SG +0117+10351 Asia/Singapore
SH -1555-00542 Atlantic/St_Helena
SI +4603+01431 Europe/Ljubljana
SJ +7800+01600 Arctic/Longyearbyen Svalbard
SJ +7059-00805 Atlantic/Jan_Mayen Jan Mayen
SJ +7800+01600 Arctic/Longyearbyen
SK +4809+01707 Europe/Bratislava
SL +0830-01315 Africa/Freetown
SM +4355+01228 Europe/San_Marino
@ -432,7 +435,7 @@ VC +1309-06114 America/St_Vincent
VE +1030-06656 America/Caracas
VG +1827-06437 America/Tortola
VI +1821-06456 America/St_Thomas
VN +1045+10640 Asia/Saigon
VN +1045+10640 Asia/Ho_Chi_Minh
VU -1740+16825 Pacific/Efate
WF -1318-17610 Pacific/Wallis
WS -1350-17144 Pacific/Apia

View File

@ -23,10 +23,6 @@
# have any questions.
#
#
# Makefile for building com/sun
#
BUILDDIR = ../../..
include $(BUILDDIR)/common/Defs.gmk

View File

@ -23,10 +23,6 @@
# have any questions.
#
#
# Makefile for building com/sun
#
BUILDDIR = ../../../..
include $(BUILDDIR)/common/Defs.gmk

View File

@ -24,7 +24,7 @@
#
#
# Makefile for building JNDI service provider toolkit
# Makefile for building JNDI DNS name service provider
#
BUILDDIR = ../../../../..

View File

@ -32,7 +32,6 @@ include $(BUILDDIR)/common/Defs.gmk
SUBDIRS = \
addjsum \
auto_multi \
buildmetaindex \
commentchecker \
compile_font_config \

View File

@ -1,458 +0,0 @@
/*
* Copyright 1998-2001 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 build.tools.automulti;
import java.lang.reflect.*;
import java.util.*;
import java.io.*;
/**
* Automatically generates the Multiplexing UI classes
* for Swing.
* <p>
* To use, type 'java AutoMulti <plafdir> <prefix>' where <plafdir>
* is the directory containing the source for Swing's UI classes and
* <prefix> is the package prefix to use before ".swing.plaf.multi".
* For example:
*
* <pre>
* cd TEST
* ../../../../build/solaris-sparc/bin/java AutoMulti ../../../../src/share/classes/javax/swing/plaf javax
* </pre>
*
* AutoMulti will scour the plaf directory for *UI.java files and
* generate Multi*UI.java files that do the multiplexing thing.
* <p>
* NOTE: This tool depends upon the existence of <plafdir> and on the
* compiled classes from <plafdir> being somewhere in the class path.
*
* @author Willie Walker
*/
public class AutoMulti {
static String importLines;
/**
* A silly list of parameter names to use. Skips "i" because we use
* it as a 'for' loop counter. If you want to get fancy, please feel
* to change how parameter names are obtained. This will break if
* someone decides to create a UI method that takes more than 8
* parameters. Which one is a bug (this breaking or having a method
* with more than eight parameters) is a subjective thing.
*/
public static String[] paramNames = {"a","b","c","d","e","f","g","h"};
/**
* Removes the package names (e.g., javax.swing) from the name.
*/
public static String unqualifyName(String name) {
StringTokenizer parser = new StringTokenizer(name,".");
String unqualifiedName = null;
while (parser.hasMoreTokens()) {
unqualifiedName = parser.nextToken();
}
return removeDollars(unqualifiedName);
}
/**
* Strips the extension from the filename.
*/
public static String stripExtension(String name) {
StringTokenizer parser = new StringTokenizer(name,".");
return parser.nextToken();
}
/**
* Adds some spaces.
*/
public static void indent(StringBuffer s, int i) {
while (i > 0) {
s.append(" ");
i--;
}
}
/**
* Spits out all the beginning stuff.
*/
public static StringBuffer createPreamble(String prefixName) {
StringBuffer s = new StringBuffer();
s.append("/*\n");
s.append(" *\n");
s.append(" * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.\n");
s.append(" * \n");
s.append(" * This software is the proprietary information of Sun Microsystems, Inc. \n");
s.append(" * Use is subject to license terms.\n");
s.append(" * \n");
s.append(" */\n");
s.append("package " + prefixName + ".swing.plaf.multi;\n");
s.append("\n");
return s;
}
/**
* Replaces 'Xxx$Yyy' with "Xxx'. Used by addImport because you
* can't import nested classes directly.
*/
public static String removeNestedClassName(String s) {
int dollarPosition = s.indexOf('$');
if (dollarPosition >= 0) { // s contains '$'
StringBuffer sb = new StringBuffer(s);
sb.setLength(dollarPosition);
return sb.toString();
} else { // no '$'
return s;
}
}
/**
* Replaces '$' with ".'. Needed for printing inner class names
* for argument and return types.
*/
public static String removeDollars(String s) {
int dollarPosition = s.indexOf('$');
if (dollarPosition >= 0) { // s contains '$'
StringBuffer sb = new StringBuffer(s);
while (dollarPosition >= 0) {
//XXX: will there ever be more than one '$'?
sb.replace(dollarPosition, dollarPosition+1, ".");
dollarPosition = sb.indexOf("$", dollarPosition);
}
return sb.toString();
} else { // no $
return s;
}
}
/**
* Adds an import line to the String.
*/
public static void addImport(String s, Class theClass) {
if (!theClass.isPrimitive() && (theClass != Object.class)) {
String className = removeNestedClassName(theClass.getName());
String importLine = new String("import " + className + ";\n");
if (importLines.indexOf(importLine) == -1) {
importLines += importLine;
}
}
}
/**
* Spits out the class header information.
*/
public static void addHeader(StringBuffer s, String className) {
s.append("/**\n");
s.append(" * A multiplexing UI used to combine <code>" + className + "</code>s.\n");
s.append(" * \n");
s.append(" * <p>This file was automatically generated by AutoMulti.\n");
s.append(" *\n");
s.append(" * @author Otto Multey\n"); // Get it? I crack myself up.
s.append(" */\n");
s.append("public class Multi" + className + " extends " + className + " {\n");
s.append("\n");
s.append(" /**\n");
s.append(" * The vector containing the real UIs. This is populated \n");
s.append(" * in the call to <code>createUI</code>, and can be obtained by calling\n");
s.append(" * the <code>getUIs</code> method. The first element is guaranteed to be the real UI \n");
s.append(" * obtained from the default look and feel.\n");
s.append(" */\n");
s.append(" protected Vector uis = new Vector();\n");
s.append("\n");
s.append("////////////////////\n");
s.append("// Common UI methods\n");
s.append("////////////////////\n");
s.append("\n");
s.append(" /**\n");
s.append(" * Returns the list of UIs associated with this multiplexing UI. This \n");
s.append(" * allows processing of the UIs by an application aware of multiplexing \n");
s.append(" * UIs on components.\n");
s.append(" */\n");
s.append(" public ComponentUI[] getUIs() {\n");
s.append(" return MultiLookAndFeel.uisToArray(uis);\n");
s.append(" }\n");
}
/**
* Prints out the code for a method. This is pretty specific to the
* Multiplexing UI code, so don't get any fancy ideas.
*/
public static void addMethod(StringBuffer s, Method m, String origName, String className) {
// Get the method name and the return type. Be a little careful about arrays.
//
String methodName = unqualifyName(m.getName());
String returnType;
if (!m.getReturnType().isArray()) {
returnType = unqualifyName(m.getReturnType().toString());
addImport(importLines,m.getReturnType());
} else {
returnType = unqualifyName(m.getReturnType().getComponentType().toString())
+ "[]";
addImport(importLines,m.getReturnType().getComponentType());
}
// Print the javadoc
//
s.append("\n");
if (methodName.equals("createUI")) {
s.append(" /**\n");
s.append(" * Returns a multiplexing UI instance if any of the auxiliary\n");
s.append(" * <code>LookAndFeel</code>s supports this UI. Otherwise, just returns the \n");
s.append(" * UI object obtained from the default <code>LookAndFeel</code>.\n");
s.append(" */\n");
} else if (!returnType.equals("void")) {
s.append(" /**\n");
s.append(" * Invokes the <code>" + methodName + "</code> method on each UI handled by this object.\n");
s.append(" * \n");
s.append(" * @return the value obtained from the first UI, which is\n");
s.append(" * the UI obtained from the default <code>LookAndFeel</code>\n");
s.append(" */\n");
} else {
s.append(" /**\n");
s.append(" * Invokes the <code>" + methodName
+ "</code> method on each UI handled by this object.\n");
s.append(" */\n");
}
// Print the method signature
//
s.append(" public");
if (Modifier.isStatic(m.getModifiers())) {
s.append(" static");
}
s.append(" " + returnType);
s.append(" " + methodName);
s.append("(");
Class[] params = m.getParameterTypes();
Class temp;
String braces;
for (int i = 0; i < params.length; i++) {
if (i > 0) {
s.append(", ");
}
temp = params[i];
braces = new String("");
while (temp.isArray()) {
braces += "[]";
temp = temp.getComponentType();
}
s.append(unqualifyName(temp.getName()) + braces + " " + paramNames[i]);
addImport(importLines,temp);
}
s.append(")");
// Don't forget about exceptions
//
Class exceptions[] = m.getExceptionTypes();
String throwsString = new String("");
if (exceptions.length > 0) {
s.append("\n");
indent(s,12);
s.append("throws ");
for (int i = 0; i < exceptions.length; i++) {
if (i > 0) {
s.append(", ");
}
s.append(unqualifyName(exceptions[i].getName()));
addImport(importLines,exceptions[i]);
}
}
s.append(throwsString + " {\n");
// Now print out the contents of the method. We do a special thing
// for the createUI method, another thing if the method returns 'void'
// and a third thing if we don't do either of the first two. If
// you want to squash this down, feel free.
//
if (methodName.equals("createUI")) {
indent(s,8);
s.append("ComponentUI mui = new Multi" + origName + "();\n");
indent(s,8);
s.append("return MultiLookAndFeel.createUIs(mui,\n");
indent(s,42);
s.append("((Multi" + origName +") mui).uis,\n");
indent(s,42);
for (int i = 0; i < params.length; i++) {
if (i > 0) {
s.append(",");
}
s.append(paramNames[i]);
}
s.append(");\n");
} else if (!returnType.equals("void")) {
indent(s,8);
s.append(returnType + " returnValue = \n");
indent(s,12);
s.append("((" + className + ") (uis.elementAt(0)))."
+ methodName + "(");
for (int i = 0; i < params.length; i++) {
if (i > 0) {
s.append(",");
}
s.append(paramNames[i]);
}
s.append(");\n");
indent(s,8);
s.append("for (int i = 1; i < uis.size(); i++) {\n");
indent(s,12);
s.append("((" + className + ") (uis.elementAt(i)))."
+ methodName + "(");
for (int i = 0; i < params.length; i++) {
if (i > 0) {
s.append(",");
}
s.append(paramNames[i]);
}
s.append(");\n");
indent(s,8);
s.append("}\n");
indent(s,8);
s.append("return returnValue;\n");
} else {
indent(s,8);
s.append("for (int i = 0; i < uis.size(); i++) {\n");
indent(s,12);
s.append("((" + className + ") (uis.elementAt(i)))."
+ methodName + "(");
for (int i = 0; i < params.length; i++) {
if (i > 0) {
s.append(",");
}
s.append(paramNames[i]);
}
s.append(");\n");
indent(s,8);
s.append("}\n");
}
indent(s,4);
s.append("}\n");
}
/**
* Takes a plaf class name (e.g., "MenuUI") and generates the corresponding
* Multiplexing UI Java source code (e.g., "MultiMenuUI.java").
*/
public static void generateFile(String prefixName, String className) {
try {
FileOutputStream fos;
PrintWriter outFile;
importLines = new String();
importLines += new String("import java.util.Vector;\n");
StringBuffer body = new StringBuffer();
Class wee = Class.forName(prefixName + ".swing.plaf." + className);
String weeName = unqualifyName(wee.getName());
addImport(importLines,wee);
while (!weeName.equals("Object")) {
body.append("\n");
body.append("////////////////////\n");
body.append("// " + weeName + " methods\n");
body.append("////////////////////\n");
Method[] methods = wee.getDeclaredMethods();
for (int i=0; i < methods.length; i++) {
if (Modifier.isPublic(methods[i].getModifiers())) {
addMethod(body,methods[i],className,weeName);
}
}
wee = wee.getSuperclass();
weeName = unqualifyName(wee.getName());
addImport(importLines,wee);
}
fos = new FileOutputStream("Multi" + className + ".java");
outFile = new PrintWriter(fos);
StringBuffer outText = createPreamble(prefixName);
outText.append(importLines.toString() + "\n");
addHeader(outText,className);
outText.append(body.toString());
outText.append("}\n");
outFile.write(outText.toString());
outFile.flush();
outFile.close();
} catch (Exception e) {
System.err.println(e);
}
}
/**
* D'Oh! Something bad happened.
*/
public static void usage(String s) throws IOException {
System.err.println("Usage: AutoMulti <plafdir> [com.sun]");
throw new IllegalArgumentException(s);
}
/**
* Takes the plaf directory name and generates the multiplexing UI
* source code.
*/
public static void main(String[] args) throws IOException {
if (args.length < 1) {
usage("");
}
String dirName = args[0];
File dir = new File(dirName);
if (!dir.isDirectory()) {
System.err.println("No such directory: " + dirName);
usage("");
}
String prefixName;
if (args.length > 1) {
prefixName = args[1];
} else {
prefixName = "com.sun.java";
}
String plafUIs[] = dir.list(new UIJavaFilter());
for (int i = 0; i < plafUIs.length; i++) {
generateFile(prefixName,stripExtension(plafUIs[i]));
}
}
}
/**
* Only accepts file names of the form *UI.java. The one exception
* is not accepting ComponentUI.java because we don't need to generate
* a multiplexing class for it.
*/
class UIJavaFilter implements FilenameFilter {
public boolean accept(File dir, String name) {
if (name.equals("ComponentUI.java")) {
return false;
} else if (name.endsWith("UI.java")) {
return true;
} else {
return false;
}
}
}

View File

@ -1,36 +0,0 @@
AutoMulti is the tool that automatically generates the
Multi*UI classes for the Multiplexing look and feel.
Instructions for using it are in AutoMulti.java.
TestALFGenerator is a tool (a variation of AutoMulti)
that automatically generates an auxiliary look and
feel that you can use to test the Multiplexing look
and feel. The TestALF look and feel implements every
method by printing the message "In the xxx method of
the TextALFYyyUI class." and, except in the case of
createUI, returning something meaningless (since,
except in the case of createUI, the return value is
ignored).
TestALFLookAndFeel.java is the only non-auto-generated
file for the TestALF L&F. If you specify a package
argument to TestALFGenerator, you'll have to change
the code in TestALFLookAndFeel.java to reflect the
package name.
To test any application with the TestALF, make sure the
compiled TestALF classes are in the class path. Then add
this to the <JDK_HOME>/lib/swing.properties file (which
you'll probably have to create):
swing.auxiliarylaf=TestALFLookAndFeel
E.g., if you're running SwingSet2 against your solaris
build, then you'd create/edit the swing.properties file
in <wsdir>/build/solaris-sparc/lib.
Then run any app. You'll see lots of thrilling "In the
Xxxx method of the Yyy class" messages. If you get anything
else (especially an exception), then you've found a bug.
Probably in the default look and feel.

View File

@ -1,401 +0,0 @@
/*
* Copyright 2001 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 build.tools.automulti;
import java.lang.reflect.*;
import java.util.*;
import java.io.*;
/**
* Automatically generates an auxiliary look and feel to be
* used for testing the Multiplexing look and feel.
* <p>
* To use, type 'java TestALFGenerator <plafdir> [<package>]' where <plafdir>
* is the directory containing the source for Swing's UI classes.
* <package> is an optional argument that specifies the package
* of the TestALF classes. If it's omitted, the classes are in
* the default package.
* For example:
*
* <pre>
* ../../../../build/solaris-sparc/bin/java TestALFGenerator ../../../../src/share/classes/javax/swing/plaf com.myco.myalaf
* </pre>
*
* TestALFGenerator will scour the plaf directory for *UI.java files and
* generate TestALF*UI.java files.
* <p>
* NOTE: This tool depends upon the existence of <plafdir> and on the
* compiled classes from <plafdir> being somewhere in the class path.
*
* @author Willie Walker
*/
public class TestALFGenerator {
static String importLines;
static String packageName;
static String classPrefix = "TestALF";
/**
* A silly list of parameter names to use. Skips "i" because we use
* it as a 'for' loop counter. If you want to get fancy, please feel
* to change how parameter names are obtained. This will break if
* someone decides to create a UI method that takes more than 8
* parameters. Which one is a bug (this breaking or having a method
* with more than eight parameters) is a subjective thing.
*/
public static String[] paramNames = {"a","b","c","d","e","f","g","h"};
/**
* Removes the package names (e.g., javax.swing) from the name.
*/
public static String unqualifyName(String name) {
StringTokenizer parser = new StringTokenizer(name,".");
String unqualifiedName = null;
while (parser.hasMoreTokens()) {
unqualifiedName = parser.nextToken();
}
return removeDollars(unqualifiedName);
}
/**
* Strips the extension from the filename.
*/
public static String stripExtension(String name) {
StringTokenizer parser = new StringTokenizer(name,".");
return parser.nextToken();
}
/**
* Adds some spaces.
*/
public static void indent(StringBuffer s, int i) {
while (i > 0) {
s.append(" ");
i--;
}
}
/**
* Spits out all the beginning stuff.
*/
public static StringBuffer createPreamble(String prefixName) {
StringBuffer s = new StringBuffer();
s.append("/*\n");
s.append(" *\n");
s.append(" * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.\n");
s.append(" * \n");
s.append(" * This software is the proprietary information of Sun Microsystems, Inc. \n");
s.append(" * Use is subject to license terms.\n");
s.append(" * \n");
s.append(" */\n");
if (packageName != null) {
s.append("package " + packageName + ";\n");
s.append("\n");
}
return s;
}
/**
* Replaces 'Xxx$Yyy' with "Xxx'. Used by addImport because you
* can't import nested classes directly.
*/
public static String removeNestedClassName(String s) {
int dollarPosition = s.indexOf('$');
if (dollarPosition >= 0) { // s contains '$'
StringBuffer sb = new StringBuffer(s);
sb.setLength(dollarPosition);
return sb.toString();
} else { // no '$'
return s;
}
}
/**
* Replaces '$' with ".'. Needed for printing inner class names
* for argument and return types.
*/
public static String removeDollars(String s) {
int dollarPosition = s.indexOf('$');
if (dollarPosition >= 0) { // s contains '$'
StringBuffer sb = new StringBuffer(s);
while (dollarPosition >= 0) {
//XXX: will there ever be more than one '$'?
sb.replace(dollarPosition, dollarPosition+1, ".");
dollarPosition = sb.indexOf("$", dollarPosition);
}
return sb.toString();
} else { // no $
return s;
}
}
/**
* Adds an import line to the String.
*/
public static void addImport(String s, Class theClass) {
if (!theClass.isPrimitive() && (theClass != Object.class)) {
String className = removeNestedClassName(theClass.getName());
String importLine = new String("import " + className + ";\n");
if (importLines.indexOf(importLine) == -1) {
importLines += importLine;
}
}
}
/**
* Spits out the class header information.
*/
public static void addHeader(StringBuffer s, String className) {
s.append("/**\n");
s.append(" * An auxiliary UI for <code>" + className + "</code>s.\n");
s.append(" * \n");
s.append(" * <p>This file was automatically generated by TestALFGenerator.\n");
s.append(" *\n");
s.append(" * @author Otto Multey\n"); // Get it? I crack myself up.
s.append(" */\n");
s.append("public class " + classPrefix + className + " extends " + className + " {\n");
s.append("\n");
}
/**
* Prints out the code for a method.
*/
public static void addMethod(StringBuffer s, Method m, String origName, String className) {
// Get the method name and the return type. Be a little careful about arrays.
//
String methodName = unqualifyName(m.getName());
String returnType;
if (!m.getReturnType().isArray()) {
returnType = unqualifyName(m.getReturnType().toString());
addImport(importLines,m.getReturnType());
} else {
returnType = unqualifyName(m.getReturnType().getComponentType().toString())
+ "[]";
addImport(importLines,m.getReturnType().getComponentType());
}
// Print the javadoc
//
s.append("\n");
if (methodName.equals("createUI")) {
s.append(" /**\n");
s.append(" * Returns a UI object for this component.\n");
s.append(" */\n");
} else {
s.append(" /**\n");
s.append(" * Prints a message saying this method has been invoked.\n");
s.append(" */\n");
}
// Print the method signature
//
s.append(" public");
if (Modifier.isStatic(m.getModifiers())) {
s.append(" static");
}
s.append(" " + returnType);
s.append(" " + methodName);
s.append("(");
Class[] params = m.getParameterTypes();
Class temp;
String braces;
for (int i = 0; i < params.length; i++) {
if (i > 0) {
s.append(", ");
}
temp = params[i];
braces = new String("");
while (temp.isArray()) {
braces += "[]";
temp = temp.getComponentType();
}
s.append(unqualifyName(temp.getName()) + braces + " " + paramNames[i]);
addImport(importLines,temp);
}
s.append(")");
// Don't forget about exceptions
//
Class exceptions[] = m.getExceptionTypes();
String throwsString = new String("");
if (exceptions.length > 0) {
s.append("\n");
indent(s,12);
s.append("throws ");
for (int i = 0; i < exceptions.length; i++) {
if (i > 0) {
s.append(", ");
}
s.append(unqualifyName(exceptions[i].getName()));
addImport(importLines,exceptions[i]);
}
}
s.append(throwsString + " {\n");
// Now print out the contents of the method.
indent(s,8);
s.append("System.out.println(\"In the " + methodName
+ " method of the "
+ classPrefix + origName + " class.\");\n");
if (methodName.equals("createUI")) {
indent(s,8);
s.append("return ui;\n");
} else {
// If we have to return something, do so.
if (!returnType.equals("void")) {
Class rType = m.getReturnType();
indent(s,8);
if (!rType.isPrimitive()) {
s.append("return null;\n");
} else if (rType == Boolean.TYPE) {
s.append("return false;\n");
} else if (rType == Character.TYPE) {
s.append("return '0';\n");
} else { // byte, short, int, long, float, or double
s.append("return 0;\n");
}
}
}
indent(s,4);
s.append("}\n");
}
/**
* Takes a plaf class name (e.g., "MenuUI") and generates the corresponding
* TestALF UI Java source code (e.g., "TestALFMenuUI.java").
*/
public static void generateFile(String prefixName, String className) {
try {
FileOutputStream fos;
PrintWriter outFile;
importLines = new String();
importLines += new String("import java.util.Vector;\n");
StringBuffer body = new StringBuffer();
Class wee = Class.forName(prefixName + ".swing.plaf." + className);
String weeName = unqualifyName(wee.getName());
String thisClassName = classPrefix + className;
addImport(importLines,wee);
// Declare and initialize the shared UI object.
body.append("\n");
body.append("////////////////////\n");
body.append("// Shared UI object\n");
body.append("////////////////////\n");
body.append("private final static " + thisClassName
+ " ui = new " + thisClassName + "();\n");
while (!weeName.equals("Object")) {
body.append("\n");
body.append("////////////////////\n");
body.append("// " + weeName + " methods\n");
body.append("////////////////////\n");
Method[] methods = wee.getDeclaredMethods();
for (int i=0; i < methods.length; i++) {
if (Modifier.isPublic(methods[i].getModifiers())) {
addMethod(body,methods[i],className,weeName);
}
}
wee = wee.getSuperclass();
weeName = unqualifyName(wee.getName());
addImport(importLines,wee);
}
fos = new FileOutputStream(classPrefix + className + ".java");
outFile = new PrintWriter(fos);
StringBuffer outText = createPreamble(prefixName);
outText.append(importLines.toString() + "\n");
addHeader(outText,className);
outText.append(body.toString());
outText.append("}\n");
outFile.write(outText.toString());
outFile.flush();
outFile.close();
} catch (Exception e) {
System.err.println(e);
}
}
/**
* D'Oh! Something bad happened.
*/
public static void usage(String s) throws IOException {
System.err.println("Usage: java TestALFGenerator <plafdir> [<packageName>]");
throw new IllegalArgumentException(s);
}
/**
* Takes the plaf directory name and generates the TestALF UI
* source code.
*/
public static void main(String[] args) throws IOException {
if (args.length < 1) {
usage("");
}
String dirName = args[0];
File dir = new File(dirName);
if (!dir.isDirectory()) {
System.err.println("No such directory: " + dirName);
usage("");
}
if (args.length > 1) {
packageName = args[1];
}
String plafUIs[] = dir.list(new UIJavaFilter());
for (int i = 0; i < plafUIs.length; i++) {
generateFile("javax",stripExtension(plafUIs[i]));
}
}
}
/**
* Only accepts file names of the form *UI.java. The one exception
* is not accepting ComponentUI.java because we don't need to generate
* a TestALF class for it.
*/
class UIJavaFilter implements FilenameFilter {
public boolean accept(File dir, String name) {
if (name.equals("ComponentUI.java")) {
return false;
} else if (name.endsWith("UI.java")) {
return true;
} else {
return false;
}
}
}

View File

@ -1,182 +0,0 @@
/*
* Copyright 2001 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 com.myco.myalaf; //search for myalaf for other refs to package name
package build.tools.automulti;
import java.util.Vector;
import java.lang.reflect.Method;
import javax.swing.*;
import javax.swing.plaf.*;
/**
* <p>An auxiliary look and feel used for testing the Multiplexing
* look and feel.
* <p>
*
* @see UIManager#addAuxiliaryLookAndFeel
* @see javax.swing.plaf.multi
*
* @author Kathy Walrath
* @author Will Walker
*/
public class TestALFLookAndFeel extends LookAndFeel {
//////////////////////////////
// LookAndFeel methods
//////////////////////////////
/**
* Returns a string, suitable for use in menus,
* that identifies this look and feel.
*
* @return a string such as "Test Auxiliary Look and Feel"
*/
public String getName() {
return "Test Auxiliary Look and Feel";
}
/**
* Returns a string, suitable for use by applications/services,
* that identifies this look and feel.
*
* @return "TestALF"
*/
public String getID() {
return "TestALF";
}
/**
* Returns a one-line description of this look and feel.
*
* @return a descriptive string such as "Allows multiple UI instances per component instance"
*/
public String getDescription() {
return "Allows multiple UI instances per component instance";
}
/**
* Returns <code>false</code>;
* this look and feel is not native to any platform.
*
* @return <code>false</code>
*/
public boolean isNativeLookAndFeel() {
return false;
}
/**
* Returns <code>true</code>;
* every platform permits this look and feel.
*
* @return <code>true</code>
*/
public boolean isSupportedLookAndFeel() {
return true;
}
/**
* Creates, initializes, and returns
* the look and feel specific defaults.
* For this look and feel,
* the defaults consist solely of
* mappings of UI class IDs
* (such as "ButtonUI")
* to <code>ComponentUI</code> class names
* (such as "com.myco.myalaf.MultiButtonUI").
*
* @return an initialized <code>UIDefaults</code> object
* @see javax.swing.JComponent#getUIClassID
*/
public UIDefaults getDefaults() {
System.out.println("In the TestALFLookAndFeel getDefaults method.");
UIDefaults table = new TestALFUIDefaults();
//String prefix = "com.myco.myalaf.TestALF";
String prefix = "TestALF";
Object[] uiDefaults = {
"ButtonUI", prefix + "ButtonUI",
"CheckBoxMenuItemUI", prefix + "MenuItemUI",
"CheckBoxUI", prefix + "ButtonUI",
"ColorChooserUI", prefix + "ColorChooserUI",
"ComboBoxUI", prefix + "ComboBoxUI",
"DesktopIconUI", prefix + "DesktopIconUI",
"DesktopPaneUI", prefix + "DesktopPaneUI",
"EditorPaneUI", prefix + "TextUI",
"FileChooserUI", prefix + "FileChooserUI",
"FormattedTextFieldUI", prefix + "TextUI",
"InternalFrameUI", prefix + "InternalFrameUI",
"LabelUI", prefix + "LabelUI",
"ListUI", prefix + "ListUI",
"MenuBarUI", prefix + "MenuBarUI",
"MenuItemUI", prefix + "MenuItemUI",
"MenuUI", prefix + "MenuItemUI",
"OptionPaneUI", prefix + "OptionPaneUI",
"PanelUI", prefix + "PanelUI",
"PasswordFieldUI", prefix + "TextUI",
"PopupMenuSeparatorUI", prefix + "SeparatorUI",
"PopupMenuUI", prefix + "PopupMenuUI",
"ProgressBarUI", prefix + "ProgressBarUI",
"RadioButtonMenuItemUI", prefix + "MenuItemUI",
"RadioButtonUI", prefix + "ButtonUI",
"RootPaneUI", prefix + "RootPaneUI",
"ScrollBarUI", prefix + "ScrollBarUI",
"ScrollPaneUI", prefix + "ScrollPaneUI",
"SeparatorUI", prefix + "SeparatorUI",
"SliderUI", prefix + "SliderUI",
"SpinnerUI", prefix + "SpinnerUI",
"SplitPaneUI", prefix + "SplitPaneUI",
"TabbedPaneUI", prefix + "TabbedPaneUI",
"TableHeaderUI", prefix + "TableHeaderUI",
"TableUI", prefix + "TableUI",
"TextAreaUI", prefix + "TextUI",
"TextFieldUI", prefix + "TextUI",
"TextPaneUI", prefix + "TextUI",
"ToggleButtonUI", prefix + "ButtonUI",
"ToolBarSeparatorUI", prefix + "SeparatorUI",
"ToolBarUI", prefix + "ToolBarUI",
"ToolTipUI", prefix + "ToolTipUI",
"TreeUI", prefix + "TreeUI",
"ViewportUI", prefix + "ViewportUI",
};
table.putDefaults(uiDefaults);
return table;
}
}
/**
* We want the Test auxiliary look and feel to be quiet and fallback
* gracefully if it cannot find a UI. This class overrides the
* getUIError method of UIDefaults, which is the method that
* emits error messages when it cannot find a UI class in the
* LAF.
*/
class TestALFUIDefaults extends UIDefaults {
protected void getUIError(String msg) {
System.err.println("Test auxiliary L&F: " + msg);
}
}

View File

@ -50,11 +50,6 @@
#define JAR_ERROR2 "Error: Unable to access jarfile %s"
#define JAR_ERROR3 "Error: Invalid or corrupt jarfile %s"
#define CLS_ERROR1 "Error: Could not find the main class %s.\n" JNI_ERROR
#define CLS_ERROR2 "Error: Failed to load Main Class: %s\n%s"
#define CLS_ERROR3 "Error: No main method found in specified class.\n" GEN_ERROR
#define CLS_ERROR4 "Error: Main method not public\n" GEN_ERROR
#define CFG_WARN1 "Warning: %s VM not supported; %s VM will be used"
#define CFG_WARN2 "Warning: No leading - on line %d of `%s'"
#define CFG_WARN3 "Warning: Missing VM type on line %d of `%s'"

View File

@ -102,8 +102,7 @@ static jboolean InitializeJVM(JavaVM **pvm, JNIEnv **penv,
InvocationFunctions *ifn);
static jstring NewPlatformString(JNIEnv *env, char *s);
static jobjectArray NewPlatformStringArray(JNIEnv *env, char **strv, int strc);
static jclass LoadClass(JNIEnv *env, char *name);
static jstring GetMainClassName(JNIEnv *env, char *jarname);
static jclass LoadMainClass(JNIEnv *env, jboolean isJar, char *name);
static void TranslateApplicationArgs(int jargc, const char **jargv, int *pargc, char ***pargv);
static jboolean AddApplicationOptions(int cpathc, const char **cpathv);
@ -301,6 +300,22 @@ JLI_Launch(int argc, char ** argv, /* main argc, argc */
}
#define CHECK_EXCEPTION_NULL_LEAVE(e) \
if ((*env)->ExceptionOccurred(env)) { \
JLI_ReportExceptionDescription(env); \
goto leave; \
} \
if ((e) == NULL) { \
JLI_ReportErrorMessage(JNI_ERROR); \
goto leave; \
}
#define CHECK_EXCEPTION_LEAVE(rv) \
if ((*env)->ExceptionOccurred(env)) { \
JLI_ReportExceptionDescription(env); \
ret = (rv); \
goto leave; \
}
int JNICALL
JavaMain(void * _args)
@ -321,9 +336,7 @@ JavaMain(void * _args)
int ret = 0;
jlong start, end;
/* Initialize the virtual machine */
start = CounterGet();
if (!InitializeJVM(&vm, &env, &ifn)) {
JLI_ReportErrorMessage(JVM_ERROR1);
@ -332,11 +345,7 @@ JavaMain(void * _args)
if (printVersion || showVersion) {
PrintJavaVersion(env, showVersion);
if ((*env)->ExceptionOccurred(env)) {
JLI_ReportExceptionDescription(env);
JLI_ReportErrorMessage(JNI_ERROR);
goto leave;
}
CHECK_EXCEPTION_LEAVE(0);
if (printVersion) {
ret = 0;
goto leave;
@ -346,11 +355,7 @@ JavaMain(void * _args)
/* If the user specified neither a class name nor a JAR file */
if (printXUsage || printUsage || (jarfile == 0 && classname == 0)) {
PrintUsage(env, printXUsage);
if ((*env)->ExceptionOccurred(env)) {
JLI_ReportExceptionDescription(env);
JLI_ReportErrorMessage(JNI_ERROR);
ret=1;
}
CHECK_EXCEPTION_LEAVE(1);
goto leave;
}
@ -395,99 +400,25 @@ JavaMain(void * _args)
* the environment (and remove these comments).
*/
if (jarfile != 0) {
mainClassName = GetMainClassName(env, jarfile);
if ((*env)->ExceptionOccurred(env)) {
JLI_ReportExceptionDescription(env);
JLI_ReportErrorMessage(JNI_ERROR);
goto leave;
}
if (mainClassName == NULL) {
JLI_ReportErrorMessage(JAR_ERROR1,jarfile, GEN_ERROR);
goto leave;
}
classname = (char *)(*env)->GetStringUTFChars(env, mainClassName, 0);
if (classname == NULL) {
JLI_ReportExceptionDescription(env);
JLI_ReportErrorMessage(JNI_ERROR);
goto leave;
}
mainClass = LoadClass(env, classname);
if(mainClass == NULL) { /* exception occured */
JLI_ReportExceptionDescription(env);
JLI_ReportErrorMessage(CLS_ERROR1, classname);
goto leave;
}
(*env)->ReleaseStringUTFChars(env, mainClassName, classname);
mainClass = LoadMainClass(env, JNI_TRUE, jarfile);
} else {
mainClassName = NewPlatformString(env, classname);
if (mainClassName == NULL) {
JLI_ReportErrorMessage(CLS_ERROR2, classname, GEN_ERROR);
goto leave;
}
classname = (char *)(*env)->GetStringUTFChars(env, mainClassName, 0);
if (classname == NULL) {
JLI_ReportExceptionDescription(env);
JLI_ReportErrorMessage(JNI_ERROR);
goto leave;
}
mainClass = LoadClass(env, classname);
if(mainClass == NULL) { /* exception occured */
JLI_ReportExceptionDescription(env);
JLI_ReportErrorMessage(CLS_ERROR1, classname);
goto leave;
}
(*env)->ReleaseStringUTFChars(env, mainClassName, classname);
mainClass = LoadMainClass(env, JNI_FALSE, classname);
}
CHECK_EXCEPTION_NULL_LEAVE(mainClass);
/* Get the application's main method */
/*
* The LoadMainClass not only loads the main class, it will also ensure
* that the main method's signature is correct, therefore further checking
* is not required. The main method is invoked here so that extraneous java
* stacks are not in the application stack trace.
*/
mainID = (*env)->GetStaticMethodID(env, mainClass, "main",
"([Ljava/lang/String;)V");
if (mainID == NULL) {
if ((*env)->ExceptionOccurred(env)) {
JLI_ReportExceptionDescription(env);
JLI_ReportErrorMessage(JNI_ERROR);
} else {
JLI_ReportErrorMessage(CLS_ERROR3);
}
goto leave;
}
{ /* Make sure the main method is public */
jint mods;
jmethodID mid;
jobject obj = (*env)->ToReflectedMethod(env, mainClass,
mainID, JNI_TRUE);
if( obj == NULL) { /* exception occurred */
JLI_ReportExceptionDescription(env);
JLI_ReportErrorMessage(JNI_ERROR);
goto leave;
}
mid =
(*env)->GetMethodID(env,
(*env)->GetObjectClass(env, obj),
"getModifiers", "()I");
if ((*env)->ExceptionOccurred(env)) {
JLI_ReportExceptionDescription(env);
JLI_ReportErrorMessage(JNI_ERROR);
goto leave;
}
mods = (*env)->CallIntMethod(env, obj, mid);
if ((mods & 1) == 0) { /* if (!Modifier.isPublic(mods)) ... */
JLI_ReportErrorMessage(CLS_ERROR4);
goto leave;
}
}
CHECK_EXCEPTION_NULL_LEAVE(mainID);
/* Build argument array */
mainArgs = NewPlatformStringArray(env, argv, argc);
if (mainArgs == NULL) {
JLI_ReportExceptionDescription(env);
JLI_ReportErrorMessage(JNI_ERROR);
goto leave;
}
CHECK_EXCEPTION_NULL_LEAVE(mainArgs);
/* Invoke main method. */
(*env)->CallStaticVoidMethod(env, mainClass, mainID, mainArgs);
@ -498,8 +429,9 @@ JavaMain(void * _args)
*/
ret = (*env)->ExceptionOccurred(env) == NULL ? 0 : 1;
leave:
/*
* Detach the main thread so that it appears to have ended when
* Always detach the main thread so that it appears to have ended when
* the application's main method exits. This will invoke the
* uncaught exception handler machinery if main threw an
* exception. An uncaught exception handler cannot change the
@ -508,10 +440,7 @@ JavaMain(void * _args)
if ((*vm)->DetachCurrentThread(vm) != 0) {
JLI_ReportErrorMessage(JVM_ERROR2);
ret = 1;
goto leave;
}
leave:
/*
* Wait for all non-daemon threads to end, then destroy the VM.
* This will actually create a trivial new Java waiter thread
@ -525,7 +454,6 @@ JavaMain(void * _args)
return ret;
}
/*
* Checks the command line options to find which JVM type was
* specified. If no command line option was given for the JVM type,
@ -1159,7 +1087,7 @@ static jstring getPlatformEncoding(JNIEnv *env) {
if (propname) {
jclass cls;
jmethodID mid;
NULL_CHECK0 (cls = (*env)->FindClass(env, "java/lang/System"));
NULL_CHECK0 (cls = FindBootStrapClass(env, "java/lang/System"));
NULL_CHECK0 (mid = (*env)->GetStaticMethodID(
env, cls,
"getProperty",
@ -1174,7 +1102,7 @@ static jstring getPlatformEncoding(JNIEnv *env) {
static jboolean isEncodingSupported(JNIEnv *env, jstring enc) {
jclass cls;
jmethodID mid;
NULL_CHECK0 (cls = (*env)->FindClass(env, "java/nio/charset/Charset"));
NULL_CHECK0 (cls = FindBootStrapClass(env, "java/nio/charset/Charset"));
NULL_CHECK0 (mid = (*env)->GetStaticMethodID(
env, cls,
"isSupported",
@ -1203,8 +1131,8 @@ NewPlatformString(JNIEnv *env, char *s)
jstring str = 0;
(*env)->SetByteArrayRegion(env, ary, 0, len, (jbyte *)s);
if (!(*env)->ExceptionOccurred(env)) {
NULL_CHECK0(cls = FindBootStrapClass(env, "java/lang/String"));
if (isEncodingSupported(env, enc) == JNI_TRUE) {
NULL_CHECK0(cls = (*env)->FindClass(env, "java/lang/String"));
NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "<init>",
"([BLjava/lang/String;)V"));
str = (*env)->NewObject(env, cls, mid, ary, enc);
@ -1215,7 +1143,6 @@ NewPlatformString(JNIEnv *env, char *s)
the encoding name, in which the StringCoding class will
pickup the iso-8859-1 as the fallback converter for us.
*/
NULL_CHECK0(cls = (*env)->FindClass(env, "java/lang/String"));
NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "<init>",
"([B)V"));
str = (*env)->NewObject(env, cls, mid, ary);
@ -1238,7 +1165,7 @@ NewPlatformStringArray(JNIEnv *env, char **strv, int strc)
jarray ary;
int i;
NULL_CHECK0(cls = (*env)->FindClass(env, "java/lang/String"));
NULL_CHECK0(cls = FindBootStrapClass(env, "java/lang/String"));
NULL_CHECK0(ary = (*env)->NewObjectArray(env, strc, cls, 0));
for (i = 0; i < strc; i++) {
jstring str = NewPlatformString(env, *strv++);
@ -1250,25 +1177,26 @@ NewPlatformStringArray(JNIEnv *env, char **strv, int strc)
}
/*
* Loads a class, convert the '.' to '/'.
* Loads a class and verifies that the main class is present and it is ok to
* call it for more details refer to the java implementation.
*/
static jclass
LoadClass(JNIEnv *env, char *name)
LoadMainClass(JNIEnv *env, jboolean isJar, char *name)
{
char *buf = JLI_MemAlloc(JLI_StrLen(name) + 1);
char *s = buf, *t = name, c;
jclass cls;
jmethodID mid;
jstring str;
jobject result;
jlong start, end;
if (JLI_IsTraceLauncher())
if (JLI_IsTraceLauncher()) {
start = CounterGet();
do {
c = *t++;
*s++ = (c == '.') ? '/' : c;
} while (c != '\0');
cls = (*env)->FindClass(env, buf);
JLI_MemFree(buf);
}
NULL_CHECK0(cls = FindBootStrapClass(env, "sun/launcher/LauncherHelper"));
NULL_CHECK0(mid = (*env)->GetStaticMethodID(env, cls, "checkAndLoadMain",
"(ZZLjava/lang/String;)Ljava/lang/Object;"));
str = (*env)->NewStringUTF(env, name);
result = (*env)->CallStaticObjectMethod(env, cls, mid, JNI_TRUE, isJar, str);
if (JLI_IsTraceLauncher()) {
end = CounterGet();
@ -1277,49 +1205,9 @@ LoadClass(JNIEnv *env, char *name)
printf("----_JAVA_LAUNCHER_DEBUG----\n");
}
return cls;
return (jclass)result;
}
/*
* Returns the main class name for the specified jar file.
*/
static jstring
GetMainClassName(JNIEnv *env, char *jarname)
{
#define MAIN_CLASS "Main-Class"
jclass cls;
jmethodID mid;
jobject jar, man, attr;
jstring str, result = 0;
NULL_CHECK0(cls = (*env)->FindClass(env, "java/util/jar/JarFile"));
NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "<init>",
"(Ljava/lang/String;)V"));
NULL_CHECK0(str = NewPlatformString(env, jarname));
NULL_CHECK0(jar = (*env)->NewObject(env, cls, mid, str));
NULL_CHECK0(mid = (*env)->GetMethodID(env, cls, "getManifest",
"()Ljava/util/jar/Manifest;"));
man = (*env)->CallObjectMethod(env, jar, mid);
if (man != 0) {
NULL_CHECK0(mid = (*env)->GetMethodID(env,
(*env)->GetObjectClass(env, man),
"getMainAttributes",
"()Ljava/util/jar/Attributes;"));
attr = (*env)->CallObjectMethod(env, man, mid);
if (attr != 0) {
NULL_CHECK0(mid = (*env)->GetMethodID(env,
(*env)->GetObjectClass(env, attr),
"getValue",
"(Ljava/lang/String;)Ljava/lang/String;"));
NULL_CHECK0(str = NewPlatformString(env, MAIN_CLASS));
result = (*env)->CallObjectMethod(env, attr, mid, str);
}
}
return result;
}
/*
* For tools, convert command line args thus:
* javac -cp foo:foo/"*" -J-ms32m ...
@ -1522,7 +1410,7 @@ PrintJavaVersion(JNIEnv *env, jboolean extraLF)
jclass ver;
jmethodID print;
NULL_CHECK(ver = (*env)->FindClass(env, "sun/misc/Version"));
NULL_CHECK(ver = FindBootStrapClass(env, "sun/misc/Version"));
NULL_CHECK(print = (*env)->GetStaticMethodID(env,
ver,
(extraLF == JNI_TRUE) ? "println" : "print",
@ -1534,7 +1422,7 @@ PrintJavaVersion(JNIEnv *env, jboolean extraLF)
}
/*
* Prints default usage or the Xusage message, see sun.launcher.LauncherHelp.java
* Prints default usage or the Xusage message, see sun.launcher.LauncherHelper.java
*/
static void
PrintUsage(JNIEnv* env, jboolean doXUsage)
@ -1544,7 +1432,7 @@ PrintUsage(JNIEnv* env, jboolean doXUsage)
jstring jprogname, vm1, vm2;
int i;
NULL_CHECK(cls = (*env)->FindClass(env, "sun/launcher/LauncherHelp"));
NULL_CHECK(cls = FindBootStrapClass(env, "sun/launcher/LauncherHelper"));
if (doXUsage) {

View File

@ -180,4 +180,16 @@ static int ContinueInNewThread(InvocationFunctions* ifn, int argc, char** argv,
*/
void InitLauncher(jboolean javaw);
/*
* This allows for finding classes from the VM's bootstrap class loader directly,
* FindClass uses the application class loader internally, this will cause
* unnecessary searching of the classpath for the required classes.
*
*/
typedef jclass (JNICALL FindClassFromBootLoader_t(JNIEnv *env,
const char *name,
jboolean init,
jobject loader,
jboolean throwError));
jclass FindBootStrapClass(JNIEnv *env, const char *classname);
#endif /* _JAVA_H_ */

View File

@ -0,0 +1,84 @@
/*
* Copyright 2008 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 com.sun.beans;
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.util.Map;
import java.util.WeakHashMap;
/**
* A hashtable-based cache with weak keys and weak values.
* An entry in the map will be automatically removed
* when its key is no longer in the ordinary use.
* A value will be automatically removed as well
* when it is no longer in the ordinary use.
*
* @since 1.7
*
* @author Sergey A. Malenkov
*/
public final class WeakCache<K, V> {
private final Map<K, Reference<V>> map = new WeakHashMap<K, Reference<V>>();
/**
* Returns a value to which the specified {@code key} is mapped,
* or {@code null} if this map contains no mapping for the {@code key}.
*
* @param key the key whose associated value is returned
* @return a value to which the specified {@code key} is mapped
*/
public V get(K key) {
Reference<V> reference = this.map.get(key);
if (reference == null) {
return null;
}
V value = reference.get();
if (value == null) {
this.map.remove(key);
}
return value;
}
/**
* Associates the specified {@code value} with the specified {@code key}.
* Removes the mapping for the specified {@code key} from this cache
* if it is present and the specified {@code value} is {@code null}.
* If the cache previously contained a mapping for the {@code key},
* the old value is replaced by the specified {@code value}.
*
* @param key the key with which the specified value is associated
* @param value the value to be associated with the specified key
*/
public void put(K key, V value) {
if (value != null) {
this.map.put(key, new WeakReference<V>(value));
}
else {
this.map.remove(key);
}
}
}

View File

@ -0,0 +1,178 @@
/*
* Copyright 2002-2007 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 com.sun.java.swing;
import sun.awt.EventQueueDelegate;
import sun.awt.AppContext;
import java.util.Map;
import java.util.concurrent.Callable;
import java.awt.AWTEvent;
import java.awt.EventQueue;
import java.awt.Component;
import javax.swing.JComponent;
import javax.swing.RepaintManager;
/**
* A collection of utility methods for Swing.
* <p>
* <b>WARNING:</b> While this class is public, it should not be treated as
* public API and its API may change in incompatable ways between dot dot
* releases and even patch releases. You should not rely on this class even
* existing.
*
* This is a second part of sun.swing.SwingUtilities2. It is required
* to provide services for JavaFX applets.
*
*/
public class SwingUtilities3 {
/**
* The {@code clientProperty} key for delegate {@code RepaintManager}
*/
private static final Object DELEGATE_REPAINT_MANAGER_KEY =
new StringBuilder("DelegateRepaintManagerKey");
/**
* Registers delegate RepaintManager for {@code JComponent}.
*/
public static void setDelegateRepaintManager(JComponent component,
RepaintManager repaintManager) {
/* setting up flag in AppContext to speed up lookups in case
* there are no delegate RepaintManagers used.
*/
AppContext.getAppContext().put(DELEGATE_REPAINT_MANAGER_KEY,
Boolean.TRUE);
component.putClientProperty(DELEGATE_REPAINT_MANAGER_KEY,
repaintManager);
}
/**
* Returns delegate {@code RepaintManager} for {@code component} hierarchy.
*/
public static RepaintManager getDelegateRepaintManager(Component
component) {
RepaintManager delegate = null;
if (Boolean.TRUE == AppContext.getAppContext().get(
DELEGATE_REPAINT_MANAGER_KEY)) {
while (delegate == null && component != null) {
while (component != null
&& ! (component instanceof JComponent)) {
component = component.getParent();
}
if (component != null) {
delegate = (RepaintManager)
((JComponent) component)
.getClientProperty(DELEGATE_REPAINT_MANAGER_KEY);
component = component.getParent();
}
}
}
return delegate;
}
/*
* We use maps to avoid reflection. Hopefully it should perform better
* this way.
*/
public static void setEventQueueDelegate(
Map<String, Map<String, Object>> map) {
EventQueueDelegate.setDelegate(new EventQueueDelegateFromMap(map));
}
private static class EventQueueDelegateFromMap
implements EventQueueDelegate.Delegate {
private final AWTEvent[] afterDispatchEventArgument;
private final Object[] afterDispatchHandleArgument;
private final Callable<Void> afterDispatchCallable;
private final AWTEvent[] beforeDispatchEventArgument;
private final Callable<Object> beforeDispatchCallable;
private final EventQueue[] getNextEventEventQueueArgument;
private final Callable<AWTEvent> getNextEventCallable;
@SuppressWarnings("unchecked")
public EventQueueDelegateFromMap(Map<String, Map<String, Object>> objectMap) {
Map<String, Object> methodMap = objectMap.get("afterDispatch");
afterDispatchEventArgument = (AWTEvent[]) methodMap.get("event");
afterDispatchHandleArgument = (Object[]) methodMap.get("handle");
afterDispatchCallable = (Callable<Void>) methodMap.get("method");
methodMap = objectMap.get("beforeDispatch");
beforeDispatchEventArgument = (AWTEvent[]) methodMap.get("event");
beforeDispatchCallable = (Callable<Object>) methodMap.get("method");
methodMap = objectMap.get("getNextEvent");
getNextEventEventQueueArgument =
(EventQueue[]) methodMap.get("eventQueue");
getNextEventCallable = (Callable<AWTEvent>) methodMap.get("method");
}
@Override
public void afterDispatch(AWTEvent event, Object handle) throws InterruptedException {
afterDispatchEventArgument[0] = event;
afterDispatchHandleArgument[0] = handle;
try {
afterDispatchCallable.call();
} catch (InterruptedException e) {
throw e;
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
public Object beforeDispatch(AWTEvent event) throws InterruptedException {
beforeDispatchEventArgument[0] = event;
try {
return beforeDispatchCallable.call();
} catch (InterruptedException e) {
throw e;
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@Override
public AWTEvent getNextEvent(EventQueue eventQueue) throws InterruptedException {
getNextEventEventQueueArgument[0] = eventQueue;
try {
return getNextEventCallable.call();
} catch (InterruptedException e) {
throw e;
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
}

View File

@ -442,7 +442,10 @@ class GTKColorChooserPanel extends AbstractColorChooserPanel implements
}
if (updateModel) {
getColorSelectionModel().setSelectedColor(color);
ColorSelectionModel model = getColorSelectionModel();
if (model != null) {
model.setSelectedColor(color);
}
}
triangle.setColor(hue, saturation, brightness);

View File

@ -770,33 +770,56 @@ class Metacity implements SynthConstants {
JComponent maximizeButton = findChild(titlePane, "InternalFrameTitlePane.maximizeButton");
JComponent closeButton = findChild(titlePane, "InternalFrameTitlePane.closeButton");
int buttonGap = 0;
Insets button_border = (Insets)gm.get("button_border");
Dimension buttonDim = calculateButtonSize(titlePane);
int x = getInt("left_titlebar_edge");
int y = (button_border != null) ? button_border.top : 0;
if (titlePaneParent.getComponentOrientation().isLeftToRight()) {
int x = getInt("left_titlebar_edge");
menuButton.setBounds(x, y, buttonDim.width, buttonDim.height);
menuButton.setBounds(x, y, buttonDim.width, buttonDim.height);
x = w - buttonDim.width - getInt("right_titlebar_edge");
if (button_border != null) {
x -= button_border.right;
}
x = w - buttonDim.width - getInt("right_titlebar_edge");
if (button_border != null) {
x -= button_border.right;
}
if (frame.isClosable()) {
closeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
x -= (buttonDim.width + buttonGap);
}
if (frame.isClosable()) {
closeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
x -= buttonDim.width;
}
if (frame.isMaximizable()) {
maximizeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
x -= (buttonDim.width + buttonGap);
}
if (frame.isMaximizable()) {
maximizeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
x -= buttonDim.width;
}
if (frame.isIconifiable()) {
minimizeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
if (frame.isIconifiable()) {
minimizeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
}
} else {
int x = w - buttonDim.width - getInt("right_titlebar_edge");
menuButton.setBounds(x, y, buttonDim.width, buttonDim.height);
x = getInt("left_titlebar_edge");
if (button_border != null) {
x += button_border.left;
}
if (frame.isClosable()) {
closeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
x += buttonDim.width;
}
if (frame.isMaximizable()) {
maximizeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
x += buttonDim.width;
}
if (frame.isIconifiable()) {
minimizeButton.setBounds(x, y, buttonDim.width, buttonDim.height);
}
}
}
} // end TitlePaneLayout
@ -973,10 +996,8 @@ class Metacity implements SynthConstants {
String title = jif.getTitle();
if (title != null) {
FontMetrics fm = SwingUtilities2.getFontMetrics(jif, g);
if (jif.getComponentOrientation().isLeftToRight()) {
title = SwingUtilities2.clipStringIfNecessary(jif, fm, title,
calculateTitleTextWidth(g, jif));
}
title = SwingUtilities2.clipStringIfNecessary(jif, fm, title,
calculateTitleArea(jif).width);
g.setColor(color);
SwingUtilities2.drawString(jif, g, title, x, y + fm.getAscent());
}
@ -1010,9 +1031,10 @@ class Metacity implements SynthConstants {
JComponent titlePane = findChild(jif, "InternalFrame.northPane");
Dimension buttonDim = calculateButtonSize(titlePane);
Insets title_border = (Insets)frameGeometry.get("title_border");
Rectangle r = new Rectangle();
Insets button_border = (Insets)getFrameGeometry().get("button_border");
r.x = getInt("left_titlebar_edge") + buttonDim.width;
Rectangle r = new Rectangle();
r.x = getInt("left_titlebar_edge");
r.y = 0;
r.height = titlePane.getHeight();
if (title_border != null) {
@ -1021,15 +1043,36 @@ class Metacity implements SynthConstants {
r.height -= (title_border.top + title_border.bottom);
}
r.width = titlePane.getWidth() - r.x - getInt("right_titlebar_edge");
if (jif.isClosable()) {
r.width -= buttonDim.width;
}
if (jif.isMaximizable()) {
r.width -= buttonDim.width;
}
if (jif.isIconifiable()) {
r.width -= buttonDim.width;
if (titlePane.getParent().getComponentOrientation().isLeftToRight()) {
r.x += buttonDim.width;
if (button_border != null) {
r.x += button_border.left;
}
r.width = titlePane.getWidth() - r.x - getInt("right_titlebar_edge");
if (jif.isClosable()) {
r.width -= buttonDim.width;
}
if (jif.isMaximizable()) {
r.width -= buttonDim.width;
}
if (jif.isIconifiable()) {
r.width -= buttonDim.width;
}
} else {
if (jif.isClosable()) {
r.x += buttonDim.width;
}
if (jif.isMaximizable()) {
r.x += buttonDim.width;
}
if (jif.isIconifiable()) {
r.x += buttonDim.width;
}
r.width = titlePane.getWidth() - r.x - getInt("right_titlebar_edge")
- buttonDim.width;
if (button_border != null) {
r.x -= button_border.right;
}
}
if (title_border != null) {
r.width -= title_border.right;

View File

@ -49,8 +49,7 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
/**
* ReferenceQueue of unreferenced WeakPCLs.
*/
private static ReferenceQueue queue;
private static ReferenceQueue<DesktopProperty> queue;
/**
* PropertyChangeListener attached to the Toolkit.
@ -76,7 +75,7 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
static {
queue = new ReferenceQueue();
queue = new ReferenceQueue<DesktopProperty>();
}
/**
@ -117,8 +116,8 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
XPStyle.invalidateStyle();
}
Frame appFrames[] = Frame.getFrames();
for (int j=0; j < appFrames.length; j++) {
updateWindowUI(appFrames[j]);
for (Frame appFrame : appFrames) {
updateWindowUI(appFrame);
}
}
@ -128,8 +127,8 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
private static void updateWindowUI(Window window) {
SwingUtilities.updateComponentTreeUI(window);
Window ownedWins[] = window.getOwnedWindows();
for (int i=0; i < ownedWins.length; i++) {
updateWindowUI(ownedWins[i]);
for (Window ownedWin : ownedWins) {
updateWindowUI(ownedWin);
}
}
@ -270,13 +269,13 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
* is handled via a WeakReference so as not to pin down the
* DesktopProperty.
*/
private static class WeakPCL extends WeakReference
private static class WeakPCL extends WeakReference<DesktopProperty>
implements PropertyChangeListener {
private Toolkit kit;
private String key;
private LookAndFeel laf;
WeakPCL(Object target, Toolkit kit, String key, LookAndFeel laf) {
WeakPCL(DesktopProperty target, Toolkit kit, String key, LookAndFeel laf) {
super(target, queue);
this.kit = kit;
this.key = key;
@ -284,7 +283,7 @@ public class DesktopProperty implements UIDefaults.ActiveValue {
}
public void propertyChange(PropertyChangeEvent pce) {
DesktopProperty property = (DesktopProperty)get();
DesktopProperty property = get();
if (property == null || laf != UIManager.getLookAndFeel()) {
// The property was GC'ed, we're no longer interested in

View File

@ -96,7 +96,7 @@ public class WindowsDesktopManager extends DefaultDesktopManager
}
} catch (PropertyVetoException e) {}
if (f != currentFrame) {
currentFrameRef = new WeakReference(f);
currentFrameRef = new WeakReference<JInternalFrame>(f);
}
}

View File

@ -983,7 +983,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
} else if (s.equals("componentOrientation")) {
ComponentOrientation o = (ComponentOrientation)e.getNewValue();
JFileChooser cc = (JFileChooser)e.getSource();
if (o != (ComponentOrientation)e.getOldValue()) {
if (o != e.getOldValue()) {
cc.applyComponentOrientation(o);
}
} else if (s.equals("ancestor")) {
@ -1123,7 +1123,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
* Data model for a type-face selection combo-box.
*/
protected class DirectoryComboBoxModel extends AbstractListModel implements ComboBoxModel {
Vector directories = new Vector();
Vector<File> directories = new Vector<File>();
int[] depths = null;
File selectedDirectory = null;
JFileChooser chooser = getFileChooser();
@ -1162,7 +1162,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
// Get the canonical (full) path. This has the side
// benefit of removing extraneous chars from the path,
// for example /foo/bar/ becomes /foo/bar
File canonical = null;
File canonical;
try {
canonical = directory.getCanonicalFile();
} catch (IOException e) {
@ -1175,7 +1175,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
File sf = useShellFolder ? ShellFolder.getShellFolder(canonical)
: canonical;
File f = sf;
Vector path = new Vector(10);
Vector<File> path = new Vector<File>(10);
do {
path.addElement(f);
} while ((f = f.getParentFile()) != null);
@ -1183,7 +1183,7 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
int pathCount = path.size();
// Insert chain at appropriate place in vector
for (int i = 0; i < pathCount; i++) {
f = (File)path.get(i);
f = path.get(i);
if (directories.contains(f)) {
int topIndex = directories.indexOf(f);
for (int j = i-1; j >= 0; j--) {
@ -1202,12 +1202,12 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
private void calculateDepths() {
depths = new int[directories.size()];
for (int i = 0; i < depths.length; i++) {
File dir = (File)directories.get(i);
File dir = directories.get(i);
File parent = dir.getParentFile();
depths[i] = 0;
if (parent != null) {
for (int j = i-1; j >= 0; j--) {
if (parent.equals((File)directories.get(j))) {
if (parent.equals(directories.get(j))) {
depths[i] = depths[j] + 1;
break;
}
@ -1306,8 +1306,8 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
FileFilter currentFilter = getFileChooser().getFileFilter();
boolean found = false;
if(currentFilter != null) {
for(int i=0; i < filters.length; i++) {
if(filters[i] == currentFilter) {
for (FileFilter filter : filters) {
if (filter == currentFilter) {
found = true;
}
}

View File

@ -137,25 +137,46 @@ public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane {
int baseline = (getHeight() + fm.getAscent() - fm.getLeading() -
fm.getDescent()) / 2;
int titleX;
Rectangle r = new Rectangle(0, 0, 0, 0);
if (frame.isIconifiable()) r = iconButton.getBounds();
else if (frame.isMaximizable()) r = maxButton.getBounds();
else if (frame.isClosable()) r = closeButton.getBounds();
int titleW;
if(WindowsGraphicsUtils.isLeftToRight(frame) ) {
if (r.x == 0) r.x = frame.getWidth()-frame.getInsets().right;
titleX = systemLabel.getX() + systemLabel.getWidth() + 2;
if (xp != null) {
titleX += 2;
}
titleW = r.x - titleX - 3;
title = getTitle(frame.getTitle(), fm, titleW);
} else {
titleX = systemLabel.getX() - 2
- SwingUtilities2.stringWidth(frame,fm,title);
Rectangle lastIconBounds = new Rectangle(0, 0, 0, 0);
if (frame.isIconifiable()) {
lastIconBounds = iconButton.getBounds();
} else if (frame.isMaximizable()) {
lastIconBounds = maxButton.getBounds();
} else if (frame.isClosable()) {
lastIconBounds = closeButton.getBounds();
}
int titleX;
int titleW;
int gap = 2;
if (WindowsGraphicsUtils.isLeftToRight(frame)) {
if (lastIconBounds.x == 0) { // There are no icons
lastIconBounds.x = frame.getWidth() - frame.getInsets().right;
}
titleX = systemLabel.getX() + systemLabel.getWidth() + gap;
if (xp != null) {
titleX += 2;
}
titleW = lastIconBounds.x - titleX - gap;
} else {
if (lastIconBounds.x == 0) { // There are no icons
lastIconBounds.x = frame.getInsets().left;
}
titleW = SwingUtilities2.stringWidth(frame, fm, title);
int minTitleX = lastIconBounds.x + lastIconBounds.width + gap;
if (xp != null) {
minTitleX += 2;
}
int availableWidth = systemLabel.getX() - gap - minTitleX;
if (availableWidth > titleW) {
titleX = systemLabel.getX() - gap - titleW;
} else {
titleX = minTitleX;
titleW = availableWidth;
}
}
title = getTitle(frame.getTitle(), fm, titleW);
if (xp != null) {
String shadowType = null;
if (isSelected) {
@ -258,8 +279,8 @@ public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane {
g.fillRect(0, 0, w, h);
}
Icon icon = getIcon();
int iconWidth = 0;
int iconHeight = 0;
int iconWidth;
int iconHeight;
if (icon != null &&
(iconWidth = icon.getIconWidth()) > 0 &&
(iconHeight = icon.getIconHeight()) > 0) {
@ -304,18 +325,18 @@ public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane {
}
protected void addSystemMenuItems(JPopupMenu menu) {
JMenuItem mi = (JMenuItem)menu.add(restoreAction);
JMenuItem mi = menu.add(restoreAction);
mi.setMnemonic('R');
mi = (JMenuItem)menu.add(moveAction);
mi = menu.add(moveAction);
mi.setMnemonic('M');
mi = (JMenuItem)menu.add(sizeAction);
mi = menu.add(sizeAction);
mi.setMnemonic('S');
mi = (JMenuItem)menu.add(iconifyAction);
mi = menu.add(iconifyAction);
mi.setMnemonic('n');
mi = (JMenuItem)menu.add(maximizeAction);
mi = menu.add(maximizeAction);
mi.setMnemonic('x');
systemPopupMenu.add(new JSeparator());
mi = (JMenuItem)menu.add(closeAction);
mi = menu.add(closeAction);
mi.setMnemonic('C');
}
@ -441,7 +462,7 @@ public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane {
public class WindowsPropertyChangeHandler extends PropertyChangeHandler {
public void propertyChange(PropertyChangeEvent evt) {
String prop = (String)evt.getPropertyName();
String prop = evt.getPropertyName();
// Update the internal frame icon for the system menu.
if (JInternalFrame.FRAME_ICON_PROPERTY.equals(prop) &&

View File

@ -369,21 +369,21 @@ public class WindowsScrollBarUI extends BasicScrollBarUI {
*/
private static class Grid {
private static final int BUFFER_SIZE = 64;
private static HashMap map;
private static HashMap<String, WeakReference<Grid>> map;
private BufferedImage image;
static {
map = new HashMap();
map = new HashMap<String, WeakReference<Grid>>();
}
public static Grid getGrid(Color fg, Color bg) {
String key = fg.getRGB() + " " + bg.getRGB();
WeakReference ref = (WeakReference)map.get(key);
Grid grid = (ref == null) ? null : (Grid)ref.get();
WeakReference<Grid> ref = map.get(key);
Grid grid = (ref == null) ? null : ref.get();
if (grid == null) {
grid = new Grid(fg, bg);
map.put(key, new WeakReference(grid));
map.put(key, new WeakReference<Grid>(grid));
}
return grid;
}

View File

@ -53,13 +53,13 @@ public class WindowsTabbedPaneUI extends BasicTabbedPaneUI {
* Keys to use for forward focus traversal when the JComponent is
* managing focus.
*/
private static Set managingFocusForwardTraversalKeys;
private static Set<KeyStroke> managingFocusForwardTraversalKeys;
/**
* Keys to use for backward focus traversal when the JComponent is
* managing focus.
*/
private static Set managingFocusBackwardTraversalKeys;
private static Set<KeyStroke> managingFocusBackwardTraversalKeys;
private boolean contentOpaque = true;
@ -69,13 +69,13 @@ public class WindowsTabbedPaneUI extends BasicTabbedPaneUI {
// focus forward traversal key
if (managingFocusForwardTraversalKeys==null) {
managingFocusForwardTraversalKeys = new HashSet();
managingFocusForwardTraversalKeys = new HashSet<KeyStroke>();
managingFocusForwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
}
tabPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, managingFocusForwardTraversalKeys);
// focus backward traversal key
if (managingFocusBackwardTraversalKeys==null) {
managingFocusBackwardTraversalKeys = new HashSet();
managingFocusBackwardTraversalKeys = new HashSet<KeyStroke>();
managingFocusBackwardTraversalKeys.add( KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK));
}
tabPane.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, managingFocusBackwardTraversalKeys);

View File

@ -124,7 +124,7 @@ public class WindowsTableHeaderUI extends BasicTableHeaderUI {
setIcon(null);
sortIcon = null;
SortOrder sortOrder =
getColumnSortOrder(header.getTable(), column);
getColumnSortOrder(table, column);
if (sortOrder != null) {
switch (sortOrder) {
case ASCENDING:

View File

@ -228,7 +228,15 @@ public class Introspector {
// to generate the appropriate exception.
}
if (c != null) {
MXBeanMappingFactory factory = MXBeanMappingFactory.forInterface(c);
MXBeanMappingFactory factory;
try {
factory = MXBeanMappingFactory.forInterface(c);
} catch (IllegalArgumentException e) {
NotCompliantMBeanException ncmbe =
new NotCompliantMBeanException(e.getMessage());
ncmbe.initCause(e);
throw ncmbe;
}
return new MXBeanSupport(mbean, c, factory);
}
checkCompliance(mbeanClass);

View File

@ -36,7 +36,6 @@ import javax.management.MBeanServer;
import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;
import javax.management.openmbean.MXBeanMappingFactory;
import javax.management.openmbean.MXBeanMappingFactoryClass;
/**
* Base class for MXBeans.

View File

@ -20,12 +20,9 @@
*/
package com.sun.org.apache.xml.internal.security;
import java.io.InputStream;
import java.security.AccessController;
import java.security.PrivilegedAction;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@ -51,7 +48,7 @@ import org.w3c.dom.Node;
* done by calling {@link Init#init} which should be done in any static block
* of the files of this library. We ensure that this call is only executed once.
*
* @author $Author: raul $
* @author $Author: mullan $
*/
public final class Init {
@ -113,20 +110,19 @@ public final class Init {
dbf.setValidating(false);
DocumentBuilder db = dbf.newDocumentBuilder();
// We don't allow users to override the Apache XML Security
// configuration in the JRE. Users should use the standard security
// provider mechanism instead if implementing their own
// transform or canonicalization algorithms.
// String cfile = System.getProperty("com.sun.org.apache.xml.internal.security.resource.config");
// InputStream is =
// Class.forName("com.sun.org.apache.xml.internal.security.Init")
// .getResourceAsStream(cfile != null ? cfile : "resource/config.xml");
// InputStream is = Class.forName("com.sun.org.apache.xml.internal.security.Init").getResourceAsStream("resource/config.xml");
InputStream is = (InputStream) AccessController.doPrivileged(
new PrivilegedAction() {
public Object run() {
// String cfile = System.getProperty
// ("com.sun.org.apache.xml.internal.security.resource.config");
return getClass().getResourceAsStream
("resource/config.xml");
// (cfile != null ? cfile : "resource/config.xml");
("resource/config.xml");
}
});
@ -167,7 +163,7 @@ public final class Init {
//
// if (tag.equals("ResourceBundles")){
// XX_configure_i18n_start = System.currentTimeMillis();
// Element resource=(Element)el;
// Element resource=(Element)el;
// /* configure internationalization */
// Attr langAttr = resource.getAttributeNode("defaultLanguageCode");
// Attr countryAttr = resource.getAttributeNode("defaultCountryCode");
@ -202,11 +198,11 @@ public final class Init {
if (currMeth.getDeclaringClass().getName()
.equals(JAVACLASS)) {
log.log(java.util.logging.Level.FINE, currMeth.getDeclaringClass().toString());
log.log(java.util.logging.Level.FINE, currMeth.getDe claringClass().toString());
}
}*/
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Canonicalizer.register(" + URI + ", "
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Canonicalizer.register(" + URI + ", "
+ JAVACLASS + ")");
Canonicalizer.register(URI, JAVACLASS);
} catch (ClassNotFoundException e) {
@ -233,9 +229,8 @@ public final class Init {
"JAVACLASS");
try {
Class.forName(JAVACLASS);
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Transform.register(" + URI + ", " + JAVACLASS
+ ")");
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Transform.register(" + URI + ", " + JAVACLASS + ")");
Transform.register(URI, JAVACLASS);
} catch (ClassNotFoundException e) {
Object exArgs[] = { URI, JAVACLASS };
@ -284,12 +279,11 @@ public final class Init {
//
// if (currMeth.getDeclaringClass().getName()
// .equals(JAVACLASS)) {
// log.log(java.util.logging.Level.FINE, currMeth.getDeclaringClass().toString());
// log.log(java.util.logging.Level.FINE, currMeth.getDe claringClass().toString());
// }
// }
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "SignatureAlgorithm.register(" + URI + ", "
+ JAVACLASS + ")");
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "SignatureAlgorithm.register(" + URI + ", " + JAVACLASS + ")");
SignatureAlgorithm.register(URI, JAVACLASS);
} catch (ClassNotFoundException e) {
Object exArgs[] = { URI, JAVACLASS };
@ -320,13 +314,11 @@ public final class Init {
"DESCRIPTION");
if ((Description != null) && (Description.length() > 0)) {
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": "
+ Description);
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": " + Description);
} else {
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS
+ ": For unknown purposes");
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": For unknown purposes");
}
try {
ResourceResolver.register(JAVACLASS);
@ -359,13 +351,11 @@ public final class Init {
"DESCRIPTION");
if ((Description != null) && (Description.length() > 0)) {
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": "
+ Description);
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": " + Description);
} else {
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS
+ ": For unknown purposes");
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Register Resolver: " + JAVACLASS + ": For unknown purposes");
}
KeyResolver.register(JAVACLASS);
@ -376,8 +366,8 @@ public final class Init {
if (tag.equals("PrefixMappings")){
XX_configure_reg_prefixes_start = System.currentTimeMillis();
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Now I try to bind prefixes:");
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Now I try to bind prefixes:");
Element[] nl = XMLUtils.selectNodes(el.getFirstChild(), CONF_NS,"PrefixMapping");
@ -386,8 +376,8 @@ public final class Init {
"namespace");
String prefix = nl[i].getAttributeNS(null,
"prefix");
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Now I try to bind " + prefix + " to " + namespace);
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Now I try to bind " + prefix + " to " + namespace);
com.sun.org.apache.xml.internal.security.utils.ElementProxy
.setDefaultPrefix(namespace, prefix);
}
@ -398,19 +388,19 @@ public final class Init {
long XX_init_end = System.currentTimeMillis();
//J-
if (true) {
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "XX_init " + ((int)(XX_init_end - XX_init_start)) + " ms");
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, " XX_prng " + ((int)(XX_prng_end - XX_prng_start)) + " ms");
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, " XX_parsing " + ((int)(XX_parsing_end - XX_parsing_start)) + " ms");
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, " XX_configure_i18n " + ((int)(XX_configure_i18n_end- XX_configure_i18n_start)) + " ms");
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, " XX_configure_reg_c14n " + ((int)(XX_configure_reg_c14n_end- XX_configure_reg_c14n_start)) + " ms");
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, " XX_configure_reg_jcemapper " + ((int)(XX_configure_reg_jcemapper_end- XX_configure_reg_jcemapper_start)) + " ms");
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, " XX_configure_reg_keyInfo " + ((int)(XX_configure_reg_keyInfo_end- XX_configure_reg_keyInfo_start)) + " ms");
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, " XX_configure_reg_keyResolver " + ((int)(XX_configure_reg_keyResolver_end- XX_configure_reg_keyResolver_start)) + " ms");
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, " XX_configure_reg_prefixes " + ((int)(XX_configure_reg_prefixes_end- XX_configure_reg_prefixes_start)) + " ms");
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, " XX_configure_reg_resourceresolver " + ((int)(XX_configure_reg_resourceresolver_end- XX_configure_reg_resourceresolver_start)) + " ms");
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, " XX_configure_reg_sigalgos " + ((int)(XX_configure_reg_sigalgos_end- XX_configure_reg_sigalgos_start)) + " ms");
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, " XX_configure_reg_transforms " + ((int)(XX_configure_reg_transforms_end- XX_configure_reg_transforms_start)) + " ms");
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "XX_init " + ((int)(XX_init_end - XX_init_start)) + " ms");
log.log(java.util.logging.Level.FINE, " XX_prng " + ((int)(XX_prng_end - XX_prng_start)) + " ms");
log.log(java.util.logging.Level.FINE, " XX_parsing " + ((int)(XX_parsing_end - XX_parsing_start)) + " ms");
log.log(java.util.logging.Level.FINE, " XX_configure_i18n " + ((int)(XX_configure_i18n_end- XX_configure_i18n_start)) + " ms");
log.log(java.util.logging.Level.FINE, " XX_configure_reg_c14n " + ((int)(XX_configure_reg_c14n_end- XX_configure_reg_c14n_start)) + " ms");
log.log(java.util.logging.Level.FINE, " XX_configure_reg_jcemapper " + ((int)(XX_configure_reg_jcemapper_end- XX_configure_reg_jcemapper_start)) + " ms");
log.log(java.util.logging.Level.FINE, " XX_configure_reg_keyInfo " + ((int)(XX_configure_reg_keyInfo_end- XX_configure_reg_keyInfo_start)) + " ms");
log.log(java.util.logging.Level.FINE, " XX_configure_reg_keyResolver " + ((int)(XX_configure_reg_keyResolver_end- XX_configure_reg_keyResolver_start)) + " ms");
log.log(java.util.logging.Level.FINE, " XX_configure_reg_prefixes " + ((int)(XX_configure_reg_prefixes_end- XX_configure_reg_prefixes_start)) + " ms");
log.log(java.util.logging.Level.FINE, " XX_configure_reg_resourceresolver " + ((int)(XX_configure_reg_resourceresolver_end- XX_configure_reg_resourceresolver_start)) + " ms");
log.log(java.util.logging.Level.FINE, " XX_configure_reg_sigalgos " + ((int)(XX_configure_reg_sigalgos_end- XX_configure_reg_sigalgos_start)) + " ms");
log.log(java.util.logging.Level.FINE, " XX_configure_reg_transforms " + ((int)(XX_configure_reg_transforms_end- XX_configure_reg_transforms_start)) + " ms");
}
} catch (Exception e) {
log.log(java.util.logging.Level.SEVERE, "Bad: ", e);

View File

@ -24,7 +24,7 @@ package com.sun.org.apache.xml.internal.security.algorithms;
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
import com.sun.org.apache.xml.internal.security.utils.Constants;
import com.sun.org.apache.xml.internal.security.utils.ElementProxy;
import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@ -33,11 +33,7 @@ import org.w3c.dom.Element;
* The Algorithm class which stores the Algorithm URI as a string.
*
*/
public abstract class Algorithm extends ElementProxy {
/** {@link java.util.logging} logging facility */
static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(Algorithm.class.getName());
public abstract class Algorithm extends SignatureElementProxy {
/**
*
@ -79,7 +75,7 @@ public abstract class Algorithm extends ElementProxy {
*/
protected void setAlgorithmURI(String algorithmURI) {
if ((this._state == MODE_CREATE) && (algorithmURI != null)) {
if ( (algorithmURI != null)) {
this._constructionElement.setAttributeNS(null, Constants._ATT_ALGORITHM,
algorithmURI);
}

View File

@ -35,7 +35,7 @@ import org.w3c.dom.Element;
/**
* This class maps algorithm identifier URIs to JAVA JCE class names.
*
* @author $Author: raul $
* @author $Author: mullan $
*/
public class JCEMapper {
@ -45,9 +45,9 @@ public class JCEMapper {
private static Map uriToJCEName = new HashMap();
private static Map uriToJCEName;
private static Map algorithmsMap = new HashMap();
private static Map algorithmsMap;
private static String providerName = null;
/**
@ -63,6 +63,8 @@ public class JCEMapper {
static void loadAlgorithms( Element algorithmsEl) {
Element[] algorithms = XMLUtils.selectNodes(algorithmsEl.getFirstChild(),Init.CONF_NS,"Algorithm");
uriToJCEName = new HashMap( algorithms.length * 2);
algorithmsMap = new HashMap( algorithms.length * 2);
for (int i = 0 ;i < algorithms.length ;i ++) {
Element el = algorithms[i];
String id = el.getAttribute("URI");
@ -70,6 +72,7 @@ public class JCEMapper {
uriToJCEName.put(id, jceName);
algorithmsMap.put(id, new Algorithm(el));
}
}
static Algorithm getAlgorithmMapping(String algoURI) {
@ -84,8 +87,8 @@ public class JCEMapper {
*
*/
public static String translateURItoJCEID(String AlgorithmURI) {
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI);
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI);
String jceName = (String) uriToJCEName.get(AlgorithmURI);
return jceName;
@ -100,8 +103,8 @@ public class JCEMapper {
*
*/
public static String getAlgorithmClassFromURI(String AlgorithmURI) {
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI);
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI);
return ((Algorithm) algorithmsMap.get(AlgorithmURI)).algorithmClass;
}

View File

@ -20,10 +20,10 @@
*/
package com.sun.org.apache.xml.internal.security.algorithms;
import java.security.MessageDigest;
import java.security.NoSuchProviderException;
import java.util.HashMap;
import java.util.Map;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
import com.sun.org.apache.xml.internal.security.utils.Constants;
@ -41,11 +41,6 @@ import org.w3c.dom.Document;
*/
public class MessageDigestAlgorithm extends Algorithm {
/** {@link java.util.logging} logging facility */
static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(
MessageDigestAlgorithm.class.getName());
/** Message Digest - NOT RECOMMENDED MD5*/
public static final String ALGO_ID_DIGEST_NOT_RECOMMENDED_MD5 = Constants.MoreAlgorithmsSpecNS + "md5";
/** Digest - Required SHA1*/
@ -76,6 +71,12 @@ public class MessageDigestAlgorithm extends Algorithm {
this.algorithm = messageDigest;
}
static ThreadLocal instances=new ThreadLocal() {
protected Object initialValue() {
return new HashMap();
};
};
/**
* Factory method for constructing a message digest algorithm by name.
*
@ -86,8 +87,15 @@ public class MessageDigestAlgorithm extends Algorithm {
*/
public static MessageDigestAlgorithm getInstance(
Document doc, String algorithmURI) throws XMLSignatureException {
MessageDigest md = getDigestInstance(algorithmURI);
return new MessageDigestAlgorithm(doc, md, algorithmURI);
}
String algorithmID = JCEMapper.translateURItoJCEID(algorithmURI);
private static MessageDigest getDigestInstance(String algorithmURI) throws XMLSignatureException {
MessageDigest result=(MessageDigest) ((Map)instances.get()).get(algorithmURI);
if (result!=null)
return result;
String algorithmID = JCEMapper.translateURItoJCEID(algorithmURI);
if (algorithmID == null) {
Object[] exArgs = { algorithmURI };
@ -113,8 +121,9 @@ public class MessageDigestAlgorithm extends Algorithm {
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
}
return new MessageDigestAlgorithm(doc, md, algorithmURI);
}
((Map)instances.get()).put(algorithmURI, md);
return md;
}
/**
* Returns the actual {@link java.security.MessageDigest} algorithm object

View File

@ -25,6 +25,7 @@ import java.security.Key;
import java.security.SecureRandom;
import java.security.spec.AlgorithmParameterSpec;
import java.util.HashMap;
import java.util.Map;
import com.sun.org.apache.xml.internal.security.algorithms.implementations.IntegrityHmac;
import com.sun.org.apache.xml.internal.security.exceptions.AlgorithmAlreadyRegisteredException;
@ -52,9 +53,35 @@ public class SignatureAlgorithm extends Algorithm {
/** All available algorithm classes are registered here */
static HashMap _algorithmHash = null;
static ThreadLocal instancesSigning=new ThreadLocal() {
protected Object initialValue() {
return new HashMap();
};
};
static ThreadLocal instancesVerify=new ThreadLocal() {
protected Object initialValue() {
return new HashMap();
};
};
static ThreadLocal keysSigning=new ThreadLocal() {
protected Object initialValue() {
return new HashMap();
};
};
static ThreadLocal keysVerify=new ThreadLocal() {
protected Object initialValue() {
return new HashMap();
};
};
// boolean isForSigning=false;
/** Field _signatureAlgorithm */
protected SignatureAlgorithmSpi _signatureAlgorithm = null;
private String algorithmURI;
/**
* Constructor SignatureAlgorithm
*
@ -64,18 +91,49 @@ public class SignatureAlgorithm extends Algorithm {
*/
public SignatureAlgorithm(Document doc, String algorithmURI)
throws XMLSecurityException {
super(doc, algorithmURI);
this.algorithmURI = algorithmURI;
}
try {
private void initializeAlgorithm(boolean isForSigning) throws XMLSignatureException {
if (_signatureAlgorithm!=null) {
return;
}
_signatureAlgorithm=isForSigning ? getInstanceForSigning(algorithmURI) : getInstanceForVerify(algorithmURI);
this._signatureAlgorithm
.engineGetContextFromElement(this._constructionElement);
}
private static SignatureAlgorithmSpi getInstanceForSigning(String algorithmURI) throws XMLSignatureException {
SignatureAlgorithmSpi result=(SignatureAlgorithmSpi) ((Map)instancesSigning.get()).get(algorithmURI);
if (result!=null) {
result.reset();
return result;
}
result=buildSigner(algorithmURI, result);
((Map)instancesSigning.get()).put(algorithmURI,result);
return result;
}
private static SignatureAlgorithmSpi getInstanceForVerify(String algorithmURI) throws XMLSignatureException {
SignatureAlgorithmSpi result=(SignatureAlgorithmSpi) ((Map)instancesVerify.get()).get(algorithmURI);
if (result!=null) {
result.reset();
return result;
}
result=buildSigner(algorithmURI, result);
((Map)instancesVerify.get()).put(algorithmURI,result);
return result;
}
private static SignatureAlgorithmSpi buildSigner(String algorithmURI, SignatureAlgorithmSpi result) throws XMLSignatureException {
try {
Class implementingClass =
SignatureAlgorithm.getImplementingClass(algorithmURI);
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Create URI \"" + algorithmURI + "\" class \""
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Create URI \"" + algorithmURI + "\" class \""
+ implementingClass + "\"");
this._signatureAlgorithm =
(SignatureAlgorithmSpi) implementingClass.newInstance();
result=(SignatureAlgorithmSpi) implementingClass.newInstance();
return result;
} catch (IllegalAccessException ex) {
Object exArgs[] = { algorithmURI, ex.getMessage() };
@ -92,7 +150,7 @@ public class SignatureAlgorithm extends Algorithm {
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs,
ex);
}
}
}
/**
* Constructor SignatureAlgorithm
@ -107,7 +165,8 @@ public class SignatureAlgorithm extends Algorithm {
throws XMLSecurityException {
this(doc, algorithmURI);
this.algorithmURI=algorithmURI;
initializeAlgorithm(true);
this._signatureAlgorithm.engineSetHMACOutputLength(HMACOutputLength);
((IntegrityHmac)this._signatureAlgorithm)
.engineAddContextToElement(this._constructionElement);
@ -124,37 +183,7 @@ public class SignatureAlgorithm extends Algorithm {
throws XMLSecurityException {
super(element, BaseURI);
String algorithmURI = this.getURI();
try {
Class implementingClass =
SignatureAlgorithm.getImplementingClass(algorithmURI);
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Create URI \"" + algorithmURI + "\" class \""
+ implementingClass + "\"");
this._signatureAlgorithm =
(SignatureAlgorithmSpi) implementingClass.newInstance();
this._signatureAlgorithm
.engineGetContextFromElement(this._constructionElement);
} catch (IllegalAccessException ex) {
Object exArgs[] = { algorithmURI, ex.getMessage() };
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs,
ex);
} catch (InstantiationException ex) {
Object exArgs[] = { algorithmURI, ex.getMessage() };
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs,
ex);
} catch (NullPointerException ex) {
Object exArgs[] = { algorithmURI, ex.getMessage() };
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs,
ex);
}
algorithmURI = this.getURI();
}
/**
@ -175,7 +204,12 @@ public class SignatureAlgorithm extends Algorithm {
* @return the result of the {@link java.security.Signature#getAlgorithm} method
*/
public String getJCEAlgorithmString() {
return this._signatureAlgorithm.engineGetJCEAlgorithmString();
try {
return getInstanceForVerify(algorithmURI).engineGetJCEAlgorithmString();
} catch (XMLSignatureException e) {
//Ignore.
return null;
}
}
/**
@ -184,7 +218,11 @@ public class SignatureAlgorithm extends Algorithm {
* @return The Provider of this Signature Alogrithm
*/
public String getJCEProviderName() {
return this._signatureAlgorithm.engineGetJCEProviderName();
try {
return getInstanceForVerify(algorithmURI).engineGetJCEProviderName();
} catch (XMLSignatureException e) {
return null;
}
}
/**
@ -231,7 +269,13 @@ public class SignatureAlgorithm extends Algorithm {
* @throws XMLSignatureException
*/
public void initSign(Key signingKey) throws XMLSignatureException {
this._signatureAlgorithm.engineInitSign(signingKey);
initializeAlgorithm(true);
Map map=(Map)keysSigning.get();
if (map.get(this.algorithmURI)==signingKey) {
return;
}
map.put(this.algorithmURI,signingKey);
this._signatureAlgorithm.engineInitSign(signingKey);
}
/**
@ -244,6 +288,7 @@ public class SignatureAlgorithm extends Algorithm {
*/
public void initSign(Key signingKey, SecureRandom secureRandom)
throws XMLSignatureException {
initializeAlgorithm(true);
this._signatureAlgorithm.engineInitSign(signingKey, secureRandom);
}
@ -258,6 +303,7 @@ public class SignatureAlgorithm extends Algorithm {
public void initSign(
Key signingKey, AlgorithmParameterSpec algorithmParameterSpec)
throws XMLSignatureException {
initializeAlgorithm(true);
this._signatureAlgorithm.engineInitSign(signingKey,
algorithmParameterSpec);
}
@ -282,7 +328,13 @@ public class SignatureAlgorithm extends Algorithm {
* @throws XMLSignatureException
*/
public void initVerify(Key verificationKey) throws XMLSignatureException {
this._signatureAlgorithm.engineInitVerify(verificationKey);
initializeAlgorithm(false);
Map map=(Map)keysVerify.get();
if (map.get(this.algorithmURI)==verificationKey) {
return;
}
map.put(this.algorithmURI,verificationKey);
this._signatureAlgorithm.engineInitVerify(verificationKey);
}
/**
@ -320,7 +372,7 @@ public class SignatureAlgorithm extends Algorithm {
.getLogger(SignatureAlgorithm.class.getName());
}
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Init() called");
log.log(java.util.logging.Level.FINE, "Init() called");
if (!SignatureAlgorithm._alreadyInitialized) {
SignatureAlgorithm._algorithmHash = new HashMap(10);
@ -340,8 +392,8 @@ public class SignatureAlgorithm extends Algorithm {
throws AlgorithmAlreadyRegisteredException,XMLSignatureException {
{
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Try to register " + algorithmURI + " " + implementingClass);
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Try to register " + algorithmURI + " " + implementingClass);
// are we already registered?
Class registeredClassClass =

View File

@ -20,27 +20,20 @@
*/
package com.sun.org.apache.xml.internal.security.algorithms;
import java.security.Key;
import java.security.SecureRandom;
import java.security.spec.AlgorithmParameterSpec;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
*
* @author $Author: raul $
* @author $Author: mullan $
*/
public abstract class SignatureAlgorithmSpi {
/** {@link java.util.logging} logging facility */
static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(SignatureAlgorithmSpi.class.getName());
/**
* Returns the URI representation of <code>Transformation algorithm</code>
*
@ -167,20 +160,6 @@ public abstract class SignatureAlgorithmSpi {
protected abstract void engineSetParameter(AlgorithmParameterSpec params)
throws XMLSignatureException;
/** Field _doc */
Document _doc = null;
/**
* Method engineSetDocument
*
* @param doc
*/
protected void engineSetDocument(Document doc) {
this._doc = doc;
}
/** Field _constructionElement */
Element _constructionElement = null;
/**
* Method engineGetContextFromElement
@ -188,7 +167,6 @@ public abstract class SignatureAlgorithmSpi {
* @param element
*/
protected void engineGetContextFromElement(Element element) {
this._constructionElement = element;
}
/**
@ -199,4 +177,7 @@ public abstract class SignatureAlgorithmSpi {
*/
protected abstract void engineSetHMACOutputLength(int HMACOutputLength)
throws XMLSignatureException;
public void reset() {
}
}

View File

@ -45,7 +45,7 @@ import org.w3c.dom.Text;
/**
*
* @author $Author: raul $
* @author $Author: mullan $
*/
public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
@ -74,8 +74,8 @@ public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
public IntegrityHmac() throws XMLSignatureException {
String algorithmID = JCEMapper.translateURItoJCEID(this.engineGetURI());
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Created IntegrityHmacSHA1 using " + algorithmID);
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Created IntegrityHmacSHA1 using " + algorithmID);
try {
this._macAlgorithm = Mac.getInstance(algorithmID);
@ -99,6 +99,10 @@ public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
throw new XMLSignatureException("empty");
}
public void reset() {
_HMACOutputLength=0;
}
/**
* Proxy method for {@link java.security.Signature#verify(byte[])}
* which is executed on the internal {@link java.security.Signature} object.
@ -145,7 +149,20 @@ public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
try {
this._macAlgorithm.init(secretKey);
} catch (InvalidKeyException ex) {
throw new XMLSignatureException("empty", ex);
// reinstantiate Mac object to work around bug in JDK
// see: http://bugs.sun.com/view_bug.do?bug_id=4953555
Mac mac = this._macAlgorithm;
try {
this._macAlgorithm = Mac.getInstance
(_macAlgorithm.getAlgorithm());
} catch (Exception e) {
// this shouldn't occur, but if it does, restore previous Mac
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "Exception when reinstantiating Mac:" + e);
}
this._macAlgorithm = mac;
}
throw new XMLSignatureException("empty", ex);
}
}
@ -323,7 +340,7 @@ public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
*/
protected String engineGetJCEAlgorithmString() {
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "engineGetJCEAlgorithmString()");
log.log(java.util.logging.Level.FINE, "engineGetJCEAlgorithmString()");
return this._macAlgorithm.getAlgorithm();
}
@ -397,7 +414,8 @@ public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
/**
* Class IntegrityHmacSHA1
*
* @author $Author: raul $
* @author $Author: mullan $
* @version $Revision: 1.5 $
*/
public static class IntegrityHmacSHA1 extends IntegrityHmac {
@ -423,7 +441,8 @@ public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
/**
* Class IntegrityHmacSHA256
*
* @author $Author: raul $
* @author $Author: mullan $
* @version $Revision: 1.5 $
*/
public static class IntegrityHmacSHA256 extends IntegrityHmac {
@ -449,7 +468,8 @@ public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
/**
* Class IntegrityHmacSHA384
*
* @author $Author: raul $
* @author $Author: mullan $
* @version $Revision: 1.5 $
*/
public static class IntegrityHmacSHA384 extends IntegrityHmac {
@ -475,7 +495,8 @@ public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
/**
* Class IntegrityHmacSHA512
*
* @author $Author: raul $
* @author $Author: mullan $
* @version $Revision: 1.5 $
*/
public static class IntegrityHmacSHA512 extends IntegrityHmac {
@ -501,7 +522,8 @@ public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
/**
* Class IntegrityHmacRIPEMD160
*
* @author $Author: raul $
* @author $Author: mullan $
* @version $Revision: 1.5 $
*/
public static class IntegrityHmacRIPEMD160 extends IntegrityHmac {
@ -527,7 +549,8 @@ public abstract class IntegrityHmac extends SignatureAlgorithmSpi {
/**
* Class IntegrityHmacMD5
*
* @author $Author: raul $
* @author $Author: mullan $
* @version $Revision: 1.5 $
*/
public static class IntegrityHmacMD5 extends IntegrityHmac {

View File

@ -3,7 +3,7 @@
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
* Copyright 1999-2007 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,8 +20,6 @@
*/
package com.sun.org.apache.xml.internal.security.algorithms.implementations;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.Key;
@ -38,329 +36,344 @@ import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithmSpi
import com.sun.org.apache.xml.internal.security.signature.XMLSignature;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
/**
*
* @author $Author: raul $
* @author $Author: mullan $
*/
public abstract class SignatureBaseRSA extends SignatureAlgorithmSpi {
/** {@link java.util.logging} logging facility */
/** {@link java.util.logging} logging facility */
static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(SignatureBaseRSA.class.getName());
java.util.logging.Logger.getLogger
(SignatureBaseRSA.class.getName());
/** @inheritDoc */
public abstract String engineGetURI();
public abstract String engineGetURI();
/** Field algorithm */
private java.security.Signature _signatureAlgorithm = null;
/** Field algorithm */
private java.security.Signature _signatureAlgorithm = null;
/**
* Constructor SignatureRSA
*
* @throws XMLSignatureException
*/
public SignatureBaseRSA() throws XMLSignatureException {
/**
* Constructor SignatureRSA
*
* @throws XMLSignatureException
*/
public SignatureBaseRSA() throws XMLSignatureException {
String algorithmID = JCEMapper.translateURItoJCEID(this.engineGetURI());
String algorithmID = JCEMapper.translateURItoJCEID(this.engineGetURI());
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Created SignatureDSA using " + algorithmID);
String provider=JCEMapper.getProviderId();
try {
if (provider==null) {
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Created SignatureRSA using " + algorithmID);
String provider=JCEMapper.getProviderId();
try {
if (provider==null) {
this._signatureAlgorithm = Signature.getInstance(algorithmID);
} else {
} else {
this._signatureAlgorithm = Signature.getInstance(algorithmID,provider);
}
} catch (java.security.NoSuchAlgorithmException ex) {
Object[] exArgs = { algorithmID,
ex.getLocalizedMessage() };
}
} catch (java.security.NoSuchAlgorithmException ex) {
Object[] exArgs = { algorithmID, ex.getLocalizedMessage() };
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
} catch (NoSuchProviderException ex) {
Object[] exArgs = { algorithmID,
ex.getLocalizedMessage() };
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
} catch (NoSuchProviderException ex) {
Object[] exArgs = { algorithmID, ex.getLocalizedMessage() };
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
}
}
}
/** @inheritDoc */
protected void engineSetParameter(AlgorithmParameterSpec params)
throws XMLSignatureException {
/** @inheritDoc */
protected void engineSetParameter(AlgorithmParameterSpec params)
throws XMLSignatureException {
try {
this._signatureAlgorithm.setParameter(params);
} catch (InvalidAlgorithmParameterException ex) {
throw new XMLSignatureException("empty", ex);
}
}
try {
this._signatureAlgorithm.setParameter(params);
} catch (InvalidAlgorithmParameterException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/** @inheritDoc */
protected boolean engineVerify(byte[] signature)
throws XMLSignatureException {
/** @inheritDoc */
protected boolean engineVerify(byte[] signature)
throws XMLSignatureException {
try {
return this._signatureAlgorithm.verify(signature);
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
}
}
try {
return this._signatureAlgorithm.verify(signature);
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/** @inheritDoc */
protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
/** @inheritDoc */
protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
if (!(publicKey instanceof PublicKey)) {
String supplied = publicKey.getClass().getName();
String needed = PublicKey.class.getName();
Object exArgs[] = { supplied, needed };
if (!(publicKey instanceof PublicKey)) {
String supplied = publicKey.getClass().getName();
String needed = PublicKey.class.getName();
Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation",
exArgs);
}
throw new XMLSignatureException
("algorithms.WrongKeyForThisOperation", exArgs);
}
try {
this._signatureAlgorithm.initVerify((PublicKey) publicKey);
} catch (InvalidKeyException ex) {
throw new XMLSignatureException("empty", ex);
}
}
try {
this._signatureAlgorithm.initVerify((PublicKey) publicKey);
} catch (InvalidKeyException ex) {
// reinstantiate Signature object to work around bug in JDK
// see: http://bugs.sun.com/view_bug.do?bug_id=4953555
Signature sig = this._signatureAlgorithm;
try {
this._signatureAlgorithm = Signature.getInstance
(_signatureAlgorithm.getAlgorithm());
} catch (Exception e) {
// this shouldn't occur, but if it does, restore previous
// Signature
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "Exception when reinstantiating Signature:" + e);
}
this._signatureAlgorithm = sig;
}
throw new XMLSignatureException("empty", ex);
}
}
/** @inheritDoc */
protected byte[] engineSign() throws XMLSignatureException {
/** @inheritDoc */
protected byte[] engineSign() throws XMLSignatureException {
try {
return this._signatureAlgorithm.sign();
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
}
}
try {
return this._signatureAlgorithm.sign();
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/** @inheritDoc */
protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
throws XMLSignatureException {
/** @inheritDoc */
protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
throws XMLSignatureException {
if (!(privateKey instanceof PrivateKey)) {
String supplied = privateKey.getClass().getName();
String needed = PrivateKey.class.getName();
Object exArgs[] = { supplied, needed };
if (!(privateKey instanceof PrivateKey)) {
String supplied = privateKey.getClass().getName();
String needed = PrivateKey.class.getName();
Object exArgs[] = { supplied, needed };
throw new XMLSignatureException
("algorithms.WrongKeyForThisOperation", exArgs);
}
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation",
exArgs);
}
try {
this._signatureAlgorithm.initSign
((PrivateKey) privateKey, secureRandom);
} catch (InvalidKeyException ex) {
throw new XMLSignatureException("empty", ex);
}
}
try {
this._signatureAlgorithm.initSign((PrivateKey) privateKey,
secureRandom);
} catch (InvalidKeyException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/** @inheritDoc */
protected void engineInitSign(Key privateKey) throws XMLSignatureException {
/** @inheritDoc */
protected void engineInitSign(Key privateKey) throws XMLSignatureException {
if (!(privateKey instanceof PrivateKey)) {
String supplied = privateKey.getClass().getName();
String needed = PrivateKey.class.getName();
Object exArgs[] = { supplied, needed };
if (!(privateKey instanceof PrivateKey)) {
String supplied = privateKey.getClass().getName();
String needed = PrivateKey.class.getName();
Object exArgs[] = { supplied, needed };
throw new XMLSignatureException
("algorithms.WrongKeyForThisOperation", exArgs);
}
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation",
exArgs);
}
try {
this._signatureAlgorithm.initSign((PrivateKey) privateKey);
} catch (InvalidKeyException ex) {
throw new XMLSignatureException("empty", ex);
}
}
try {
this._signatureAlgorithm.initSign((PrivateKey) privateKey);
} catch (InvalidKeyException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/** @inheritDoc */
protected void engineUpdate(byte[] input) throws XMLSignatureException {
try {
this._signatureAlgorithm.update(input);
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/** @inheritDoc */
protected void engineUpdate(byte[] input) throws XMLSignatureException {
/** @inheritDoc */
protected void engineUpdate(byte input) throws XMLSignatureException {
try {
this._signatureAlgorithm.update(input);
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
}
}
try {
this._signatureAlgorithm.update(input);
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/** @inheritDoc */
protected void engineUpdate(byte buf[], int offset, int len)
throws XMLSignatureException {
try {
this._signatureAlgorithm.update(buf, offset, len);
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/** @inheritDoc */
protected void engineUpdate(byte input) throws XMLSignatureException {
/** @inheritDoc */
protected String engineGetJCEAlgorithmString() {
return this._signatureAlgorithm.getAlgorithm();
}
try {
this._signatureAlgorithm.update(input);
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/** @inheritDoc */
protected String engineGetJCEProviderName() {
return this._signatureAlgorithm.getProvider().getName();
}
/** @inheritDoc */
protected void engineUpdate(byte buf[], int offset, int len)
throws XMLSignatureException {
/** @inheritDoc */
protected void engineSetHMACOutputLength(int HMACOutputLength)
throws XMLSignatureException {
throw new XMLSignatureException
("algorithms.HMACOutputLengthOnlyForHMAC");
}
try {
this._signatureAlgorithm.update(buf, offset, len);
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/** @inheritDoc */
protected void engineInitSign(
Key signingKey, AlgorithmParameterSpec algorithmParameterSpec)
throws XMLSignatureException {
throw new XMLSignatureException(
"algorithms.CannotUseAlgorithmParameterSpecOnRSA");
}
/** @inheritDoc */
protected String engineGetJCEAlgorithmString() {
return this._signatureAlgorithm.getAlgorithm();
}
/**
* Class SignatureRSASHA1
*
* @author $Author: mullan $
* @version $Revision: 1.5 $
*/
public static class SignatureRSASHA1 extends SignatureBaseRSA {
/** @inheritDoc */
protected String engineGetJCEProviderName() {
return this._signatureAlgorithm.getProvider().getName();
}
/**
* Constructor SignatureRSASHA1
*
* @throws XMLSignatureException
*/
public SignatureRSASHA1() throws XMLSignatureException {
super();
}
/** @inheritDoc */
protected void engineSetHMACOutputLength(int HMACOutputLength)
throws XMLSignatureException {
throw new XMLSignatureException("algorithms.HMACOutputLengthOnlyForHMAC");
}
/** @inheritDoc */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1;
}
}
/** @inheritDoc */
protected void engineInitSign(
Key signingKey, AlgorithmParameterSpec algorithmParameterSpec)
throws XMLSignatureException {
throw new XMLSignatureException(
"algorithms.CannotUseAlgorithmParameterSpecOnRSA");
}
/**
* Class SignatureRSASHA256
*
* @author $Author: mullan $
* @version $Revision: 1.5 $
*/
public static class SignatureRSASHA256 extends SignatureBaseRSA {
/**
* Class SignatureRSASHA1
*
* @author $Author: raul $
*/
public static class SignatureRSASHA1 extends SignatureBaseRSA {
/**
* Constructor SignatureRSASHA256
*
* @throws XMLSignatureException
*/
public SignatureRSASHA256() throws XMLSignatureException {
super();
}
/**
* Constructor SignatureRSASHA1
*
* @throws XMLSignatureException
*/
public SignatureRSASHA1() throws XMLSignatureException {
super();
}
/** @inheritDoc */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256;
}
}
/** @inheritDoc */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA1;
}
}
/**
* Class SignatureRSASHA384
*
* @author $Author: mullan $
* @version $Revision: 1.5 $
*/
public static class SignatureRSASHA384 extends SignatureBaseRSA {
/**
* Class SignatureRSASHA256
*
* @author $Author: raul $
*/
public static class SignatureRSASHA256 extends SignatureBaseRSA {
/**
* Constructor SignatureRSASHA384
*
* @throws XMLSignatureException
*/
public SignatureRSASHA384() throws XMLSignatureException {
super();
}
/**
* Constructor SignatureRSASHA256
*
* @throws XMLSignatureException
*/
public SignatureRSASHA256() throws XMLSignatureException {
super();
}
/** @inheritDoc */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384;
}
}
/** @inheritDoc */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256;
}
}
/**
* Class SignatureRSASHA512
*
* @author $Author: mullan $
* @version $Revision: 1.5 $
*/
public static class SignatureRSASHA512 extends SignatureBaseRSA {
/**
* Class SignatureRSASHA384
*
* @author $Author: raul $
*/
public static class SignatureRSASHA384 extends SignatureBaseRSA {
/**
* Constructor SignatureRSASHA512
*
* @throws XMLSignatureException
*/
public SignatureRSASHA512() throws XMLSignatureException {
super();
}
/**
* Constructor SignatureRSASHA384
*
* @throws XMLSignatureException
*/
public SignatureRSASHA384() throws XMLSignatureException {
super();
}
/** @inheritDoc */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512;
}
}
/** @inheritDoc */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA384;
}
}
/**
* Class SignatureRSARIPEMD160
*
* @author $Author: mullan $
* @version $Revision: 1.5 $
*/
public static class SignatureRSARIPEMD160 extends SignatureBaseRSA {
/**
* Class SignatureRSASHA512
*
* @author $Author: raul $
*/
public static class SignatureRSASHA512 extends SignatureBaseRSA {
/**
* Constructor SignatureRSARIPEMD160
*
* @throws XMLSignatureException
*/
public SignatureRSARIPEMD160() throws XMLSignatureException {
super();
}
/**
* Constructor SignatureRSASHA512
*
* @throws XMLSignatureException
*/
public SignatureRSASHA512() throws XMLSignatureException {
super();
}
/** @inheritDoc */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160;
}
}
/** @inheritDoc */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512;
}
}
/**
* Class SignatureRSAMD5
*
* @author $Author: mullan $
* @version $Revision: 1.5 $
*/
public static class SignatureRSAMD5 extends SignatureBaseRSA {
/**
* Class SignatureRSARIPEMD160
*
* @author $Author: raul $
*/
public static class SignatureRSARIPEMD160 extends SignatureBaseRSA {
/**
* Constructor SignatureRSAMD5
*
* @throws XMLSignatureException
*/
public SignatureRSAMD5() throws XMLSignatureException {
super();
}
/**
* Constructor SignatureRSARIPEMD160
*
* @throws XMLSignatureException
*/
public SignatureRSARIPEMD160() throws XMLSignatureException {
super();
}
/** @inheritDoc */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_RSA_RIPEMD160;
}
}
/**
* Class SignatureRSAMD5
*
* @author $Author: raul $
*/
public static class SignatureRSAMD5 extends SignatureBaseRSA {
/**
* Constructor SignatureRSAMD5
*
* @throws XMLSignatureException
*/
public SignatureRSAMD5() throws XMLSignatureException {
super();
}
/** @inheritDoc */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5;
}
}
/** @inheritDoc */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_NOT_RECOMMENDED_RSA_MD5;
}
}
}

View File

@ -20,8 +20,6 @@
*/
package com.sun.org.apache.xml.internal.security.algorithms.implementations;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
@ -39,342 +37,359 @@ import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
import com.sun.org.apache.xml.internal.security.utils.Base64;
import com.sun.org.apache.xml.internal.security.utils.Constants;
/**
*
* @author $Author: vishal $
* @author $Author: mullan $
*/
public class SignatureDSA extends SignatureAlgorithmSpi {
/** {@link java.util.logging} logging facility */
/** {@link java.util.logging} logging facility */
static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(SignatureDSA.class.getName());
/** Field _URI */
public static final String _URI = Constants.SignatureSpecNS + "dsa-sha1";
/** Field _URI */
public static final String _URI = Constants.SignatureSpecNS + "dsa-sha1";
/** Field algorithm */
private java.security.Signature _signatureAlgorithm = null;
/** Field algorithm */
private java.security.Signature _signatureAlgorithm = null;
/**
* Method engineGetURI
*
* @inheritDoc
*/
protected String engineGetURI() {
return SignatureDSA._URI;
}
/**
* Method engineGetURI
*
* @inheritDoc
*/
protected String engineGetURI() {
return SignatureDSA._URI;
}
/**
* Constructor SignatureDSA
*
* @throws XMLSignatureException
*/
public SignatureDSA() throws XMLSignatureException {
/**
* Constructor SignatureDSA
*
* @throws XMLSignatureException
*/
public SignatureDSA() throws XMLSignatureException {
String algorithmID = JCEMapper.translateURItoJCEID(SignatureDSA._URI);
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Created SignatureDSA using " + algorithmID);
String algorithmID = JCEMapper.translateURItoJCEID(SignatureDSA._URI);
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Created SignatureDSA using " + algorithmID);
try {
this._signatureAlgorithm = Signature.getInstance(algorithmID);
} catch (java.security.NoSuchAlgorithmException ex) {
Object[] exArgs = { algorithmID,
ex.getLocalizedMessage() };
String provider = JCEMapper.getProviderId();
try {
if (provider == null) {
this._signatureAlgorithm = Signature.getInstance(algorithmID);
} else {
this._signatureAlgorithm =
Signature.getInstance(algorithmID, provider);
}
} catch (java.security.NoSuchAlgorithmException ex) {
Object[] exArgs = { algorithmID, ex.getLocalizedMessage() };
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
} catch (java.security.NoSuchProviderException ex) {
Object[] exArgs = { algorithmID, ex.getLocalizedMessage() };
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
}
}
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
}
}
/**
* @inheritDoc
*/
protected void engineSetParameter(AlgorithmParameterSpec params)
throws XMLSignatureException {
/**
* @inheritDoc
*/
protected void engineSetParameter(AlgorithmParameterSpec params)
try {
this._signatureAlgorithm.setParameter(params);
} catch (InvalidAlgorithmParameterException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/**
* @inheritDoc
*/
protected boolean engineVerify(byte[] signature)
throws XMLSignatureException {
try {
this._signatureAlgorithm.setParameter(params);
} catch (InvalidAlgorithmParameterException ex) {
throw new XMLSignatureException("empty", ex);
}
}
try {
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Called DSA.verify() on " + Base64.encode(signature));
/**
* @inheritDoc
*/
protected boolean engineVerify(byte[] signature)
byte[] jcebytes = SignatureDSA.convertXMLDSIGtoASN1(signature);
return this._signatureAlgorithm.verify(jcebytes);
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
} catch (IOException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/**
* @inheritDoc
*/
protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
if (!(publicKey instanceof PublicKey)) {
String supplied = publicKey.getClass().getName();
String needed = PublicKey.class.getName();
Object exArgs[] = { supplied, needed };
throw new XMLSignatureException
("algorithms.WrongKeyForThisOperation", exArgs);
}
try {
this._signatureAlgorithm.initVerify((PublicKey) publicKey);
} catch (InvalidKeyException ex) {
// reinstantiate Signature object to work around bug in JDK
// see: http://bugs.sun.com/view_bug.do?bug_id=4953555
Signature sig = this._signatureAlgorithm;
try {
this._signatureAlgorithm = Signature.getInstance
(_signatureAlgorithm.getAlgorithm());
} catch (Exception e) {
// this shouldn't occur, but if it does, restore previous
// Signature
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "Exception when reinstantiating Signature:" + e);
}
this._signatureAlgorithm = sig;
}
throw new XMLSignatureException("empty", ex);
}
}
/**
* @inheritDoc
*/
protected byte[] engineSign() throws XMLSignatureException {
try {
byte jcebytes[] = this._signatureAlgorithm.sign();
return SignatureDSA.convertASN1toXMLDSIG(jcebytes);
} catch (IOException ex) {
throw new XMLSignatureException("empty", ex);
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/**
* @inheritDoc
*/
protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
throws XMLSignatureException {
try {
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Called DSA.verify() on " + Base64.encode(signature));
if (!(privateKey instanceof PrivateKey)) {
String supplied = privateKey.getClass().getName();
String needed = PrivateKey.class.getName();
Object exArgs[] = { supplied, needed };
byte[] jcebytes = SignatureDSA.convertXMLDSIGtoASN1(signature);
throw new XMLSignatureException
("algorithms.WrongKeyForThisOperation", exArgs);
}
return this._signatureAlgorithm.verify(jcebytes);
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
} catch (IOException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/**
* @inheritDoc
*/
protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
if (!(publicKey instanceof PublicKey)) {
String supplied = publicKey.getClass().getName();
String needed = PublicKey.class.getName();
Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation",
exArgs);
}
try {
this._signatureAlgorithm.initVerify((PublicKey) publicKey);
} catch (InvalidKeyException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/**
* @inheritDoc
*/
protected byte[] engineSign() throws XMLSignatureException {
try {
byte jcebytes[] = this._signatureAlgorithm.sign();
return SignatureDSA.convertASN1toXMLDSIG(jcebytes);
} catch (IOException ex) {
throw new XMLSignatureException("empty", ex);
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/**
* @inheritDoc
*/
protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
throws XMLSignatureException {
if (!(privateKey instanceof PrivateKey)) {
String supplied = privateKey.getClass().getName();
String needed = PrivateKey.class.getName();
Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation",
exArgs);
}
try {
this._signatureAlgorithm.initSign((PrivateKey) privateKey,
try {
this._signatureAlgorithm.initSign((PrivateKey) privateKey,
secureRandom);
} catch (InvalidKeyException ex) {
throw new XMLSignatureException("empty", ex);
}
}
} catch (InvalidKeyException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/**
* @inheritDoc
*/
protected void engineInitSign(Key privateKey) throws XMLSignatureException {
/**
* @inheritDoc
*/
protected void engineInitSign(Key privateKey) throws XMLSignatureException {
if (!(privateKey instanceof PrivateKey)) {
String supplied = privateKey.getClass().getName();
String needed = PrivateKey.class.getName();
Object exArgs[] = { supplied, needed };
if (!(privateKey instanceof PrivateKey)) {
String supplied = privateKey.getClass().getName();
String needed = PrivateKey.class.getName();
Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation",
exArgs);
}
throw new XMLSignatureException
("algorithms.WrongKeyForThisOperation", exArgs);
}
try {
this._signatureAlgorithm.initSign((PrivateKey) privateKey);
} catch (InvalidKeyException ex) {
throw new XMLSignatureException("empty", ex);
}
}
try {
this._signatureAlgorithm.initSign((PrivateKey) privateKey);
} catch (InvalidKeyException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/**
* @inheritDoc
*/
protected void engineUpdate(byte[] input) throws XMLSignatureException {
/**
* @inheritDoc
*/
protected void engineUpdate(byte[] input) throws XMLSignatureException {
try {
this._signatureAlgorithm.update(input);
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
}
}
try {
this._signatureAlgorithm.update(input);
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/**
* @inheritDoc
*/
protected void engineUpdate(byte input) throws XMLSignatureException {
try {
this._signatureAlgorithm.update(input);
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/**
* @inheritDoc
*/
protected void engineUpdate(byte input) throws XMLSignatureException {
/**
* @inheritDoc
*/
protected void engineUpdate(byte buf[], int offset, int len)
throws XMLSignatureException {
try {
this._signatureAlgorithm.update(buf, offset, len);
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
}
}
try {
this._signatureAlgorithm.update(input);
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/**
* Method engineGetJCEAlgorithmString
*
* @inheritDoc
*/
protected String engineGetJCEAlgorithmString() {
return this._signatureAlgorithm.getAlgorithm();
}
/**
* @inheritDoc
*/
protected void engineUpdate(byte buf[], int offset, int len)
throws XMLSignatureException {
/**
* Method engineGetJCEProviderName
*
* @inheritDoc
*/
protected String engineGetJCEProviderName() {
return this._signatureAlgorithm.getProvider().getName();
}
try {
this._signatureAlgorithm.update(buf, offset, len);
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/**
* Method engineGetJCEAlgorithmString
*
* @inheritDoc
*/
protected String engineGetJCEAlgorithmString() {
return this._signatureAlgorithm.getAlgorithm();
}
/**
* Method engineGetJCEProviderName
*
* @inheritDoc
*/
protected String engineGetJCEProviderName() {
return this._signatureAlgorithm.getProvider().getName();
}
/**
* Converts an ASN.1 DSA value to a XML Signature DSA Value.
*
* The JAVA JCE DSA Signature algorithm creates ASN.1 encoded (r,s) value
* pairs; the XML Signature requires the core BigInteger values.
*
* @param asn1Bytes
* @return the decode bytes
*
* @throws IOException
* @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
*/
private static byte[] convertASN1toXMLDSIG(byte asn1Bytes[])
/**
* Converts an ASN.1 DSA value to a XML Signature DSA Value.
*
* The JAVA JCE DSA Signature algorithm creates ASN.1 encoded (r,s) value
* pairs; the XML Signature requires the core BigInteger values.
*
* @param asn1Bytes
* @return the decode bytes
*
* @throws IOException
* @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
*/
private static byte[] convertASN1toXMLDSIG(byte asn1Bytes[])
throws IOException {
byte rLength = asn1Bytes[3];
int i;
byte rLength = asn1Bytes[3];
int i;
for (i = rLength; (i > 0) && (asn1Bytes[(4 + rLength) - i] == 0); i--);
for (i = rLength; (i > 0) && (asn1Bytes[(4 + rLength) - i] == 0); i--);
byte sLength = asn1Bytes[5 + rLength];
int j;
byte sLength = asn1Bytes[5 + rLength];
int j;
for (j = sLength;
for (j = sLength;
(j > 0) && (asn1Bytes[(6 + rLength + sLength) - j] == 0); j--);
if ((asn1Bytes[0] != 48) || (asn1Bytes[1] != asn1Bytes.length - 2)
if ((asn1Bytes[0] != 48) || (asn1Bytes[1] != asn1Bytes.length - 2)
|| (asn1Bytes[2] != 2) || (i > 20)
|| (asn1Bytes[4 + rLength] != 2) || (j > 20)) {
throw new IOException("Invalid ASN.1 format of DSA signature");
}
byte xmldsigBytes[] = new byte[40];
throw new IOException("Invalid ASN.1 format of DSA signature");
}
byte xmldsigBytes[] = new byte[40];
System.arraycopy(asn1Bytes, (4 + rLength) - i, xmldsigBytes, 20 - i,
System.arraycopy(asn1Bytes, (4 + rLength) - i, xmldsigBytes, 20 - i,
i);
System.arraycopy(asn1Bytes, (6 + rLength + sLength) - j, xmldsigBytes,
System.arraycopy(asn1Bytes, (6 + rLength + sLength) - j, xmldsigBytes,
40 - j, j);
return xmldsigBytes;
}
return xmldsigBytes;
}
/**
* Converts a XML Signature DSA Value to an ASN.1 DSA value.
*
* The JAVA JCE DSA Signature algorithm creates ASN.1 encoded (r,s) value
* pairs; the XML Signature requires the core BigInteger values.
*
* @param xmldsigBytes
* @return the encoded ASN.1 bytes
*
* @throws IOException
* @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
*/
private static byte[] convertXMLDSIGtoASN1(byte xmldsigBytes[])
/**
* Converts a XML Signature DSA Value to an ASN.1 DSA value.
*
* The JAVA JCE DSA Signature algorithm creates ASN.1 encoded (r,s) value
* pairs; the XML Signature requires the core BigInteger values.
*
* @param xmldsigBytes
* @return the encoded ASN.1 bytes
*
* @throws IOException
* @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
*/
private static byte[] convertXMLDSIGtoASN1(byte xmldsigBytes[])
throws IOException {
if (xmldsigBytes.length != 40) {
throw new IOException("Invalid XMLDSIG format of DSA signature");
}
if (xmldsigBytes.length != 40) {
throw new IOException("Invalid XMLDSIG format of DSA signature");
}
int i;
int i;
for (i = 20; (i > 0) && (xmldsigBytes[20 - i] == 0); i--);
for (i = 20; (i > 0) && (xmldsigBytes[20 - i] == 0); i--);
int j = i;
int j = i;
if (xmldsigBytes[20 - i] < 0) {
if (xmldsigBytes[20 - i] < 0) {
j += 1;
}
}
int k;
int k;
for (k = 20; (k > 0) && (xmldsigBytes[40 - k] == 0); k--);
for (k = 20; (k > 0) && (xmldsigBytes[40 - k] == 0); k--);
int l = k;
int l = k;
if (xmldsigBytes[40 - k] < 0) {
l += 1;
}
if (xmldsigBytes[40 - k] < 0) {
l += 1;
}
byte asn1Bytes[] = new byte[6 + j + l];
byte asn1Bytes[] = new byte[6 + j + l];
asn1Bytes[0] = 48;
asn1Bytes[1] = (byte) (4 + j + l);
asn1Bytes[2] = 2;
asn1Bytes[3] = (byte) j;
asn1Bytes[0] = 48;
asn1Bytes[1] = (byte) (4 + j + l);
asn1Bytes[2] = 2;
asn1Bytes[3] = (byte) j;
System.arraycopy(xmldsigBytes, 20 - i, asn1Bytes, (4 + j) - i, i);
System.arraycopy(xmldsigBytes, 20 - i, asn1Bytes, (4 + j) - i, i);
asn1Bytes[4 + j] = 2;
asn1Bytes[5 + j] = (byte) l;
asn1Bytes[4 + j] = 2;
asn1Bytes[5 + j] = (byte) l;
System.arraycopy(xmldsigBytes, 40 - k, asn1Bytes, (6 + j + l) - k, k);
System.arraycopy(xmldsigBytes, 40 - k, asn1Bytes, (6 + j + l) - k, k);
return asn1Bytes;
}
return asn1Bytes;
}
/**
* Method engineSetHMACOutputLength
*
* @param HMACOutputLength
* @throws XMLSignatureException
*/
protected void engineSetHMACOutputLength(int HMACOutputLength)
throws XMLSignatureException {
throw new XMLSignatureException("algorithms.HMACOutputLengthOnlyForHMAC");
}
/**
* Method engineSetHMACOutputLength
*
* @param HMACOutputLength
* @throws XMLSignatureException
*/
protected void engineSetHMACOutputLength(int HMACOutputLength)
throws XMLSignatureException {
throw new XMLSignatureException(
"algorithms.HMACOutputLengthOnlyForHMAC");
}
/**
* Method engineInitSign
*
* @param signingKey
* @param algorithmParameterSpec
* @throws XMLSignatureException
*/
protected void engineInitSign(
Key signingKey, AlgorithmParameterSpec algorithmParameterSpec)
throws XMLSignatureException {
throw new XMLSignatureException(
"algorithms.CannotUseAlgorithmParameterSpecOnDSA");
}
/**
* Method engineInitSign
*
* @param signingKey
* @param algorithmParameterSpec
* @throws XMLSignatureException
*/
protected void engineInitSign(
Key signingKey, AlgorithmParameterSpec algorithmParameterSpec)
throws XMLSignatureException {
throw new XMLSignatureException(
"algorithms.CannotUseAlgorithmParameterSpecOnDSA");
}
}

View File

@ -0,0 +1,384 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.sun.org.apache.xml.internal.security.algorithms.implementations;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchProviderException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.Signature;
import java.security.SignatureException;
import java.security.spec.AlgorithmParameterSpec;
import com.sun.org.apache.xml.internal.security.algorithms.JCEMapper;
import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithmSpi;
import com.sun.org.apache.xml.internal.security.signature.XMLSignature;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
import com.sun.org.apache.xml.internal.security.utils.Base64;
/**
*
* @author $Author: mullan $
*/
public abstract class SignatureECDSA extends SignatureAlgorithmSpi {
/** {@link java.util.logging} logging facility */
static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(SignatureECDSA.class.getName());
/** @inheritDoc */
public abstract String engineGetURI();
/** Field algorithm */
private java.security.Signature _signatureAlgorithm = null;
/**
* Converts an ASN.1 ECDSA value to a XML Signature ECDSA Value.
*
* The JAVA JCE ECDSA Signature algorithm creates ASN.1 encoded (r,s) value
* pairs; the XML Signature requires the core BigInteger values.
*
* @param asn1Bytes
* @return the decode bytes
*
* @throws IOException
* @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
* @see <A HREF="ftp://ftp.rfc-editor.org/in-notes/rfc4050.txt">3.3. ECDSA Signatures</A>
*/
private static byte[] convertASN1toXMLDSIG(byte asn1Bytes[])
throws IOException {
byte rLength = asn1Bytes[3];
int i;
for (i = rLength; (i > 0) && (asn1Bytes[(4 + rLength) - i] == 0); i--);
byte sLength = asn1Bytes[5 + rLength];
int j;
for (j = sLength;
(j > 0) && (asn1Bytes[(6 + rLength + sLength) - j] == 0); j--);
if ((asn1Bytes[0] != 48) || (asn1Bytes[1] != asn1Bytes.length - 2)
|| (asn1Bytes[2] != 2) || (i > 24)
|| (asn1Bytes[4 + rLength] != 2) || (j > 24)) {
throw new IOException("Invalid ASN.1 format of ECDSA signature");
}
byte xmldsigBytes[] = new byte[48];
System.arraycopy(asn1Bytes, (4 + rLength) - i, xmldsigBytes, 24 - i,
i);
System.arraycopy(asn1Bytes, (6 + rLength + sLength) - j, xmldsigBytes,
48 - j, j);
return xmldsigBytes;
}
/**
* Converts a XML Signature ECDSA Value to an ASN.1 DSA value.
*
* The JAVA JCE ECDSA Signature algorithm creates ASN.1 encoded (r,s) value
* pairs; the XML Signature requires the core BigInteger values.
*
* @param xmldsigBytes
* @return the encoded ASN.1 bytes
*
* @throws IOException
* @see <A HREF="http://www.w3.org/TR/xmldsig-core/#dsa-sha1">6.4.1 DSA</A>
* @see <A HREF="ftp://ftp.rfc-editor.org/in-notes/rfc4050.txt">3.3. ECDSA Signatures</A>
*/
private static byte[] convertXMLDSIGtoASN1(byte xmldsigBytes[])
throws IOException {
if (xmldsigBytes.length != 48) {
throw new IOException("Invalid XMLDSIG format of ECDSA signature");
}
int i;
for (i = 24; (i > 0) && (xmldsigBytes[24 - i] == 0); i--);
int j = i;
if (xmldsigBytes[24 - i] < 0) {
j += 1;
}
int k;
for (k = 24; (k > 0) && (xmldsigBytes[48 - k] == 0); k--);
int l = k;
if (xmldsigBytes[48 - k] < 0) {
l += 1;
}
byte asn1Bytes[] = new byte[6 + j + l];
asn1Bytes[0] = 48;
asn1Bytes[1] = (byte) (4 + j + l);
asn1Bytes[2] = 2;
asn1Bytes[3] = (byte) j;
System.arraycopy(xmldsigBytes, 24 - i, asn1Bytes, (4 + j) - i, i);
asn1Bytes[4 + j] = 2;
asn1Bytes[5 + j] = (byte) l;
System.arraycopy(xmldsigBytes, 48 - k, asn1Bytes, (6 + j + l) - k, k);
return asn1Bytes;
}
/**
* Constructor SignatureRSA
*
* @throws XMLSignatureException
*/
public SignatureECDSA() throws XMLSignatureException {
String algorithmID = JCEMapper.translateURItoJCEID(this.engineGetURI());
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Created SignatureECDSA using " + algorithmID);
String provider=JCEMapper.getProviderId();
try {
if (provider==null) {
this._signatureAlgorithm = Signature.getInstance(algorithmID);
} else {
this._signatureAlgorithm = Signature.getInstance(algorithmID,provider);
}
} catch (java.security.NoSuchAlgorithmException ex) {
Object[] exArgs = { algorithmID,
ex.getLocalizedMessage() };
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
} catch (NoSuchProviderException ex) {
Object[] exArgs = { algorithmID,
ex.getLocalizedMessage() };
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
}
}
/** @inheritDoc */
protected void engineSetParameter(AlgorithmParameterSpec params)
throws XMLSignatureException {
try {
this._signatureAlgorithm.setParameter(params);
} catch (InvalidAlgorithmParameterException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/** @inheritDoc */
protected boolean engineVerify(byte[] signature)
throws XMLSignatureException {
try {
byte[] jcebytes = SignatureECDSA.convertXMLDSIGtoASN1(signature);
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Called ECDSA.verify() on " + Base64.encode(signature));
return this._signatureAlgorithm.verify(jcebytes);
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
} catch (IOException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/** @inheritDoc */
protected void engineInitVerify(Key publicKey) throws XMLSignatureException {
if (!(publicKey instanceof PublicKey)) {
String supplied = publicKey.getClass().getName();
String needed = PublicKey.class.getName();
Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation",
exArgs);
}
try {
this._signatureAlgorithm.initVerify((PublicKey) publicKey);
} catch (InvalidKeyException ex) {
// reinstantiate Signature object to work around bug in JDK
// see: http://bugs.sun.com/view_bug.do?bug_id=4953555
Signature sig = this._signatureAlgorithm;
try {
this._signatureAlgorithm = Signature.getInstance
(_signatureAlgorithm.getAlgorithm());
} catch (Exception e) {
// this shouldn't occur, but if it does, restore previous
// Signature
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "Exception when reinstantiating Signature:" + e);
}
this._signatureAlgorithm = sig;
}
throw new XMLSignatureException("empty", ex);
}
}
/** @inheritDoc */
protected byte[] engineSign() throws XMLSignatureException {
try {
byte jcebytes[] = this._signatureAlgorithm.sign();
return SignatureECDSA.convertASN1toXMLDSIG(jcebytes);
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
} catch (IOException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/** @inheritDoc */
protected void engineInitSign(Key privateKey, SecureRandom secureRandom)
throws XMLSignatureException {
if (!(privateKey instanceof PrivateKey)) {
String supplied = privateKey.getClass().getName();
String needed = PrivateKey.class.getName();
Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation",
exArgs);
}
try {
this._signatureAlgorithm.initSign((PrivateKey) privateKey,
secureRandom);
} catch (InvalidKeyException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/** @inheritDoc */
protected void engineInitSign(Key privateKey) throws XMLSignatureException {
if (!(privateKey instanceof PrivateKey)) {
String supplied = privateKey.getClass().getName();
String needed = PrivateKey.class.getName();
Object exArgs[] = { supplied, needed };
throw new XMLSignatureException("algorithms.WrongKeyForThisOperation",
exArgs);
}
try {
this._signatureAlgorithm.initSign((PrivateKey) privateKey);
} catch (InvalidKeyException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/** @inheritDoc */
protected void engineUpdate(byte[] input) throws XMLSignatureException {
try {
this._signatureAlgorithm.update(input);
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/** @inheritDoc */
protected void engineUpdate(byte input) throws XMLSignatureException {
try {
this._signatureAlgorithm.update(input);
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/** @inheritDoc */
protected void engineUpdate(byte buf[], int offset, int len)
throws XMLSignatureException {
try {
this._signatureAlgorithm.update(buf, offset, len);
} catch (SignatureException ex) {
throw new XMLSignatureException("empty", ex);
}
}
/** @inheritDoc */
protected String engineGetJCEAlgorithmString() {
return this._signatureAlgorithm.getAlgorithm();
}
/** @inheritDoc */
protected String engineGetJCEProviderName() {
return this._signatureAlgorithm.getProvider().getName();
}
/** @inheritDoc */
protected void engineSetHMACOutputLength(int HMACOutputLength)
throws XMLSignatureException {
throw new XMLSignatureException("algorithms.HMACOutputLengthOnlyForHMAC");
}
/** @inheritDoc */
protected void engineInitSign(
Key signingKey, AlgorithmParameterSpec algorithmParameterSpec)
throws XMLSignatureException {
throw new XMLSignatureException(
"algorithms.CannotUseAlgorithmParameterSpecOnRSA");
}
/**
* Class SignatureRSASHA1
*
* @author $Author: mullan $
* @version $Revision: 1.2 $
*/
public static class SignatureECDSASHA1 extends SignatureECDSA {
/**
* Constructor SignatureRSASHA1
*
* @throws XMLSignatureException
*/
public SignatureECDSASHA1() throws XMLSignatureException {
super();
}
/** @inheritDoc */
public String engineGetURI() {
return XMLSignature.ALGO_ID_SIGNATURE_ECDSA_SHA1;
}
}
}

View File

@ -2,7 +2,6 @@
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
*

View File

@ -3,7 +3,7 @@
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
* Copyright 1999-2008 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -20,8 +20,6 @@
*/
package com.sun.org.apache.xml.internal.security.c14n;
import java.io.ByteArrayInputStream;
import java.io.OutputStream;
import java.util.HashMap;
@ -37,318 +35,326 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
/**
*
*
* @author Christian Geuer-Pollmann
*/
public class Canonicalizer {
//J-
/** The output encoding of canonicalized data */
public static final String ENCODING = "UTF8";
/** The output encoding of canonicalized data */
public static final String ENCODING = "UTF8";
/**
* XPath Expresion for selecting every node and continuos comments joined in only one node
/**
* XPath Expresion for selecting every node and continuous comments joined
* in only one node
*/
public static final String XPATH_C14N_WITH_COMMENTS_SINGLE_NODE = "(.//. | .//@* | .//namespace::*)";
public static final String XPATH_C14N_WITH_COMMENTS_SINGLE_NODE =
"(.//. | .//@* | .//namespace::*)";
/**
/**
* The URL defined in XML-SEC Rec for inclusive c14n <b>without</b> comments.
*/
public static final String ALGO_ID_C14N_OMIT_COMMENTS = "http://www.w3.org/TR/2001/REC-xml-c14n-20010315";
/**
* The URL defined in XML-SEC Rec for inclusive c14n <b>with</b> comments.
*/
public static final String ALGO_ID_C14N_WITH_COMMENTS = ALGO_ID_C14N_OMIT_COMMENTS + "#WithComments";
/**
* The URL defined in XML-SEC Rec for exclusive c14n <b>without</b> comments.
*/
public static final String ALGO_ID_C14N_EXCL_OMIT_COMMENTS = "http://www.w3.org/2001/10/xml-exc-c14n#";
/**
* The URL defined in XML-SEC Rec for exclusive c14n <b>with</b> comments.
*/
public static final String ALGO_ID_C14N_EXCL_WITH_COMMENTS = ALGO_ID_C14N_EXCL_OMIT_COMMENTS + "WithComments";
public static final String ALGO_ID_C14N_OMIT_COMMENTS =
"http://www.w3.org/TR/2001/REC-xml-c14n-20010315";
/**
* The URL defined in XML-SEC Rec for inclusive c14n <b>with</b> comments.
*/
public static final String ALGO_ID_C14N_WITH_COMMENTS =
ALGO_ID_C14N_OMIT_COMMENTS + "#WithComments";
/**
* The URL defined in XML-SEC Rec for exclusive c14n <b>without</b> comments.
*/
public static final String ALGO_ID_C14N_EXCL_OMIT_COMMENTS =
"http://www.w3.org/2001/10/xml-exc-c14n#";
/**
* The URL defined in XML-SEC Rec for exclusive c14n <b>with</b> comments.
*/
public static final String ALGO_ID_C14N_EXCL_WITH_COMMENTS =
ALGO_ID_C14N_EXCL_OMIT_COMMENTS + "WithComments";
/**
* The URI for inclusive c14n 1.1 <b>without</b> comments.
*/
public static final String ALGO_ID_C14N11_OMIT_COMMENTS =
"http://www.w3.org/2006/12/xml-c14n11";
/**
* The URI for inclusive c14n 1.1 <b>with</b> comments.
*/
public static final String ALGO_ID_C14N11_WITH_COMMENTS =
ALGO_ID_C14N11_OMIT_COMMENTS + "#WithComments";
static boolean _alreadyInitialized = false;
static Map _canonicalizerHash = null;
static boolean _alreadyInitialized = false;
static Map _canonicalizerHash = null;
protected CanonicalizerSpi canonicalizerSpi = null;
//J+
protected CanonicalizerSpi canonicalizerSpi = null;
/**
* Method init
*
*/
public static void init() {
/**
* Method init
*
*/
public static void init() {
if (!Canonicalizer._alreadyInitialized) {
Canonicalizer._canonicalizerHash = new HashMap(10);
Canonicalizer._alreadyInitialized = true;
}
}
if (!Canonicalizer._alreadyInitialized) {
Canonicalizer._canonicalizerHash = new HashMap(10);
Canonicalizer._alreadyInitialized = true;
}
}
/**
* Constructor Canonicalizer
*
* @param algorithmURI
* @throws InvalidCanonicalizerException
*/
private Canonicalizer(String algorithmURI)
/**
* Constructor Canonicalizer
*
* @param algorithmURI
* @throws InvalidCanonicalizerException
*/
private Canonicalizer(String algorithmURI)
throws InvalidCanonicalizerException {
try {
Class implementingClass = getImplementingClass(algorithmURI);
try {
Class implementingClass = getImplementingClass(algorithmURI);
this.canonicalizerSpi =
(CanonicalizerSpi) implementingClass.newInstance();
this.canonicalizerSpi.reset=true;
} catch (Exception e) {
Object exArgs[] = { algorithmURI };
this.canonicalizerSpi =
(CanonicalizerSpi) implementingClass.newInstance();
this.canonicalizerSpi.reset=true;
} catch (Exception e) {
Object exArgs[] = { algorithmURI };
throw new InvalidCanonicalizerException(
"signature.Canonicalizer.UnknownCanonicalizer", exArgs);
}
}
throw new InvalidCanonicalizerException(
"signature.Canonicalizer.UnknownCanonicalizer", exArgs);
}
}
/**
* Method getInstance
*
* @param algorithmURI
* @return a Conicicalizer instance ready for the job
* @throws InvalidCanonicalizerException
*/
public static final Canonicalizer getInstance(String algorithmURI)
/**
* Method getInstance
*
* @param algorithmURI
* @return a Conicicalizer instance ready for the job
* @throws InvalidCanonicalizerException
*/
public static final Canonicalizer getInstance(String algorithmURI)
throws InvalidCanonicalizerException {
Canonicalizer c14nizer = new Canonicalizer(algorithmURI);
Canonicalizer c14nizer = new Canonicalizer(algorithmURI);
return c14nizer;
}
return c14nizer;
}
/**
* Method register
*
* @param algorithmURI
* @param implementingClass
* @throws AlgorithmAlreadyRegisteredException
*/
public static void register(String algorithmURI, String implementingClass)
/**
* Method register
*
* @param algorithmURI
* @param implementingClass
* @throws AlgorithmAlreadyRegisteredException
*/
public static void register(String algorithmURI, String implementingClass)
throws AlgorithmAlreadyRegisteredException {
// check whether URI is already registered
Class registeredClass = getImplementingClass(algorithmURI);
// check whether URI is already registered
Class registeredClass = getImplementingClass(algorithmURI);
if (registeredClass != null) {
Object exArgs[] = { algorithmURI, registeredClass };
if (registeredClass != null) {
Object exArgs[] = { algorithmURI, registeredClass };
throw new AlgorithmAlreadyRegisteredException(
"algorithm.alreadyRegistered", exArgs);
}
try {
_canonicalizerHash.put(algorithmURI, Class.forName(implementingClass));
} catch (ClassNotFoundException e) {
throw new RuntimeException("c14n class not found");
throw new AlgorithmAlreadyRegisteredException(
"algorithm.alreadyRegistered", exArgs);
}
}
/**
* Method getURI
*
* @return the URI defined for this c14n instance.
*/
public final String getURI() {
return this.canonicalizerSpi.engineGetURI();
}
try {
_canonicalizerHash.put(algorithmURI, Class.forName(implementingClass));
} catch (ClassNotFoundException e) {
throw new RuntimeException("c14n class not found");
}
}
/**
* Method getIncludeComments
*
* @return true if the c14n respect the comments.
*/
public boolean getIncludeComments() {
return this.canonicalizerSpi.engineGetIncludeComments();
}
/**
* Method getURI
*
* @return the URI defined for this c14n instance.
*/
public final String getURI() {
return this.canonicalizerSpi.engineGetURI();
}
/**
* This method tries to canonicalize the given bytes. It's possible to even
* canonicalize non-wellformed sequences if they are well-formed after being
* wrapped with a <CODE>&gt;a&lt;...&gt;/a&lt;</CODE>.
*
* @param inputBytes
* @return the result of the conicalization.
* @throws CanonicalizationException
* @throws java.io.IOException
* @throws javax.xml.parsers.ParserConfigurationException
* @throws org.xml.sax.SAXException
*/
public byte[] canonicalize(byte[] inputBytes)
/**
* Method getIncludeComments
*
* @return true if the c14n respect the comments.
*/
public boolean getIncludeComments() {
return this.canonicalizerSpi.engineGetIncludeComments();
}
/**
* This method tries to canonicalize the given bytes. It's possible to even
* canonicalize non-wellformed sequences if they are well-formed after being
* wrapped with a <CODE>&gt;a&lt;...&gt;/a&lt;</CODE>.
*
* @param inputBytes
* @return the result of the conicalization.
* @throws CanonicalizationException
* @throws java.io.IOException
* @throws javax.xml.parsers.ParserConfigurationException
* @throws org.xml.sax.SAXException
*/
public byte[] canonicalize(byte[] inputBytes)
throws javax.xml.parsers.ParserConfigurationException,
java.io.IOException, org.xml.sax.SAXException,
CanonicalizationException {
ByteArrayInputStream bais = new ByteArrayInputStream(inputBytes);
InputSource in = new InputSource(bais);
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
ByteArrayInputStream bais = new ByteArrayInputStream(inputBytes);
InputSource in = new InputSource(bais);
DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance();
dfactory.setNamespaceAware(true);
dfactory.setNamespaceAware(true);
// needs to validate for ID attribute nomalization
dfactory.setValidating(true);
// needs to validate for ID attribute nomalization
dfactory.setValidating(true);
DocumentBuilder db = dfactory.newDocumentBuilder();
DocumentBuilder db = dfactory.newDocumentBuilder();
/*
* for some of the test vectors from the specification,
* there has to be a validatin parser for ID attributes, default
* attribute values, NMTOKENS, etc.
* Unfortunaltely, the test vectors do use different DTDs or
* even no DTD. So Xerces 1.3.1 fires many warnings about using
* ErrorHandlers.
*
* Text from the spec:
*
* The input octet stream MUST contain a well-formed XML document,
* but the input need not be validated. However, the attribute
* value normalization and entity reference resolution MUST be
* performed in accordance with the behaviors of a validating
* XML processor. As well, nodes for default attributes (declared
* in the ATTLIST with an AttValue but not specified) are created
* in each element. Thus, the declarations in the document type
* declaration are used to help create the canonical form, even
* though the document type declaration is not retained in the
* canonical form.
*
*/
db.setErrorHandler(new com.sun.org.apache.xml.internal.security.utils
.IgnoreAllErrorHandler());
/*
* for some of the test vectors from the specification,
* there has to be a validatin parser for ID attributes, default
* attribute values, NMTOKENS, etc.
* Unfortunaltely, the test vectors do use different DTDs or
* even no DTD. So Xerces 1.3.1 fires many warnings about using
* ErrorHandlers.
*
* Text from the spec:
*
* The input octet stream MUST contain a well-formed XML document,
* but the input need not be validated. However, the attribute
* value normalization and entity reference resolution MUST be
* performed in accordance with the behaviors of a validating
* XML processor. As well, nodes for default attributes (declared
* in the ATTLIST with an AttValue but not specified) are created
* in each element. Thus, the declarations in the document type
* declaration are used to help create the canonical form, even
* though the document type declaration is not retained in the
* canonical form.
*
*/
db.setErrorHandler(new com.sun.org.apache.xml.internal.security.utils
.IgnoreAllErrorHandler());
Document document = db.parse(in);
byte result[] = this.canonicalizeSubtree(document);
Document document = db.parse(in);
byte result[] = this.canonicalizeSubtree(document);
return result;
}
return result;
}
/**
* Canonicalizes the subtree rooted by <CODE>node</CODE>.
*
* @param node The node to canicalize
* @return the result of the c14n.
*
* @throws CanonicalizationException
*/
public byte[] canonicalizeSubtree(Node node)
/**
* Canonicalizes the subtree rooted by <CODE>node</CODE>.
*
* @param node The node to canicalize
* @return the result of the c14n.
*
* @throws CanonicalizationException
*/
public byte[] canonicalizeSubtree(Node node)
throws CanonicalizationException {
return this.canonicalizerSpi.engineCanonicalizeSubTree(node);
}
return this.canonicalizerSpi.engineCanonicalizeSubTree(node);
}
/**
* Canonicalizes the subtree rooted by <CODE>node</CODE>.
*
* @param node
* @param inclusiveNamespaces
* @return the result of the c14n.
* @throws CanonicalizationException
*/
public byte[] canonicalizeSubtree(Node node, String inclusiveNamespaces)
/**
* Canonicalizes the subtree rooted by <CODE>node</CODE>.
*
* @param node
* @param inclusiveNamespaces
* @return the result of the c14n.
* @throws CanonicalizationException
*/
public byte[] canonicalizeSubtree(Node node, String inclusiveNamespaces)
throws CanonicalizationException {
return this.canonicalizerSpi.engineCanonicalizeSubTree(node,
return this.canonicalizerSpi.engineCanonicalizeSubTree(node,
inclusiveNamespaces);
}
}
/**
* Canonicalizes an XPath node set. The <CODE>xpathNodeSet</CODE> is treated
* as a list of XPath nodes, not as a list of subtrees.
*
* @param xpathNodeSet
* @return the result of the c14n.
* @throws CanonicalizationException
*/
public byte[] canonicalizeXPathNodeSet(NodeList xpathNodeSet)
/**
* Canonicalizes an XPath node set. The <CODE>xpathNodeSet</CODE> is treated
* as a list of XPath nodes, not as a list of subtrees.
*
* @param xpathNodeSet
* @return the result of the c14n.
* @throws CanonicalizationException
*/
public byte[] canonicalizeXPathNodeSet(NodeList xpathNodeSet)
throws CanonicalizationException {
return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet);
}
return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet);
}
/**
* Canonicalizes an XPath node set. The <CODE>xpathNodeSet</CODE> is treated
* as a list of XPath nodes, not as a list of subtrees.
*
* @param xpathNodeSet
* @param inclusiveNamespaces
* @return the result of the c14n.
* @throws CanonicalizationException
*/
public byte[] canonicalizeXPathNodeSet(
/**
* Canonicalizes an XPath node set. The <CODE>xpathNodeSet</CODE> is treated
* as a list of XPath nodes, not as a list of subtrees.
*
* @param xpathNodeSet
* @param inclusiveNamespaces
* @return the result of the c14n.
* @throws CanonicalizationException
*/
public byte[] canonicalizeXPathNodeSet(
NodeList xpathNodeSet, String inclusiveNamespaces)
throws CanonicalizationException {
return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet,
return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet,
inclusiveNamespaces);
}
}
/**
* Canonicalizes an XPath node set.
*
* @param xpathNodeSet
* @return the result of the c14n.
* @throws CanonicalizationException
*/
public byte[] canonicalizeXPathNodeSet(Set xpathNodeSet)
/**
* Canonicalizes an XPath node set.
*
* @param xpathNodeSet
* @return the result of the c14n.
* @throws CanonicalizationException
*/
public byte[] canonicalizeXPathNodeSet(Set xpathNodeSet)
throws CanonicalizationException {
return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet);
}
return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet);
}
/**
* Canonicalizes an XPath node set.
*
* @param xpathNodeSet
* @param inclusiveNamespaces
* @return the result of the c14n.
* @throws CanonicalizationException
*/
public byte[] canonicalizeXPathNodeSet(
Set xpathNodeSet, String inclusiveNamespaces)
throws CanonicalizationException {
return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet,
inclusiveNamespaces);
}
/**
* Canonicalizes an XPath node set.
*
* @param xpathNodeSet
* @param inclusiveNamespaces
* @return the result of the c14n.
* @throws CanonicalizationException
*/
public byte[] canonicalizeXPathNodeSet(Set xpathNodeSet,
String inclusiveNamespaces) throws CanonicalizationException {
return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet,
inclusiveNamespaces);
}
/**
* Sets the writter where the cannocalization ends. ByteArrayOutputStream if
* none is setted.
* @param os
*/
public void setWriter(OutputStream os) {
this.canonicalizerSpi.setWriter(os);
}
/**
* Sets the writer where the canonicalization ends. ByteArrayOutputStream
* if none is set.
* @param os
*/
public void setWriter(OutputStream os) {
this.canonicalizerSpi.setWriter(os);
}
/**
* Returns the name of the implementing {@link CanonicalizerSpi} class
*
* @return the name of the implementing {@link CanonicalizerSpi} class
*/
public String getImplementingCanonicalizerClass() {
return this.canonicalizerSpi.getClass().getName();
}
/**
* Returns the name of the implementing {@link CanonicalizerSpi} class
*
* @return the name of the implementing {@link CanonicalizerSpi} class
*/
public String getImplementingCanonicalizerClass() {
return this.canonicalizerSpi.getClass().getName();
}
/**
* Method getImplementingClass
*
* @param URI
* @return the name of the class that implements the give URI
*/
private static Class getImplementingClass(String URI) {
return (Class) _canonicalizerHash.get(URI);
}
/**
* Method getImplementingClass
*
* @param URI
* @return the name of the class that implements the given URI
*/
private static Class getImplementingClass(String URI) {
return (Class) _canonicalizerHash.get(URI);
}
/**
* Set the canonicalizator behaviour to not reset.
*
*/
public void notReset() {
this.canonicalizerSpi.reset=false;
}
/**
* Set the canonicalizer behaviour to not reset.
*/
public void notReset() {
this.canonicalizerSpi.reset = false;
}
}

View File

@ -2,7 +2,6 @@
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
*

View File

@ -2,7 +2,6 @@
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
@ -21,17 +20,17 @@
*/
package com.sun.org.apache.xml.internal.security.c14n.helper;
import com.sun.org.apache.xml.internal.security.utils.Constants;
import org.w3c.dom.Attr;
import java.io.Serializable;
import java.util.Comparator;
/**
* Compares two attributes based on the C14n specification.
*
* <UL>
* <LI>Namespace nodes have a lesser document order position than attribute nodes.
* <LI>Namespace nodes have a lesser document order position than attribute
* nodes.
* <LI> An element's namespace nodes are sorted lexicographically by
* local name (the default namespace node, if one exists, has no
* local name and is therefore lexicographically least).
@ -40,104 +39,89 @@ import org.w3c.dom.Attr;
* key (an empty namespace URI is lexicographically least).
* </UL>
*
* $todo$ Should we implement java.util.Comparator and import java.util.Arrays to use Arrays.sort(intarray);
* @author Christian Geuer-Pollmann
*/
public class AttrCompare implements java.util.Comparator {
public class AttrCompare implements Comparator, Serializable {
private final int ATTR0_BEFORE_ATTR1 = -1;
private final int ATTR1_BEFORE_ATTR0 = 1;
private final static long serialVersionUID = -7113259629930576230L;
private final static int ATTR0_BEFORE_ATTR1 = -1;
private final static int ATTR1_BEFORE_ATTR0 = 1;
private final static String XMLNS=Constants.NamespaceSpecNS;
private final static String XMLNS=Constants.NamespaceSpecNS;
/**
* Compares two attributes based on the C14n specification.
*
* <UL>
* <LI>Namespace nodes have a lesser document order position than attribute nodes.
* <LI> An element's namespace nodes are sorted lexicographically by
* local name (the default namespace node, if one exists, has no
* local name and is therefore lexicographically least).
* <LI> An element's attribute nodes are sorted lexicographically with
* namespace URI as the primary key and local name as the secondary
* key (an empty namespace URI is lexicographically least).
* </UL>
*
* @param obj0 casted Attr
* @param obj1 casted Attr
* @return returns a negative integer, zero, or a positive integer as obj0 is less than, equal to, or greater than obj1
*
*/
public int compare(Object obj0, Object obj1) {
/**
* Compares two attributes based on the C14n specification.
*
* <UL>
* <LI>Namespace nodes have a lesser document order position than
* attribute nodes.
* <LI> An element's namespace nodes are sorted lexicographically by
* local name (the default namespace node, if one exists, has no
* local name and is therefore lexicographically least).
* <LI> An element's attribute nodes are sorted lexicographically with
* namespace URI as the primary key and local name as the secondary
* key (an empty namespace URI is lexicographically least).
* </UL>
*
* @param obj0 casted Attr
* @param obj1 casted Attr
* @return returns a negative integer, zero, or a positive integer as
* obj0 is less than, equal to, or greater than obj1
*
*/
public int compare(Object obj0, Object obj1) {
Attr attr0 = (Attr) obj0;
Attr attr1 = (Attr) obj1;
String namespaceURI0 = attr0.getNamespaceURI();
String namespaceURI1 = attr1.getNamespaceURI();
Attr attr0 = (Attr) obj0;
Attr attr1 = (Attr) obj1;
String namespaceURI0 = attr0.getNamespaceURI();
String namespaceURI1 = attr1.getNamespaceURI();
boolean isNamespaceAttr0 =
XMLNS.equals(namespaceURI0);
boolean isNamespaceAttr1 =
XMLNS.equals(namespaceURI1);
boolean isNamespaceAttr0 = XMLNS==namespaceURI0;
boolean isNamespaceAttr1 = XMLNS==namespaceURI1;
if (isNamespaceAttr0) {
if (isNamespaceAttr1) {
if (isNamespaceAttr0) {
if (isNamespaceAttr1) {
// both are namespaces
String localname0 = attr0.getLocalName();
String localname1 = attr1.getLocalName();
// both are namespaces
String localname0 = attr0.getLocalName();
String localname1 = attr1.getLocalName();
if (localname0.equals("xmlns")) {
localname0 = "";
}
if (localname0.equals("xmlns")) {
localname0 = "";
if (localname1.equals("xmlns")) {
localname1 = "";
}
return localname0.compareTo(localname1);
}
// attr0 is a namespace, attr1 is not
return ATTR0_BEFORE_ATTR1;
}
if (localname1.equals("xmlns")) {
localname1 = "";
}
return localname0.compareTo(localname1);
}
// attr0 is a namespace, attr1 is not
return ATTR0_BEFORE_ATTR1;
}
if (isNamespaceAttr1) {
if (isNamespaceAttr1) {
// attr1 is a namespace, attr0 is not
return ATTR1_BEFORE_ATTR0;
}
// none is a namespae
if (namespaceURI0 == null) {
if (namespaceURI1 == null) {
/*
String localName0 = attr0.getLocalName();
String localName1 = attr1.getLocalName();
return localName0.compareTo(localName1);
*/
}
// none is a namespace
if (namespaceURI0 == null) {
if (namespaceURI1 == null) {
String name0 = attr0.getName();
String name1 = attr1.getName();
return name0.compareTo(name1);
}
return ATTR0_BEFORE_ATTR1;
}
return ATTR0_BEFORE_ATTR1;
}
if (namespaceURI1 == null) {
return ATTR1_BEFORE_ATTR0;
}
int a = namespaceURI0.compareTo(namespaceURI1);
if (namespaceURI1 == null) {
return ATTR1_BEFORE_ATTR0;
}
if (a != 0) {
return a;
}
/*
String localName0 = ;
String localName1 =;*/
return (attr0.getLocalName())
.compareTo( attr1.getLocalName());
}
int a = namespaceURI0.compareTo(namespaceURI1);
if (a != 0) {
return a;
}
return (attr0.getLocalName()).compareTo(attr1.getLocalName());
}
}

View File

@ -0,0 +1,684 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 2008 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.sun.org.apache.xml.internal.security.c14n.implementations;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
import java.util.logging.Logger;
import java.util.logging.Logger;
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
import com.sun.org.apache.xml.internal.security.c14n.helper.C14nHelper;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
import com.sun.org.apache.xml.internal.security.utils.Constants;
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
/**
* Implements <A HREF="http://www.w3.org/TR/2008/PR-xml-c14n11-20080129/">
* Canonical XML Version 1.1</A>, a W3C Proposed Recommendation from 29
* January 2008.
*
* @author Sean Mullan
* @author Raul Benito
* @version $Revision: 1.2 $
*/
public abstract class Canonicalizer11 extends CanonicalizerBase {
boolean firstCall = true;
final SortedSet result = new TreeSet(COMPARE);
static final String XMLNS_URI = Constants.NamespaceSpecNS;
static final String XML_LANG_URI = Constants.XML_LANG_SPACE_SpecNS;
static Logger log = Logger.getLogger(Canonicalizer11.class.getName());
static class XmlAttrStack {
int currentLevel = 0;
int lastlevel = 0;
XmlsStackElement cur;
static class XmlsStackElement {
int level;
boolean rendered = false;
List nodes = new ArrayList();
};
List levels = new ArrayList();
void push(int level) {
currentLevel = level;
if (currentLevel == -1)
return;
cur = null;
while (lastlevel >= currentLevel) {
levels.remove(levels.size() - 1);
if (levels.size() == 0) {
lastlevel = 0;
return;
}
lastlevel=((XmlsStackElement)levels.get(levels.size()-1)).level;
}
}
void addXmlnsAttr(Attr n) {
if (cur == null) {
cur = new XmlsStackElement();
cur.level = currentLevel;
levels.add(cur);
lastlevel = currentLevel;
}
cur.nodes.add(n);
}
void getXmlnsAttr(Collection col) {
if (cur == null) {
cur = new XmlsStackElement();
cur.level = currentLevel;
lastlevel = currentLevel;
levels.add(cur);
}
int size = levels.size() - 2;
boolean parentRendered = false;
XmlsStackElement e = null;
if (size == -1) {
parentRendered = true;
} else {
e = (XmlsStackElement) levels.get(size);
if (e.rendered && e.level+1 == currentLevel)
parentRendered = true;
}
if (parentRendered) {
col.addAll(cur.nodes);
cur.rendered = true;
return;
}
Map loa = new HashMap();
List baseAttrs = new ArrayList();
boolean successiveOmitted = true;
for (;size>=0;size--) {
e = (XmlsStackElement) levels.get(size);
if (e.rendered) {
successiveOmitted = false;
}
Iterator it = e.nodes.iterator();
while (it.hasNext() && successiveOmitted) {
Attr n = (Attr) it.next();
if (n.getLocalName().equals("base")) {
if (!e.rendered) {
baseAttrs.add(n);
}
} else if (!loa.containsKey(n.getName()))
loa.put(n.getName(), n);
}
}
if (!baseAttrs.isEmpty()) {
Iterator it = cur.nodes.iterator();
String base = null;
Attr baseAttr = null;
while (it.hasNext()) {
Attr n = (Attr) it.next();
if (n.getLocalName().equals("base")) {
base = n.getValue();
baseAttr = n;
break;
}
}
it = baseAttrs.iterator();
while (it.hasNext()) {
Attr n = (Attr) it.next();
if (base == null) {
base = n.getValue();
baseAttr = n;
} else {
try {
base = joinURI(n.getValue(), base);
} catch (URISyntaxException ue) {
ue.printStackTrace();
}
}
}
if (base != null && base.length() != 0) {
baseAttr.setValue(base);
col.add(baseAttr);
}
}
cur.rendered = true;
col.addAll(loa.values());
}
};
XmlAttrStack xmlattrStack = new XmlAttrStack();
/**
* Constructor Canonicalizer11
*
* @param includeComments
*/
public Canonicalizer11(boolean includeComments) {
super(includeComments);
}
/**
* Returns the Attr[]s to be outputted for the given element.
* <br>
* The code of this method is a copy of {@link #handleAttributes(Element,
* NameSpaceSymbTable)},
* whereas it takes into account that subtree-c14n is -- well --
* subtree-based.
* So if the element in question isRoot of c14n, it's parent is not in the
* node set, as well as all other ancestors.
*
* @param E
* @param ns
* @return the Attr[]s to be outputted
* @throws CanonicalizationException
*/
Iterator handleAttributesSubtree(Element E, NameSpaceSymbTable ns)
throws CanonicalizationException {
if (!E.hasAttributes() && !firstCall) {
return null;
}
// result will contain the attrs which have to be outputted
final SortedSet result = this.result;
result.clear();
NamedNodeMap attrs = E.getAttributes();
int attrsLength = attrs.getLength();
for (int i = 0; i < attrsLength; i++) {
Attr N = (Attr) attrs.item(i);
String NUri = N.getNamespaceURI();
if (XMLNS_URI != NUri) {
// It's not a namespace attr node. Add to the result and
// continue.
result.add(N);
continue;
}
String NName = N.getLocalName();
String NValue = N.getValue();
if (XML.equals(NName)
&& XML_LANG_URI.equals(NValue)) {
// The default mapping for xml must not be output.
continue;
}
Node n = ns.addMappingAndRender(NName, NValue, N);
if (n != null) {
// Render the ns definition
result.add(n);
if (C14nHelper.namespaceIsRelative(N)) {
Object exArgs[] = {E.getTagName(), NName, N.getNodeValue()};
throw new CanonicalizationException(
"c14n.Canonicalizer.RelativeNamespace", exArgs);
}
}
}
if (firstCall) {
// It is the first node of the subtree
// Obtain all the namespaces defined in the parents, and added
// to the output.
ns.getUnrenderedNodes(result);
// output the attributes in the xml namespace.
xmlattrStack.getXmlnsAttr(result);
firstCall = false;
}
return result.iterator();
}
/**
* Returns the Attr[]s to be outputted for the given element.
* <br>
* IMPORTANT: This method expects to work on a modified DOM tree, i.e. a
* DOM which has been prepared using
* {@link com.sun.org.apache.xml.internal.security.utils.XMLUtils#circumventBug2650(
* org.w3c.dom.Document)}.
*
* @param E
* @param ns
* @return the Attr[]s to be outputted
* @throws CanonicalizationException
*/
Iterator handleAttributes(Element E, NameSpaceSymbTable ns)
throws CanonicalizationException {
// result will contain the attrs which have to be output
xmlattrStack.push(ns.getLevel());
boolean isRealVisible = isVisibleDO(E, ns.getLevel()) == 1;
NamedNodeMap attrs = null;
int attrsLength = 0;
if (E.hasAttributes()) {
attrs = E.getAttributes();
attrsLength = attrs.getLength();
}
SortedSet result = this.result;
result.clear();
for (int i = 0; i < attrsLength; i++) {
Attr N = (Attr) attrs.item(i);
String NUri = N.getNamespaceURI();
if (XMLNS_URI != NUri) {
// A non namespace definition node.
if (XML_LANG_URI == NUri) {
if (N.getLocalName().equals("id")) {
if (isRealVisible) {
// treat xml:id like any other attribute
// (emit it, but don't inherit it)
result.add(N);
}
} else {
xmlattrStack.addXmlnsAttr(N);
}
} else if (isRealVisible) {
// The node is visible add the attribute to the list of
// output attributes.
result.add(N);
}
// keep working
continue;
}
String NName = N.getLocalName();
String NValue = N.getValue();
if ("xml".equals(NName)
&& XML_LANG_URI.equals(NValue)) {
/* except omit namespace node with local name xml, which defines
* the xml prefix, if its string value is
* http://www.w3.org/XML/1998/namespace.
*/
continue;
}
// add the prefix binding to the ns symb table.
// ns.addInclusiveMapping(NName,NValue,N,isRealVisible);
if (isVisible(N)) {
if (!isRealVisible && ns.removeMappingIfRender(NName)) {
continue;
}
// The xpath select this node output it if needed.
// Node n = ns.addMappingAndRenderXNodeSet
// (NName, NValue, N, isRealVisible);
Node n = ns.addMappingAndRender(NName, NValue, N);
if (n != null) {
result.add(n);
if (C14nHelper.namespaceIsRelative(N)) {
Object exArgs[] =
{ E.getTagName(), NName, N.getNodeValue() };
throw new CanonicalizationException(
"c14n.Canonicalizer.RelativeNamespace", exArgs);
}
}
} else {
if (isRealVisible && NName != XMLNS) {
ns.removeMapping(NName);
} else {
ns.addMapping(NName, NValue, N);
}
}
}
if (isRealVisible) {
// The element is visible, handle the xmlns definition
Attr xmlns = E.getAttributeNodeNS(XMLNS_URI, XMLNS);
Node n = null;
if (xmlns == null) {
// No xmlns def just get the already defined.
n = ns.getMapping(XMLNS);
} else if (!isVisible(xmlns)) {
// There is a defn but the xmlns is not selected by the xpath.
// then xmlns=""
n = ns.addMappingAndRender(XMLNS, "", nullNode);
}
// output the xmlns def if needed.
if (n != null) {
result.add(n);
}
// Float all xml:* attributes of the unselected parent elements to
// this one. addXmlAttributes(E,result);
xmlattrStack.getXmlnsAttr(result);
ns.getUnrenderedNodes(result);
}
return result.iterator();
}
/**
* Always throws a CanonicalizationException because this is inclusive c14n.
*
* @param xpathNodeSet
* @param inclusiveNamespaces
* @return none it always fails
* @throws CanonicalizationException always
*/
public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet,
String inclusiveNamespaces) throws CanonicalizationException {
throw new CanonicalizationException(
"c14n.Canonicalizer.UnsupportedOperation");
}
/**
* Always throws a CanonicalizationException because this is inclusive c14n.
*
* @param rootNode
* @param inclusiveNamespaces
* @return none it always fails
* @throws CanonicalizationException
*/
public byte[] engineCanonicalizeSubTree(Node rootNode,
String inclusiveNamespaces) throws CanonicalizationException {
throw new CanonicalizationException(
"c14n.Canonicalizer.UnsupportedOperation");
}
void circumventBugIfNeeded(XMLSignatureInput input)
throws CanonicalizationException, ParserConfigurationException,
IOException, SAXException {
if (!input.isNeedsToBeExpanded())
return;
Document doc = null;
if (input.getSubNode() != null) {
doc = XMLUtils.getOwnerDocument(input.getSubNode());
} else {
doc = XMLUtils.getOwnerDocument(input.getNodeSet());
}
XMLUtils.circumventBug2650(doc);
}
void handleParent(Element e, NameSpaceSymbTable ns) {
if (!e.hasAttributes()) {
return;
}
xmlattrStack.push(-1);
NamedNodeMap attrs = e.getAttributes();
int attrsLength = attrs.getLength();
for (int i = 0; i < attrsLength; i++) {
Attr N = (Attr) attrs.item(i);
if (Constants.NamespaceSpecNS != N.getNamespaceURI()) {
// Not a namespace definition, ignore.
if (XML_LANG_URI == N.getNamespaceURI()) {
xmlattrStack.addXmlnsAttr(N);
}
continue;
}
String NName = N.getLocalName();
String NValue = N.getNodeValue();
if (XML.equals(NName)
&& Constants.XML_LANG_SPACE_SpecNS.equals(NValue)) {
continue;
}
ns.addMapping(NName,NValue,N);
}
}
private static String joinURI(String baseURI, String relativeURI)
throws URISyntaxException {
String bscheme = null;
String bauthority = null;
String bpath = "";
String bquery = null;
String bfragment = null; // Is this correct?
// pre-parse the baseURI
if (baseURI != null) {
if (baseURI.endsWith("..")) {
baseURI = baseURI + "/";
}
URI base = new URI(baseURI);
bscheme = base.getScheme();
bauthority = base.getAuthority();
bpath = base.getPath();
bquery = base.getQuery();
bfragment = base.getFragment();
}
URI r = new URI(relativeURI);
String rscheme = r.getScheme();
String rauthority = r.getAuthority();
String rpath = r.getPath();
String rquery = r.getQuery();
String rfragment = null;
String tscheme, tauthority, tpath, tquery, tfragment;
if (rscheme != null && rscheme.equals(bscheme)) {
rscheme = null;
}
if (rscheme != null) {
tscheme = rscheme;
tauthority = rauthority;
tpath = removeDotSegments(rpath);
tquery = rquery;
} else {
if (rauthority != null) {
tauthority = rauthority;
tpath = removeDotSegments(rpath);
tquery = rquery;
} else {
if (rpath.length() == 0) {
tpath = bpath;
if (rquery != null) {
tquery = rquery;
} else {
tquery = bquery;
}
} else {
if (rpath.startsWith("/")) {
tpath = removeDotSegments(rpath);
} else {
if (bauthority != null && bpath.length() == 0) {
tpath = "/" + rpath;
} else {
int last = bpath.lastIndexOf('/');
if (last == -1) {
tpath = rpath;
} else {
tpath = bpath.substring(0, last+1) + rpath;
}
}
tpath = removeDotSegments(tpath);
}
tquery = rquery;
}
tauthority = bauthority;
}
tscheme = bscheme;
}
tfragment = rfragment;
return new URI(tscheme, tauthority, tpath, tquery, tfragment).toString();
}
private static String removeDotSegments(String path) {
log.log(java.util.logging.Level.FINE, "STEP OUTPUT BUFFER\t\tINPUT BUFFER");
// 1. The input buffer is initialized with the now-appended path
// components then replace occurrences of "//" in the input buffer
// with "/" until no more occurrences of "//" are in the input buffer.
String input = path;
while (input.indexOf("//") > -1) {
input = input.replaceAll("//", "/");
}
// Initialize the output buffer with the empty string.
StringBuffer output = new StringBuffer();
// If the input buffer starts with a root slash "/" then move this
// character to the output buffer.
if (input.charAt(0) == '/') {
output.append("/");
input = input.substring(1);
}
printStep("1 ", output.toString(), input);
// While the input buffer is not empty, loop as follows
while (input.length() != 0) {
// 2A. If the input buffer begins with a prefix of "./",
// then remove that prefix from the input buffer
// else if the input buffer begins with a prefix of "../", then
// if also the output does not contain the root slash "/" only,
// then move this prefix to the end of the output buffer else
// remove that prefix
if (input.startsWith("./")) {
input = input.substring(2);
printStep("2A", output.toString(), input);
} else if (input.startsWith("../")) {
input = input.substring(3);
if (!output.toString().equals("/")) {
output.append("../");
}
printStep("2A", output.toString(), input);
// 2B. if the input buffer begins with a prefix of "/./" or "/.",
// where "." is a complete path segment, then replace that prefix
// with "/" in the input buffer; otherwise,
} else if (input.startsWith("/./")) {
input = input.substring(2);
printStep("2B", output.toString(), input);
} else if (input.equals("/.")) {
// FIXME: what is complete path segment?
input = input.replaceFirst("/.", "/");
printStep("2B", output.toString(), input);
// 2C. if the input buffer begins with a prefix of "/../" or "/..",
// where ".." is a complete path segment, then replace that prefix
// with "/" in the input buffer and if also the output buffer is
// empty, last segment in the output buffer equals "../" or "..",
// where ".." is a complete path segment, then append ".." or "/.."
// for the latter case respectively to the output buffer else
// remove the last segment and its preceding "/" (if any) from the
// output buffer and if hereby the first character in the output
// buffer was removed and it was not the root slash then delete a
// leading slash from the input buffer; otherwise,
} else if (input.startsWith("/../")) {
input = input.substring(3);
if (output.length() == 0) {
output.append("/");
} else if (output.toString().endsWith("../")) {
output.append("..");
} else if (output.toString().endsWith("..")) {
output.append("/..");
} else {
int index = output.lastIndexOf("/");
if (index == -1) {
output = new StringBuffer();
if (input.charAt(0) == '/') {
input = input.substring(1);
}
} else {
output = output.delete(index, output.length());
}
}
printStep("2C", output.toString(), input);
} else if (input.equals("/..")) {
// FIXME: what is complete path segment?
input = input.replaceFirst("/..", "/");
if (output.length() == 0) {
output.append("/");
} else if (output.toString().endsWith("../")) {
output.append("..");
} else if (output.toString().endsWith("..")) {
output.append("/..");
} else {
int index = output.lastIndexOf("/");
if (index == -1) {
output = new StringBuffer();
if (input.charAt(0) == '/') {
input = input.substring(1);
}
} else {
output = output.delete(index, output.length());
}
}
printStep("2C", output.toString(), input);
// 2D. if the input buffer consists only of ".", then remove
// that from the input buffer else if the input buffer consists
// only of ".." and if the output buffer does not contain only
// the root slash "/", then move the ".." to the output buffer
// else delte it.; otherwise,
} else if (input.equals(".")) {
input = "";
printStep("2D", output.toString(), input);
} else if (input.equals("..")) {
if (!output.toString().equals("/"))
output.append("..");
input = "";
printStep("2D", output.toString(), input);
// 2E. move the first path segment (if any) in the input buffer
// to the end of the output buffer, including the initial "/"
// character (if any) and any subsequent characters up to, but not
// including, the next "/" character or the end of the input buffer.
} else {
int end = -1;
int begin = input.indexOf('/');
if (begin == 0) {
end = input.indexOf('/', 1);
} else {
end = begin;
begin = 0;
}
String segment;
if (end == -1) {
segment = input.substring(begin);
input = "";
} else {
segment = input.substring(begin, end);
input = input.substring(end);
}
output.append(segment);
printStep("2E", output.toString(), input);
}
}
// 3. Finally, if the only or last segment of the output buffer is
// "..", where ".." is a complete path segment not followed by a slash
// then append a slash "/". The output buffer is returned as the result
// of remove_dot_segments
if (output.toString().endsWith("..")) {
output.append("/");
printStep("3 ", output.toString(), input);
}
return output.toString();
}
private static void printStep(String step, String output, String input) {
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, " " + step + ": " + output);
if (output.length() == 0) {
log.log(java.util.logging.Level.FINE, "\t\t\t\t" + input);
} else {
log.log(java.util.logging.Level.FINE, "\t\t\t" + input);
}
}
}
}

View File

@ -0,0 +1,41 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 2008 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.sun.org.apache.xml.internal.security.c14n.implementations;
import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer;
/**
* @author Sean Mullan
*/
public class Canonicalizer11_OmitComments extends Canonicalizer11 {
public Canonicalizer11_OmitComments() {
super(false);
}
public final String engineGetURI() {
return Canonicalizer.ALGO_ID_C14N11_OMIT_COMMENTS;
}
public final boolean engineGetIncludeComments() {
return false;
}
}

View File

@ -0,0 +1,41 @@
/*
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 2008 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.sun.org.apache.xml.internal.security.c14n.implementations;
import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer;
/**
* @author Sean Mullan
*/
public class Canonicalizer11_WithComments extends Canonicalizer11 {
public Canonicalizer11_WithComments() {
super(true);
}
public final String engineGetURI() {
return Canonicalizer.ALGO_ID_C14N11_WITH_COMMENTS;
}
public final boolean engineGetIncludeComments() {
return true;
}
}

View File

@ -2,7 +2,6 @@
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
@ -23,20 +22,30 @@ package com.sun.org.apache.xml.internal.security.c14n.implementations;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import javax.xml.parsers.ParserConfigurationException;
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
import com.sun.org.apache.xml.internal.security.c14n.helper.C14nHelper;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
import com.sun.org.apache.xml.internal.security.utils.Constants;
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
/**
@ -44,13 +53,92 @@ import org.w3c.dom.Node;
* XML Version 1.0</A>, a W3C Recommendation from 15 March 2001.
*
* @author Christian Geuer-Pollmann <geuerp@apache.org>
* @version $Revision: 1.5 $
*/
public abstract class Canonicalizer20010315 extends CanonicalizerBase {
boolean firstCall=true;
final SortedSet result= new TreeSet(COMPARE);
static final String XMLNS_URI=Constants.NamespaceSpecNS;
static final String XML_LANG_URI=Constants.XML_LANG_SPACE_SpecNS;
/**
static class XmlAttrStack {
int currentLevel=0;
int lastlevel=0;
XmlsStackElement cur;
static class XmlsStackElement {
int level;
boolean rendered=false;
List nodes=new ArrayList();
};
List levels=new ArrayList();
void push(int level) {
currentLevel=level;
if (currentLevel==-1)
return;
cur=null;
while (lastlevel>=currentLevel) {
levels.remove(levels.size()-1);
if (levels.size()==0) {
lastlevel=0;
return;
}
lastlevel=((XmlsStackElement)levels.get(levels.size()-1)).level;
}
}
void addXmlnsAttr(Attr n) {
if (cur==null) {
cur=new XmlsStackElement();
cur.level=currentLevel;
levels.add(cur);
lastlevel=currentLevel;
}
cur.nodes.add(n);
}
void getXmlnsAttr(Collection col) {
int size=levels.size()-1;
if (cur==null) {
cur=new XmlsStackElement();
cur.level=currentLevel;
lastlevel=currentLevel;
levels.add(cur);
}
boolean parentRendered=false;
XmlsStackElement e=null;
if (size==-1) {
parentRendered=true;
} else {
e=(XmlsStackElement)levels.get(size);
if (e.rendered && e.level+1==currentLevel)
parentRendered=true;
}
if (parentRendered) {
col.addAll(cur.nodes);
cur.rendered=true;
return;
}
Map loa = new HashMap();
for (;size>=0;size--) {
e=(XmlsStackElement)levels.get(size);
Iterator it=e.nodes.iterator();
while (it.hasNext()) {
Attr n=(Attr)it.next();
if (!loa.containsKey(n.getName()))
loa.put(n.getName(),n);
}
//if (e.rendered)
//break;
};
//cur.nodes.clear();
//cur.nodes.addAll(loa.values());
cur.rendered=true;
col.addAll(loa.values());
}
}
XmlAttrStack xmlattrStack=new XmlAttrStack();
/**
* Constructor Canonicalizer20010315
*
* @param includeComments
@ -86,16 +174,16 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
for (int i = 0; i < attrsLength; i++) {
Attr N = (Attr) attrs.item(i);
String NName=N.getLocalName();
String NValue=N.getValue();
String NUri =N.getNamespaceURI();
if (!XMLNS_URI.equals(NUri)) {
if (XMLNS_URI!=NUri) {
//It's not a namespace attr node. Add to the result and continue.
result.add(N);
continue;
}
String NName=N.getLocalName();
String NValue=N.getValue();
if (XML.equals(NName)
&& XML_LANG_URI.equals(NValue)) {
//The default mapping for xml must not be output.
@ -120,64 +208,13 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
//Obtain all the namespaces defined in the parents, and added to the output.
ns.getUnrenderedNodes(result);
//output the attributes in the xml namespace.
addXmlAttributesSubtree(E, result);
firstCall=false;
xmlattrStack.getXmlnsAttr(result);
firstCall=false;
}
return result.iterator();
}
/**
* Float the xml:* attributes of the parent nodes to the root node of c14n
* @param E the root node.
* @param result the xml:* attributes to output.
*/
private void addXmlAttributesSubtree(Element E, SortedSet result) {
// E is in the node-set
Node parent = E.getParentNode();
Map loa = new HashMap();
if ((parent != null) && (parent.getNodeType() == Node.ELEMENT_NODE)) {
// parent element is not in node set
for (Node ancestor = parent;
(ancestor != null)
&& (ancestor.getNodeType() == Node.ELEMENT_NODE);
ancestor = ancestor.getParentNode()) {
Element el=((Element) ancestor);
if (!el.hasAttributes()) {
continue;
}
// for all ancestor elements
NamedNodeMap ancestorAttrs = el.getAttributes();
for (int i = 0; i < ancestorAttrs.getLength(); i++) {
// for all attributes in the ancestor element
Attr currentAncestorAttr = (Attr) ancestorAttrs.item(i);
if (XML_LANG_URI.equals(
currentAncestorAttr.getNamespaceURI())) {
// do we have an xml:* ?
if (!E.hasAttributeNS(
XML_LANG_URI,
currentAncestorAttr.getLocalName())) {
// the xml:* attr is not in E
if (!loa.containsKey(currentAncestorAttr.getName())) {
loa.put(currentAncestorAttr.getName(),
currentAncestorAttr);
}
}
}
}
}
}
result.addAll( loa.values());
}
/**
* Returns the Attr[]s to be outputted for the given element.
* <br>
@ -192,7 +229,8 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
*/
Iterator handleAttributes(Element E, NameSpaceSymbTable ns ) throws CanonicalizationException {
// result will contain the attrs which have to be outputted
boolean isRealVisible=isVisible(E);
xmlattrStack.push(ns.getLevel());
boolean isRealVisible=isVisibleDO(E,ns.getLevel())==1;
NamedNodeMap attrs = null;
int attrsLength = 0;
if (E.hasAttributes()) {
@ -204,16 +242,15 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
SortedSet result = this.result;
result.clear();
for (int i = 0; i < attrsLength; i++) {
Attr N = (Attr) attrs.item(i);
String NName=N.getLocalName();
String NValue=N.getValue();
String NUri =N.getNamespaceURI();
if (!XMLNS_URI.equals(NUri)) {
if (XMLNS_URI!=NUri) {
//A non namespace definition node.
if (isRealVisible){
if (XML_LANG_URI==NUri) {
xmlattrStack.addXmlnsAttr(N);
} else if (isRealVisible){
//The node is visible add the attribute to the list of output attributes.
result.add(N);
}
@ -221,7 +258,8 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
continue;
}
String NName=N.getLocalName();
String NValue=N.getValue();
if ("xml".equals(NName)
&& XML_LANG_URI.equals(NValue)) {
/* except omit namespace node with local name xml, which defines
@ -232,16 +270,26 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
//add the prefix binding to the ns symb table.
//ns.addInclusiveMapping(NName,NValue,N,isRealVisible);
if (isVisible(N)) {
//The xpath select this node output it if needed.
Node n=ns.addMappingAndRenderXNodeSet(NName,NValue,N,isRealVisible);
if (n!=null) {
if (!isRealVisible && ns.removeMappingIfRender(NName)) {
continue;
}
//The xpath select this node output it if needed.
//Node n=ns.addMappingAndRenderXNodeSet(NName,NValue,N,isRealVisible);
Node n=ns.addMappingAndRender(NName,NValue,N);
if (n!=null) {
result.add(n);
if (C14nHelper.namespaceIsRelative(N)) {
Object exArgs[] = { E.getTagName(), NName, N.getNodeValue() };
throw new CanonicalizationException(
"c14n.Canonicalizer.RelativeNamespace", exArgs);
}
}
}
}
} else {
if (isRealVisible && NName!=XMLNS) {
ns.removeMapping(NName);
} else {
ns.addMapping(NName,NValue,N);
}
}
}
if (isRealVisible) {
@ -254,84 +302,21 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
} else if ( !isVisible(xmlns)) {
//There is a definition but the xmlns is not selected by the xpath.
//then xmlns=""
n=ns.addMappingAndRenderXNodeSet(XMLNS,"",nullNode,true);
n=ns.addMappingAndRender(XMLNS,"",nullNode);
}
//output the xmlns def if needed.
if (n!=null) {
result.add(n);
}
//Float all xml:* attributes of the unselected parent elements to this one.
addXmlAttributes(E,result);
//addXmlAttributes(E,result);
xmlattrStack.getXmlnsAttr(result);
ns.getUnrenderedNodes(result);
}
return result.iterator();
}
/**
* Float the xml:* attributes of the unselected parent nodes to the ciurrent node.
* @param E
* @param result
*/
private void addXmlAttributes(Element E, SortedSet result) {
/* The processing of an element node E MUST be modified slightly when an
* XPath node-set is given as input and the element's parent is omitted
* from the node-set. The method for processing the attribute axis of an
* element E in the node-set is enhanced. All element nodes along E's
* ancestor axis are examined for nearest occurrences of attributes in
* the xml namespace, such as xml:lang and xml:space (whether or not they
* are in the node-set). From this list of attributes, remove any that are
* in E's attribute axis (whether or not they are in the node-set). Then,
* lexicographically merge this attribute list with the nodes of E's
* attribute axis that are in the node-set. The result of visiting the
* attribute axis is computed by processing the attribute nodes in this
* merged attribute list.
*/
// E is in the node-set
Node parent = E.getParentNode();
Map loa = new HashMap();
if ((parent != null) && (parent.getNodeType() == Node.ELEMENT_NODE)
&&!isVisible(parent)) {
// parent element is not in node set
for (Node ancestor = parent;
(ancestor != null)
&& (ancestor.getNodeType() == Node.ELEMENT_NODE);
ancestor = ancestor.getParentNode()) {
Element el=((Element) ancestor);
if (!el.hasAttributes()) {
continue;
}
// for all ancestor elements
NamedNodeMap ancestorAttrs =el.getAttributes();
for (int i = 0; i < ancestorAttrs.getLength(); i++) {
// for all attributes in the ancestor element
Attr currentAncestorAttr = (Attr) ancestorAttrs.item(i);
if (XML_LANG_URI.equals(
currentAncestorAttr.getNamespaceURI())) {
// do we have an xml:* ?
if (!E.hasAttributeNS(
XML_LANG_URI,
currentAncestorAttr.getLocalName())) {
// the xml:* attr is not in E
if (!loa.containsKey(currentAncestorAttr.getName())) {
loa.put(currentAncestorAttr.getName(),
currentAncestorAttr);
}
}
}
}
}
}
result.addAll(loa.values());
}
/**
* Always throws a CanonicalizationException because this is inclusive c14n.
*
@ -363,4 +348,43 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
throw new CanonicalizationException(
"c14n.Canonicalizer.UnsupportedOperation");
}
void circumventBugIfNeeded(XMLSignatureInput input) throws CanonicalizationException, ParserConfigurationException, IOException, SAXException {
if (!input.isNeedsToBeExpanded())
return;
Document doc = null;
if (input.getSubNode() != null) {
doc=XMLUtils.getOwnerDocument(input.getSubNode());
} else {
doc=XMLUtils.getOwnerDocument(input.getNodeSet());
}
XMLUtils.circumventBug2650(doc);
}
void handleParent(Element e, NameSpaceSymbTable ns) {
if (!e.hasAttributes()) {
return;
}
xmlattrStack.push(-1);
NamedNodeMap attrs = e.getAttributes();
int attrsLength = attrs.getLength();
for (int i = 0; i < attrsLength; i++) {
Attr N = (Attr) attrs.item(i);
if (Constants.NamespaceSpecNS!=N.getNamespaceURI()) {
//Not a namespace definition, ignore.
if (XML_LANG_URI==N.getNamespaceURI()) {
xmlattrStack.addXmlnsAttr(N);
}
continue;
}
String NName=N.getLocalName();
String NValue=N.getNodeValue();
if (XML.equals(NName)
&& Constants.XML_LANG_SPACE_SpecNS.equals(NValue)) {
continue;
}
ns.addMapping(NName,NValue,N);
}
}
}

View File

@ -2,7 +2,6 @@
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
@ -21,20 +20,26 @@
*/
package com.sun.org.apache.xml.internal.security.c14n.implementations;
import java.io.IOException;
import java.util.Iterator;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import javax.xml.parsers.ParserConfigurationException;
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
import com.sun.org.apache.xml.internal.security.c14n.helper.C14nHelper;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
import com.sun.org.apache.xml.internal.security.transforms.params.InclusiveNamespaces;
import com.sun.org.apache.xml.internal.security.utils.Constants;
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
/**
* Implements &quot; <A
* HREF="http://www.w3.org/TR/2002/REC-xml-exc-c14n-20020718/">Exclusive XML
@ -47,6 +52,7 @@ import org.w3c.dom.Node;
* <i>THIS </i> implementation is a complete rewrite of the algorithm.
*
* @author Christian Geuer-Pollmann <geuerp@apache.org>
* @version $Revision: 1.5 $
* @see <a href="http://www.w3.org/TR/2002/REC-xml-exc-c14n-20020718/ Exclusive#">
* XML Canonicalization, Version 1.0</a>
*/
@ -55,7 +61,7 @@ public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
* This Set contains the names (Strings like "xmlns" or "xmlns:foo") of
* the inclusive namespaces.
*/
TreeSet _inclusiveNSSet = null;
TreeSet _inclusiveNSSet = new TreeSet();
static final String XMLNS_URI=Constants.NamespaceSpecNS;
final SortedSet result = new TreeSet(COMPARE);
/**
@ -143,10 +149,8 @@ public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
for (int i = 0; i < attrsLength; i++) {
Attr N = (Attr) attrs.item(i);
String NName=N.getLocalName();
String NNodeValue=N.getNodeValue();
if (!XMLNS_URI.equals(N.getNamespaceURI())) {
if (XMLNS_URI!=N.getNamespaceURI()) {
//Not a namespace definition.
//The Element is output element, add his prefix(if used) to visibyUtilized
String prefix = N.getPrefix();
@ -157,6 +161,8 @@ public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
result.add(N);
continue;
}
String NName=N.getLocalName();
String NNodeValue=N.getNodeValue();
if (ns.addMapping(NName, NNodeValue,N)) {
//New definition check if it is relative.
@ -168,17 +174,17 @@ public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
}
}
}
String prefix;
if (E.getNamespaceURI() != null) {
String prefix = E.getPrefix();
prefix = E.getPrefix();
if ((prefix == null) || (prefix.length() == 0)) {
visiblyUtilized.add(XMLNS);
} else {
visiblyUtilized.add(prefix);
prefix=XMLNS;
}
} else {
visiblyUtilized.add(XMLNS);
prefix=XMLNS;
}
visiblyUtilized.add(prefix);
//This can be optimezed by I don't have time
Iterator it=visiblyUtilized.iterator();
@ -211,12 +217,6 @@ public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
}
/** @inheritDoc */
public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet
) throws CanonicalizationException {
return engineCanonicalizeXPathNodeSet(xpathNodeSet,"");
}
/**
* @inheritDoc
* @param E
@ -236,21 +236,20 @@ public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
//The prefix visibly utilized(in the attribute or in the name) in the element
Set visiblyUtilized =null;
//It's the output selected.
boolean isOutputElement = isVisible(E);
boolean isOutputElement=isVisibleDO(E,ns.getLevel())==1;
if (isOutputElement) {
visiblyUtilized = (Set) this._inclusiveNSSet.clone();
}
for (int i = 0; i < attrsLength; i++) {
Attr N = (Attr) attrs.item(i);
String NName=N.getLocalName();
String NNodeValue=N.getNodeValue();
if ( !isVisible(N) ) {
//The node is not in the nodeset(if there is a nodeset)
continue;
}
if (!XMLNS_URI.equals(N.getNamespaceURI())) {
if (XMLNS_URI!=N.getNamespaceURI()) {
if ( !isVisible(N) ) {
//The node is not in the nodeset(if there is a nodeset)
continue;
}
//Not a namespace definition.
if (isOutputElement) {
//The Element is output element, add his prefix(if used) to visibyUtilized
@ -263,6 +262,25 @@ public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
}
continue;
}
String NName=N.getLocalName();
if (isOutputElement && !isVisible(N) && NName!=XMLNS) {
ns.removeMappingIfNotRender(NName);
continue;
}
String NNodeValue=N.getNodeValue();
if (!isOutputElement && isVisible(N) && _inclusiveNSSet.contains(NName) && !ns.removeMappingIfRender(NName)) {
Node n=ns.addMappingAndRender(NName,NNodeValue,N);
if (n!=null) {
result.add(n);
if (C14nHelper.namespaceIsRelative(N)) {
Object exArgs[] = { E.getTagName(), NName, N.getNodeValue() };
throw new CanonicalizationException(
"c14n.Canonicalizer.RelativeNamespace", exArgs);
}
}
}
if (ns.addMapping(NName, NNodeValue,N)) {
@ -306,18 +324,20 @@ public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
}
result.add(key);
}
} else /*if (_circunvented)*/ {
Iterator it=this._inclusiveNSSet.iterator();
while (it.hasNext()) {
String s=(String)it.next();
Attr key=ns.getMappingWithoutRendered(s);
if (key==null) {
continue;
}
result.add(key);
}
}
return result.iterator();
}
void circumventBugIfNeeded(XMLSignatureInput input) throws CanonicalizationException, ParserConfigurationException, IOException, SAXException {
if (!input.isNeedsToBeExpanded() || _inclusiveNSSet.isEmpty())
return;
Document doc = null;
if (input.getSubNode() != null) {
doc=XMLUtils.getOwnerDocument(input.getSubNode());
} else {
doc=XMLUtils.getOwnerDocument(input.getNodeSet());
}
XMLUtils.circumventBug2650(doc);
}
}

View File

@ -28,6 +28,7 @@ import com.sun.org.apache.xml.internal.security.c14n.Canonicalizer;
/**
* Class Canonicalizer20010315ExclWithComments
*
* @version $Revision: 1.5 $
*/
public class Canonicalizer20010315ExclWithComments
extends Canonicalizer20010315Excl {

View File

@ -2,7 +2,6 @@
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
*

View File

@ -27,9 +27,11 @@ import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
import javax.xml.parsers.DocumentBuilderFactory;
@ -45,7 +47,6 @@ import com.sun.org.apache.xml.internal.security.utils.UnsyncByteArrayOutputStrea
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
import org.w3c.dom.Attr;
import org.w3c.dom.Comment;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
@ -57,6 +58,7 @@ import org.xml.sax.SAXException;
* Abstract base class for canonicalization algorithms.
*
* @author Christian Geuer-Pollmann <geuerp@apache.org>
* @version $Revision: 1.5 $
*/
public abstract class CanonicalizerBase extends CanonicalizerSpi {
//Constants to be outputed, In char array form, so
@ -122,6 +124,18 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
throws CanonicalizationException {
return engineCanonicalizeSubTree(rootNode,(Node)null);
}
/**
* Method engineCanonicalizeXPathNodeSet
* @inheritDoc
* @param xpathNodeSet
* @throws CanonicalizationException
*/
public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet)
throws CanonicalizationException {
this._xpathNodeSet = xpathNodeSet;
return engineCanonicalizeXPathNodeSetInternal(XMLUtils.getOwnerDocument(this._xpathNodeSet));
}
/**
* Canonicalizes a Subtree node.
* @param input the root of the subtree to canicalize
@ -143,15 +157,8 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
return bytes;
} else if (input.isNodeSet()) {
nodeFilter=input.getNodeFilters();
Document doc = null;
if (input.getSubNode() != null) {
doc=XMLUtils.getOwnerDocument(input.getSubNode());
} else {
doc=XMLUtils.getOwnerDocument(input.getNodeSet());
}
if (input.isNeedsToBeExpanded()) {
XMLUtils.circumventBug2650(doc);
}
circumventBugIfNeeded(input);
if (input.getSubNode() != null) {
bytes = engineCanonicalizeXPathNodeSetInternal(input.getSubNode());
@ -173,6 +180,13 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
}
}
/**
* @param _writer The _writer to set.
*/
public void setWriter(OutputStream _writer) {
this._writer = _writer;
}
/**
* Canonicalizes a Subtree node.
*
* @param rootNode
@ -187,11 +201,13 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
this._excludeNode = excludeNode;
try {
NameSpaceSymbTable ns=new NameSpaceSymbTable();
int nodeLevel=NODE_BEFORE_DOCUMENT_ELEMENT;
if (rootNode instanceof Element) {
//Fills the nssymbtable with the definitions of the parent of the root subnode
getParentNameSpaces((Element)rootNode,ns);
nodeLevel=NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
}
this.canonicalizeSubTree(rootNode,ns,rootNode);
this.canonicalizeSubTree(rootNode,ns,rootNode,nodeLevel);
this._writer.close();
if (this._writer instanceof ByteArrayOutputStream) {
byte []result=((ByteArrayOutputStream)this._writer).toByteArray();
@ -199,6 +215,12 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
((ByteArrayOutputStream)this._writer).reset();
}
return result;
} else if (this._writer instanceof UnsyncByteArrayOutputStream) {
byte []result=((UnsyncByteArrayOutputStream)this._writer).toByteArray();
if (reset) {
((UnsyncByteArrayOutputStream)this._writer).reset();
}
return result;
}
return null;
@ -219,13 +241,17 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
* @throws CanonicalizationException
* @throws IOException
*/
final void canonicalizeSubTree(Node currentNode, NameSpaceSymbTable ns,Node endnode)
final void canonicalizeSubTree(Node currentNode, NameSpaceSymbTable ns,Node endnode,
int documentLevel)
throws CanonicalizationException, IOException {
if (isVisibleInt(currentNode)==-1)
return;
Node sibling=null;
Node parentNode=null;
final OutputStream writer=this._writer;
final Node excludeNode=this._excludeNode;
final boolean includeComments=this._includeComments;
Map cache=new HashMap();
do {
switch (currentNode.getNodeType()) {
@ -242,18 +268,17 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
case Node.DOCUMENT_FRAGMENT_NODE :
case Node.DOCUMENT_NODE :
ns.outputNodePush();
//currentNode = currentNode.getFirstChild();
sibling= currentNode.getFirstChild();
break;
case Node.COMMENT_NODE :
if (includeComments) {
outputCommentToWriter((Comment) currentNode, writer);
outputCommentToWriter((Comment) currentNode, writer, documentLevel);
}
break;
case Node.PROCESSING_INSTRUCTION_NODE :
outputPItoWriter((ProcessingInstruction) currentNode, writer);
outputPItoWriter((ProcessingInstruction) currentNode, writer, documentLevel);
break;
case Node.TEXT_NODE :
@ -262,6 +287,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
break;
case Node.ELEMENT_NODE :
documentLevel=NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
if (currentNode==excludeNode) {
break;
}
@ -270,27 +296,27 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
ns.outputNodePush();
writer.write('<');
String name=currentElement.getTagName();
writeStringToUtf8(name,writer);
UtfHelpper.writeByte(name,writer,cache);
Iterator attrs = this.handleAttributesSubtree(currentElement,ns);
if (attrs!=null) {
//we output all Attrs which are available
while (attrs.hasNext()) {
Attr attr = (Attr) attrs.next();
outputAttrToWriter(attr.getNodeName(),attr.getNodeValue(), writer);
outputAttrToWriter(attr.getNodeName(),attr.getNodeValue(), writer,cache);
}
}
writer.write('>');
sibling= currentNode.getFirstChild();
if (sibling==null) {
writer.write(_END_TAG);
writeStringToUtf8(name,writer);
UtfHelpper.writeStringToUtf8(name,writer);
writer.write('>');
//We fineshed with this level, pop to the previous definitions.
ns.outputNodePop();
if (parentNode != null) {
if (parentNode != null) {
sibling= currentNode.getNextSibling();
}
}
} else {
parentNode=currentElement;
}
@ -298,7 +324,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
}
while (sibling==null && parentNode!=null) {
writer.write(_END_TAG);
writeStringToUtf8(((Element)parentNode).getTagName(),writer);
UtfHelpper.writeByte(((Element)parentNode).getTagName(),writer,cache);
writer.write('>');
//We fineshed with this level, pop to the previous definitions.
ns.outputNodePop();
@ -307,6 +333,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
sibling=parentNode.getNextSibling();
parentNode=parentNode.getParentNode();
if (!(parentNode instanceof Element)) {
documentLevel=NODE_AFTER_DOCUMENT_ELEMENT;
parentNode=null;
}
}
@ -317,47 +344,8 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
} while(true);
}
/**
* Checks whether a Comment or ProcessingInstruction is before or after the
* document element. This is needed for prepending or appending "\n"s.
*
* @param currentNode comment or pi to check
* @return NODE_BEFORE_DOCUMENT_ELEMENT, NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT or NODE_AFTER_DOCUMENT_ELEMENT
* @see #NODE_BEFORE_DOCUMENT_ELEMENT
* @see #NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT
* @see #NODE_AFTER_DOCUMENT_ELEMENT
*/
final static int getPositionRelativeToDocumentElement(Node currentNode) {
if ((currentNode == null) ||
(currentNode.getParentNode().getNodeType() != Node.DOCUMENT_NODE) ) {
return CanonicalizerBase.NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
}
Element documentElement = currentNode.getOwnerDocument().getDocumentElement();
if ( (documentElement == null) || (documentElement == currentNode) ){
return CanonicalizerBase.NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
}
for (Node x = currentNode; x != null; x = x.getNextSibling()) {
if (x == documentElement) {
return CanonicalizerBase.NODE_BEFORE_DOCUMENT_ELEMENT;
}
}
return CanonicalizerBase.NODE_AFTER_DOCUMENT_ELEMENT;
}
/**
* Method engineCanonicalizeXPathNodeSet
* @inheritDoc
* @param xpathNodeSet
* @throws CanonicalizationException
*/
public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet)
throws CanonicalizationException {
this._xpathNodeSet = xpathNodeSet;
return engineCanonicalizeXPathNodeSetInternal(XMLUtils.getOwnerDocument(this._xpathNodeSet));
}
private byte[] engineCanonicalizeXPathNodeSetInternal(Node doc)
throws CanonicalizationException {
@ -370,6 +358,12 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
((ByteArrayOutputStream)this._writer).reset();
}
return sol;
} else if (this._writer instanceof UnsyncByteArrayOutputStream) {
byte []result=((UnsyncByteArrayOutputStream)this._writer).toByteArray();
if (reset) {
((UnsyncByteArrayOutputStream)this._writer).reset();
}
return result;
}
return null;
} catch (UnsupportedEncodingException ex) {
@ -390,11 +384,17 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
*/
final void canonicalizeXPathNodeSet(Node currentNode,Node endnode )
throws CanonicalizationException, IOException {
boolean currentNodeIsVisible = false;
NameSpaceSymbTable ns=new NameSpaceSymbTable();
if (isVisibleInt(currentNode)==-1)
return;
boolean currentNodeIsVisible = false;
NameSpaceSymbTable ns=new NameSpaceSymbTable();
if (currentNode instanceof Element)
getParentNameSpaces((Element)currentNode,ns);
Node sibling=null;
Node parentNode=null;
OutputStream writer=this._writer;
int documentLevel=NODE_BEFORE_DOCUMENT_ELEMENT;
Map cache=new HashMap();
do {
switch (currentNode.getNodeType()) {
@ -416,14 +416,14 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
break;
case Node.COMMENT_NODE :
if (this._includeComments && isVisible(currentNode)) {
outputCommentToWriter((Comment) currentNode, writer);
if (this._includeComments && (isVisibleDO(currentNode,ns.getLevel())==1)) {
outputCommentToWriter((Comment) currentNode, writer, documentLevel);
}
break;
case Node.PROCESSING_INSTRUCTION_NODE :
if (isVisible(currentNode))
outputPItoWriter((ProcessingInstruction) currentNode, writer);
outputPItoWriter((ProcessingInstruction) currentNode, writer, documentLevel);
break;
case Node.TEXT_NODE :
@ -436,12 +436,6 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|| (nextSibling.getNodeType()
== Node.CDATA_SECTION_NODE));
nextSibling = nextSibling.getNextSibling()) {
/* The XPath data model allows to select only the first of a
* sequence of mixed text and CDATA nodes. But we must output
* them all, so we must search:
*
* @see http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6329
*/
outputTextToWriter(nextSibling.getNodeValue(), writer);
currentNode=nextSibling;
sibling=currentNode.getNextSibling();
@ -451,15 +445,21 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
break;
case Node.ELEMENT_NODE :
documentLevel=NODE_NOT_BEFORE_OR_AFTER_DOCUMENT_ELEMENT;
Element currentElement = (Element) currentNode;
//Add a level to the nssymbtable. So latter can be pop-back.
String name=null;
currentNodeIsVisible=isVisible(currentNode);
int i=isVisibleDO(currentNode,ns.getLevel());
if (i==-1) {
sibling= currentNode.getNextSibling();
break;
}
currentNodeIsVisible=(i==1);
if (currentNodeIsVisible) {
ns.outputNodePush();
writer.write('<');
name=currentElement.getTagName();
writeStringToUtf8(name,writer);
UtfHelpper.writeByte(name,writer,cache);
} else {
ns.push();
}
@ -469,7 +469,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
//we output all Attrs which are available
while (attrs.hasNext()) {
Attr attr = (Attr) attrs.next();
outputAttrToWriter(attr.getNodeName(),attr.getNodeValue(), writer);
outputAttrToWriter(attr.getNodeName(),attr.getNodeValue(), writer,cache);
}
}
if (currentNodeIsVisible) {
@ -480,7 +480,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
if (sibling==null) {
if (currentNodeIsVisible) {
writer.write(_END_TAG);
writeStringToUtf8(name,writer);
UtfHelpper.writeByte(name,writer,cache);
writer.write('>');
//We fineshed with this level, pop to the previous definitions.
ns.outputNodePop();
@ -498,7 +498,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
while (sibling==null && parentNode!=null) {
if (isVisible(parentNode)) {
writer.write(_END_TAG);
writeStringToUtf8(((Element)parentNode).getTagName(),writer);
UtfHelpper.writeByte(((Element)parentNode).getTagName(),writer,cache);
writer.write('>');
//We fineshed with this level, pop to the previous definitions.
ns.outputNodePop();
@ -511,6 +511,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
parentNode=parentNode.getParentNode();
if (!(parentNode instanceof Element)) {
parentNode=null;
documentLevel=NODE_AFTER_DOCUMENT_ELEMENT;
}
}
if (sibling==null)
@ -519,12 +520,38 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
sibling=currentNode.getNextSibling();
} while(true);
}
int isVisibleDO(Node currentNode,int level) {
if (nodeFilter!=null) {
Iterator it=nodeFilter.iterator();
while (it.hasNext()) {
int i=((NodeFilter)it.next()).isNodeIncludeDO(currentNode,level);
if (i!=1)
return i;
}
}
if ((this._xpathNodeSet!=null) && !this._xpathNodeSet.contains(currentNode))
return 0;
return 1;
}
int isVisibleInt(Node currentNode) {
if (nodeFilter!=null) {
Iterator it=nodeFilter.iterator();
while (it.hasNext()) {
int i=((NodeFilter)it.next()).isNodeInclude(currentNode);
if (i!=1)
return i;
}
}
if ((this._xpathNodeSet!=null) && !this._xpathNodeSet.contains(currentNode))
return 0;
return 1;
}
boolean isVisible(Node currentNode) {
if (nodeFilter!=null) {
Iterator it=nodeFilter.iterator();
while (it.hasNext()) {
if (!((NodeFilter)it.next()).isNodeInclude(currentNode))
if (((NodeFilter)it.next()).isNodeInclude(currentNode)!=1)
return false;
}
}
@ -533,19 +560,42 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
return true;
}
void handleParent(Element e,NameSpaceSymbTable ns) {
if (!e.hasAttributes()) {
return;
}
NamedNodeMap attrs = e.getAttributes();
int attrsLength = attrs.getLength();
for (int i = 0; i < attrsLength; i++) {
Attr N = (Attr) attrs.item(i);
if (Constants.NamespaceSpecNS!=N.getNamespaceURI()) {
//Not a namespace definition, ignore.
continue;
}
String NName=N.getLocalName();
String NValue=N.getNodeValue();
if (XML.equals(NName)
&& Constants.XML_LANG_SPACE_SpecNS.equals(NValue)) {
continue;
}
ns.addMapping(NName,NValue,N);
}
}
/**
* Adds to ns the definitons from the parent elements of el
* @param el
* @param ns
*/
final static void getParentNameSpaces(Element el,NameSpaceSymbTable ns) {
List parents=new ArrayList();
final void getParentNameSpaces(Element el,NameSpaceSymbTable ns) {
List parents=new ArrayList(10);
Node n1=el.getParentNode();
if (!(n1 instanceof Element)) {
return;
}
//Obtain all the parents of the elemnt
Element parent=(Element) el.getParentNode();
Element parent=(Element) n1;
while (parent!=null) {
parents.add(parent);
Node n=parent.getParentNode();
@ -557,297 +607,15 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
//Visit them in reverse order.
ListIterator it=parents.listIterator(parents.size());
while (it.hasPrevious()) {
Element ele=(Element)it.previous();
if (!ele.hasAttributes()) {
continue;
Element ele=(Element)it.previous();
handleParent(ele, ns);
}
NamedNodeMap attrs = ele.getAttributes();
int attrsLength = attrs.getLength();
for (int i = 0; i < attrsLength; i++) {
Attr N = (Attr) attrs.item(i);
if (!Constants.NamespaceSpecNS.equals(N.getNamespaceURI())) {
//Not a namespace definition, ignore.
continue;
}
String NName=N.getLocalName();
String NValue=N.getNodeValue();
if (XML.equals(NName)
&& Constants.XML_LANG_SPACE_SpecNS.equals(NValue)) {
continue;
}
ns.addMapping(NName,NValue,N);
}
}
Attr nsprefix;
if (((nsprefix=ns.getMappingWithoutRendered("xmlns"))!=null)
&& "".equals(nsprefix.getValue())) {
ns.addMappingAndRender("xmlns","",nullNode);
}
}
/**
* Outputs an Attribute to the internal Writer.
*
* The string value of the node is modified by replacing
* <UL>
* <LI>all ampersands (&) with <CODE>&amp;amp;</CODE></LI>
* <LI>all open angle brackets (<) with <CODE>&amp;lt;</CODE></LI>
* <LI>all quotation mark characters with <CODE>&amp;quot;</CODE></LI>
* <LI>and the whitespace characters <CODE>#x9</CODE>, #xA, and #xD, with character
* references. The character references are written in uppercase
* hexadecimal with no leading zeroes (for example, <CODE>#xD</CODE> is represented
* by the character reference <CODE>&amp;#xD;</CODE>)</LI>
* </UL>
*
* @param name
* @param value
* @param writer
* @throws IOException
*/
static final void outputAttrToWriter(final String name, final String value, final OutputStream writer) throws IOException {
writer.write(' ');
writeStringToUtf8(name,writer);
writer.write(equalsStr);
byte []toWrite;
final int length = value.length();
for (int i=0;i < length; i++) {
char c = value.charAt(i);
switch (c) {
case '&' :
toWrite=_AMP_;
//writer.write(_AMP_);
break;
case '<' :
toWrite=_LT_;
//writer.write(_LT_);
break;
case '"' :
toWrite=_QUOT_;
//writer.write(_QUOT_);
break;
case 0x09 : // '\t'
toWrite=__X9_;
//writer.write(__X9_);
break;
case 0x0A : // '\n'
toWrite=__XA_;
//writer.write(__XA_);
break;
case 0x0D : // '\r'
toWrite=__XD_;
//writer.write(__XD_);
break;
default :
writeCharToUtf8(c,writer);
//this._writer.write(c);
continue;
}
writer.write(toWrite);
}
writer.write('\"');
}
final static void writeCharToUtf8(final char c,final OutputStream out) throws IOException{
char ch;
if (/*(c >= 0x0001) &&*/ (c <= 0x007F)) {
out.write(c);
return;
}
int bias;
int write;
if (c > 0x07FF) {
ch=(char)(c>>>12);
write=0xE0;
if (ch>0) {
write |= ( ch & 0x0F);
}
out.write(write);
write=0x80;
bias=0x3F;
} else {
write=0xC0;
bias=0x1F;
}
ch=(char)(c>>>6);
if (ch>0) {
write|= (ch & bias);
}
out.write(write);
out.write(0x80 | ((c) & 0x3F));
}
final static void writeStringToUtf8(final String str,final OutputStream out) throws IOException{
final int length=str.length();
int i=0;
char c;
while (i<length) {
c=str.charAt(i++);
if (/*(c >= 0x0001) &&*/ (c <= 0x007F)) {
out.write(c);
continue;
}
char ch;
int bias;
int write;
if (c > 0x07FF) {
ch=(char)(c>>>12);
write=0xE0;
if (ch>0) {
write |= ( ch & 0x0F);
}
out.write(write);
write=0x80;
bias=0x3F;
} else {
write=0xC0;
bias=0x1F;
}
ch=(char)(c>>>6);
if (ch>0) {
write|= (ch & bias);
}
out.write(write);
out.write(0x80 | ((c) & 0x3F));
continue;
}
}
/**
* Outputs a PI to the internal Writer.
*
* @param currentPI
* @param writer where to write the things
* @throws IOException
*/
static final void outputPItoWriter(ProcessingInstruction currentPI, OutputStream writer) throws IOException {
final int position = getPositionRelativeToDocumentElement(currentPI);
if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
writer.write('\n');
}
writer.write(_BEGIN_PI);
final String target = currentPI.getTarget();
int length = target.length();
for (int i = 0; i < length; i++) {
char c=target.charAt(i);
if (c==0x0D) {
writer.write(__XD_);
} else {
writeCharToUtf8(c,writer);
}
}
final String data = currentPI.getData();
length = data.length();
if (length > 0) {
writer.write(' ');
for (int i = 0; i < length; i++) {
char c=data.charAt(i);
if (c==0x0D) {
writer.write(__XD_);
} else {
writeCharToUtf8(c,writer);
}
}
}
writer.write(_END_PI);
if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
writer.write('\n');
}
}
/**
* Method outputCommentToWriter
*
* @param currentComment
* @param writer writer where to write the things
* @throws IOException
*/
static final void outputCommentToWriter(Comment currentComment, OutputStream writer) throws IOException {
final int position = getPositionRelativeToDocumentElement(currentComment);
if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
writer.write('\n');
}
writer.write(_BEGIN_COMM);
final String data = currentComment.getData();
final int length = data.length();
for (int i = 0; i < length; i++) {
char c=data.charAt(i);
if (c==0x0D) {
writer.write(__XD_);
} else {
writeCharToUtf8(c,writer);
}
}
writer.write(_END_COMM);
if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
writer.write('\n');
}
}
/**
* Outputs a Text of CDATA section to the internal Writer.
*
* @param text
* @param writer writer where to write the things
* @throws IOException
*/
static final void outputTextToWriter(final String text, final OutputStream writer) throws IOException {
final int length = text.length();
byte []toWrite;
for (int i = 0; i < length; i++) {
char c = text.charAt(i);
switch (c) {
case '&' :
toWrite=_AMP_;
//writer.write(_AMP_);
break;
case '<' :
toWrite=_LT_;
//writer.write(_LT_);
break;
case '>' :
toWrite=_GT_;
//writer.write(_GT_);
break;
case 0xD :
toWrite=__XD_;
//writer.write(__XD_);
break;
default :
writeCharToUtf8(c,writer);
continue;
}
writer.write(toWrite);
}
}
/**
* Obtain the attributes to output for this node in XPathNodeSet c14n.
*
@ -870,13 +638,207 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
abstract Iterator handleAttributesSubtree(Element E, NameSpaceSymbTable ns)
throws CanonicalizationException;
abstract void circumventBugIfNeeded(XMLSignatureInput input) throws CanonicalizationException, ParserConfigurationException, IOException, SAXException;
/**
* Outputs an Attribute to the internal Writer.
*
* The string value of the node is modified by replacing
* <UL>
* <LI>all ampersands (&) with <CODE>&amp;amp;</CODE></LI>
* <LI>all open angle brackets (<) with <CODE>&amp;lt;</CODE></LI>
* <LI>all quotation mark characters with <CODE>&amp;quot;</CODE></LI>
* <LI>and the whitespace characters <CODE>#x9</CODE>, #xA, and #xD, with character
* references. The character references are written in uppercase
* hexadecimal with no leading zeroes (for example, <CODE>#xD</CODE> is represented
* by the character reference <CODE>&amp;#xD;</CODE>)</LI>
* </UL>
*
* @param name
* @param value
* @param writer
* @throws IOException
*/
static final void outputAttrToWriter(final String name, final String value, final OutputStream writer,
final Map cache) throws IOException {
writer.write(' ');
UtfHelpper.writeByte(name,writer,cache);
writer.write(equalsStr);
byte []toWrite;
final int length = value.length();
int i=0;
while (i < length) {
char c = value.charAt(i++);
/**
* @param _writer The _writer to set.
*/
public void setWriter(OutputStream _writer) {
this._writer = _writer;
}
switch (c) {
case '&' :
toWrite=_AMP_;
break;
case '<' :
toWrite=_LT_;
break;
case '"' :
toWrite=_QUOT_;
break;
case 0x09 : // '\t'
toWrite=__X9_;
break;
case 0x0A : // '\n'
toWrite=__XA_;
break;
case 0x0D : // '\r'
toWrite=__XD_;
break;
default :
if (c < 0x80 ) {
writer.write(c);
} else {
UtfHelpper.writeCharToUtf8(c,writer);
};
continue;
}
writer.write(toWrite);
}
writer.write('\"');
}
/**
* Outputs a PI to the internal Writer.
*
* @param currentPI
* @param writer where to write the things
* @throws IOException
*/
static final void outputPItoWriter(ProcessingInstruction currentPI, OutputStream writer,int position) throws IOException {
if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
writer.write('\n');
}
writer.write(_BEGIN_PI);
final String target = currentPI.getTarget();
int length = target.length();
for (int i = 0; i < length; i++) {
char c=target.charAt(i);
if (c==0x0D) {
writer.write(__XD_);
} else {
if (c < 0x80) {
writer.write(c);
} else {
UtfHelpper.writeCharToUtf8(c,writer);
};
}
}
final String data = currentPI.getData();
length = data.length();
if (length > 0) {
writer.write(' ');
for (int i = 0; i < length; i++) {
char c=data.charAt(i);
if (c==0x0D) {
writer.write(__XD_);
} else {
UtfHelpper.writeCharToUtf8(c,writer);
}
}
}
writer.write(_END_PI);
if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
writer.write('\n');
}
}
/**
* Method outputCommentToWriter
*
* @param currentComment
* @param writer writer where to write the things
* @throws IOException
*/
static final void outputCommentToWriter(Comment currentComment, OutputStream writer,int position) throws IOException {
if (position == NODE_AFTER_DOCUMENT_ELEMENT) {
writer.write('\n');
}
writer.write(_BEGIN_COMM);
final String data = currentComment.getData();
final int length = data.length();
for (int i = 0; i < length; i++) {
char c=data.charAt(i);
if (c==0x0D) {
writer.write(__XD_);
} else {
if (c < 0x80) {
writer.write(c);
} else {
UtfHelpper.writeCharToUtf8(c,writer);
};
}
}
writer.write(_END_COMM);
if (position == NODE_BEFORE_DOCUMENT_ELEMENT) {
writer.write('\n');
}
}
/**
* Outputs a Text of CDATA section to the internal Writer.
*
* @param text
* @param writer writer where to write the things
* @throws IOException
*/
static final void outputTextToWriter(final String text, final OutputStream writer) throws IOException {
final int length = text.length();
byte []toWrite;
for (int i = 0; i < length; i++) {
char c = text.charAt(i);
switch (c) {
case '&' :
toWrite=_AMP_;
break;
case '<' :
toWrite=_LT_;
break;
case '>' :
toWrite=_GT_;
break;
case 0xD :
toWrite=__XD_;
break;
default :
if (c < 0x80) {
writer.write(c);
} else {
UtfHelpper.writeCharToUtf8(c,writer);
};
continue;
}
writer.write(toWrite);
}
}
}

View File

@ -20,16 +20,10 @@
*/
package com.sun.org.apache.xml.internal.security.c14n.implementations;
import java.lang.reflect.Array;
import java.util.AbstractList;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.w3c.dom.Attr;
@ -46,21 +40,26 @@ import org.w3c.dom.Node;
public class NameSpaceSymbTable {
/**The map betwen prefix-> entry table. */
SymbMap symb = new SymbMap();
SymbMap symb;
/**The level of nameSpaces (for Inclusive visibility).*/
int nameSpaces=0;
/**The stacks for removing the definitions when doing pop.*/
List level = new ArrayList();
List level;
boolean cloned=true;
static final String XMLNS="xmlns";
final static SymbMap initialMap=new SymbMap();
static {
NameSpaceSymbEntry ne=new NameSpaceSymbEntry("",null,true,XMLNS);
ne.lastrendered="";
initialMap.put(XMLNS,ne);
}
/**
* Default constractor
**/
public NameSpaceSymbTable() {
level = new ArrayList(10);
//Insert the default binding for xmlns.
NameSpaceSymbEntry ne=new NameSpaceSymbEntry("",null,true);
ne.lastrendered="";
symb.put(XMLNS,ne);
symb=(SymbMap) initialMap.clone();
}
/**
@ -75,8 +74,14 @@ public class NameSpaceSymbTable {
NameSpaceSymbEntry n=(NameSpaceSymbEntry)(it.next());
//put them rendered?
if ((!n.rendered) && (n.n!=null)) {
n=(NameSpaceSymbEntry) n.clone();
needsClone();
symb.put(n.prefix,n);
n.lastrendered=n.uri;
n.rendered=true;
result.add(n.n);
n.rendered=true;
}
}
}
@ -104,10 +109,6 @@ public class NameSpaceSymbTable {
**/
public void push() {
//Put the number of namespace definitions in the stack.
/**if (cloned) {
Object ob[]= {symb,cloned ? symb : null};
level.add(ob);
} **/
level.add(null);
cloned=false;
}
@ -124,7 +125,7 @@ public class NameSpaceSymbTable {
if (size==0) {
cloned=false;
} else
cloned=(level.get(size-1)!=symb);
cloned=(level.get(size-1)!=symb);
} else {
cloned=false;
}
@ -134,8 +135,7 @@ public class NameSpaceSymbTable {
final void needsClone() {
if (!cloned) {
level.remove(level.size()-1);
level.add(symb);
level.set(level.size()-1,symb);
symb=(SymbMap) symb.clone();
cloned=true;
}
@ -200,7 +200,7 @@ public class NameSpaceSymbTable {
return false;
}
//Creates and entry in the table for this new definition.
NameSpaceSymbEntry ne=new NameSpaceSymbEntry(uri,n,false);
NameSpaceSymbEntry ne=new NameSpaceSymbEntry(uri,n,false,prefix);
needsClone();
symb.put(prefix, ne);
if (ob != null) {
@ -238,7 +238,7 @@ public class NameSpaceSymbTable {
return null;
}
NameSpaceSymbEntry ne=new NameSpaceSymbEntry(uri,n,true);
NameSpaceSymbEntry ne=new NameSpaceSymbEntry(uri,n,true,prefix);
ne.lastrendered=uri;
needsClone();
symb.put(prefix, ne);
@ -251,53 +251,38 @@ public class NameSpaceSymbTable {
}
return ne.n;
}
/**
* Adds & gets(if needed) the attribute node that defines the binding for the prefix.
* Take on account if the rules of rendering in the inclusive c14n.
* For inclusive c14n.
* @param prefix the prefix to obtain the attribute.
* @param outputNode the container element is an output element.
* @param uri the Uri of the definition
* @param n the attribute that have the definition
* @return null if there is no need to render the prefix. Otherwise the node of
* definition.
**/
public Node addMappingAndRenderXNodeSet(String prefix, String uri,Attr n,boolean outputNode) {
public int getLevel() {
// TODO Auto-generated method stub
return level.size();
}
public void removeMapping(String prefix) {
NameSpaceSymbEntry ob = symb.get(prefix);
int visibleNameSpaces=nameSpaces;
if ((ob!=null) && uri.equals(ob.uri)) {
if (!ob.rendered) {
ob=(NameSpaceSymbEntry)ob.clone();
needsClone();
symb.put(prefix,ob);
ob.rendered=true;
ob.level=visibleNameSpaces;
return ob.n;
}
ob=(NameSpaceSymbEntry)ob.clone();
if (ob!=null) {
needsClone();
symb.put(prefix,ob);
if (outputNode && (((visibleNameSpaces-ob.level)<2) || XMLNS.equals(prefix)) ) {
ob.level=visibleNameSpaces;
return null; //Already rendered, just return nulll
}
ob.level=visibleNameSpaces;
return ob.n;
}
symb.put(prefix,null);
}
}
NameSpaceSymbEntry ne=new NameSpaceSymbEntry(uri,n,true);
ne.level=nameSpaces;
ne.rendered=true;
needsClone();
symb.put(prefix, ne);
if (ob != null) {
ne.lastrendered=ob.lastrendered;
public void removeMappingIfNotRender(String prefix) {
NameSpaceSymbEntry ob = symb.get(prefix);
if ((ob.lastrendered!=null)&& (ob.lastrendered.equals(uri))) {
ne.rendered=true;
}
}
return ne.n;
if (ob!=null && !ob.rendered) {
needsClone();
symb.put(prefix,null);
}
}
public boolean removeMappingIfRender(String prefix) {
NameSpaceSymbEntry ob = symb.get(prefix);
if (ob!=null && ob.rendered) {
needsClone();
symb.put(prefix,null);
}
return false;
}
}
@ -305,10 +290,11 @@ public class NameSpaceSymbTable {
* The internal structure of NameSpaceSymbTable.
**/
class NameSpaceSymbEntry implements Cloneable {
NameSpaceSymbEntry(String name,Attr n,boolean rendered) {
NameSpaceSymbEntry(String name,Attr n,boolean rendered,String prefix) {
this.uri=name;
this.rendered=rendered;
this.n=n;
this.prefix=prefix;
}
/** @inheritDoc */
public Object clone() {
@ -320,6 +306,7 @@ class NameSpaceSymbEntry implements Cloneable {
}
/** The level where the definition was rendered(Only for inclusive) */
int level=0;
String prefix;
/**The URI that the prefix defines */
String uri;
/**The last output in the URI for this prefix (This for speed reason).*/
@ -330,53 +317,57 @@ class NameSpaceSymbEntry implements Cloneable {
Attr n;
};
class SymbMap implements Cloneable{
int free=23;
NameSpaceSymbEntry[] entries=new NameSpaceSymbEntry[free];
String[] keys=new String[free];
void put(String key, NameSpaceSymbEntry value) {
class SymbMap implements Cloneable {
int free=23;
NameSpaceSymbEntry[] entries;
String[] keys;
SymbMap() {
entries=new NameSpaceSymbEntry[free];
keys=new String[free];
}
void put(String key, NameSpaceSymbEntry value) {
int index = index(key);
Object oldKey = keys[index];
keys[index] = key;
entries[index] = value;
Object oldKey = keys[index];
keys[index] = key;
entries[index] = value;
if (oldKey==null || !oldKey.equals(key)) {
if (--free == 0) {
free=entries.length;
int newCapacity = free<<2;
rehash(newCapacity);
}
if (--free == 0) {
free=entries.length;
int newCapacity = free<<2;
rehash(newCapacity);
}
}
}
List entrySet() {
List a=new ArrayList();
for (int i=0;i<entries.length;i++) {
if ((entries[i]!=null) && !("".equals(entries[i]))) {
a.add(entries[i]);
}
}
return a;
List a=new ArrayList();
for (int i=0;i<entries.length;i++) {
if ((entries[i]!=null) && !("".equals(entries[i].uri))) {
a.add(entries[i]);
}
}
return a;
}
protected int index(Object obj) {
protected int index(Object obj) {
Object[] set = keys;
int length = set.length;
//abs of index
int length = set.length;
//abs of index
int index = (obj.hashCode() & 0x7fffffff) % length;
Object cur = set[index];
if (cur == null || (cur.equals( obj))) {
return index;
return index;
}
length=length-1;
do {
index=index==length? 0:++index;
cur = set[index];
index=index==length? 0:++index;
cur = set[index];
} while (cur != null && (!cur.equals(obj)));
return index;
}
/**
/**
* rehashes the map to the new capacity.
*
* @param newCapacity an <code>int</code> value
@ -384,37 +375,38 @@ class SymbMap implements Cloneable{
protected void rehash(int newCapacity) {
int oldCapacity = keys.length;
String oldKeys[] = keys;
NameSpaceSymbEntry oldVals[] = entries;
NameSpaceSymbEntry oldVals[] = entries;
keys = new String[newCapacity];
entries = new NameSpaceSymbEntry[newCapacity];
keys = new String[newCapacity];
entries = new NameSpaceSymbEntry[newCapacity];
for (int i = oldCapacity; i-- > 0;) {
if(oldKeys[i] != null) {
String o = oldKeys[i];
int index = index(o);
keys[index] = o;
entries[index] = oldVals[i];
keys[index] = o;
entries[index] = oldVals[i];
}
}
}
NameSpaceSymbEntry get(String key) {
return entries[index(key)];
}
protected Object clone() {
// TODO Auto-generated method stub
try {
SymbMap copy=(SymbMap) super.clone();
copy.entries=new NameSpaceSymbEntry[entries.length];
System.arraycopy(entries,0,copy.entries,0,entries.length);
copy.keys=new String[keys.length];
System.arraycopy(keys,0,copy.keys,0,keys.length);
return copy;
} catch (CloneNotSupportedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
NameSpaceSymbEntry get(String key) {
return entries[index(key)];
}
protected Object clone() {
try {
SymbMap copy=(SymbMap) super.clone();
copy.entries=new NameSpaceSymbEntry[entries.length];
System.arraycopy(entries,0,copy.entries,0,entries.length);
copy.keys=new String[keys.length];
System.arraycopy(keys,0,copy.keys,0,keys.length);
return copy;
} catch (CloneNotSupportedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}

View File

@ -0,0 +1,155 @@
package com.sun.org.apache.xml.internal.security.c14n.implementations;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Map;
public class UtfHelpper {
final static void writeByte(final String str,final OutputStream out,Map cache) throws IOException {
byte []result=(byte[]) cache.get(str);
if (result==null) {
result=getStringInUtf8(str);
cache.put(str,result);
}
out.write(result);
}
final static void writeCharToUtf8(final char c,final OutputStream out) throws IOException{
if (c < 0x80) {
out.write(c);
return;
}
if ((c >= 0xD800 && c <= 0xDBFF) || (c >= 0xDC00 && c <= 0xDFFF) ){
//No Surrogates in sun java
out.write(0x3f);
return;
}
int bias;
int write;
char ch;
if (c > 0x07FF) {
ch=(char)(c>>>12);
write=0xE0;
if (ch>0) {
write |= ( ch & 0x0F);
}
out.write(write);
write=0x80;
bias=0x3F;
} else {
write=0xC0;
bias=0x1F;
}
ch=(char)(c>>>6);
if (ch>0) {
write|= (ch & bias);
}
out.write(write);
out.write(0x80 | ((c) & 0x3F));
}
final static void writeStringToUtf8(final String str,final OutputStream out) throws IOException{
final int length=str.length();
int i=0;
char c;
while (i<length) {
c=str.charAt(i++);
if (c < 0x80) {
out.write(c);
continue;
}
if ((c >= 0xD800 && c <= 0xDBFF) || (c >= 0xDC00 && c <= 0xDFFF) ){
//No Surrogates in sun java
out.write(0x3f);
continue;
}
char ch;
int bias;
int write;
if (c > 0x07FF) {
ch=(char)(c>>>12);
write=0xE0;
if (ch>0) {
write |= ( ch & 0x0F);
}
out.write(write);
write=0x80;
bias=0x3F;
} else {
write=0xC0;
bias=0x1F;
}
ch=(char)(c>>>6);
if (ch>0) {
write|= (ch & bias);
}
out.write(write);
out.write(0x80 | ((c) & 0x3F));
}
}
public final static byte[] getStringInUtf8(final String str) {
final int length=str.length();
boolean expanded=false;
byte []result=new byte[length];
int i=0;
int out=0;
char c;
while (i<length) {
c=str.charAt(i++);
if ( c < 0x80 ) {
result[out++]=(byte)c;
continue;
}
if ((c >= 0xD800 && c <= 0xDBFF) || (c >= 0xDC00 && c <= 0xDFFF) ){
//No Surrogates in sun java
result[out++]=0x3f;
continue;
}
if (!expanded) {
byte newResult[]=new byte[3*length];
System.arraycopy(result, 0, newResult, 0, out);
result=newResult;
expanded=true;
}
char ch;
int bias;
byte write;
if (c > 0x07FF) {
ch=(char)(c>>>12);
write=(byte)0xE0;
if (ch>0) {
write |= ( ch & 0x0F);
}
result[out++]=write;
write=(byte)0x80;
bias=0x3F;
} else {
write=(byte)0xC0;
bias=0x1F;
}
ch=(char)(c>>>6);
if (ch>0) {
write|= (ch & bias);
}
result[out++]=write;
result[out++]=(byte)(0x80 | ((c) & 0x3F));/**/
}
if (expanded) {
byte newResult[]=new byte[out];
System.arraycopy(result, 0, newResult, 0, out);
result=newResult;
}
return result;
}
}

View File

@ -108,84 +108,78 @@ public class XMLCipherInput {
return null;
}
/**
* Internal method to get bytes in decryption mode
/**
* Internal method to get bytes in decryption mode
* @return the decripted bytes
* @throws XMLEncryptionException
*/
*/
private byte[] getDecryptBytes() throws XMLEncryptionException {
private byte[] getDecryptBytes() throws XMLEncryptionException {
String base64EncodedEncryptedOctets = null;
String base64EncodedEncryptedOctets = null;
if (_cipherData.getDataType() == CipherData.REFERENCE_TYPE) {
// Fun time!
if (logger.isLoggable(java.util.logging.Level.FINE)) logger.log(java.util.logging.Level.FINE, "Found a reference type CipherData");
CipherReference cr = _cipherData.getCipherReference();
// Fun time!
logger.log(java.util.logging.Level.FINE, "Found a reference type CipherData");
CipherReference cr = _cipherData.getCipherReference();
// Need to wrap the uri in an Attribute node so that we can
// Pass to the resource resolvers
// Need to wrap the uri in an Attribute node so that we can
// Pass to the resource resolvers
Attr uriAttr = cr.getURIAsAttr();
XMLSignatureInput input = null;
Attr uriAttr = cr.getURIAsAttr();
XMLSignatureInput input = null;
try {
ResourceResolver resolver =
ResourceResolver.getInstance(uriAttr, null);
input = resolver.resolve(uriAttr, null);
} catch (ResourceResolverException ex) {
throw new XMLEncryptionException("empty", ex);
}
try {
ResourceResolver resolver =
ResourceResolver.getInstance(uriAttr, null);
input = resolver.resolve(uriAttr, null);
} catch (ResourceResolverException ex) {
throw new XMLEncryptionException("empty", ex);
}
if (input != null) {
if (logger.isLoggable(java.util.logging.Level.FINE)) logger.log(java.util.logging.Level.FINE, "Managed to resolve URI \"" + cr.getURI() + "\"");
}
else {
if (logger.isLoggable(java.util.logging.Level.FINE)) logger.log(java.util.logging.Level.FINE, "Failed to resolve URI \"" + cr.getURI() + "\"");
}
if (input != null) {
logger.log(java.util.logging.Level.FINE, "Managed to resolve URI \"" + cr.getURI() + "\"");
} else {
logger.log(java.util.logging.Level.FINE, "Failed to resolve URI \"" + cr.getURI() + "\"");
}
// Lets see if there are any transforms
Transforms transforms = cr.getTransforms();
if (transforms != null) {
if (logger.isLoggable(java.util.logging.Level.FINE)) logger.log(java.util.logging.Level.FINE, "Have transforms in cipher reference");
try {
com.sun.org.apache.xml.internal.security.transforms.Transforms dsTransforms =
transforms.getDSTransforms();
input = dsTransforms.performTransforms(input);
} catch (TransformationException ex) {
throw new XMLEncryptionException("empty", ex);
}
}
try {
return input.getBytes();
}
catch (IOException ex) {
throw new XMLEncryptionException("empty", ex);
} catch (CanonicalizationException ex) {
throw new XMLEncryptionException("empty", ex);
}
// retrieve the cipher text
} else if (_cipherData.getDataType() == CipherData.VALUE_TYPE) {
CipherValue cv = _cipherData.getCipherValue();
base64EncodedEncryptedOctets = new String(cv.getValue());
} else {
throw new XMLEncryptionException("CipherData.getDataType() returned unexpected value");
// Lets see if there are any transforms
Transforms transforms = cr.getTransforms();
if (transforms != null) {
logger.log(java.util.logging.Level.FINE, "Have transforms in cipher reference");
try {
com.sun.org.apache.xml.internal.security.transforms.Transforms dsTransforms =
transforms.getDSTransforms();
input = dsTransforms.performTransforms(input);
} catch (TransformationException ex) {
throw new XMLEncryptionException("empty", ex);
}
}
if (logger.isLoggable(java.util.logging.Level.FINE)) logger.log(java.util.logging.Level.FINE, "Encrypted octets:\n" + base64EncodedEncryptedOctets);
try {
return input.getBytes();
} catch (IOException ex) {
throw new XMLEncryptionException("empty", ex);
} catch (CanonicalizationException ex) {
throw new XMLEncryptionException("empty", ex);
}
// retrieve the cipher text
} else if (_cipherData.getDataType() == CipherData.VALUE_TYPE) {
base64EncodedEncryptedOctets =
_cipherData.getCipherValue().getValue();
} else {
throw new XMLEncryptionException("CipherData.getDataType() returned unexpected value");
}
logger.log(java.util.logging.Level.FINE, "Encrypted octets:\n" + base64EncodedEncryptedOctets);
byte[] encryptedBytes = null;
try {
encryptedBytes = Base64.decode(base64EncodedEncryptedOctets);
encryptedBytes = Base64.decode(base64EncodedEncryptedOctets);
} catch (Base64DecodingException bde) {
throw new XMLEncryptionException("empty", bde);
}
return (encryptedBytes);
}
return (encryptedBytes);
}
}

View File

@ -2,7 +2,6 @@
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
@ -28,7 +27,7 @@ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
/**
*
* @author $Author: raul $
* @author $Author: mullan $
*/
public class ContentHandlerAlreadyRegisteredException
extends XMLSecurityException {

View File

@ -25,6 +25,8 @@ package com.sun.org.apache.xml.internal.security.keys;
import java.security.PublicKey;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import javax.crypto.SecretKey;
@ -88,15 +90,22 @@ import org.w3c.dom.NodeList;
* The <CODE>containsXXX()</CODE> methods return <I>whether</I> the KeyInfo
* contains the corresponding type.
*
* @author $Author: raul $
* @author $Author: mullan $
*/
public class KeyInfo extends SignatureElementProxy {
/** {@link java.util.logging} logging facility */
static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(KeyInfo.class.getName());
List x509Datas=null;
List encryptedKeys=null;
static final List nullList;
static {
List list = new ArrayList();
list.add(null);
nullList = Collections.unmodifiableList(list);
}
/**
* Constructor KeyInfo
@ -108,7 +117,6 @@ public class KeyInfo extends SignatureElementProxy {
XMLUtils.addReturnToElement(this._constructionElement);
}
/**
@ -119,8 +127,8 @@ public class KeyInfo extends SignatureElementProxy {
* @throws XMLSecurityException
*/
public KeyInfo(Element element, String BaseURI) throws XMLSecurityException {
super(element, BaseURI);
// _storageResolvers.add(null);
}
@ -131,7 +139,7 @@ public class KeyInfo extends SignatureElementProxy {
*/
public void setId(String Id) {
if ((this._state == MODE_SIGN) && (Id != null)) {
if ((Id != null)) {
this._constructionElement.setAttributeNS(null, Constants._ATT_ID, Id);
IdResolver.registerElementById(this._constructionElement, Id);
}
@ -162,10 +170,8 @@ public class KeyInfo extends SignatureElementProxy {
*/
public void add(KeyName keyname) {
if (this._state == MODE_SIGN) {
this._constructionElement.appendChild(keyname.getElement());
XMLUtils.addReturnToElement(this._constructionElement);
}
}
/**
@ -219,11 +225,8 @@ public class KeyInfo extends SignatureElementProxy {
* @param keyvalue
*/
public void add(KeyValue keyvalue) {
if (this._state == MODE_SIGN) {
this._constructionElement.appendChild(keyvalue.getElement());
XMLUtils.addReturnToElement(this._constructionElement);
}
}
/**
@ -241,11 +244,8 @@ public class KeyInfo extends SignatureElementProxy {
* @param mgmtdata
*/
public void add(MgmtData mgmtdata) {
if (this._state == MODE_SIGN) {
this._constructionElement.appendChild(mgmtdata.getElement());
XMLUtils.addReturnToElement(this._constructionElement);
}
}
/**
@ -254,11 +254,8 @@ public class KeyInfo extends SignatureElementProxy {
* @param pgpdata
*/
public void add(PGPData pgpdata) {
if (this._state == MODE_SIGN) {
this._constructionElement.appendChild(pgpdata.getElement());
XMLUtils.addReturnToElement(this._constructionElement);
}
}
/**
@ -279,11 +276,8 @@ public class KeyInfo extends SignatureElementProxy {
* @param retrievalmethod
*/
public void add(RetrievalMethod retrievalmethod) {
if (this._state == MODE_SIGN) {
this._constructionElement.appendChild(retrievalmethod.getElement());
XMLUtils.addReturnToElement(this._constructionElement);
}
}
/**
@ -292,11 +286,8 @@ public class KeyInfo extends SignatureElementProxy {
* @param spkidata
*/
public void add(SPKIData spkidata) {
if (this._state == MODE_SIGN) {
this._constructionElement.appendChild(spkidata.getElement());
XMLUtils.addReturnToElement(this._constructionElement);
}
}
/**
@ -305,11 +296,11 @@ public class KeyInfo extends SignatureElementProxy {
* @param x509data
*/
public void add(X509Data x509data) {
if (this._state == MODE_SIGN) {
if (x509Datas==null)
x509Datas=new ArrayList();
x509Datas.add(x509data);
this._constructionElement.appendChild(x509data.getElement());
XMLUtils.addReturnToElement(this._constructionElement);
}
}
/**
@ -321,12 +312,11 @@ public class KeyInfo extends SignatureElementProxy {
public void add(EncryptedKey encryptedKey)
throws XMLEncryptionException {
if (this._state == MODE_SIGN) {
if (encryptedKeys==null)
encryptedKeys=new ArrayList();
encryptedKeys.add(encryptedKey);
XMLCipher cipher = XMLCipher.getInstance();
this._constructionElement.appendChild(cipher.martial(encryptedKey));
}
}
/**
@ -335,11 +325,8 @@ public class KeyInfo extends SignatureElementProxy {
* @param element
*/
public void addUnknownElement(Element element) {
if (this._state == MODE_SIGN) {
this._constructionElement.appendChild(element);
XMLUtils.addReturnToElement(this._constructionElement);
}
}
/**
@ -403,6 +390,9 @@ public class KeyInfo extends SignatureElementProxy {
*@return the number of the X509Data tags
*/
public int lengthX509Data() {
if (x509Datas!=null) {
return x509Datas.size();
}
return this.length(Constants.SignatureSpecNS, Constants._TAG_X509DATA);
}
@ -550,7 +540,9 @@ public class KeyInfo extends SignatureElementProxy {
* @throws XMLSecurityException
*/
public X509Data itemX509Data(int i) throws XMLSecurityException {
if (x509Datas!=null) {
return (X509Data) x509Datas.get(i);
}
Element e = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
Constants._TAG_X509DATA,i);
@ -569,7 +561,9 @@ public class KeyInfo extends SignatureElementProxy {
*/
public EncryptedKey itemEncryptedKey(int i) throws XMLSecurityException {
if (encryptedKeys!=null) {
return (EncryptedKey) encryptedKeys.get(i);
}
Element e =
XMLUtils.selectXencNode(this._constructionElement.getFirstChild(),
EncryptionConstants._TAG_ENCRYPTEDKEY,i);
@ -707,20 +701,20 @@ public class KeyInfo extends SignatureElementProxy {
PublicKey pk = this.getPublicKeyFromInternalResolvers();
if (pk != null) {
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "I could find a key using the per-KeyInfo key resolvers");
log.log(java.util.logging.Level.FINE, "I could find a key using the per-KeyInfo key resolvers");
return pk;
}
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "I couldn't find a key using the per-KeyInfo key resolvers");
log.log(java.util.logging.Level.FINE, "I couldn't find a key using the per-KeyInfo key resolvers");
pk = this.getPublicKeyFromStaticResolvers();
if (pk != null) {
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "I could find a key using the system-wide key resolvers");
log.log(java.util.logging.Level.FINE, "I could find a key using the system-wide key resolvers");
return pk;
}
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "I couldn't find a key using the system-wide key resolvers");
log.log(java.util.logging.Level.FINE, "I couldn't find a key using the system-wide key resolvers");
return null;
}
@ -732,46 +726,29 @@ public class KeyInfo extends SignatureElementProxy {
* @throws KeyResolverException
*/
PublicKey getPublicKeyFromStaticResolvers() throws KeyResolverException {
for (int i = 0; i < KeyResolver.length(); i++) {
KeyResolver keyResolver = KeyResolver.item(i);
int length=KeyResolver.length();
int storageLength=this._storageResolvers.size();
Iterator it= KeyResolver.iterator();
for (int i = 0; i < length; i++) {
KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
Node currentChild=this._constructionElement.getFirstChild();
String uri= this.getBaseURI();
while (currentChild!=null) {
if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
if (this._storageResolvers.size() == 0) {
// if we do not have storage resolvers, we verify with null
StorageResolver storage = null;
if (keyResolver.canResolve((Element) currentChild,
this.getBaseURI(), storage)) {
PublicKey pk =
keyResolver.resolvePublicKey((Element) currentChild,
this.getBaseURI(),
storage);
if (pk != null) {
return pk;
}
}
} else {
for (int k = 0; k < this._storageResolvers.size(); k++) {
for (int k = 0; k < storageLength; k++) {
StorageResolver storage =
(StorageResolver) this._storageResolvers.get(k);
if (keyResolver.canResolve((Element) currentChild,
this.getBaseURI(), storage)) {
PublicKey pk =
keyResolver.resolvePublicKey((Element) currentChild,
this.getBaseURI(),
PublicKey pk =
keyResolver.engineLookupAndResolvePublicKey((Element) currentChild,
uri,
storage);
if (pk != null) {
return pk;
}
if (pk != null) {
KeyResolver.hit(it);
return pk;
}
}
}
}
currentChild=currentChild.getNextSibling();
}
@ -786,50 +763,27 @@ public class KeyInfo extends SignatureElementProxy {
* @throws KeyResolverException
*/
PublicKey getPublicKeyFromInternalResolvers() throws KeyResolverException {
for (int i = 0; i < this.lengthInternalKeyResolver(); i++) {
int length=lengthInternalKeyResolver();
int storageLength=this._storageResolvers.size();
for (int i = 0; i < length; i++) {
KeyResolverSpi keyResolver = this.itemInternalKeyResolver(i);
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
Node currentChild=this._constructionElement.getFirstChild();
String uri=this.getBaseURI();
while (currentChild!=null) {
if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
if (this._storageResolvers.size() == 0) {
// if we do not have storage resolvers, we verify with null
StorageResolver storage = null;
if (keyResolver.engineCanResolve((Element) currentChild,
this.getBaseURI(),
storage)) {
PublicKey pk =
keyResolver
.engineResolvePublicKey((Element) currentChild, this
.getBaseURI(), storage);
for (int k = 0; k < storageLength; k++) {
StorageResolver storage =
(StorageResolver) this._storageResolvers.get(k);
PublicKey pk = keyResolver
.engineLookupAndResolvePublicKey((Element) currentChild, uri, storage);
if (pk != null) {
return pk;
return pk;
}
}
} else {
for (int k = 0; k < this._storageResolvers.size(); k++) {
StorageResolver storage =
(StorageResolver) this._storageResolvers.get(k);
if (keyResolver.engineCanResolve((Element) currentChild,
this.getBaseURI(),
storage)) {
PublicKey pk = keyResolver
.engineResolvePublicKey((Element) currentChild, this
.getBaseURI(), storage);
if (pk != null) {
return pk;
}
}
}
}
}
currentChild=currentChild.getNextSibling();
}
@ -850,12 +804,12 @@ public class KeyInfo extends SignatureElementProxy {
X509Certificate cert = this.getX509CertificateFromInternalResolvers();
if (cert != null) {
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE,
log.log(java.util.logging.Level.FINE,
"I could find a X509Certificate using the per-KeyInfo key resolvers");
return cert;
}
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE,
log.log(java.util.logging.Level.FINE,
"I couldn't find a X509Certificate using the per-KeyInfo key resolvers");
@ -863,12 +817,12 @@ public class KeyInfo extends SignatureElementProxy {
cert = this.getX509CertificateFromStaticResolvers();
if (cert != null) {
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE,
log.log(java.util.logging.Level.FINE,
"I could find a X509Certificate using the system-wide key resolvers");
return cert;
}
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE,
log.log(java.util.logging.Level.FINE,
"I couldn't find a X509Certificate using the system-wide key resolvers");
@ -885,53 +839,44 @@ public class KeyInfo extends SignatureElementProxy {
*/
X509Certificate getX509CertificateFromStaticResolvers()
throws KeyResolverException {
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Start getX509CertificateFromStaticResolvers() with "
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Start getX509CertificateFromStaticResolvers() with "
+ KeyResolver.length() + " resolvers");
String uri=this.getBaseURI();
int length= KeyResolver.length();
int storageLength=this._storageResolvers.size();
Iterator it = KeyResolver.iterator();
for (int i = 0; i <length; i++) {
KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
X509Certificate cert= applyCurrentResolver(uri, storageLength, keyResolver);
if (cert!=null) {
KeyResolver.hit(it);
return cert;
}
}
return null;
}
for (int i = 0; i < KeyResolver.length(); i++) {
KeyResolver keyResolver = KeyResolver.item(i);
Node currentChild=this._constructionElement.getFirstChild();
while (currentChild!=null) {
if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
if (this._storageResolvers.size() == 0) {
private X509Certificate applyCurrentResolver(String uri, int storageLength, KeyResolverSpi keyResolver) throws KeyResolverException {
Node currentChild=this._constructionElement.getFirstChild();
while (currentChild!=null) {
if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
for (int k = 0; k < storageLength; k++) {
StorageResolver storage =
(StorageResolver) this._storageResolvers.get(k);
// if we do not have storage resolvers, we verify with null
StorageResolver storage = null;
X509Certificate cert = keyResolver
.engineLookupResolveX509Certificate((Element) currentChild, uri,
storage);
if (keyResolver.canResolve((Element) currentChild,
this.getBaseURI(), storage)) {
X509Certificate cert =
keyResolver
.resolveX509Certificate((Element) currentChild, this
.getBaseURI(), storage);
if (cert != null) {
return cert;
}
}
} else {
for (int k = 0; k < this._storageResolvers.size(); k++) {
StorageResolver storage =
(StorageResolver) this._storageResolvers.get(k);
if (keyResolver.canResolve((Element) currentChild,
this.getBaseURI(), storage)) {
X509Certificate cert = keyResolver
.resolveX509Certificate((Element) currentChild, this
.getBaseURI(), storage);
if (cert != null) {
return cert;
}
}
if (cert != null) {
return cert;
}
}
}
currentChild=currentChild.getNextSibling();
}
}
return null;
return null;
}
/**
@ -942,55 +887,18 @@ public class KeyInfo extends SignatureElementProxy {
*/
X509Certificate getX509CertificateFromInternalResolvers()
throws KeyResolverException {
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Start getX509CertificateFromInternalResolvers() with "
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Start getX509CertificateFromInternalResolvers() with "
+ this.lengthInternalKeyResolver() + " resolvers");
String uri=this.getBaseURI();
int storageLength=this._storageResolvers.size();
for (int i = 0; i < this.lengthInternalKeyResolver(); i++) {
KeyResolverSpi keyResolver = this.itemInternalKeyResolver(i);
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
Node currentChild=this._constructionElement.getFirstChild();
while (currentChild!=null) {
if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
if (this._storageResolvers.size() == 0) {
// if we do not have storage resolvers, we verify with null
StorageResolver storage = null;
if (keyResolver.engineCanResolve((Element) currentChild,
this.getBaseURI(),
storage)) {
X509Certificate cert =
keyResolver.engineResolveX509Certificate(
(Element) currentChild, this.getBaseURI(), storage);
if (cert != null) {
return cert;
}
}
} else {
for (int k = 0; k < this._storageResolvers.size(); k++) {
StorageResolver storage =
(StorageResolver) this._storageResolvers.get(k);
if (keyResolver.engineCanResolve((Element) currentChild,
this.getBaseURI(),
storage)) {
X509Certificate cert =
keyResolver.engineResolveX509Certificate(
(Element) currentChild, this.getBaseURI(),
storage);
if (cert != null) {
return cert;
}
}
}
}
}
currentChild=currentChild.getNextSibling();
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
X509Certificate cert= applyCurrentResolver(uri, storageLength, keyResolver);
if (cert!=null) {
return cert;
}
}
@ -1006,21 +914,21 @@ public class KeyInfo extends SignatureElementProxy {
SecretKey sk = this.getSecretKeyFromInternalResolvers();
if (sk != null) {
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "I could find a secret key using the per-KeyInfo key resolvers");
log.log(java.util.logging.Level.FINE, "I could find a secret key using the per-KeyInfo key resolvers");
return sk;
}
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "I couldn't find a secret key using the per-KeyInfo key resolvers");
log.log(java.util.logging.Level.FINE, "I couldn't find a secret key using the per-KeyInfo key resolvers");
sk = this.getSecretKeyFromStaticResolvers();
if (sk != null) {
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "I could find a secret key using the system-wide key resolvers");
log.log(java.util.logging.Level.FINE, "I could find a secret key using the system-wide key resolvers");
return sk;
}
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "I couldn't find a secret key using the system-wide key resolvers");
log.log(java.util.logging.Level.FINE, "I couldn't find a secret key using the system-wide key resolvers");
return null;
@ -1034,47 +942,29 @@ public class KeyInfo extends SignatureElementProxy {
*/
SecretKey getSecretKeyFromStaticResolvers() throws KeyResolverException {
for (int i = 0; i < KeyResolver.length(); i++) {
KeyResolver keyResolver = KeyResolver.item(i);
final int length=KeyResolver.length();
int storageLength=this._storageResolvers.size();
Iterator it = KeyResolver.iterator();
for (int i = 0; i < length; i++) {
KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
Node currentChild=this._constructionElement.getFirstChild();
String uri=this.getBaseURI();
while (currentChild!=null) {
if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
if (this._storageResolvers.size() == 0) {
for (int k = 0; k < storageLength; k++) {
StorageResolver storage =
(StorageResolver) this._storageResolvers.get(k);
// if we do not have storage resolvers, we verify with null
StorageResolver storage = null;
if (keyResolver.canResolve((Element) currentChild,
this.getBaseURI(), storage)) {
SecretKey sk =
keyResolver.resolveSecretKey((Element) currentChild,
this.getBaseURI(),
storage);
SecretKey sk =
keyResolver.engineLookupAndResolveSecretKey((Element) currentChild,
uri,
storage);
if (sk != null) {
return sk;
}
}
} else {
for (int k = 0; k < this._storageResolvers.size(); k++) {
StorageResolver storage =
(StorageResolver) this._storageResolvers.get(k);
if (keyResolver.canResolve((Element) currentChild,
this.getBaseURI(), storage)) {
SecretKey sk =
keyResolver.resolveSecretKey((Element) currentChild,
this.getBaseURI(),
storage);
if (sk != null) {
return sk;
}
}
}
}
}
currentChild=currentChild.getNextSibling();
}
@ -1090,51 +980,28 @@ public class KeyInfo extends SignatureElementProxy {
*/
SecretKey getSecretKeyFromInternalResolvers() throws KeyResolverException {
int storageLength=this._storageResolvers.size();
for (int i = 0; i < this.lengthInternalKeyResolver(); i++) {
KeyResolverSpi keyResolver = this.itemInternalKeyResolver(i);
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
Node currentChild=this._constructionElement.getFirstChild();
String uri=this.getBaseURI();
while (currentChild!=null) {
if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
if (this._storageResolvers.size() == 0) {
for (int k = 0; k < storageLength; k++) {
StorageResolver storage =
(StorageResolver) this._storageResolvers.get(k);
// if we do not have storage resolvers, we verify with null
StorageResolver storage = null;
if (keyResolver.engineCanResolve((Element) currentChild,
this.getBaseURI(),
storage)) {
SecretKey sk =
keyResolver
.engineResolveSecretKey((Element) currentChild, this
.getBaseURI(), storage);
SecretKey sk = keyResolver
.engineLookupAndResolveSecretKey((Element) currentChild, uri, storage);
if (sk != null) {
return sk;
}
}
} else {
for (int k = 0; k < this._storageResolvers.size(); k++) {
StorageResolver storage =
(StorageResolver) this._storageResolvers.get(k);
if (keyResolver.engineCanResolve((Element) currentChild,
this.getBaseURI(),
storage)) {
SecretKey sk = keyResolver
.engineResolveSecretKey((Element) currentChild, this
.getBaseURI(), storage);
if (sk != null) {
return sk;
}
}
}
}
}
}
}
currentChild=currentChild.getNextSibling();
}
}
@ -1145,7 +1012,7 @@ public class KeyInfo extends SignatureElementProxy {
/**
* Stores the individual (per-KeyInfo) {@link KeyResolver}s
*/
List _internalKeyResolvers = new ArrayList();
List _internalKeyResolvers = null;
/**
* This method is used to add a custom {@link KeyResolverSpi} to a KeyInfo
@ -1154,6 +1021,9 @@ public class KeyInfo extends SignatureElementProxy {
* @param realKeyResolver
*/
public void registerInternalKeyResolver(KeyResolverSpi realKeyResolver) {
if (_internalKeyResolvers==null) {
_internalKeyResolvers=new ArrayList();
}
this._internalKeyResolvers.add(realKeyResolver);
}
@ -1162,6 +1032,8 @@ public class KeyInfo extends SignatureElementProxy {
* @return the length of the key
*/
int lengthInternalKeyResolver() {
if (_internalKeyResolvers==null)
return 0;
return this._internalKeyResolvers.size();
}
@ -1176,7 +1048,7 @@ public class KeyInfo extends SignatureElementProxy {
}
/** Field _storageResolvers */
List _storageResolvers = new ArrayList();
List _storageResolvers = nullList;
/**
* Method addStorageResolver
@ -1184,19 +1056,11 @@ public class KeyInfo extends SignatureElementProxy {
* @param storageResolver
*/
public void addStorageResolver(StorageResolver storageResolver) {
if (storageResolver != null) {
if (_storageResolvers == nullList ){
_storageResolvers=new ArrayList();
}
this._storageResolvers.add(storageResolver);
}
}
/**
* Method getStorageResolvers
*
* @return the internalStorages
*/
List getStorageResolvers() {
return this._storageResolvers;
}
//J-

View File

@ -2,7 +2,6 @@
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
@ -36,7 +35,7 @@ import com.sun.org.apache.xml.internal.security.keys.content.X509Data;
/**
* Utility class for for <CODE>com.sun.org.apache.xml.internal.security.keys</CODE> package.
*
* @author $Author: raul $
* @author $Author: mullan $
*/
public class KeyUtils {

View File

@ -2,7 +2,6 @@
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
@ -28,7 +27,7 @@ package com.sun.org.apache.xml.internal.security.keys.content;
/**
* Empty interface just to identify Elements that can be cildren of ds:KeyInfo.
*
* @author $Author: blautenb $
* @author $Author: mullan $
*/
public interface KeyInfoContent {
}

View File

@ -20,25 +20,18 @@
*/
package com.sun.org.apache.xml.internal.security.keys.content;
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
import com.sun.org.apache.xml.internal.security.utils.Constants;
import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
*
* @author $Author: raul $
* @author $Author: mullan $
*/
public class KeyName extends SignatureElementProxy implements KeyInfoContent {
/** {@link java.util.logging} logging facility */
static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(KeyName.class.getName());
/**
* Constructor KeyName
*

View File

@ -20,11 +20,8 @@
*/
package com.sun.org.apache.xml.internal.security.keys.content;
import java.security.PublicKey;
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
import com.sun.org.apache.xml.internal.security.keys.content.keyvalues.DSAKeyValue;
import com.sun.org.apache.xml.internal.security.keys.content.keyvalues.RSAKeyValue;
@ -34,140 +31,131 @@ import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
* The KeyValue element contains a single public key that may be useful in
* validating the signature. Structured formats for defining DSA (REQUIRED)
* and RSA (RECOMMENDED) public keys are defined in Signature Algorithms
* (section 6.4). The KeyValue element may include externally defined public
* keys values represented as PCDATA or element types from an external namespace.
* keys values represented as PCDATA or element types from an external
* namespace.
*
* @author $Author: vishal $
* @author $Author: mullan $
*/
public class KeyValue extends SignatureElementProxy implements KeyInfoContent {
/** {@link java.util.logging} logging facility */
static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(KeyValue.class.getName());
/**
* Constructor KeyValue
*
* @param doc
* @param dsaKeyValue
*/
public KeyValue(Document doc, DSAKeyValue dsaKeyValue) {
/**
* Constructor KeyValue
*
* @param doc
* @param dsaKeyValue
*/
public KeyValue(Document doc, DSAKeyValue dsaKeyValue) {
super(doc);
super(doc);
XMLUtils.addReturnToElement(this._constructionElement);
this._constructionElement.appendChild(dsaKeyValue.getElement());
XMLUtils.addReturnToElement(this._constructionElement);
}
XMLUtils.addReturnToElement(this._constructionElement);
this._constructionElement.appendChild(dsaKeyValue.getElement());
XMLUtils.addReturnToElement(this._constructionElement);
}
/**
* Constructor KeyValue
*
* @param doc
* @param rsaKeyValue
*/
public KeyValue(Document doc, RSAKeyValue rsaKeyValue) {
/**
* Constructor KeyValue
*
* @param doc
* @param rsaKeyValue
*/
public KeyValue(Document doc, RSAKeyValue rsaKeyValue) {
super(doc);
super(doc);
XMLUtils.addReturnToElement(this._constructionElement);
this._constructionElement.appendChild(rsaKeyValue.getElement());
XMLUtils.addReturnToElement(this._constructionElement);
}
XMLUtils.addReturnToElement(this._constructionElement);
this._constructionElement.appendChild(rsaKeyValue.getElement());
XMLUtils.addReturnToElement(this._constructionElement);
}
/**
* Constructor KeyValue
*
* @param doc
* @param unknownKeyValue
*/
public KeyValue(Document doc, Element unknownKeyValue) {
/**
* Constructor KeyValue
*
* @param doc
* @param unknownKeyValue
*/
public KeyValue(Document doc, Element unknownKeyValue) {
super(doc);
super(doc);
XMLUtils.addReturnToElement(this._constructionElement);
this._constructionElement.appendChild(unknownKeyValue);
XMLUtils.addReturnToElement(this._constructionElement);
}
XMLUtils.addReturnToElement(this._constructionElement);
this._constructionElement.appendChild(unknownKeyValue);
XMLUtils.addReturnToElement(this._constructionElement);
}
/**
* Constructor KeyValue
*
* @param doc
* @param pk
*/
public KeyValue(Document doc, PublicKey pk) {
/**
* Constructor KeyValue
*
* @param doc
* @param pk
*/
public KeyValue(Document doc, PublicKey pk) {
super(doc);
super(doc);
XMLUtils.addReturnToElement(this._constructionElement);
XMLUtils.addReturnToElement(this._constructionElement);
if (pk instanceof java.security.interfaces.DSAPublicKey) {
DSAKeyValue dsa = new DSAKeyValue(this._doc, pk);
if (pk instanceof java.security.interfaces.DSAPublicKey) {
DSAKeyValue dsa = new DSAKeyValue(this._doc, pk);
this._constructionElement.appendChild(dsa.getElement());
XMLUtils.addReturnToElement(this._constructionElement);
} else if (pk instanceof java.security.interfaces.RSAPublicKey) {
RSAKeyValue rsa = new RSAKeyValue(this._doc, pk);
this._constructionElement.appendChild(dsa.getElement());
XMLUtils.addReturnToElement(this._constructionElement);
} else if (pk instanceof java.security.interfaces.RSAPublicKey) {
RSAKeyValue rsa = new RSAKeyValue(this._doc, pk);
this._constructionElement.appendChild(rsa.getElement());
XMLUtils.addReturnToElement(this._constructionElement);
}
}
this._constructionElement.appendChild(rsa.getElement());
XMLUtils.addReturnToElement(this._constructionElement);
}
}
/**
* Constructor KeyValue
*
* @param element
* @param BaseURI
* @throws XMLSecurityException
*/
public KeyValue(Element element, String BaseURI)
/**
* Constructor KeyValue
*
* @param element
* @param BaseURI
* @throws XMLSecurityException
*/
public KeyValue(Element element, String BaseURI)
throws XMLSecurityException {
super(element, BaseURI);
}
super(element, BaseURI);
}
/**
* Method getPublicKey
*
* @return the public key
* @throws XMLSecurityException
*/
public PublicKey getPublicKey() throws XMLSecurityException {
/**
* Method getPublicKey
*
* @return the public key
* @throws XMLSecurityException
*/
public PublicKey getPublicKey() throws XMLSecurityException {
Element rsa = XMLUtils.selectDsNode
(this._constructionElement.getFirstChild(),
Constants._TAG_RSAKEYVALUE,0);
Element rsa = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
Constants._TAG_RSAKEYVALUE,0);
if (rsa != null) {
RSAKeyValue kv = new RSAKeyValue(rsa,
this._baseURI);
if (rsa != null) {
RSAKeyValue kv = new RSAKeyValue(rsa, this._baseURI);
return kv.getPublicKey();
}
}
Element dsa = XMLUtils.selectDsNode(this._constructionElement,
Constants._TAG_DSAKEYVALUE,0);
if (dsa != null) {
DSAKeyValue kv = new DSAKeyValue(dsa,
this._baseURI);
Element dsa = XMLUtils.selectDsNode
(this._constructionElement.getFirstChild(),
Constants._TAG_DSAKEYVALUE,0);
if (dsa != null) {
DSAKeyValue kv = new DSAKeyValue(dsa, this._baseURI);
return kv.getPublicKey();
}
}
return null;
}
return null;
}
/** @inheritDoc */
public String getBaseLocalName() {
return Constants._TAG_KEYVALUE;
}
/** @inheritDoc */
public String getBaseLocalName() {
return Constants._TAG_KEYVALUE;
}
}

View File

@ -20,25 +20,18 @@
*/
package com.sun.org.apache.xml.internal.security.keys.content;
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
import com.sun.org.apache.xml.internal.security.utils.Constants;
import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
*
* @author $Author: raul $
* @author $Author: mullan $
*/
public class MgmtData extends SignatureElementProxy implements KeyInfoContent {
/** {@link java.util.logging} logging facility */
static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(MgmtData.class.getName());
/**
* Constructor MgmtData
*

View File

@ -20,25 +20,18 @@
*/
package com.sun.org.apache.xml.internal.security.keys.content;
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
import com.sun.org.apache.xml.internal.security.utils.Constants;
import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
import org.w3c.dom.Element;
/**
*
* @author $Author: raul $
* @author $Author: mullan $
* $todo$ Implement
*/
public class PGPData extends SignatureElementProxy implements KeyInfoContent {
/** {@link java.util.logging} logging facility */
static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(PGPData.class.getName());
/**
* Constructor PGPData
*

View File

@ -20,9 +20,6 @@
*/
package com.sun.org.apache.xml.internal.security.keys.content;
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
import com.sun.org.apache.xml.internal.security.signature.XMLSignatureException;
import com.sun.org.apache.xml.internal.security.transforms.Transforms;
@ -33,17 +30,13 @@ import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
*
* @author $Author: raul $
* @author $Author: mullan $
*/
public class RetrievalMethod extends SignatureElementProxy
implements KeyInfoContent {
/** {@link java.util.logging} logging facility */
static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(RetrievalMethod.class.getName());
//J-
/** DSA retrieval */
public static final String TYPE_DSA = Constants.SignatureSpecNS + "DSAKeyValue";
@ -133,7 +126,7 @@ public class RetrievalMethod extends SignatureElementProxy
try {
Element transformsElem =
XMLUtils.selectDsNode(this._constructionElement,
XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
Constants
._TAG_TRANSFORMS, 0);

View File

@ -20,25 +20,18 @@
*/
package com.sun.org.apache.xml.internal.security.keys.content;
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
import com.sun.org.apache.xml.internal.security.utils.Constants;
import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
import org.w3c.dom.Element;
/**
*
* @author $Author: raul $
* @author $Author: mullan $
* $todo$ implement
*/
public class SPKIData extends SignatureElementProxy implements KeyInfoContent {
/** {@link java.util.logging} logging facility */
static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(SPKIData.class.getName());
/**
* Constructor SPKIData
*

View File

@ -41,7 +41,7 @@ import org.w3c.dom.Node;
/**
*
* @author $Author: raul $
* @author $Author: mullan $
*/
public class X509Data extends SignatureElementProxy implements KeyInfoContent {
@ -72,60 +72,17 @@ public class X509Data extends SignatureElementProxy implements KeyInfoContent {
throws XMLSecurityException {
super(element, BaseURI);
boolean noElements=true;
Node sibling=this._constructionElement.getFirstChild();
while (sibling!=null) {
if (sibling.getNodeType()!=Node.ELEMENT_NODE) {
sibling=sibling.getNextSibling();
continue;
}
noElements=false;
Element currentElem = (Element) sibling;
sibling=sibling.getNextSibling();
String localname = currentElem.getLocalName();
if (currentElem.getNamespaceURI().equals(Constants.SignatureSpecNS)) {
if (localname.equals(Constants._TAG_X509ISSUERSERIAL)) {
XMLX509IssuerSerial is = new XMLX509IssuerSerial(currentElem,
BaseURI);
this.add(is);
} else if (localname.equals(Constants._TAG_X509SKI)) {
XMLX509SKI ski = new XMLX509SKI(currentElem, BaseURI);
this.add(ski);
} else if (localname.equals(Constants._TAG_X509SUBJECTNAME)) {
XMLX509SubjectName sn = new XMLX509SubjectName(currentElem,
BaseURI);
this.add(sn);
} else if (localname.equals(Constants._TAG_X509CERTIFICATE)) {
XMLX509Certificate cert = new XMLX509Certificate(currentElem,
BaseURI);
this.add(cert);
} else if (localname.equals(Constants._TAG_X509CRL)) {
XMLX509CRL crl = new XMLX509CRL(currentElem, BaseURI);
this.add(crl);
} else {
log.log(java.util.logging.Level.WARNING, "Found a " + currentElem.getTagName() + " element in "
+ Constants._TAG_X509DATA);
this.addUnknownElement(currentElem);
}
} else {
log.log(java.util.logging.Level.WARNING, "Found a " + currentElem.getTagName() + " element in "
+ Constants._TAG_X509DATA);
this.addUnknownElement(currentElem);
}
return;
}
if (noElements) {
Object exArgs[] = { "Elements", Constants._TAG_X509DATA };
throw new XMLSecurityException("xml.WrongContent", exArgs);
}
/* No Elements found */
Object exArgs[] = { "Elements", Constants._TAG_X509DATA };
throw new XMLSecurityException("xml.WrongContent", exArgs);
}
/**
@ -169,11 +126,9 @@ public class X509Data extends SignatureElementProxy implements KeyInfoContent {
*/
public void add(XMLX509IssuerSerial xmlX509IssuerSerial) {
if (this._state == MODE_SIGN) {
this._constructionElement
.appendChild(xmlX509IssuerSerial.getElement());
XMLUtils.addReturnToElement(this._constructionElement);
}
}
/**
@ -202,11 +157,8 @@ public class X509Data extends SignatureElementProxy implements KeyInfoContent {
* @param xmlX509SKI
*/
public void add(XMLX509SKI xmlX509SKI) {
if (this._state == MODE_SIGN) {
this._constructionElement.appendChild(xmlX509SKI.getElement());
XMLUtils.addReturnToElement(this._constructionElement);
}
}
/**
@ -233,11 +185,8 @@ public class X509Data extends SignatureElementProxy implements KeyInfoContent {
* @param xmlX509SubjectName
*/
public void add(XMLX509SubjectName xmlX509SubjectName) {
if (this._state == MODE_SIGN) {
this._constructionElement.appendChild(xmlX509SubjectName.getElement());
XMLUtils.addReturnToElement(this._constructionElement);
}
}
/**
@ -266,11 +215,8 @@ public class X509Data extends SignatureElementProxy implements KeyInfoContent {
* @param xmlX509Certificate
*/
public void add(XMLX509Certificate xmlX509Certificate) {
if (this._state == MODE_SIGN) {
this._constructionElement.appendChild(xmlX509Certificate.getElement());
XMLUtils.addReturnToElement(this._constructionElement);
}
}
/**
@ -288,11 +234,8 @@ public class X509Data extends SignatureElementProxy implements KeyInfoContent {
* @param xmlX509CRL
*/
public void add(XMLX509CRL xmlX509CRL) {
if (this._state == MODE_SIGN) {
this._constructionElement.appendChild(xmlX509CRL.getElement());
XMLUtils.addReturnToElement(this._constructionElement);
}
}
/**
@ -301,11 +244,8 @@ public class X509Data extends SignatureElementProxy implements KeyInfoContent {
* @param element
*/
public void addUnknownElement(Element element) {
if (this._state == MODE_SIGN) {
this._constructionElement.appendChild(element);
XMLUtils.addReturnToElement(this._constructionElement);
}
}
/**
@ -479,7 +419,7 @@ public class X509Data extends SignatureElementProxy implements KeyInfoContent {
* TODO implement
**/
public Element itemUnknownElement(int i) {
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "itemUnknownElement not implemented:"+i);
log.log(java.util.logging.Level.FINE, "itemUnknownElement not implemented:"+i);
return null;
}

View File

@ -20,8 +20,6 @@
*/
package com.sun.org.apache.xml.internal.security.keys.content.keyvalues;
import java.math.BigInteger;
import java.security.Key;
import java.security.KeyFactory;
@ -39,18 +37,13 @@ import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
*
* @author $Author: raul $
* @author $Author: mullan $
*/
public class DSAKeyValue extends SignatureElementProxy
implements KeyValueContent {
/** {@link java.util.logging} logging facility */
static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(DSAKeyValue.class.getName());
/**
* Constructor DSAKeyValue
*

View File

@ -2,7 +2,6 @@
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
@ -32,7 +31,7 @@ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
*
*
*
* @author $Author: raul $
* @author $Author: mullan $
*
*/
public interface KeyValueContent {

View File

@ -20,8 +20,6 @@
*/
package com.sun.org.apache.xml.internal.security.keys.content.keyvalues;
import java.math.BigInteger;
import java.security.Key;
import java.security.KeyFactory;
@ -39,19 +37,13 @@ import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
*
* @author $Author: raul $
* @author $Author: mullan $
*/
public class RSAKeyValue extends SignatureElementProxy
implements KeyValueContent {
/** {@link java.util.logging} logging facility */
static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(
RSAKeyValue.class.getName());
/**
* Constructor RSAKeyValue
*

View File

@ -20,30 +20,20 @@
*/
package com.sun.org.apache.xml.internal.security.keys.content.x509;
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
import com.sun.org.apache.xml.internal.security.utils.Constants;
import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
*
*
*
*
* @author $Author: raul $
* @author $Author: mullan $
*
*/
public class XMLX509CRL extends SignatureElementProxy
implements XMLX509DataContent {
/** {@link java.util.logging} logging facility */
static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(XMLX509CRL.class.getName());
/**
* Constructor XMLX509CRL
*

View File

@ -20,8 +20,6 @@
*/
package com.sun.org.apache.xml.internal.security.keys.content.x509;
import java.io.ByteArrayInputStream;
import java.security.PublicKey;
import java.security.cert.CertificateException;
@ -34,18 +32,13 @@ import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
*
* @author $Author: raul $
* @author $Author: mullan $
*/
public class XMLX509Certificate extends SignatureElementProxy
implements XMLX509DataContent {
/** {@link java.util.logging} logging facility */
static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(XMLX509Certificate.class.getName());
/** Field JCA_CERT_ID */
public static final String JCA_CERT_ID = "X.509";
@ -146,23 +139,25 @@ public class XMLX509Certificate extends SignatureElementProxy
return null;
}
/** @inheritDoc */
public boolean equals(Object obj) {
/** @inheritDoc */
public boolean equals(Object obj) {
try {
if (!obj.getClass().getName().equals(this.getClass().getName())) {
if (obj == null) {
return false;
}
}
if (!this.getClass().getName().equals(obj.getClass().getName())) {
return false;
}
XMLX509Certificate other = (XMLX509Certificate) obj;
try {
XMLX509Certificate other = (XMLX509Certificate) obj;
/** $todo$ or should be create X509Certificates and use the equals() from the Certs */
return java.security.MessageDigest.isEqual(other.getCertificateBytes(),
this.getCertificateBytes());
} catch (XMLSecurityException ex) {
return false;
}
}
/** $todo$ or should be create X509Certificates and use the equals() from the Certs */
return java.security.MessageDigest.isEqual
(other.getCertificateBytes(), this.getCertificateBytes());
} catch (XMLSecurityException ex) {
return false;
}
}
/** @inheritDoc */
public String getBaseLocalName() {

View File

@ -2,7 +2,6 @@
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
@ -28,7 +27,7 @@ package com.sun.org.apache.xml.internal.security.keys.content.x509;
/**
* Just used for tagging contents that are allowed inside a ds:X509Data Element.
*
* @author $Author: blautenb $
* @author $Author: mullan $
*/
public interface XMLX509DataContent {
}

View File

@ -20,8 +20,6 @@
*/
package com.sun.org.apache.xml.internal.security.keys.content.x509;
import java.math.BigInteger;
import java.security.cert.X509Certificate;
@ -33,148 +31,139 @@ import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
*
* @author $Author: raul $
* @author $Author: mullan $
*/
public class XMLX509IssuerSerial extends SignatureElementProxy
implements XMLX509DataContent {
/** {@link java.util.logging} logging facility */
/** {@link java.util.logging} logging facility */
static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(
XMLX509IssuerSerial.class.getName());
/**
* Constructor XMLX509IssuerSerial
*
* @param element
* @param BaseURI
* @throws XMLSecurityException
*/
public XMLX509IssuerSerial(Element element, String BaseURI)
/**
* Constructor XMLX509IssuerSerial
*
* @param element
* @param baseURI
* @throws XMLSecurityException
*/
public XMLX509IssuerSerial(Element element, String baseURI)
throws XMLSecurityException {
super(element, BaseURI);
}
super(element, baseURI);
}
/**
* Constructor XMLX509IssuerSerial
*
* @param doc
* @param X509IssuerName
* @param X509SerialNumber
*/
public XMLX509IssuerSerial(Document doc, String X509IssuerName,
BigInteger X509SerialNumber) {
/**
* Constructor XMLX509IssuerSerial
*
* @param doc
* @param x509IssuerName
* @param x509SerialNumber
*/
public XMLX509IssuerSerial(Document doc, String x509IssuerName,
BigInteger x509SerialNumber) {
super(doc);
super(doc);
XMLUtils.addReturnToElement(this._constructionElement);
addTextElement(x509IssuerName, Constants._TAG_X509ISSUERNAME);
addTextElement(x509SerialNumber.toString(), Constants._TAG_X509SERIALNUMBER);
}
XMLUtils.addReturnToElement(this._constructionElement);
this.addTextElement(X509IssuerName, Constants._TAG_X509ISSUERNAME);
XMLUtils.addReturnToElement(this._constructionElement);
this.addTextElement(X509SerialNumber.toString(), Constants._TAG_X509SERIALNUMBER);
}
/**
* Constructor XMLX509IssuerSerial
*
* @param doc
* @param x509IssuerName
* @param x509SerialNumber
*/
public XMLX509IssuerSerial(Document doc, String x509IssuerName,
String x509SerialNumber) {
this(doc, x509IssuerName, new BigInteger(x509SerialNumber));
}
/**
* Constructor XMLX509IssuerSerial
*
* @param doc
* @param X509IssuerName
* @param X509SerialNumber
*/
public XMLX509IssuerSerial(Document doc, String X509IssuerName,
String X509SerialNumber) {
this(doc, X509IssuerName, new BigInteger(X509SerialNumber));
}
/**
* Constructor XMLX509IssuerSerial
*
* @param doc
* @param x509IssuerName
* @param x509SerialNumber
*/
public XMLX509IssuerSerial(Document doc, String x509IssuerName,
int x509SerialNumber) {
this(doc, x509IssuerName,
new BigInteger(Integer.toString(x509SerialNumber)));
}
/**
* Constructor XMLX509IssuerSerial
*
* @param doc
* @param X509IssuerName
* @param X509SerialNumber
*/
public XMLX509IssuerSerial(Document doc, String X509IssuerName,
int X509SerialNumber) {
this(doc, X509IssuerName,
new BigInteger(Integer.toString(X509SerialNumber)));
}
/**
* Constructor XMLX509IssuerSerial
*
* @param doc
* @param x509certificate
*/
public XMLX509IssuerSerial(Document doc, X509Certificate x509certificate) {
/**
* Constructor XMLX509IssuerSerial
*
* @param doc
* @param x509certificate
*/
public XMLX509IssuerSerial(Document doc, X509Certificate x509certificate) {
this(doc,
RFC2253Parser.normalize(x509certificate.getIssuerDN().getName()),
x509certificate.getSerialNumber());
}
this(doc,
RFC2253Parser.normalize(x509certificate.getIssuerDN().getName()),
x509certificate.getSerialNumber());
}
/**
* Method getSerialNumber
*
* @return the serial number
*/
public BigInteger getSerialNumber() {
/**
* Method getSerialNumber
*
*
* @return the serial number
*/
public BigInteger getSerialNumber() {
String text = this.getTextFromChildElement
(Constants._TAG_X509SERIALNUMBER, Constants.SignatureSpecNS);
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "X509SerialNumber text: " + text);
String text =
this.getTextFromChildElement(Constants._TAG_X509SERIALNUMBER,
Constants.SignatureSpecNS);
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "In dem X509SerialNumber wurde gefunden: " + text);
return new BigInteger(text);
}
return new BigInteger(text);
}
/**
* Method getSerialNumberInteger
*
* @return the serial number as plain int
*/
public int getSerialNumberInteger() {
return this.getSerialNumber().intValue();
}
/**
* Method getSerialNumberInteger
*
*
* @return the serial number as plain int
*/
public int getSerialNumberInteger() {
return this.getSerialNumber().intValue();
}
/**
* Method getIssuerName
*
* @return the issuer name
*/
public String getIssuerName() {
/**
* Method getIssuerName
*
*
* @return the issuer name
*/
public String getIssuerName() {
return RFC2253Parser
.normalize(this
.getTextFromChildElement(Constants._TAG_X509ISSUERNAME,
Constants.SignatureSpecNS));
}
return RFC2253Parser
.normalize(this
.getTextFromChildElement(Constants._TAG_X509ISSUERNAME,
Constants.SignatureSpecNS));
}
/** @inheritDoc */
public boolean equals(Object obj) {
/** @inheritDoc */
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (!this.getClass().getName().equals(obj.getClass().getName())) {
return false;
}
if (!obj.getClass().getName().equals(this.getClass().getName())) {
return false;
}
XMLX509IssuerSerial other = (XMLX509IssuerSerial) obj;
XMLX509IssuerSerial other = (XMLX509IssuerSerial) obj;
return this.getSerialNumber().equals(other.getSerialNumber())
&& this.getIssuerName().equals(other.getIssuerName());
}
if (other.getSerialNumber().equals(this.getSerialNumber())
&& other.getIssuerName().equals(this.getIssuerName())) {
return true;
}
return false;
}
/** @inheritDoc */
public String getBaseLocalName() {
return Constants._TAG_X509ISSUERSERIAL;
}
/** @inheritDoc */
public String getBaseLocalName() {
return Constants._TAG_X509ISSUERSERIAL;
}
}

View File

@ -20,8 +20,6 @@
*/
package com.sun.org.apache.xml.internal.security.keys.content.x509;
import java.io.IOException;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
@ -36,192 +34,143 @@ import com.sun.org.apache.xml.internal.security.utils.SignatureElementProxy;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import sun.security.util.DerValue;
/**
* Handles SubjectKeyIdentifier (SKI) for X.509v3.
*
* @author $Author: raul $
* @see <A HREF="http://java.sun.com/products/jdk/1.2/docs/api/java/security/cert/X509Extension.html">Interface X509Extension</A>
* @author $Author: mullan $
* @see <A HREF="http://java.sun.com/j2se/1.5.0/docs/api/java/security/cert/X509Extension.html">Interface X509Extension</A>
*/
public class XMLX509SKI extends SignatureElementProxy
implements XMLX509DataContent {
/** {@link java.util.logging} logging facility */
/** {@link java.util.logging} logging facility */
static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(XMLX509SKI.class.getName());
/**
* <CODE>SubjectKeyIdentifier (id-ce-subjectKeyIdentifier) (2.5.29.14)</CODE>:
* This extension identifies the public key being certified. It enables
* distinct keys used by the same subject to be differentiated
* (e.g., as key updating occurs).
* <BR />
* A key identifer shall be unique with respect to all key identifiers
* for the subject with which it is used. This extension is always non-critical.
*/
public static final String SKI_OID = "2.5.29.14";
/**
* <CODE>SubjectKeyIdentifier (id-ce-subjectKeyIdentifier) (2.5.29.14)</CODE>:
* This extension identifies the public key being certified. It enables
* distinct keys used by the same subject to be differentiated
* (e.g., as key updating occurs).
* <BR />
* A key identifer shall be unique with respect to all key identifiers
* for the subject with which it is used. This extension is always non-critical.
*/
public static final String SKI_OID = "2.5.29.14";
/**
* Constructor X509SKI
*
* @param doc
* @param skiBytes
*/
public XMLX509SKI(Document doc, byte[] skiBytes) {
/**
* Constructor X509SKI
*
* @param doc
* @param skiBytes
*/
public XMLX509SKI(Document doc, byte[] skiBytes) {
super(doc);
this.addBase64Text(skiBytes);
}
super(doc);
this.addBase64Text(skiBytes);
}
/**
* Constructor XMLX509SKI
*
* @param doc
* @param x509certificate
* @throws XMLSecurityException
*/
public XMLX509SKI(Document doc, X509Certificate x509certificate)
/**
* Constructor XMLX509SKI
*
* @param doc
* @param x509certificate
* @throws XMLSecurityException
*/
public XMLX509SKI(Document doc, X509Certificate x509certificate)
throws XMLSecurityException {
super(doc);
this.addBase64Text(XMLX509SKI.getSKIBytesFromCert(x509certificate));
}
super(doc);
this.addBase64Text(XMLX509SKI.getSKIBytesFromCert(x509certificate));
}
/**
* Constructor XMLX509SKI
*
* @param element
* @param BaseURI
* @throws XMLSecurityException
*/
public XMLX509SKI(Element element, String BaseURI)
/**
* Constructor XMLX509SKI
*
* @param element
* @param BaseURI
* @throws XMLSecurityException
*/
public XMLX509SKI(Element element, String BaseURI)
throws XMLSecurityException {
super(element, BaseURI);
}
super(element, BaseURI);
}
/**
* Method getSKIBytes
*
* @return the skibytes
* @throws XMLSecurityException
*/
public byte[] getSKIBytes() throws XMLSecurityException {
return this.getBytesFromTextChild();
}
/**
* Method getSKIBytes
*
* @return the skibytes
* @throws XMLSecurityException
*/
public byte[] getSKIBytes() throws XMLSecurityException {
return this.getBytesFromTextChild();
}
/**
* Method getSKIBytesFromCert
*
* @param cert
* @return sky bytes from the given certificate
*
* @throws XMLSecurityException
* @see java.security.cert.X509Extension#getExtensionValue(java.lang.String)
*/
public static byte[] getSKIBytesFromCert(X509Certificate cert)
throws XMLSecurityException {
/**
* Method getSKIBytesFromCert
*
* @param cert
* @return ski bytes from the given certificate
*
* @throws XMLSecurityException
* @see java.security.cert.X509Extension#getExtensionValue(java.lang.String)
*/
public static byte[] getSKIBytesFromCert(X509Certificate cert)
throws XMLSecurityException {
try {
/*
* Gets the DER-encoded OCTET string for the extension value (extnValue)
* identified by the passed-in oid String. The oid string is
* represented by a set of positive whole numbers separated by periods.
*/
byte[] derEncodedValue = cert.getExtensionValue(XMLX509SKI.SKI_OID);
if (cert.getVersion() < 3) {
if (cert.getVersion() < 3) {
Object exArgs[] = { new Integer(cert.getVersion()) };
throw new XMLSecurityException("certificate.noSki.lowVersion",
exArgs);
}
}
byte[] extensionValue = null;
/**
* Use sun.security.util.DerValue if it is present.
*/
try {
DerValue dervalue = new DerValue(derEncodedValue);
if (dervalue == null) {
throw new XMLSecurityException("certificate.noSki.null");
}
if (dervalue.tag != DerValue.tag_OctetString) {
throw new XMLSecurityException("certificate.noSki.notOctetString");
}
extensionValue = dervalue.getOctetString();
} catch (NoClassDefFoundError e) {
}
/**
* Fall back to org.bouncycastle.asn1.DERInputStream
*/
if (extensionValue == null) {
try {
Class clazz = Class.forName("org.bouncycastle.asn1.DERInputStream");
if (clazz != null) {
Constructor constructor = clazz.getConstructor(new Class[]{InputStream.class});
InputStream is = (InputStream) constructor.newInstance(new Object[]{new ByteArrayInputStream(derEncodedValue)});
Method method = clazz.getMethod("readObject", new Class[]{});
Object obj = method.invoke(is, new Object[]{});
if (obj == null) {
throw new XMLSecurityException("certificate.noSki.null");
}
Class clazz2 = Class.forName("org.bouncycastle.asn1.ASN1OctetString");
if (!clazz2.isInstance(obj)) {
throw new XMLSecurityException("certificate.noSki.notOctetString");
}
Method method2 = clazz2.getMethod("getOctets", new Class[]{});
extensionValue = (byte[]) method2.invoke(obj, new Object[]{});
}
} catch (Throwable t) {
}
}
/**
* Strip away first two bytes from the DerValue (tag and length)
*/
byte abyte0[] = new byte[extensionValue.length - 2];
System.arraycopy(extensionValue, 2, abyte0, 0, abyte0.length);
/*
byte abyte0[] = new byte[derEncodedValue.length - 4];
System.arraycopy(derEncodedValue, 4, abyte0, 0, abyte0.length);
/*
* Gets the DER-encoded OCTET string for the extension value
* (extnValue) identified by the passed-in oid String. The oid
* string is represented by a set of positive whole numbers
* separated by periods.
*/
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Base64 of SKI is " + Base64.encode(abyte0));
byte[] extensionValue = cert.getExtensionValue(XMLX509SKI.SKI_OID);
if (extensionValue == null) {
throw new XMLSecurityException("certificate.noSki.null");
}
return abyte0;
} catch (IOException ex) {
throw new XMLSecurityException("generic.EmptyMessage", ex);
}
}
/**
* Strip away first four bytes from the extensionValue
* The first two bytes are the tag and length of the extensionValue
* OCTET STRING, and the next two bytes are the tag and length of
* the skid OCTET STRING.
*/
byte skidValue[] = new byte[extensionValue.length - 4];
/** @inheritDoc */
public boolean equals(Object obj) {
System.arraycopy(extensionValue, 4, skidValue, 0, skidValue.length);
if (!obj.getClass().getName().equals(this.getClass().getName())) {
return false;
}
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "Base64 of SKI is " + Base64.encode(skidValue));
}
XMLX509SKI other = (XMLX509SKI) obj;
return skidValue;
}
try {
return java.security.MessageDigest.isEqual(other.getSKIBytes(),
/** @inheritDoc */
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (!this.getClass().getName().equals(obj.getClass().getName())) {
return false;
}
XMLX509SKI other = (XMLX509SKI) obj;
try {
return java.security.MessageDigest.isEqual(other.getSKIBytes(),
this.getSKIBytes());
} catch (XMLSecurityException ex) {
return false;
}
}
} catch (XMLSecurityException ex) {
return false;
}
}
/** @inheritDoc */
public String getBaseLocalName() {
return Constants._TAG_X509SKI;
}
/** @inheritDoc */
public String getBaseLocalName() {
return Constants._TAG_X509SKI;
}
}

View File

@ -20,8 +20,6 @@
*/
package com.sun.org.apache.xml.internal.security.keys.content.x509;
import java.security.cert.X509Certificate;
import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
@ -33,15 +31,11 @@ import org.w3c.dom.Element;
/**
*
* @author $Author: raul $
* @author $Author: mullan $
*/
public class XMLX509SubjectName extends SignatureElementProxy
implements XMLX509DataContent {
/** {@link java.util.logging} logging facility */
static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(XMLX509SubjectName.class.getName());
/**
* Constructor X509SubjectName
*
@ -88,23 +82,21 @@ public class XMLX509SubjectName extends SignatureElementProxy
return RFC2253Parser.normalize(this.getTextFromTextChild());
}
/** @inheritDoc */
public boolean equals(Object obj) {
/** @inheritDoc */
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (!obj.getClass().getName().equals(this.getClass().getName())) {
return false;
}
if (!this.getClass().getName().equals(obj.getClass().getName())) {
return false;
}
XMLX509SubjectName other = (XMLX509SubjectName) obj;
String otherSubject = other.getSubjectName();
String thisSubject = this.getSubjectName();
if (otherSubject.equals(thisSubject)) {
return true;
}
return false;
XMLX509SubjectName other = (XMLX509SubjectName) obj;
String otherSubject = other.getSubjectName();
String thisSubject = this.getSubjectName();
return thisSubject.equals(otherSubject);
}
/** @inheritDoc */

View File

@ -2,7 +2,6 @@
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
@ -29,7 +28,7 @@ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
/**
*
*
* @author $Author: raul $
* @author $Author: mullan $
*/
public class InvalidKeyResolverException extends XMLSecurityException {

View File

@ -2,7 +2,6 @@
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
@ -26,6 +25,7 @@ package com.sun.org.apache.xml.internal.security.keys.keyresolver;
import java.security.PublicKey;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.crypto.SecretKey;
@ -39,7 +39,8 @@ import org.w3c.dom.Node;
* KeyResolver is factory class for subclass of KeyResolverSpi that
* represent child element of KeyInfo.
*
* @author $Author: raul $
* @author $Author: mullan $
* @version %I%, %G%
*/
public class KeyResolver {
@ -72,6 +73,7 @@ public class KeyResolver {
InstantiationException {
this._resolverSpi =
(KeyResolverSpi) Class.forName(className).newInstance();
this._resolverSpi.setGlobalResolver(true);
}
/**
@ -83,21 +85,17 @@ public class KeyResolver {
return KeyResolver._resolverVector.size();
}
/**
* Method item
*
* @param i
* @return the number i resolver registerd
* @throws KeyResolverException
*/
public static KeyResolver item(int i) throws KeyResolverException {
KeyResolver resolver = (KeyResolver) KeyResolver._resolverVector.get(i);
if (resolver==null) {
throw new KeyResolverException("utils.resolver.noClass");
}
return resolver;
public static void hit(Iterator hintI) {
ResolverIterator hint = (ResolverIterator) hintI;
int i = hint.i;
if (i!=1 && hint.res ==_resolverVector) {
List resolverVector=(List)((ArrayList)_resolverVector).clone();
Object ob=resolverVector.remove(i-1);
resolverVector.add(0,ob);
_resolverVector=resolverVector;
} else {
//System.out.println("KeyResolver hitting");
}
}
/**
@ -106,17 +104,19 @@ public class KeyResolver {
* @param element
* @param BaseURI
* @param storage
* @return the instance that happends to implement the thing.
* @return The certificate represented by the element.
*
* @throws KeyResolverException
*/
public static final KeyResolver getInstance(
public static final X509Certificate getX509Certificate(
Element element, String BaseURI, StorageResolver storage)
throws KeyResolverException {
for (int i = 0; i < KeyResolver._resolverVector.size(); i++) {
// use the old vector to not be hit by updates
List resolverVector = KeyResolver._resolverVector;
for (int i = 0; i < resolverVector.size(); i++) {
KeyResolver resolver=
(KeyResolver) KeyResolver._resolverVector.get(i);
(KeyResolver) resolverVector.get(i);
if (resolver==null) {
Object exArgs[] = {
@ -127,11 +127,63 @@ public class KeyResolver {
throw new KeyResolverException("utils.resolver.noClass", exArgs);
}
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "check resolvability by class " + resolver.getClass());
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "check resolvability by class " + resolver.getClass());
if (resolver.canResolve(element, BaseURI, storage)) {
return resolver;
X509Certificate cert=resolver.resolveX509Certificate(element, BaseURI, storage);
if (cert!=null) {
return cert;
}
}
Object exArgs[] = {
(((element != null) && (element.getNodeType() == Node.ELEMENT_NODE))
? element.getTagName()
: "null") };
throw new KeyResolverException("utils.resolver.noClass", exArgs);
}
/**
* Method getInstance
*
* @param element
* @param BaseURI
* @param storage
* @return the public key contained in the element
*
* @throws KeyResolverException
*/
public static final PublicKey getPublicKey(
Element element, String BaseURI, StorageResolver storage)
throws KeyResolverException {
List resolverVector = KeyResolver._resolverVector;
for (int i = 0; i < resolverVector.size(); i++) {
KeyResolver resolver=
(KeyResolver) resolverVector.get(i);
if (resolver==null) {
Object exArgs[] = {
(((element != null)
&& (element.getNodeType() == Node.ELEMENT_NODE))
? element.getTagName()
: "null") };
throw new KeyResolverException("utils.resolver.noClass", exArgs);
}
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "check resolvability by class " + resolver.getClass());
PublicKey cert=resolver.resolvePublicKey(element, BaseURI, storage);
if (cert!=null) {
if (i!=0 && resolverVector==_resolverVector) {
//update resolver.
resolverVector=(List)((ArrayList)_resolverVector).clone();
Object ob=resolverVector.remove(i);
resolverVector.add(0,ob);
_resolverVector=resolverVector;
}
return cert;
}
}
@ -182,34 +234,6 @@ public class KeyResolver {
KeyResolver._resolverVector.add(0, className);
}
/*
* Method resolve
*
* @param element
*
* @throws KeyResolverException
*/
/**
* Method resolveStatic
*
* @param element
* @param BaseURI
* @param storage
* @return resolve from the static register an element
*
* @throws KeyResolverException
*/
public static PublicKey resolveStatic(
Element element, String BaseURI, StorageResolver storage)
throws KeyResolverException {
KeyResolver myResolver = KeyResolver.getInstance(element, BaseURI,
storage);
return myResolver.resolvePublicKey(element, BaseURI, storage);
}
/**
* Method resolve
*
@ -223,7 +247,7 @@ public class KeyResolver {
public PublicKey resolvePublicKey(
Element element, String BaseURI, StorageResolver storage)
throws KeyResolverException {
return this._resolverSpi.engineResolvePublicKey(element, BaseURI, storage);
return this._resolverSpi.engineLookupAndResolvePublicKey(element, BaseURI, storage);
}
/**
@ -239,7 +263,7 @@ public class KeyResolver {
public X509Certificate resolveX509Certificate(
Element element, String BaseURI, StorageResolver storage)
throws KeyResolverException {
return this._resolverSpi.engineResolveX509Certificate(element, BaseURI,
return this._resolverSpi.engineLookupResolveX509Certificate(element, BaseURI,
storage);
}
@ -253,7 +277,7 @@ public class KeyResolver {
public SecretKey resolveSecretKey(
Element element, String BaseURI, StorageResolver storage)
throws KeyResolverException {
return this._resolverSpi.engineResolveSecretKey(element, BaseURI,
return this._resolverSpi.engineLookupAndResolveSecretKey(element, BaseURI,
storage);
}
@ -277,14 +301,6 @@ public class KeyResolver {
return this._resolverSpi.engineGetProperty(key);
}
/**
* Method getPropertyKeys
*
* @return the properties key registerd in this resolver
*/
public String[] getPropertyKeys() {
return this._resolverSpi.engineGetPropertyKeys();
}
/**
* Method understandsProperty
@ -296,18 +312,6 @@ public class KeyResolver {
return this._resolverSpi.understandsProperty(propertyToTest);
}
/**
* Method canResolve
*
* @param element
* @param BaseURI
* @param storage
* @return true if can resolve the key in the element
*/
public boolean canResolve(Element element, String BaseURI,
StorageResolver storage) {
return this._resolverSpi.engineCanResolve(element, BaseURI, storage);
}
/**
* Method resolverClassName
@ -317,4 +321,37 @@ public class KeyResolver {
public String resolverClassName() {
return this._resolverSpi.getClass().getName();
}
static class ResolverIterator implements Iterator {
List res;
Iterator it;
int i;
public ResolverIterator(List list) {
res = list;
it = res.iterator();
}
public boolean hasNext() {
// TODO Auto-generated method stub
return it.hasNext();
}
public Object next() {
i++;
KeyResolver resolver = (KeyResolver) it.next();
if (resolver==null) {
throw new RuntimeException("utils.resolver.noClass");
}
return resolver._resolverSpi;
}
public void remove() {
// TODO Auto-generated method stub
}
};
public static Iterator iterator() {
return new ResolverIterator(_resolverVector);
}
}

View File

@ -2,7 +2,6 @@
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
@ -31,7 +30,7 @@ import com.sun.org.apache.xml.internal.security.exceptions.XMLSecurityException;
*
*
*
* @author $Author: raul $
* @author $Author: mullan $
*
*/
public class KeyResolverException extends XMLSecurityException {

View File

@ -20,17 +20,15 @@
*/
package com.sun.org.apache.xml.internal.security.keys.keyresolver;
import java.security.PublicKey;
import java.security.cert.X509Certificate;
import java.util.HashMap;
import javax.crypto.SecretKey;
import com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver;
import org.w3c.dom.Element;
/**
* This class is abstract class for a child KeyInfo Elemnet.
*
@ -41,14 +39,10 @@ import org.w3c.dom.Element;
* JAVACLASS="MyPackage.MyKeyValueImpl"//gt;
* </PRE>
*
* @author $Author: raul $
* @author $Author: mullan $
* @version $Revision: 1.5 $
*/
public abstract class KeyResolverSpi {
/** {@link java.util.logging} logging facility */
static java.util.logging.Logger log =
java.util.logging.Logger.getLogger(KeyResolverSpi.class.getName());
/**
* This method helps the {@link com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolver} to decide whether a
* {@link com.sun.org.apache.xml.internal.security.utils.resolver.ResourceResolverSpi} is able to perform the requested action.
@ -56,10 +50,12 @@ public abstract class KeyResolverSpi {
* @param element
* @param BaseURI
* @param storage
* @return true if can resolve the key in the element
* @return
*/
abstract public boolean engineCanResolve(Element element, String BaseURI,
StorageResolver storage);
public boolean engineCanResolve(Element element, String BaseURI,
StorageResolver storage) {
throw new UnsupportedOperationException();
}
/**
* Method engineResolvePublicKey
@ -71,9 +67,60 @@ public abstract class KeyResolverSpi {
*
* @throws KeyResolverException
*/
abstract public PublicKey engineResolvePublicKey(
public PublicKey engineResolvePublicKey(
Element element, String BaseURI, StorageResolver storage)
throws KeyResolverException;
throws KeyResolverException {
throw new UnsupportedOperationException();
};
/**
* Method engineResolvePublicKey
*
* @param element
* @param BaseURI
* @param storage
* @return resolved public key from the registered from the element.
*
* @throws KeyResolverException
*/
public PublicKey engineLookupAndResolvePublicKey(
Element element, String BaseURI, StorageResolver storage)
throws KeyResolverException {
KeyResolverSpi tmp = cloneIfNeeded();
if (!tmp.engineCanResolve(element, BaseURI, storage))
return null;
return tmp.engineResolvePublicKey(element, BaseURI, storage);
}
private KeyResolverSpi cloneIfNeeded() throws KeyResolverException {
KeyResolverSpi tmp=this;
if (globalResolver) {
try {
tmp = (KeyResolverSpi) getClass().newInstance();
} catch (InstantiationException e) {
throw new KeyResolverException("",e);
} catch (IllegalAccessException e) {
throw new KeyResolverException("",e);
}
}
return tmp;
}
/**
* Method engineResolveCertificate
*
* @param element
* @param BaseURI
* @param storage
* @return resolved X509Certificate key from the registered from the elements
*
* @throws KeyResolverException
*/
public X509Certificate engineResolveX509Certificate(
Element element, String BaseURI, StorageResolver storage)
throws KeyResolverException{
throw new UnsupportedOperationException();
};
/**
* Method engineResolveCertificate
@ -85,9 +132,30 @@ public abstract class KeyResolverSpi {
*
* @throws KeyResolverException
*/
abstract public X509Certificate engineResolveX509Certificate(
public X509Certificate engineLookupResolveX509Certificate(
Element element, String BaseURI, StorageResolver storage)
throws KeyResolverException;
throws KeyResolverException {
KeyResolverSpi tmp = cloneIfNeeded();
if (!tmp.engineCanResolve(element, BaseURI, storage))
return null;
return tmp.engineResolveX509Certificate(element, BaseURI, storage);
}
/**
* Method engineResolveSecretKey
*
* @param element
* @param BaseURI
* @param storage
* @return resolved SecretKey key from the registered from the elements
*
* @throws KeyResolverException
*/
public SecretKey engineResolveSecretKey(
Element element, String BaseURI, StorageResolver storage)
throws KeyResolverException{
throw new UnsupportedOperationException();
};
/**
* Method engineResolveSecretKey
@ -99,12 +167,19 @@ public abstract class KeyResolverSpi {
*
* @throws KeyResolverException
*/
abstract public SecretKey engineResolveSecretKey(
public SecretKey engineLookupAndResolveSecretKey(
Element element, String BaseURI, StorageResolver storage)
throws KeyResolverException;
throws KeyResolverException {
KeyResolverSpi tmp = cloneIfNeeded();
if (!tmp.engineCanResolve(element, BaseURI, storage))
return null;
return tmp.engineResolveSecretKey(element, BaseURI, storage);
}
/** Field _properties */
protected java.util.Map _properties = new java.util.HashMap(10);
protected java.util.Map _properties = null;
protected boolean globalResolver=false;
/**
* Method engineSetProperty
@ -113,19 +188,8 @@ public abstract class KeyResolverSpi {
* @param value
*/
public void engineSetProperty(String key, String value) {
java.util.Iterator i = this._properties.keySet().iterator();
while (i.hasNext()) {
String c = (String) i.next();
if (c.equals(key)) {
key = c;
break;
}
}
if (_properties==null)
_properties=new HashMap();
this._properties.put(key, value);
}
@ -136,31 +200,12 @@ public abstract class KeyResolverSpi {
* @return obtain the property appointed by key
*/
public String engineGetProperty(String key) {
java.util.Iterator i = this._properties.keySet().iterator();
while (i.hasNext()) {
String c = (String) i.next();
if (c.equals(key)) {
key = c;
break;
}
}
if (_properties==null)
return null;
return (String) this._properties.get(key);
}
/**
* Method engineGetPropertyKeys
*
* @return the keys of properties known by this resolver
*/
public String[] engineGetPropertyKeys() {
return new String[0];
}
/**
* Method understandsProperty
*
@ -168,17 +213,13 @@ public abstract class KeyResolverSpi {
* @return true if understood the property
*/
public boolean understandsProperty(String propertyToTest) {
if (_properties==null)
return false;
String[] understood = this.engineGetPropertyKeys();
if (understood != null) {
for (int i = 0; i < understood.length; i++) {
if (understood[i].equals(propertyToTest)) {
return true;
}
}
}
return false;
return this._properties.get(propertyToTest)!=null;
}
public void setGlobalResolver(boolean globalResolver) {
this.globalResolver = globalResolver;
}
}

View File

@ -37,46 +37,10 @@ import org.w3c.dom.Element;
/**
*
* @author $Author: raul $
* @author $Author: mullan $
*/
public class DSAKeyValueResolver extends KeyResolverSpi {
/** Field _dsaKeyElement */
private Element _dsaKeyElement = null;
/** @inheritDoc */
public boolean engineCanResolve(Element element, String BaseURI,
StorageResolver storage) {
if (element == null) {
return false;
}
boolean isKeyValue = XMLUtils.elementIsInSignatureSpace(element,
Constants._TAG_KEYVALUE);
boolean isDSAKeyValue = XMLUtils.elementIsInSignatureSpace(element,
Constants._TAG_DSAKEYVALUE);
if (isKeyValue) {
this._dsaKeyElement =
XMLUtils.selectDsNode(element.getFirstChild(),Constants._TAG_DSAKEYVALUE,0);
if (this._dsaKeyElement != null) {
return true;
}
} else if (isDSAKeyValue) {
// this trick is needed to allow the RetrievalMethodResolver to eat a
// ds:DSAKeyValue directly (without KeyValue)
this._dsaKeyElement = element;
return true;
}
return false;
}
/**
* Method engineResolvePublicKey
*
@ -85,20 +49,30 @@ public class DSAKeyValueResolver extends KeyResolverSpi {
* @param storage
* @return null if no {@link PublicKey} could be obtained
*/
public PublicKey engineResolvePublicKey(
public PublicKey engineLookupAndResolvePublicKey(
Element element, String BaseURI, StorageResolver storage) {
if (element == null) {
return null;
}
Element dsaKeyElement=null;
boolean isKeyValue = XMLUtils.elementIsInSignatureSpace(element,
Constants._TAG_KEYVALUE);
if (isKeyValue) {
dsaKeyElement =
XMLUtils.selectDsNode(element.getFirstChild(),Constants._TAG_DSAKEYVALUE,0);
} else if (XMLUtils.elementIsInSignatureSpace(element,
Constants._TAG_DSAKEYVALUE)) {
// this trick is needed to allow the RetrievalMethodResolver to eat a
// ds:DSAKeyValue directly (without KeyValue)
dsaKeyElement = element;
}
if (this._dsaKeyElement == null) {
boolean weCanResolve = this.engineCanResolve(element, BaseURI,
storage);
if (!weCanResolve || (this._dsaKeyElement == null)) {
return null;
}
if (dsaKeyElement == null) {
return null;
}
try {
DSAKeyValue dsaKeyValue = new DSAKeyValue(this._dsaKeyElement,
DSAKeyValue dsaKeyValue = new DSAKeyValue(dsaKeyElement,
BaseURI);
PublicKey pk = dsaKeyValue.getPublicKey();
@ -112,13 +86,13 @@ public class DSAKeyValueResolver extends KeyResolverSpi {
/** @inheritDoc */
public X509Certificate engineResolveX509Certificate(
public X509Certificate engineLookupResolveX509Certificate(
Element element, String BaseURI, StorageResolver storage) {
return null;
}
/** @inheritDoc */
public javax.crypto.SecretKey engineResolveSecretKey(
public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
Element element, String BaseURI, StorageResolver storage){
return null;
}

View File

@ -56,7 +56,6 @@ public class EncryptedKeyResolver extends KeyResolverSpi {
RSAKeyValueResolver.class.getName());
Key _key;
Key _kek;
String _algorithm;
@ -66,7 +65,6 @@ public class EncryptedKeyResolver extends KeyResolverSpi {
* @param algorithm
*/
public EncryptedKeyResolver(String algorithm) {
_key = null;
_kek = null;
_algorithm=algorithm;
}
@ -78,64 +76,49 @@ public class EncryptedKeyResolver extends KeyResolverSpi {
*/
public EncryptedKeyResolver(String algorithm, Key kek) {
_key = null;
_algorithm = algorithm;
_kek = kek;
}
/**
* Method engineCanResolve
*
* @param element
* @param BaseURI
* @param storage
* @return true if can resolve the key in the element
*
*/
public boolean engineCanResolve(Element element, String BaseURI,
StorageResolver storage) {
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "EncryptedKeyResolver - Can I resolve " + element.getTagName());
if (element == null) {
return false;
}
boolean isEncryptedKey = XMLUtils.elementIsInEncryptionSpace(element,
EncryptionConstants._TAG_ENCRYPTEDKEY);
if (isEncryptedKey) {
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Passed an Encrypted Key");
try {
XMLCipher cipher = XMLCipher.getInstance();
cipher.init(XMLCipher.UNWRAP_MODE, _kek);
EncryptedKey ek = cipher.loadEncryptedKey(element);
_key = cipher.decryptKey(ek, _algorithm);
}
catch (Exception e) {}
}
return (_key != null);
}
/** @inheritDoc */
public PublicKey engineResolvePublicKey(
public PublicKey engineLookupAndResolvePublicKey(
Element element, String BaseURI, StorageResolver storage) {
return null;
}
/** @inheritDoc */
public X509Certificate engineResolveX509Certificate(
public X509Certificate engineLookupResolveX509Certificate(
Element element, String BaseURI, StorageResolver storage) {
return null;
}
/** @inheritDoc */
public javax.crypto.SecretKey engineResolveSecretKey(
public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
Element element, String BaseURI, StorageResolver storage) {
return (SecretKey) _key;
SecretKey key=null;
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "EncryptedKeyResolver - Can I resolve " + element.getTagName());
if (element == null) {
return null;
}
boolean isEncryptedKey = XMLUtils.elementIsInEncryptionSpace(element,
EncryptionConstants._TAG_ENCRYPTEDKEY);
if (isEncryptedKey) {
log.log(java.util.logging.Level.FINE, "Passed an Encrypted Key");
try {
XMLCipher cipher = XMLCipher.getInstance();
cipher.init(XMLCipher.UNWRAP_MODE, _kek);
EncryptedKey ek = cipher.loadEncryptedKey(element);
key = (SecretKey) cipher.decryptKey(ek, _algorithm);
}
catch (Exception e) {}
}
return key;
}
}

View File

@ -2,7 +2,6 @@
* reserved comment block
* DO NOT REMOVE OR ALTER!
*/
/*
* Copyright 1999-2004 The Apache Software Foundation.
*
@ -38,7 +37,7 @@ import org.w3c.dom.Element;
/**
*
* @author $Author: raul $
* @author $Author: mullan $
*/
public class RSAKeyValueResolver extends KeyResolverSpi {
@ -48,75 +47,55 @@ public class RSAKeyValueResolver extends KeyResolverSpi {
RSAKeyValueResolver.class.getName());
/** Field _rsaKeyElement */
private Element _rsaKeyElement = null;
/** @inheritDoc */
public boolean engineCanResolve(Element element, String BaseURI,
StorageResolver storage) {
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName());
public PublicKey engineLookupAndResolvePublicKey(
Element element, String BaseURI, StorageResolver storage) {
if (log.isLoggable(java.util.logging.Level.FINE))
log.log(java.util.logging.Level.FINE, "Can I resolve " + element.getTagName());
if (element == null) {
return false;
return null;
}
boolean isKeyValue = XMLUtils.elementIsInSignatureSpace(element,
Constants._TAG_KEYVALUE);
boolean isRSAKeyValue = XMLUtils.elementIsInSignatureSpace(element,
Constants._TAG_RSAKEYVALUE);
if (isKeyValue) {
this._rsaKeyElement = XMLUtils.selectDsNode(element.getFirstChild(),
Constants._TAG_RSAKEYVALUE, 0);
if (this._rsaKeyElement != null) {
return true;
}
} else if (isRSAKeyValue) {
boolean isKeyValue = XMLUtils.elementIsInSignatureSpace(element,
Constants._TAG_KEYVALUE);
Element rsaKeyElement=null;
if (isKeyValue) {
rsaKeyElement = XMLUtils.selectDsNode(element.getFirstChild(),
Constants._TAG_RSAKEYVALUE, 0);
} else if (XMLUtils.elementIsInSignatureSpace(element,
Constants._TAG_RSAKEYVALUE)) {
// this trick is needed to allow the RetrievalMethodResolver to eat a
// ds:RSAKeyValue directly (without KeyValue)
this._rsaKeyElement = element;
rsaKeyElement = element;
}
return true;
}
return false;
}
/** @inheritDoc */
public PublicKey engineResolvePublicKey(
Element element, String BaseURI, StorageResolver storage) {
if (this._rsaKeyElement == null) {
boolean weCanResolve = this.engineCanResolve(element, BaseURI,
storage);
if (!weCanResolve || (this._rsaKeyElement == null)) {
return null;
}
if (rsaKeyElement == null) {
return null;
}
try {
RSAKeyValue rsaKeyValue = new RSAKeyValue(this._rsaKeyElement,
RSAKeyValue rsaKeyValue = new RSAKeyValue(rsaKeyElement,
BaseURI);
return rsaKeyValue.getPublicKey();
} catch (XMLSecurityException ex) {
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex);
log.log(java.util.logging.Level.FINE, "XMLSecurityException", ex);
}
return null;
}
/** @inheritDoc */
public X509Certificate engineResolveX509Certificate(
public X509Certificate engineLookupResolveX509Certificate(
Element element, String BaseURI, StorageResolver storage) {
return null;
}
/** @inheritDoc */
public javax.crypto.SecretKey engineResolveSecretKey(
public javax.crypto.SecretKey engineLookupAndResolveSecretKey(
Element element, String BaseURI, StorageResolver storage) {
return null;
}

Some files were not shown because too many files have changed in this diff Show More