+
+ return false;
+ }
+
+ private void checkOrganisationData(HttpServletRequest req) throws GigiApiException {
+ email = extractParam(req, "contact");
+ optionalName = extractParam(req, "optionalName");
+ postalAddress = extractParam(req, "postalAddress");
+ if ( !EmailProvider.MAIL.matcher(email).matches()) {
+ throw new GigiApiException("Contact email is not a valid email address");
+ }
+ }
+
+ private void checkCertData(HttpServletRequest req) throws GigiApiException {
+ o = extractParam(req, "O");
+ c = extractParam(req, "C");
+ 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));
+ }
+ if (c.length() != 2) {
+ throw new GigiApiException(SprintfCommand.createSimple("{0} not given or not exactly {1} characters long", "Country code", 2));
+ }
+
+ 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();