summaryrefslogtreecommitdiffstats
path: root/pki/base/common/src/com/netscape/certsrv/util/HttpInput.java
diff options
context:
space:
mode:
authorAde Lee <alee@redhat.com>2012-01-11 13:58:57 -0500
committerAde Lee <alee@redhat.com>2012-01-11 13:58:57 -0500
commitfbbf6c77236902e726faafe380a5ddf1891e8dc9 (patch)
tree1e671265cbd3d4072838eeec51b6a2ec77bed7d1 /pki/base/common/src/com/netscape/certsrv/util/HttpInput.java
parentf7a1d6a79d1b0367e556d5c53fe5e0c07c7b5c66 (diff)
downloadpki-fbbf6c77236902e726faafe380a5ddf1891e8dc9.tar.gz
pki-fbbf6c77236902e726faafe380a5ddf1891e8dc9.tar.xz
pki-fbbf6c77236902e726faafe380a5ddf1891e8dc9.zip
Formatting - no wrap in comments and code
Diffstat (limited to 'pki/base/common/src/com/netscape/certsrv/util/HttpInput.java')
-rw-r--r--pki/base/common/src/com/netscape/certsrv/util/HttpInput.java197
1 files changed, 84 insertions, 113 deletions
diff --git a/pki/base/common/src/com/netscape/certsrv/util/HttpInput.java b/pki/base/common/src/com/netscape/certsrv/util/HttpInput.java
index 4f68bf63..9b7eec1d 100644
--- a/pki/base/common/src/com/netscape/certsrv/util/HttpInput.java
+++ b/pki/base/common/src/com/netscape/certsrv/util/HttpInput.java
@@ -26,19 +26,16 @@ import javax.servlet.http.HttpServletRequest;
import netscape.ldap.LDAPDN;
-public class HttpInput
-{
- public static int getPortNumberInInt(HttpServletRequest request, String name)
- throws IOException
- {
+public class HttpInput {
+ public static int getPortNumberInInt(HttpServletRequest request, String name)
+ throws IOException {
String val = request.getParameter(name);
int p = Integer.parseInt(val);
return p;
}
-
+
public static String getBoolean(HttpServletRequest request, String name)
- throws IOException
- {
+ throws IOException {
String val = request.getParameter(name);
if (val.equals("true") || val.equals("false")) {
return val;
@@ -47,8 +44,7 @@ public class HttpInput
}
public static String getCheckbox(HttpServletRequest request, String name)
- throws IOException
- {
+ throws IOException {
String val = request.getParameter(name);
if (val == null || val.equals("")) {
return "off";
@@ -59,8 +55,7 @@ public class HttpInput
}
public static String getInteger(HttpServletRequest request, String name)
- throws IOException
- {
+ throws IOException {
String val = request.getParameter(name);
int p = 0;
try {
@@ -75,9 +70,8 @@ public class HttpInput
return val;
}
- public static String getInteger(HttpServletRequest request, String name,
- int min, int max) throws IOException
- {
+ public static String getInteger(HttpServletRequest request, String name,
+ int min, int max) throws IOException {
String val = getInteger(request, name);
int p = Integer.parseInt(val);
if (p < min || p > max) {
@@ -85,41 +79,36 @@ public class HttpInput
}
return val;
}
-
+
public static String getPortNumber(HttpServletRequest request, String name)
- throws IOException
- {
- String v = getInteger(request, name);
+ throws IOException {
+ String v = getInteger(request, name);
return v;
}
-
+
public static String getString(HttpServletRequest request, String name)
- throws IOException
- {
+ throws IOException {
String val = request.getParameter(name);
return val;
}
public static String getString(HttpServletRequest request, String name,
- int minlen, int maxlen) throws IOException
- {
+ int minlen, int maxlen) throws IOException {
String val = request.getParameter(name);
if (val.length() < minlen || val.length() > maxlen) {
- throw new IOException("String length of '" + val +
- "' is out of range");
+ throw new IOException("String length of '" + val +
+ "' is out of range");
}
return val;
}
-
+
public static String getLdapDatabase(HttpServletRequest request, String name)
- throws IOException
- {
+ throws IOException {
return getString(request, name);
}
-
+
public static String getURL(HttpServletRequest request, String name)
- throws IOException
- {
+ throws IOException {
String v = getString(request, name);
try {
URL u = new URL(v);
@@ -128,163 +117,145 @@ public class HttpInput
}
return v;
}
-
+
public static String getUID(HttpServletRequest request, String name)
- throws IOException
- {
+ throws IOException {
return getString(request, name);
}
-
+
public static String getPassword(HttpServletRequest request, String name)
- throws IOException
- {
+ throws IOException {
return getString(request, name);
}
public static String getKeyType(HttpServletRequest request, String name)
- throws IOException
- {
+ throws IOException {
String v = getString(request, name);
if (v.equals("rsa")) {
- return v;
+ return v;
}
if (v.equals("ecc")) {
- return v;
+ return v;
}
throw new IOException("Invalid key type '" + v + "' not supported.");
}
-
+
public static String getKeySize(HttpServletRequest request, String name)
- throws IOException
- {
+ throws IOException {
String i = getInteger(request, name);
if (i.equals("256") || i.equals("512") || i.equals("1024") ||
- i.equals("2048") || i.equals("4096")) {
- return i;
+ i.equals("2048") || i.equals("4096")) {
+ return i;
}
throw new IOException("Invalid key length '" + i + "'. Currently supported key lengths are 256, 512, 1024, 2048, 4096.");
}
public static String getKeySize(HttpServletRequest request, String name, String keyType)
- throws IOException
- {
+ throws IOException {
String i = getInteger(request, name);
if (keyType.equals("rsa")) {
- if (i.equals("256") || i.equals("512") || i.equals("1024") ||
- i.equals("2048") || i.equals("4096")) {
- return i;
- } else {
- throw new IOException("Invalid key length '" + i + "'. Currently supported RSA key lengths are 256, 512, 1024, 2048, 4096.");
- }
+ if (i.equals("256") || i.equals("512") || i.equals("1024") ||
+ i.equals("2048") || i.equals("4096")) {
+ return i;
+ } else {
+ throw new IOException("Invalid key length '" + i + "'. Currently supported RSA key lengths are 256, 512, 1024, 2048, 4096.");
+ }
}
if (keyType.equals("ecc")) {
- int p = 0;
- try {
- p = Integer.parseInt(i);
- } catch (NumberFormatException e) {
- throw new IOException("Input '" + i + "' is not an integer");
- }
- if ((p >= 112) && (p <= 571))
- return i;
- else {
- throw new IOException("Invalid key length '" + i + "'. Please consult your security officer for a proper length, or take the default value. Here are examples of some commonly used key lengths: 256, 384, 521.");
- }
-/*
+ int p = 0;
+ try {
+ p = Integer.parseInt(i);
+ } catch (NumberFormatException e) {
+ throw new IOException("Input '" + i + "' is not an integer");
+ }
+ if ((p >= 112) && (p <= 571))
+ return i;
+ else {
+ throw new IOException("Invalid key length '" + i + "'. Please consult your security officer for a proper length, or take the default value. Here are examples of some commonly used key lengths: 256, 384, 521.");
+ }
+ /*
- if (i.equals("256") || i.equals("384") || i.equals("521")) {
- return i;
- } else {
- throw new IOException("Invalid key length '" + i + "'. Currently supported ECC key lengths are 256, 384, 521.");
- }
-*/
+ if (i.equals("256") || i.equals("384") || i.equals("521")) {
+ return i;
+ } else {
+ throw new IOException("Invalid key length '" + i + "'. Currently supported ECC key lengths are 256, 384, 521.");
+ }
+ */
}
throw new IOException("Invalid key type '" + keyType + "'");
}
-
+
public static String getDN(HttpServletRequest request, String name)
- throws IOException
- {
+ throws IOException {
String v = getString(request, name);
String dn[] = LDAPDN.explodeDN(v, true);
if (dn == null || dn.length <= 0) {
- throw new IOException("Invalid DN " + v + " in " + name);
+ throw new IOException("Invalid DN " + v + " in " + name);
}
return v;
}
-
+
public static String getID(HttpServletRequest request, String name)
- throws IOException
- {
+ throws IOException {
return getString(request, name);
}
-
+
public static String getName(HttpServletRequest request, String name)
- throws IOException
- {
+ throws IOException {
return getString(request, name);
}
-
+
public static String getCertRequest(HttpServletRequest request, String name)
- throws IOException
- {
+ throws IOException {
return getString(request, name);
}
-
+
public static String getCertChain(HttpServletRequest request, String name)
- throws IOException
- {
+ throws IOException {
return getString(request, name);
}
-
+
public static String getCert(HttpServletRequest request, String name)
- throws IOException
- {
+ throws IOException {
return getString(request, name);
}
public static String getNickname(HttpServletRequest request, String name)
- throws IOException
- {
+ throws IOException {
return getString(request, name);
}
-
+
public static String getHostname(HttpServletRequest request, String name)
- throws IOException
- {
+ throws IOException {
return getString(request, name);
}
-
+
public static String getTokenName(HttpServletRequest request, String name)
- throws IOException
- {
+ throws IOException {
return getString(request, name);
}
public static String getReplicationAgreementName(HttpServletRequest request, String name)
- throws IOException
- {
+ throws IOException {
return getString(request, name);
}
-
+
public static String getEmail(HttpServletRequest request, String name)
- throws IOException
- {
+ throws IOException {
String v = getString(request, name);
if (v.indexOf('@') == -1) {
- throw new IOException("Invalid email " + v);
+ throw new IOException("Invalid email " + v);
}
return v;
}
-
+
public static String getDomainName(HttpServletRequest request, String name)
- throws IOException
- {
+ throws IOException {
return getString(request, name);
}
-
- public static String getSecurityDomainName(HttpServletRequest request, String name)
- throws IOException
- {
+
+ public static String getSecurityDomainName(HttpServletRequest request, String name)
+ throws IOException {
String v = getName(request, name);
Pattern p = Pattern.compile("[A-Za-z0-9]+[A-Za-z0-9 -]*");
Matcher m = p.matcher(v);