summaryrefslogtreecommitdiffstats
path: root/base/common
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 /base/common
parenta4db0f39e257950a5c89203452c1184c7080e5bd (diff)
downloadpki-9db76ed1d1f8969e93aaff320e49662f53688e2e.tar.gz
pki-9db76ed1d1f8969e93aaff320e49662f53688e2e.tar.xz
pki-9db76ed1d1f8969e93aaff320e49662f53688e2e.zip
Fixes for Coverity Defects of Category : FB.SBSC_USE_STRINGBUFFER_CONCATENATION
Diffstat (limited to 'base/common')
-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
16 files changed, 140 insertions, 145 deletions
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;