summaryrefslogtreecommitdiffstats
path: root/base/common/src/com/netscape/cmscore/dbs
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/src/com/netscape/cmscore/dbs
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/src/com/netscape/cmscore/dbs')
-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
4 files changed, 31 insertions, 28 deletions
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(