1 20 21 22 package com.methodhead.reg; 23 24 import java.io.Serializable ; 25 import javax.servlet.http.HttpServletRequest ; 26 27 import org.apache.struts.action.ActionMapping; 28 import org.apache.struts.action.ActionErrors; 29 import org.apache.struts.action.ActionError; 30 import org.apache.struts.validator.DynaValidatorForm; 31 import com.methodhead.aikp.AikpForm; 32 import com.methodhead.auth.AuthUtil; 33 import java.util.List ; 34 import java.util.ArrayList ; 35 import java.util.Iterator ; 36 import org.apache.struts.Globals; 37 import org.apache.struts.util.LabelValueBean; 38 import org.apache.struts.util.MessageResources; 39 import com.methodhead.sitecontext.SiteContext; 40 import com.methodhead.util.StrutsUtil; 41 import org.apache.commons.lang.StringUtils; 42 43 public class PasswordForm 44 extends 45 DynaValidatorForm 46 implements 47 Serializable { 48 49 public ActionErrors validate( 50 ActionMapping mapping, 51 HttpServletRequest request ) { 52 53 if ( !StringUtils.isBlank( ( String )get( "cancel" ) ) ) 57 return new ActionErrors(); 58 59 ActionErrors errors = super.validate( mapping, request ); 60 61 if ( !errors.isEmpty() ) 62 return errors; 63 64 User cur = ( User )AuthUtil.getUser( request ); 65 66 if ( !cur.authenticate( ( String )get( "oldpassword" ) ) ) 70 errors.add( 71 "oldpassword", new ActionError( "reg.password.incorrectoldpassword" ) ); 72 73 if ( !get( "password" ).equals( get( "verifypassword" ) ) ) 77 errors.add( 78 "verifypassword", 79 new ActionError( "reg.password.verifypasswordmismatch" ) ); 80 81 return errors; 82 } 83 } 84 | Popular Tags |