< prev index next >
src/share/classes/sun/security/provider/X509Factory.java
Print this page
rev 1463 : 6535697: keytool can be more flexible on format of PEM-encoded X.509 certificates
Reviewed-by: vinnie
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1998, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2009, 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
@@ -636,14 +636,19 @@
new BufferedReader(new InputStreamReader(bufin, "ASCII"));
// First read all of the data that is found between
// the "-----BEGIN" and "-----END" boundaries into a buffer.
String temp;
- if ((temp=readLine(br))==null || !temp.startsWith("-----BEGIN")) {
+ while (true) {
+ temp=readLine(br);
+ if (temp == null) {
throw new IOException("Unsupported encoding");
- } else {
+ }
len += temp.length();
+ if (temp.startsWith("-----BEGIN")) {
+ break;
+ }
}
StringBuffer strBuf = new StringBuffer();
while ((temp=readLine(br))!=null && !temp.startsWith("-----END")) {
strBuf.append(temp);
}
@@ -681,26 +686,15 @@
/*
* Determines if input is binary or Base64 encoded.
*/
private boolean isBase64(InputStream is) throws IOException {
- if (is.available() >= 10) {
- is.mark(10);
+ if (is.available() >= 1) {
+ is.mark(1);
int c1 = is.read();
- int c2 = is.read();
- int c3 = is.read();
- int c4 = is.read();
- int c5 = is.read();
- int c6 = is.read();
- int c7 = is.read();
- int c8 = is.read();
- int c9 = is.read();
- int c10 = is.read();
is.reset();
- if (c1 == '-' && c2 == '-' && c3 == '-' && c4 == '-'
- && c5 == '-' && c6 == 'B' && c7 == 'E' && c8 == 'G'
- && c9 == 'I' && c10 == 'N') {
+ if (c1 != DerValue.tag_Sequence) {
return true;
} else {
return false;
}
} else {
< prev index next >