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 --git a/jdk/src/share/classes/sun/misc/JavaIOAccess.java b/jdk/src/share/classes/sun/misc/JavaIOAccess.java
index 2a076a9d84de8d71659023dd94af4a53eaa61bac..f0b50a8ac4e3dd8343cb5cadb8fd20dd9c0faf7e 100644
--- a/jdk/src/share/classes/sun/misc/JavaIOAccess.java
+++ b/jdk/src/share/classes/sun/misc/JavaIOAccess.java
@@ -29,6 +29,5 @@ import java.nio.charset.Charset;
public interface JavaIOAccess {
public Console console();
- public Runnable consoleRestoreHook();
public Charset charset();
}
diff --git a/jdk/src/share/classes/sun/misc/JavaLangAccess.java b/jdk/src/share/classes/sun/misc/JavaLangAccess.java
index 7c1cc55032f7e9431d7fbe17554fba478c857897..c288bc8402f04f7af27fb967b0d4830c6cdacde3 100644
--- a/jdk/src/share/classes/sun/misc/JavaLangAccess.java
+++ b/jdk/src/share/classes/sun/misc/JavaLangAccess.java
@@ -54,4 +54,7 @@ public interface JavaLangAccess {
/** Set thread's blocker field. */
void blockedOn(Thread t, Interruptible b);
+
+ /** register shutdown hook */
+ void registerShutdownHook(int slot, Runnable r);
}
diff --git a/jdk/src/share/classes/sun/misc/SharedSecrets.java b/jdk/src/share/classes/sun/misc/SharedSecrets.java
index 938e54c6c503a96fc788bc3260610545924332ae..16b5727c60444cf4999deeb3f917cb82639673bd 100644
--- a/jdk/src/share/classes/sun/misc/SharedSecrets.java
+++ b/jdk/src/share/classes/sun/misc/SharedSecrets.java
@@ -44,7 +44,6 @@ public class SharedSecrets {
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 @@ public class SharedSecrets {
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 --git a/jdk/src/share/classes/sun/misc/JavaIODeleteOnExitAccess.java b/jdk/src/share/classes/sun/nio/cs/ArrayDecoder.java
similarity index 81%
rename from jdk/src/share/classes/sun/misc/JavaIODeleteOnExitAccess.java
rename to jdk/src/share/classes/sun/nio/cs/ArrayDecoder.java
index 54aef8b428a76b6f3e0bb212c29a60b4379dbb72..daff5ec39d1744ef722b015c2fe72b4e75e206bb 100644
--- a/jdk/src/share/classes/sun/misc/JavaIODeleteOnExitAccess.java
+++ b/jdk/src/share/classes/sun/nio/cs/ArrayDecoder.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
+ * 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
@@ -23,8 +23,13 @@
* have any questions.
*/
-package sun.misc;
+package sun.nio.cs;
-public interface JavaIODeleteOnExitAccess extends Runnable {
- public void run();
+/*
+ * FastPath byte[]->char[] decoder, REPLACE on malformed or
+ * unmappable input.
+ */
+
+public interface ArrayDecoder {
+ int decode(byte[] src, int off, int len, char[] dst);
}
diff --git a/jdk/src/share/classes/sun/nio/cs/ArrayEncoder.java b/jdk/src/share/classes/sun/nio/cs/ArrayEncoder.java
new file mode 100644
index 0000000000000000000000000000000000000000..1eb4726f70b7ecc03962156d0dddb4ee10ba5ca8
--- /dev/null
+++ b/jdk/src/share/classes/sun/nio/cs/ArrayEncoder.java
@@ -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 --git a/jdk/src/share/classes/sun/nio/cs/ISO_8859_1.java b/jdk/src/share/classes/sun/nio/cs/ISO_8859_1.java
index ad27a1507ac3722db2533d99f0ad17e45e05a9cd..7eb3b5b8a833b661f2f958e8f6056e58e5f417bd 100644
--- a/jdk/src/share/classes/sun/nio/cs/ISO_8859_1.java
+++ b/jdk/src/share/classes/sun/nio/cs/ISO_8859_1.java
@@ -23,9 +23,6 @@
* have any questions.
*/
-/*
- */
-
package sun.nio.cs;
import java.nio.ByteBuffer;
@@ -34,10 +31,7 @@ import java.nio.charset.Charset;
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 @@ class ISO_8859_1
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 @@ class ISO_8859_1
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 @@ class ISO_8859_1
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 @@ class ISO_8859_1
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 --git a/jdk/src/share/classes/sun/nio/cs/SingleByte.java b/jdk/src/share/classes/sun/nio/cs/SingleByte.java
index fdbf4e3c6436234a523de587aaefd062d1fccb55..9b0531eebd93a90ce0978cdff65ca252f08f623e 100644
--- a/jdk/src/share/classes/sun/nio/cs/SingleByte.java
+++ b/jdk/src/share/classes/sun/nio/cs/SingleByte.java
@@ -32,6 +32,7 @@ import java.nio.charset.Charset;
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 @@ public class SingleByte
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 @@ public class SingleByte
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 @@ public class SingleByte
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 @@ public class SingleByte
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 --git a/jdk/src/share/classes/sun/nio/cs/US_ASCII.java b/jdk/src/share/classes/sun/nio/cs/US_ASCII.java
index d22fa64e352446fdd73f4218fc9bdb32ac8a526d..fa718450768cb1f6609496f796e3cc23f9c5a6ac 100644
--- a/jdk/src/share/classes/sun/nio/cs/US_ASCII.java
+++ b/jdk/src/share/classes/sun/nio/cs/US_ASCII.java
@@ -31,10 +31,7 @@ import java.nio.charset.Charset;
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 @@ public class US_ASCII
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 @@ public class US_ASCII
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 @@ public class US_ASCII
return c < 0x80;
}
- private final Surrogate.Parser sgp = new Surrogate.Parser();
+ 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 @@ public class US_ASCII
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 --git a/jdk/src/share/classes/sun/security/jgss/spnego/NegTokenInit.java b/jdk/src/share/classes/sun/security/jgss/spnego/NegTokenInit.java
index 6003cdfaeabbce1225b14bf137807303746c6ba5..9bb77fd7a1d849a3c419cfe9a6671e20ee55095b 100644
--- a/jdk/src/share/classes/sun/security/jgss/spnego/NegTokenInit.java
+++ b/jdk/src/share/classes/sun/security/jgss/spnego/NegTokenInit.java
@@ -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 @@ public class NegTokenInit extends SpNegoToken {
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 @@ public class NegTokenInit extends SpNegoToken {
// 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 @@ public class NegTokenInit extends SpNegoToken {
return mechTypeList;
}
- byte[] getReqFlags() {
+ BitArray getReqFlags() {
return reqFlags;
}
diff --git a/jdk/src/share/classes/sun/security/jgss/spnego/SpNegoContext.java b/jdk/src/share/classes/sun/security/jgss/spnego/SpNegoContext.java
index 7185b0e08a720a7ce66fd045111a1094f50e5d66..a84e8a260015b125f6ca3a6f142b9e5def545ca6 100644
--- a/jdk/src/share/classes/sun/security/jgss/spnego/SpNegoContext.java
+++ b/jdk/src/share/classes/sun/security/jgss/spnego/SpNegoContext.java
@@ -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 @@ public class SpNegoContext implements GSSContextSpi {
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 @@ public class SpNegoContext implements GSSContextSpi {
/**
* get the context flags
*/
- private byte[] getContextFlags() {
- int flags = 0;
-
- 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;
-
- byte[] temp = new byte[1];
- temp[0] = (byte)(flags & 0xff);
- return temp;
+ private BitArray getContextFlags() {
+ BitArray out = new BitArray(7);
+
+ 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);
+
+ return out;
}
private void setContextFlags() {
diff --git a/jdk/src/share/classes/sun/security/provider/certpath/OCSPResponse.java b/jdk/src/share/classes/sun/security/provider/certpath/OCSPResponse.java
index 20bac34f2ccfaa6b098730c466b92703f21961a1..62cd4288ed00f1a58dd65dc80c6fca51ce326564 100644
--- a/jdk/src/share/classes/sun/security/provider/certpath/OCSPResponse.java
+++ b/jdk/src/share/classes/sun/security/provider/certpath/OCSPResponse.java
@@ -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 @@ package sun.security.provider.certpath;
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 @@ class OCSPResponse {
// 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 @@ class OCSPResponse {
// 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