提交 1cfe91bb 编写于 作者: L lana

Merge

# #
# Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 1995, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -88,9 +88,9 @@ ABS_TEMP_DIR = $(ABS_OUTPUTDIR)/tmp ...@@ -88,9 +88,9 @@ ABS_TEMP_DIR = $(ABS_OUTPUTDIR)/tmp
dummy := $(shell $(MKDIR) -p $(TEMP_DIR)) dummy := $(shell $(MKDIR) -p $(TEMP_DIR))
# The language version we want for this jdk build # The language version we want for this jdk build
SOURCE_LANGUAGE_VERSION=7 SOURCE_LANGUAGE_VERSION=8
# The class version we want for this jdk build # The class version we want for this jdk build
TARGET_CLASS_VERSION=7 TARGET_CLASS_VERSION=8
# The MESSAGE, WARNING and ERROR files are used to store sanity check and # The MESSAGE, WARNING and ERROR files are used to store sanity check and
# source check messages, warnings and errors. # source check messages, warnings and errors.
......
...@@ -143,12 +143,12 @@ ifeq ($(wildcard $(SHARE_SRC)/classes/javax/crypto/Cipher.java),) ...@@ -143,12 +143,12 @@ ifeq ($(wildcard $(SHARE_SRC)/classes/javax/crypto/Cipher.java),)
endif endif
# Add the source level # Add the source level
SOURCE_LANGUAGE_VERSION = 7 SOURCE_LANGUAGE_VERSION = 8
LANGUAGE_VERSION = -source $(SOURCE_LANGUAGE_VERSION) LANGUAGE_VERSION = -source $(SOURCE_LANGUAGE_VERSION)
JAVACFLAGS += $(LANGUAGE_VERSION) JAVACFLAGS += $(LANGUAGE_VERSION)
# Add the class version we want # Add the class version we want
TARGET_CLASS_VERSION = 7 TARGET_CLASS_VERSION = 8
CLASS_VERSION = -target $(TARGET_CLASS_VERSION) CLASS_VERSION = -target $(TARGET_CLASS_VERSION)
JAVACFLAGS += $(CLASS_VERSION) JAVACFLAGS += $(CLASS_VERSION)
JAVACFLAGS += -encoding ascii JAVACFLAGS += -encoding ascii
......
# #
# Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
...@@ -36,7 +36,7 @@ FILES_java = \ ...@@ -36,7 +36,7 @@ FILES_java = \
# The sources built here use new language syntax to generate # The sources built here use new language syntax to generate
# method handle calls. Let's be sure we are using that format. # method handle calls. Let's be sure we are using that format.
LANGUAGE_VERSION = -source 7 LANGUAGE_VERSION = -source 8
CLASS_VERSION = -target 7 CLASS_VERSION = -target 8
include $(BUILDDIR)/common/Classes.gmk include $(BUILDDIR)/common/Classes.gmk
...@@ -21,4 +21,4 @@ ...@@ -21,4 +21,4 @@
# or visit www.oracle.com if you need additional information or have any # or visit www.oracle.com if you need additional information or have any
# questions. # questions.
# #
tzdata2012c tzdata2012i
...@@ -821,6 +821,23 @@ Zone Indian/Mayotte 3:00:56 - LMT 1911 Jul # Mamoutzou ...@@ -821,6 +821,23 @@ Zone Indian/Mayotte 3:00:56 - LMT 1911 Jul # Mamoutzou
# "...à partir du dernier dimance d'avril et non fins mars, # "...à partir du dernier dimance d'avril et non fins mars,
# comme annoncé précédemment." # comme annoncé précédemment."
# From Milamber Space Network (2012-07-17):
# The official return to GMT is announced by the Moroccan government:
# <a href="http://www.mmsp.gov.ma/fr/actualites.aspx?id=288">
# http://www.mmsp.gov.ma/fr/actualites.aspx?id=288 [in French]
# </a>
#
# Google translation, lightly edited:
# Back to the standard time of the Kingdom (GMT)
# Pursuant to Decree No. 2-12-126 issued on 26 Jumada (I) 1433 (April 18,
# 2012) and in accordance with the order of Mr. President of the
# Government No. 3-47-12 issued on 24 Sha'ban (11 July 2012), the Ministry
# of Public Service and Administration Modernization announces the return
# of the legal time of the Kingdom (GMT) from Friday, July 20, 2012 until
# Monday, August 20, 2012. So the time will be delayed by 60 minutes from
# 3:00 am Friday, July 20, 2012 and will again be advanced by 60 minutes
# August 20, 2012 from 2:00 am.
# RULE NAME FROM TO TYPE IN ON AT SAVE LETTER/S # 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 - Sep 12 0:00 1:00 S
...@@ -848,6 +865,8 @@ Rule Morocco 2011 only - Apr 3 0:00 1:00 S ...@@ -848,6 +865,8 @@ Rule Morocco 2011 only - Apr 3 0:00 1:00 S
Rule Morocco 2011 only - Jul 31 0 0 - Rule Morocco 2011 only - Jul 31 0 0 -
Rule Morocco 2012 max - Apr lastSun 2:00 1:00 S Rule Morocco 2012 max - Apr lastSun 2:00 1:00 S
Rule Morocco 2012 max - Sep lastSun 3:00 0 - Rule Morocco 2012 max - Sep lastSun 3:00 0 -
Rule Morocco 2012 only - Jul 20 3:00 0 -
Rule Morocco 2012 only - Aug 20 2:00 1:00 S
# Zone NAME GMTOFF RULES FORMAT [UNTIL] # Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Africa/Casablanca -0:30:20 - LMT 1913 Oct 26 Zone Africa/Casablanca -0:30:20 - LMT 1913 Oct 26
......
...@@ -1193,15 +1193,15 @@ Rule Zion 2004 only - Sep 22 1:00 0 S ...@@ -1193,15 +1193,15 @@ Rule Zion 2004 only - Sep 22 1:00 0 S
# #
# ftp://ftp.cs.huji.ac.il/pub/tz/announcements/2005+beyond.ps # ftp://ftp.cs.huji.ac.il/pub/tz/announcements/2005+beyond.ps
# From Paul Eggert (2005-02-22): # From Paul Eggert (2012-10-26):
# I used Ephraim Silverberg's dst-israel.el program # I used Ephraim Silverberg's dst-israel.el program
# <ftp://ftp.cs.huji.ac.il/pub/tz/software/dst-israel.el> (2005-02-20) # <ftp://ftp.cs.huji.ac.il/pub/tz/software/dst-israel.el> (2005-02-20)
# along with Ed Reingold's cal-hebrew in GNU Emacs 21.4, # along with Ed Reingold's cal-hebrew in GNU Emacs 21.4,
# to generate the transitions in this list. # to generate the transitions from 2005 through 2012.
# (I replaced "lastFri" with "Fri>=26" by hand.) # (I replaced "lastFri" with "Fri>=26" by hand.)
# The spring transitions below all correspond to the following Rule: # The spring transitions all correspond to the following Rule:
# #
# Rule Zion 2005 max - Mar Fri>=26 2:00 1:00 D # Rule Zion 2005 2012 - Mar Fri>=26 2:00 1:00 D
# #
# but older zic implementations (e.g., Solaris 8) do not support # but older zic implementations (e.g., Solaris 8) do not support
# "Fri>=26" to mean April 1 in years like 2005, so for now we list the # "Fri>=26" to mean April 1 in years like 2005, so for now we list the
...@@ -1218,39 +1218,36 @@ Rule Zion 2009 only - Sep 27 2:00 0 S ...@@ -1218,39 +1218,36 @@ Rule Zion 2009 only - Sep 27 2:00 0 S
Rule Zion 2010 only - Sep 12 2:00 0 S Rule Zion 2010 only - Sep 12 2:00 0 S
Rule Zion 2011 only - Apr 1 2:00 1:00 D Rule Zion 2011 only - Apr 1 2:00 1:00 D
Rule Zion 2011 only - Oct 2 2:00 0 S Rule Zion 2011 only - Oct 2 2:00 0 S
Rule Zion 2012 2015 - Mar Fri>=26 2:00 1:00 D Rule Zion 2012 only - Mar Fri>=26 2:00 1:00 D
Rule Zion 2012 only - Sep 23 2:00 0 S Rule Zion 2012 only - Sep 23 2:00 0 S
Rule Zion 2013 only - Sep 8 2:00 0 S
Rule Zion 2014 only - Sep 28 2:00 0 S # From Ephraim Silverberg (2012-10-18):
Rule Zion 2015 only - Sep 20 2:00 0 S
Rule Zion 2016 only - Apr 1 2:00 1:00 D # Yesterday, the Interior Ministry Committee, after more than a year
Rule Zion 2016 only - Oct 9 2:00 0 S # past, approved sending the proposed June 2011 changes to the Time
Rule Zion 2017 2021 - Mar Fri>=26 2:00 1:00 D # Decree Law back to the Knesset for second and third (final) votes
Rule Zion 2017 only - Sep 24 2:00 0 S # before the upcoming elections on Jan. 22, 2013. Hence, although the
Rule Zion 2018 only - Sep 16 2:00 0 S # changes are not yet law, they are expected to be so before February 2013.
Rule Zion 2019 only - Oct 6 2:00 0 S #
Rule Zion 2020 only - Sep 27 2:00 0 S # As of 2013, DST starts at 02:00 on the Friday before the last Sunday in March.
Rule Zion 2021 only - Sep 12 2:00 0 S # DST ends at 02:00 on the first Sunday after October 1, unless it occurs on the
Rule Zion 2022 only - Apr 1 2:00 1:00 D # second day of the Jewish Rosh Hashana holiday, in which case DST ends a day
Rule Zion 2022 only - Oct 2 2:00 0 S # later (i.e. at 02:00 the first Monday after October 2).
Rule Zion 2023 2032 - Mar Fri>=26 2:00 1:00 D # [Rosh Hashana holidays are factored in until 2100.]
Rule Zion 2023 only - Sep 24 2:00 0 S
Rule Zion 2024 only - Oct 6 2:00 0 S # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Zion 2025 only - Sep 28 2:00 0 S Rule Zion 2013 max - Mar Fri>=23 2:00 1:00 D
Rule Zion 2026 only - Sep 20 2:00 0 S Rule Zion 2013 2026 - Oct Sun>=2 2:00 0 S
Rule Zion 2027 only - Oct 10 2:00 0 S Rule Zion 2027 only - Oct Mon>=3 2:00 0 S
Rule Zion 2028 only - Sep 24 2:00 0 S Rule Zion 2028 max - Oct Sun>=2 2:00 0 S
Rule Zion 2029 only - Sep 16 2:00 0 S # The following rules are commented out for now, as they break older
Rule Zion 2030 only - Oct 6 2:00 0 S # versions of zic that support only signed 32-bit timestamps, i.e.,
Rule Zion 2031 only - Sep 21 2:00 0 S # through 2038-01-19 03:14:07 UTC.
Rule Zion 2032 only - Sep 12 2:00 0 S #Rule Zion 2028 2053 - Oct Sun>=2 2:00 0 S
Rule Zion 2033 only - Apr 1 2:00 1:00 D #Rule Zion 2054 only - Oct Mon>=3 2:00 0 S
Rule Zion 2033 only - Oct 2 2:00 0 S #Rule Zion 2055 2080 - Oct Sun>=2 2:00 0 S
Rule Zion 2034 2037 - Mar Fri>=26 2:00 1:00 D #Rule Zion 2081 only - Oct Mon>=3 2:00 0 S
Rule Zion 2034 only - Sep 17 2:00 0 S #Rule Zion 2082 max - Oct Sun>=2 2:00 0 S
Rule Zion 2035 only - Oct 7 2:00 0 S
Rule Zion 2036 only - Sep 28 2:00 0 S
Rule Zion 2037 only - Sep 13 2:00 0 S
# Zone NAME GMTOFF RULES FORMAT [UNTIL] # Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Asia/Jerusalem 2:20:56 - LMT 1880 Zone Asia/Jerusalem 2:20:56 - LMT 1880
...@@ -1385,6 +1382,16 @@ Zone Asia/Tokyo 9:18:59 - LMT 1887 Dec 31 15:00u ...@@ -1385,6 +1382,16 @@ Zone Asia/Tokyo 9:18:59 - LMT 1887 Dec 31 15:00u
# From Arthur David Olson (2009-04-06): # From Arthur David Olson (2009-04-06):
# We still have Jordan switching to DST on Thursdays in 2000 and 2001. # We still have Jordan switching to DST on Thursdays in 2000 and 2001.
# From Steffen Thorsen (2012-10-25):
# Yesterday the government in Jordan announced that they will not
# switch back to standard time this winter, so the will stay on DST
# until about the same time next year (at least).
# http://www.petra.gov.jo/Public_News/Nws_NewsDetails.aspx?NewsID=88950
#
# From Paul Eggert (2012-10-25):
# For now, assume this is just a one-year measure. If it becomes
# permanent, we should move Jordan from EET to AST effective tomorrow.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Jordan 1973 only - Jun 6 0:00 1:00 S Rule Jordan 1973 only - Jun 6 0:00 1:00 S
Rule Jordan 1973 1975 - Oct 1 0:00 0 - Rule Jordan 1973 1975 - Oct 1 0:00 0 -
...@@ -1413,7 +1420,8 @@ Rule Jordan 2002 max - Mar lastThu 24:00 1:00 S ...@@ -1413,7 +1420,8 @@ Rule Jordan 2002 max - Mar lastThu 24:00 1:00 S
Rule Jordan 2003 only - Oct 24 0:00s 0 - Rule Jordan 2003 only - Oct 24 0:00s 0 -
Rule Jordan 2004 only - Oct 15 0:00s 0 - Rule Jordan 2004 only - Oct 15 0:00s 0 -
Rule Jordan 2005 only - Sep lastFri 0:00s 0 - Rule Jordan 2005 only - Sep lastFri 0:00s 0 -
Rule Jordan 2006 max - Oct lastFri 0:00s 0 - Rule Jordan 2006 2011 - Oct lastFri 0:00s 0 -
Rule Jordan 2013 max - Oct lastFri 0:00s 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL] # Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Asia/Amman 2:23:44 - LMT 1931 Zone Asia/Amman 2:23:44 - LMT 1931
2:00 Jordan EE%sT 2:00 Jordan EE%sT
...@@ -2316,6 +2324,8 @@ Rule Palestine 2010 only - Aug 11 0:00 0 - ...@@ -2316,6 +2324,8 @@ Rule Palestine 2010 only - Aug 11 0:00 0 -
# From Arthur David Olson (2011-09-20): # From Arthur David Olson (2011-09-20):
# 2011 transitions per http://www.timeanddate.com as of 2011-09-20. # 2011 transitions per http://www.timeanddate.com as of 2011-09-20.
# From Paul Eggert (2012-10-12):
# 2012 transitions per http://www.timeanddate.com as of 2012-10-12.
# Zone NAME GMTOFF RULES FORMAT [UNTIL] # Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Asia/Gaza 2:17:52 - LMT 1900 Oct Zone Asia/Gaza 2:17:52 - LMT 1900 Oct
...@@ -2326,7 +2336,7 @@ Zone Asia/Gaza 2:17:52 - LMT 1900 Oct ...@@ -2326,7 +2336,7 @@ Zone Asia/Gaza 2:17:52 - LMT 1900 Oct
2:00 Palestine EE%sT 2011 Apr 2 12:01 2:00 Palestine EE%sT 2011 Apr 2 12:01
2:00 1:00 EEST 2011 Aug 1 2:00 1:00 EEST 2011 Aug 1
2:00 - EET 2012 Mar 30 2:00 - EET 2012 Mar 30
2:00 1:00 EEST 2012 Sep 28 2:00 1:00 EEST 2012 Sep 21 1:00
2:00 - EET 2:00 - EET
Zone Asia/Hebron 2:20:23 - LMT 1900 Oct Zone Asia/Hebron 2:20:23 - LMT 1900 Oct
...@@ -2341,7 +2351,7 @@ Zone Asia/Hebron 2:20:23 - LMT 1900 Oct ...@@ -2341,7 +2351,7 @@ Zone Asia/Hebron 2:20:23 - LMT 1900 Oct
2:00 - EET 2011 Aug 30 2:00 - EET 2011 Aug 30
2:00 1:00 EEST 2011 Sep 30 3:00 2:00 1:00 EEST 2011 Sep 30 3:00
2:00 - EET 2012 Mar 30 2:00 - EET 2012 Mar 30
2:00 1:00 EEST 2012 Sep 28 3:00 2:00 1:00 EEST 2012 Sep 21 1:00
2:00 - EET 2:00 - EET
# Paracel Is # Paracel Is
......
...@@ -344,15 +344,23 @@ Zone Indian/Cocos 6:27:40 - LMT 1900 ...@@ -344,15 +344,23 @@ Zone Indian/Cocos 6:27:40 - LMT 1900
# The commencement of daylight saving will remain unchanged and start # The commencement of daylight saving will remain unchanged and start
# on the 23rd of October, 2011. # on the 23rd of October, 2011.
# From the Fiji Government Online Portal (2012-08-21) via Steffen Thorsen:
# The Minister for Labour, Industrial Relations and Employment Mr Jone Usamate
# today confirmed that Fiji will start daylight savings at 2 am on Sunday 21st
# October 2012 and end at 3 am on Sunday 20th January 2013.
# http://www.fiji.gov.fj/index.php?option=com_content&view=article&id=6702&catid=71&Itemid=155
#
# From Paul Eggert (2012-08-31):
# For now, guess a pattern of the penultimate Sundays in October and January.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Fiji 1998 1999 - Nov Sun>=1 2:00 1:00 S Rule Fiji 1998 1999 - Nov Sun>=1 2:00 1:00 S
Rule Fiji 1999 2000 - Feb lastSun 3:00 0 - Rule Fiji 1999 2000 - Feb lastSun 3:00 0 -
Rule Fiji 2009 only - Nov 29 2:00 1:00 S Rule Fiji 2009 only - Nov 29 2:00 1:00 S
Rule Fiji 2010 only - Mar lastSun 3:00 0 - Rule Fiji 2010 only - Mar lastSun 3:00 0 -
Rule Fiji 2010 only - Oct 24 2:00 1:00 S Rule Fiji 2010 max - Oct Sun>=18 2:00 1:00 S
Rule Fiji 2011 only - Mar Sun>=1 3:00 0 - Rule Fiji 2011 only - Mar Sun>=1 3:00 0 -
Rule Fiji 2011 only - Oct 23 2:00 1:00 S Rule Fiji 2012 max - Jan Sun>=18 3:00 0 -
Rule Fiji 2012 only - Jan 22 3:00 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL] # Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Pacific/Fiji 11:53:40 - LMT 1915 Oct 26 # Suva Zone Pacific/Fiji 11:53:40 - LMT 1915 Oct 26 # Suva
12:00 Fiji FJ%sT # Fiji Time 12:00 Fiji FJ%sT # Fiji Time
...@@ -643,6 +651,23 @@ Zone Pacific/Pago_Pago 12:37:12 - LMT 1879 Jul 5 ...@@ -643,6 +651,23 @@ Zone Pacific/Pago_Pago 12:37:12 - LMT 1879 Jul 5
# Although Samoa has used Daylight Saving Time in the 2010-2011 and 2011-2012 # Although Samoa has used Daylight Saving Time in the 2010-2011 and 2011-2012
# seasons, there is not yet any indication that this trend will continue on # seasons, there is not yet any indication that this trend will continue on
# a regular basis. For now, we have explicitly listed the transitions below. # a regular basis. For now, we have explicitly listed the transitions below.
#
# From Nicky (2012-09-10):
# Daylight Saving Time commences on Sunday 30th September 2012 and
# ends on Sunday 7th of April 2013.
#
# Please find link below for more information.
# http://www.mcil.gov.ws/mcil_publications.html
#
# That publication also includes dates for Summer of 2013/4 as well
# which give the impression of a pattern in selecting dates for the
# future, so for now, we will guess this will continue.
# Western Samoa
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule WS 2012 max - Sep lastSun 3:00 1 D
Rule WS 2012 max - Apr Sun>=1 4:00 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Pacific/Apia 12:33:04 - LMT 1879 Jul 5 Zone Pacific/Apia 12:33:04 - LMT 1879 Jul 5
-11:26:56 - LMT 1911 -11:26:56 - LMT 1911
-11:30 - SAMT 1950 # Samoa Time -11:30 - SAMT 1950 # Samoa Time
...@@ -650,8 +675,8 @@ Zone Pacific/Apia 12:33:04 - LMT 1879 Jul 5 ...@@ -650,8 +675,8 @@ Zone Pacific/Apia 12:33:04 - LMT 1879 Jul 5
-11:00 1:00 WSDT 2011 Apr 2 4:00 -11:00 1:00 WSDT 2011 Apr 2 4:00
-11:00 - WST 2011 Sep 24 3:00 -11:00 - WST 2011 Sep 24 3:00
-11:00 1:00 WSDT 2011 Dec 30 -11:00 1:00 WSDT 2011 Dec 30
13:00 1:00 WSDT 2012 Apr 1 4:00 13:00 1:00 WSDT 2012 Apr Sun>=1 4:00
13:00 - WST 13:00 WS WS%sT
# Solomon Is # Solomon Is
# excludes Bougainville, for which see Papua New Guinea # excludes Bougainville, for which see Papua New Guinea
...@@ -663,25 +688,25 @@ Zone Pacific/Guadalcanal 10:39:48 - LMT 1912 Oct # Honiara ...@@ -663,25 +688,25 @@ Zone Pacific/Guadalcanal 10:39:48 - LMT 1912 Oct # Honiara
# #
# From Gwillim Law (2011-12-29) # From Gwillim Law (2011-12-29)
# A correspondent informed me that Tokelau, like Samoa, will be skipping # A correspondent informed me that Tokelau, like Samoa, will be skipping
# December 31 this year, thereby changing its time zone from UTC-10 to # December 31 this year ...
# UTC+14. When I tried to verify this statement, I found a confirming
# article in Time magazine online
# <a href="http://www.time.com/time/world/article/0,8599,2103243,00.html">
# (http://www.time.com/time/world/article/0,8599,2103243,00.html).
# </a>
# #
# From Jonathan Leffler (2011-12-29) # From Steffen Thorsen (2012-07-25)
# Information from the BBC to the same effect: # ... we double checked by calling hotels and offices based in Tokelau asking
# <a href="http://www.bbc.co.uk/news/world-asia-16351377"> # about the time there, and they all told a time that agrees with UTC+13....
# http://www.bbc.co.uk/news/world-asia-16351377 # Shanks says UTC-10 from 1901 [but] ... there is a good chance the change
# </a> # actually was to UTC-11 back then.
# #
# Patch supplied by Tim Parenti (2011-12-29) # From Paul Eggert (2012-07-25)
# A Google Books snippet of Appendix to the Journals of the House of
# Representatives of New Zealand, Session 1948,
# <http://books.google.com/books?id=ZaVCAQAAIAAJ>, page 65, says Tokelau
# was "11 hours slow on G.M.T." Go with Thorsen and assume Shanks & Pottenger
# are off by an hour starting in 1901.
# Zone NAME GMTOFF RULES FORMAT [UNTIL] # Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Pacific/Fakaofo -11:24:56 - LMT 1901 Zone Pacific/Fakaofo -11:24:56 - LMT 1901
-10:00 - TKT 2011 Dec 30 # Tokelau Time -11:00 - TKT 2011 Dec 30 # Tokelau Time
14:00 - TKT 13:00 - TKT
# Tonga # Tonga
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
......
...@@ -2820,6 +2820,13 @@ Zone America/Costa_Rica -5:36:20 - LMT 1890 # San Jose ...@@ -2820,6 +2820,13 @@ Zone America/Costa_Rica -5:36:20 - LMT 1890 # San Jose
# http://www.timeanddate.com/news/time/cuba-starts-dst-2012.html # http://www.timeanddate.com/news/time/cuba-starts-dst-2012.html
# </a> # </a>
# From Steffen Thorsen (2012-11-03):
# Radio Reloj and many other sources report that Cuba is changing back
# to standard time on 2012-11-04:
# http://www.radioreloj.cu/index.php/noticias-radio-reloj/36-nacionales/9961-regira-horario-normal-en-cuba-desde-el-domingo-cuatro-de-noviembre
# From Paul Eggert (2012-11-03):
# For now, assume the future rule is first Sunday in November.
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Cuba 1928 only - Jun 10 0:00 1:00 D Rule Cuba 1928 only - Jun 10 0:00 1:00 D
Rule Cuba 1928 only - Oct 10 0:00 0 S Rule Cuba 1928 only - Oct 10 0:00 0 S
...@@ -2857,7 +2864,7 @@ Rule Cuba 2009 2010 - Mar Sun>=8 0:00s 1:00 D ...@@ -2857,7 +2864,7 @@ Rule Cuba 2009 2010 - Mar Sun>=8 0:00s 1:00 D
Rule Cuba 2011 only - Mar Sun>=15 0:00s 1:00 D Rule Cuba 2011 only - Mar Sun>=15 0:00s 1:00 D
Rule Cuba 2011 only - Nov 13 0:00s 0 S Rule Cuba 2011 only - Nov 13 0:00s 0 S
Rule Cuba 2012 only - Apr 1 0:00s 1:00 D Rule Cuba 2012 only - Apr 1 0:00s 1:00 D
Rule Cuba 2012 max - Oct lastSun 0:00s 0 S Rule Cuba 2012 max - Nov Sun>=1 0:00s 0 S
Rule Cuba 2013 max - Mar Sun>=8 0:00s 1:00 D Rule Cuba 2013 max - Mar Sun>=8 0:00s 1:00 D
# Zone NAME GMTOFF RULES FORMAT [UNTIL] # Zone NAME GMTOFF RULES FORMAT [UNTIL]
......
...@@ -852,6 +852,15 @@ Zone America/La_Paz -4:32:36 - LMT 1890 ...@@ -852,6 +852,15 @@ Zone America/La_Paz -4:32:36 - LMT 1890
# http://www.in.gov.br/visualiza/index.jsp?data=13/10/2011&jornal=1000&pagina=6&totalArquivos=6 # http://www.in.gov.br/visualiza/index.jsp?data=13/10/2011&jornal=1000&pagina=6&totalArquivos=6
# </a> # </a>
# From Kelley Cook (2012-10-16):
# The governor of state of Bahia in Brazil announced on Thursday that
# due to public pressure, he is reversing the DST policy they implemented
# last year and will not be going to Summer Time on October 21st....
# http://www.correio24horas.com.br/r/artigo/apos-pressoes-wagner-suspende-horario-de-verao-na-bahia
# From Rodrigo Severo (2012-10-16):
# Tocantins state will have DST.
# http://noticias.terra.com.br/brasil/noticias/0,,OI6232536-EI306.html
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
# Decree <a href="http://pcdsh01.on.br/HV20466.htm">20,466</a> (1931-10-01) # Decree <a href="http://pcdsh01.on.br/HV20466.htm">20,466</a> (1931-10-01)
...@@ -1071,7 +1080,8 @@ Zone America/Araguaina -3:12:48 - LMT 1914 ...@@ -1071,7 +1080,8 @@ Zone America/Araguaina -3:12:48 - LMT 1914
-3:00 Brazil BR%sT 1990 Sep 17 -3:00 Brazil BR%sT 1990 Sep 17
-3:00 - BRT 1995 Sep 14 -3:00 - BRT 1995 Sep 14
-3:00 Brazil BR%sT 2003 Sep 24 -3:00 Brazil BR%sT 2003 Sep 24
-3:00 - BRT -3:00 - BRT 2012 Oct 21
-3:00 Brazil BR%sT
# #
# Alagoas (AL), Sergipe (SE) # Alagoas (AL), Sergipe (SE)
Zone America/Maceio -2:22:52 - LMT 1914 Zone America/Maceio -2:22:52 - LMT 1914
...@@ -1090,7 +1100,8 @@ Zone America/Maceio -2:22:52 - LMT 1914 ...@@ -1090,7 +1100,8 @@ Zone America/Maceio -2:22:52 - LMT 1914
Zone America/Bahia -2:34:04 - LMT 1914 Zone America/Bahia -2:34:04 - LMT 1914
-3:00 Brazil BR%sT 2003 Sep 24 -3:00 Brazil BR%sT 2003 Sep 24
-3:00 - BRT 2011 Oct 16 -3:00 - BRT 2011 Oct 16
-3:00 Brazil BR%sT -3:00 Brazil BR%sT 2012 Oct 21
-3:00 - BRT
# #
# Goias (GO), Distrito Federal (DF), Minas Gerais (MG), # Goias (GO), Distrito Federal (DF), Minas Gerais (MG),
# Espirito Santo (ES), Rio de Janeiro (RJ), Sao Paulo (SP), Parana (PR), # Espirito Santo (ES), Rio de Janeiro (RJ), Sao Paulo (SP), Parana (PR),
......
/* /*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -311,6 +311,8 @@ class CharacterData01 extends CharacterData { ...@@ -311,6 +311,8 @@ class CharacterData01 extends CharacterData {
case 0x011063: retval = 90; break; // BRAHMI NUMBER NINETY case 0x011063: retval = 90; break; // BRAHMI NUMBER NINETY
case 0x011064: retval = 100; break; // BRAHMI NUMBER ONE HUNDRED case 0x011064: retval = 100; break; // BRAHMI NUMBER ONE HUNDRED
case 0x011065: retval = 1000; break; // BRAHMI NUMBER ONE THOUSAND case 0x011065: retval = 1000; break; // BRAHMI NUMBER ONE THOUSAND
case 0x012432: retval = 216000; break; // CUNEIFORM NUMERIC SIGN SHAR2 TIMES GAL PLUS DISH
case 0x012433: retval = 432000; break; // CUNEIFORM NUMERIC SIGN SHAR2 TIMES GAL PLUS MIN
case 0x01D36C: retval = 40; break; // COUNTING ROD TENS DIGIT FOUR case 0x01D36C: retval = 40; break; // COUNTING ROD TENS DIGIT FOUR
case 0x01D36D: retval = 50; break; // COUNTING ROD TENS DIGIT FIVE case 0x01D36D: retval = 50; break; // COUNTING ROD TENS DIGIT FIVE
case 0x01D36E: retval = 60; break; // COUNTING ROD TENS DIGIT SIX case 0x01D36E: retval = 60; break; // COUNTING ROD TENS DIGIT SIX
......
# PropList-6.1.0.txt # PropList-6.2.0.txt
# Date: 2011-11-30, 01:49:54 GMT [MD] # Date: 2012-05-23, 20:34:59 GMT [MD]
# #
# Unicode Character Database # Unicode Character Database
# Copyright (c) 1991-2011 Unicode, Inc. # Copyright (c) 1991-2012 Unicode, Inc.
# For terms of use, see http://www.unicode.org/terms_of_use.html # For terms of use, see http://www.unicode.org/terms_of_use.html
# For documentation, see http://www.unicode.org/reports/tr44/ # For documentation, see http://www.unicode.org/reports/tr44/
......
# Scripts-6.1.0.txt # Scripts-6.2.0.txt
# Date: 2011-11-27, 05:10:50 GMT [MD] # Date: 2012-06-04, 17:21:29 GMT [MD]
# #
# Unicode Character Database # Unicode Character Database
# Copyright (c) 1991-2011 Unicode, Inc. # Copyright (c) 1991-2012 Unicode, Inc.
# For terms of use, see http://www.unicode.org/terms_of_use.html # For terms of use, see http://www.unicode.org/terms_of_use.html
# For documentation, see http://www.unicode.org/reports/tr44/ # For documentation, see http://www.unicode.org/reports/tr44/
...@@ -146,7 +146,7 @@ ...@@ -146,7 +146,7 @@
208A..208C ; Common # Sm [3] SUBSCRIPT PLUS SIGN..SUBSCRIPT EQUALS SIGN 208A..208C ; Common # Sm [3] SUBSCRIPT PLUS SIGN..SUBSCRIPT EQUALS SIGN
208D ; Common # Ps SUBSCRIPT LEFT PARENTHESIS 208D ; Common # Ps SUBSCRIPT LEFT PARENTHESIS
208E ; Common # Pe SUBSCRIPT RIGHT PARENTHESIS 208E ; Common # Pe SUBSCRIPT RIGHT PARENTHESIS
20A0..20B9 ; Common # Sc [26] EURO-CURRENCY SIGN..INDIAN RUPEE SIGN 20A0..20BA ; Common # Sc [27] EURO-CURRENCY SIGN..TURKISH LIRA SIGN
2100..2101 ; Common # So [2] ACCOUNT OF..ADDRESSED TO THE SUBJECT 2100..2101 ; Common # So [2] ACCOUNT OF..ADDRESSED TO THE SUBJECT
2102 ; Common # L& DOUBLE-STRUCK CAPITAL C 2102 ; Common # L& DOUBLE-STRUCK CAPITAL C
2103..2106 ; Common # So [4] DEGREE CELSIUS..CADA UNA 2103..2106 ; Common # So [4] DEGREE CELSIUS..CADA UNA
...@@ -576,7 +576,7 @@ FFFC..FFFD ; Common # So [2] OBJECT REPLACEMENT CHARACTER..REPLACEMENT CHAR ...@@ -576,7 +576,7 @@ FFFC..FFFD ; Common # So [2] OBJECT REPLACEMENT CHARACTER..REPLACEMENT CHAR
E0001 ; Common # Cf LANGUAGE TAG E0001 ; Common # Cf LANGUAGE TAG
E0020..E007F ; Common # Cf [96] TAG SPACE..CANCEL TAG E0020..E007F ; Common # Cf [96] TAG SPACE..CANCEL TAG
# Total code points: 6412 # Total code points: 6413
# ================================================ # ================================================
...@@ -760,7 +760,7 @@ FB46..FB4F ; Hebrew # Lo [10] HEBREW LETTER TSADI WITH DAGESH..HEBREW LIGATU ...@@ -760,7 +760,7 @@ FB46..FB4F ; Hebrew # Lo [10] HEBREW LETTER TSADI WITH DAGESH..HEBREW LIGATU
061E ; Arabic # Po ARABIC TRIPLE DOT PUNCTUATION MARK 061E ; Arabic # Po ARABIC TRIPLE DOT PUNCTUATION MARK
0620..063F ; Arabic # Lo [32] ARABIC LETTER KASHMIRI YEH..ARABIC LETTER FARSI YEH WITH THREE DOTS ABOVE 0620..063F ; Arabic # Lo [32] ARABIC LETTER KASHMIRI YEH..ARABIC LETTER FARSI YEH WITH THREE DOTS ABOVE
0641..064A ; Arabic # Lo [10] ARABIC LETTER FEH..ARABIC LETTER YEH 0641..064A ; Arabic # Lo [10] ARABIC LETTER FEH..ARABIC LETTER YEH
0656..065E ; Arabic # Mn [9] ARABIC SUBSCRIPT ALEF..ARABIC FATHA WITH TWO DOTS 0656..065F ; Arabic # Mn [10] ARABIC SUBSCRIPT ALEF..ARABIC WAVY HAMZA BELOW
066A..066D ; Arabic # Po [4] ARABIC PERCENT SIGN..ARABIC FIVE POINTED STAR 066A..066D ; Arabic # Po [4] ARABIC PERCENT SIGN..ARABIC FIVE POINTED STAR
066E..066F ; Arabic # Lo [2] ARABIC LETTER DOTLESS BEH..ARABIC LETTER DOTLESS QAF 066E..066F ; Arabic # Lo [2] ARABIC LETTER DOTLESS BEH..ARABIC LETTER DOTLESS QAF
0671..06D3 ; Arabic # Lo [99] ARABIC LETTER ALEF WASLA..ARABIC LETTER YEH BARREE WITH HAMZA ABOVE 0671..06D3 ; Arabic # Lo [99] ARABIC LETTER ALEF WASLA..ARABIC LETTER YEH BARREE WITH HAMZA ABOVE
...@@ -827,7 +827,7 @@ FE76..FEFC ; Arabic # Lo [135] ARABIC FATHA ISOLATED FORM..ARABIC LIGATURE LA ...@@ -827,7 +827,7 @@ FE76..FEFC ; Arabic # Lo [135] ARABIC FATHA ISOLATED FORM..ARABIC LIGATURE LA
1EEAB..1EEBB ; Arabic # Lo [17] ARABIC MATHEMATICAL DOUBLE-STRUCK LAM..ARABIC MATHEMATICAL DOUBLE-STRUCK GHAIN 1EEAB..1EEBB ; Arabic # Lo [17] ARABIC MATHEMATICAL DOUBLE-STRUCK LAM..ARABIC MATHEMATICAL DOUBLE-STRUCK GHAIN
1EEF0..1EEF1 ; Arabic # Sm [2] ARABIC MATHEMATICAL OPERATOR MEEM WITH HAH WITH TATWEEL..ARABIC MATHEMATICAL OPERATOR HAH WITH DAL 1EEF0..1EEF1 ; Arabic # Sm [2] ARABIC MATHEMATICAL OPERATOR MEEM WITH HAH WITH TATWEEL..ARABIC MATHEMATICAL OPERATOR HAH WITH DAL
# Total code points: 1234 # Total code points: 1235
# ================================================ # ================================================
...@@ -1477,7 +1477,6 @@ A490..A4C6 ; Yi # So [55] YI RADICAL QOT..YI RADICAL KE ...@@ -1477,7 +1477,6 @@ A490..A4C6 ; Yi # So [55] YI RADICAL QOT..YI RADICAL KE
0300..036F ; Inherited # Mn [112] COMBINING GRAVE ACCENT..COMBINING LATIN SMALL LETTER X 0300..036F ; Inherited # Mn [112] COMBINING GRAVE ACCENT..COMBINING LATIN SMALL LETTER X
0485..0486 ; Inherited # Mn [2] COMBINING CYRILLIC DASIA PNEUMATA..COMBINING CYRILLIC PSILI PNEUMATA 0485..0486 ; Inherited # Mn [2] COMBINING CYRILLIC DASIA PNEUMATA..COMBINING CYRILLIC PSILI PNEUMATA
064B..0655 ; Inherited # Mn [11] ARABIC FATHATAN..ARABIC HAMZA BELOW 064B..0655 ; Inherited # Mn [11] ARABIC FATHATAN..ARABIC HAMZA BELOW
065F ; Inherited # Mn ARABIC WAVY HAMZA BELOW
0670 ; Inherited # Mn ARABIC LETTER SUPERSCRIPT ALEF 0670 ; Inherited # Mn ARABIC LETTER SUPERSCRIPT ALEF
0951..0952 ; Inherited # Mn [2] DEVANAGARI STRESS SIGN UDATTA..DEVANAGARI STRESS SIGN ANUDATTA 0951..0952 ; Inherited # Mn [2] DEVANAGARI STRESS SIGN UDATTA..DEVANAGARI STRESS SIGN ANUDATTA
1CD0..1CD2 ; Inherited # Mn [3] VEDIC TONE KARSHANA..VEDIC TONE PRENKHA 1CD0..1CD2 ; Inherited # Mn [3] VEDIC TONE KARSHANA..VEDIC TONE PRENKHA
...@@ -1504,7 +1503,7 @@ FE20..FE26 ; Inherited # Mn [7] COMBINING LIGATURE LEFT HALF..COMBINING CON ...@@ -1504,7 +1503,7 @@ FE20..FE26 ; Inherited # Mn [7] COMBINING LIGATURE LEFT HALF..COMBINING CON
1D1AA..1D1AD ; Inherited # Mn [4] MUSICAL SYMBOL COMBINING DOWN BOW..MUSICAL SYMBOL COMBINING SNAP PIZZICATO 1D1AA..1D1AD ; Inherited # Mn [4] MUSICAL SYMBOL COMBINING DOWN BOW..MUSICAL SYMBOL COMBINING SNAP PIZZICATO
E0100..E01EF ; Inherited # Mn [240] VARIATION SELECTOR-17..VARIATION SELECTOR-256 E0100..E01EF ; Inherited # Mn [240] VARIATION SELECTOR-17..VARIATION SELECTOR-256
# Total code points: 524 # Total code points: 523
# ================================================ # ================================================
......
# SpecialCasing-6.1.0.txt # SpecialCasing-6.2.0.txt
# Date: 2011-11-27, 05:10:51 GMT [MD] # Date: 2012-05-23, 20:35:15 GMT [MD]
# #
# Unicode Character Database # Unicode Character Database
# Copyright (c) 1991-2011 Unicode, Inc. # Copyright (c) 1991-2012 Unicode, Inc.
# For terms of use, see http://www.unicode.org/terms_of_use.html # For terms of use, see http://www.unicode.org/terms_of_use.html
# For documentation, see http://www.unicode.org/reports/tr44/ # For documentation, see http://www.unicode.org/reports/tr44/
# #
......
...@@ -7190,6 +7190,7 @@ ...@@ -7190,6 +7190,7 @@
20B7;SPESMILO SIGN;Sc;0;ET;;;;;N;;;;; 20B7;SPESMILO SIGN;Sc;0;ET;;;;;N;;;;;
20B8;TENGE SIGN;Sc;0;ET;;;;;N;;;;; 20B8;TENGE SIGN;Sc;0;ET;;;;;N;;;;;
20B9;INDIAN RUPEE SIGN;Sc;0;ET;;;;;N;;;;; 20B9;INDIAN RUPEE SIGN;Sc;0;ET;;;;;N;;;;;
20BA;TURKISH LIRA SIGN;Sc;0;ET;;;;;N;;;;;
20D0;COMBINING LEFT HARPOON ABOVE;Mn;230;NSM;;;;;N;NON-SPACING LEFT HARPOON ABOVE;;;; 20D0;COMBINING LEFT HARPOON ABOVE;Mn;230;NSM;;;;;N;NON-SPACING LEFT HARPOON ABOVE;;;;
20D1;COMBINING RIGHT HARPOON ABOVE;Mn;230;NSM;;;;;N;NON-SPACING RIGHT HARPOON ABOVE;;;; 20D1;COMBINING RIGHT HARPOON ABOVE;Mn;230;NSM;;;;;N;NON-SPACING RIGHT HARPOON ABOVE;;;;
20D2;COMBINING LONG VERTICAL LINE OVERLAY;Mn;1;NSM;;;;;N;NON-SPACING LONG VERTICAL BAR OVERLAY;;;; 20D2;COMBINING LONG VERTICAL LINE OVERLAY;Mn;1;NSM;;;;;N;NON-SPACING LONG VERTICAL BAR OVERLAY;;;;
...@@ -18703,8 +18704,8 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;; ...@@ -18703,8 +18704,8 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
1242F;CUNEIFORM NUMERIC SIGN THREE SHARU VARIANT FORM;Nl;0;L;;;;3;N;;;;; 1242F;CUNEIFORM NUMERIC SIGN THREE SHARU VARIANT FORM;Nl;0;L;;;;3;N;;;;;
12430;CUNEIFORM NUMERIC SIGN FOUR SHARU;Nl;0;L;;;;4;N;;;;; 12430;CUNEIFORM NUMERIC SIGN FOUR SHARU;Nl;0;L;;;;4;N;;;;;
12431;CUNEIFORM NUMERIC SIGN FIVE SHARU;Nl;0;L;;;;5;N;;;;; 12431;CUNEIFORM NUMERIC SIGN FIVE SHARU;Nl;0;L;;;;5;N;;;;;
12432;CUNEIFORM NUMERIC SIGN SHAR2 TIMES GAL PLUS DISH;Nl;0;L;;;;;N;;;;; 12432;CUNEIFORM NUMERIC SIGN SHAR2 TIMES GAL PLUS DISH;Nl;0;L;;;;216000;N;;;;;
12433;CUNEIFORM NUMERIC SIGN SHAR2 TIMES GAL PLUS MIN;Nl;0;L;;;;;N;;;;; 12433;CUNEIFORM NUMERIC SIGN SHAR2 TIMES GAL PLUS MIN;Nl;0;L;;;;432000;N;;;;;
12434;CUNEIFORM NUMERIC SIGN ONE BURU;Nl;0;L;;;;1;N;;;;; 12434;CUNEIFORM NUMERIC SIGN ONE BURU;Nl;0;L;;;;1;N;;;;;
12435;CUNEIFORM NUMERIC SIGN TWO BURU;Nl;0;L;;;;2;N;;;;; 12435;CUNEIFORM NUMERIC SIGN TWO BURU;Nl;0;L;;;;2;N;;;;;
12436;CUNEIFORM NUMERIC SIGN THREE BURU;Nl;0;L;;;;3;N;;;;; 12436;CUNEIFORM NUMERIC SIGN THREE BURU;Nl;0;L;;;;3;N;;;;;
...@@ -18739,8 +18740,8 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;; ...@@ -18739,8 +18740,8 @@ FFFD;REPLACEMENT CHARACTER;So;0;ON;;;;;N;;;;;
12453;CUNEIFORM NUMERIC SIGN FOUR BAN2 VARIANT FORM;Nl;0;L;;;;4;N;;;;; 12453;CUNEIFORM NUMERIC SIGN FOUR BAN2 VARIANT FORM;Nl;0;L;;;;4;N;;;;;
12454;CUNEIFORM NUMERIC SIGN FIVE BAN2;Nl;0;L;;;;5;N;;;;; 12454;CUNEIFORM NUMERIC SIGN FIVE BAN2;Nl;0;L;;;;5;N;;;;;
12455;CUNEIFORM NUMERIC SIGN FIVE BAN2 VARIANT FORM;Nl;0;L;;;;5;N;;;;; 12455;CUNEIFORM NUMERIC SIGN FIVE BAN2 VARIANT FORM;Nl;0;L;;;;5;N;;;;;
12456;CUNEIFORM NUMERIC SIGN NIGIDAMIN;Nl;0;L;;;;;N;;;;; 12456;CUNEIFORM NUMERIC SIGN NIGIDAMIN;Nl;0;L;;;;-1;N;;;;;
12457;CUNEIFORM NUMERIC SIGN NIGIDAESH;Nl;0;L;;;;;N;;;;; 12457;CUNEIFORM NUMERIC SIGN NIGIDAESH;Nl;0;L;;;;-1;N;;;;;
12458;CUNEIFORM NUMERIC SIGN ONE ESHE3;Nl;0;L;;;;1;N;;;;; 12458;CUNEIFORM NUMERIC SIGN ONE ESHE3;Nl;0;L;;;;1;N;;;;;
12459;CUNEIFORM NUMERIC SIGN TWO ESHE3;Nl;0;L;;;;2;N;;;;; 12459;CUNEIFORM NUMERIC SIGN TWO ESHE3;Nl;0;L;;;;2;N;;;;;
1245A;CUNEIFORM NUMERIC SIGN ONE THIRD DISH;Nl;0;L;;;;1/3;N;;;;; 1245A;CUNEIFORM NUMERIC SIGN ONE THIRD DISH;Nl;0;L;;;;1/3;N;;;;;
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
GENDATA_TIMEZONE := GENDATA_TIMEZONE :=
# TODO: read from make/sun/javazic/tzdata/VERSION # TODO: read from make/sun/javazic/tzdata/VERSION
GENDATA_TIMEZONE_VERSION := tzdata2012c GENDATA_TIMEZONE_VERSION := tzdata2012i
GENDATA_TIMEZONE_DST := $(JDK_OUTPUTDIR)/lib/zi GENDATA_TIMEZONE_DST := $(JDK_OUTPUTDIR)/lib/zi
GENDATA_TIMEZONE_TMP := $(JDK_OUTPUTDIR)/gendata_timezone GENDATA_TIMEZONE_TMP := $(JDK_OUTPUTDIR)/gendata_timezone
......
...@@ -45,7 +45,7 @@ $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE,\ ...@@ -45,7 +45,7 @@ $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE,\
JVM:=$(JAVA),\ JVM:=$(JAVA),\
JAVAC:=$(JAVAC_JARS),\ JAVAC:=$(JAVAC_JARS),\
JAVAH:=$(JAVAH_JARS),\ JAVAH:=$(JAVAH_JARS),\
FLAGS:=-bootclasspath $(JDK_OUTPUTDIR)/classes -source 7 -target 7 -encoding ascii -XDignore.symbol.file=true $(DISABLE_WARNINGS),\ FLAGS:=-bootclasspath $(JDK_OUTPUTDIR)/classes -source 8 -target 8 -encoding ascii -XDignore.symbol.file=true $(DISABLE_WARNINGS),\
SERVER_DIR:=$(SJAVAC_SERVER_DIR),\ SERVER_DIR:=$(SJAVAC_SERVER_DIR),\
SERVER_JVM:=$(SJAVAC_SERVER_JAVA))) SERVER_JVM:=$(SJAVAC_SERVER_JAVA)))
......
/* /*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -55,12 +55,25 @@ abstract class PBEKeyFactory extends SecretKeyFactorySpi { ...@@ -55,12 +55,25 @@ abstract class PBEKeyFactory extends SecretKeyFactorySpi {
} }
static { static {
validTypes = new HashSet<String>(4); validTypes = new HashSet<String>(17);
validTypes.add("PBEWithMD5AndDES".toUpperCase()); validTypes.add("PBEWithMD5AndDES".toUpperCase());
validTypes.add("PBEWithSHA1AndDESede".toUpperCase()); validTypes.add("PBEWithSHA1AndDESede".toUpperCase());
validTypes.add("PBEWithSHA1AndRC2_40".toUpperCase()); validTypes.add("PBEWithSHA1AndRC2_40".toUpperCase());
validTypes.add("PBEWithSHA1AndRC2_128".toUpperCase());
validTypes.add("PBEWithSHA1AndRC4_40".toUpperCase());
validTypes.add("PBEWithSHA1AndRC4_128".toUpperCase());
// Proprietary algorithm. // Proprietary algorithm.
validTypes.add("PBEWithMD5AndTripleDES".toUpperCase()); validTypes.add("PBEWithMD5AndTripleDES".toUpperCase());
validTypes.add("PBEWithHmacSHA1AndAES_128".toUpperCase());
validTypes.add("PBEWithHmacSHA224AndAES_128".toUpperCase());
validTypes.add("PBEWithHmacSHA256AndAES_128".toUpperCase());
validTypes.add("PBEWithHmacSHA384AndAES_128".toUpperCase());
validTypes.add("PBEWithHmacSHA512AndAES_128".toUpperCase());
validTypes.add("PBEWithHmacSHA1AndAES_256".toUpperCase());
validTypes.add("PBEWithHmacSHA224AndAES_256".toUpperCase());
validTypes.add("PBEWithHmacSHA256AndAES_256".toUpperCase());
validTypes.add("PBEWithHmacSHA384AndAES_256".toUpperCase());
validTypes.add("PBEWithHmacSHA512AndAES_256".toUpperCase());
} }
public static final class PBEWithMD5AndDES public static final class PBEWithMD5AndDES
...@@ -84,6 +97,27 @@ abstract class PBEKeyFactory extends SecretKeyFactorySpi { ...@@ -84,6 +97,27 @@ abstract class PBEKeyFactory extends SecretKeyFactorySpi {
} }
} }
public static final class PBEWithSHA1AndRC2_128
extends PBEKeyFactory {
public PBEWithSHA1AndRC2_128() {
super("PBEWithSHA1AndRC2_128");
}
}
public static final class PBEWithSHA1AndRC4_40
extends PBEKeyFactory {
public PBEWithSHA1AndRC4_40() {
super("PBEWithSHA1AndRC4_40");
}
}
public static final class PBEWithSHA1AndRC4_128
extends PBEKeyFactory {
public PBEWithSHA1AndRC4_128() {
super("PBEWithSHA1AndRC4_128");
}
}
/* /*
* Private proprietary algorithm for supporting JCEKS. * Private proprietary algorithm for supporting JCEKS.
*/ */
...@@ -94,6 +128,75 @@ abstract class PBEKeyFactory extends SecretKeyFactorySpi { ...@@ -94,6 +128,75 @@ abstract class PBEKeyFactory extends SecretKeyFactorySpi {
} }
} }
public static final class PBEWithHmacSHA1AndAES_128
extends PBEKeyFactory {
public PBEWithHmacSHA1AndAES_128() {
super("PBEWithHmacSHA1AndAES_128");
}
}
public static final class PBEWithHmacSHA224AndAES_128
extends PBEKeyFactory {
public PBEWithHmacSHA224AndAES_128() {
super("PBEWithHmacSHA224AndAES_128");
}
}
public static final class PBEWithHmacSHA256AndAES_128
extends PBEKeyFactory {
public PBEWithHmacSHA256AndAES_128() {
super("PBEWithHmacSHA256AndAES_128");
}
}
public static final class PBEWithHmacSHA384AndAES_128
extends PBEKeyFactory {
public PBEWithHmacSHA384AndAES_128() {
super("PBEWithHmacSHA384AndAES_128");
}
}
public static final class PBEWithHmacSHA512AndAES_128
extends PBEKeyFactory {
public PBEWithHmacSHA512AndAES_128() {
super("PBEWithHmacSHA512AndAES_128");
}
}
public static final class PBEWithHmacSHA1AndAES_256
extends PBEKeyFactory {
public PBEWithHmacSHA1AndAES_256() {
super("PBEWithHmacSHA1AndAES_256");
}
}
public static final class PBEWithHmacSHA224AndAES_256
extends PBEKeyFactory {
public PBEWithHmacSHA224AndAES_256() {
super("PBEWithHmacSHA224AndAES_256");
}
}
public static final class PBEWithHmacSHA256AndAES_256
extends PBEKeyFactory {
public PBEWithHmacSHA256AndAES_256() {
super("PBEWithHmacSHA256AndAES_256");
}
}
public static final class PBEWithHmacSHA384AndAES_256
extends PBEKeyFactory {
public PBEWithHmacSHA384AndAES_256() {
super("PBEWithHmacSHA384AndAES_256");
}
}
public static final class PBEWithHmacSHA512AndAES_256
extends PBEKeyFactory {
public PBEWithHmacSHA512AndAES_256() {
super("PBEWithHmacSHA512AndAES_256");
}
}
/** /**
* Generates a <code>SecretKey</code> object from the provided key * Generates a <code>SecretKey</code> object from the provided key
......
/* /*
* Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -57,6 +57,9 @@ public final class PBEParameters extends AlgorithmParametersSpi { ...@@ -57,6 +57,9 @@ public final class PBEParameters extends AlgorithmParametersSpi {
// the iteration count // the iteration count
private int iCount = 0; private int iCount = 0;
// the cipher parameter
private AlgorithmParameterSpec cipherParam = null;
protected void engineInit(AlgorithmParameterSpec paramSpec) protected void engineInit(AlgorithmParameterSpec paramSpec)
throws InvalidParameterSpecException throws InvalidParameterSpecException
{ {
...@@ -66,6 +69,7 @@ public final class PBEParameters extends AlgorithmParametersSpi { ...@@ -66,6 +69,7 @@ public final class PBEParameters extends AlgorithmParametersSpi {
} }
this.salt = ((PBEParameterSpec)paramSpec).getSalt().clone(); this.salt = ((PBEParameterSpec)paramSpec).getSalt().clone();
this.iCount = ((PBEParameterSpec)paramSpec).getIterationCount(); this.iCount = ((PBEParameterSpec)paramSpec).getIterationCount();
this.cipherParam = ((PBEParameterSpec)paramSpec).getParameterSpec();
} }
protected void engineInit(byte[] encoded) protected void engineInit(byte[] encoded)
...@@ -102,7 +106,8 @@ public final class PBEParameters extends AlgorithmParametersSpi { ...@@ -102,7 +106,8 @@ public final class PBEParameters extends AlgorithmParametersSpi {
throws InvalidParameterSpecException throws InvalidParameterSpecException
{ {
if (PBEParameterSpec.class.isAssignableFrom(paramSpec)) { if (PBEParameterSpec.class.isAssignableFrom(paramSpec)) {
return paramSpec.cast(new PBEParameterSpec(this.salt, this.iCount)); return paramSpec.cast(
new PBEParameterSpec(this.salt, this.iCount, this.cipherParam));
} else { } else {
throw new InvalidParameterSpecException throw new InvalidParameterSpecException
("Inappropriate parameter specification"); ("Inappropriate parameter specification");
......
/*
* Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.crypto.provider;
import java.io.UnsupportedEncodingException;
import java.security.*;
import java.security.spec.*;
import javax.crypto.*;
import javax.crypto.interfaces.*;
import javax.crypto.spec.*;
/**
* This class represents password-based encryption as defined by the PKCS #5
* standard.
* These algorithms implement PBE with HmacSHA1/HmacSHA2-family and AES-CBC.
* Padding is done as described in PKCS #5.
*
* @author Jan Luehe
*
*
* @see javax.crypto.Cipher
*/
abstract class PBES2Core extends CipherSpi {
private static final int DEFAULT_SALT_LENGTH = 20;
private static final int DEFAULT_COUNT = 4096;
// the encapsulated cipher
private final CipherCore cipher;
private final int keyLength; // in bits
private final int blkSize; // in bits
private final PBKDF2Core kdf;
private final String pbeAlgo;
private final String cipherAlgo;
private int iCount = DEFAULT_COUNT;
private byte[] salt = null;
private IvParameterSpec ivSpec = null;
/**
* Creates an instance of PBE Scheme 2 according to the selected
* password-based key derivation function and encryption scheme.
*/
PBES2Core(String kdfAlgo, String cipherAlgo, int keySize)
throws NoSuchAlgorithmException, NoSuchPaddingException {
this.cipherAlgo = cipherAlgo;
keyLength = keySize * 8;
pbeAlgo = "PBEWith" + kdfAlgo + "And" + cipherAlgo + "_" + keyLength;
if (cipherAlgo.equals("AES")) {
blkSize = AESConstants.AES_BLOCK_SIZE;
cipher = new CipherCore(new AESCrypt(), blkSize);
switch(kdfAlgo) {
case "HmacSHA1":
kdf = new PBKDF2Core.HmacSHA1();
break;
case "HmacSHA224":
kdf = new PBKDF2Core.HmacSHA224();
break;
case "HmacSHA256":
kdf = new PBKDF2Core.HmacSHA256();
break;
case "HmacSHA384":
kdf = new PBKDF2Core.HmacSHA384();
break;
case "HmacSHA512":
kdf = new PBKDF2Core.HmacSHA512();
break;
default:
throw new NoSuchAlgorithmException(
"No Cipher implementation for " + kdfAlgo);
}
} else {
throw new NoSuchAlgorithmException("No Cipher implementation for " +
pbeAlgo);
}
cipher.setMode("CBC");
cipher.setPadding("PKCS5Padding");
}
protected void engineSetMode(String mode) throws NoSuchAlgorithmException {
if ((mode != null) && (!mode.equalsIgnoreCase("CBC"))) {
throw new NoSuchAlgorithmException("Invalid cipher mode: " + mode);
}
}
protected void engineSetPadding(String paddingScheme)
throws NoSuchPaddingException {
if ((paddingScheme != null) &&
(!paddingScheme.equalsIgnoreCase("PKCS5Padding"))) {
throw new NoSuchPaddingException("Invalid padding scheme: " +
paddingScheme);
}
}
protected int engineGetBlockSize() {
return blkSize;
}
protected int engineGetOutputSize(int inputLen) {
return cipher.getOutputSize(inputLen);
}
protected byte[] engineGetIV() {
return cipher.getIV();
}
protected AlgorithmParameters engineGetParameters() {
AlgorithmParameters params = null;
if (salt == null) {
// generate random salt and use default iteration count
salt = new byte[DEFAULT_SALT_LENGTH];
SunJCE.RANDOM.nextBytes(salt);
iCount = DEFAULT_COUNT;
}
if (ivSpec == null) {
// generate random IV
byte[] ivBytes = new byte[blkSize];
SunJCE.RANDOM.nextBytes(ivBytes);
ivSpec = new IvParameterSpec(ivBytes);
}
PBEParameterSpec pbeSpec = new PBEParameterSpec(salt, iCount, ivSpec);
try {
params = AlgorithmParameters.getInstance(pbeAlgo, "SunJCE");
} catch (NoSuchAlgorithmException nsae) {
// should never happen
throw new RuntimeException("SunJCE called, but not configured");
} catch (NoSuchProviderException nspe) {
// should never happen
throw new RuntimeException("SunJCE called, but not configured");
}
try {
params.init(pbeSpec);
} catch (InvalidParameterSpecException ipse) {
// should never happen
throw new RuntimeException("PBEParameterSpec not supported");
}
return params;
}
protected void engineInit(int opmode, Key key, SecureRandom random)
throws InvalidKeyException {
try {
engineInit(opmode, key, (AlgorithmParameterSpec) null, random);
} catch (InvalidAlgorithmParameterException ie) {
InvalidKeyException ike =
new InvalidKeyException("requires PBE parameters");
ike.initCause(ie);
throw ike;
}
}
protected void engineInit(int opmode, Key key,
AlgorithmParameterSpec params,
SecureRandom random)
throws InvalidKeyException, InvalidAlgorithmParameterException {
if ((key == null) ||
(key.getEncoded() == null) ||
!(key.getAlgorithm().regionMatches(true, 0, "PBE", 0, 3))) {
throw new InvalidKeyException("Missing password");
}
// TBD: consolidate the salt, ic and IV parameter checks below
// Extract salt and iteration count from the key, if present
if (key instanceof javax.crypto.interfaces.PBEKey) {
salt = ((javax.crypto.interfaces.PBEKey)key).getSalt();
if (salt != null && salt.length < 8) {
throw new InvalidAlgorithmParameterException(
"Salt must be at least 8 bytes long");
}
iCount = ((javax.crypto.interfaces.PBEKey)key).getIterationCount();
if (iCount == 0) {
iCount = DEFAULT_COUNT;
} else if (iCount < 0) {
throw new InvalidAlgorithmParameterException(
"Iteration count must be a positive number");
}
}
// Extract salt, iteration count and IV from the params, if present
if (params == null) {
if (salt == null) {
// generate random salt and use default iteration count
salt = new byte[DEFAULT_SALT_LENGTH];
random.nextBytes(salt);
iCount = DEFAULT_COUNT;
}
if ((opmode == Cipher.ENCRYPT_MODE) ||
(opmode == Cipher.WRAP_MODE)) {
// generate random IV
byte[] ivBytes = new byte[blkSize];
random.nextBytes(ivBytes);
ivSpec = new IvParameterSpec(ivBytes);
}
} else {
if (!(params instanceof PBEParameterSpec)) {
throw new InvalidAlgorithmParameterException
("Wrong parameter type: PBE expected");
}
// salt and iteration count from the params take precedence
byte[] specSalt = ((PBEParameterSpec) params).getSalt();
if (specSalt != null && specSalt.length < 8) {
throw new InvalidAlgorithmParameterException(
"Salt must be at least 8 bytes long");
}
salt = specSalt;
int specICount = ((PBEParameterSpec) params).getIterationCount();
if (specICount == 0) {
specICount = DEFAULT_COUNT;
} else if (specICount < 0) {
throw new InvalidAlgorithmParameterException(
"Iteration count must be a positive number");
}
iCount = specICount;
AlgorithmParameterSpec specParams =
((PBEParameterSpec) params).getParameterSpec();
if (specParams != null) {
if (specParams instanceof IvParameterSpec) {
ivSpec = (IvParameterSpec)specParams;
} else {
throw new InvalidAlgorithmParameterException(
"Wrong parameter type: IV expected");
}
} else if ((opmode == Cipher.ENCRYPT_MODE) ||
(opmode == Cipher.WRAP_MODE)) {
// generate random IV
byte[] ivBytes = new byte[blkSize];
random.nextBytes(ivBytes);
ivSpec = new IvParameterSpec(ivBytes);
} else {
throw new InvalidAlgorithmParameterException(
"Missing parameter type: IV expected");
}
}
SecretKeySpec cipherKey = null;
byte[] derivedKey = null;
byte[] passwdBytes = key.getEncoded();
char[] passwdChars = new char[passwdBytes.length];
for (int i=0; i<passwdChars.length; i++)
passwdChars[i] = (char) (passwdBytes[i] & 0x7f);
PBEKeySpec pbeSpec =
new PBEKeySpec(passwdChars, salt, iCount, blkSize * 8);
// password char[] was cloned in PBEKeySpec constructor,
// so we can zero it out here
java.util.Arrays.fill(passwdChars, ' ');
java.util.Arrays.fill(passwdBytes, (byte)0x00);
SecretKey s = null;
try {
s = kdf.engineGenerateSecret(pbeSpec);
} catch (InvalidKeySpecException ikse) {
InvalidKeyException ike =
new InvalidKeyException("Cannot construct PBE key");
ike.initCause(ikse);
throw ike;
}
derivedKey = s.getEncoded();
cipherKey = new SecretKeySpec(derivedKey, cipherAlgo);
// initialize the underlying cipher
cipher.init(opmode, cipherKey, ivSpec, random);
}
protected void engineInit(int opmode, Key key, AlgorithmParameters params,
SecureRandom random)
throws InvalidKeyException, InvalidAlgorithmParameterException {
AlgorithmParameterSpec pbeSpec = null;
if (params != null) {
try {
pbeSpec = params.getParameterSpec(PBEParameterSpec.class);
} catch (InvalidParameterSpecException ipse) {
throw new InvalidAlgorithmParameterException(
"Wrong parameter type: PBE expected");
}
}
engineInit(opmode, key, pbeSpec, random);
}
protected byte[] engineUpdate(byte[] input, int inputOffset, int inputLen) {
return cipher.update(input, inputOffset, inputLen);
}
protected int engineUpdate(byte[] input, int inputOffset, int inputLen,
byte[] output, int outputOffset)
throws ShortBufferException {
return cipher.update(input, inputOffset, inputLen,
output, outputOffset);
}
protected byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen)
throws IllegalBlockSizeException, BadPaddingException {
return cipher.doFinal(input, inputOffset, inputLen);
}
protected int engineDoFinal(byte[] input, int inputOffset, int inputLen,
byte[] output, int outputOffset)
throws ShortBufferException, IllegalBlockSizeException,
BadPaddingException {
return cipher.doFinal(input, inputOffset, inputLen,
output, outputOffset);
}
protected int engineGetKeySize(Key key) throws InvalidKeyException {
return keyLength;
}
protected byte[] engineWrap(Key key)
throws IllegalBlockSizeException, InvalidKeyException {
return cipher.wrap(key);
}
protected Key engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm,
int wrappedKeyType)
throws InvalidKeyException, NoSuchAlgorithmException {
byte[] encodedKey;
return cipher.unwrap(wrappedKey, wrappedKeyAlgorithm,
wrappedKeyType);
}
public static final class HmacSHA1AndAES_128 extends PBES2Core {
public HmacSHA1AndAES_128()
throws NoSuchAlgorithmException, NoSuchPaddingException {
super("HmacSHA1", "AES", 16);
}
}
public static final class HmacSHA224AndAES_128 extends PBES2Core {
public HmacSHA224AndAES_128()
throws NoSuchAlgorithmException, NoSuchPaddingException {
super("HmacSHA224", "AES", 16);
}
}
public static final class HmacSHA256AndAES_128 extends PBES2Core {
public HmacSHA256AndAES_128()
throws NoSuchAlgorithmException, NoSuchPaddingException {
super("HmacSHA256", "AES", 16);
}
}
public static final class HmacSHA384AndAES_128 extends PBES2Core {
public HmacSHA384AndAES_128()
throws NoSuchAlgorithmException, NoSuchPaddingException {
super("HmacSHA384", "AES", 16);
}
}
public static final class HmacSHA512AndAES_128 extends PBES2Core {
public HmacSHA512AndAES_128()
throws NoSuchAlgorithmException, NoSuchPaddingException {
super("HmacSHA512", "AES", 16);
}
}
public static final class HmacSHA1AndAES_256 extends PBES2Core {
public HmacSHA1AndAES_256()
throws NoSuchAlgorithmException, NoSuchPaddingException {
super("HmacSHA1", "AES", 32);
}
}
public static final class HmacSHA224AndAES_256 extends PBES2Core {
public HmacSHA224AndAES_256()
throws NoSuchAlgorithmException, NoSuchPaddingException {
super("HmacSHA224", "AES", 32);
}
}
public static final class HmacSHA256AndAES_256 extends PBES2Core {
public HmacSHA256AndAES_256()
throws NoSuchAlgorithmException, NoSuchPaddingException {
super("HmacSHA256", "AES", 32);
}
}
public static final class HmacSHA384AndAES_256 extends PBES2Core {
public HmacSHA384AndAES_256()
throws NoSuchAlgorithmException, NoSuchPaddingException {
super("HmacSHA384", "AES", 32);
}
}
public static final class HmacSHA512AndAES_256 extends PBES2Core {
public HmacSHA512AndAES_256()
throws NoSuchAlgorithmException, NoSuchPaddingException {
super("HmacSHA512", "AES", 32);
}
}
}
/* /*
* Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -45,7 +45,7 @@ import javax.crypto.spec.*; ...@@ -45,7 +45,7 @@ import javax.crypto.spec.*;
public final class PBEWithMD5AndDESCipher extends CipherSpi { public final class PBEWithMD5AndDESCipher extends CipherSpi {
// the encapsulated DES cipher // the encapsulated DES cipher
private PBECipherCore core; private PBES1Core core;
/** /**
* Creates an instance of this cipher, and initializes its mode (CBC) and * Creates an instance of this cipher, and initializes its mode (CBC) and
...@@ -58,7 +58,7 @@ public final class PBEWithMD5AndDESCipher extends CipherSpi { ...@@ -58,7 +58,7 @@ public final class PBEWithMD5AndDESCipher extends CipherSpi {
*/ */
public PBEWithMD5AndDESCipher() public PBEWithMD5AndDESCipher()
throws NoSuchAlgorithmException, NoSuchPaddingException { throws NoSuchAlgorithmException, NoSuchPaddingException {
core = new PBECipherCore("DES"); core = new PBES1Core("DES");
} }
/** /**
......
/* /*
* Copyright (c) 1998, 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -55,7 +55,7 @@ import javax.crypto.spec.*; ...@@ -55,7 +55,7 @@ import javax.crypto.spec.*;
*/ */
public final class PBEWithMD5AndTripleDESCipher extends CipherSpi { public final class PBEWithMD5AndTripleDESCipher extends CipherSpi {
private PBECipherCore core; private PBES1Core core;
/** /**
* Creates an instance of this cipher, and initializes its mode (CBC) and * Creates an instance of this cipher, and initializes its mode (CBC) and
...@@ -70,7 +70,7 @@ public final class PBEWithMD5AndTripleDESCipher extends CipherSpi { ...@@ -70,7 +70,7 @@ public final class PBEWithMD5AndTripleDESCipher extends CipherSpi {
throws NoSuchAlgorithmException, NoSuchPaddingException throws NoSuchAlgorithmException, NoSuchPaddingException
{ {
// set the encapsulated cipher to do triple DES // set the encapsulated cipher to do triple DES
core = new PBECipherCore("DESede"); core = new PBES1Core("DESede");
} }
/** /**
......
/*
* Copyright (c) 2005, 2012, Oracle and/or its affiliates. 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.crypto.provider;
import java.security.InvalidKeyException;
import java.security.spec.KeySpec;
import java.security.spec.InvalidKeySpecException;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactorySpi;
import javax.crypto.spec.PBEKeySpec;
/**
* This class implements a key factory for PBE keys derived using
* PBKDF2 with HmacSHA1/HmacSHA224/HmacSHA256/HmacSHA384/HmacSHA512
* pseudo random function (PRF) as defined in PKCS#5 v2.1.
*
* @author Valerie Peng
*
*/
abstract class PBKDF2Core extends SecretKeyFactorySpi {
private final String prfAlgo;
PBKDF2Core(String prfAlgo) {
this.prfAlgo = prfAlgo;
}
/**
* Generates a <code>SecretKey</code> object from the provided key
* specification (key material).
*
* @param keySpec the specification (key material) of the secret key
*
* @return the secret key
*
* @exception InvalidKeySpecException if the given key specification
* is inappropriate for this key factory to produce a public key.
*/
protected SecretKey engineGenerateSecret(KeySpec keySpec)
throws InvalidKeySpecException
{
if (!(keySpec instanceof PBEKeySpec)) {
throw new InvalidKeySpecException("Invalid key spec");
}
PBEKeySpec ks = (PBEKeySpec) keySpec;
return new PBKDF2KeyImpl(ks, prfAlgo);
}
/**
* Returns a specification (key material) of the given key
* in the requested format.
*
* @param key the key
*
* @param keySpec the requested format in which the key material shall be
* returned
*
* @return the underlying key specification (key material) in the
* requested format
*
* @exception InvalidKeySpecException if the requested key
* specification is inappropriate for the given key, or the
* given key cannot be processed (e.g., the given key has an
* unrecognized algorithm or format).
*/
protected KeySpec engineGetKeySpec(SecretKey key, Class<?> keySpecCl)
throws InvalidKeySpecException {
if (key instanceof javax.crypto.interfaces.PBEKey) {
// Check if requested key spec is amongst the valid ones
if ((keySpecCl != null)
&& PBEKeySpec.class.isAssignableFrom(keySpecCl)) {
javax.crypto.interfaces.PBEKey pKey =
(javax.crypto.interfaces.PBEKey) key;
return new PBEKeySpec
(pKey.getPassword(), pKey.getSalt(),
pKey.getIterationCount(), pKey.getEncoded().length*8);
} else {
throw new InvalidKeySpecException("Invalid key spec");
}
} else {
throw new InvalidKeySpecException("Invalid key " +
"format/algorithm");
}
}
/**
* Translates a <code>SecretKey</code> object, whose provider may be
* unknown or potentially untrusted, into a corresponding
* <code>SecretKey</code> object of this key factory.
*
* @param key the key whose provider is unknown or untrusted
*
* @return the translated key
*
* @exception InvalidKeyException if the given key cannot be processed by
* this key factory.
*/
protected SecretKey engineTranslateKey(SecretKey key)
throws InvalidKeyException {
if ((key != null) &&
(key.getAlgorithm().equalsIgnoreCase("PBKDF2With" + prfAlgo)) &&
(key.getFormat().equalsIgnoreCase("RAW"))) {
// Check if key originates from this factory
if (key instanceof com.sun.crypto.provider.PBKDF2KeyImpl) {
return key;
}
// Check if key implements the PBEKey
if (key instanceof javax.crypto.interfaces.PBEKey) {
javax.crypto.interfaces.PBEKey pKey =
(javax.crypto.interfaces.PBEKey) key;
try {
PBEKeySpec spec =
new PBEKeySpec(pKey.getPassword(),
pKey.getSalt(),
pKey.getIterationCount(),
pKey.getEncoded().length*8);
return new PBKDF2KeyImpl(spec, prfAlgo);
} catch (InvalidKeySpecException re) {
InvalidKeyException ike = new InvalidKeyException
("Invalid key component(s)");
ike.initCause(re);
throw ike;
}
}
}
throw new InvalidKeyException("Invalid key format/algorithm");
}
public static final class HmacSHA1 extends PBKDF2Core {
public HmacSHA1() {
super("HmacSHA1");
}
}
public static final class HmacSHA224 extends PBKDF2Core {
public HmacSHA224() {
super("HmacSHA224");
}
}
public static final class HmacSHA256 extends PBKDF2Core {
public HmacSHA256() {
super("HmacSHA256");
}
}
public static final class HmacSHA384 extends PBKDF2Core {
public HmacSHA384() {
super("HmacSHA384");
}
}
public static final class HmacSHA512 extends PBKDF2Core {
public HmacSHA512() {
super("HmacSHA512");
}
}
}
/*
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.crypto.provider;
import java.util.Arrays;
import java.nio.ByteBuffer;
import javax.crypto.MacSpi;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.PBEParameterSpec;
import java.security.*;
import java.security.spec.*;
/**
* This is an implementation of the PBMAC1 algorithms as defined
* in PKCS#5 v2.1 standard.
*/
abstract class PBMAC1Core extends HmacCore {
private static final int DEFAULT_SALT_LENGTH = 20;
private static final int DEFAULT_COUNT = 4096;
private final String kdfAlgo;
private final String hashAlgo;
private final PBKDF2Core kdf;
private final int blockLength; // in octets
/**
* Creates an instance of PBMAC1 according to the selected
* password-based key derivation function.
*/
PBMAC1Core(String kdfAlgo, String hashAlgo, int blockLength)
throws NoSuchAlgorithmException {
super(hashAlgo, blockLength);
this.kdfAlgo = kdfAlgo;
this.hashAlgo = hashAlgo;
this.blockLength = blockLength;
switch(kdfAlgo) {
case "HmacSHA1":
kdf = new PBKDF2Core.HmacSHA1();
break;
case "HmacSHA224":
kdf = new PBKDF2Core.HmacSHA224();
break;
case "HmacSHA256":
kdf = new PBKDF2Core.HmacSHA256();
break;
case "HmacSHA384":
kdf = new PBKDF2Core.HmacSHA384();
break;
case "HmacSHA512":
kdf = new PBKDF2Core.HmacSHA512();
break;
default:
throw new NoSuchAlgorithmException(
"No MAC implementation for " + kdfAlgo);
}
}
/**
* Initializes the HMAC with the given secret key and algorithm parameters.
*
* @param key the secret key.
* @param params the algorithm parameters.
*
* @exception InvalidKeyException if the given key is inappropriate for
* initializing this MAC.
* @exception InvalidAlgorithmParameterException if the given algorithm
* parameters are inappropriate for this MAC.
*/
protected void engineInit(Key key, AlgorithmParameterSpec params)
throws InvalidKeyException, InvalidAlgorithmParameterException {
char[] passwdChars;
byte[] salt = null;
int iCount = 0;
if (key instanceof javax.crypto.interfaces.PBEKey) {
javax.crypto.interfaces.PBEKey pbeKey =
(javax.crypto.interfaces.PBEKey) key;
passwdChars = pbeKey.getPassword();
salt = pbeKey.getSalt(); // maybe null if unspecified
iCount = pbeKey.getIterationCount(); // maybe 0 if unspecified
} else if (key instanceof SecretKey) {
byte[] passwdBytes = key.getEncoded();
if ((passwdBytes == null) ||
!(key.getAlgorithm().regionMatches(true, 0, "PBE", 0, 3))) {
throw new InvalidKeyException("Missing password");
}
passwdChars = new char[passwdBytes.length];
for (int i=0; i<passwdChars.length; i++) {
passwdChars[i] = (char) (passwdBytes[i] & 0x7f);
}
} else {
throw new InvalidKeyException("SecretKey of PBE type required");
}
if (params == null) {
// generate default for salt and iteration count if necessary
if (salt == null) {
salt = new byte[DEFAULT_SALT_LENGTH];
SunJCE.RANDOM.nextBytes(salt);
}
if (iCount == 0) iCount = DEFAULT_COUNT;
} else if (!(params instanceof PBEParameterSpec)) {
throw new InvalidAlgorithmParameterException
("PBEParameterSpec type required");
} else {
PBEParameterSpec pbeParams = (PBEParameterSpec) params;
// make sure the parameter values are consistent
if (salt != null) {
if (!Arrays.equals(salt, pbeParams.getSalt())) {
throw new InvalidAlgorithmParameterException
("Inconsistent value of salt between key and params");
}
} else {
salt = pbeParams.getSalt();
}
if (iCount != 0) {
if (iCount != pbeParams.getIterationCount()) {
throw new InvalidAlgorithmParameterException
("Different iteration count between key and params");
}
} else {
iCount = pbeParams.getIterationCount();
}
}
// For security purpose, we need to enforce a minimum length
// for salt; just require the minimum salt length to be 8-byte
// which is what PKCS#5 recommends and openssl does.
if (salt.length < 8) {
throw new InvalidAlgorithmParameterException
("Salt must be at least 8 bytes long");
}
if (iCount <= 0) {
throw new InvalidAlgorithmParameterException
("IterationCount must be a positive number");
}
PBEKeySpec pbeSpec =
new PBEKeySpec(passwdChars, salt, iCount, blockLength);
// password char[] was cloned in PBEKeySpec constructor,
// so we can zero it out here
java.util.Arrays.fill(passwdChars, ' ');
SecretKey s = null;
try {
s = kdf.engineGenerateSecret(pbeSpec);
} catch (InvalidKeySpecException ikse) {
InvalidKeyException ike =
new InvalidKeyException("Cannot construct PBE key");
ike.initCause(ikse);
throw ike;
}
byte[] derivedKey = s.getEncoded();
SecretKey cipherKey = new SecretKeySpec(derivedKey, kdfAlgo);
super.engineInit(cipherKey, null);
}
public static final class HmacSHA1 extends PBMAC1Core {
public HmacSHA1() throws NoSuchAlgorithmException {
super("HmacSHA1", "SHA1", 64);
}
}
public static final class HmacSHA224 extends PBMAC1Core {
public HmacSHA224() throws NoSuchAlgorithmException {
super("HmacSHA224", "SHA-224", 64);
}
}
public static final class HmacSHA256 extends PBMAC1Core {
public HmacSHA256() throws NoSuchAlgorithmException {
super("HmacSHA256", "SHA-256", 64);
}
}
public static final class HmacSHA384 extends PBMAC1Core {
public HmacSHA384() throws NoSuchAlgorithmException {
super("HmacSHA384", "SHA-384", 128);
}
}
public static final class HmacSHA512 extends PBMAC1Core {
public HmacSHA512() throws NoSuchAlgorithmException {
super("HmacSHA512", "SHA-512", 128);
}
}
}
...@@ -35,19 +35,24 @@ import javax.crypto.spec.*; ...@@ -35,19 +35,24 @@ import javax.crypto.spec.*;
/** /**
* This class implements password-base encryption algorithm with * This class implements password-base encryption algorithm with
* SHA1 digest and the following Ciphers in CBC mode * SHA1 digest and the following Ciphers (in CBC mode, where applicable):
* - DESede cipher and * - DESede cipher and
* - RC2 Cipher with 40-bit effective key length * - RC2 Cipher with 40-bit or 128-bit effective key length and
* - RC4 Cipher with 40-bit or 128-bit effective key length
* as defined by PKCS #12 version 1.0 standard. * as defined by PKCS #12 version 1.0 standard.
* *
* @author Valerie Peng * @author Valerie Peng
* @see javax.crypto.CipherSpi * @see javax.crypto.CipherSpi
*/ */
final class PKCS12PBECipherCore { final class PKCS12PBECipherCore {
// TBD: replace CipherCore with a CipherSpi object to simplify maintenance
private CipherCore cipher; private CipherCore cipher;
private int blockSize; private int blockSize;
private int keySize; private int keySize;
private String algo = null; private String algo = null;
private String pbeAlgo = null;
private byte[] salt = null; private byte[] salt = null;
private int iCount = 0; private int iCount = 0;
...@@ -58,8 +63,16 @@ final class PKCS12PBECipherCore { ...@@ -58,8 +63,16 @@ final class PKCS12PBECipherCore {
static final int CIPHER_IV = 2; static final int CIPHER_IV = 2;
static final int MAC_KEY = 3; static final int MAC_KEY = 3;
// Uses default hash algorithm (SHA-1)
static byte[] derive(char[] chars, byte[] salt, static byte[] derive(char[] chars, byte[] salt,
int ic, int n, int type) { int ic, int n, int type) {
return derive(chars, salt, ic, n, type, "SHA-1", 64);
}
// Uses supplied hash algorithm
static byte[] derive(char[] chars, byte[] salt, int ic, int n, int type,
String hashAlgo, int blockLength) {
// Add in trailing NULL terminator. Special case: // Add in trailing NULL terminator. Special case:
// no terminator if password is "\0". // no terminator if password is "\0".
int length = chars.length*2; int length = chars.length*2;
...@@ -75,21 +88,23 @@ final class PKCS12PBECipherCore { ...@@ -75,21 +88,23 @@ final class PKCS12PBECipherCore {
passwd[j] = (byte) ((chars[i] >>> 8) & 0xFF); passwd[j] = (byte) ((chars[i] >>> 8) & 0xFF);
passwd[j+1] = (byte) (chars[i] & 0xFF); passwd[j+1] = (byte) (chars[i] & 0xFF);
} }
int v = 512 / 8; byte[] key = new byte[n];
int u = 160 / 8;
try {
MessageDigest sha = MessageDigest.getInstance(hashAlgo);
int v = blockLength;
int u = sha.getDigestLength();
int c = roundup(n, u) / u; int c = roundup(n, u) / u;
byte[] D = new byte[v]; byte[] D = new byte[v];
int s = roundup(salt.length, v); int s = roundup(salt.length, v);
int p = roundup(passwd.length, v); int p = roundup(passwd.length, v);
byte[] I = new byte[s + p]; byte[] I = new byte[s + p];
byte[] key = new byte[n];
Arrays.fill(D, (byte)type); Arrays.fill(D, (byte)type);
concat(salt, I, 0, s); concat(salt, I, 0, s);
concat(passwd, I, s, p); concat(passwd, I, s, p);
try {
MessageDigest sha = MessageDigest.getInstance("SHA1");
byte[] Ai; byte[] Ai;
byte[] B = new byte[v]; byte[] B = new byte[v];
byte[] tmp = new byte[v]; byte[] tmp = new byte[v];
...@@ -150,12 +165,18 @@ final class PKCS12PBECipherCore { ...@@ -150,12 +165,18 @@ final class PKCS12PBECipherCore {
PKCS12PBECipherCore(String symmCipherAlg, int defKeySize) PKCS12PBECipherCore(String symmCipherAlg, int defKeySize)
throws NoSuchAlgorithmException { throws NoSuchAlgorithmException {
algo = symmCipherAlg; algo = symmCipherAlg;
if (algo.equals("RC4")) {
pbeAlgo = "PBEWithSHA1AndRC4_" + defKeySize * 8;
} else {
SymmetricCipher symmCipher = null; SymmetricCipher symmCipher = null;
if (algo.equals("DESede")) { if (algo.equals("DESede")) {
symmCipher = new DESedeCrypt(); symmCipher = new DESedeCrypt();
pbeAlgo = "PBEWithSHA1AndDESede";
} else if (algo.equals("RC2")) { } else if (algo.equals("RC2")) {
symmCipher = new RC2Crypt(); symmCipher = new RC2Crypt();
pbeAlgo = "PBEWithSHA1AndRC2_" + defKeySize * 8;
} else { } else {
throw new NoSuchAlgorithmException("No Cipher implementation " + throw new NoSuchAlgorithmException("No Cipher implementation " +
"for PBEWithSHA1And" + algo); "for PBEWithSHA1And" + algo);
...@@ -168,6 +189,7 @@ final class PKCS12PBECipherCore { ...@@ -168,6 +189,7 @@ final class PKCS12PBECipherCore {
} catch (NoSuchPaddingException nspe) { } catch (NoSuchPaddingException nspe) {
// should not happen // should not happen
} }
}
keySize = defKeySize; keySize = defKeySize;
} }
...@@ -210,8 +232,7 @@ final class PKCS12PBECipherCore { ...@@ -210,8 +232,7 @@ final class PKCS12PBECipherCore {
} }
PBEParameterSpec pbeSpec = new PBEParameterSpec(salt, iCount); PBEParameterSpec pbeSpec = new PBEParameterSpec(salt, iCount);
try { try {
params = AlgorithmParameters.getInstance("PBEWithSHA1And" + params = AlgorithmParameters.getInstance(pbeAlgo, "SunJCE");
(algo.equalsIgnoreCase("RC2")?"RC2_40":algo), "SunJCE");
} catch (GeneralSecurityException gse) { } catch (GeneralSecurityException gse) {
// should never happen // should never happen
throw new RuntimeException( throw new RuntimeException(
...@@ -229,6 +250,13 @@ final class PKCS12PBECipherCore { ...@@ -229,6 +250,13 @@ final class PKCS12PBECipherCore {
void implInit(int opmode, Key key, AlgorithmParameterSpec params, void implInit(int opmode, Key key, AlgorithmParameterSpec params,
SecureRandom random) throws InvalidKeyException, SecureRandom random) throws InvalidKeyException,
InvalidAlgorithmParameterException { InvalidAlgorithmParameterException {
implInit(opmode, key, params, random, null);
}
void implInit(int opmode, Key key, AlgorithmParameterSpec params,
SecureRandom random, CipherSpi cipherImpl)
throws InvalidKeyException,
InvalidAlgorithmParameterException {
char[] passwdChars = null; char[] passwdChars = null;
salt = null; salt = null;
iCount = 0; iCount = 0;
...@@ -309,6 +337,11 @@ final class PKCS12PBECipherCore { ...@@ -309,6 +337,11 @@ final class PKCS12PBECipherCore {
byte[] derivedKey = derive(passwdChars, salt, iCount, byte[] derivedKey = derive(passwdChars, salt, iCount,
keySize, CIPHER_KEY); keySize, CIPHER_KEY);
SecretKey cipherKey = new SecretKeySpec(derivedKey, algo); SecretKey cipherKey = new SecretKeySpec(derivedKey, algo);
if (cipherImpl != null && cipherImpl instanceof ARCFOURCipher) {
((ARCFOURCipher)cipherImpl).engineInit(opmode, cipherKey, random);
} else {
byte[] derivedIv = derive(passwdChars, salt, iCount, 8, byte[] derivedIv = derive(passwdChars, salt, iCount, 8,
CIPHER_IV); CIPHER_IV);
IvParameterSpec ivSpec = new IvParameterSpec(derivedIv, 0, 8); IvParameterSpec ivSpec = new IvParameterSpec(derivedIv, 0, 8);
...@@ -316,10 +349,17 @@ final class PKCS12PBECipherCore { ...@@ -316,10 +349,17 @@ final class PKCS12PBECipherCore {
// initialize the underlying cipher // initialize the underlying cipher
cipher.init(opmode, cipherKey, ivSpec, random); cipher.init(opmode, cipherKey, ivSpec, random);
} }
}
void implInit(int opmode, Key key, AlgorithmParameters params, void implInit(int opmode, Key key, AlgorithmParameters params,
SecureRandom random) SecureRandom random)
throws InvalidKeyException, InvalidAlgorithmParameterException { throws InvalidKeyException, InvalidAlgorithmParameterException {
implInit(opmode, key, params, random, null);
}
void implInit(int opmode, Key key, AlgorithmParameters params,
SecureRandom random, CipherSpi cipherImpl)
throws InvalidKeyException, InvalidAlgorithmParameterException {
AlgorithmParameterSpec paramSpec = null; AlgorithmParameterSpec paramSpec = null;
if (params != null) { if (params != null) {
try { try {
...@@ -329,13 +369,19 @@ final class PKCS12PBECipherCore { ...@@ -329,13 +369,19 @@ final class PKCS12PBECipherCore {
"requires PBE parameters"); "requires PBE parameters");
} }
} }
implInit(opmode, key, paramSpec, random); implInit(opmode, key, paramSpec, random, cipherImpl);
} }
void implInit(int opmode, Key key, SecureRandom random) void implInit(int opmode, Key key, SecureRandom random)
throws InvalidKeyException { throws InvalidKeyException {
implInit(opmode, key, random, null);
}
void implInit(int opmode, Key key, SecureRandom random,
CipherSpi cipherImpl) throws InvalidKeyException {
try { try {
implInit(opmode, key, (AlgorithmParameterSpec) null, random); implInit(opmode, key, (AlgorithmParameterSpec) null, random,
cipherImpl);
} catch (InvalidAlgorithmParameterException iape) { } catch (InvalidAlgorithmParameterException iape) {
throw new InvalidKeyException("requires PBE parameters"); throw new InvalidKeyException("requires PBE parameters");
} }
...@@ -526,4 +572,245 @@ final class PKCS12PBECipherCore { ...@@ -526,4 +572,245 @@ final class PKCS12PBECipherCore {
return core.implWrap(key); return core.implWrap(key);
} }
} }
public static final class PBEWithSHA1AndRC2_128 extends CipherSpi {
private final PKCS12PBECipherCore core;
public PBEWithSHA1AndRC2_128() throws NoSuchAlgorithmException {
core = new PKCS12PBECipherCore("RC2", 16);
}
protected byte[] engineDoFinal(byte[] in, int inOff, int inLen)
throws IllegalBlockSizeException, BadPaddingException {
return core.implDoFinal(in, inOff, inLen);
}
protected int engineDoFinal(byte[] in, int inOff, int inLen,
byte[] out, int outOff)
throws ShortBufferException, IllegalBlockSizeException,
BadPaddingException {
return core.implDoFinal(in, inOff, inLen, out, outOff);
}
protected int engineGetBlockSize() {
return core.implGetBlockSize();
}
protected byte[] engineGetIV() {
return core.implGetIV();
}
protected int engineGetKeySize(Key key) throws InvalidKeyException {
return core.implGetKeySize(key);
}
protected int engineGetOutputSize(int inLen) {
return core.implGetOutputSize(inLen);
}
protected AlgorithmParameters engineGetParameters() {
return core.implGetParameters();
}
protected void engineInit(int opmode, Key key,
AlgorithmParameterSpec params,
SecureRandom random)
throws InvalidKeyException, InvalidAlgorithmParameterException {
core.implInit(opmode, key, params, random);
}
protected void engineInit(int opmode, Key key,
AlgorithmParameters params,
SecureRandom random)
throws InvalidKeyException, InvalidAlgorithmParameterException {
core.implInit(opmode, key, params, random);
}
protected void engineInit(int opmode, Key key, SecureRandom random)
throws InvalidKeyException {
core.implInit(opmode, key, random);
}
protected void engineSetMode(String mode)
throws NoSuchAlgorithmException {
core.implSetMode(mode);
}
protected void engineSetPadding(String paddingScheme)
throws NoSuchPaddingException {
core.implSetPadding(paddingScheme);
}
protected Key engineUnwrap(byte[] wrappedKey,
String wrappedKeyAlgorithm,
int wrappedKeyType)
throws InvalidKeyException, NoSuchAlgorithmException {
return core.implUnwrap(wrappedKey, wrappedKeyAlgorithm,
wrappedKeyType);
}
protected byte[] engineUpdate(byte[] in, int inOff, int inLen) {
return core.implUpdate(in, inOff, inLen);
}
protected int engineUpdate(byte[] in, int inOff, int inLen,
byte[] out, int outOff)
throws ShortBufferException {
return core.implUpdate(in, inOff, inLen, out, outOff);
}
protected byte[] engineWrap(Key key)
throws IllegalBlockSizeException, InvalidKeyException {
return core.implWrap(key);
}
}
public static final class PBEWithSHA1AndRC4_40 extends CipherSpi {
private static final int RC4_KEYSIZE = 5;
private final PKCS12PBECipherCore core;
private final ARCFOURCipher cipher;
public PBEWithSHA1AndRC4_40() throws NoSuchAlgorithmException {
core = new PKCS12PBECipherCore("RC4", RC4_KEYSIZE);
cipher = new ARCFOURCipher();
}
protected byte[] engineDoFinal(byte[] in, int inOff, int inLen)
throws IllegalBlockSizeException, BadPaddingException {
return cipher.engineDoFinal(in, inOff, inLen);
}
protected int engineDoFinal(byte[] in, int inOff, int inLen,
byte[] out, int outOff)
throws ShortBufferException, IllegalBlockSizeException,
BadPaddingException {
return cipher.engineDoFinal(in, inOff, inLen, out, outOff);
}
protected int engineGetBlockSize() {
return cipher.engineGetBlockSize();
}
protected byte[] engineGetIV() {
return cipher.engineGetIV();
}
protected int engineGetKeySize(Key key) throws InvalidKeyException {
return RC4_KEYSIZE;
}
protected int engineGetOutputSize(int inLen) {
return cipher.engineGetOutputSize(inLen);
}
protected AlgorithmParameters engineGetParameters() {
return core.implGetParameters();
}
protected void engineInit(int opmode, Key key,
AlgorithmParameterSpec params,
SecureRandom random)
throws InvalidKeyException, InvalidAlgorithmParameterException {
core.implInit(opmode, key, params, random, cipher);
}
protected void engineInit(int opmode, Key key,
AlgorithmParameters params,
SecureRandom random)
throws InvalidKeyException, InvalidAlgorithmParameterException {
core.implInit(opmode, key, params, random, cipher);
}
protected void engineInit(int opmode, Key key, SecureRandom random)
throws InvalidKeyException {
core.implInit(opmode, key, random, cipher);
}
protected void engineSetMode(String mode)
throws NoSuchAlgorithmException {
if (mode.equalsIgnoreCase("ECB") == false) {
throw new NoSuchAlgorithmException("Unsupported mode " + mode);
}
}
protected void engineSetPadding(String paddingScheme)
throws NoSuchPaddingException {
if (paddingScheme.equalsIgnoreCase("NoPadding") == false) {
throw new NoSuchPaddingException("Padding must be NoPadding");
}
}
protected Key engineUnwrap(byte[] wrappedKey,
String wrappedKeyAlgorithm,
int wrappedKeyType)
throws InvalidKeyException, NoSuchAlgorithmException {
return cipher.engineUnwrap(wrappedKey, wrappedKeyAlgorithm,
wrappedKeyType);
}
protected byte[] engineUpdate(byte[] in, int inOff, int inLen) {
return cipher.engineUpdate(in, inOff, inLen);
}
protected int engineUpdate(byte[] in, int inOff, int inLen,
byte[] out, int outOff)
throws ShortBufferException {
return cipher.engineUpdate(in, inOff, inLen, out, outOff);
}
protected byte[] engineWrap(Key key)
throws IllegalBlockSizeException, InvalidKeyException {
return cipher.engineWrap(key);
}
}
public static final class PBEWithSHA1AndRC4_128 extends CipherSpi {
private static final int RC4_KEYSIZE = 16;
private final PKCS12PBECipherCore core;
private final ARCFOURCipher cipher;
public PBEWithSHA1AndRC4_128() throws NoSuchAlgorithmException {
core = new PKCS12PBECipherCore("RC4", RC4_KEYSIZE);
cipher = new ARCFOURCipher();
}
protected byte[] engineDoFinal(byte[] in, int inOff, int inLen)
throws IllegalBlockSizeException, BadPaddingException {
return cipher.engineDoFinal(in, inOff, inLen);
}
protected int engineDoFinal(byte[] in, int inOff, int inLen,
byte[] out, int outOff)
throws ShortBufferException, IllegalBlockSizeException,
BadPaddingException {
return cipher.engineDoFinal(in, inOff, inLen, out, outOff);
}
protected int engineGetBlockSize() {
return cipher.engineGetBlockSize();
}
protected byte[] engineGetIV() {
return cipher.engineGetIV();
}
protected int engineGetKeySize(Key key) throws InvalidKeyException {
return RC4_KEYSIZE;
}
protected int engineGetOutputSize(int inLen) {
return cipher.engineGetOutputSize(inLen);
}
protected AlgorithmParameters engineGetParameters() {
return core.implGetParameters();
}
protected void engineInit(int opmode, Key key,
AlgorithmParameterSpec params,
SecureRandom random)
throws InvalidKeyException, InvalidAlgorithmParameterException {
core.implInit(opmode, key, params, random, cipher);
}
protected void engineInit(int opmode, Key key,
AlgorithmParameters params,
SecureRandom random)
throws InvalidKeyException, InvalidAlgorithmParameterException {
core.implInit(opmode, key, params, random, cipher);
}
protected void engineInit(int opmode, Key key, SecureRandom random)
throws InvalidKeyException {
core.implInit(opmode, key, random, cipher);
}
protected void engineSetMode(String mode)
throws NoSuchAlgorithmException {
if (mode.equalsIgnoreCase("ECB") == false) {
throw new NoSuchAlgorithmException("Unsupported mode " + mode);
}
}
protected void engineSetPadding(String paddingScheme)
throws NoSuchPaddingException {
if (paddingScheme.equalsIgnoreCase("NoPadding") == false) {
throw new NoSuchPaddingException("Padding must be NoPadding");
}
}
protected Key engineUnwrap(byte[] wrappedKey,
String wrappedKeyAlgorithm,
int wrappedKeyType)
throws InvalidKeyException, NoSuchAlgorithmException {
return cipher.engineUnwrap(wrappedKey, wrappedKeyAlgorithm,
wrappedKeyType);
}
protected byte[] engineUpdate(byte[] in, int inOff, int inLen) {
return cipher.engineUpdate(in, inOff, inLen);
}
protected int engineUpdate(byte[] in, int inOff, int inLen,
byte[] out, int outOff)
throws ShortBufferException {
return cipher.engineUpdate(in, inOff, inLen, out, outOff);
}
protected byte[] engineWrap(Key key)
throws IllegalBlockSizeException, InvalidKeyException {
return cipher.engineWrap(key);
}
}
} }
...@@ -77,10 +77,14 @@ public final class SunJCE extends Provider { ...@@ -77,10 +77,14 @@ public final class SunJCE extends Provider {
"(implements RSA, DES, Triple DES, AES, Blowfish, ARCFOUR, RC2, PBE, " "(implements RSA, DES, Triple DES, AES, Blowfish, ARCFOUR, RC2, PBE, "
+ "Diffie-Hellman, HMAC)"; + "Diffie-Hellman, HMAC)";
private static final String OID_PKCS12_RC2_40 = "1.2.840.113549.1.12.1.6"; private static final String OID_PKCS12_RC4_128 = "1.2.840.113549.1.12.1.1";
private static final String OID_PKCS12_RC4_40 = "1.2.840.113549.1.12.1.2";
private static final String OID_PKCS12_DESede = "1.2.840.113549.1.12.1.3"; private static final String OID_PKCS12_DESede = "1.2.840.113549.1.12.1.3";
private static final String OID_PKCS12_RC2_128 = "1.2.840.113549.1.12.1.5";
private static final String OID_PKCS12_RC2_40 = "1.2.840.113549.1.12.1.6";
private static final String OID_PKCS5_MD5_DES = "1.2.840.113549.1.5.3"; private static final String OID_PKCS5_MD5_DES = "1.2.840.113549.1.5.3";
private static final String OID_PKCS5_PBKDF2 = "1.2.840.113549.1.5.12"; private static final String OID_PKCS5_PBKDF2 = "1.2.840.113549.1.5.12";
private static final String OID_PKCS5_PBES2 = "1.2.840.113549.1.5.13";
private static final String OID_PKCS3 = "1.2.840.113549.1.3.1"; private static final String OID_PKCS3 = "1.2.840.113549.1.3.1";
/* Are we debugging? -- for developers */ /* Are we debugging? -- for developers */
...@@ -138,14 +142,26 @@ public final class SunJCE extends Provider { ...@@ -138,14 +142,26 @@ public final class SunJCE extends Provider {
put("Cipher.DESedeWrap SupportedPaddings", "NOPADDING"); put("Cipher.DESedeWrap SupportedPaddings", "NOPADDING");
put("Cipher.DESedeWrap SupportedKeyFormats", "RAW"); put("Cipher.DESedeWrap SupportedKeyFormats", "RAW");
// PBES1
put("Cipher.PBEWithMD5AndDES", put("Cipher.PBEWithMD5AndDES",
"com.sun.crypto.provider.PBEWithMD5AndDESCipher"); "com.sun.crypto.provider.PBEWithMD5AndDESCipher");
put("Alg.Alias.Cipher.OID."+OID_PKCS5_MD5_DES, put("Alg.Alias.Cipher.OID."+OID_PKCS5_MD5_DES,
"PBEWithMD5AndDES"); "PBEWithMD5AndDES");
put("Alg.Alias.Cipher."+OID_PKCS5_MD5_DES, put("Alg.Alias.Cipher."+OID_PKCS5_MD5_DES,
"PBEWithMD5AndDES"); "PBEWithMD5AndDES");
put("Cipher.PBEWithMD5AndTripleDES", put("Cipher.PBEWithMD5AndTripleDES",
"com.sun.crypto.provider.PBEWithMD5AndTripleDESCipher"); "com.sun.crypto.provider.PBEWithMD5AndTripleDESCipher");
put("Cipher.PBEWithSHA1AndDESede",
"com.sun.crypto.provider.PKCS12PBECipherCore$" +
"PBEWithSHA1AndDESede");
put("Alg.Alias.Cipher.OID." + OID_PKCS12_DESede,
"PBEWithSHA1AndDESede");
put("Alg.Alias.Cipher." + OID_PKCS12_DESede,
"PBEWithSHA1AndDESede");
put("Cipher.PBEWithSHA1AndRC2_40", put("Cipher.PBEWithSHA1AndRC2_40",
"com.sun.crypto.provider.PKCS12PBECipherCore$" + "com.sun.crypto.provider.PKCS12PBECipherCore$" +
"PBEWithSHA1AndRC2_40"); "PBEWithSHA1AndRC2_40");
...@@ -153,13 +169,70 @@ public final class SunJCE extends Provider { ...@@ -153,13 +169,70 @@ public final class SunJCE extends Provider {
"PBEWithSHA1AndRC2_40"); "PBEWithSHA1AndRC2_40");
put("Alg.Alias.Cipher." + OID_PKCS12_RC2_40, put("Alg.Alias.Cipher." + OID_PKCS12_RC2_40,
"PBEWithSHA1AndRC2_40"); "PBEWithSHA1AndRC2_40");
put("Cipher.PBEWithSHA1AndDESede",
put("Cipher.PBEWithSHA1AndRC2_128",
"com.sun.crypto.provider.PKCS12PBECipherCore$" + "com.sun.crypto.provider.PKCS12PBECipherCore$" +
"PBEWithSHA1AndDESede"); "PBEWithSHA1AndRC2_128");
put("Alg.Alias.Cipher.OID." + OID_PKCS12_DESede, put("Alg.Alias.Cipher.OID." + OID_PKCS12_RC2_128,
"PBEWithSHA1AndDESede"); "PBEWithSHA1AndRC2_128");
put("Alg.Alias.Cipher." + OID_PKCS12_DESede, put("Alg.Alias.Cipher." + OID_PKCS12_RC2_128,
"PBEWithSHA1AndDESede"); "PBEWithSHA1AndRC2_128");
put("Cipher.PBEWithSHA1AndRC4_40",
"com.sun.crypto.provider.PKCS12PBECipherCore$" +
"PBEWithSHA1AndRC4_40");
put("Alg.Alias.Cipher.OID." + OID_PKCS12_RC4_40,
"PBEWithSHA1AndRC4_40");
put("Alg.Alias.Cipher." + OID_PKCS12_RC4_40,
"PBEWithSHA1AndRC4_40");
put("Cipher.PBEWithSHA1AndRC4_128",
"com.sun.crypto.provider.PKCS12PBECipherCore$" +
"PBEWithSHA1AndRC4_128");
put("Alg.Alias.Cipher.OID." + OID_PKCS12_RC4_128,
"PBEWithSHA1AndRC4_128");
put("Alg.Alias.Cipher." + OID_PKCS12_RC4_128,
"PBEWithSHA1AndRC4_128");
//PBES2
put("Cipher.PBEWithHmacSHA1AndAES_128",
"com.sun.crypto.provider.PBES2Core$HmacSHA1AndAES_128");
put("Cipher.PBEWithHmacSHA224AndAES_128",
"com.sun.crypto.provider.PBES2Core$" +
"HmacSHA224AndAES_128");
put("Cipher.PBEWithHmacSHA256AndAES_128",
"com.sun.crypto.provider.PBES2Core$" +
"HmacSHA256AndAES_128");
put("Cipher.PBEWithHmacSHA384AndAES_128",
"com.sun.crypto.provider.PBES2Core$" +
"HmacSHA384AndAES_128");
put("Cipher.PBEWithHmacSHA512AndAES_128",
"com.sun.crypto.provider.PBES2Core$" +
"HmacSHA512AndAES_128");
put("Cipher.PBEWithHmacSHA1AndAES_256",
"com.sun.crypto.provider.PBES2Core$HmacSHA1AndAES_256");
put("Cipher.PBEWithHmacSHA224AndAES_256",
"com.sun.crypto.provider.PBES2Core$" +
"HmacSHA224AndAES_256");
put("Cipher.PBEWithHmacSHA256AndAES_256",
"com.sun.crypto.provider.PBES2Core$" +
"HmacSHA256AndAES_256");
put("Cipher.PBEWithHmacSHA384AndAES_256",
"com.sun.crypto.provider.PBES2Core$" +
"HmacSHA384AndAES_256");
put("Cipher.PBEWithHmacSHA512AndAES_256",
"com.sun.crypto.provider.PBES2Core$" +
"HmacSHA512AndAES_256");
put("Cipher.Blowfish", put("Cipher.Blowfish",
"com.sun.crypto.provider.BlowfishCipher"); "com.sun.crypto.provider.BlowfishCipher");
...@@ -301,6 +374,7 @@ public final class SunJCE extends Provider { ...@@ -301,6 +374,7 @@ public final class SunJCE extends Provider {
"DiffieHellman"); "DiffieHellman");
put("Alg.Alias.KeyPairGenerator."+OID_PKCS3, put("Alg.Alias.KeyPairGenerator."+OID_PKCS3,
"DiffieHellman"); "DiffieHellman");
/* /*
* Algorithm parameter generation engines * Algorithm parameter generation engines
*/ */
...@@ -371,6 +445,64 @@ public final class SunJCE extends Provider { ...@@ -371,6 +445,64 @@ public final class SunJCE extends Provider {
put("Alg.Alias.AlgorithmParameters." + OID_PKCS12_RC2_40, put("Alg.Alias.AlgorithmParameters." + OID_PKCS12_RC2_40,
"PBEWithSHA1AndRC2_40"); "PBEWithSHA1AndRC2_40");
put("AlgorithmParameters.PBEWithSHA1AndRC2_128",
"com.sun.crypto.provider.PBEParameters");
put("Alg.Alias.AlgorithmParameters.OID."+OID_PKCS12_RC2_128,
"PBEWithSHA1AndRC2_128");
put("Alg.Alias.AlgorithmParameters." + OID_PKCS12_RC2_128,
"PBEWithSHA1AndRC2_128");
put("AlgorithmParameters.PBEWithSHA1AndRC4_40",
"com.sun.crypto.provider.PBEParameters");
put("Alg.Alias.AlgorithmParameters.OID."+OID_PKCS12_RC4_40,
"PBEWithSHA1AndRC4_40");
put("Alg.Alias.AlgorithmParameters." + OID_PKCS12_RC4_40,
"PBEWithSHA1AndRC4_40");
put("AlgorithmParameters.PBEWithSHA1AndRC4_128",
"com.sun.crypto.provider.PBEParameters");
put("Alg.Alias.AlgorithmParameters.OID."+OID_PKCS12_RC4_128,
"PBEWithSHA1AndRC4_128");
put("Alg.Alias.AlgorithmParameters." + OID_PKCS12_RC4_128,
"PBEWithSHA1AndRC4_128");
put("AlgorithmParameters.PBES2",
"com.sun.crypto.provider.PBES2Parameters$General");
put("Alg.Alias.AlgorithmParameters.OID."+OID_PKCS5_PBES2,
"PBES2");
put("Alg.Alias.AlgorithmParameters." + OID_PKCS5_PBES2,
"PBES2");
put("AlgorithmParameters.PBEWithHmacSHA1AndAES_128",
"com.sun.crypto.provider.PBES2Parameters$HmacSHA1AndAES_128");
put("AlgorithmParameters.PBEWithHmacSHA224AndAES_128",
"com.sun.crypto.provider.PBES2Parameters$HmacSHA224AndAES_128");
put("AlgorithmParameters.PBEWithHmacSHA256AndAES_128",
"com.sun.crypto.provider.PBES2Parameters$HmacSHA256AndAES_128");
put("AlgorithmParameters.PBEWithHmacSHA384AndAES_128",
"com.sun.crypto.provider.PBES2Parameters$HmacSHA384AndAES_128");
put("AlgorithmParameters.PBEWithHmacSHA512AndAES_128",
"com.sun.crypto.provider.PBES2Parameters$HmacSHA512AndAES_128");
put("AlgorithmParameters.PBEWithHmacSHA1AndAES_256",
"com.sun.crypto.provider.PBES2Parameters$HmacSHA1AndAES_256");
put("AlgorithmParameters.PBEWithHmacSHA224AndAES_256",
"com.sun.crypto.provider.PBES2Parameters$HmacSHA224AndAES_256");
put("AlgorithmParameters.PBEWithHmacSHA256AndAES_256",
"com.sun.crypto.provider.PBES2Parameters$HmacSHA256AndAES_256");
put("AlgorithmParameters.PBEWithHmacSHA384AndAES_256",
"com.sun.crypto.provider.PBES2Parameters$HmacSHA384AndAES_256");
put("AlgorithmParameters.PBEWithHmacSHA512AndAES_256",
"com.sun.crypto.provider.PBES2Parameters$HmacSHA512AndAES_256");
put("AlgorithmParameters.Blowfish", put("AlgorithmParameters.Blowfish",
"com.sun.crypto.provider.BlowfishParameters"); "com.sun.crypto.provider.BlowfishParameters");
...@@ -378,6 +510,7 @@ public final class SunJCE extends Provider { ...@@ -378,6 +510,7 @@ public final class SunJCE extends Provider {
"com.sun.crypto.provider.AESParameters"); "com.sun.crypto.provider.AESParameters");
put("Alg.Alias.AlgorithmParameters.Rijndael", "AES"); put("Alg.Alias.AlgorithmParameters.Rijndael", "AES");
put("AlgorithmParameters.RC2", put("AlgorithmParameters.RC2",
"com.sun.crypto.provider.RC2Parameters"); "com.sun.crypto.provider.RC2Parameters");
...@@ -393,6 +526,7 @@ public final class SunJCE extends Provider { ...@@ -393,6 +526,7 @@ public final class SunJCE extends Provider {
put("Alg.Alias.KeyFactory.OID."+OID_PKCS3, put("Alg.Alias.KeyFactory.OID."+OID_PKCS3,
"DiffieHellman"); "DiffieHellman");
put("Alg.Alias.KeyFactory."+OID_PKCS3, "DiffieHellman"); put("Alg.Alias.KeyFactory."+OID_PKCS3, "DiffieHellman");
/* /*
* Secret-key factories * Secret-key factories
*/ */
...@@ -441,13 +575,90 @@ public final class SunJCE extends Provider { ...@@ -441,13 +575,90 @@ public final class SunJCE extends Provider {
put("Alg.Alias.SecretKeyFactory." + OID_PKCS12_RC2_40, put("Alg.Alias.SecretKeyFactory." + OID_PKCS12_RC2_40,
"PBEWithSHA1AndRC2_40"); "PBEWithSHA1AndRC2_40");
put("SecretKeyFactory.PBEWithSHA1AndRC2_128",
"com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndRC2_128"
);
put("Alg.Alias.SecretKeyFactory.OID." + OID_PKCS12_RC2_128,
"PBEWithSHA1AndRC2_128");
put("Alg.Alias.SecretKeyFactory." + OID_PKCS12_RC2_128,
"PBEWithSHA1AndRC2_128");
put("SecretKeyFactory.PBEWithSHA1AndRC4_40",
"com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndRC4_40"
);
put("Alg.Alias.SecretKeyFactory.OID." + OID_PKCS12_RC4_40,
"PBEWithSHA1AndRC4_40");
put("Alg.Alias.SecretKeyFactory." + OID_PKCS12_RC4_40,
"PBEWithSHA1AndRC4_40");
put("SecretKeyFactory.PBEWithSHA1AndRC4_128",
"com.sun.crypto.provider.PBEKeyFactory$PBEWithSHA1AndRC4_128"
);
put("Alg.Alias.SecretKeyFactory.OID." + OID_PKCS12_RC4_128,
"PBEWithSHA1AndRC4_128");
put("Alg.Alias.SecretKeyFactory." + OID_PKCS12_RC4_128,
"PBEWithSHA1AndRC4_128");
put("SecretKeyFactory.PBEWithHmacSHA1AndAES_128",
"com.sun.crypto.provider.PBEKeyFactory$" +
"PBEWithHmacSHA1AndAES_128");
put("SecretKeyFactory.PBEWithHmacSHA224AndAES_128",
"com.sun.crypto.provider.PBEKeyFactory$" +
"PBEWithHmacSHA224AndAES_128");
put("SecretKeyFactory.PBEWithHmacSHA256AndAES_128",
"com.sun.crypto.provider.PBEKeyFactory$" +
"PBEWithHmacSHA256AndAES_128");
put("SecretKeyFactory.PBEWithHmacSHA384AndAES_128",
"com.sun.crypto.provider.PBEKeyFactory$" +
"PBEWithHmacSHA384AndAES_128");
put("SecretKeyFactory.PBEWithHmacSHA512AndAES_128",
"com.sun.crypto.provider.PBEKeyFactory$" +
"PBEWithHmacSHA512AndAES_128");
put("SecretKeyFactory.PBEWithHmacSHA1AndAES_256",
"com.sun.crypto.provider.PBEKeyFactory$" +
"PBEWithHmacSHA1AndAES_256");
put("SecretKeyFactory.PBEWithHmacSHA224AndAES_256",
"com.sun.crypto.provider.PBEKeyFactory$" +
"PBEWithHmacSHA224AndAES_256");
put("SecretKeyFactory.PBEWithHmacSHA256AndAES_256",
"com.sun.crypto.provider.PBEKeyFactory$" +
"PBEWithHmacSHA256AndAES_256");
put("SecretKeyFactory.PBEWithHmacSHA384AndAES_256",
"com.sun.crypto.provider.PBEKeyFactory$" +
"PBEWithHmacSHA384AndAES_256");
put("SecretKeyFactory.PBEWithHmacSHA512AndAES_256",
"com.sun.crypto.provider.PBEKeyFactory$" +
"PBEWithHmacSHA512AndAES_256");
// PBKDF2
put("SecretKeyFactory.PBKDF2WithHmacSHA1", put("SecretKeyFactory.PBKDF2WithHmacSHA1",
"com.sun.crypto.provider.PBKDF2HmacSHA1Factory"); "com.sun.crypto.provider.PBKDF2Core$HmacSHA1");
put("Alg.Alias.SecretKeyFactory.OID." + OID_PKCS5_PBKDF2, put("Alg.Alias.SecretKeyFactory.OID." + OID_PKCS5_PBKDF2,
"PBKDF2WithHmacSHA1"); "PBKDF2WithHmacSHA1");
put("Alg.Alias.SecretKeyFactory." + OID_PKCS5_PBKDF2, put("Alg.Alias.SecretKeyFactory." + OID_PKCS5_PBKDF2,
"PBKDF2WithHmacSHA1"); "PBKDF2WithHmacSHA1");
put("SecretKeyFactory.PBKDF2WithHmacSHA224",
"com.sun.crypto.provider.PBKDF2Core$HmacSHA224");
put("SecretKeyFactory.PBKDF2WithHmacSHA256",
"com.sun.crypto.provider.PBKDF2Core$HmacSHA256");
put("SecretKeyFactory.PBKDF2WithHmacSHA384",
"com.sun.crypto.provider.PBKDF2Core$HmacSHA384");
put("SecretKeyFactory.PBKDF2WithHmacSHA512",
"com.sun.crypto.provider.PBKDF2Core$HmacSHA512");
/* /*
* MAC * MAC
*/ */
...@@ -475,6 +686,19 @@ public final class SunJCE extends Provider { ...@@ -475,6 +686,19 @@ public final class SunJCE extends Provider {
put("Mac.HmacPBESHA1", put("Mac.HmacPBESHA1",
"com.sun.crypto.provider.HmacPKCS12PBESHA1"); "com.sun.crypto.provider.HmacPKCS12PBESHA1");
// PBMAC1
put("Mac.PBEWithHmacSHA1",
"com.sun.crypto.provider.PBMAC1Core$HmacSHA1");
put("Mac.PBEWithHmacSHA224",
"com.sun.crypto.provider.PBMAC1Core$HmacSHA224");
put("Mac.PBEWithHmacSHA256",
"com.sun.crypto.provider.PBMAC1Core$HmacSHA256");
put("Mac.PBEWithHmacSHA384",
"com.sun.crypto.provider.PBMAC1Core$HmacSHA384");
put("Mac.PBEWithHmacSHA512",
"com.sun.crypto.provider.PBMAC1Core$HmacSHA512");
put("Mac.SslMacMD5", put("Mac.SslMacMD5",
"com.sun.crypto.provider.SslMacCore$SslMacMD5"); "com.sun.crypto.provider.SslMacCore$SslMacMD5");
put("Mac.SslMacSHA1", put("Mac.SslMacSHA1",
...@@ -487,6 +711,10 @@ public final class SunJCE extends Provider { ...@@ -487,6 +711,10 @@ public final class SunJCE extends Provider {
put("Mac.HmacSHA384 SupportedKeyFormats", "RAW"); put("Mac.HmacSHA384 SupportedKeyFormats", "RAW");
put("Mac.HmacSHA512 SupportedKeyFormats", "RAW"); put("Mac.HmacSHA512 SupportedKeyFormats", "RAW");
put("Mac.HmacPBESHA1 SupportedKeyFormats", "RAW"); put("Mac.HmacPBESHA1 SupportedKeyFormats", "RAW");
put("Mac.HmacPBESHA224 SupportedKeyFormats", "RAW");
put("Mac.HmacPBESHA256 SupportedKeyFormats", "RAW");
put("Mac.HmacPBESHA384 SupportedKeyFormats", "RAW");
put("Mac.HmacPBESHA512 SupportedKeyFormats", "RAW");
put("Mac.SslMacMD5 SupportedKeyFormats", "RAW"); put("Mac.SslMacMD5 SupportedKeyFormats", "RAW");
put("Mac.SslMacSHA1 SupportedKeyFormats", "RAW"); put("Mac.SslMacSHA1 SupportedKeyFormats", "RAW");
......
...@@ -59,6 +59,9 @@ class Constants { ...@@ -59,6 +59,9 @@ class Constants {
public final static Package.Version JAVA7_MAX_CLASS_VERSION = public final static Package.Version JAVA7_MAX_CLASS_VERSION =
Package.Version.of(51, 00); Package.Version.of(51, 00);
public final static Package.Version JAVA8_MAX_CLASS_VERSION =
Package.Version.of(52, 00);
public final static int JAVA_PACKAGE_MAGIC = 0xCAFED00D; public final static int JAVA_PACKAGE_MAGIC = 0xCAFED00D;
public final static Package.Version JAVA5_PACKAGE_VERSION = public final static Package.Version JAVA5_PACKAGE_VERSION =
...@@ -72,7 +75,7 @@ class Constants { ...@@ -72,7 +75,7 @@ class Constants {
// upper limit, should point to the latest class version // upper limit, should point to the latest class version
public final static Package.Version JAVA_MAX_CLASS_VERSION = public final static Package.Version JAVA_MAX_CLASS_VERSION =
JAVA7_MAX_CLASS_VERSION; JAVA8_MAX_CLASS_VERSION;
// upper limit should point to the latest package version, for version info!. // upper limit should point to the latest package version, for version info!.
public final static Package.Version MAX_PACKAGE_VERSION = public final static Package.Version MAX_PACKAGE_VERSION =
......
...@@ -542,9 +542,15 @@ public final class ResourceManager { ...@@ -542,9 +542,15 @@ public final class ResourceManager {
try { try {
NamingEnumeration<InputStream> resources = NamingEnumeration<InputStream> resources =
helper.getResources(cl, APP_RESOURCE_FILE_NAME); helper.getResources(cl, APP_RESOURCE_FILE_NAME);
try {
while (resources.hasMore()) { while (resources.hasMore()) {
Properties props = new Properties(); Properties props = new Properties();
props.load(resources.next()); InputStream istream = resources.next();
try {
props.load(istream);
} finally {
istream.close();
}
if (result == null) { if (result == null) {
result = props; result = props;
...@@ -552,11 +558,18 @@ public final class ResourceManager { ...@@ -552,11 +558,18 @@ public final class ResourceManager {
mergeTables(result, props); mergeTables(result, props);
} }
} }
} finally {
while (resources.hasMore()) {
InputStream istream = (InputStream)resources.next();
istream.close();
}
}
// Merge in properties from file in <java.home>/lib. // Merge in properties from file in <java.home>/lib.
InputStream istream = InputStream istream =
helper.getJavaHomeLibStream(JRELIB_PROPERTY_FILE_NAME); helper.getJavaHomeLibStream(JRELIB_PROPERTY_FILE_NAME);
if (istream != null) { if (istream != null) {
try {
Properties props = new Properties(); Properties props = new Properties();
props.load(istream); props.load(istream);
...@@ -565,6 +578,9 @@ public final class ResourceManager { ...@@ -565,6 +578,9 @@ public final class ResourceManager {
} else { } else {
mergeTables(result, props); mergeTables(result, props);
} }
} finally {
istream.close();
}
} }
} catch (IOException e) { } catch (IOException e) {
......
/*
* Copyright (c) 2012, Oracle and/or its affiliates. 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. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.sun.security.jgss;
import org.ietf.jgss.*;
/**
* The extended GSSCredential interface for supporting additional
* functionalities not defined by {@code org.ietf.jgss.GSSCredential}.
* @since 1.8
*/
public interface ExtendedGSSCredential extends GSSCredential {
/**
* Impersonates a principal. In Kerberos, this can be implemented
* using the Microsoft S4U2self extension.
* <p>
* A {@link GSSException#NO_CRED GSSException.NO_CRED} will be thrown if the
* impersonation fails. A {@link GSSException#FAILURE GSSException.FAILURE}
* will be thrown if the impersonation method is not available to this
* credential object.
* @param name the name of the principal to impersonate
* @return a credential for that principal
* @throws GSSException containing the following
* major error codes:
* {@link GSSException#NO_CRED GSSException.NO_CRED}
* {@link GSSException#FAILURE GSSException.FAILURE}
*/
public GSSCredential impersonate(GSSName name) throws GSSException;
}
...@@ -40,7 +40,7 @@ import java.util.Locale; ...@@ -40,7 +40,7 @@ import java.util.Locale;
* a character's category (lowercase letter, digit, etc.) and for converting * a character's category (lowercase letter, digit, etc.) and for converting
* characters from uppercase to lowercase and vice versa. * characters from uppercase to lowercase and vice versa.
* <p> * <p>
* Character information is based on the Unicode Standard, version 6.1.0. * Character information is based on the Unicode Standard, version 6.2.0.
* <p> * <p>
* The methods and data of class {@code Character} are defined by * The methods and data of class {@code Character} are defined by
* the information in the <i>UnicodeData</i> file that is part of the * the information in the <i>UnicodeData</i> file that is part of the
...@@ -3758,8 +3758,7 @@ class Character implements java.io.Serializable, Comparable<Character> { ...@@ -3758,8 +3758,7 @@ class Character implements java.io.Serializable, Comparable<Character> {
0x0640, // 0640..0640; COMMON 0x0640, // 0640..0640; COMMON
0x0641, // 0641..064A; ARABIC 0x0641, // 0641..064A; ARABIC
0x064B, // 064B..0655; INHERITED 0x064B, // 064B..0655; INHERITED
0x0656, // 0656..065E; ARABIC 0x0656, // 0656..065F; ARABIC
0x065F, // 065F..065F; INHERITED
0x0660, // 0660..0669; COMMON 0x0660, // 0660..0669; COMMON
0x066A, // 066A..066F; ARABIC 0x066A, // 066A..066F; ARABIC
0x0670, // 0670..0670; INHERITED 0x0670, // 0670..0670; INHERITED
...@@ -4081,7 +4080,6 @@ class Character implements java.io.Serializable, Comparable<Character> { ...@@ -4081,7 +4080,6 @@ class Character implements java.io.Serializable, Comparable<Character> {
ARABIC, ARABIC,
INHERITED, INHERITED,
ARABIC, ARABIC,
INHERITED,
COMMON, COMMON,
ARABIC, ARABIC,
INHERITED, INHERITED,
......
...@@ -742,6 +742,7 @@ public final class Math { ...@@ -742,6 +742,7 @@ public final class Math {
* @param y the second value * @param y the second value
* @return the result * @return the result
* @throws ArithmeticException if the result overflows an int * @throws ArithmeticException if the result overflows an int
* @since 1.8
*/ */
public static int addExact(int x, int y) { public static int addExact(int x, int y) {
int r = x + y; int r = x + y;
...@@ -760,6 +761,7 @@ public final class Math { ...@@ -760,6 +761,7 @@ public final class Math {
* @param y the second value * @param y the second value
* @return the result * @return the result
* @throws ArithmeticException if the result overflows a long * @throws ArithmeticException if the result overflows a long
* @since 1.8
*/ */
public static long addExact(long x, long y) { public static long addExact(long x, long y) {
long r = x + y; long r = x + y;
...@@ -778,6 +780,7 @@ public final class Math { ...@@ -778,6 +780,7 @@ public final class Math {
* @param y the second value to subtract from the first * @param y the second value to subtract from the first
* @return the result * @return the result
* @throws ArithmeticException if the result overflows an int * @throws ArithmeticException if the result overflows an int
* @since 1.8
*/ */
public static int subtractExact(int x, int y) { public static int subtractExact(int x, int y) {
int r = x - y; int r = x - y;
...@@ -797,6 +800,7 @@ public final class Math { ...@@ -797,6 +800,7 @@ public final class Math {
* @param y the second value to subtract from the first * @param y the second value to subtract from the first
* @return the result * @return the result
* @throws ArithmeticException if the result overflows a long * @throws ArithmeticException if the result overflows a long
* @since 1.8
*/ */
public static long subtractExact(long x, long y) { public static long subtractExact(long x, long y) {
long r = x - y; long r = x - y;
...@@ -816,6 +820,7 @@ public final class Math { ...@@ -816,6 +820,7 @@ public final class Math {
* @param y the second value * @param y the second value
* @return the result * @return the result
* @throws ArithmeticException if the result overflows an int * @throws ArithmeticException if the result overflows an int
* @since 1.8
*/ */
public static int multiplyExact(int x, int y) { public static int multiplyExact(int x, int y) {
long r = (long)x * (long)y; long r = (long)x * (long)y;
...@@ -833,6 +838,7 @@ public final class Math { ...@@ -833,6 +838,7 @@ public final class Math {
* @param y the second value * @param y the second value
* @return the result * @return the result
* @throws ArithmeticException if the result overflows a long * @throws ArithmeticException if the result overflows a long
* @since 1.8
*/ */
public static long multiplyExact(long x, long y) { public static long multiplyExact(long x, long y) {
long r = x * y; long r = x * y;
...@@ -857,6 +863,7 @@ public final class Math { ...@@ -857,6 +863,7 @@ public final class Math {
* @param value the long value * @param value the long value
* @return the argument as an int * @return the argument as an int
* @throws ArithmeticException if the {@code argument} overflows an int * @throws ArithmeticException if the {@code argument} overflows an int
* @since 1.8
*/ */
public static int toIntExact(long value) { public static int toIntExact(long value) {
if ((int)value != value) { if ((int)value != value) {
...@@ -865,6 +872,159 @@ public final class Math { ...@@ -865,6 +872,159 @@ public final class Math {
return (int)value; return (int)value;
} }
/**
* Returns the largest (closest to positive infinity)
* {@code int} value that is less than or equal to the algebraic quotient.
* There is one special case, if the dividend is the
* {@linkplain Integer#MIN_VALUE Integer.MIN_VALUE} and the divisor is {@code -1},
* then integer overflow occurs and
* the result is equal to the {@code Integer.MIN_VALUE}.
* <p>
* Normal integer division operates under the round to zero rounding mode
* (truncation). This operation instead acts under the round toward
* negative infinity (floor) rounding mode.
* The floor rounding mode gives different results than truncation
* when the exact result is negative.
* <ul>
* <li>If the signs of the arguments are the same, the results of
* {@code floorDiv} and the {@code /} operator are the same. <br>
* For example, {@code floorDiv(4, 3) == 1} and {@code (4 / 3) == 1}.</li>
* <li>If the signs of the arguments are different, the quotient is negative and
* {@code floorDiv} returns the integer less than or equal to the quotient
* and the {@code /} operator returns the integer closest to zero.<br>
* For example, {@code floorDiv(-4, 3) == -2},
* whereas {@code (-4 / 3) == -1}.
* </li>
* </ul>
* <p>
*
* @param x the dividend
* @param y the divisor
* @return the largest (closest to positive infinity)
* {@code int} value that is less than or equal to the algebraic quotient.
* @throws ArithmeticException if the divisor {@code y} is zero
* @see #floorMod(int, int)
* @see #floor(double)
* @since 1.8
*/
public static int floorDiv(int x, int y) {
int r = x / y;
// if the signs are different and modulo not zero, round down
if ((x ^ y) < 0 && (r * y != x)) {
r--;
}
return r;
}
/**
* Returns the largest (closest to positive infinity)
* {@code long} value that is less than or equal to the algebraic quotient.
* There is one special case, if the dividend is the
* {@linkplain Long#MIN_VALUE Long.MIN_VALUE} and the divisor is {@code -1},
* then integer overflow occurs and
* the result is equal to the {@code Long.MIN_VALUE}.
* <p>
* Normal integer division operates under the round to zero rounding mode
* (truncation). This operation instead acts under the round toward
* negative infinity (floor) rounding mode.
* The floor rounding mode gives different results than truncation
* when the exact result is negative.
* <p>
* For examples, see {@link #floorDiv(int, int)}.
*
* @param x the dividend
* @param y the divisor
* @return the largest (closest to positive infinity)
* {@code long} value that is less than or equal to the algebraic quotient.
* @throws ArithmeticException if the divisor {@code y} is zero
* @see #floorMod(long, long)
* @see #floor(double)
* @since 1.8
*/
public static long floorDiv(long x, long y) {
long r = x / y;
// if the signs are different and modulo not zero, round down
if ((x ^ y) < 0 && (r * y != x)) {
r--;
}
return r;
}
/**
* Returns the floor modulus of the {@code int} arguments.
* <p>
* The floor modulus is {@code x - (floorDiv(x, y) * y)},
* has the same sign as the divisor {@code y}, and
* is in the range of {@code -abs(y) < r < +abs(y)}.
*
* <p>
* The relationship between {@code floorDiv} and {@code floorMod} is such that:
* <ul>
* <li>{@code floorDiv(x, y) * y + floorMod(x, y) == x}
* </ul>
* <p>
* The difference in values between {@code floorMod} and
* the {@code %} operator is due to the difference between
* {@code floorDiv} that returns the integer less than or equal to the quotient
* and the {@code /} operator that returns the integer closest to zero.
* <p>
* Examples:
* <ul>
* <li>If the signs of the arguments are the same, the results
* of {@code floorMod} and the {@code %} operator are the same. <br>
* <ul>
* <li>{@code floorMod(4, 3) == 1}; &nbsp; and {@code (4 % 3) == 1}</li>
* </ul>
* <li>If the signs of the arguments are different, the results differ from the {@code %} operator.<br>
* <ul>
* <li>{@code floorMod(+4, -3) == -2}; &nbsp; and {@code (+4 % -3) == +1} </li>
* <li>{@code floorMod(-4, +3) == +2}; &nbsp; and {@code (-4 % +3) == -1} </li>
* <li>{@code floorMod(-4, -3) == -1}; &nbsp; and {@code (-4 % -3) == -1 } </li>
* </ul>
* </li>
* </ul>
* <p>
* If the signs of arguments are unknown and a positive modulus
* is needed it can be computed as {@code (floorMod(x, y) + abs(y)) % abs(y)}.
*
* @param x the dividend
* @param y the divisor
* @return the floor modulus {@code x - (floorDiv(x, y) * y)}
* @throws ArithmeticException if the divisor {@code y} is zero
* @see #floorDiv(int, int)
* @since 1.8
*/
public static int floorMod(int x, int y) {
int r = x - floorDiv(x, y) * y;
return r;
}
/**
* Returns the floor modulus of the {@code long} arguments.
* <p>
* The floor modulus is {@code x - (floorDiv(x, y) * y)},
* has the same sign as the divisor {@code y}, and
* is in the range of {@code -abs(y) < r < +abs(y)}.
*
* <p>
* The relationship between {@code floorDiv} and {@code floorMod} is such that:
* <ul>
* <li>{@code floorDiv(x, y) * y + floorMod(x, y) == x}
* </ul>
* <p>
* For examples, see {@link #floorMod(int, int)}.
*
* @param x the dividend
* @param y the divisor
* @return the floor modulus {@code x - (floorDiv(x, y) * y)}
* @throws ArithmeticException if the divisor {@code y} is zero
* @see #floorDiv(long, long)
* @since 1.8
*/
public static long floorMod(long x, long y) {
return x - floorDiv(x, y) * y;
}
/** /**
* Returns the absolute value of an {@code int} value. * Returns the absolute value of an {@code int} value.
* If the argument is not negative, the argument is returned. * If the argument is not negative, the argument is returned.
......
...@@ -365,7 +365,7 @@ public final class StrictMath { ...@@ -365,7 +365,7 @@ public final class StrictMath {
* @param a the value to be floored or ceiled * @param a the value to be floored or ceiled
* @param negativeBoundary result for values in (-1, 0) * @param negativeBoundary result for values in (-1, 0)
* @param positiveBoundary result for values in (0, 1) * @param positiveBoundary result for values in (0, 1)
* @param sign the sign of the result * @param increment value to add when the argument is non-integral
*/ */
private static double floorOrCeil(double a, private static double floorOrCeil(double a,
double negativeBoundary, double negativeBoundary,
...@@ -702,7 +702,7 @@ public final class StrictMath { ...@@ -702,7 +702,7 @@ public final class StrictMath {
* <p>This method is properly synchronized to allow correct use by * <p>This method is properly synchronized to allow correct use by
* more than one thread. However, if many threads need to generate * more than one thread. However, if many threads need to generate
* pseudorandom numbers at a great rate, it may reduce contention * pseudorandom numbers at a great rate, it may reduce contention
* for each thread to have its own pseudorandom number generator. * for each thread to have its own pseudorandom-number generator.
* *
* @return a pseudorandom {@code double} greater than or equal * @return a pseudorandom {@code double} greater than or equal
* to {@code 0.0} and less than {@code 1.0}. * to {@code 0.0} and less than {@code 1.0}.
...@@ -745,7 +745,7 @@ public final class StrictMath { ...@@ -745,7 +745,7 @@ public final class StrictMath {
} }
/** /**
* Return the difference of the arguments, * Returns the difference of the arguments,
* throwing an exception if the result overflows an {@code int}. * throwing an exception if the result overflows an {@code int}.
* *
* @param x the first value * @param x the first value
...@@ -760,7 +760,7 @@ public final class StrictMath { ...@@ -760,7 +760,7 @@ public final class StrictMath {
} }
/** /**
* Return the difference of the arguments, * Returns the difference of the arguments,
* throwing an exception if the result overflows a {@code long}. * throwing an exception if the result overflows a {@code long}.
* *
* @param x the first value * @param x the first value
...@@ -775,7 +775,7 @@ public final class StrictMath { ...@@ -775,7 +775,7 @@ public final class StrictMath {
} }
/** /**
* Return the product of the arguments, * Returns the product of the arguments,
* throwing an exception if the result overflows an {@code int}. * throwing an exception if the result overflows an {@code int}.
* *
* @param x the first value * @param x the first value
...@@ -790,7 +790,7 @@ public final class StrictMath { ...@@ -790,7 +790,7 @@ public final class StrictMath {
} }
/** /**
* Return the product of the arguments, * Returns the product of the arguments,
* throwing an exception if the result overflows a {@code long}. * throwing an exception if the result overflows a {@code long}.
* *
* @param x the first value * @param x the first value
...@@ -805,7 +805,7 @@ public final class StrictMath { ...@@ -805,7 +805,7 @@ public final class StrictMath {
} }
/** /**
* Return the value of the {@code long} argument; * Returns the value of the {@code long} argument;
* throwing an exception if the value overflows an {@code int}. * throwing an exception if the value overflows an {@code int}.
* *
* @param value the long value * @param value the long value
...@@ -818,6 +818,107 @@ public final class StrictMath { ...@@ -818,6 +818,107 @@ public final class StrictMath {
return Math.toIntExact(value); return Math.toIntExact(value);
} }
/**
* Returns the largest (closest to positive infinity)
* {@code int} value that is less than or equal to the algebraic quotient.
* There is one special case, if the dividend is the
* {@linkplain Integer#MIN_VALUE Integer.MIN_VALUE} and the divisor is {@code -1},
* then integer overflow occurs and
* the result is equal to the {@code Integer.MIN_VALUE}.
* <p>
* See {@link Math#floorDiv(int, int) Math.floorDiv} for examples and
* a comparison to the integer division {@code /} operator.
*
* @param x the dividend
* @param y the divisor
* @return the largest (closest to positive infinity)
* {@code int} value that is less than or equal to the algebraic quotient.
* @throws ArithmeticException if the divisor {@code y} is zero
* @see Math#floorDiv(int, int)
* @see Math#floor(double)
* @since 1.8
*/
public static int floorDiv(int x, int y) {
return Math.floorDiv(x, y);
}
/**
* Returns the largest (closest to positive infinity)
* {@code long} value that is less than or equal to the algebraic quotient.
* There is one special case, if the dividend is the
* {@linkplain Long#MIN_VALUE Long.MIN_VALUE} and the divisor is {@code -1},
* then integer overflow occurs and
* the result is equal to the {@code Long.MIN_VALUE}.
* <p>
* See {@link Math#floorDiv(int, int) Math.floorDiv} for examples and
* a comparison to the integer division {@code /} operator.
*
* @param x the dividend
* @param y the divisor
* @return the largest (closest to positive infinity)
* {@code long} value that is less than or equal to the algebraic quotient.
* @throws ArithmeticException if the divisor {@code y} is zero
* @see Math#floorDiv(long, long)
* @see Math#floor(double)
* @since 1.8
*/
public static long floorDiv(long x, long y) {
return Math.floorDiv(x, y);
}
/**
* Returns the floor modulus of the {@code int} arguments.
* <p>
* The floor modulus is {@code x - (floorDiv(x, y) * y)},
* has the same sign as the divisor {@code y}, and
* is in the range of {@code -abs(y) < r < +abs(y)}.
* <p>
* The relationship between {@code floorDiv} and {@code floorMod} is such that:
* <ul>
* <li>{@code floorDiv(x, y) * y + floorMod(x, y) == x}
* </ul>
* <p>
* See {@link Math#floorMod(int, int) Math.floorMod} for examples and
* a comparison to the {@code %} operator.
*
* @param x the dividend
* @param y the divisor
* @return the floor modulus {@code x - (floorDiv(x, y) * y)}
* @throws ArithmeticException if the divisor {@code y} is zero
* @see Math#floorMod(int, int)
* @see StrictMath#floorDiv(int, int)
* @since 1.8
*/
public static int floorMod(int x, int y) {
return Math.floorMod(x , y);
}
/**
* Returns the floor modulus of the {@code long} arguments.
* <p>
* The floor modulus is {@code x - (floorDiv(x, y) * y)},
* has the same sign as the divisor {@code y}, and
* is in the range of {@code -abs(y) < r < +abs(y)}.
* <p>
* The relationship between {@code floorDiv} and {@code floorMod} is such that:
* <ul>
* <li>{@code floorDiv(x, y) * y + floorMod(x, y) == x}
* </ul>
* <p>
* See {@link Math#floorMod(int, int) Math.floorMod} for examples and
* a comparison to the {@code %} operator.
*
* @param x the dividend
* @param y the divisor
* @return the floor modulus {@code x - (floorDiv(x, y) * y)}
* @throws ArithmeticException if the divisor {@code y} is zero
* @see Math#floorMod(long, long)
* @see StrictMath#floorDiv(long, long)
* @since 1.8
*/
public static long floorMod(long x, long y) {
return Math.floorMod(x, y);
}
/** /**
* Returns the absolute value of an {@code int} value. * Returns the absolute value of an {@code int} value.
* If the argument is not negative, the argument is returned. * If the argument is not negative, the argument is returned.
...@@ -1543,7 +1644,7 @@ public final class StrictMath { ...@@ -1543,7 +1644,7 @@ public final class StrictMath {
} }
/** /**
* Return {@code d} &times; * Returns {@code d} &times;
* 2<sup>{@code scaleFactor}</sup> rounded as if performed * 2<sup>{@code scaleFactor}</sup> rounded as if performed
* by a single correctly rounded floating-point multiply to a * by a single correctly rounded floating-point multiply to a
* member of the double value set. See the Java * member of the double value set. See the Java
...@@ -1577,7 +1678,7 @@ public final class StrictMath { ...@@ -1577,7 +1678,7 @@ public final class StrictMath {
} }
/** /**
* Return {@code f} &times; * Returns {@code f} &times;
* 2<sup>{@code scaleFactor}</sup> rounded as if performed * 2<sup>{@code scaleFactor}</sup> rounded as if performed
* by a single correctly rounded floating-point multiply to a * by a single correctly rounded floating-point multiply to a
* member of the float value set. See the Java * member of the float value set. See the Java
......
/* /*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -46,7 +46,7 @@ public enum ElementType { ...@@ -46,7 +46,7 @@ public enum ElementType {
/** Method declaration */ /** Method declaration */
METHOD, METHOD,
/** Parameter declaration */ /** Formal parameter declaration */
PARAMETER, PARAMETER,
/** Constructor declaration */ /** Constructor declaration */
...@@ -59,5 +59,19 @@ public enum ElementType { ...@@ -59,5 +59,19 @@ public enum ElementType {
ANNOTATION_TYPE, ANNOTATION_TYPE,
/** Package declaration */ /** Package declaration */
PACKAGE PACKAGE,
/**
* Type parameter declaration
*
* @since 1.8
*/
TYPE_PARAMETER,
/**
* Use of a type
*
* @since 1.8
*/
TYPE_USE
} }
...@@ -315,12 +315,14 @@ public class CertPathBuilder { ...@@ -315,12 +315,14 @@ public class CertPathBuilder {
* Returns a {@code CertPathChecker} that the encapsulated * Returns a {@code CertPathChecker} that the encapsulated
* {@code CertPathBuilderSpi} implementation uses to check the revocation * {@code CertPathBuilderSpi} implementation uses to check the revocation
* status of certificates. A PKIX implementation returns objects of * status of certificates. A PKIX implementation returns objects of
* type {@code PKIXRevocationChecker}. * type {@code PKIXRevocationChecker}. Each invocation of this method
* returns a new instance of {@code CertPathChecker}.
* *
* <p>The primary purpose of this method is to allow callers to specify * <p>The primary purpose of this method is to allow callers to specify
* additional input parameters and options specific to revocation checking. * additional input parameters and options specific to revocation checking.
* See the class description for an example. * See the class description for an example.
* *
* @return a {@code CertPathChecker}
* @throws UnsupportedOperationException if the service provider does not * @throws UnsupportedOperationException if the service provider does not
* support this method * support this method
* @since 1.8 * @since 1.8
......
...@@ -327,12 +327,14 @@ public class CertPathValidator { ...@@ -327,12 +327,14 @@ public class CertPathValidator {
* Returns a {@code CertPathChecker} that the encapsulated * Returns a {@code CertPathChecker} that the encapsulated
* {@code CertPathValidatorSpi} implementation uses to check the revocation * {@code CertPathValidatorSpi} implementation uses to check the revocation
* status of certificates. A PKIX implementation returns objects of * status of certificates. A PKIX implementation returns objects of
* type {@code PKIXRevocationChecker}. * type {@code PKIXRevocationChecker}. Each invocation of this method
* returns a new instance of {@code CertPathChecker}.
* *
* <p>The primary purpose of this method is to allow callers to specify * <p>The primary purpose of this method is to allow callers to specify
* additional input parameters and options specific to revocation checking. * additional input parameters and options specific to revocation checking.
* See the class description for an example. * See the class description for an example.
* *
* @return a {@code CertPathChecker}
* @throws UnsupportedOperationException if the service provider does not * @throws UnsupportedOperationException if the service provider does not
* support this method * support this method
* @since 1.8 * @since 1.8
......
...@@ -63,8 +63,8 @@ import java.util.Set; ...@@ -63,8 +63,8 @@ import java.util.Set;
* and then the {@code PKIXParameters} is passed along with the {@code CertPath} * and then the {@code PKIXParameters} is passed along with the {@code CertPath}
* to be validated to the {@link CertPathValidator#validate validate} method * to be validated to the {@link CertPathValidator#validate validate} method
* of a PKIX {@code CertPathValidator}. When supplying a revocation checker in * of a PKIX {@code CertPathValidator}. When supplying a revocation checker in
* this manner, do not enable the default revocation checking mechanism (by * this manner, it will be used to check revocation irrespective of the setting
* calling {@link PKIXParameters#setRevocationEnabled}. * of the {@link PKIXParameters#isRevocationEnabled RevocationEnabled} flag.
* *
* <p>Note that when a {@code PKIXRevocationChecker} is added to * <p>Note that when a {@code PKIXRevocationChecker} is added to
* {@code PKIXParameters}, it clones the {@code PKIXRevocationChecker}; * {@code PKIXParameters}, it clones the {@code PKIXRevocationChecker};
...@@ -88,7 +88,7 @@ public abstract class PKIXRevocationChecker extends PKIXCertPathChecker { ...@@ -88,7 +88,7 @@ public abstract class PKIXRevocationChecker extends PKIXCertPathChecker {
private URI ocspResponder; private URI ocspResponder;
private X509Certificate ocspResponderCert; private X509Certificate ocspResponderCert;
private List<Extension> ocspExtensions = Collections.<Extension>emptyList(); private List<Extension> ocspExtensions = Collections.<Extension>emptyList();
private Map<X509Certificate, byte[]> ocspStapled = Collections.emptyMap(); private Map<X509Certificate, byte[]> ocspResponses = Collections.emptyMap();
private Set<Option> options = Collections.emptySet(); private Set<Option> options = Collections.emptySet();
protected PKIXRevocationChecker() {} protected PKIXRevocationChecker() {}
...@@ -169,40 +169,40 @@ public abstract class PKIXRevocationChecker extends PKIXCertPathChecker { ...@@ -169,40 +169,40 @@ public abstract class PKIXRevocationChecker extends PKIXCertPathChecker {
} }
/** /**
* Sets the stapled OCSP responses. These responses are used to determine * Sets the OCSP responses. These responses are used to determine
* the revocation status of the specified certificates when OCSP is used. * the revocation status of the specified certificates when OCSP is used.
* *
* @param responses a map of stapled OCSP responses. Each key is an * @param responses a map of OCSP responses. Each key is an
* {@code X509Certificate} that maps to the corresponding * {@code X509Certificate} that maps to the corresponding
* DER-encoded OCSP response for that certificate. A deep copy of * DER-encoded OCSP response for that certificate. A deep copy of
* the map is performed to protect against subsequent modification. * the map is performed to protect against subsequent modification.
*/ */
public void setOCSPStapledResponses(Map<X509Certificate, byte[]> responses) public void setOCSPResponses(Map<X509Certificate, byte[]> responses)
{ {
if (responses == null) { if (responses == null) {
this.ocspStapled = Collections.<X509Certificate, byte[]>emptyMap(); this.ocspResponses = Collections.<X509Certificate, byte[]>emptyMap();
} else { } else {
Map<X509Certificate, byte[]> copy = new HashMap<>(responses.size()); Map<X509Certificate, byte[]> copy = new HashMap<>(responses.size());
for (Map.Entry<X509Certificate, byte[]> e : responses.entrySet()) { for (Map.Entry<X509Certificate, byte[]> e : responses.entrySet()) {
copy.put(e.getKey(), e.getValue().clone()); copy.put(e.getKey(), e.getValue().clone());
} }
this.ocspStapled = copy; this.ocspResponses = copy;
} }
} }
/** /**
* Gets the stapled OCSP responses. These responses are used to determine * Gets the OCSP responses. These responses are used to determine
* the revocation status of the specified certificates when OCSP is used. * the revocation status of the specified certificates when OCSP is used.
* *
* @return a map of stapled OCSP responses. Each key is an * @return a map of OCSP responses. Each key is an
* {@code X509Certificate} that maps to the corresponding * {@code X509Certificate} that maps to the corresponding
* DER-encoded OCSP response for that certificate. A deep copy of * DER-encoded OCSP response for that certificate. A deep copy of
* the map is returned to protect against subsequent modification. * the map is returned to protect against subsequent modification.
* Returns an empty map if no responses have been specified. * Returns an empty map if no responses have been specified.
*/ */
public Map<X509Certificate, byte[]> getOCSPStapledResponses() { public Map<X509Certificate, byte[]> getOCSPResponses() {
Map<X509Certificate, byte[]> copy = new HashMap<>(ocspStapled.size()); Map<X509Certificate, byte[]> copy = new HashMap<>(ocspResponses.size());
for (Map.Entry<X509Certificate, byte[]> e : ocspStapled.entrySet()) { for (Map.Entry<X509Certificate, byte[]> e : ocspResponses.entrySet()) {
copy.put(e.getKey(), e.getValue().clone()); copy.put(e.getKey(), e.getValue().clone());
} }
return copy; return copy;
...@@ -234,10 +234,10 @@ public abstract class PKIXRevocationChecker extends PKIXCertPathChecker { ...@@ -234,10 +234,10 @@ public abstract class PKIXRevocationChecker extends PKIXCertPathChecker {
public Object clone() { public Object clone() {
PKIXRevocationChecker copy = (PKIXRevocationChecker)super.clone(); PKIXRevocationChecker copy = (PKIXRevocationChecker)super.clone();
copy.ocspExtensions = new ArrayList<>(ocspExtensions); copy.ocspExtensions = new ArrayList<>(ocspExtensions);
copy.ocspStapled = new HashMap<>(ocspStapled); copy.ocspResponses = new HashMap<>(ocspResponses);
// deep-copy the encoded stapled responses, since they are mutable // deep-copy the encoded responses, since they are mutable
for (Map.Entry<X509Certificate, byte[]> entry : for (Map.Entry<X509Certificate, byte[]> entry :
copy.ocspStapled.entrySet()) copy.ocspResponses.entrySet())
{ {
byte[] encoded = entry.getValue(); byte[] encoded = entry.getValue();
entry.setValue(encoded.clone()); entry.setValue(encoded.clone());
......
/* /*
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -41,6 +41,7 @@ public class PBEParameterSpec implements AlgorithmParameterSpec { ...@@ -41,6 +41,7 @@ public class PBEParameterSpec implements AlgorithmParameterSpec {
private byte[] salt; private byte[] salt;
private int iterationCount; private int iterationCount;
private AlgorithmParameterSpec paramSpec = null;
/** /**
* Constructs a parameter set for password-based encryption as defined in * Constructs a parameter set for password-based encryption as defined in
...@@ -56,6 +57,25 @@ public class PBEParameterSpec implements AlgorithmParameterSpec { ...@@ -56,6 +57,25 @@ public class PBEParameterSpec implements AlgorithmParameterSpec {
this.iterationCount = iterationCount; this.iterationCount = iterationCount;
} }
/**
* Constructs a parameter set for password-based encryption as defined in
* the PKCS #5 standard.
*
* @param salt the salt. The contents of <code>salt</code> are copied
* to protect against subsequent modification.
* @param iterationCount the iteration count.
* @param paramSpec the cipher algorithm parameter specification.
* @exception NullPointerException if <code>salt</code> is null.
*
* @since 1.8
*/
public PBEParameterSpec(byte[] salt, int iterationCount,
AlgorithmParameterSpec paramSpec) {
this.salt = salt.clone();
this.iterationCount = iterationCount;
this.paramSpec = paramSpec;
}
/** /**
* Returns the salt. * Returns the salt.
* *
...@@ -74,4 +94,15 @@ public class PBEParameterSpec implements AlgorithmParameterSpec { ...@@ -74,4 +94,15 @@ public class PBEParameterSpec implements AlgorithmParameterSpec {
public int getIterationCount() { public int getIterationCount() {
return this.iterationCount; return this.iterationCount;
} }
/**
* Returns the cipher algorithm parameter specification.
*
* @return the parameter specification, or null if none was set.
*
* @since 1.8
*/
public AlgorithmParameterSpec getParameterSpec() {
return this.paramSpec;
}
} }
/* /*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -29,7 +29,7 @@ import java.sql.*; ...@@ -29,7 +29,7 @@ import java.sql.*;
import java.io.*; import java.io.*;
import java.util.Map; import java.util.Map;
import java.net.URL; import java.net.URL;
import java.util.Arrays;
/** /**
* A serialized version of an <code>Array</code> * A serialized version of an <code>Array</code>
...@@ -524,6 +524,97 @@ public class SerialArray implements Array, Serializable, Cloneable { ...@@ -524,6 +524,97 @@ public class SerialArray implements Array, Serializable, Cloneable {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
/**
* Compares this SerialArray to the specified object. The result is {@code
* true} if and only if the argument is not {@code null} and is a {@code
* SerialArray} object whose elements are identical to this object's elements
*
* @param obj The object to compare this {@code SerialArray} against
*
* @return {@code true} if the given object represents a {@code SerialArray}
* equivalent to this SerialArray, {@code false} otherwise
*
*/
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof SerialArray) {
SerialArray sa = (SerialArray)obj;
return baseType == sa.baseType &&
baseTypeName.equals(sa.baseTypeName) &&
Arrays.equals(elements, sa.elements);
}
return false;
}
/**
* Returns a hash code for this SerialArray. The hash code for a
* {@code SerialArray} object is computed using the hash codes
* of the elements of the {@code SerialArray} object
*
* @return a hash code value for this object.
*/
public int hashCode() {
return (((31 + Arrays.hashCode(elements)) * 31 + len) * 31 +
baseType) * 31 + baseTypeName.hashCode();
}
/**
* Returns a clone of this {@code SerialArray}. The copy will contain a
* reference to a clone of the underlying objects array, not a reference
* to the original underlying object array of this {@code SerialArray} object.
*
* @return a clone of this SerialArray
*/
public Object clone() {
try {
SerialArray sa = (SerialArray) super.clone();
sa.elements = Arrays.copyOf(elements, len);
return sa;
} catch (CloneNotSupportedException ex) {
// this shouldn't happen, since we are Cloneable
throw new InternalError();
}
}
/**
* readObject is called to restore the state of the {@code SerialArray} from
* a stream.
*/
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException {
ObjectInputStream.GetField fields = s.readFields();
Object[] tmp = (Object[])fields.get("elements", null);
if (tmp == null)
throw new InvalidObjectException("elements is null and should not be!");
elements = tmp.clone();
len = fields.get("len", 0);
if(elements.length != len)
throw new InvalidObjectException("elements is not the expected size");
baseType = fields.get("baseType", 0);
baseTypeName = (String)fields.get("baseTypeName", null);
}
/**
* writeObject is called to save the state of the {@code SerialArray}
* to a stream.
*/
private void writeObject(ObjectOutputStream s)
throws IOException, ClassNotFoundException {
ObjectOutputStream.PutField fields = s.putFields();
fields.put("elements", elements);
fields.put("len", len);
fields.put("baseType", baseType);
fields.put("baseTypeName", baseTypeName);
s.writeFields();
}
/** /**
* The identifier that assists in the serialization of this <code>SerialArray</code> * The identifier that assists in the serialization of this <code>SerialArray</code>
* object. * object.
......
/* /*
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -100,10 +100,64 @@ public class SerialDatalink implements Serializable, Cloneable { ...@@ -100,10 +100,64 @@ public class SerialDatalink implements Serializable, Cloneable {
return aURL; return aURL;
} }
/**
* Compares this {@code SerialDatalink} to the specified object.
* The result is {@code true} if and only if the argument is not
* {@code null} and is a {@code SerialDatalink} object whose URL is
* identical to this object's URL
*
* @param obj The object to compare this {@code SerialDatalink} against
*
* @return {@code true} if the given object represents a {@code SerialDatalink}
* equivalent to this SerialDatalink, {@code false} otherwise
*
*/
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof SerialDatalink) {
SerialDatalink sdl = (SerialDatalink) obj;
return url.equals(sdl.url);
}
return false;
}
/** /**
* The identifier that assists in the serialization of this <code>SerialDatalink</code> * Returns a hash code for this {@code SerialDatalink}. The hash code for a
* object. * {@code SerialDatalink} object is taken as the hash code of
* the {@code URL} it stores
*
* @return a hash code value for this object.
*/
public int hashCode() {
return 31 + url.hashCode();
}
/**
* Returns a clone of this {@code SerialDatalink}.
*
* @return a clone of this SerialDatalink
*/
public Object clone() {
try {
SerialDatalink sdl = (SerialDatalink) super.clone();
return sdl;
} catch (CloneNotSupportedException ex) {
// this shouldn't happen, since we are Cloneable
throw new InternalError();
}
}
/**
* readObject and writeObject are called to restore the state
* of the {@code SerialDatalink}
* from a stream. Note: we leverage the default Serialized form
*/
/**
* The identifier that assists in the serialization of this
* {@code SerialDatalink} object.
*/ */
static final long serialVersionUID = 2826907821828733626L; static final long serialVersionUID = 2826907821828733626L;
} }
/* /*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -27,6 +27,8 @@ package javax.sql.rowset.serial; ...@@ -27,6 +27,8 @@ package javax.sql.rowset.serial;
import java.io.*; import java.io.*;
import java.lang.reflect.*; import java.lang.reflect.*;
import java.util.Arrays;
import java.util.Vector;
import javax.sql.rowset.RowSetWarning; import javax.sql.rowset.RowSetWarning;
/** /**
...@@ -49,7 +51,7 @@ public class SerialJavaObject implements Serializable, Cloneable { ...@@ -49,7 +51,7 @@ public class SerialJavaObject implements Serializable, Cloneable {
/** /**
* Placeholder for object to be serialized. * Placeholder for object to be serialized.
*/ */
private final Object obj; private Object obj;
/** /**
...@@ -82,18 +84,9 @@ public class SerialJavaObject implements Serializable, Cloneable { ...@@ -82,18 +84,9 @@ public class SerialJavaObject implements Serializable, Cloneable {
// any of these are static, this should invalidate // any of these are static, this should invalidate
// the action of attempting to persist these fields // the action of attempting to persist these fields
// in a serialized form // in a serialized form
boolean anyStaticFields = false;
fields = c.getFields(); fields = c.getFields();
for (int i = 0; i < fields.length; i++ ) { if (hasStaticFields(fields)) {
if ( fields[i].getModifiers() == Modifier.STATIC ) {
anyStaticFields = true;
}
}
if (anyStaticFields) {
throw new SerialException("Located static fields in " + throw new SerialException("Located static fields in " +
"object instance. Cannot serialize"); "object instance. Cannot serialize");
} }
...@@ -142,15 +135,117 @@ public class SerialJavaObject implements Serializable, Cloneable { ...@@ -142,15 +135,117 @@ public class SerialJavaObject implements Serializable, Cloneable {
* object. When there are multiple warnings, each warning is chained to the * object. When there are multiple warnings, each warning is chained to the
* previous warning. * previous warning.
*/ */
java.util.Vector<RowSetWarning> chain; Vector<RowSetWarning> chain;
/**
* Compares this SerialJavaObject to the specified object.
* The result is {@code true} if and only if the argument
* is not {@code null} and is a {@code SerialJavaObject}
* object that is identical to this object
*
* @param o The object to compare this {@code SerialJavaObject} against
*
* @return {@code true} if the given object represents a {@code SerialJavaObject}
* equivalent to this SerialJavaObject, {@code false} otherwise
*
*/
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o instanceof SerialJavaObject) {
SerialJavaObject sjo = (SerialJavaObject) o;
return obj.equals(sjo.obj);
}
return false;
}
/**
* Returns a hash code for this SerialJavaObject. The hash code for a
* {@code SerialJavaObject} object is taken as the hash code of
* the {@code Object} it stores
*
* @return a hash code value for this object.
*/
public int hashCode() {
return 31 + obj.hashCode();
}
/**
* Returns a clone of this {@code SerialJavaObject}.
*
* @return a clone of this SerialJavaObject
*/
public Object clone() {
try {
SerialJavaObject sjo = (SerialJavaObject) super.clone();
sjo.fields = Arrays.copyOf(fields, fields.length);
if (chain != null)
sjo.chain = new Vector<>(chain);
return sjo;
} catch (CloneNotSupportedException ex) {
// this shouldn't happen, since we are Cloneable
throw new InternalError();
}
}
/** /**
* Registers the given warning. * Registers the given warning.
*/ */
private void setWarning(RowSetWarning e) { private void setWarning(RowSetWarning e) {
if (chain == null) { if (chain == null) {
chain = new java.util.Vector<>(); chain = new Vector<>();
} }
chain.add(e); chain.add(e);
} }
/**
* readObject is called to restore the state of the {@code SerialJavaObject}
* from a stream.
*/
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException {
ObjectInputStream.GetField fields1 = s.readFields();
@SuppressWarnings("unchecked")
Vector<RowSetWarning> tmp = (Vector<RowSetWarning>)fields1.get("chain", null);
if (tmp != null)
chain = new Vector<>(tmp);
obj = fields1.get("obj", null);
if (obj != null) {
fields = obj.getClass().getFields();
if(hasStaticFields(fields))
throw new IOException("Located static fields in " +
"object instance. Cannot serialize");
} else {
throw new IOException("Object cannot be null!");
}
}
/**
* writeObject is called to save the state of the {@code SerialJavaObject}
* to a stream.
*/
private void writeObject(ObjectOutputStream s)
throws IOException {
ObjectOutputStream.PutField fields = s.putFields();
fields.put("obj", obj);
fields.put("chain", chain);
s.writeFields();
}
/*
* Check to see if there are any Static Fields in this object
*/
private static boolean hasStaticFields(Field[] fields) {
for (Field field : fields) {
if ( field.getModifiers() == Modifier.STATIC) {
return true;
}
}
return false;
}
} }
/* /*
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -162,6 +162,84 @@ public class SerialRef implements Ref, Serializable, Cloneable { ...@@ -162,6 +162,84 @@ public class SerialRef implements Ref, Serializable, Cloneable {
object = obj; object = obj;
} }
/**
* Compares this SerialRef to the specified object. The result is {@code
* true} if and only if the argument is not {@code null} and is a {@code
* SerialRef} object that represents the same object as this
* object.
*
* @param obj The object to compare this {@code SerialRef} against
*
* @return {@code true} if the given object represents a {@code SerialRef}
* equivalent to this SerialRef, {@code false} otherwise
*
*/
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if(obj instanceof SerialRef) {
SerialRef ref = (SerialRef)obj;
return baseTypeName.equals(ref.baseTypeName) &&
object.equals(ref.object);
}
return false;
}
/**
* Returns a hash code for this {@code SerialRef}.
* @return a hash code value for this object.
*/
public int hashCode() {
return (31 + object.hashCode()) * 31 + baseTypeName.hashCode();
}
/**
* Returns a clone of this {@code SerialRef}. .
* The underlying {@code Ref} object will be set to null.
*
* @return a clone of this SerialRef
*/
public Object clone() {
try {
SerialRef ref = (SerialRef) super.clone();
ref.reference = null;
return ref;
} catch (CloneNotSupportedException ex) {
// this shouldn't happen, since we are Cloneable
throw new InternalError();
}
}
/**
* readObject is called to restore the state of the SerialRef from
* a stream.
*/
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException {
ObjectInputStream.GetField fields = s.readFields();
object = fields.get("object", null);
baseTypeName = (String) fields.get("baseTypeName", null);
reference = (Ref) fields.get("reference", null);
}
/**
* writeObject is called to save the state of the SerialRef
* to a stream.
*/
private void writeObject(ObjectOutputStream s)
throws IOException, ClassNotFoundException {
ObjectOutputStream.PutField fields = s.putFields();
fields.put("baseTypeName", baseTypeName);
fields.put("object", object);
// Note: this check to see if it is an instance of Serializable
// is for backwards compatibiity
fields.put("reference", reference instanceof Serializable ? reference : null);
s.writeFields();
}
/** /**
* The identifier that assists in the serialization of this <code>SerialRef</code> * The identifier that assists in the serialization of this <code>SerialRef</code>
* object. * object.
......
...@@ -249,6 +249,88 @@ public class SerialStruct implements Struct, Serializable, Cloneable { ...@@ -249,6 +249,88 @@ public class SerialStruct implements Struct, Serializable, Cloneable {
return; return;
} }
/**
* Compares this SerialStruct to the specified object. The result is
* {@code true} if and only if the argument is not {@code null} and is a
* {@code SerialStruct} object whose attributes are identical to this
* object's attributes
*
* @param obj The object to compare this {@code SerialStruct} against
*
* @return {@code true} if the given object represents a {@code SerialStruct}
* equivalent to this SerialStruct, {@code false} otherwise
*
*/
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof SerialStruct) {
SerialStruct ss = (SerialStruct)obj;
return SQLTypeName.equals(ss.SQLTypeName) &&
Arrays.equals(attribs, ss.attribs);
}
return false;
}
/**
* Returns a hash code for this {@code SerialStruct}. The hash code for a
* {@code SerialStruct} object is computed using the hash codes
* of the attributes of the {@code SerialStruct} object and its
* {@code SQLTypeName}
*
* @return a hash code value for this object.
*/
public int hashCode() {
return ((31 + Arrays.hashCode(attribs)) * 31) * 31
+ SQLTypeName.hashCode();
}
/**
* Returns a clone of this {@code SerialStruct}. The copy will contain a
* reference to a clone of the underlying attribs array, not a reference
* to the original underlying attribs array of this {@code SerialStruct} object.
*
* @return a clone of this SerialStruct
*/
public Object clone() {
try {
SerialStruct ss = (SerialStruct) super.clone();
ss.attribs = Arrays.copyOf(attribs, attribs.length);
return ss;
} catch (CloneNotSupportedException ex) {
// this shouldn't happen, since we are Cloneable
throw new InternalError();
}
}
/**
* readObject is called to restore the state of the {@code SerialStruct} from
* a stream.
*/
private void readObject(ObjectInputStream s)
throws IOException, ClassNotFoundException {
ObjectInputStream.GetField fields = s.readFields();
Object[] tmp = (Object[])fields.get("attribs", null);
attribs = tmp == null ? null : tmp.clone();
SQLTypeName = (String)fields.get("SQLTypeName", null);
}
/**
* writeObject is called to save the state of the {@code SerialStruct}
* to a stream.
*/
private void writeObject(ObjectOutputStream s)
throws IOException, ClassNotFoundException {
ObjectOutputStream.PutField fields = s.putFields();
fields.put("attribs", attribs);
fields.put("SQLTypeName", SQLTypeName);
s.writeFields();
}
/** /**
* The identifier that assists in the serialization of this * The identifier that assists in the serialization of this
* <code>SerialStruct</code> object. * <code>SerialStruct</code> object.
......
...@@ -302,12 +302,10 @@ public class FileChannelImpl ...@@ -302,12 +302,10 @@ public class FileChannelImpl
} }
} }
public FileChannel truncate(long size) throws IOException { public FileChannel truncate(long newSize) throws IOException {
ensureOpen(); ensureOpen();
if (size < 0) if (newSize < 0)
throw new IllegalArgumentException(); throw new IllegalArgumentException("Negative size");
if (size > size())
return this;
if (!writable) if (!writable)
throw new NonWritableChannelException(); throw new NonWritableChannelException();
synchronized (positionLock) { synchronized (positionLock) {
...@@ -320,6 +318,14 @@ public class FileChannelImpl ...@@ -320,6 +318,14 @@ public class FileChannelImpl
if (!isOpen()) if (!isOpen())
return null; return null;
// get current size
long size;
do {
size = nd.size(fd);
} while ((size == IOStatus.INTERRUPTED) && isOpen());
if (!isOpen())
return null;
// get current position // get current position
do { do {
p = position0(fd, -1); p = position0(fd, -1);
...@@ -328,16 +334,18 @@ public class FileChannelImpl ...@@ -328,16 +334,18 @@ public class FileChannelImpl
return null; return null;
assert p >= 0; assert p >= 0;
// truncate file // truncate file if given size is less than the current size
if (newSize < size) {
do { do {
rv = nd.truncate(fd, size); rv = nd.truncate(fd, newSize);
} while ((rv == IOStatus.INTERRUPTED) && isOpen()); } while ((rv == IOStatus.INTERRUPTED) && isOpen());
if (!isOpen()) if (!isOpen())
return null; return null;
}
// set position to size if greater than size // if position is beyond new size then adjust it
if (p > size) if (p > newSize)
p = size; p = newSize;
do { do {
rv = (int)position0(fd, p); rv = (int)position0(fd, p);
} while ((rv == IOStatus.INTERRUPTED) && isOpen()); } while ((rv == IOStatus.INTERRUPTED) && isOpen());
...@@ -779,6 +787,8 @@ public class FileChannelImpl ...@@ -779,6 +787,8 @@ public class FileChannelImpl
throws IOException throws IOException
{ {
ensureOpen(); ensureOpen();
if (mode == null)
throw new NullPointerException("Mode is null");
if (position < 0L) if (position < 0L)
throw new IllegalArgumentException("Negative position"); throw new IllegalArgumentException("Negative position");
if (size < 0L) if (size < 0L)
...@@ -787,6 +797,7 @@ public class FileChannelImpl ...@@ -787,6 +797,7 @@ public class FileChannelImpl
throw new IllegalArgumentException("Position + size overflow"); throw new IllegalArgumentException("Position + size overflow");
if (size > Integer.MAX_VALUE) if (size > Integer.MAX_VALUE)
throw new IllegalArgumentException("Size exceeds Integer.MAX_VALUE"); throw new IllegalArgumentException("Size exceeds Integer.MAX_VALUE");
int imode = -1; int imode = -1;
if (mode == MapMode.READ_ONLY) if (mode == MapMode.READ_ONLY)
imode = MAP_RO; imode = MAP_RO;
......
...@@ -31,10 +31,19 @@ package sun.security.jgss; ...@@ -31,10 +31,19 @@ package sun.security.jgss;
* different callers. * different callers.
*/ */
public class GSSCaller { public class GSSCaller {
public static final GSSCaller CALLER_UNKNOWN = new GSSCaller(); public static final GSSCaller CALLER_UNKNOWN = new GSSCaller("UNKNOWN");
public static final GSSCaller CALLER_INITIATE = new GSSCaller(); public static final GSSCaller CALLER_INITIATE = new GSSCaller("INITIATE");
public static final GSSCaller CALLER_ACCEPT = new GSSCaller(); public static final GSSCaller CALLER_ACCEPT = new GSSCaller("ACCEPT");
public static final GSSCaller CALLER_SSL_CLIENT = new GSSCaller(); public static final GSSCaller CALLER_SSL_CLIENT = new GSSCaller("SSL_CLIENT");
public static final GSSCaller CALLER_SSL_SERVER = new GSSCaller(); public static final GSSCaller CALLER_SSL_SERVER = new GSSCaller("SSL_SERVER");
private String name;
GSSCaller(String s) {
name = s;
}
@Override
public String toString() {
return "GSSCaller{" + name + '}';
}
} }
...@@ -28,8 +28,9 @@ package sun.security.jgss; ...@@ -28,8 +28,9 @@ package sun.security.jgss;
import org.ietf.jgss.*; import org.ietf.jgss.*;
import sun.security.jgss.spi.*; import sun.security.jgss.spi.*;
import java.util.*; import java.util.*;
import com.sun.security.jgss.*;
public class GSSCredentialImpl implements GSSCredential { public class GSSCredentialImpl implements ExtendedGSSCredential {
private GSSManagerImpl gssManager = null; private GSSManagerImpl gssManager = null;
private boolean destroyed = false; private boolean destroyed = false;
...@@ -122,6 +123,19 @@ public class GSSCredentialImpl implements GSSCredential { ...@@ -122,6 +123,19 @@ public class GSSCredentialImpl implements GSSCredential {
} }
} }
public GSSCredential impersonate(GSSName name) throws GSSException {
if (destroyed) {
throw new IllegalStateException("This credential is " +
"no longer valid");
}
Oid mech = tempCred.getMechanism();
GSSNameSpi nameElement = (name == null ? null :
((GSSNameImpl)name).getElement(mech));
GSSCredentialSpi cred = tempCred.impersonate(nameElement);
return (cred == null ?
null : new GSSCredentialImpl(gssManager, cred));
}
public GSSName getName() throws GSSException { public GSSName getName() throws GSSException {
if (destroyed) { if (destroyed) {
throw new IllegalStateException("This credential is " + throw new IllegalStateException("This credential is " +
......
...@@ -35,6 +35,7 @@ public class HttpCaller extends GSSCaller { ...@@ -35,6 +35,7 @@ public class HttpCaller extends GSSCaller {
final private HttpCallerInfo hci; final private HttpCallerInfo hci;
public HttpCaller(HttpCallerInfo hci) { public HttpCaller(HttpCallerInfo hci) {
super("HTTP_CLIENT");
this.hci = hci; this.hci = hci;
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
package sun.security.jgss.krb5; package sun.security.jgss.krb5;
import java.io.IOException;
import org.ietf.jgss.*; import org.ietf.jgss.*;
import sun.security.jgss.GSSCaller; import sun.security.jgss.GSSCaller;
import sun.security.jgss.spi.*; import sun.security.jgss.spi.*;
...@@ -177,4 +178,21 @@ public class Krb5AcceptCredential ...@@ -177,4 +178,21 @@ public class Krb5AcceptCredential
public void destroy() throws DestroyFailedException { public void destroy() throws DestroyFailedException {
screds.destroy(); screds.destroy();
} }
/**
* Impersonation is only available on the initiator side. The
* service must starts as an initiator to get an initial TGT to complete
* the S4U2self protocol.
*/
@Override
public GSSCredentialSpi impersonate(GSSNameSpi name) throws GSSException {
Credentials cred = screds.getInitCred();
if (cred != null) {
return Krb5InitCredential.getInstance(this.name, cred)
.impersonate(name);
} else {
throw new GSSException(GSSException.FAILURE, -1,
"Only an initiate credentials can impersonate");
}
}
} }
...@@ -45,6 +45,7 @@ import java.security.PrivilegedActionException; ...@@ -45,6 +45,7 @@ import java.security.PrivilegedActionException;
import javax.crypto.Cipher; import javax.crypto.Cipher;
import javax.security.auth.Subject; import javax.security.auth.Subject;
import javax.security.auth.kerberos.*; import javax.security.auth.kerberos.*;
import sun.security.krb5.internal.Ticket;
/** /**
* Implements the mechanism specific context class for the Kerberos v5 * Implements the mechanism specific context class for the Kerberos v5
...@@ -76,7 +77,7 @@ class Krb5Context implements GSSContextSpi { ...@@ -76,7 +77,7 @@ class Krb5Context implements GSSContextSpi {
* values. * values.
*/ */
private boolean credDelegState = false; private boolean credDelegState = false; // now only useful at client
private boolean mutualAuthState = true; private boolean mutualAuthState = true;
private boolean replayDetState = true; private boolean replayDetState = true;
private boolean sequenceDetState = true; private boolean sequenceDetState = true;
...@@ -84,6 +85,8 @@ class Krb5Context implements GSSContextSpi { ...@@ -84,6 +85,8 @@ class Krb5Context implements GSSContextSpi {
private boolean integState = true; private boolean integState = true;
private boolean delegPolicyState = false; private boolean delegPolicyState = false;
private boolean isConstrainedDelegationTried = false;
private int mySeqNumber; private int mySeqNumber;
private int peerSeqNumber; private int peerSeqNumber;
private int keySrc; private int keySrc;
...@@ -113,13 +116,11 @@ class Krb5Context implements GSSContextSpi { ...@@ -113,13 +116,11 @@ class Krb5Context implements GSSContextSpi {
private Krb5CredElement myCred; private Krb5CredElement myCred;
private Krb5CredElement delegatedCred; // Set only on acceptor side private Krb5CredElement delegatedCred; // Set only on acceptor side
/* DESCipher instance used by the corresponding GSSContext */
private Cipher desCipher = null;
// XXX See if the required info from these can be extracted and // XXX See if the required info from these can be extracted and
// stored elsewhere // stored elsewhere
private Credentials serviceCreds; private Credentials serviceCreds;
private KrbApReq apReq; private KrbApReq apReq;
Ticket serviceTicket;
final private GSSCaller caller; final private GSSCaller caller;
private static final boolean DEBUG = Krb5Util.DEBUG; private static final boolean DEBUG = Krb5Util.DEBUG;
...@@ -248,7 +249,14 @@ class Krb5Context implements GSSContextSpi { ...@@ -248,7 +249,14 @@ class Krb5Context implements GSSContextSpi {
* Is credential delegation enabled? * Is credential delegation enabled?
*/ */
public final boolean getCredDelegState() { public final boolean getCredDelegState() {
if (isInitiator()) {
return credDelegState; return credDelegState;
} else {
// Server side deleg state is not flagged by credDelegState.
// It can use constrained delegation.
tryConstrainedDelegation();
return delegatedCred != null;
}
} }
/** /**
...@@ -498,7 +506,8 @@ class Krb5Context implements GSSContextSpi { ...@@ -498,7 +506,8 @@ class Krb5Context implements GSSContextSpi {
* Returns the delegated credential for the context. This * Returns the delegated credential for the context. This
* is an optional feature of contexts which not all * is an optional feature of contexts which not all
* mechanisms will support. A context can be requested to * mechanisms will support. A context can be requested to
* support credential delegation by using the <b>CRED_DELEG</b>. * support credential delegation by using the <b>CRED_DELEG</b>,
* or it can request for a constrained delegation.
* This is only valid on the acceptor side of the context. * This is only valid on the acceptor side of the context.
* @return GSSCredentialSpi object for the delegated credential * @return GSSCredentialSpi object for the delegated credential
* @exception GSSException * @exception GSSException
...@@ -507,11 +516,41 @@ class Krb5Context implements GSSContextSpi { ...@@ -507,11 +516,41 @@ class Krb5Context implements GSSContextSpi {
public final GSSCredentialSpi getDelegCred() throws GSSException { public final GSSCredentialSpi getDelegCred() throws GSSException {
if (state != STATE_IN_PROCESS && state != STATE_DONE) if (state != STATE_IN_PROCESS && state != STATE_DONE)
throw new GSSException(GSSException.NO_CONTEXT); throw new GSSException(GSSException.NO_CONTEXT);
if (delegatedCred == null) if (isInitiator()) {
throw new GSSException(GSSException.NO_CRED); throw new GSSException(GSSException.NO_CRED);
}
tryConstrainedDelegation();
if (delegatedCred == null) {
throw new GSSException(GSSException.NO_CRED);
}
return delegatedCred; return delegatedCred;
} }
private void tryConstrainedDelegation() {
if (state != STATE_IN_PROCESS && state != STATE_DONE) {
return;
}
// We will only try constrained delegation once (if necessary).
if (!isConstrainedDelegationTried) {
if (delegatedCred == null) {
if (DEBUG) {
System.out.println(">>> Constrained deleg from " + caller);
}
// The constrained delegation part. The acceptor needs to have
// isInitiator=true in order to get a TGT, either earlier at
// logon stage, if useSubjectCredsOnly, or now.
try {
delegatedCred = new Krb5ProxyCredential(
Krb5InitCredential.getInstance(
GSSCaller.CALLER_ACCEPT, myName, lifetime),
peerName, serviceTicket);
} catch (GSSException gsse) {
// OK, delegatedCred is null then
}
}
isConstrainedDelegationTried = true;
}
}
/** /**
* Tests if this is the initiator side of the context. * Tests if this is the initiator side of the context.
* *
...@@ -577,8 +616,15 @@ class Krb5Context implements GSSContextSpi { ...@@ -577,8 +616,15 @@ class Krb5Context implements GSSContextSpi {
"No TGT available"); "No TGT available");
} }
myName = (Krb5NameElement) myCred.getName(); myName = (Krb5NameElement) myCred.getName();
Credentials tgt = Credentials tgt;
((Krb5InitCredential) myCred).getKrb5Credentials(); final Krb5ProxyCredential second;
if (myCred instanceof Krb5InitCredential) {
second = null;
tgt = ((Krb5InitCredential) myCred).getKrb5Credentials();
} else {
second = (Krb5ProxyCredential) myCred;
tgt = second.self.getKrb5Credentials();
}
checkPermission(peerName.getKrb5PrincipalName().getName(), checkPermission(peerName.getKrb5PrincipalName().getName(),
"initiate"); "initiate");
...@@ -607,7 +653,9 @@ class Krb5Context implements GSSContextSpi { ...@@ -607,7 +653,9 @@ class Krb5Context implements GSSContextSpi {
GSSCaller.CALLER_UNKNOWN, GSSCaller.CALLER_UNKNOWN,
// since it's useSubjectCredsOnly here, // since it's useSubjectCredsOnly here,
// don't worry about the null // don't worry about the null
myName.getKrb5PrincipalName().getName(), second == null ?
myName.getKrb5PrincipalName().getName():
second.getName().getKrb5PrincipalName().getName(),
peerName.getKrb5PrincipalName().getName(), peerName.getKrb5PrincipalName().getName(),
acc); acc);
}}); }});
...@@ -638,9 +686,17 @@ class Krb5Context implements GSSContextSpi { ...@@ -638,9 +686,17 @@ class Krb5Context implements GSSContextSpi {
"the subject"); "the subject");
} }
// Get Service ticket using the Kerberos protocols // Get Service ticket using the Kerberos protocols
if (second == null) {
serviceCreds = Credentials.acquireServiceCreds( serviceCreds = Credentials.acquireServiceCreds(
peerName.getKrb5PrincipalName().getName(), peerName.getKrb5PrincipalName().getName(),
tgt); tgt);
} else {
serviceCreds = Credentials.acquireS4U2proxyCreds(
peerName.getKrb5PrincipalName().getName(),
second.tkt,
second.getName().getKrb5PrincipalName(),
tgt);
}
if (GSSUtil.useSubjectCredsOnly(caller)) { if (GSSUtil.useSubjectCredsOnly(caller)) {
final Subject subject = final Subject subject =
AccessController.doPrivileged( AccessController.doPrivileged(
...@@ -776,6 +832,7 @@ class Krb5Context implements GSSContextSpi { ...@@ -776,6 +832,7 @@ class Krb5Context implements GSSContextSpi {
retVal = new AcceptSecContextToken(this, retVal = new AcceptSecContextToken(this,
token.getKrbApReq()).encode(); token.getKrbApReq()).encode();
} }
serviceTicket = token.getKrbApReq().getCreds().getTicket();
myCred = null; myCred = null;
state = STATE_DONE; state = STATE_DONE;
} else { } else {
...@@ -802,8 +859,6 @@ class Krb5Context implements GSSContextSpi { ...@@ -802,8 +859,6 @@ class Krb5Context implements GSSContextSpi {
return retVal; return retVal;
} }
/** /**
* Queries the context for largest data size to accomodate * Queries the context for largest data size to accomodate
* the specified protection and be <= maxTokSize. * the specified protection and be <= maxTokSize.
......
...@@ -309,8 +309,7 @@ public class Krb5InitCredential ...@@ -309,8 +309,7 @@ public class Krb5InitCredential
int initLifetime) int initLifetime)
throws GSSException { throws GSSException {
String realm = null; final String clientPrincipal;
final String clientPrincipal, tgsPrincipal = null;
/* /*
* Find the TGT for the realm that the client is in. If the client * Find the TGT for the realm that the client is in. If the client
...@@ -318,20 +317,8 @@ public class Krb5InitCredential ...@@ -318,20 +317,8 @@ public class Krb5InitCredential
*/ */
if (name != null) { if (name != null) {
clientPrincipal = (name.getKrb5PrincipalName()).getName(); clientPrincipal = (name.getKrb5PrincipalName()).getName();
realm = (name.getKrb5PrincipalName()).getRealmAsString();
} else { } else {
clientPrincipal = null; clientPrincipal = null;
try {
Config config = Config.getInstance();
realm = config.getDefaultRealm();
} catch (KrbException e) {
GSSException ge =
new GSSException(GSSException.NO_CRED, -1,
"Attempt to obtain INITIATE credentials failed!" +
" (" + e.getMessage() + ")");
ge.initCause(e);
throw ge;
}
} }
final AccessControlContext acc = AccessController.getContext(); final AccessControlContext acc = AccessController.getContext();
...@@ -343,9 +330,11 @@ public class Krb5InitCredential ...@@ -343,9 +330,11 @@ public class Krb5InitCredential
return AccessController.doPrivileged( return AccessController.doPrivileged(
new PrivilegedExceptionAction<KerberosTicket>() { new PrivilegedExceptionAction<KerberosTicket>() {
public KerberosTicket run() throws Exception { public KerberosTicket run() throws Exception {
// It's OK to use null as serverPrincipal. TGT is almost
// the first ticket for a principal and we use list.
return Krb5Util.getTicket( return Krb5Util.getTicket(
realCaller, realCaller,
clientPrincipal, tgsPrincipal, acc); clientPrincipal, null, acc);
}}); }});
} catch (PrivilegedActionException e) { } catch (PrivilegedActionException e) {
GSSException ge = GSSException ge =
...@@ -356,4 +345,20 @@ public class Krb5InitCredential ...@@ -356,4 +345,20 @@ public class Krb5InitCredential
throw ge; throw ge;
} }
} }
@Override
public GSSCredentialSpi impersonate(GSSNameSpi name) throws GSSException {
try {
Krb5NameElement kname = (Krb5NameElement)name;
Credentials newCred = Credentials.acquireS4U2selfCreds(
kname.getKrb5PrincipalName(), krb5Credentials);
return new Krb5ProxyCredential(this, kname, newCred.getTicket());
} catch (IOException | KrbException ke) {
GSSException ge =
new GSSException(GSSException.FAILURE, -1,
"Attempt to obtain S4U2self credentials failed!");
ge.initCause(ke);
throw ge;
}
}
} }
...@@ -206,7 +206,7 @@ public class Krb5Util { ...@@ -206,7 +206,7 @@ public class Krb5Util {
* identity, which can be: * identity, which can be:
* 1. Some KerberosKeys (generated from password) * 1. Some KerberosKeys (generated from password)
* 2. A KeyTab (for a typical service) * 2. A KeyTab (for a typical service)
* 3. A TGT (for a user2user service. Not supported yet) * 3. A TGT (for S4U2proxy extension)
* *
* Note that some creds can coexist. For example, a user2user service * Note that some creds can coexist. For example, a user2user service
* can use its keytab (or keys) if the client can successfully obtain a * can use its keytab (or keys) if the client can successfully obtain a
...@@ -219,7 +219,7 @@ public class Krb5Util { ...@@ -219,7 +219,7 @@ public class Krb5Util {
private List<KeyTab> ktabs; private List<KeyTab> ktabs;
private List<KerberosKey> kk; private List<KerberosKey> kk;
private Subject subj; private Subject subj;
//private KerberosTicket tgt; // user2user, not supported yet private KerberosTicket tgt;
private static ServiceCreds getInstance( private static ServiceCreds getInstance(
Subject subj, String serverPrincipal) { Subject subj, String serverPrincipal) {
...@@ -255,6 +255,8 @@ public class Krb5Util { ...@@ -255,6 +255,8 @@ public class Krb5Util {
subj, null, null, KeyTab.class); subj, null, null, KeyTab.class);
sc.kk = SubjectComber.findMany( sc.kk = SubjectComber.findMany(
subj, serverPrincipal, null, KerberosKey.class); subj, serverPrincipal, null, KerberosKey.class);
sc.tgt = SubjectComber.find(subj, null, null, KerberosTicket.class);
if (sc.ktabs.isEmpty() && sc.kk.isEmpty()) { if (sc.ktabs.isEmpty() && sc.kk.isEmpty()) {
return null; return null;
} }
...@@ -310,10 +312,22 @@ public class Krb5Util { ...@@ -310,10 +312,22 @@ public class Krb5Util {
return ekeys; return ekeys;
} }
public Credentials getInitCred() {
if (tgt == null) {
return null;
}
try {
return ticketToCreds(tgt);
} catch (KrbException | IOException e) {
return null;
}
}
public void destroy() { public void destroy() {
kp = null; kp = null;
ktabs = null; ktabs = null;
kk = null; kk = null;
tgt = null;
} }
} }
/** /**
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册