1 19 20 package com.sslexplorer.security.forms; 21 22 import javax.servlet.http.HttpServletRequest ; 23 24 import org.apache.struts.Globals; 25 import org.apache.struts.action.ActionErrors; 26 import org.apache.struts.action.ActionMapping; 27 import org.apache.struts.action.ActionMessage; 28 29 import com.sslexplorer.core.FieldValidationException; 30 import com.sslexplorer.core.forms.CoreForm; 31 32 33 43 public class UpdatePrivateKeyPassphraseForm extends CoreForm { 44 45 String oldPassphrase; 47 boolean resetPrivateKey = false; 48 49 54 public String getOldPassphrase() { 55 return oldPassphrase; 56 } 57 58 63 public void setOldPassphrase(String oldPassword) { 64 this.oldPassphrase = oldPassword.trim(); 65 } 66 67 70 public void reset(ActionMapping mapping, javax.servlet.http.HttpServletRequest request) { 71 super.reset(mapping, request); 72 oldPassphrase = null; 73 resetPrivateKey = false; 74 } 75 76 82 public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { 83 if(isCommiting()) { 84 ActionErrors errors = new ActionErrors(); 85 try { 86 if (getOldPassphrase().length() == 0 && !resetPrivateKey) { 87 throw new FieldValidationException("noOldPassphrase"); 88 } 89 } catch (FieldValidationException fve) { 90 errors.add(Globals.ERROR_KEY, new ActionMessage("updatePrivateKeyPassphrase.error." + fve.getResourceKey())); 91 } catch (Exception e) { 92 errors.add(Globals.ERROR_KEY, new ActionMessage("updatePrivateKeyPassphrase.error.validateFailed", e.getMessage())); 93 } 94 return errors; 95 } 96 else { 97 return null; 98 } 99 } 100 101 public boolean isResetPrivateKey() { 102 return resetPrivateKey; 103 } 104 105 public void setResetPrivateKey(boolean resetPrivateKey) { 106 this.resetPrivateKey = resetPrivateKey; 107 } 108 } | Popular Tags |