diff options
author | Jack Magne <jmagne@dhcp-32-224.sjc.redhat.com> | 2012-04-29 19:44:56 -0700 |
---|---|---|
committer | Jack Magne <jmagne@dhcp-32-224.sjc.redhat.com> | 2012-05-07 18:56:46 -0700 |
commit | b0bca63ac46e079e3a21ed1c4d6fd532966568d0 (patch) | |
tree | 54c880869f40d2ec9ac30c7a201f2810dbd341a0 /base/util/src | |
parent | 391d345b5a6a1a905e3db4105a65dd4fdd0d19a9 (diff) | |
download | pki-b0bca63ac46e079e3a21ed1c4d6fd532966568d0.tar.gz pki-b0bca63ac46e079e3a21ed1c4d6fd532966568d0.tar.xz pki-b0bca63ac46e079e3a21ed1c4d6fd532966568d0.zip |
Provide CA EE Restful interface and test client.
Tickets #144 and #145
Providing the following:
1. Simple EE restful interface for certificates, printing, listing and searching.
2. Simple EE restful interface for certificate enrollment requests.
3. Simple EE restful interface for profiles and profile properties.
4. Simple Test client to exercise the functionality.
5. Created restful client base class inherited by CARestClient and DRMRestClient.
6. Provide simple restful implementations of new interfaces added.
ToDO: Need some more refactoring to base classes for some of the new classes which are similar to classes
in the DRM restful area.
ToDO: Actual certificate enrollment code that will be refactored from existing ProfileSubmitServlet.
Provide CA EE Restful interface and test client review fixes.
Diffstat (limited to 'base/util/src')
-rw-r--r-- | base/util/src/com/netscape/cmsutil/ldap/LDAPUtil.java | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/base/util/src/com/netscape/cmsutil/ldap/LDAPUtil.java b/base/util/src/com/netscape/cmsutil/ldap/LDAPUtil.java index e821db67a..4409ddeaf 100644 --- a/base/util/src/com/netscape/cmsutil/ldap/LDAPUtil.java +++ b/base/util/src/com/netscape/cmsutil/ldap/LDAPUtil.java @@ -45,12 +45,13 @@ public class LDAPUtil { * @param string string to escape * @return escaped string */ - public static String escape(String string) { + public static String escapeFilter(String string) { StringBuilder sb = new StringBuilder(); for (char c : string.toCharArray()) { if (SPECIAL_CHARS.indexOf(c) >= 0) { sb.append('\\'); - if (c < 0x10) sb.append('0'); // make sure it's 2-digit + if (c < 0x10) + sb.append('0'); // make sure it's 2-digit sb.append(Integer.toHexString(c)); } else { sb.append(c); @@ -59,6 +60,45 @@ public class LDAPUtil { return sb.toString(); } + public static String escapeDN(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.toString(); + } + public static void importLDIF(LDAPConnection conn, String filename, ArrayList<String> errors) throws IOException { LDIF ldif = new LDIF(filename); while (true) { |