summaryrefslogtreecommitdiffstats
path: root/base/ca
diff options
context:
space:
mode:
authorFraser Tweedale <ftweedal@redhat.com>2015-05-21 02:43:31 -0400
committerFraser Tweedale <ftweedal@redhat.com>2015-05-22 21:37:31 +1000
commitdc6f5768e815f6a8bf4cb971f1603a84945699cc (patch)
tree0be98fdabd4fffe1d64566e9726d3c31d303ee81 /base/ca
parentfe9e2d9a677317585db34ac5131d17f696c1e09e (diff)
downloadpki-dc6f5768e815f6a8bf4cb971f1603a84945699cc.tar.gz
pki-dc6f5768e815f6a8bf4cb971f1603a84945699cc.tar.xz
pki-dc6f5768e815f6a8bf4cb971f1603a84945699cc.zip
Use SimpleProperties to handle raw profile format
The store() method of the 'Properties' class escapes '=' and ':' in values, corrupting the profile data. Continue using 'Properties' to read the input (unescaping values) then copy the properties into a 'SimpleProperties' object so that unwanted backslashes do not appear in the output.
Diffstat (limited to 'base/ca')
-rw-r--r--base/ca/src/org/dogtagpki/server/ca/rest/ProfileService.java23
1 files changed, 21 insertions, 2 deletions
diff --git a/base/ca/src/org/dogtagpki/server/ca/rest/ProfileService.java b/base/ca/src/org/dogtagpki/server/ca/rest/ProfileService.java
index 78f89b012..0e708f4f4 100644
--- a/base/ca/src/org/dogtagpki/server/ca/rest/ProfileService.java
+++ b/base/ca/src/org/dogtagpki/server/ca/rest/ProfileService.java
@@ -80,6 +80,7 @@ import com.netscape.cms.realm.PKIPrincipal;
import com.netscape.cms.servlet.base.PKIService;
import com.netscape.cms.servlet.profile.PolicyConstraintFactory;
import com.netscape.cms.servlet.profile.PolicyDefaultFactory;
+import com.netscape.cmscore.base.SimpleProperties;
/**
* @author alee
@@ -537,6 +538,8 @@ public class ProfileService extends PKIService implements ProfileResource {
Map<String, String> auditParams = new LinkedHashMap<String, String>();
String profileId = null;
String classId = null;
+ // First read the data into a Properties to process escaped
+ // separator characters (':', '=') in values
Properties properties = new Properties();
try {
// load data and read profileId and classId
@@ -555,9 +558,16 @@ public class ProfileService extends PKIService implements ProfileResource {
properties.remove("profileId");
properties.remove("classId");
+ // Now copy into SimpleProperties to avoid unwanted escapes
+ // of separator characters in output
+ SimpleProperties simpleProperties = new SimpleProperties();
+ for (String k : properties.stringPropertyNames()) {
+ simpleProperties.setProperty(k, properties.getProperty(k));
+ }
+
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
- properties.store(out, null);
+ simpleProperties.store(out, null);
data = out.toByteArray(); // original data sans profileId, classId
IProfile profile = ps.getProfile(profileId);
@@ -655,6 +665,8 @@ public class ProfileService extends PKIService implements ProfileResource {
throw new BadRequestException("Cannot change profile data. Profile must be disabled");
}
+ // First read the data into a Properties to process escaped
+ // separator characters (':', '=') in values
Properties properties = new Properties();
try {
properties.load(new ByteArrayInputStream(data));
@@ -664,6 +676,13 @@ public class ProfileService extends PKIService implements ProfileResource {
properties.remove("profileId");
properties.remove("classId");
+ // Now copy into SimpleProperties to avoid unwanted escapes
+ // of separator characters in output
+ SimpleProperties simpleProperties = new SimpleProperties();
+ for (String k : properties.stringPropertyNames()) {
+ simpleProperties.setProperty(k, properties.getProperty(k));
+ }
+
try {
IProfile profile = ps.getProfile(profileId);
if (profile == null) {
@@ -671,7 +690,7 @@ public class ProfileService extends PKIService implements ProfileResource {
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
- properties.store(out, null);
+ simpleProperties.store(out, null);
data = out.toByteArray(); // original data sans profileId, classId
profile.getConfigStore().load(new ByteArrayInputStream(data));