1 26 package org.snipsnap.net.admin; 27 28 import org.snipsnap.config.Configuration; 29 30 import javax.servlet.http.HttpServletRequest ; 31 import javax.servlet.http.HttpServletResponse ; 32 import java.util.Map ; 33 34 public class SetupAdministrator implements SetupHandler { 35 public String getName() { 36 return "administrator"; 37 } 38 39 public Map setup(HttpServletRequest request, HttpServletResponse response, Configuration config, Map errors) { 40 String login = request.getParameter(Configuration.APP_ADMIN_LOGIN); 41 config.setAdminLogin(login); 42 if (null == login || "".equals(login)) { 43 errors.put(Configuration.APP_ADMIN_LOGIN, Configuration.APP_ADMIN_LOGIN); 44 } 45 String password = request.getParameter(Configuration.APP_ADMIN_PASSWORD); 46 String verify = request.getParameter(Configuration.APP_ADMIN_PASSWORD + ".vrfy"); 47 if ((password != null && password.length() > 0) || config.getAdminPassword() == null) { 48 if (password == null || password.length() == 0) { 49 errors.put(Configuration.APP_ADMIN_PASSWORD, Configuration.APP_ADMIN_PASSWORD); 50 } else if (!password.equals(verify)) { 51 errors.put(Configuration.APP_ADMIN_PASSWORD, Configuration.APP_ADMIN_PASSWORD + ".match"); 52 } else if (password.length() < 3) { 53 errors.put(Configuration.APP_ADMIN_PASSWORD, Configuration.APP_ADMIN_PASSWORD + ".length"); 54 } else { 55 config.setAdminPassword(password); 56 } 57 } 58 config.setAdminEmail(request.getParameter(Configuration.APP_ADMIN_EMAIL)); 59 60 return errors; 61 } 62 } 63 | Popular Tags |