diff options
38 files changed, 306 insertions, 487 deletions
diff --git a/luni/src/main/java/java/net/URLConnection.java b/luni/src/main/java/java/net/URLConnection.java index 403c48b..e9d7ff7 100644 --- a/luni/src/main/java/java/net/URLConnection.java +++ b/luni/src/main/java/java/net/URLConnection.java @@ -797,15 +797,15 @@ public abstract class URLConnection { * @return the string to be parsed */ private String parseTypeString(String typeString) { - StringBuilder typeStringBuffer = new StringBuilder(typeString); - for (int i = 0; i < typeStringBuffer.length(); i++) { + StringBuilder result = new StringBuilder(typeString); + for (int i = 0; i < result.length(); i++) { // if non-alphanumeric, replace it with '_' - char c = typeStringBuffer.charAt(i); + char c = result.charAt(i); if (!(Character.isLetter(c) || Character.isDigit(c) || c == '.')) { - typeStringBuffer.setCharAt(i, '_'); + result.setCharAt(i, '_'); } } - return typeStringBuffer.toString(); + return result.toString(); } /** diff --git a/luni/src/main/java/org/apache/harmony/security/x501/AttributeTypeAndValue.java b/luni/src/main/java/org/apache/harmony/security/x501/AttributeTypeAndValue.java index 96e3df5..89f5b3e 100644 --- a/luni/src/main/java/org/apache/harmony/security/x501/AttributeTypeAndValue.java +++ b/luni/src/main/java/org/apache/harmony/security/x501/AttributeTypeAndValue.java @@ -228,31 +228,30 @@ public final class AttributeTypeAndValue { * Appends AttributeTypeAndValue string representation * * @param attrFormat - format of DN - * @param buf - string buffer to be used */ - public void appendName(String attrFormat, StringBuffer buf) { + public void appendName(String attrFormat, StringBuilder sb) { boolean hexFormat = false; if (X500Principal.RFC1779.equals(attrFormat)) { if (RFC1779_NAMES == oid.getGroup()) { - buf.append(oid.getName()); + sb.append(oid.getName()); } else { - buf.append(oid.toOIDString()); + sb.append(oid.toOIDString()); } - buf.append('='); + sb.append('='); if (value.escapedString == value.getHexString()) { - buf.append(value.getHexString().toUpperCase(Locale.US)); + sb.append(value.getHexString().toUpperCase(Locale.US)); } else if (value.escapedString.length() != value.rawString.length()) { // was escaped - value.appendQEString(buf); + value.appendQEString(sb); } else { - buf.append(value.escapedString); + sb.append(value.escapedString); } } else { Object group = oid.getGroup(); // RFC2253 includes names from RFC1779 if (RFC1779_NAMES == group || RFC2253_NAMES == group) { - buf.append(oid.getName()); + sb.append(oid.getName()); if (X500Principal.CANONICAL.equals(attrFormat)) { // only PrintableString and UTF8String in string format @@ -267,19 +266,19 @@ public final class AttributeTypeAndValue { } } else { - buf.append(oid.toString()); + sb.append(oid.toString()); hexFormat = true; } - buf.append('='); + sb.append('='); if (hexFormat) { - buf.append(value.getHexString()); + sb.append(value.getHexString()); } else { if (X500Principal.CANONICAL.equals(attrFormat)) { - buf.append(value.makeCanonical()); + sb.append(value.makeCanonical()); } else { - buf.append(value.escapedString); + sb.append(value.escapedString); } } } diff --git a/luni/src/main/java/org/apache/harmony/security/x501/AttributeValue.java b/luni/src/main/java/org/apache/harmony/security/x501/AttributeValue.java index 3b9226c..2369d0f 100644 --- a/luni/src/main/java/org/apache/harmony/security/x501/AttributeValue.java +++ b/luni/src/main/java/org/apache/harmony/security/x501/AttributeValue.java @@ -25,8 +25,6 @@ package org.apache.harmony.security.x501; import java.io.IOException; import org.apache.harmony.security.asn1.ASN1StringType; import org.apache.harmony.security.asn1.DerInputStream; -import org.apache.harmony.security.x509.Utils; - /** * X.501 Attribute Value @@ -99,13 +97,30 @@ public final class AttributeValue { } } + /** + * Checks if the string is PrintableString (see X.680) + */ + private static boolean isPrintableString(String str) { + for (int i = 0; i< str.length(); ++i) { + char ch = str.charAt(i); + if (!(ch == 0x20 + || ch >= 0x27 && ch<= 0x29 // '() + || ch >= 0x2B && ch<= 0x3A // +,-./0-9: + || ch == '=' + || ch == '?' + || ch >= 'A' && ch<= 'Z' + || ch >= 'a' && ch<= 'z')) { + return false; + } + } + return true; + } + public int getTag() { if (tag == -1) { - if (Utils.isPrintableString(rawString)) { - tag = ASN1StringType.PRINTABLESTRING.id; - } else { - tag = ASN1StringType.UTF8STRING.id; - } + tag = isPrintableString(rawString) + ? ASN1StringType.PRINTABLESTRING.id + : ASN1StringType.UTF8STRING.id; } return tag; } @@ -114,11 +129,9 @@ public final class AttributeValue { if (hexString == null) { if (!wasEncoded) { //FIXME optimize me: what about reusable OutputStream??? - if (Utils.isPrintableString(rawString)) { - encoded = ASN1StringType.PRINTABLESTRING.encode(rawString); - } else { - encoded = ASN1StringType.UTF8STRING.encode(rawString); - } + encoded = isPrintableString(rawString) + ? ASN1StringType.PRINTABLESTRING.encode(rawString) + : ASN1StringType.UTF8STRING.encode(rawString); } StringBuilder buf = new StringBuilder(encoded.length * 2 + 1); @@ -144,21 +157,21 @@ public final class AttributeValue { return hexString; } - public void appendQEString(StringBuffer buf) { - buf.append('"'); + public void appendQEString(StringBuilder sb) { + sb.append('"'); if (hasQE) { char c; for (int i = 0; i < rawString.length(); i++) { c = rawString.charAt(i); if (c == '"' || c == '\\') { - buf.append('\\'); + sb.append('\\'); } - buf.append(c); + sb.append(c); } } else { - buf.append(rawString); + sb.append(rawString); } - buf.append('"'); + sb.append('"'); } /** diff --git a/luni/src/main/java/org/apache/harmony/security/x501/Name.java b/luni/src/main/java/org/apache/harmony/security/x501/Name.java index 40ef852..54ef4ef 100644 --- a/luni/src/main/java/org/apache/harmony/security/x501/Name.java +++ b/luni/src/main/java/org/apache/harmony/security/x501/Name.java @@ -166,7 +166,7 @@ public final class Name { * the format requested, format is int value */ private String getName0(String format) { - StringBuffer name = new StringBuffer(); + StringBuilder name = new StringBuilder(); // starting with the last element and moving to the first. for (int i = rdn.size() - 1; i >= 0; i--) { diff --git a/luni/src/main/java/org/apache/harmony/security/x509/AlgorithmIdentifier.java b/luni/src/main/java/org/apache/harmony/security/x509/AlgorithmIdentifier.java index f0fa49f..0333ed9 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/AlgorithmIdentifier.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/AlgorithmIdentifier.java @@ -125,18 +125,15 @@ public final class AlgorithmIdentifier { return algorithm.hashCode() * 37 + (parameters != null ? parameters.hashCode() : 0); } - /** - * Places the string representation into the StringBuffer object. - */ - public void dumpValue(StringBuffer buffer) { - buffer.append(getAlgorithmName()); + public void dumpValue(StringBuilder sb) { + sb.append(getAlgorithmName()); if (parameters == null) { - buffer.append(", no params, "); + sb.append(", no params, "); } else { - buffer.append(", params unparsed, "); + sb.append(", params unparsed, "); } - buffer.append("OID = "); - buffer.append(getAlgorithm()); + sb.append("OID = "); + sb.append(getAlgorithm()); } /** diff --git a/luni/src/main/java/org/apache/harmony/security/x509/AlternativeName.java b/luni/src/main/java/org/apache/harmony/security/x509/AlternativeName.java index 48e4376..f46e7d0 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/AlternativeName.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/AlternativeName.java @@ -59,15 +59,9 @@ public final class AlternativeName extends ExtensionValue { return encoding; } - /** - * Places the string representation of extension value - * into the StringBuffer object. - */ - @Override public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append(prefix).append((which) ? "Subject" : "Issuer") - .append(" Alternative Names [\n"); - alternativeNames.dumpValue(buffer, prefix + " "); - buffer.append(prefix).append("]\n"); + @Override public void dumpValue(StringBuilder sb, String prefix) { + sb.append(prefix).append((which) ? "Subject" : "Issuer").append(" Alternative Names [\n"); + alternativeNames.dumpValue(sb, prefix + " "); + sb.append(prefix).append("]\n"); } } - diff --git a/luni/src/main/java/org/apache/harmony/security/x509/AuthorityKeyIdentifier.java b/luni/src/main/java/org/apache/harmony/security/x509/AuthorityKeyIdentifier.java index 381c2b2..be43ba7 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/AuthorityKeyIdentifier.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/AuthorityKeyIdentifier.java @@ -77,26 +77,22 @@ public final class AuthorityKeyIdentifier extends ExtensionValue { return encoding; } - /** - * Places the string representation of extension value - * into the StringBuffer object. - */ - @Override public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append(prefix).append("AuthorityKeyIdentifier [\n"); + @Override public void dumpValue(StringBuilder sb, String prefix) { + sb.append(prefix).append("AuthorityKeyIdentifier [\n"); if (keyIdentifier != null) { - buffer.append(prefix).append(" keyIdentifier:\n"); - buffer.append(Array.toString(keyIdentifier, prefix + " ")); + sb.append(prefix).append(" keyIdentifier:\n"); + sb.append(Array.toString(keyIdentifier, prefix + " ")); } if (authorityCertIssuer != null) { - buffer.append(prefix).append(" authorityCertIssuer: [\n"); - authorityCertIssuer.dumpValue(buffer, prefix + " "); - buffer.append(prefix).append(" ]\n"); + sb.append(prefix).append(" authorityCertIssuer: [\n"); + authorityCertIssuer.dumpValue(sb, prefix + " "); + sb.append(prefix).append(" ]\n"); } if (authorityCertSerialNumber != null) { - buffer.append(prefix).append(" authorityCertSerialNumber: ") - .append(authorityCertSerialNumber).append('\n'); + sb.append(prefix).append(" authorityCertSerialNumber: "); + sb.append(authorityCertSerialNumber).append('\n'); } - buffer.append(prefix).append("]\n"); + sb.append(prefix).append("]\n"); } public static final ASN1Type ASN1 = new ASN1Sequence( @@ -134,4 +130,3 @@ public final class AuthorityKeyIdentifier extends ExtensionValue { } }; } - diff --git a/luni/src/main/java/org/apache/harmony/security/x509/BasicConstraints.java b/luni/src/main/java/org/apache/harmony/security/x509/BasicConstraints.java index ccb8d10..6a473f5 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/BasicConstraints.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/BasicConstraints.java @@ -72,12 +72,8 @@ public final class BasicConstraints extends ExtensionValue { return encoding; } - /** - * Places the string representation of extension value - * into the StringBuffer object. - */ - public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append(prefix).append("BasicConstraints [\n").append(prefix) + public void dumpValue(StringBuilder sb, String prefix) { + sb.append(prefix).append("BasicConstraints [\n").append(prefix) .append(" CA: ").append(ca) .append("\n ").append(prefix).append("pathLenConstraint: ") .append(pathLenConstraint).append('\n').append(prefix) diff --git a/luni/src/main/java/org/apache/harmony/security/x509/CRLDistributionPoints.java b/luni/src/main/java/org/apache/harmony/security/x509/CRLDistributionPoints.java index b3db0c5..5080add 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/CRLDistributionPoints.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/CRLDistributionPoints.java @@ -87,18 +87,14 @@ public final class CRLDistributionPoints extends ExtensionValue { return (CRLDistributionPoints) ASN1.decode(encoding); } - /** - * Places the string representation of extension value - * into the StringBuffer object. - */ - @Override public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append(prefix).append("CRL Distribution Points: [\n"); + @Override public void dumpValue(StringBuilder sb, String prefix) { + sb.append(prefix).append("CRL Distribution Points: [\n"); int number = 0; for (DistributionPoint distributionPoint : distributionPoints) { - buffer.append(prefix).append(" [").append(++number).append("]\n"); - distributionPoint.dumpValue(buffer, prefix + " "); + sb.append(prefix).append(" [").append(++number).append("]\n"); + distributionPoint.dumpValue(sb, prefix + " "); } - buffer.append(prefix).append("]\n"); + sb.append(prefix).append("]\n"); } /** diff --git a/luni/src/main/java/org/apache/harmony/security/x509/CRLNumber.java b/luni/src/main/java/org/apache/harmony/security/x509/CRLNumber.java index 5396bea..0038068 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/CRLNumber.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/CRLNumber.java @@ -62,12 +62,8 @@ public final class CRLNumber extends ExtensionValue { return encoding; } - /** - * Places the string representation of extension value - * into the StringBuffer object. - */ - @Override public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append(prefix).append("CRL Number: [ ").append(number).append(" ]\n"); + @Override public void dumpValue(StringBuilder sb, String prefix) { + sb.append(prefix).append("CRL Number: [ ").append(number).append(" ]\n"); } /** diff --git a/luni/src/main/java/org/apache/harmony/security/x509/Certificate.java b/luni/src/main/java/org/apache/harmony/security/x509/Certificate.java index 5edf8d5..d4bb29e 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/Certificate.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/Certificate.java @@ -87,16 +87,16 @@ public final class Certificate { } @Override public String toString() { - StringBuffer buffer = new StringBuffer(); - buffer.append("X.509 Certificate:\n[\n"); - tbsCertificate.dumpValue(buffer); - buffer.append("\n Algorithm: ["); - signatureAlgorithm.dumpValue(buffer); - buffer.append(']'); - buffer.append("\n Signature Value:\n"); - buffer.append(Array.toString(signatureValue, "")); - buffer.append(']'); - return buffer.toString(); + StringBuilder result = new StringBuilder(); + result.append("X.509 Certificate:\n[\n"); + tbsCertificate.dumpValue(result); + result.append("\n Algorithm: ["); + signatureAlgorithm.dumpValue(result); + result.append(']'); + result.append("\n Signature Value:\n"); + result.append(Array.toString(signatureValue, "")); + result.append(']'); + return result.toString(); } /** @@ -133,4 +133,3 @@ public final class Certificate { } }; } - diff --git a/luni/src/main/java/org/apache/harmony/security/x509/CertificateIssuer.java b/luni/src/main/java/org/apache/harmony/security/x509/CertificateIssuer.java index 3f37114..544ff8e 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/CertificateIssuer.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/CertificateIssuer.java @@ -55,22 +55,18 @@ public final class CertificateIssuer extends ExtensionValue { return issuer; } - /** - * Places the string representation of extension value - * into the StringBuffer object. - */ - @Override public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append(prefix).append("Certificate Issuer: "); + @Override public void dumpValue(StringBuilder sb, String prefix) { + sb.append(prefix).append("Certificate Issuer: "); if (issuer == null) { try { issuer = getIssuer(); } catch (IOException e) { // incorrect extension value encoding - buffer.append("Unparseable (incorrect!) extension value:\n"); - super.dumpValue(buffer); + sb.append("Unparseable (incorrect!) extension value:\n"); + super.dumpValue(sb); } } - buffer.append(issuer).append('\n'); + sb.append(issuer).append('\n'); } /** diff --git a/luni/src/main/java/org/apache/harmony/security/x509/CertificateList.java b/luni/src/main/java/org/apache/harmony/security/x509/CertificateList.java index f588ef5..85d8789 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/CertificateList.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/CertificateList.java @@ -89,11 +89,11 @@ public final class CertificateList { } @Override public String toString() { - StringBuffer res = new StringBuffer(); - tbsCertList.dumpValue(res); - res.append("\nSignature Value:\n"); - res.append(Array.toString(signatureValue, "")); - return res.toString(); + StringBuilder result = new StringBuilder(); + tbsCertList.dumpValue(result); + result.append("\nSignature Value:\n"); + result.append(Array.toString(signatureValue, "")); + return result.toString(); } /** @@ -132,4 +132,3 @@ public final class CertificateList { } }; } - diff --git a/luni/src/main/java/org/apache/harmony/security/x509/CertificatePolicies.java b/luni/src/main/java/org/apache/harmony/security/x509/CertificatePolicies.java index 90bc3a3..5f2959a 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/CertificatePolicies.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/CertificatePolicies.java @@ -90,19 +90,15 @@ public final class CertificatePolicies extends ExtensionValue { return encoding; } - /** - * Places the string representation of extension value - * into the StringBuffer object. - */ - @Override public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append(prefix).append("CertificatePolicies [\n"); + @Override public void dumpValue(StringBuilder sb, String prefix) { + sb.append(prefix).append("CertificatePolicies [\n"); for (PolicyInformation policyInformation : policyInformations) { - buffer.append(prefix); - buffer.append(" "); - policyInformation.dumpValue(buffer); - buffer.append('\n'); + sb.append(prefix); + sb.append(" "); + policyInformation.dumpValue(sb); + sb.append('\n'); } - buffer.append(prefix).append("]\n"); + sb.append(prefix).append("]\n"); } /** @@ -119,4 +115,3 @@ public final class CertificatePolicies extends ExtensionValue { } }; } - diff --git a/luni/src/main/java/org/apache/harmony/security/x509/DistributionPoint.java b/luni/src/main/java/org/apache/harmony/security/x509/DistributionPoint.java index ce0644a..c82d4a0 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/DistributionPoint.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/DistributionPoint.java @@ -79,28 +79,24 @@ public final class DistributionPoint { this.cRLIssuer = cRLIssuer; } - /** - * Places the string representation of extension value - * into the StringBuffer object. - */ - public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append(prefix); - buffer.append("Distribution Point: [\n"); + public void dumpValue(StringBuilder sb, String prefix) { + sb.append(prefix); + sb.append("Distribution Point: [\n"); if (distributionPoint != null) { - distributionPoint.dumpValue(buffer, prefix + " "); + distributionPoint.dumpValue(sb, prefix + " "); } if (reasons != null) { - reasons.dumpValue(buffer, prefix + " "); + reasons.dumpValue(sb, prefix + " "); } if (cRLIssuer != null) { - buffer.append(prefix); - buffer.append(" CRL Issuer: [\n"); - cRLIssuer.dumpValue(buffer, prefix + " "); - buffer.append(prefix); - buffer.append(" ]\n"); + sb.append(prefix); + sb.append(" CRL Issuer: [\n"); + cRLIssuer.dumpValue(sb, prefix + " "); + sb.append(prefix); + sb.append(" ]\n"); } - buffer.append(prefix); - buffer.append("]\n"); + sb.append(prefix); + sb.append("]\n"); } /** diff --git a/luni/src/main/java/org/apache/harmony/security/x509/DistributionPointName.java b/luni/src/main/java/org/apache/harmony/security/x509/DistributionPointName.java index 72cf674..893c2ce 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/DistributionPointName.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/DistributionPointName.java @@ -80,23 +80,18 @@ public final class DistributionPointName { this.nameRelativeToCRLIssuer = nameRelativeToCRLIssuer; } - /** - * Places the string representation of extension value - * into the StringBuffer object. - */ - public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append(prefix); - buffer.append("Distribution Point Name: [\n"); + public void dumpValue(StringBuilder sb, String prefix) { + sb.append(prefix); + sb.append("Distribution Point Name: [\n"); if (fullName != null) { - fullName.dumpValue(buffer, prefix + " "); + fullName.dumpValue(sb, prefix + " "); } else { - buffer.append(prefix); - buffer.append(" "); - buffer.append(nameRelativeToCRLIssuer.getName( - X500Principal.RFC2253)); + sb.append(prefix); + sb.append(" "); + sb.append(nameRelativeToCRLIssuer.getName(X500Principal.RFC2253)); } - buffer.append(prefix); - buffer.append("]\n"); + sb.append(prefix); + sb.append("]\n"); } public static final ASN1Choice ASN1 = new ASN1Choice(new ASN1Type[] { @@ -130,4 +125,3 @@ public final class DistributionPointName { } }; } - diff --git a/luni/src/main/java/org/apache/harmony/security/x509/ExtendedKeyUsage.java b/luni/src/main/java/org/apache/harmony/security/x509/ExtendedKeyUsage.java index e75716d..9a91503 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/ExtendedKeyUsage.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/ExtendedKeyUsage.java @@ -70,25 +70,25 @@ public final class ExtendedKeyUsage extends ExtensionValue { return encoding; } - @Override public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append(prefix).append("Extended Key Usage: "); + @Override public void dumpValue(StringBuilder sb, String prefix) { + sb.append(prefix).append("Extended Key Usage: "); if (keys == null) { try { keys = getExtendedKeyUsage(); } catch (IOException e) { // incorrect extension value encoding - super.dumpValue(buffer); + super.dumpValue(sb); return; } } - buffer.append('['); + sb.append('['); for (Iterator<?> it = keys.iterator(); it.hasNext();) { - buffer.append(" \"").append(it.next()).append('"'); + sb.append(" \"").append(it.next()).append('"'); if (it.hasNext()) { - buffer.append(','); + sb.append(','); } } - buffer.append(" ]\n"); + sb.append(" ]\n"); } /** diff --git a/luni/src/main/java/org/apache/harmony/security/x509/Extension.java b/luni/src/main/java/org/apache/harmony/security/x509/Extension.java index 1a7502e..d0eb5c0 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/Extension.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/Extension.java @@ -286,12 +286,8 @@ public final class Extension { } } - /** - * Places the string representation into the StringBuffer object. - */ - public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append("OID: ").append(getExtnID()) - .append(", Critical: ").append(critical).append('\n'); + public void dumpValue(StringBuilder sb, String prefix) { + sb.append("OID: ").append(getExtnID()).append(", Critical: ").append(critical).append('\n'); if (!valueDecoded) { try { decodeExtensionValue(); @@ -299,57 +295,56 @@ public final class Extension { } } if (extnValueObject != null) { - extnValueObject.dumpValue(buffer, prefix); + extnValueObject.dumpValue(sb, prefix); return; } // else: dump unparsed hex representation - buffer.append(prefix); + sb.append(prefix); if (Arrays.equals(extnID, SUBJ_DIRECTORY_ATTRS)) { - buffer.append("Subject Directory Attributes Extension"); + sb.append("Subject Directory Attributes Extension"); } else if (Arrays.equals(extnID, SUBJ_KEY_ID)) { - buffer.append("Subject Key Identifier Extension"); + sb.append("Subject Key Identifier Extension"); } else if (Arrays.equals(extnID, KEY_USAGE)) { - buffer.append("Key Usage Extension"); + sb.append("Key Usage Extension"); } else if (Arrays.equals(extnID, PRIVATE_KEY_USAGE_PERIOD)) { - buffer.append("Private Key Usage Period Extension"); + sb.append("Private Key Usage Period Extension"); } else if (Arrays.equals(extnID, SUBJECT_ALT_NAME)) { - buffer.append("Subject Alternative Name Extension"); + sb.append("Subject Alternative Name Extension"); } else if (Arrays.equals(extnID, ISSUER_ALTERNATIVE_NAME)) { - buffer.append("Issuer Alternative Name Extension"); + sb.append("Issuer Alternative Name Extension"); } else if (Arrays.equals(extnID, BASIC_CONSTRAINTS)) { - buffer.append("Basic Constraints Extension"); + sb.append("Basic Constraints Extension"); } else if (Arrays.equals(extnID, NAME_CONSTRAINTS)) { - buffer.append("Name Constraints Extension"); + sb.append("Name Constraints Extension"); } else if (Arrays.equals(extnID, CRL_DISTR_POINTS)) { - buffer.append("CRL Distribution Points Extension"); + sb.append("CRL Distribution Points Extension"); } else if (Arrays.equals(extnID, CERTIFICATE_POLICIES)) { - buffer.append("Certificate Policies Extension"); + sb.append("Certificate Policies Extension"); } else if (Arrays.equals(extnID, POLICY_MAPPINGS)) { - buffer.append("Policy Mappings Extension"); + sb.append("Policy Mappings Extension"); } else if (Arrays.equals(extnID, AUTH_KEY_ID)) { - buffer.append("Authority Key Identifier Extension"); + sb.append("Authority Key Identifier Extension"); } else if (Arrays.equals(extnID, POLICY_CONSTRAINTS)) { - buffer.append("Policy Constraints Extension"); + sb.append("Policy Constraints Extension"); } else if (Arrays.equals(extnID, EXTENDED_KEY_USAGE)) { - buffer.append("Extended Key Usage Extension"); + sb.append("Extended Key Usage Extension"); } else if (Arrays.equals(extnID, INHIBIT_ANY_POLICY)) { - buffer.append("Inhibit Any-Policy Extension"); + sb.append("Inhibit Any-Policy Extension"); } else if (Arrays.equals(extnID, AUTHORITY_INFO_ACCESS)) { - buffer.append("Authority Information Access Extension"); + sb.append("Authority Information Access Extension"); } else if (Arrays.equals(extnID, SUBJECT_INFO_ACCESS)) { - buffer.append("Subject Information Access Extension"); + sb.append("Subject Information Access Extension"); } else if (Arrays.equals(extnID, INVALIDITY_DATE)) { - buffer.append("Invalidity Date Extension"); + sb.append("Invalidity Date Extension"); } else if (Arrays.equals(extnID, CRL_NUMBER)) { - buffer.append("CRL Number Extension"); + sb.append("CRL Number Extension"); } else if (Arrays.equals(extnID, REASON_CODE)) { - buffer.append("Reason Code Extension"); + sb.append("Reason Code Extension"); } else { - buffer.append("Unknown Extension"); + sb.append("Unknown Extension"); } - buffer.append('\n').append(prefix) - .append("Unparsed Extension Value:\n"); - buffer.append(Array.toString(extnValue, prefix)); + sb.append('\n').append(prefix).append("Unparsed Extension Value:\n"); + sb.append(Array.toString(extnValue, prefix)); } diff --git a/luni/src/main/java/org/apache/harmony/security/x509/ExtensionValue.java b/luni/src/main/java/org/apache/harmony/security/x509/ExtensionValue.java index a9abf32..62e9159 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/ExtensionValue.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/ExtensionValue.java @@ -40,28 +40,19 @@ public class ExtensionValue { return encoding; } - /** - * Places the string representation of extension value - * into the StringBuffer object. - */ - public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append(prefix).append("Unparseable extension value:\n"); + public void dumpValue(StringBuilder sb, String prefix) { + sb.append(prefix).append("Unparseable extension value:\n"); if (encoding == null) { encoding = getEncoded(); } if (encoding == null) { - buffer.append("NULL\n"); + sb.append("NULL\n"); } else { - buffer.append(Array.toString(encoding, prefix)); + sb.append(Array.toString(encoding, prefix)); } } - /** - * Places the string representation of extension value - * into the StringBuffer object. - */ - public void dumpValue(StringBuffer buffer) { - dumpValue(buffer, ""); + public void dumpValue(StringBuilder sb) { + dumpValue(sb, ""); } } - diff --git a/luni/src/main/java/org/apache/harmony/security/x509/Extensions.java b/luni/src/main/java/org/apache/harmony/security/x509/Extensions.java index 10c40f9..3336b0d 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/Extensions.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/Extensions.java @@ -329,18 +329,14 @@ public final class Extensions { return hashCode; } - /** - * Places the string representation into the StringBuffer object. - */ - public void dumpValue(StringBuffer buffer, String prefix) { + public void dumpValue(StringBuilder sb, String prefix) { if (extensions == null) { return; } int num = 1; for (Extension extension: extensions) { - buffer.append('\n').append(prefix) - .append('[').append(num++).append("]: "); - extension.dumpValue(buffer, prefix); + sb.append('\n').append(prefix).append('[').append(num++).append("]: "); + extension.dumpValue(sb, prefix); } } diff --git a/luni/src/main/java/org/apache/harmony/security/x509/GeneralNames.java b/luni/src/main/java/org/apache/harmony/security/x509/GeneralNames.java index 957380b..93c4af1 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/GeneralNames.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/GeneralNames.java @@ -107,18 +107,14 @@ public final class GeneralNames { return encoding; } - /** - * Places the string representation of extension value - * into the StringBuffer object. - */ - public void dumpValue(StringBuffer buffer, String prefix) { + public void dumpValue(StringBuilder sb, String prefix) { if (generalNames == null) { return; } for (GeneralName generalName : generalNames) { - buffer.append(prefix); - buffer.append(generalName); - buffer.append('\n'); + sb.append(prefix); + sb.append(generalName); + sb.append('\n'); } } diff --git a/luni/src/main/java/org/apache/harmony/security/x509/GeneralSubtree.java b/luni/src/main/java/org/apache/harmony/security/x509/GeneralSubtree.java index ce21634..42987b6 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/GeneralSubtree.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/GeneralSubtree.java @@ -83,20 +83,14 @@ public final class GeneralSubtree { return encoding; } - /** - * Places the string representation of extension value - * into the StringBuffer object. - */ - public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append(prefix).append("General Subtree: [\n"); - buffer.append(prefix).append(" base: ").append(base).append('\n'); - buffer.append(prefix).append(" minimum: ") - .append(minimum).append('\n'); + public void dumpValue(StringBuilder sb, String prefix) { + sb.append(prefix).append("General Subtree: [\n"); + sb.append(prefix).append(" base: ").append(base).append('\n'); + sb.append(prefix).append(" minimum: ").append(minimum).append('\n'); if (maximum >= 0) { - buffer.append(prefix).append(" maximum: ") - .append(maximum).append('\n'); + sb.append(prefix).append(" maximum: ").append(maximum).append('\n'); } - buffer.append(prefix).append("]\n"); + sb.append(prefix).append("]\n"); } /** diff --git a/luni/src/main/java/org/apache/harmony/security/x509/InfoAccessSyntax.java b/luni/src/main/java/org/apache/harmony/security/x509/InfoAccessSyntax.java index bf04391..cd0dd4d 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/InfoAccessSyntax.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/InfoAccessSyntax.java @@ -82,17 +82,13 @@ public final class InfoAccessSyntax extends ExtensionValue { return res.toString(); } - /** - * Places the string representation of extension value - * into the StringBuffer object. - */ - @Override public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append(prefix).append("AccessDescriptions:\n"); + @Override public void dumpValue(StringBuilder sb, String prefix) { + sb.append(prefix).append("AccessDescriptions:\n"); if (accessDescriptions == null || accessDescriptions.isEmpty()) { - buffer.append("NULL\n"); + sb.append("NULL\n"); } else { for (Object accessDescription : accessDescriptions) { - buffer.append(accessDescription.toString()); + sb.append(accessDescription.toString()); } } } diff --git a/luni/src/main/java/org/apache/harmony/security/x509/InhibitAnyPolicy.java b/luni/src/main/java/org/apache/harmony/security/x509/InhibitAnyPolicy.java index b80b446..b27471e 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/InhibitAnyPolicy.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/InhibitAnyPolicy.java @@ -58,13 +58,7 @@ public final class InhibitAnyPolicy extends ExtensionValue { return encoding; } - /** - * Places the string representation of extension value - * into the StringBuffer object. - */ - @Override public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append(prefix).append("Inhibit Any-Policy: ") - .append(skipCerts).append('\n'); + @Override public void dumpValue(StringBuilder sb, String prefix) { + sb.append(prefix).append("Inhibit Any-Policy: ").append(skipCerts).append('\n'); } } - diff --git a/luni/src/main/java/org/apache/harmony/security/x509/InvalidityDate.java b/luni/src/main/java/org/apache/harmony/security/x509/InvalidityDate.java index 8c8073c..b7c1847 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/InvalidityDate.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/InvalidityDate.java @@ -60,13 +60,8 @@ public final class InvalidityDate extends ExtensionValue { return encoding; } - /** - * Places the string representation of extension value - * into the StringBuffer object. - */ - @Override public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append(prefix).append("Invalidity Date: [ ") - .append(date).append(" ]\n"); + @Override public void dumpValue(StringBuilder sb, String prefix) { + sb.append(prefix).append("Invalidity Date: [ ").append(date).append(" ]\n"); } /** @@ -74,4 +69,3 @@ public final class InvalidityDate extends ExtensionValue { */ public static final ASN1Type ASN1 = ASN1GeneralizedTime.getInstance(); } - diff --git a/luni/src/main/java/org/apache/harmony/security/x509/IssuingDistributionPoint.java b/luni/src/main/java/org/apache/harmony/security/x509/IssuingDistributionPoint.java index 6c11616..17533a3 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/IssuingDistributionPoint.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/IssuingDistributionPoint.java @@ -107,26 +107,18 @@ public final class IssuingDistributionPoint extends ExtensionValue { return encoding; } - /** - * Places the string representation of extension value - * into the StringBuffer object. - */ - @Override public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append(prefix).append("Issuing Distribution Point: [\n"); + @Override public void dumpValue(StringBuilder sb, String prefix) { + sb.append(prefix).append("Issuing Distribution Point: [\n"); if (distributionPoint != null) { - distributionPoint.dumpValue(buffer, " " + prefix); + distributionPoint.dumpValue(sb, " " + prefix); } - buffer.append(prefix).append(" onlyContainsUserCerts: ") - .append(onlyContainsUserCerts).append('\n'); - buffer.append(prefix).append(" onlyContainsCACerts: ") - .append(onlyContainsCACerts).append('\n'); + sb.append(prefix).append(" onlyContainsUserCerts: ").append(onlyContainsUserCerts).append('\n'); + sb.append(prefix).append(" onlyContainsCACerts: ").append(onlyContainsCACerts).append('\n'); if (onlySomeReasons != null) { - onlySomeReasons.dumpValue(buffer, prefix + " "); + onlySomeReasons.dumpValue(sb, prefix + " "); } - buffer.append(prefix).append(" indirectCRL: ") - .append(indirectCRL).append('\n'); - buffer.append(prefix).append(" onlyContainsAttributeCerts: ") - .append(onlyContainsAttributeCerts).append('\n'); + sb.append(prefix).append(" indirectCRL: ").append(indirectCRL).append('\n'); + sb.append(prefix).append(" onlyContainsAttributeCerts: ").append(onlyContainsAttributeCerts).append('\n'); } /** @@ -183,4 +175,3 @@ public final class IssuingDistributionPoint extends ExtensionValue { }; } - diff --git a/luni/src/main/java/org/apache/harmony/security/x509/KeyUsage.java b/luni/src/main/java/org/apache/harmony/security/x509/KeyUsage.java index 02a71e2..c3cb165 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/KeyUsage.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/KeyUsage.java @@ -80,15 +80,14 @@ public final class KeyUsage extends ExtensionValue { return encoding; } - @Override public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append(prefix).append("KeyUsage [\n"); - for (int i=0; i<keyUsage.length; i++) { + @Override public void dumpValue(StringBuilder sb, String prefix) { + sb.append(prefix).append("KeyUsage [\n"); + for (int i = 0; i < keyUsage.length; i++) { if (keyUsage[i]) { - buffer.append(prefix).append(" ") - .append(USAGES[i]).append('\n'); + sb.append(prefix).append(" ").append(USAGES[i]).append('\n'); } } - buffer.append(prefix).append("]\n"); + sb.append(prefix).append("]\n"); } /** diff --git a/luni/src/main/java/org/apache/harmony/security/x509/NameConstraints.java b/luni/src/main/java/org/apache/harmony/security/x509/NameConstraints.java index e6f5812..ee7530c 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/NameConstraints.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/NameConstraints.java @@ -235,23 +235,23 @@ public final class NameConstraints extends ExtensionValue { return true; } - @Override public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append(prefix).append("Name Constraints: [\n"); + @Override public void dumpValue(StringBuilder sb, String prefix) { + sb.append(prefix).append("Name Constraints: [\n"); if (permittedSubtrees != null) { - buffer.append(prefix).append(" Permitted: [\n"); + sb.append(prefix).append(" Permitted: [\n"); for (GeneralSubtree generalSubtree : permittedSubtrees.getSubtrees()) { - generalSubtree.dumpValue(buffer, prefix + " "); + generalSubtree.dumpValue(sb, prefix + " "); } - buffer.append(prefix).append(" ]\n"); + sb.append(prefix).append(" ]\n"); } if (excludedSubtrees != null) { - buffer.append(prefix).append(" Excluded: [\n"); + sb.append(prefix).append(" Excluded: [\n"); for (GeneralSubtree generalSubtree : excludedSubtrees.getSubtrees()) { - generalSubtree.dumpValue(buffer, prefix + " "); + generalSubtree.dumpValue(sb, prefix + " "); } - buffer.append(prefix).append(" ]\n"); + sb.append(prefix).append(" ]\n"); } - buffer.append('\n').append(prefix).append("]\n"); + sb.append('\n').append(prefix).append("]\n"); } /** diff --git a/luni/src/main/java/org/apache/harmony/security/x509/PolicyConstraints.java b/luni/src/main/java/org/apache/harmony/security/x509/PolicyConstraints.java index e86a498..1c4d4f1 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/PolicyConstraints.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/PolicyConstraints.java @@ -90,21 +90,15 @@ public final class PolicyConstraints extends ExtensionValue { return encoding; } - /** - * Places the string representation of extension value - * into the StringBuffer object. - */ - @Override public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append(prefix).append("PolicyConstraints: [\n"); + @Override public void dumpValue(StringBuilder sb, String prefix) { + sb.append(prefix).append("PolicyConstraints: [\n"); if (requireExplicitPolicy != null) { - buffer.append(prefix).append(" requireExplicitPolicy: ") - .append(requireExplicitPolicy).append('\n'); + sb.append(prefix).append(" requireExplicitPolicy: ").append(requireExplicitPolicy).append('\n'); } if (inhibitPolicyMapping != null) { - buffer.append(prefix).append(" inhibitPolicyMapping: ") - .append(inhibitPolicyMapping).append('\n'); + sb.append(prefix).append(" inhibitPolicyMapping: ").append(inhibitPolicyMapping).append('\n'); } - buffer.append(prefix).append("]\n"); + sb.append(prefix).append("]\n"); } /** diff --git a/luni/src/main/java/org/apache/harmony/security/x509/PolicyInformation.java b/luni/src/main/java/org/apache/harmony/security/x509/PolicyInformation.java index 51ab57e..77bd0b1 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/PolicyInformation.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/PolicyInformation.java @@ -75,13 +75,8 @@ public final class PolicyInformation { return encoding; } - /** - * Places the string representation of extension value - * into the StringBuffer object. - */ - public void dumpValue(StringBuffer buffer) { - buffer.append("Policy Identifier [") - .append(policyIdentifier).append(']'); + public void dumpValue(StringBuilder sb) { + sb.append("Policy Identifier [").append(policyIdentifier).append(']'); } /** @@ -104,4 +99,3 @@ public final class PolicyInformation { } }; } - diff --git a/luni/src/main/java/org/apache/harmony/security/x509/ReasonCode.java b/luni/src/main/java/org/apache/harmony/security/x509/ReasonCode.java index 61fbbc6..183ecde 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/ReasonCode.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/ReasonCode.java @@ -71,41 +71,41 @@ public final class ReasonCode extends ExtensionValue { return encoding; } - @Override public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append(prefix).append("Reason Code: [ "); + @Override public void dumpValue(StringBuilder sb, String prefix) { + sb.append(prefix).append("Reason Code: [ "); switch (code) { - case UNSPECIFIED: - buffer.append("unspecified"); - break; - case KEY_COMPROMISE: - buffer.append("keyCompromise"); - break; - case CA_COMPROMISE: - buffer.append("cACompromise"); - break; - case AFFILIATION_CHANGED: - buffer.append("affiliationChanged"); - break; - case SUPERSEDED: - buffer.append("superseded"); - break; - case CESSATION_OF_OPERATION: - buffer.append("cessationOfOperation"); - break; - case CERTIFICATE_HOLD: - buffer.append("certificateHold"); - break; - case REMOVE_FROM_CRL: - buffer.append("removeFromCRL"); - break; - case PRIVILEGE_WITHDRAWN: - buffer.append("privilegeWithdrawn"); - break; - case AA_COMPROMISE: - buffer.append("aACompromise"); - break; + case UNSPECIFIED: + sb.append("unspecified"); + break; + case KEY_COMPROMISE: + sb.append("keyCompromise"); + break; + case CA_COMPROMISE: + sb.append("cACompromise"); + break; + case AFFILIATION_CHANGED: + sb.append("affiliationChanged"); + break; + case SUPERSEDED: + sb.append("superseded"); + break; + case CESSATION_OF_OPERATION: + sb.append("cessationOfOperation"); + break; + case CERTIFICATE_HOLD: + sb.append("certificateHold"); + break; + case REMOVE_FROM_CRL: + sb.append("removeFromCRL"); + break; + case PRIVILEGE_WITHDRAWN: + sb.append("privilegeWithdrawn"); + break; + case AA_COMPROMISE: + sb.append("aACompromise"); + break; } - buffer.append(" ]\n"); + sb.append(" ]\n"); } /** diff --git a/luni/src/main/java/org/apache/harmony/security/x509/ReasonFlags.java b/luni/src/main/java/org/apache/harmony/security/x509/ReasonFlags.java index beb4a1c..5231e61 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/ReasonFlags.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/ReasonFlags.java @@ -76,21 +76,16 @@ public final class ReasonFlags { this.flags = flags; } - /** - * Places the string representation of extension value - * into the StringBuffer object. - */ - public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append(prefix); - buffer.append("ReasonFlags [\n"); + public void dumpValue(StringBuilder sb, String prefix) { + sb.append(prefix); + sb.append("ReasonFlags [\n"); for (int i=0; i<flags.length; i++) { if (flags[i]) { - buffer.append(prefix).append(" ") - .append(REASONS[i]).append('\n'); + sb.append(prefix).append(" ").append(REASONS[i]).append('\n'); } } - buffer.append(prefix); - buffer.append("]\n"); + sb.append(prefix); + sb.append("]\n"); } /** @@ -108,4 +103,3 @@ public final class ReasonFlags { } }; } - diff --git a/luni/src/main/java/org/apache/harmony/security/x509/SubjectKeyIdentifier.java b/luni/src/main/java/org/apache/harmony/security/x509/SubjectKeyIdentifier.java index 5f22505..7415002 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/SubjectKeyIdentifier.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/SubjectKeyIdentifier.java @@ -65,10 +65,9 @@ public final class SubjectKeyIdentifier extends ExtensionValue { return encoding; } - @Override public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append(prefix).append("SubjectKeyIdentifier: [\n"); - buffer.append(Array.toString(keyIdentifier, prefix)); - buffer.append(prefix).append("]\n"); + @Override public void dumpValue(StringBuilder sb, String prefix) { + sb.append(prefix).append("SubjectKeyIdentifier: [\n"); + sb.append(Array.toString(keyIdentifier, prefix)); + sb.append(prefix).append("]\n"); } } - diff --git a/luni/src/main/java/org/apache/harmony/security/x509/TBSCertList.java b/luni/src/main/java/org/apache/harmony/security/x509/TBSCertList.java index e031dbb..f5923e9 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/TBSCertList.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/TBSCertList.java @@ -155,20 +155,13 @@ public final class TBSCertList { + (crlEntryExtensions == null ? 0 : crlEntryExtensions.hashCode()); } - /** - * Places the string representation of extension value - * into the StringBuffer object. - */ - public void dumpValue(StringBuffer buffer, String prefix) { - buffer.append(prefix).append("Certificate Serial Number: ") - .append(userCertificate).append('\n'); - buffer.append(prefix).append("Revocation Date: ") - .append(revocationDate); + public void dumpValue(StringBuilder sb, String prefix) { + sb.append(prefix).append("Certificate Serial Number: ").append(userCertificate).append('\n'); + sb.append(prefix).append("Revocation Date: ").append(revocationDate); if (crlEntryExtensions != null) { - buffer.append('\n').append(prefix) - .append("CRL Entry Extensions: ["); - crlEntryExtensions.dumpValue(buffer, prefix + " "); - buffer.append(prefix).append(']'); + sb.append('\n').append(prefix).append("CRL Entry Extensions: ["); + crlEntryExtensions.dumpValue(sb, prefix + " "); + sb.append(prefix).append(']'); } } @@ -299,34 +292,28 @@ public final class TBSCertList { + (int)thisUpdate.getTime() / 1000; } - /** - * Places the string representation of extension value - * into the StringBuffer object. - */ - public void dumpValue(StringBuffer buffer) { - buffer.append("X.509 CRL v").append(version); - buffer.append("\nSignature Algorithm: ["); - signature.dumpValue(buffer); - buffer.append(']'); - buffer.append("\nIssuer: ").append(issuer.getName(X500Principal.RFC2253)); - buffer.append("\n\nThis Update: ").append(thisUpdate); - buffer.append("\nNext Update: ").append(nextUpdate).append('\n'); + public void dumpValue(StringBuilder sb) { + sb.append("X.509 CRL v").append(version); + sb.append("\nSignature Algorithm: ["); + signature.dumpValue(sb); + sb.append(']'); + sb.append("\nIssuer: ").append(issuer.getName(X500Principal.RFC2253)); + sb.append("\n\nThis Update: ").append(thisUpdate); + sb.append("\nNext Update: ").append(nextUpdate).append('\n'); if (revokedCertificates != null) { - buffer.append("\nRevoked Certificates: ") - .append(revokedCertificates.size()).append(" ["); + sb.append("\nRevoked Certificates: ").append(revokedCertificates.size()).append(" ["); int number = 1; for (RevokedCertificate revokedCertificate : revokedCertificates) { - buffer.append("\n [").append(number++).append(']'); - revokedCertificate.dumpValue(buffer, " "); - buffer.append('\n'); + sb.append("\n [").append(number++).append(']'); + revokedCertificate.dumpValue(sb, " "); + sb.append('\n'); } - buffer.append("]\n"); + sb.append("]\n"); } if (crlExtensions != null) { - buffer.append("\nCRL Extensions: ") - .append(crlExtensions.size()).append(" ["); - crlExtensions.dumpValue(buffer, " "); - buffer.append("]\n"); + sb.append("\nCRL Extensions: ").append(crlExtensions.size()).append(" ["); + crlExtensions.dumpValue(sb, " "); + sb.append("]\n"); } } diff --git a/luni/src/main/java/org/apache/harmony/security/x509/TBSCertificate.java b/luni/src/main/java/org/apache/harmony/security/x509/TBSCertificate.java index da8325d..9d622c9 100644 --- a/luni/src/main/java/org/apache/harmony/security/x509/TBSCertificate.java +++ b/luni/src/main/java/org/apache/harmony/security/x509/TBSCertificate.java @@ -194,45 +194,36 @@ public final class TBSCertificate { return encoding; } - /** - * Places the string representation into the StringBuffer object. - */ - public void dumpValue(StringBuffer buffer) { - buffer.append('['); - buffer.append("\n Version: V").append(version+1); - buffer.append("\n Subject: ") - .append(subject.getName(X500Principal.RFC2253)); - buffer.append("\n Signature Algorithm: "); - signature.dumpValue(buffer); - buffer.append("\n Key: "); - buffer.append(subjectPublicKeyInfo.getPublicKey().toString()); - buffer.append("\n Validity: [From: "); - buffer.append(validity.getNotBefore()); - buffer.append("\n To: "); - buffer.append(validity.getNotAfter()).append(']'); - buffer.append("\n Issuer: "); - buffer.append(issuer.getName(X500Principal.RFC2253)); - buffer.append("\n Serial Number: "); - buffer.append(serialNumber); + public void dumpValue(StringBuilder sb) { + sb.append('['); + sb.append("\n Version: V").append(version+1); + sb.append("\n Subject: ").append(subject.getName(X500Principal.RFC2253)); + sb.append("\n Signature Algorithm: "); + signature.dumpValue(sb); + sb.append("\n Key: ").append(subjectPublicKeyInfo.getPublicKey().toString()); + sb.append("\n Validity: [From: ").append(validity.getNotBefore()); + sb.append("\n To: ").append(validity.getNotAfter()).append(']'); + sb.append("\n Issuer: ").append(issuer.getName(X500Principal.RFC2253)); + sb.append("\n Serial Number: ").append(serialNumber); if (issuerUniqueID != null) { - buffer.append("\n Issuer Id: "); + sb.append("\n Issuer Id: "); for (boolean b : issuerUniqueID) { - buffer.append(b ? '1' : '0'); + sb.append(b ? '1' : '0'); } } if (subjectUniqueID != null) { - buffer.append("\n Subject Id: "); + sb.append("\n Subject Id: "); for (boolean b : subjectUniqueID) { - buffer.append(b ? '1' : '0'); + sb.append(b ? '1' : '0'); } } if (extensions != null) { - buffer.append("\n\n Extensions: "); - buffer.append("[\n"); - extensions.dumpValue(buffer, " "); - buffer.append(" ]"); + sb.append("\n\n Extensions: "); + sb.append("[\n"); + extensions.dumpValue(sb, " "); + sb.append(" ]"); } - buffer.append("\n]"); + sb.append("\n]"); } /** diff --git a/luni/src/main/java/org/apache/harmony/security/x509/Utils.java b/luni/src/main/java/org/apache/harmony/security/x509/Utils.java deleted file mode 100644 index 5e168c4..0000000 --- a/luni/src/main/java/org/apache/harmony/security/x509/Utils.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** -* @author Alexander V. Esin -* @version $Revision$ -*/ - -package org.apache.harmony.security.x509; - -/** - * Text utils for processing DN string representations - */ -public final class Utils { - private Utils() {} - - /** - * Checks if the string is PrintableString (see X.680) - * @param str input string - * @return true if the string is PrintableString, false otherwise - */ - public static boolean isPrintableString(String str) { - for (int i= 0; i< str.length(); ++i) { - char ch= str.charAt(i); - if (!(ch== 0x20 - || ch>= 0x27 && ch<= 0x29 // '() - || ch>= 0x2B && ch<= 0x3A // +,-./0-9: - || ch== '=' - || ch== '?' - || ch>= 'A' && ch<= 'Z' - || ch>= 'a' && ch<= 'z')) { - return false; - } - } - return true; - } -}
\ No newline at end of file diff --git a/xml/src/main/java/org/xmlpull/v1/XmlPullParserFactory.java b/xml/src/main/java/org/xmlpull/v1/XmlPullParserFactory.java index 8ad1b89..644d01d 100644 --- a/xml/src/main/java/org/xmlpull/v1/XmlPullParserFactory.java +++ b/xml/src/main/java/org/xmlpull/v1/XmlPullParserFactory.java @@ -175,7 +175,7 @@ public class XmlPullParserFactory { if (parserClasses.size() == 0) throw new XmlPullParserException ("No valid parser classes found in "+classNamesLocation); - final StringBuffer issues = new StringBuffer (); + final StringBuilder issues = new StringBuilder(); for (int i = 0; i < parserClasses.size(); i++) { final Class ppClass = (Class) parserClasses.get(i); @@ -221,7 +221,7 @@ public class XmlPullParserFactory { ("No valid serializer classes found in "+classNamesLocation); } - final StringBuffer issues = new StringBuffer (); + final StringBuilder issues = new StringBuilder (); for (int i = 0; i < serializerClasses.size (); i++) { final Class ppClass = (Class) serializerClasses.get(i); @@ -269,7 +269,7 @@ public class XmlPullParserFactory { if (is == null) throw new XmlPullParserException ("resource not found: "+RESOURCE_NAME +" make sure that parser implementing XmlPull API is available"); - final StringBuffer sb = new StringBuffer(); + final StringBuilder sb = new StringBuilder(); while (true) { final int ch = is.read(); diff --git a/xml/src/main/java/org/xmlpull/v1/sax2/Driver.java b/xml/src/main/java/org/xmlpull/v1/sax2/Driver.java index 0bd2d4f..88cffd7 100644 --- a/xml/src/main/java/org/xmlpull/v1/sax2/Driver.java +++ b/xml/src/main/java/org/xmlpull/v1/sax2/Driver.java @@ -358,7 +358,7 @@ public class Driver implements Locator, XMLReader, Attributes "start tag must be read before skiping subtree"+pp.getPositionDescription()); } final int[] holderForStartAndLength = new int[2]; - final StringBuffer rawName = new StringBuffer(16); + final StringBuilder rawName = new StringBuilder(16); String prefix = null; String name = null; int level = pp.getDepth() - 1; |