From 947ab8aa80c430bdec9ecfced19074c3bbd661c2 Mon Sep 17 00:00:00 2001 From: Endi Sukma Dewata Date: Tue, 18 Sep 2012 10:37:06 -0500 Subject: Removed duplicate DN escaping methods. The duplicate methods to escape DN value have been removed. The codes that used the duplicate methods have been modified to use LDAPUtil.escapeDN(). Ticket #193 --- .../netscape/cms/profile/def/EnrollDefault.java | 40 ---------------------- .../def/nsTokenUserKeySubjectNameDefault.java | 5 +-- 2 files changed, 3 insertions(+), 42 deletions(-) (limited to 'base/common/src/com/netscape/cms/profile') diff --git a/base/common/src/com/netscape/cms/profile/def/EnrollDefault.java b/base/common/src/com/netscape/cms/profile/def/EnrollDefault.java index 162d1647c..53ec23b40 100644 --- a/base/common/src/com/netscape/cms/profile/def/EnrollDefault.java +++ b/base/common/src/com/netscape/cms/profile/def/EnrollDefault.java @@ -772,44 +772,4 @@ public abstract class EnrollDefault implements IPolicyDefault, ICertInfoPolicyDe } return p.substitute2("request", attrSet); } - - protected StringBuffer escapeValueRfc1779(String v, boolean doubleEscape) { - StringBuffer result = new StringBuffer(); - - // Do we need to escape any characters - for (int i = 0; i < v.length(); i++) { - int c = v.charAt(i); - if (c == ',' || c == '=' || c == '+' || c == '<' || - c == '>' || c == '#' || c == ';' || c == '\r' || - c == '\n' || c == '\\' || c == '"') { - if ((c == 0x5c) && ((i + 1) < v.length())) { - int nextC = v.charAt(i + 1); - if ((c == 0x5c) && (nextC == ',' || nextC == '=' || nextC == '+' || - nextC == '<' || nextC == '>' || nextC == '#' || - nextC == ';' || nextC == '\r' || nextC == '\n' || - nextC == '\\' || nextC == '"')) { - if (doubleEscape) - result.append('\\'); - } else { - result.append('\\'); - if (doubleEscape) - result.append('\\'); - } - } else { - result.append('\\'); - if (doubleEscape) - result.append('\\'); - } - } - if (c == '\r') { - result.append("0D"); - } else if (c == '\n') { - result.append("0A"); - } else { - result.append((char) c); - } - } - return result; - } - } diff --git a/base/common/src/com/netscape/cms/profile/def/nsTokenUserKeySubjectNameDefault.java b/base/common/src/com/netscape/cms/profile/def/nsTokenUserKeySubjectNameDefault.java index dff36748c..01cc73aba 100644 --- a/base/common/src/com/netscape/cms/profile/def/nsTokenUserKeySubjectNameDefault.java +++ b/base/common/src/com/netscape/cms/profile/def/nsTokenUserKeySubjectNameDefault.java @@ -40,6 +40,7 @@ import com.netscape.certsrv.property.Descriptor; import com.netscape.certsrv.property.EPropertyException; import com.netscape.certsrv.property.IDescriptor; import com.netscape.certsrv.request.IRequest; +import com.netscape.cmsutil.ldap.LDAPUtil; /** * This class implements an enrollment default policy @@ -429,8 +430,8 @@ public class nsTokenUserKeySubjectNameDefault extends EnrollDefault { String[] sla = la.getStringValueArray(); CMS.debug("nsTokenUserKeySubjectNameDefault: getSubjectName(): got attribute: " + mLdapStringAttrs[i] + - "=" + escapeValueRfc1779(sla[0], false).toString()); - request.setExtData(mLdapStringAttrs[i], escapeValueRfc1779(sla[0], false).toString()); + "=" + LDAPUtil.escapeDN(sla[0])); + request.setExtData(mLdapStringAttrs[i], LDAPUtil.escapeDN(sla[0])); } } CMS.debug("pattern = " + pattern); -- cgit