s
with any leading zeros removed.
- */
- static String stripLeadingZeros(String s) {
- return s.replaceFirst("^0+", "");
- }
-
- /**
- * Extract a hexadecimal digit from position position
- * of string s
.
- */
- static int getHexDigit(String s, int position) {
- int value = Character.digit(s.charAt(position), 16);
- if (value <= -1 || value >= 16) {
- throw new AssertionError("Unxpected failure of digit converstion of " +
- s.charAt(position));
- }
- return value;
- }
-
-
}
diff -r 21c83ff61827 -r caf47ebdd810 jdk/src/share/classes/sun/misc/JavaIOAccess.java
--- a/jdk/src/share/classes/sun/misc/JavaIOAccess.java Fri Mar 27 14:11:45 2009 -0700
+++ b/jdk/src/share/classes/sun/misc/JavaIOAccess.java Tue Mar 31 08:53:40 2009 -0700
@@ -29,6 +29,5 @@
public interface JavaIOAccess {
public Console console();
- public Runnable consoleRestoreHook();
public Charset charset();
}
diff -r 21c83ff61827 -r caf47ebdd810 jdk/src/share/classes/sun/misc/JavaIODeleteOnExitAccess.java
--- a/jdk/src/share/classes/sun/misc/JavaIODeleteOnExitAccess.java Fri Mar 27 14:11:45 2009 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Sun designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Sun in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- */
-
-package sun.misc;
-
-public interface JavaIODeleteOnExitAccess extends Runnable {
- public void run();
-}
diff -r 21c83ff61827 -r caf47ebdd810 jdk/src/share/classes/sun/misc/JavaLangAccess.java
--- a/jdk/src/share/classes/sun/misc/JavaLangAccess.java Fri Mar 27 14:11:45 2009 -0700
+++ b/jdk/src/share/classes/sun/misc/JavaLangAccess.java Tue Mar 31 08:53:40 2009 -0700
@@ -54,4 +54,7 @@
/** Set thread's blocker field. */
void blockedOn(Thread t, Interruptible b);
+
+ /** register shutdown hook */
+ void registerShutdownHook(int slot, Runnable r);
}
diff -r 21c83ff61827 -r caf47ebdd810 jdk/src/share/classes/sun/misc/SharedSecrets.java
--- a/jdk/src/share/classes/sun/misc/SharedSecrets.java Fri Mar 27 14:11:45 2009 -0700
+++ b/jdk/src/share/classes/sun/misc/SharedSecrets.java Tue Mar 31 08:53:40 2009 -0700
@@ -44,7 +44,6 @@
private static JavaUtilJarAccess javaUtilJarAccess;
private static JavaLangAccess javaLangAccess;
private static JavaIOAccess javaIOAccess;
- private static JavaIODeleteOnExitAccess javaIODeleteOnExitAccess;
private static JavaNetAccess javaNetAccess;
private static JavaNioAccess javaNioAccess;
private static JavaIOFileDescriptorAccess javaIOFileDescriptorAccess;
@@ -103,17 +102,6 @@
return javaIOAccess;
}
- public static void setJavaIODeleteOnExitAccess(JavaIODeleteOnExitAccess jida) {
- javaIODeleteOnExitAccess = jida;
- }
-
- public static JavaIODeleteOnExitAccess getJavaIODeleteOnExitAccess() {
- if (javaIODeleteOnExitAccess == null) {
- unsafe.ensureClassInitialized(File.class);
- }
- return javaIODeleteOnExitAccess;
- }
-
public static void setJavaIOFileDescriptorAccess(JavaIOFileDescriptorAccess jiofda) {
javaIOFileDescriptorAccess = jiofda;
}
diff -r 21c83ff61827 -r caf47ebdd810 jdk/src/share/classes/sun/nio/cs/ArrayDecoder.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/nio/cs/ArrayDecoder.java Tue Mar 31 08:53:40 2009 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.nio.cs;
+
+/*
+ * FastPath byte[]->char[] decoder, REPLACE on malformed or
+ * unmappable input.
+ */
+
+public interface ArrayDecoder {
+ int decode(byte[] src, int off, int len, char[] dst);
+}
diff -r 21c83ff61827 -r caf47ebdd810 jdk/src/share/classes/sun/nio/cs/ArrayEncoder.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/share/classes/sun/nio/cs/ArrayEncoder.java Tue Mar 31 08:53:40 2009 -0700
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2009 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package sun.nio.cs;
+
+/*
+ * FastPath char[]->byte[] encoder, REPLACE on malformed input or
+ * unmappable input.
+ */
+
+public interface ArrayEncoder {
+ int encode(char[] src, int off, int len, byte[] dst);
+}
diff -r 21c83ff61827 -r caf47ebdd810 jdk/src/share/classes/sun/nio/cs/ISO_8859_1.java
--- a/jdk/src/share/classes/sun/nio/cs/ISO_8859_1.java Fri Mar 27 14:11:45 2009 -0700
+++ b/jdk/src/share/classes/sun/nio/cs/ISO_8859_1.java Tue Mar 31 08:53:40 2009 -0700
@@ -23,9 +23,6 @@
* have any questions.
*/
-/*
- */
-
package sun.nio.cs;
import java.nio.ByteBuffer;
@@ -34,10 +31,7 @@
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult;
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.MalformedInputException;
-import java.nio.charset.UnmappableCharacterException;
-
+import java.util.Arrays;
class ISO_8859_1
extends Charset
@@ -65,8 +59,8 @@
return new Encoder(this);
}
- private static class Decoder extends CharsetDecoder {
-
+ private static class Decoder extends CharsetDecoder
+ implements ArrayDecoder {
private Decoder(Charset cs) {
super(cs, 1.0f, 1.0f);
}
@@ -127,10 +121,18 @@
return decodeBufferLoop(src, dst);
}
+ public int decode(byte[] src, int sp, int len, char[] dst) {
+ if (len > dst.length)
+ len = dst.length;
+ int dp = 0;
+ while (dp < len)
+ dst[dp++] = (char)(src[sp++] & 0xff);
+ return dp;
+ }
}
- private static class Encoder extends CharsetEncoder {
-
+ private static class Encoder extends CharsetEncoder
+ implements ArrayEncoder {
private Encoder(Charset cs) {
super(cs, 1.0f, 1.0f);
}
@@ -139,6 +141,10 @@
return c <= '\u00FF';
}
+ public boolean isLegalReplacement(byte[] repl) {
+ return (repl.length == 1); // we accept any byte value
+ }
+
private final Surrogate.Parser sgp = new Surrogate.Parser();
private CoderResult encodeArrayLoop(CharBuffer src,
@@ -208,5 +214,31 @@
return encodeBufferLoop(src, dst);
}
+ private byte repl = (byte)'?';
+ protected void implReplaceWith(byte[] newReplacement) {
+ repl = newReplacement[0];
+ }
+
+ public int encode(char[] src, int sp, int len, byte[] dst) {
+ int dp = 0;
+ int sl = sp + Math.min(len, dst.length);
+ while (sp < sl) {
+ char c = src[sp++];
+ if (c <= '\u00FF') {
+ dst[dp++] = (byte)c;
+ continue;
+ }
+ if (Surrogate.isHigh(c) && sp < sl &&
+ Surrogate.isLow(src[sp])) {
+ if (len > dst.length) {
+ sl++;
+ len--;
+ }
+ sp++;
+ }
+ dst[dp++] = repl;
+ }
+ return dp;
+ }
}
}
diff -r 21c83ff61827 -r caf47ebdd810 jdk/src/share/classes/sun/nio/cs/SingleByte.java
--- a/jdk/src/share/classes/sun/nio/cs/SingleByte.java Fri Mar 27 14:11:45 2009 -0700
+++ b/jdk/src/share/classes/sun/nio/cs/SingleByte.java Tue Mar 31 08:53:40 2009 -0700
@@ -32,6 +32,7 @@
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult;
+import java.util.Arrays;
import static sun.nio.cs.CharsetMapping.*;
public class SingleByte
@@ -45,7 +46,8 @@
return cr;
}
- public static class Decoder extends CharsetDecoder {
+ final public static class Decoder extends CharsetDecoder
+ implements ArrayDecoder {
private final char[] b2c;
public Decoder(Charset cs, char[] b2c) {
@@ -108,9 +110,29 @@
private final char decode(int b) {
return b2c[b + 128];
}
+
+ private char repl = '\uFFFD';
+ protected void implReplaceWith(String newReplacement) {
+ repl = newReplacement.charAt(0);
+ }
+
+ public int decode(byte[] src, int sp, int len, char[] dst) {
+ if (len > dst.length)
+ len = dst.length;
+ int dp = 0;
+ while (dp < len) {
+ dst[dp] = decode(src[sp++]);
+ if (dst[dp] == UNMAPPABLE_DECODING) {
+ dst[dp] = repl;
+ }
+ dp++;
+ }
+ return dp;
+ }
}
- public static class Encoder extends CharsetEncoder {
+ final public static class Encoder extends CharsetEncoder
+ implements ArrayEncoder {
private Surrogate.Parser sgp;
private final char[] c2b;
private final char[] c2bIndex;
@@ -125,6 +147,11 @@
return encode(c) != UNMAPPABLE_ENCODING;
}
+ public boolean isLegalReplacement(byte[] repl) {
+ return ((repl.length == 1 && repl[0] == (byte)'?') ||
+ super.isLegalReplacement(repl));
+ }
+
private CoderResult encodeArrayLoop(CharBuffer src, ByteBuffer dst) {
char[] sa = src.array();
int sp = src.arrayOffset() + src.position();
@@ -200,6 +227,34 @@
return UNMAPPABLE_ENCODING;
return c2b[index + (ch & 0xff)];
}
+
+ private byte repl = (byte)'?';
+ protected void implReplaceWith(byte[] newReplacement) {
+ repl = newReplacement[0];
+ }
+
+ public int encode(char[] src, int sp, int len, byte[] dst) {
+ int dp = 0;
+ int sl = sp + Math.min(len, dst.length);
+ while (sp < sl) {
+ char c = src[sp++];
+ int b = encode(c);
+ if (b != UNMAPPABLE_ENCODING) {
+ dst[dp++] = (byte)b;
+ continue;
+ }
+ if (Surrogate.isHigh(c) && sp < sl &&
+ Surrogate.isLow(src[sp])) {
+ if (len > dst.length) {
+ sl++;
+ len--;
+ }
+ sp++;
+ }
+ dst[dp++] = repl;
+ }
+ return dp;
+ }
}
// init the c2b and c2bIndex tables from b2c.
diff -r 21c83ff61827 -r caf47ebdd810 jdk/src/share/classes/sun/nio/cs/US_ASCII.java
--- a/jdk/src/share/classes/sun/nio/cs/US_ASCII.java Fri Mar 27 14:11:45 2009 -0700
+++ b/jdk/src/share/classes/sun/nio/cs/US_ASCII.java Tue Mar 31 08:53:40 2009 -0700
@@ -31,10 +31,7 @@
import java.nio.charset.CharsetDecoder;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.CoderResult;
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.MalformedInputException;
-import java.nio.charset.UnmappableCharacterException;
-
+import java.util.Arrays;
public class US_ASCII
extends Charset
@@ -61,7 +58,8 @@
return new Encoder(this);
}
- private static class Decoder extends CharsetDecoder {
+ private static class Decoder extends CharsetDecoder
+ implements ArrayDecoder {
private Decoder(Charset cs) {
super(cs, 1.0f, 1.0f);
@@ -131,9 +129,27 @@
return decodeBufferLoop(src, dst);
}
+ private char repl = '\uFFFD';
+ protected void implReplaceWith(String newReplacement) {
+ repl = newReplacement.charAt(0);
+ }
+
+ public int decode(byte[] src, int sp, int len, char[] dst) {
+ int dp = 0;
+ len = Math.min(len, dst.length);
+ while (dp < len) {
+ byte b = src[sp++];
+ if (b >= 0)
+ dst[dp++] = (char)b;
+ else
+ dst[dp++] = repl;
+ }
+ return dp;
+ }
}
- private static class Encoder extends CharsetEncoder {
+ private static class Encoder extends CharsetEncoder
+ implements ArrayEncoder {
private Encoder(Charset cs) {
super(cs, 1.0f, 1.0f);
@@ -143,8 +159,11 @@
return c < 0x80;
}
+ public boolean isLegalReplacement(byte[] repl) {
+ return (repl.length == 1 && repl[0] >= 0);
+ }
+
private final Surrogate.Parser sgp = new Surrogate.Parser();
-
private CoderResult encodeArrayLoop(CharBuffer src,
ByteBuffer dst)
{
@@ -213,6 +232,32 @@
return encodeBufferLoop(src, dst);
}
+ private byte repl = (byte)'?';
+ protected void implReplaceWith(byte[] newReplacement) {
+ repl = newReplacement[0];
+ }
+
+ public int encode(char[] src, int sp, int len, byte[] dst) {
+ int dp = 0;
+ int sl = sp + Math.min(len, dst.length);
+ while (sp < sl) {
+ char c = src[sp++];
+ if (c < 0x80) {
+ dst[dp++] = (byte)c;
+ continue;
+ }
+ if (Surrogate.isHigh(c) && sp < sl &&
+ Surrogate.isLow(src[sp])) {
+ if (len > dst.length) {
+ sl++;
+ len--;
+ }
+ sp++;
+ }
+ dst[dp++] = repl;
+ }
+ return dp;
+ }
}
}
diff -r 21c83ff61827 -r caf47ebdd810 jdk/src/share/classes/sun/security/jgss/spnego/NegTokenInit.java
--- a/jdk/src/share/classes/sun/security/jgss/spnego/NegTokenInit.java Fri Mar 27 14:11:45 2009 -0700
+++ b/jdk/src/share/classes/sun/security/jgss/spnego/NegTokenInit.java Tue Mar 31 08:53:40 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -66,11 +66,11 @@
private byte[] mechTypes = null;
private Oid[] mechTypeList = null;
- private byte[] reqFlags = null;
+ private BitArray reqFlags = null;
private byte[] mechToken = null;
private byte[] mechListMIC = null;
- NegTokenInit(byte[] mechTypes, byte[] flags,
+ NegTokenInit(byte[] mechTypes, BitArray flags,
byte[] token, byte[] mechListMIC)
{
super(NEG_TOKEN_INIT_ID);
@@ -101,7 +101,7 @@
// write context flags with CONTEXT 01
if (reqFlags != null) {
DerOutputStream flags = new DerOutputStream();
- flags.putBitString(reqFlags);
+ flags.putUnalignedBitString(reqFlags);
initToken.write(DerValue.createTag(DerValue.TAG_CONTEXT,
true, (byte) 0x01), flags);
}
@@ -237,7 +237,7 @@
return mechTypeList;
}
- byte[] getReqFlags() {
+ BitArray getReqFlags() {
return reqFlags;
}
diff -r 21c83ff61827 -r caf47ebdd810 jdk/src/share/classes/sun/security/jgss/spnego/SpNegoContext.java
--- a/jdk/src/share/classes/sun/security/jgss/spnego/SpNegoContext.java Fri Mar 27 14:11:45 2009 -0700
+++ b/jdk/src/share/classes/sun/security/jgss/spnego/SpNegoContext.java Tue Mar 31 08:53:40 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2005-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -53,13 +53,6 @@
private int state = STATE_NEW;
- private static final int CHECKSUM_DELEG_FLAG = 1;
- private static final int CHECKSUM_MUTUAL_FLAG = 2;
- private static final int CHECKSUM_REPLAY_FLAG = 4;
- private static final int CHECKSUM_SEQUENCE_FLAG = 8;
- private static final int CHECKSUM_CONF_FLAG = 16;
- private static final int CHECKSUM_INTEG_FLAG = 32;
-
/*
* Optional features that the application can set and their default
* values.
@@ -697,25 +690,17 @@
/**
* get the context flags
*/
- private byte[] getContextFlags() {
- int flags = 0;
+ private BitArray getContextFlags() {
+ BitArray out = new BitArray(7);
- if (getCredDelegState())
- flags |= CHECKSUM_DELEG_FLAG;
- if (getMutualAuthState())
- flags |= CHECKSUM_MUTUAL_FLAG;
- if (getReplayDetState())
- flags |= CHECKSUM_REPLAY_FLAG;
- if (getSequenceDetState())
- flags |= CHECKSUM_SEQUENCE_FLAG;
- if (getIntegState())
- flags |= CHECKSUM_INTEG_FLAG;
- if (getConfState())
- flags |= CHECKSUM_CONF_FLAG;
+ if (getCredDelegState()) out.set(0, true);
+ if (getMutualAuthState()) out.set(1, true);
+ if (getReplayDetState()) out.set(2, true);
+ if (getSequenceDetState()) out.set(3, true);
+ if (getConfState()) out.set(5, true);
+ if (getIntegState()) out.set(6, true);
- byte[] temp = new byte[1];
- temp[0] = (byte)(flags & 0xff);
- return temp;
+ return out;
}
private void setContextFlags() {
diff -r 21c83ff61827 -r caf47ebdd810 jdk/src/share/classes/sun/security/provider/certpath/OCSPResponse.java
--- a/jdk/src/share/classes/sun/security/provider/certpath/OCSPResponse.java Fri Mar 27 14:11:45 2009 -0700
+++ b/jdk/src/share/classes/sun/security/provider/certpath/OCSPResponse.java Tue Mar 31 08:53:40 2009 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright 2003-2008 Sun Microsystems, Inc. All Rights Reserved.
+ * Copyright 2003-2009 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,8 +28,6 @@
import java.io.*;
import java.math.BigInteger;
import java.security.*;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateFactory;
import java.security.cert.CertPathValidatorException;
import java.security.cert.CRLReason;
import java.security.cert.X509Certificate;
@@ -335,7 +333,7 @@
// Check whether the cert returned by the responder is trusted
if (x509Certs != null && x509Certs[0] != null) {
- X509Certificate cert = x509Certs[0];
+ X509CertImpl cert = x509Certs[0];
// First check if the cert matches the responder cert which
// was set locally.
@@ -344,8 +342,8 @@
// Next check if the cert was issued by the responder cert
// which was set locally.
- } else if (cert.getIssuerDN().equals(
- responderCert.getSubjectDN())) {
+ } else if (cert.getIssuerX500Principal().equals(
+ responderCert.getSubjectX500Principal())) {
// Check for the OCSPSigning key purpose
List+ * A CA may specify that an OCSP client can trust a responder for the + * lifetime of the responder's certificate. The CA does so by including + * the extension id-pkix-ocsp-nocheck. This SHOULD be a non-critical + * extension. The value of the extension should be NULL. CAs issuing + * such a certificate should realized that a compromise of the + * responder's key, is as serious as the compromise of a CA key used to + * sign CRLs, at least for the validity period of this certificate. CA's + * may choose to issue this type of certificate with a very short + * lifetime and renew it frequently. + *
+ * id-pkix-ocsp-nocheck OBJECT IDENTIFIER ::= { id-pkix-ocsp 5 } + *+ * + * @author Xuelei Fan + * @see Extension + * @see CertAttrSet + */ +public class OCSPNoCheckExtension extends Extension + implements CertAttrSet