mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8233884: Avoid looking up standard charsets in security libraries
Reviewed-by: coffeys
This commit is contained in:
parent
301e068935
commit
8e859259bc
48 changed files with 317 additions and 391 deletions
|
@ -27,9 +27,12 @@ package sun.security.util;
|
|||
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Date;
|
||||
import java.util.Vector;
|
||||
import java.math.BigInteger;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.*;
|
||||
|
||||
/**
|
||||
* A DER input stream, used for parsing ASN.1 DER-encoded data such as
|
||||
|
@ -457,7 +460,7 @@ public class DerInputStream {
|
|||
* Read a string that was encoded as a UTF8String DER value.
|
||||
*/
|
||||
public String getUTF8String() throws IOException {
|
||||
return readString(DerValue.tag_UTF8String, "UTF-8", "UTF8");
|
||||
return readString(DerValue.tag_UTF8String, "UTF-8", UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -465,7 +468,7 @@ public class DerInputStream {
|
|||
*/
|
||||
public String getPrintableString() throws IOException {
|
||||
return readString(DerValue.tag_PrintableString, "Printable",
|
||||
"ASCII");
|
||||
US_ASCII);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -475,22 +478,21 @@ public class DerInputStream {
|
|||
/*
|
||||
* Works for common characters between T61 and ASCII.
|
||||
*/
|
||||
return readString(DerValue.tag_T61String, "T61", "ISO-8859-1");
|
||||
return readString(DerValue.tag_T61String, "T61", ISO_8859_1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a string that was encoded as a IA5tring DER value.
|
||||
* Read a string that was encoded as a IA5String DER value.
|
||||
*/
|
||||
public String getIA5String() throws IOException {
|
||||
return readString(DerValue.tag_IA5String, "IA5", "ASCII");
|
||||
return readString(DerValue.tag_IA5String, "IA5", US_ASCII);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read a string that was encoded as a BMPString DER value.
|
||||
*/
|
||||
public String getBMPString() throws IOException {
|
||||
return readString(DerValue.tag_BMPString, "BMP",
|
||||
"UnicodeBigUnmarked");
|
||||
return readString(DerValue.tag_BMPString, "BMP", UTF_16BE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -498,7 +500,7 @@ public class DerInputStream {
|
|||
*/
|
||||
public String getGeneralString() throws IOException {
|
||||
return readString(DerValue.tag_GeneralString, "General",
|
||||
"ASCII");
|
||||
US_ASCII);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -510,7 +512,7 @@ public class DerInputStream {
|
|||
* correspond to the stringTag above.
|
||||
*/
|
||||
private String readString(byte stringTag, String stringName,
|
||||
String enc) throws IOException {
|
||||
Charset charset) throws IOException {
|
||||
|
||||
if (buffer.read() != stringTag)
|
||||
throw new IOException("DER input not a " +
|
||||
|
@ -522,7 +524,7 @@ public class DerInputStream {
|
|||
throw new IOException("Short read of DER " +
|
||||
stringName + " string");
|
||||
|
||||
return new String(retval, enc);
|
||||
return new String(retval, charset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue