+ private void checkOrganisationData(HttpServletRequest req) throws GigiApiException {
+ email = extractParam(req, "contact");
+ optionalName = extractParam(req, "optionalName");
+ postalAddress = extractParam(req, "postalAddress");
+ if ( !EmailProvider.isValidMailAddress(email)) {
+ throw new GigiApiException("Contact email is not a valid email address");
+ }
+ }
+
+ 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();