- Organisation ne = new Organisation(o, c, st, l, LoginPage.getUser(req));
- result = ne;
- return true;
+ }
+
+ private void checkCertData(HttpServletRequest req) throws GigiApiException {
+ o = extractParam(req, "O");
+ st = extractParam(req, "ST");
+ l = extractParam(req, "L");
+
+ if (o.length() > 64 || o.length() < 1) {
+ throw new GigiApiException(SprintfCommand.createSimple("{0} not given or longer than {1} characters", "Organisation name", 64));
+ }
+
+ cs.update(req);
+
+ if (st.length() > 128 || st.length() < 1) {
+ throw new GigiApiException(SprintfCommand.createSimple("{0} not given or longer than {1} characters", "State/county", 128));
+ }
+
+ if (l.length() > 128 || l.length() < 1) {
+ throw new GigiApiException(SprintfCommand.createSimple("{0} not given or longer than {1} characters", "Town/suburb", 128));
+ }
+ }
+
+ private String extractParam(HttpServletRequest req, String name) {
+ String parameter = req.getParameter(name);
+ if (parameter == null) {
+ return "";
+ }
+ return parameter.trim();