summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAbhishek Koneru <akoneru@redhat.com>2012-05-18 16:12:17 -0400
committerAde Lee <alee@redhat.com>2012-05-24 23:08:51 -0400
commit9db76ed1d1f8969e93aaff320e49662f53688e2e (patch)
tree2e7af87ca0f72cdf4eb982764757d2884b21ce7b
parenta4db0f39e257950a5c89203452c1184c7080e5bd (diff)
downloadpki-9db76ed1d1f8969e93aaff320e49662f53688e2e.tar.gz
pki-9db76ed1d1f8969e93aaff320e49662f53688e2e.tar.xz
pki-9db76ed1d1f8969e93aaff320e49662f53688e2e.zip
Fixes for Coverity Defects of Category : FB.SBSC_USE_STRINGBUFFER_CONCATENATION
-rw-r--r--base/ca/src/com/netscape/ca/CRLIssuingPoint.java15
-rw-r--r--base/common/src/com/netscape/certsrv/acls/ACL.java8
-rw-r--r--base/common/src/com/netscape/certsrv/acls/ACLEntry.java14
-rw-r--r--base/common/src/com/netscape/cmscore/cert/CertUtils.java14
-rw-r--r--base/common/src/com/netscape/cmscore/dbs/DBRegistry.java30
-rw-r--r--base/common/src/com/netscape/cmscore/dbs/KeyRepository.java6
-rw-r--r--base/common/src/com/netscape/cmscore/dbs/PublicKeyMapper.java8
-rw-r--r--base/common/src/com/netscape/cmscore/dbs/RevocationInfoMapper.java15
-rw-r--r--base/common/src/com/netscape/cmscore/ldap/LdapRule.java31
-rw-r--r--base/common/src/com/netscape/cmscore/ldap/PublisherProcessor.java29
-rw-r--r--base/common/src/com/netscape/cmscore/notification/EmailFormProcessor.java9
-rw-r--r--base/common/src/com/netscape/cmscore/profile/ProfileSubsystem.java10
-rw-r--r--base/common/src/com/netscape/cmscore/security/JssSubsystem.java55
-rw-r--r--base/common/src/com/netscape/cmscore/security/KeyCertUtil.java14
-rw-r--r--base/common/src/com/netscape/cmscore/security/PWCBsdr.java8
-rw-r--r--base/common/src/com/netscape/cmscore/security/PWsdrCache.java24
-rw-r--r--base/common/src/com/netscape/cmscore/usrgrp/UGSubsystem.java10
-rw-r--r--base/java-tools/src/com/netscape/cmstools/AtoB.java7
-rw-r--r--base/java-tools/src/com/netscape/cmstools/CMCEnroll.java14
-rw-r--r--base/java-tools/src/com/netscape/cmstools/CMCRequest.java22
-rw-r--r--base/java-tools/src/com/netscape/cmstools/CMCResponse.java7
-rw-r--r--base/java-tools/src/com/netscape/cmstools/DRMTool.java95
-rw-r--r--base/java-tools/src/com/netscape/cmstools/PasswordCache.java22
-rw-r--r--base/java-tools/src/com/netscape/cmstools/PrettyPrintCert.java7
-rw-r--r--base/java-tools/src/com/netscape/cmstools/PrettyPrintCrl.java7
-rw-r--r--base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java28
-rw-r--r--base/util/src/com/netscape/cmsutil/util/Cert.java12
-rw-r--r--base/util/src/netscape/security/extensions/AuthInfoAccessExtension.java16
-rw-r--r--base/util/src/netscape/security/extensions/CertificateScopeOfUseExtension.java6
-rw-r--r--base/util/src/netscape/security/extensions/SubjectInfoAccessExtension.java15
-rw-r--r--base/util/src/netscape/security/pkcs/PKCS7.java21
-rw-r--r--base/util/src/netscape/security/util/CertPrettyPrint.java24
-rw-r--r--base/util/src/netscape/security/util/ObjectIdentifier.java10
33 files changed, 308 insertions, 305 deletions
diff --git a/base/ca/src/com/netscape/ca/CRLIssuingPoint.java b/base/ca/src/com/netscape/ca/CRLIssuingPoint.java
index aaeea2636..29bb1d1a1 100644
--- a/base/ca/src/com/netscape/ca/CRLIssuingPoint.java
+++ b/base/ca/src/com/netscape/ca/CRLIssuingPoint.java
@@ -1820,10 +1820,12 @@ public class CRLIssuingPoint implements ICRLIssuingPoint, Runnable {
if (mProfileList.size() > 1) {
filter += "(|";
}
+ StringBuffer tempBuffer = new StringBuffer();
for (int k = 0; k < mProfileList.size(); k++) {
String id = mProfileList.elementAt(k);
- filter += "(" + CertRecord.ATTR_META_INFO + "=profileId:" + id + ")";
+ tempBuffer.append("(" + CertRecord.ATTR_META_INFO + "=profileId:" + id + ")");
}
+ filter += tempBuffer.toString();
if (mProfileList.size() > 1) {
filter += ")";
}
@@ -2481,14 +2483,15 @@ public class CRLIssuingPoint implements ICRLIssuingPoint, Runnable {
mDeltaCRLSize = deltaCRLCerts.size();
long totalTime = 0;
- String splitTimes = " (";
+ StringBuffer splitTimes = new StringBuffer();
+ splitTimes.append(" (");
for (int i = 1; i < mSplits.length && i < 5; i++) {
totalTime += mSplits[i];
if (i > 1)
- splitTimes += ",";
- splitTimes += Long.toString(mSplits[i]);
+ splitTimes.append(",");
+ splitTimes.append(String.valueOf(mSplits[i]));
}
- splitTimes += ")";
+ splitTimes.append(")");
mLogger.log(ILogger.EV_AUDIT, ILogger.S_OTHER,
AuditFormat.LEVEL,
CMS.getLogMessage("CMSCORE_CA_CA_DELTA_CRL_UPDATED"),
@@ -2499,7 +2502,7 @@ public class CRLIssuingPoint implements ICRLIssuingPoint, Runnable {
getLastUpdate(),
getNextDeltaUpdate(),
Long.toString(mDeltaCRLSize),
- Long.toString(totalTime) + splitTimes
+ Long.toString(totalTime) + splitTimes.toString()
}
);
} catch (EBaseException e) {
diff --git a/base/common/src/com/netscape/certsrv/acls/ACL.java b/base/common/src/com/netscape/certsrv/acls/ACL.java
index 086b26015..83be047e7 100644
--- a/base/common/src/com/netscape/certsrv/acls/ACL.java
+++ b/base/common/src/com/netscape/certsrv/acls/ACL.java
@@ -151,17 +151,17 @@ public class ACL implements IACL, java.io.Serializable {
* <resource name>[<ACLEntry1>,<ACLEntry 2>,...<ACLEntry N>]
*/
public String toString() {
- String entries = "";
+ StringBuffer entries = new StringBuffer();
Enumeration<ACLEntry> e = entries();
for (; e.hasMoreElements();) {
ACLEntry entry = e.nextElement();
- entries += entry.toString();
+ entries.append(entry.toString());
if (e.hasMoreElements())
- entries += ",";
+ entries.append(",");
}
- return getName() + "[" + entries + "]";
+ return getName() + "[" + entries.toString() + "]";
}
/**
diff --git a/base/common/src/com/netscape/certsrv/acls/ACLEntry.java b/base/common/src/com/netscape/certsrv/acls/ACLEntry.java
index 3d18c263c..76924ed93 100644
--- a/base/common/src/com/netscape/certsrv/acls/ACLEntry.java
+++ b/base/common/src/com/netscape/certsrv/acls/ACLEntry.java
@@ -223,23 +223,23 @@ public class ACLEntry implements IACLEntry, java.io.Serializable {
* @return string representation of this ACLEntry
*/
public String toString() {
- String entry = "";
+ StringBuffer entry = new StringBuffer();
if (isNegative()) {
- entry += "deny (";
+ entry.append("deny (");
} else {
- entry += "allow (";
+ entry.append("allow (");
}
Enumeration<String> e = permissions();
for (; e.hasMoreElements();) {
String p = e.nextElement();
- entry += p;
+ entry.append(p);
if (e.hasMoreElements())
- entry += ",";
+ entry.append(",");
}
- entry += ") " + getAttributeExpressions();
- return entry;
+ entry.append(") ").append(getAttributeExpressions());
+ return entry.toString();
}
}
diff --git a/base/common/src/com/netscape/cmscore/cert/CertUtils.java b/base/common/src/com/netscape/cmscore/cert/CertUtils.java
index 009e9b0d9..d443781ae 100644
--- a/base/common/src/com/netscape/cmscore/cert/CertUtils.java
+++ b/base/common/src/com/netscape/cmscore/cert/CertUtils.java
@@ -612,7 +612,7 @@ public class CertUtils {
}
public static String normalizeCertStr(String s) {
- String val = "";
+ StringBuffer val = new StringBuffer();
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == '\n') {
@@ -624,9 +624,9 @@ public class CertUtils {
} else if (s.charAt(i) == ' ') {
continue;
}
- val += s.charAt(i);
+ val.append(s.charAt(i));
}
- return val;
+ return val.toString();
}
public static String stripCRLBrackets(String s) {
@@ -747,17 +747,17 @@ public class CertUtils {
throws NoSuchAlgorithmException/*, CertificateEncodingException*/{
// byte certDer[] = cert.getEncoded();
String[] hashes = new String[] { "MD2", "MD5", "SHA1", "SHA256", "SHA512" };
- String certFingerprints = "";
+ StringBuffer certFingerprints = new StringBuffer();
PrettyPrintFormat pp = new PrettyPrintFormat(":");
for (int i = 0; i < hashes.length; i++) {
MessageDigest md = MessageDigest.getInstance(hashes[i]);
md.update(certDer);
- certFingerprints += hashes[i] + ":\n" +
- pp.toHexString(md.digest(), 8, 16);
+ certFingerprints.append(hashes[i] + ":\n" +
+ pp.toHexString(md.digest(), 8, 16));
}
- return certFingerprints;
+ return certFingerprints.toString();
}
/**
diff --git a/base/common/src/com/netscape/cmscore/dbs/DBRegistry.java b/base/common/src/com/netscape/cmscore/dbs/DBRegistry.java
index 5169bc4c9..250ebf394 100644
--- a/base/common/src/com/netscape/cmscore/dbs/DBRegistry.java
+++ b/base/common/src/com/netscape/cmscore/dbs/DBRegistry.java
@@ -262,12 +262,20 @@ public class DBRegistry implements IDBRegistry, ISubsystem {
}
}
}
- String result = "";
+ return inStringFormat(v);
+ }
+ /**
+ * Convert a Vector<String> to Concatenated String
+ * @param v
+ * @return
+ */
+ private String inStringFormat(Vector<String> v){
+ StringBuffer result = new StringBuffer();
for (int i = 0; i < v.size(); i++) {
- result += v.elementAt(i);
+ result.append(v.elementAt(i));
}
- return result;
+ return result.toString();
}
/**
@@ -321,13 +329,13 @@ public class DBRegistry implements IDBRegistry, ISubsystem {
if (ldapNames == null)
throw new EDBException(
CMS.getUserMessage("CMS_DBS_INVALID_FILTER_ITEM", f));
- String filter = "";
+ StringBuffer filter = new StringBuffer();
for (int g = 0; g < ldapNames.length; g++) {
- filter += "(objectclass=" +
- ldapNames[g] + ")";
+ filter.append("(objectclass=" +
+ ldapNames[g] + ")");
}
- return "&" + filter;
+ return "&" + filter.toString();
} else {
return c.convert(type, "=", value);
}
@@ -526,13 +534,7 @@ public class DBRegistry implements IDBRegistry, ISubsystem {
v.addElement(s[i]);
}
- // concate them
- String result = "";
-
- for (int i = 0; i < v.size(); i++) {
- result += v.elementAt(i) + "+";
- }
- return result;
+ return inStringFormat(v);
}
}
diff --git a/base/common/src/com/netscape/cmscore/dbs/KeyRepository.java b/base/common/src/com/netscape/cmscore/dbs/KeyRepository.java
index 3e7759772..726746627 100644
--- a/base/common/src/com/netscape/cmscore/dbs/KeyRepository.java
+++ b/base/common/src/com/netscape/cmscore/dbs/KeyRepository.java
@@ -389,12 +389,12 @@ public class KeyRepository extends Repository implements IKeyRepository {
* Read RFC-2254
*/
public static String escapeBinaryData(byte data[]) {
- String result = "";
+ StringBuffer result = new StringBuffer();
for (int i = 0; i < data.length; i++) {
- result = result + "\\" + Integer.toHexString(data[i]);
+ result.append("\\" + Integer.toHexString(data[i]));
}
- return result;
+ return result.toString();
}
public Enumeration<IKeyRecord> searchKeys(String filter, int maxSize)
diff --git a/base/common/src/com/netscape/cmscore/dbs/PublicKeyMapper.java b/base/common/src/com/netscape/cmscore/dbs/PublicKeyMapper.java
index c1bf43b48..8a4dbc77d 100644
--- a/base/common/src/com/netscape/cmscore/dbs/PublicKeyMapper.java
+++ b/base/common/src/com/netscape/cmscore/dbs/PublicKeyMapper.java
@@ -123,14 +123,14 @@ public class PublicKeyMapper implements IDBAttrMapper {
}
public static String escapeBinaryData(byte data[]) {
- String result = "";
+ StringBuffer result = new StringBuffer();
for (int i = 0; i < data.length; i++) {
int v = 0xff & data[i];
- result = result + "\\" + (v < 16 ? "0" : "") +
- Integer.toHexString(v);
+ result.append("\\" + (v < 16 ? "0" : "") +
+ Integer.toHexString(v));
}
- return result;
+ return result.toString();
}
}
diff --git a/base/common/src/com/netscape/cmscore/dbs/RevocationInfoMapper.java b/base/common/src/com/netscape/cmscore/dbs/RevocationInfoMapper.java
index 396067c79..2b9bca3d5 100644
--- a/base/common/src/com/netscape/cmscore/dbs/RevocationInfoMapper.java
+++ b/base/common/src/com/netscape/cmscore/dbs/RevocationInfoMapper.java
@@ -66,11 +66,12 @@ public class RevocationInfoMapper implements IDBAttrMapper {
throws EBaseException {
try {
// in format of <date>;<extensions>
- String value = "";
+ StringBuffer value = new StringBuffer();
+
RevocationInfo info = (RevocationInfo) obj;
Date d = info.getRevocationDate();
- value = DateMapper.dateToDB(d);
+ value.append(DateMapper.dateToDB(d));
CRLExtensions exts = info.getCRLEntryExtensions();
// CRLExtension's DER encoding and decoding does not work!
// That is why we need to do our own serialization.
@@ -83,20 +84,20 @@ public class RevocationInfoMapper implements IDBAttrMapper {
RevocationReason reason =
((CRLReasonExtension) ext).getReason();
- value = value + ";CRLReasonExtension=" +
- Integer.toString(reason.toInt());
+ value.append(";CRLReasonExtension=" +
+ Integer.toString(reason.toInt()));
} else if (ext instanceof InvalidityDateExtension) {
Date invalidityDate =
((InvalidityDateExtension) ext).getInvalidityDate();
- value = value + ";InvalidityDateExtension=" +
- DateMapper.dateToDB(invalidityDate);
+ value.append(";InvalidityDateExtension=" +
+ DateMapper.dateToDB(invalidityDate));
} else {
Debug.trace("XXX skipped extension");
}
}
attrs.add(new LDAPAttribute(CertDBSchema.LDAP_ATTR_REVO_INFO,
- value));
+ value.toString()));
} catch (Exception e) {
Debug.trace(e.toString());
throw new EDBException(
diff --git a/base/common/src/com/netscape/cmscore/ldap/LdapRule.java b/base/common/src/com/netscape/cmscore/ldap/LdapRule.java
index f5fdcc502..eaf5e763a 100644
--- a/base/common/src/com/netscape/cmscore/ldap/LdapRule.java
+++ b/base/common/src/com/netscape/cmscore/ldap/LdapRule.java
@@ -66,28 +66,28 @@ public class LdapRule implements ILdapRule, IExtendedPluginInfo {
mProcessor = processor;
Enumeration<String> mappers = mProcessor.getMapperInsts().keys();
Enumeration<String> publishers = mProcessor.getPublisherInsts().keys();
-
- String map = NOMAPPER;
+ StringBuffer map=new StringBuffer();
+ map.append(NOMAPPER);
for (; mappers.hasMoreElements();) {
String name = mappers.nextElement();
- map = map + "," + name;
+ map.append(",").append(name);
}
- String publish = "";
+ StringBuffer publish = new StringBuffer();
for (; publishers.hasMoreElements();) {
String name = publishers.nextElement();
- publish = publish + "," + name;
+ publish.append(",").append(name);
}
epi_params = new String[] {
"type;choice(cacert,crl, certs);The publishing object type",
"mapper;choice("
- + map + ");Use the mapper to find the ldap dn \nto publish the certificate or crl",
+ + map.toString() + ");Use the mapper to find the ldap dn \nto publish the certificate or crl",
"publisher;choice("
- + publish + ");Use the publisher to publish the certificate or crl a directory etc",
+ + publish.toString() + ");Use the publisher to publish the certificate or crl a directory etc",
"enable;boolean;Enable this publishing rule",
"predicate;string;Filter describing when this publishing rule shoule be used"
};
@@ -171,22 +171,27 @@ public class LdapRule implements ILdapRule, IExtendedPluginInfo {
public Vector<String> getInstanceParams() {
//if (mProcessor == null) System.out.println("xxxxnull");
//dont know why the processor was null in getExtendedPluginInfo()
- Enumeration<String> mappers = mProcessor.getMapperInsts().keys();
+
+ /* Commented block contains variables which are used only in the below commented block.
+ *
+ * Enumeration<String> mappers = mProcessor.getMapperInsts().keys();
Enumeration<String> publishers = mProcessor.getPublisherInsts().keys();
- String map = NOMAPPER;
+ StringBuffer map=new StringBuffer();
+ map.append(NOMAPPER);
for (; mappers.hasMoreElements();) {
String name = mappers.nextElement();
- map = map + "," + name;
+ map.append(",").append(name);
}
- String publish = "";
+ StringBuffer publish=new StringBuffer();
+
for (; publishers.hasMoreElements();) {
String name = publishers.nextElement();
- publish = publish + "," + name;
- }
+ publish.append(",").append(name);
+ }*/
/*
mExtendedPluginInfo = new NameValuePairs();
diff --git a/base/common/src/com/netscape/cmscore/ldap/PublisherProcessor.java b/base/common/src/com/netscape/cmscore/ldap/PublisherProcessor.java
index 1314899b7..e5aef45a5 100644
--- a/base/common/src/com/netscape/cmscore/ldap/PublisherProcessor.java
+++ b/base/common/src/com/netscape/cmscore/ldap/PublisherProcessor.java
@@ -837,7 +837,7 @@ public class PublisherProcessor implements
public void publishCACert(X509Certificate cert)
throws ELdapException {
boolean error = false;
- String errorRule = "";
+ StringBuffer errorRule = new StringBuffer();
if (!enabled())
return;
@@ -889,15 +889,14 @@ public class PublisherProcessor implements
//log(ILogger.LL_WARN, e.toString());
CMS.debug("PublisherProcessor::publishCACert returned error: " + e);
error = true;
- errorRule = errorRule + " " + rule.getInstanceName() +
- " error:" + e;
+ errorRule.append(" " + rule.getInstanceName() + " error:" + e);
}
}
// set the ldap published flag.
if (!error) {
setPublishedFlag(cert.getSerialNumber(), true);
} else {
- throw new ELdapException(CMS.getUserMessage("CMS_LDAP_PUBLISH_FAILED", errorRule));
+ throw new ELdapException(CMS.getUserMessage("CMS_LDAP_PUBLISH_FAILED", errorRule.toString()));
}
}
@@ -908,7 +907,7 @@ public class PublisherProcessor implements
public void unpublishCACert(X509Certificate cert)
throws ELdapException {
boolean error = false;
- String errorRule = "";
+ StringBuffer errorRule = new StringBuffer();
if (!enabled())
return;
@@ -956,7 +955,7 @@ public class PublisherProcessor implements
// continue publishing even publisher has errors
//log(ILogger.LL_WARN, e.toString());
error = true;
- errorRule = errorRule + " " + rule.getInstanceName();
+ errorRule.append(" ").append(rule.getInstanceName());
}
}
@@ -964,7 +963,7 @@ public class PublisherProcessor implements
if (!error) {
setPublishedFlag(cert.getSerialNumber(), false);
} else {
- throw new ELdapException(CMS.getUserMessage("CMS_LDAP_UNPUBLISH_FAILED", errorRule));
+ throw new ELdapException(CMS.getUserMessage("CMS_LDAP_UNPUBLISH_FAILED", errorRule.toString()));
}
}
@@ -1034,7 +1033,7 @@ public class PublisherProcessor implements
public void publishCert(X509Certificate cert, IRequest req)
throws ELdapException {
boolean error = false;
- String errorRule = "";
+ StringBuffer errorRule = new StringBuffer();
CMS.debug("In PublisherProcessor::publishCert");
if (!enabled())
@@ -1048,7 +1047,7 @@ public class PublisherProcessor implements
CMS.debug("Publishing: can't find publishing rule,exiting routine.");
error = true;
- errorRule = "No rules enabled";
+ errorRule.append("No rules enabled");
}
while (rules != null && rules.hasMoreElements()) {
@@ -1073,15 +1072,15 @@ public class PublisherProcessor implements
// continue publishing even publisher has errors
//log(ILogger.LL_WARN, e.toString());
error = true;
- errorRule = errorRule + " " + rule.getInstanceName();
+ errorRule.append(" ").append(rule.getInstanceName());
}
}
// set the ldap published flag.
if (!error) {
setPublishedFlag(cert.getSerialNumber(), true);
} else {
- CMS.debug("PublishProcessor::publishCert : " + CMS.getUserMessage("CMS_LDAP_PUBLISH_FAILED", errorRule));
- throw new ELdapException(CMS.getUserMessage("CMS_LDAP_PUBLISH_FAILED", errorRule));
+ CMS.debug("PublishProcessor::publishCert : " + CMS.getUserMessage("CMS_LDAP_PUBLISH_FAILED", errorRule.toString()));
+ throw new ELdapException(CMS.getUserMessage("CMS_LDAP_PUBLISH_FAILED", errorRule.toString()));
}
}
@@ -1092,7 +1091,7 @@ public class PublisherProcessor implements
public void unpublishCert(X509Certificate cert, IRequest req)
throws ELdapException {
boolean error = false;
- String errorRule = "";
+ StringBuffer errorRule = new StringBuffer();
if (!enabled())
return;
@@ -1139,7 +1138,7 @@ public class PublisherProcessor implements
// continue publishing even publisher has errors
//log(ILogger.LL_WARN, e.toString());
error = true;
- errorRule = errorRule + " " + rule.getInstanceName();
+ errorRule.append(" ").append(rule.getInstanceName());
}
}
@@ -1147,7 +1146,7 @@ public class PublisherProcessor implements
if (!error) {
setPublishedFlag(cert.getSerialNumber(), false);
} else {
- throw new ELdapException(CMS.getUserMessage("CMS_LDAP_UNPUBLISH_FAILED", errorRule));
+ throw new ELdapException(CMS.getUserMessage("CMS_LDAP_UNPUBLISH_FAILED", errorRule.toString()));
}
}
diff --git a/base/common/src/com/netscape/cmscore/notification/EmailFormProcessor.java b/base/common/src/com/netscape/cmscore/notification/EmailFormProcessor.java
index d187a7fed..2625d8efa 100644
--- a/base/common/src/com/netscape/cmscore/notification/EmailFormProcessor.java
+++ b/base/common/src/com/netscape/cmscore/notification/EmailFormProcessor.java
@@ -220,22 +220,21 @@ public class EmailFormProcessor implements IEmailFormProcessor {
* takes a vector of strings and concatenate them
*/
public String formContent(Vector<String> vec) {
- String content = null;
+ StringBuffer content = new StringBuffer();
Enumeration<String> e = vec.elements();
// initialize content with first element
if (e.hasMoreElements()) {
- content = e.nextElement();
+ content.append(e.nextElement());
}
while (e.hasMoreElements()) {
String v = e.nextElement();
-
- content += v;
+ content.append(v);
}
- return content;
+ return content.toString();
}
/**
diff --git a/base/common/src/com/netscape/cmscore/profile/ProfileSubsystem.java b/base/common/src/com/netscape/cmscore/profile/ProfileSubsystem.java
index c5a12447a..1be949183 100644
--- a/base/common/src/com/netscape/cmscore/profile/ProfileSubsystem.java
+++ b/base/common/src/com/netscape/cmscore/profile/ProfileSubsystem.java
@@ -154,19 +154,19 @@ public class ProfileSubsystem implements IProfileSubsystem {
}
StringTokenizer tokenizer = new StringTokenizer(ids, ",");
- String list = "";
+ StringBuffer list = new StringBuffer();
while (tokenizer.hasMoreTokens()) {
String element = tokenizer.nextToken();
if (!element.equals(id)) {
- list = list + element + ",";
+ list.append(element).append(",");
}
}
- if (!list.equals(""))
- list = list.substring(0, list.length() - 1);
+ if (list.length() != 0)
+ list.deleteCharAt(list.length() - 1);
- mConfig.putString(PROP_LIST, list);
+ mConfig.putString(PROP_LIST, list.toString());
mConfig.removeSubStore(id);
File file1 = new File(configPath);
diff --git a/base/common/src/com/netscape/cmscore/security/JssSubsystem.java b/base/common/src/com/netscape/cmscore/security/JssSubsystem.java
index 42249e324..2d6fe7d88 100644
--- a/base/common/src/com/netscape/cmscore/security/JssSubsystem.java
+++ b/base/common/src/com/netscape/cmscore/security/JssSubsystem.java
@@ -508,7 +508,8 @@ public final class JssSubsystem implements ICryptoSubsystem {
}
public String getTokenList() throws EBaseException {
- String tokenList = "";
+ StringBuffer tokenList = new StringBuffer();
+
@SuppressWarnings("unchecked")
Enumeration<CryptoToken> tokens = mCryptoManager.getExternalTokens();
int num = 0;
@@ -522,10 +523,9 @@ public final class JssSubsystem implements ICryptoSubsystem {
continue;
}
- if (num++ == 0)
- tokenList = tokenList + c.getName();
- else
- tokenList = tokenList + "," + c.getName();
+ if (num++ != 0)
+ tokenList.append(",");
+ tokenList.append(c.getName());
}
} catch (TokenException e) {
String[] params = { mId, e.toString() };
@@ -536,10 +536,10 @@ public final class JssSubsystem implements ICryptoSubsystem {
throw ex;
}
- if (tokenList.equals(""))
+ if (tokenList.length()==0)
return Constants.PR_INTERNAL_TOKEN;
else
- return (tokenList + "," + Constants.PR_INTERNAL_TOKEN);
+ return tokenList.append(",").append(Constants.PR_INTERNAL_TOKEN).toString();
}
public boolean isTokenLoggedIn(String name) throws EBaseException {
@@ -596,7 +596,7 @@ public final class JssSubsystem implements ICryptoSubsystem {
}
public String getAllCerts() throws EBaseException {
- String certNames = "";
+ StringBuffer certNames = new StringBuffer();
try {
@SuppressWarnings("unchecked")
@@ -610,10 +610,9 @@ public final class JssSubsystem implements ICryptoSubsystem {
for (int i = 0; i < list.length; i++) {
String nickname = list[i].getNickname();
- if (certNames.equals(""))
- certNames = certNames + nickname;
- else
- certNames = certNames + "," + nickname;
+ if (i > 0)
+ certNames.append(",");
+ certNames.append(nickname);
}
}
} catch (TokenException e) {
@@ -625,13 +624,13 @@ public final class JssSubsystem implements ICryptoSubsystem {
throw ex;
}
- return certNames;
+ return certNames.toString();
}
public String getCertListWithoutTokenName(String name) throws EBaseException {
CryptoToken c = null;
- String certNames = "";
+ StringBuffer certNames = new StringBuffer();
try {
if (name.equals(Constants.PR_INTERNAL_TOKEN)) {
@@ -653,12 +652,11 @@ public final class JssSubsystem implements ICryptoSubsystem {
if (index != -1)
nickname = nickname.substring(index + 1);
- if (i == 0)
- certNames = certNames + nickname;
- else
- certNames = certNames + "," + nickname;
+ if (i != 0)
+ certNames.append(",");
+ certNames.append(nickname);
}
- return certNames;
+ return certNames.toString();
} else
return "";
@@ -682,7 +680,7 @@ public final class JssSubsystem implements ICryptoSubsystem {
public String getCertList(String name) throws EBaseException {
CryptoToken c = null;
- String certNames = "";
+ StringBuffer certNames = new StringBuffer();
try {
if (name.equals(Constants.PR_INTERNAL_TOKEN)) {
@@ -701,12 +699,12 @@ public final class JssSubsystem implements ICryptoSubsystem {
for (int i = 0; i < list.length; i++) {
String nickname = list[i].getNickname();
- if (i == 0)
- certNames = certNames + nickname;
- else
- certNames = certNames + "," + nickname;
+ if (i != 0)
+ certNames.append(",");
+ certNames.append(nickname);
}
- return certNames;
+
+ return certNames.toString();
} else
return "";
@@ -2004,7 +2002,8 @@ public final class JssSubsystem implements ICryptoSubsystem {
} catch (CertificateException e) {
// failed to decode as a certificate, try decoding
// as a PKCS #7 blob
- String content = "";
+ StringBuffer content = new StringBuffer();
+
String noHeader = CertUtils.stripCertBrackets(b64E);
String normalized = CertUtils.normalizeCertStr(noHeader);
byte data[] = Utils.base64decode(normalized);
@@ -2030,10 +2029,10 @@ public final class JssSubsystem implements ICryptoSubsystem {
ASN1Util.encode(cert));
CertPrettyPrint print = new CertPrettyPrint(certImpl);
- content += print.toString(Locale.getDefault());
+ content.append(print.toString(Locale.getDefault()));
}
- return content;
+ return content.toString();
}
} catch (InvalidBERException e) {
log(ILogger.LL_FAILURE, CMS.getLogMessage("CMSCORE_SECURITY_PRINT_CERT", e.toString()));
diff --git a/base/common/src/com/netscape/cmscore/security/KeyCertUtil.java b/base/common/src/com/netscape/cmscore/security/KeyCertUtil.java
index 7a980c621..844052e4b 100644
--- a/base/common/src/com/netscape/cmscore/security/KeyCertUtil.java
+++ b/base/common/src/com/netscape/cmscore/security/KeyCertUtil.java
@@ -151,7 +151,8 @@ public class KeyCertUtil {
public static String getTokenNames(CryptoManager manager)
throws TokenException {
- String tokenList = "";
+ StringBuffer tokenList = new StringBuffer();
+
@SuppressWarnings("unchecked")
Enumeration<CryptoToken> tokens = manager.getExternalTokens();
int num = 0;
@@ -159,16 +160,15 @@ public class KeyCertUtil {
while (tokens.hasMoreElements()) {
CryptoToken c = tokens.nextElement();
- if (num++ == 0)
- tokenList = tokenList + c.getName();
- else
- tokenList = tokenList + "," + c.getName();
+ if (num++ != 0)
+ tokenList.append(",");
+ tokenList.append(c.getName());
}
- if (tokenList.equals(""))
+ if (tokenList.length() == 0)
return Constants.PR_INTERNAL_TOKEN;
else
- return (tokenList + "," + Constants.PR_INTERNAL_TOKEN);
+ return (tokenList.toString() + "," + Constants.PR_INTERNAL_TOKEN);
}
public static String base64Encode(byte[] bytes) throws IOException {
diff --git a/base/common/src/com/netscape/cmscore/security/PWCBsdr.java b/base/common/src/com/netscape/cmscore/security/PWCBsdr.java
index 4017a7869..0ff50668c 100644
--- a/base/common/src/com/netscape/cmscore/security/PWCBsdr.java
+++ b/base/common/src/com/netscape/cmscore/security/PWCBsdr.java
@@ -17,7 +17,6 @@
// --- END COPYRIGHT BLOCK ---
package com.netscape.cmscore.security;
-import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
@@ -79,13 +78,12 @@ public class PWCBsdr implements PasswordCallback {
}
// System.out.println("after CMS.getConfigStore");
- if (File.separator.equals("/")) {
+
// Unix
mCB = new PWsdrConsolePasswordCallback(prompt);
- } else {
- mCB = new PWsdrConsolePasswordCallback(prompt);
+
// mCB = new PWsdrDialogPasswordCallback( prompt );
- }
+
// System.out.println( "Created PWCBsdr with prompt of "
// + mprompt );
diff --git a/base/common/src/com/netscape/cmscore/security/PWsdrCache.java b/base/common/src/com/netscape/cmscore/security/PWsdrCache.java
index 2e0dfd550..e4e8a432b 100644
--- a/base/common/src/com/netscape/cmscore/security/PWsdrCache.java
+++ b/base/common/src/com/netscape/cmscore/security/PWsdrCache.java
@@ -231,11 +231,12 @@ public class PWsdrCache {
*/
public void addEntry(String tag, String pwd, Hashtable<String, String> tagPwds) throws EBaseException {
- String stringToAdd = null;
+ StringBuffer stringToAdd = new StringBuffer();
+
String bufs = null;
if (tagPwds == null) {
- stringToAdd = tag + ":" + pwd + "\n";
+ stringToAdd.append(tag + ":" + pwd + System.getProperty("line.separator"));
} else {
Enumeration<String> enum1 = tagPwds.keys();
@@ -244,11 +245,7 @@ public class PWsdrCache {
pwd = tagPwds.get(tag);
debug("password tag: " + tag + " stored in " + mPWcachedb);
- if (stringToAdd == null) {
- stringToAdd = tag + ":" + pwd + "\n";
- } else {
- stringToAdd += tag + ":" + pwd + "\n";
- }
+ stringToAdd.append(tag + ":" + pwd + System.getProperty("line.separator"));
}
}
@@ -269,7 +266,7 @@ public class PWsdrCache {
bufs = hashtable2String(ht);
} else {
debug("adding new tag: " + tag);
- bufs = stringToAdd;
+ bufs = stringToAdd.toString();
}
// write update to cache
@@ -436,19 +433,14 @@ public class PWsdrCache {
public String hashtable2String(Hashtable<String, String> ht) {
Enumeration<String> enum1 = ht.keys();
- String returnString = null;
+ StringBuffer returnString = new StringBuffer();
while (enum1.hasMoreElements()) {
String tag = enum1.nextElement();
String pwd = ht.get(tag);
-
- if (returnString == null) {
- returnString = tag + ":" + pwd + "\n";
- } else {
- returnString += tag + ":" + pwd + "\n";
- }
+ returnString.append(tag + ":" + pwd + System.getProperty("line.separator"));
}
- return returnString;
+ return returnString.toString();
}
public Hashtable<String, String> string2Hashtable(String cache) {
diff --git a/base/common/src/com/netscape/cmscore/usrgrp/UGSubsystem.java b/base/common/src/com/netscape/cmscore/usrgrp/UGSubsystem.java
index e48fd620a..382cc249c 100644
--- a/base/common/src/com/netscape/cmscore/usrgrp/UGSubsystem.java
+++ b/base/common/src/com/netscape/cmscore/usrgrp/UGSubsystem.java
@@ -271,17 +271,17 @@ public final class UGSubsystem implements IUGSubsystem {
if (hasSlash != -1) {
String up = filter;
- String stripped = "";
+ StringBuffer stripped = new StringBuffer();
hasSlash = up.indexOf('\\');
while (hasSlash != -1) {
- stripped += up.substring(0, hasSlash) +
- "\\5c";
- ;
+ stripped.append(up.substring(0, hasSlash)).append(
+ "\\5c");
+
up = up.substring(hasSlash + 1);
hasSlash = up.indexOf('\\');
}
- filter = stripped + up;
+ filter = stripped.toString() + up;
}
LDAPConnection ldapconn = null;
diff --git a/base/java-tools/src/com/netscape/cmstools/AtoB.java b/base/java-tools/src/com/netscape/cmstools/AtoB.java
index e3059b0d1..51fb3cc17 100644
--- a/base/java-tools/src/com/netscape/cmstools/AtoB.java
+++ b/base/java-tools/src/com/netscape/cmstools/AtoB.java
@@ -61,7 +61,8 @@ public class AtoB {
BufferedReader inputBlob = null;
String asciiBASE64BlobChunk = "";
- String asciiBASE64Blob = "";
+ StringBuffer asciiBASE64Blob = new StringBuffer();
+
byte binaryBASE64Blob[] = null;
FileOutputStream outputBlob = null;
@@ -95,7 +96,7 @@ public class AtoB {
while ((asciiBASE64BlobChunk = inputBlob.readLine()) != null) {
if (!(asciiBASE64BlobChunk.startsWith(HEADER)) &&
!(asciiBASE64BlobChunk.startsWith(TRAILER))) {
- asciiBASE64Blob += asciiBASE64BlobChunk.trim();
+ asciiBASE64Blob.append(asciiBASE64BlobChunk.trim());
}
}
} catch (IOException e) {
@@ -115,7 +116,7 @@ public class AtoB {
// (5) Decode the ASCII BASE 64 blob enclosed in the
// String() object into a BINARY BASE 64 byte[] object
- binaryBASE64Blob = Utils.base64decode(asciiBASE64Blob);
+ binaryBASE64Blob = Utils.base64decode(asciiBASE64Blob.toString());
// (6) Finally, print the actual AtoB blob to the
// specified output file
diff --git a/base/java-tools/src/com/netscape/cmstools/CMCEnroll.java b/base/java-tools/src/com/netscape/cmstools/CMCEnroll.java
index ba8d71f3d..d13ed13f7 100644
--- a/base/java-tools/src/com/netscape/cmstools/CMCEnroll.java
+++ b/base/java-tools/src/com/netscape/cmstools/CMCEnroll.java
@@ -394,13 +394,13 @@ public class CMCEnroll {
// headers beginning with HEADER and any trailers beginning
// with TRAILER
String asciiBASE64BlobChunk = "";
- String asciiBASE64Blob = "";
+ StringBuffer asciiBASE64Blob = new StringBuffer();
try {
while ((asciiBASE64BlobChunk = inputBlob.readLine()) != null) {
if (!(asciiBASE64BlobChunk.startsWith(HEADER)) &&
!(asciiBASE64BlobChunk.startsWith(TRAILER))) {
- asciiBASE64Blob += asciiBASE64BlobChunk.trim();
+ asciiBASE64Blob.append(asciiBASE64BlobChunk.trim());
}
}
} catch (IOException e) {
@@ -416,13 +416,13 @@ public class CMCEnroll {
"encoded error encountered in close():\n" + e);
}
- asciiBASE64Blob = getCMCBlob(signerCert, cm, nValue, asciiBASE64Blob);
+ String asciiBASE64Blob_str = getCMCBlob(signerCert, cm, nValue, asciiBASE64Blob.toString());
// (5) Decode the ASCII BASE 64 blob enclosed in the
// String() object into a BINARY BASE 64 byte[] object
@SuppressWarnings("unused")
byte binaryBASE64Blob[] =
- Utils.base64decode(asciiBASE64Blob); // check for errors
+ Utils.base64decode(asciiBASE64Blob_str); // check for errors
// (6) Finally, print the actual CMCEnroll blob to the
// specified output file
@@ -435,10 +435,10 @@ public class CMCEnroll {
}
System.out.println(HEADER);
- System.out.println(asciiBASE64Blob + TRAILER);
+ System.out.println(asciiBASE64Blob.toString() + TRAILER);
try {
- asciiBASE64Blob = HEADER + "\n" + asciiBASE64Blob + TRAILER;
- outputBlob.write(asciiBASE64Blob.getBytes());
+ asciiBASE64Blob_str = HEADER + "\n" + asciiBASE64Blob_str.toString() + TRAILER;
+ outputBlob.write(asciiBASE64Blob_str.getBytes());
} catch (IOException e) {
System.out.println("CMCEnroll: I/O error " +
"encountered during write():\n" +
diff --git a/base/java-tools/src/com/netscape/cmstools/CMCRequest.java b/base/java-tools/src/com/netscape/cmstools/CMCRequest.java
index e46b746aa..dc359a8b0 100644
--- a/base/java-tools/src/com/netscape/cmstools/CMCRequest.java
+++ b/base/java-tools/src/com/netscape/cmstools/CMCRequest.java
@@ -673,11 +673,12 @@ public class CMCRequest {
try {
byte bvalue[] = str.getBytes();
System.out.println("Data Return Control: ");
- String ss = " Value: ";
+ StringBuffer ss = new StringBuffer();
+ ss.append(" Value: ");
for (int m = 0; m < bvalue.length; m++) {
- ss = ss + bvalue[m] + " ";
+ ss.append(bvalue[m]).append(" ");
}
- System.out.println(ss);
+ System.out.println(ss.toString());
OCTET_STRING s = new OCTET_STRING(bvalue);
TaggedAttribute dataReturnControl = new TaggedAttribute(new
INTEGER(bpid++), OBJECT_IDENTIFIER.id_cmc_dataReturn, s);
@@ -756,11 +757,14 @@ public class CMCRequest {
}
byte bb[] = sn.getBytes();
System.out.println("SenderNonce control: ");
- String ss = " Value: ";
+
+ StringBuffer ss = new StringBuffer();
+
+ ss.append(" Value: ");
for (int m = 0; m < bb.length; m++) {
- ss = ss + bb[m] + " ";
+ ss.append(bb[m] + " ");
}
- System.out.println(ss);
+ System.out.println(ss.toString());
TaggedAttribute senderNonce = new TaggedAttribute(new
INTEGER(bpid++), OBJECT_IDENTIFIER.id_cmc_senderNonce,
new OCTET_STRING(sn.getBytes()));
@@ -1006,16 +1010,16 @@ public class CMCRequest {
// headers beginning with HEADER and any trailers beginning
// with TRAILER
String asciiBASE64BlobChunk = "";
- String asciiBASE64Blob = "";
+ StringBuffer asciiBASE64Blob = new StringBuffer();
try {
while ((asciiBASE64BlobChunk = inputBlob.readLine()) != null) {
if (!(asciiBASE64BlobChunk.startsWith(HEADER)) &&
!(asciiBASE64BlobChunk.startsWith(TRAILER))) {
- asciiBASE64Blob += asciiBASE64BlobChunk.trim();
+ asciiBASE64Blob.append(asciiBASE64BlobChunk.trim());
}
}
- requests[i] = asciiBASE64Blob;
+ requests[i] = asciiBASE64Blob.toString();
} catch (IOException e) {
System.out.println("CMCRequest: Unexpected BASE64 " +
"encoded error encountered in readLine():\n" +
diff --git a/base/java-tools/src/com/netscape/cmstools/CMCResponse.java b/base/java-tools/src/com/netscape/cmstools/CMCResponse.java
index 959f06f52..eae0b7303 100644
--- a/base/java-tools/src/com/netscape/cmstools/CMCResponse.java
+++ b/base/java-tools/src/com/netscape/cmstools/CMCResponse.java
@@ -73,7 +73,8 @@ public class CMCResponse {
org.mozilla.jss.pkix.cms.SignedData cmcFullResp =
(org.mozilla.jss.pkix.cms.SignedData) cii.getInterpretedContent();
- String content = "";
+ StringBuffer content = new StringBuffer();
+
if (cmcFullResp.hasCertificates()) {
SET certs = cmcFullResp.getCertificates();
int numCerts = certs.size();
@@ -82,12 +83,12 @@ public class CMCResponse {
Certificate cert = (Certificate) certs.elementAt(i);
X509CertImpl certImpl = new X509CertImpl(ASN1Util.encode(cert));
CertPrettyPrint print = new CertPrettyPrint(certImpl);
- content += print.toString(Locale.getDefault());
+ content.append(print.toString(Locale.getDefault()));
}
}
System.out.println("Certificates: ");
- System.out.println(content);
+ System.out.println(content.toString());
System.out.println("");
EncapsulatedContentInfo ci = cmcFullResp.getContentInfo();
OBJECT_IDENTIFIER id = ci.getContentType();
diff --git a/base/java-tools/src/com/netscape/cmstools/DRMTool.java b/base/java-tools/src/com/netscape/cmstools/DRMTool.java
index f67d735e6..164931d6c 100644
--- a/base/java-tools/src/com/netscape/cmstools/DRMTool.java
+++ b/base/java-tools/src/com/netscape/cmstools/DRMTool.java
@@ -1446,7 +1446,7 @@ public class DRMTool {
private static PublicKey getPublicKey() {
BufferedReader inputCert = null;
String encodedBASE64CertChunk = "";
- String encodedBASE64Cert = "";
+ StringBuffer encodedBASE64Cert = new StringBuffer();
byte decodedBASE64Cert[] = null;
X509CertImpl cert = null;
PublicKey key = null;
@@ -1481,7 +1481,7 @@ public class DRMTool {
while ((encodedBASE64CertChunk = inputCert.readLine()) != null) {
if (!(encodedBASE64CertChunk.startsWith(HEADER)) &&
!(encodedBASE64CertChunk.startsWith(TRAILER))) {
- encodedBASE64Cert += encodedBASE64CertChunk.trim();
+ encodedBASE64Cert.append(encodedBASE64CertChunk.trim());
}
}
} catch (IOException exWrapReadLineIO) {
@@ -1512,7 +1512,7 @@ public class DRMTool {
// Decode the ASCII BASE 64 certificate enclosed in the
// String() object into a BINARY BASE 64 byte[] object
decodedBASE64Cert = Utils.base64decode(
- encodedBASE64Cert);
+ encodedBASE64Cert.toString());
// Create an X509CertImpl() object from
// the BINARY BASE 64 byte[] object
@@ -1997,36 +1997,36 @@ public class DRMTool {
* suitable for an LDIF file
*/
private static String format_ldif_data(int length, String data) {
- String revised_data = "";
+ StringBuffer revised_data = new StringBuffer();
if (data.length() > length) {
// process first line
for (int i = 0; i < length; i++) {
- revised_data += data.charAt(i);
+ revised_data.append(data.charAt(i));
}
// terminate first line
- revised_data += '\n';
+ revised_data.append(System.getProperty("line.separator"));
// process remaining lines
int j = 0;
for (int i = length; i < data.length(); i++) {
if (j == 0) {
- revised_data += ' ';
+ revised_data.append(' ');
}
- revised_data += data.charAt(i);
+ revised_data.append(data.charAt(i));
j++;
if (j == 76) {
- revised_data += '\n';
+ revised_data.append(System.getProperty("line.separator"));
j = 0;
}
}
}
- return revised_data.replaceAll("\\s+$", "");
+ return revised_data.toString().replaceAll("\\s+$", "");
}
/*********************/
@@ -2778,8 +2778,9 @@ public class DRMTool {
* @return the composed output line
*/
private static String output_extdata_request_notes(String record_type,
- String line) {
- String input = null;
+ String line) {
+ StringBuffer input = new StringBuffer();
+
String data = null;
String unformatted_data = null;
String output = null;
@@ -2787,13 +2788,13 @@ public class DRMTool {
// extract the data
if (line.length() > DRM_LDIF_EXTDATA_REQUEST_NOTES.length()) {
- input = line.substring(
+ input.append(line.substring(
DRM_LDIF_EXTDATA_REQUEST_NOTES.length() + 1
- ).trim();
+ ).trim());
} else {
- input = line.substring(
+ input.append(line.substring(
DRM_LDIF_EXTDATA_REQUEST_NOTES.length()
- ).trim();
+ ).trim());
}
while ((line = ldif_record.next()) != null) {
@@ -2801,7 +2802,7 @@ public class DRMTool {
// Do NOT use "trim()";
// remove single leading space and
// trailing carriage returns and newlines ONLY!
- input += line.replaceFirst(" ", "").replace('\r', '\0').replace('\n', '\0');
+ input.append(line.replaceFirst(" ", "").replace('\r', '\0').replace('\n', '\0'));
} else {
next_line = line;
break;
@@ -2812,7 +2813,7 @@ public class DRMTool {
if (drmtoolCfg.get(DRMTOOL_CFG_ENROLLMENT_EXTDATA_REQUEST_NOTES)) {
// write out a revised 'extdata-requestnotes' line
if (mRewrapFlag && mAppendIdOffsetFlag) {
- data = input
+ data = input.toString()
+ SPACE
+ LEFT_BRACE
+ mDateOfModify
@@ -2843,7 +2844,7 @@ public class DRMTool {
EXTDATA_REQUEST_NOTES_FIRST_LINE_DATA_LENGTH,
unformatted_data);
} else if (mRewrapFlag && mRemoveIdOffsetFlag) {
- data = input
+ data = input.toString()
+ SPACE
+ LEFT_BRACE
+ mDateOfModify
@@ -2874,7 +2875,7 @@ public class DRMTool {
EXTDATA_REQUEST_NOTES_FIRST_LINE_DATA_LENGTH,
unformatted_data);
} else if (mRewrapFlag) {
- data = input
+ data = input.toString()
+ SPACE
+ LEFT_BRACE
+ mDateOfModify
@@ -2898,7 +2899,7 @@ public class DRMTool {
EXTDATA_REQUEST_NOTES_FIRST_LINE_DATA_LENGTH,
unformatted_data);
} else if (mAppendIdOffsetFlag) {
- data = input
+ data = input.toString()
+ SPACE
+ LEFT_BRACE
+ mDateOfModify
@@ -2923,7 +2924,7 @@ public class DRMTool {
EXTDATA_REQUEST_NOTES_FIRST_LINE_DATA_LENGTH,
unformatted_data);
} else if (mRemoveIdOffsetFlag) {
- data = input
+ data = input.toString()
+ SPACE
+ LEFT_BRACE
+ mDateOfModify
@@ -2957,7 +2958,7 @@ public class DRMTool {
+ SPACE
+ format_ldif_data(
EXTDATA_REQUEST_NOTES_FIRST_LINE_DATA_LENGTH,
- input)
+ input.toString())
+ TIC
+ NEWLINE
+ "--->"
@@ -2973,7 +2974,7 @@ public class DRMTool {
if (drmtoolCfg.get(DRMTOOL_CFG_RECOVERY_EXTDATA_REQUEST_NOTES)) {
// write out a revised 'extdata-requestnotes' line
if (mRewrapFlag && mAppendIdOffsetFlag) {
- data = input
+ data = input.toString()
+ SPACE
+ LEFT_BRACE
+ mDateOfModify
@@ -3004,7 +3005,7 @@ public class DRMTool {
EXTDATA_REQUEST_NOTES_FIRST_LINE_DATA_LENGTH,
unformatted_data);
} else if (mRewrapFlag && mRemoveIdOffsetFlag) {
- data = input
+ data = input.toString()
+ SPACE
+ LEFT_BRACE
+ mDateOfModify
@@ -3035,7 +3036,7 @@ public class DRMTool {
EXTDATA_REQUEST_NOTES_FIRST_LINE_DATA_LENGTH,
unformatted_data);
} else if (mRewrapFlag) {
- data = input
+ data = input.toString()
+ SPACE
+ LEFT_BRACE
+ mDateOfModify
@@ -3059,7 +3060,7 @@ public class DRMTool {
EXTDATA_REQUEST_NOTES_FIRST_LINE_DATA_LENGTH,
unformatted_data);
} else if (mAppendIdOffsetFlag) {
- data = input
+ data = input.toString()
+ SPACE
+ LEFT_BRACE
+ mDateOfModify
@@ -3084,7 +3085,7 @@ public class DRMTool {
EXTDATA_REQUEST_NOTES_FIRST_LINE_DATA_LENGTH,
unformatted_data);
} else if (mRemoveIdOffsetFlag) {
- data = input
+ data = input.toString()
+ SPACE
+ LEFT_BRACE
+ mDateOfModify
@@ -3118,7 +3119,7 @@ public class DRMTool {
+ SPACE
+ format_ldif_data(
EXTDATA_REQUEST_NOTES_FIRST_LINE_DATA_LENGTH,
- input)
+ input.toString())
+ TIC
+ NEWLINE
+ "--->"
@@ -3134,7 +3135,7 @@ public class DRMTool {
if (drmtoolCfg.get(DRMTOOL_CFG_KEYGEN_EXTDATA_REQUEST_NOTES)) {
// write out a revised 'extdata-requestnotes' line
if (mRewrapFlag && mAppendIdOffsetFlag) {
- data = input
+ data = input.toString()
+ SPACE
+ LEFT_BRACE
+ mDateOfModify
@@ -3165,7 +3166,7 @@ public class DRMTool {
EXTDATA_REQUEST_NOTES_FIRST_LINE_DATA_LENGTH,
unformatted_data);
} else if (mRewrapFlag && mRemoveIdOffsetFlag) {
- data = input
+ data = input.toString()
+ SPACE
+ LEFT_BRACE
+ mDateOfModify
@@ -3196,7 +3197,7 @@ public class DRMTool {
EXTDATA_REQUEST_NOTES_FIRST_LINE_DATA_LENGTH,
unformatted_data);
} else if (mRewrapFlag) {
- data = input
+ data = input.toString()
+ SPACE
+ LEFT_BRACE
+ mDateOfModify
@@ -3220,7 +3221,7 @@ public class DRMTool {
EXTDATA_REQUEST_NOTES_FIRST_LINE_DATA_LENGTH,
unformatted_data);
} else if (mAppendIdOffsetFlag) {
- data = input
+ data = input.toString()
+ SPACE
+ LEFT_BRACE
+ mDateOfModify
@@ -3245,7 +3246,7 @@ public class DRMTool {
EXTDATA_REQUEST_NOTES_FIRST_LINE_DATA_LENGTH,
unformatted_data);
} else if (mRemoveIdOffsetFlag) {
- data = input
+ data = input.toString()
+ SPACE
+ LEFT_BRACE
+ mDateOfModify
@@ -3279,7 +3280,7 @@ public class DRMTool {
+ SPACE
+ format_ldif_data(
EXTDATA_REQUEST_NOTES_FIRST_LINE_DATA_LENGTH,
- input)
+ input.toString())
+ TIC
+ NEWLINE
+ "--->"
@@ -3668,7 +3669,7 @@ public class DRMTool {
String line) {
byte source_wrappedKeyData[] = null;
byte target_wrappedKeyData[] = null;
- String data = null;
+ StringBuffer data = new StringBuffer();
String revised_data = null;
String unformatted_data = null;
String formatted_data = null;
@@ -3685,13 +3686,13 @@ public class DRMTool {
// these options have been selected
if (mRewrapFlag) {
// extract the data
- data = line.substring(
- DRM_LDIF_PRIVATE_KEY_DATA.length() + 1
- ).trim();
+ data.append(line.substring(
+ DRM_LDIF_PRIVATE_KEY_DATA.length() + 1
+ ).trim());
while ((line = ldif_record.next()) != null) {
if (line.startsWith(SPACE)) {
- data += line.trim();
+ data.append(line.trim());
} else {
break;
}
@@ -3701,7 +3702,7 @@ public class DRMTool {
// enclosed in the String() object
// into a BINARY BASE 64 byte[] object
source_wrappedKeyData =
- Utils.base64decode(data);
+ Utils.base64decode(data.toString());
// rewrap the source wrapped private key data
target_wrappedKeyData = rewrap_wrapped_key_data(
@@ -3734,7 +3735,7 @@ public class DRMTool {
log("Changed 'privateKeyData' from:"
+ NEWLINE
+ TIC
- + data
+ + data.toString()
+ TIC
+ NEWLINE
+ " to:"
@@ -3759,13 +3760,13 @@ public class DRMTool {
// these options have been selected
if (mRewrapFlag) {
// extract the data
- data = line.substring(
+ data.append(line.substring(
DRM_LDIF_PRIVATE_KEY_DATA.length() + 1
- ).trim();
+ ).trim());
while ((line = ldif_record.next()) != null) {
if (line.startsWith(SPACE)) {
- data += line.trim();
+ data.append(line.trim());
} else {
break;
}
@@ -3775,7 +3776,7 @@ public class DRMTool {
// enclosed in the String() object
// into a BINARY BASE 64 byte[] object
source_wrappedKeyData =
- Utils.base64decode(data);
+ Utils.base64decode(data.toString());
// rewrap the source wrapped private key data
target_wrappedKeyData = rewrap_wrapped_key_data(
@@ -3808,7 +3809,7 @@ public class DRMTool {
log("Changed 'privateKeyData' from:"
+ NEWLINE
+ TIC
- + data
+ + data.toString()
+ TIC
+ NEWLINE
+ " to:"
diff --git a/base/java-tools/src/com/netscape/cmstools/PasswordCache.java b/base/java-tools/src/com/netscape/cmstools/PasswordCache.java
index c9e36585e..1e123b17a 100644
--- a/base/java-tools/src/com/netscape/cmstools/PasswordCache.java
+++ b/base/java-tools/src/com/netscape/cmstools/PasswordCache.java
@@ -442,11 +442,11 @@ class PWsdrCache {
*/
public void addEntry(String tag, String pwd, Hashtable<String, String> tagPwds) throws IOException {
System.out.println("PWsdrCache: in addEntry");
- String stringToAdd = null;
+ StringBuffer stringToAdd = new StringBuffer();
String bufs = null;
if (tagPwds == null) {
- stringToAdd = tag + ":" + pwd + "\n";
+ stringToAdd.append(tag + ":" + pwd + System.getProperty("line.separator"));
} else {
Enumeration<String> enum1 = tagPwds.keys();
@@ -455,11 +455,7 @@ class PWsdrCache {
pwd = tagPwds.get(tag);
debug("password tag: " + tag + " stored in " + mPWcachedb);
- if (stringToAdd == null) {
- stringToAdd = tag + ":" + pwd + "\n";
- } else {
- stringToAdd += tag + ":" + pwd + "\n";
- }
+ stringToAdd.append(tag + ":" + pwd + System.getProperty("line.separator"));
}
}
@@ -480,7 +476,7 @@ class PWsdrCache {
bufs = hashtable2String(ht);
} else {
debug("adding new tag: " + tag);
- bufs = stringToAdd;
+ bufs = stringToAdd.toString();
}
// write update to cache
@@ -671,19 +667,15 @@ class PWsdrCache {
public String hashtable2String(Hashtable<String, String> ht) {
Enumeration<String> enum1 = ht.keys();
- String returnString = null;
+ StringBuffer returnString = new StringBuffer();
while (enum1.hasMoreElements()) {
String tag = enum1.nextElement();
String pwd = ht.get(tag);
+ returnString.append(tag + ":" + pwd + System.getProperty("line.separator"));
- if (returnString == null) {
- returnString = tag + ":" + pwd + "\n";
- } else {
- returnString += tag + ":" + pwd + "\n";
- }
}
- return returnString;
+ return returnString.toString();
}
public Hashtable<String, String> string2Hashtable(String cache) {
diff --git a/base/java-tools/src/com/netscape/cmstools/PrettyPrintCert.java b/base/java-tools/src/com/netscape/cmstools/PrettyPrintCert.java
index fdb988dd5..a713fb5a3 100644
--- a/base/java-tools/src/com/netscape/cmstools/PrettyPrintCert.java
+++ b/base/java-tools/src/com/netscape/cmstools/PrettyPrintCert.java
@@ -80,7 +80,8 @@ public class PrettyPrintCert {
BufferedReader inputCert = null;
String encodedBASE64CertChunk = "";
- String encodedBASE64Cert = "";
+ StringBuffer encodedBASE64Cert = new StringBuffer();
+
byte decodedBASE64Cert[] = null;
X509CertImpl cert = null;
Locale aLocale = null;
@@ -153,7 +154,7 @@ public class PrettyPrintCert {
while ((encodedBASE64CertChunk = inputCert.readLine()) != null) {
if (!(encodedBASE64CertChunk.startsWith(HEADER)) &&
!(encodedBASE64CertChunk.startsWith(TRAILER))) {
- encodedBASE64Cert += encodedBASE64CertChunk.trim();
+ encodedBASE64Cert.append(encodedBASE64CertChunk.trim());
}
}
} catch (IOException e) {
@@ -173,7 +174,7 @@ public class PrettyPrintCert {
// (5) Decode the ASCII BASE 64 certificate enclosed in the
// String() object into a BINARY BASE 64 byte[] object
- decodedBASE64Cert = Utils.base64decode(encodedBASE64Cert);
+ decodedBASE64Cert = Utils.base64decode(encodedBASE64Cert.toString());
// (6) Create an X509CertImpl() object from the BINARY BASE 64
// byte[] object
diff --git a/base/java-tools/src/com/netscape/cmstools/PrettyPrintCrl.java b/base/java-tools/src/com/netscape/cmstools/PrettyPrintCrl.java
index 8bd4f9ed5..86bb82155 100644
--- a/base/java-tools/src/com/netscape/cmstools/PrettyPrintCrl.java
+++ b/base/java-tools/src/com/netscape/cmstools/PrettyPrintCrl.java
@@ -73,7 +73,8 @@ public class PrettyPrintCrl {
BufferedReader inputCrl = null;
String encodedBASE64CrlChunk = "";
- String encodedBASE64Crl = "";
+ StringBuffer encodedBASE64Crl = new StringBuffer(0);
+
byte decodedBASE64Crl[] = null;
X509CRLImpl crl = null;
Locale aLocale = null;
@@ -136,7 +137,7 @@ public class PrettyPrintCrl {
while ((encodedBASE64CrlChunk = inputCrl.readLine()) != null) {
if (!(encodedBASE64CrlChunk.startsWith(HEADER)) &&
!(encodedBASE64CrlChunk.startsWith(TRAILER))) {
- encodedBASE64Crl += encodedBASE64CrlChunk.trim();
+ encodedBASE64Crl.append(encodedBASE64CrlChunk.trim());
}
}
} catch (IOException e) {
@@ -156,7 +157,7 @@ public class PrettyPrintCrl {
// (5) Decode the ASCII BASE 64 CRL enclosed in the
// String() object into a BINARY BASE 64 byte[] object
- decodedBASE64Crl = Utils.base64decode(encodedBASE64Crl);
+ decodedBASE64Crl = Utils.base64decode(encodedBASE64Crl.toString());
// (6) Create an X509CRLImpl() object from the BINARY BASE 64
// byte[] object
diff --git a/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java b/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java
index c8402b2ca..65e5ad9b3 100644
--- a/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java
+++ b/base/util/src/com/netscape/cmsutil/crypto/CryptoUtil.java
@@ -403,19 +403,20 @@ public class CryptoUtil {
* formats a cert request
*/
public static String reqFormat(String content) {
- String result = CERTREQ_BEGIN_HEADING + "\n";
+ StringBuffer result = new StringBuffer();
+ result.append(CERTREQ_BEGIN_HEADING + System.getProperty("line.separator"));
while (content.length() >= LINE_COUNT) {
- result = result + content.substring(0, LINE_COUNT) + "\n";
+ result.append(content.substring(0, LINE_COUNT) + System.getProperty("line.separator"));
content = content.substring(LINE_COUNT);
}
if (content.length() > 0) {
- result = result + content + "\n" + CERTREQ_END_HEADING;
+ result.append(content).append(System.getProperty("line.separator") + CERTREQ_END_HEADING);
} else {
- result = result + CERTREQ_END_HEADING;
+ result.append(CERTREQ_END_HEADING);
}
- return result;
+ return result.toString();
}
public static String getPKCS10FromKey(String dn,
@@ -463,19 +464,20 @@ public class CryptoUtil {
if (content == null || content.length() == 0) {
return "";
}
- String result = CERT_BEGIN_HEADING + "\n";
+ StringBuffer result = new StringBuffer();
+ result.append(CERT_BEGIN_HEADING + System.getProperty("line.separator"));
while (content.length() >= LINE_COUNT) {
- result = result + content.substring(0, LINE_COUNT) + "\n";
+ result.append(content.substring(0, LINE_COUNT) + System.getProperty("line.separator"));
content = content.substring(LINE_COUNT);
}
if (content.length() > 0) {
- result = result + content + "\n" + CERT_END_HEADING;
+ result.append(content + System.getProperty("line.separator") + CERT_END_HEADING);
} else {
- result = result + CERT_END_HEADING;
+ result.append(CERT_END_HEADING);
}
- return result;
+ return result.toString();
}
/**
@@ -545,7 +547,7 @@ public class CryptoUtil {
}
public static String normalizeCertStr(String s) {
- String val = "";
+ StringBuffer val = new StringBuffer();
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == '\n') {
@@ -557,9 +559,9 @@ public class CryptoUtil {
} else if (s.charAt(i) == ' ') {
continue;
}
- val += s.charAt(i);
+ val.append(s.charAt(i));
}
- return val;
+ return val.toString();
}
public static void importCertificateChain(String certchain)
diff --git a/base/util/src/com/netscape/cmsutil/util/Cert.java b/base/util/src/com/netscape/cmsutil/util/Cert.java
index 3563f70c7..7dfc18a5d 100644
--- a/base/util/src/com/netscape/cmsutil/util/Cert.java
+++ b/base/util/src/com/netscape/cmsutil/util/Cert.java
@@ -151,7 +151,7 @@ public class Cert {
}
public static String normalizeCertStr(String s) {
- String val = "";
+ StringBuffer val = new StringBuffer();
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == '\n') {
@@ -163,13 +163,13 @@ public class Cert {
} else if (s.charAt(i) == ' ') {
continue;
}
- val += s.charAt(i);
+ val.append(s.charAt(i));
}
- return val;
+ return val.toString();
}
public static String normalizeCertStrAndReq(String s) {
- String val = "";
+ StringBuffer val = new StringBuffer();
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == '\n') {
@@ -179,8 +179,8 @@ public class Cert {
} else if (s.charAt(i) == '"') {
continue;
}
- val += s.charAt(i);
+ val.append(s.charAt(i));
}
- return val;
+ return val.toString();
}
}
diff --git a/base/util/src/netscape/security/extensions/AuthInfoAccessExtension.java b/base/util/src/netscape/security/extensions/AuthInfoAccessExtension.java
index c3d2bec6c..15c56a04c 100644
--- a/base/util/src/netscape/security/extensions/AuthInfoAccessExtension.java
+++ b/base/util/src/netscape/security/extensions/AuthInfoAccessExtension.java
@@ -28,8 +28,6 @@ import java.security.cert.CertificateException;
import java.util.Enumeration;
import java.util.Vector;
-import com.netscape.cmsutil.util.Utils;
-
import netscape.security.util.DerOutputStream;
import netscape.security.util.DerValue;
import netscape.security.util.ObjectIdentifier;
@@ -38,6 +36,8 @@ import netscape.security.x509.Extension;
import netscape.security.x509.GeneralName;
import netscape.security.x509.URIName;
+import com.netscape.cmsutil.util.Utils;
+
/**
* This represents the authority information access extension
* as defined in RFC2459.
@@ -219,16 +219,18 @@ public class AuthInfoAccessExtension extends Extension implements CertAttrSet {
* Returns a printable representation of the AuthInfoAccess.
*/
public String toString() {
- String s = super.toString() + "AuthInfoAccess [\n";
+ StringBuffer s = new StringBuffer();
+ String b = super.toString() + "AuthInfoAccess [\n";
+ s.append(b);
for (int i = 0; i < mDesc.size(); i++) {
AccessDescription ad = mDesc.elementAt(i);
- s += "(" + i + ")";
- s += " ";
- s += ad.getMethod().toString() + " " + ad.getLocation().toString();
+ s.append("(" + i + ")");
+ s.append(" ");
+ s.append(ad.getMethod().toString() + " " + ad.getLocation().toString());
}
- return (s + "]\n");
+ return (s.toString() + "]\n");
}
public static void main(String[] argv) {
diff --git a/base/util/src/netscape/security/extensions/CertificateScopeOfUseExtension.java b/base/util/src/netscape/security/extensions/CertificateScopeOfUseExtension.java
index 271bd3606..0f93c2b78 100644
--- a/base/util/src/netscape/security/extensions/CertificateScopeOfUseExtension.java
+++ b/base/util/src/netscape/security/extensions/CertificateScopeOfUseExtension.java
@@ -183,15 +183,15 @@ public class CertificateScopeOfUseExtension extends Extension
* Returns a printable representation of the CertificateRenewalWindow.
*/
public String toString() {
- String s = super.toString() + "CertificateUseOfScope [\n";
+ StringBuffer s = new StringBuffer(super.toString() + "CertificateUseOfScope [\n");
if (mEntries != null) {
for (int i = 0; i < mEntries.size(); i++) {
CertificateScopeEntry se = mEntries.elementAt(i);
- s += se.toString();
+ s.append(se.toString());
}
}
- return (s + "]\n");
+ return (s.toString() + "]\n");
}
}
diff --git a/base/util/src/netscape/security/extensions/SubjectInfoAccessExtension.java b/base/util/src/netscape/security/extensions/SubjectInfoAccessExtension.java
index b11c77634..72407d62e 100644
--- a/base/util/src/netscape/security/extensions/SubjectInfoAccessExtension.java
+++ b/base/util/src/netscape/security/extensions/SubjectInfoAccessExtension.java
@@ -28,8 +28,6 @@ import java.security.cert.CertificateException;
import java.util.Enumeration;
import java.util.Vector;
-import com.netscape.cmsutil.util.Utils;
-
import netscape.security.util.DerOutputStream;
import netscape.security.util.DerValue;
import netscape.security.util.ObjectIdentifier;
@@ -38,6 +36,8 @@ import netscape.security.x509.Extension;
import netscape.security.x509.GeneralName;
import netscape.security.x509.URIName;
+import com.netscape.cmsutil.util.Utils;
+
/**
* This represents the subject information access extension
* as defined in RFC3280.
@@ -201,16 +201,15 @@ public class SubjectInfoAccessExtension extends Extension implements CertAttrSet
* Returns a printable representation of the AuthInfoAccess.
*/
public String toString() {
- String s = super.toString() + "AuthInfoAccess [\n";
+ StringBuffer s=new StringBuffer(super.toString() + "AuthInfoAccess [\n");
for (int i = 0; i < mDesc.size(); i++) {
AccessDescription ad = mDesc.elementAt(i);
-
- s += "(" + i + ")";
- s += " ";
- s += ad.getMethod().toString() + " " + ad.getLocation().toString();
+ s.append( "(" + i + ")");
+ s.append(" ");
+ s.append(ad.getMethod().toString() + " " + ad.getLocation().toString());
}
- return (s + "]\n");
+ return (s.toString() + "]\n");
}
public static void main(String[] argv) {
diff --git a/base/util/src/netscape/security/pkcs/PKCS7.java b/base/util/src/netscape/security/pkcs/PKCS7.java
index 8bd514099..b53918233 100644
--- a/base/util/src/netscape/security/pkcs/PKCS7.java
+++ b/base/util/src/netscape/security/pkcs/PKCS7.java
@@ -425,22 +425,23 @@ public class PKCS7 {
* Returns the PKCS7 block in a printable string form.
*/
public String toString() {
- String out = "";
+ StringBuffer out=new StringBuffer();
- out += "PKCS7 :: version: " + version + "\n";
- out += "PKCS7 :: digest AlgorithmIds: \n";
+
+ out.append("PKCS7 :: version: " + version+System.getProperty("line.separator"));
+ out.append("PKCS7 :: digest AlgorithmIds: "+System.getProperty("line.separator"));
for (int i = 0; i < digestAlgorithmIds.length; i++) {
- out += "\t" + digestAlgorithmIds[i] + "\n";
+ out.append("\t" + digestAlgorithmIds[i]+System.getProperty("line.separator"));
}
- out += contentInfo + "\n";
- out += "PKCS7 :: certificates: \n";
+ out.append(contentInfo).append(System.getProperty("line.separator"));
+ out.append("PKCS7 :: certificates: "+System.getProperty("line.separator"));
for (int i = 0; i < certificates.length; i++) {
- out += "\t" + i + ". " + certificates[i] + "\n";
+ out.append("\t" + i + ". " + certificates[i]+System.getProperty("line.separator"));
}
- out += "PKCS7 :: signer infos: \n";
+ out.append("PKCS7 :: signer infos: "+System.getProperty("line.separator"));
for (int i = 0; i < signerInfos.length; i++) {
- out += ("\t" + i + ". " + signerInfos[i] + "\n");
+ out.append("\t" + i + ". " + signerInfos[i]+System.getProperty("line.separator"));
}
- return out;
+ return out.toString();
}
}
diff --git a/base/util/src/netscape/security/util/CertPrettyPrint.java b/base/util/src/netscape/security/util/CertPrettyPrint.java
index 6e2f953e4..a72f0d4fb 100644
--- a/base/util/src/netscape/security/util/CertPrettyPrint.java
+++ b/base/util/src/netscape/security/util/CertPrettyPrint.java
@@ -96,7 +96,7 @@ public class CertPrettyPrint {
}
public String pkcs7toString(Locale clientLocale) {
- String content = "";
+ StringBuffer content=new StringBuffer();
try {
mX509Cert = new X509CertImpl(mCert_b);
@@ -134,15 +134,15 @@ public class CertPrettyPrint {
}
CertPrettyPrint print = new CertPrettyPrint(certImpl);
- content += print.toString(Locale.getDefault());
- content += "\n";
+ content.append(print.toString(Locale.getDefault()));
+ content.append("\n");
}
- return content;
+ return content.toString();
}
}
- return content;
+ return content.toString();
}
public String stripCertBrackets(String s) {
@@ -165,7 +165,7 @@ public class CertPrettyPrint {
}
public String normalizeCertStr(String s) {
- String val = "";
+ StringBuffer val = new StringBuffer();
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == '\n') {
@@ -177,9 +177,9 @@ public class CertPrettyPrint {
} else if (s.charAt(i) == ' ') {
continue;
}
- val += s.charAt(i);
+ val.append(s.charAt(i));
}
- return val;
+ return val.toString();
}
public String X509toString(Locale clientLocale) {
@@ -323,18 +323,18 @@ public class CertPrettyPrint {
// fingerprints
String[] hashes = new String[] { "MD2", "MD5", "SHA1", "SHA256", "SHA512" };
- String certFingerprints = "";
+ StringBuffer certFingerprints = new StringBuffer();
sb.append(pp.indent(8) + "FingerPrint\n");
for (int i = 0; i < hashes.length; i++) {
MessageDigest md = MessageDigest.getInstance(hashes[i]);
md.update(mX509Cert.getEncoded());
- certFingerprints += pp.indent(12) + hashes[i] + ":\n" +
- pp.toHexString(md.digest(), 16, 16);
+ certFingerprints.append(pp.indent(12) + hashes[i] + ":\n" +
+ pp.toHexString(md.digest(), 16, 16));
}
- sb.append(certFingerprints);
+ sb.append(certFingerprints.toString());
} catch (Exception e) {
}
diff --git a/base/util/src/netscape/security/util/ObjectIdentifier.java b/base/util/src/netscape/security/util/ObjectIdentifier.java
index 67846ec55..99de73e0d 100644
--- a/base/util/src/netscape/security/util/ObjectIdentifier.java
+++ b/base/util/src/netscape/security/util/ObjectIdentifier.java
@@ -413,14 +413,14 @@ final public class ObjectIdentifier implements Serializable {
public static ObjectIdentifier getObjectIdentifier(int values[])
throws IOException {
- String retval;
+ StringBuffer retval = new StringBuffer();
int i;
- for (i = 0, retval = ""; i < values.length; i++) {
+ for (i = 0; i < values.length; i++) {
if (i != 0)
- retval += ".";
- retval += values[i];
+ retval.append(".");
+ retval.append(values[i]);
}
- return getObjectIdentifier(retval);
+ return getObjectIdentifier(retval.toString());
}
}