mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
8372950: Pem.pemEncoded should cache the Pattern
Reviewed-by: ascarpino
This commit is contained in:
parent
5df183be6c
commit
532a0a65b1
@ -59,6 +59,9 @@ public class Pem {
|
|||||||
// Pattern matching for stripping whitespace.
|
// Pattern matching for stripping whitespace.
|
||||||
private static final Pattern STRIP_WHITESPACE_PATTERN;
|
private static final Pattern STRIP_WHITESPACE_PATTERN;
|
||||||
|
|
||||||
|
// Pattern matching for inserting line breaks.
|
||||||
|
private static final Pattern LINE_WRAP_64_PATTERN;
|
||||||
|
|
||||||
// Lazy initialized PBES2 OID value
|
// Lazy initialized PBES2 OID value
|
||||||
private static ObjectIdentifier PBES2OID;
|
private static ObjectIdentifier PBES2OID;
|
||||||
|
|
||||||
@ -72,6 +75,7 @@ public class Pem {
|
|||||||
PBE_PATTERN = Pattern.compile("^PBEWith.*And.*",
|
PBE_PATTERN = Pattern.compile("^PBEWith.*And.*",
|
||||||
Pattern.CASE_INSENSITIVE);
|
Pattern.CASE_INSENSITIVE);
|
||||||
STRIP_WHITESPACE_PATTERN = Pattern.compile("\\s+");
|
STRIP_WHITESPACE_PATTERN = Pattern.compile("\\s+");
|
||||||
|
LINE_WRAP_64_PATTERN = Pattern.compile("(.{64})");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String CERTIFICATE = "CERTIFICATE";
|
public static final String CERTIFICATE = "CERTIFICATE";
|
||||||
@ -359,7 +363,7 @@ public class Pem {
|
|||||||
* @return PEM in a string
|
* @return PEM in a string
|
||||||
*/
|
*/
|
||||||
public static String pemEncoded(PEM pem) {
|
public static String pemEncoded(PEM pem) {
|
||||||
String p = pem.content().replaceAll("(.{64})", "$1\r\n");
|
String p = LINE_WRAP_64_PATTERN.matcher(pem.content()).replaceAll("$1\r\n");
|
||||||
return pemEncoded(pem.type(), p);
|
return pemEncoded(pem.type(), p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user