Explorar o código

1.添加用户导入controller

yapeng.li %!s(int64=4) %!d(string=hai) anos
pai
achega
9b39775eb0

+ 3 - 0
maxkey-core/src/main/java/org/maxkey/constants/ConstantsOperateMessage.java

@@ -28,4 +28,7 @@ public final class ConstantsOperateMessage {
     public static final String DELETE_SUCCESS = "message.action.delete.success";
     public static final String DELETE_ERROR = "message.action.delete.error";
 
+    public static final String import_success = "message.action.import.success";
+    public static final String IMPORT_ERROR = "message.action.import.error";
+
 }

+ 64 - 0
maxkey-core/src/main/java/org/maxkey/domain/ImportResultBaseVO.java

@@ -0,0 +1,64 @@
+package org.maxkey.domain;
+
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * @author yapeng.li
+ * @date 2019.3.6
+ */
+public class ImportResultBaseVO {
+    /**
+     * 资源名
+     */
+    private String name;
+    /**
+     * 状态
+     */
+    private String status;
+    /**
+     * 描述
+     */
+    private String desc;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        if(status==0){
+            this.status = "SUCCESS";
+        }else if(status==1){
+            this.status = "FAILURE";
+        }else{
+            this.status = "IGNORE";
+        }
+    }
+
+    public String getDesc() {
+        if(StringUtils.isEmpty(desc)){
+            return "";
+        }
+        return desc;
+    }
+
+    public void setDesc(String desc) {
+        this.desc = desc;
+    }
+
+    @Override
+    public String toString() {
+        return "ImportResultBaseVO{" +
+                "name='" + name + '\'' +
+                ", status='" + status + '\'' +
+                ", desc='" + desc + '\'' +
+                '}';
+    }
+}

+ 105 - 0
maxkey-core/src/main/java/org/maxkey/domain/ImportResultVO.java

@@ -0,0 +1,105 @@
+package org.maxkey.domain;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author yapeng.li
+ * @since 2020/9/21 21:12
+ */
+public class ImportResultVO {
+
+    /**
+     * 成功结果
+     */
+    List<ImportResultBaseVO> success;
+    /**
+     * 失败结果
+     */
+    List<ImportResultBaseVO> error;
+    /**
+     * 忽略结果
+     */
+    List<ImportResultBaseVO> ignore;
+    /**
+     * 成功次数
+     */
+    Integer successCount;
+    /**
+     * 失败次数
+     */
+    Integer errorCount;
+    /**
+     * 忽略次数
+     */
+    Integer ignoreCount;
+
+    public List<ImportResultBaseVO> getSuccess() {
+        if(success==null){
+            success = new ArrayList<>();
+        }
+        return success;
+    }
+
+    public void setSuccess(List<ImportResultBaseVO> success) {
+        this.success = success;
+    }
+
+    public List<ImportResultBaseVO> getError() {
+        if(error==null){
+            error = new ArrayList<>();
+        }
+        return error;
+    }
+
+    public void setError(List<ImportResultBaseVO> error) {
+        this.error = error;
+    }
+
+    public List<ImportResultBaseVO> getIgnore() {
+        if(ignore==null){
+            ignore = new ArrayList<>();
+        }
+        return ignore;
+    }
+
+    public void setIgnore(List<ImportResultBaseVO> ignore) {
+        this.ignore = ignore;
+    }
+
+    public Integer getSuccessCount() {
+        return successCount;
+    }
+
+    public void setSuccessCount(Integer successCount) {
+        this.successCount = successCount;
+    }
+
+    public Integer getErrorCount() {
+        return errorCount;
+    }
+
+    public void setErrorCount(Integer errorCount) {
+        this.errorCount = errorCount;
+    }
+
+    public Integer getIgnoreCount() {
+        return ignoreCount;
+    }
+
+    public void setIgnoreCount(Integer ignoreCount) {
+        this.ignoreCount = ignoreCount;
+    }
+
+    @Override
+    public String toString() {
+        return "ImportResultVO{" +
+                "success=" + success +
+                ", error=" + error +
+                ", ignore=" + ignore +
+                ", successCount=" + successCount +
+                ", errorCount=" + errorCount +
+                ", ignoreCount=" + ignoreCount +
+                '}';
+    }
+}

+ 20 - 0
maxkey-core/src/main/java/org/maxkey/util/ExcelUtils.java

@@ -0,0 +1,20 @@
+package org.maxkey.util;
+
+import org.maxkey.domain.UserInfo;
+
+import java.io.InputStream;
+import java.util.List;
+
+/**
+ * @author yapeng.li
+ * @since 2020/9/21 21:06
+ */
+public class ExcelUtils {
+
+
+    public static List<UserInfo> readExcel(InputStream in) throws Exception {
+
+
+        return null;
+    }
+}

+ 63 - 49
maxkey-persistence/src/main/java/org/maxkey/persistence/service/UserInfoService.java

@@ -1,19 +1,19 @@
 /*
  * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *     http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
- 
+
 
 package org.maxkey.persistence.service;
 
@@ -23,6 +23,7 @@ import org.maxkey.constants.ConstantsStatus;
 import org.maxkey.crypto.ReciprocalUtils;
 import org.maxkey.crypto.password.PasswordReciprocal;
 import org.maxkey.domain.ChangePassword;
+import org.maxkey.domain.ImportResultVO;
 import org.maxkey.domain.UserInfo;
 import org.maxkey.identity.kafka.KafkaIdentityAction;
 import org.maxkey.identity.kafka.KafkaIdentityTopic;
@@ -38,6 +39,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.security.crypto.password.PasswordEncoder;
 import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
 
 
 /**
@@ -47,20 +49,20 @@ import org.springframework.stereotype.Service;
 @Service
 public class UserInfoService extends JpaBaseService<UserInfo> {
 	final static Logger _logger = LoggerFactory.getLogger(UserInfoService.class);
-	
+
 	final static  String UPDATE_GRIDLIST_SQL = "UPDATE MXK_USERINFO SET GRIDLIST = ? WHERE ID = ?";
 	@Autowired
 	private PasswordEncoder passwordEncoder;
-	
+
 	@Autowired
 	PasswordPolicyValidator passwordPolicyValidator;
-	
+
 	@Autowired
 	KafkaProvisioningService kafkaProvisioningService;
-	
+
 	 @Autowired
 	 protected JdbcTemplate jdbcTemplate;
-	
+
 	public UserInfoService() {
 		super(UserInfoMapper.class);
 	}
@@ -73,12 +75,12 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
 		// TODO Auto-generated method stub
 		return (UserInfoMapper)super.getMapper();
 	}
-	
+
     public boolean insert(UserInfo userInfo) {
         userInfo = passwordEncoder(userInfo);
         if (super.insert(userInfo)) {
             kafkaProvisioningService.send(
-                    KafkaIdentityTopic.USERINFO_TOPIC, 
+                    KafkaIdentityTopic.USERINFO_TOPIC,
                     userInfo,
                     KafkaIdentityAction.CREATE_ACTION);
             return true;
@@ -86,26 +88,38 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
 
         return false;
     }
-	
+
     public boolean update(UserInfo userInfo) {
         userInfo = passwordEncoder(userInfo);
         if (super.update(userInfo)) {
             kafkaProvisioningService.send(
-                    KafkaIdentityTopic.USERINFO_TOPIC, 
+                    KafkaIdentityTopic.USERINFO_TOPIC,
                     userInfo,
                     KafkaIdentityAction.UPDATE_ACTION);
-           
+
             changePasswordProvisioning(userInfo);
             return true;
         }
         return false;
     }
-	
+
+    public ImportResultVO importing(MultipartFile file,Integer type){
+
+		// 校验当前文件格式是不是excel文件
+
+		// 解析excel文件中数据
+
+		// 判断当前类型 0忽略 1覆盖 2终止
+		// 返回导入结果
+
+		return new ImportResultVO();
+	}
+
 	public boolean delete(UserInfo userInfo) {
 		if( super.delete(userInfo)){
 		    kafkaProvisioningService.send(
-		            KafkaIdentityTopic.USERINFO_TOPIC, 
-		            userInfo, 
+		            KafkaIdentityTopic.USERINFO_TOPIC,
+		            userInfo,
 		            KafkaIdentityAction.DELETE_ACTION);
 			 return true;
 		}
@@ -126,8 +140,8 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
         }
 	    return true;
 	}
-	
-	
+
+
 	public boolean updateProtectedApps(UserInfo userinfo) {
 		try {
 			if(WebContext.getUserInfo() != null) {
@@ -144,7 +158,7 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
 	public UserInfo loadByUsername(String username) {
 		return getMapper().loadByUsername(username);
 	}
-	
+
 	public UserInfo loadByAppIdAndUsername(String appId,String username){
 		try {
 			UserInfo userinfo = new UserInfo();
@@ -155,7 +169,7 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
 		}
 		return null;
 	}
-	
+
 
 	public void logisticDeleteAllByCid(String cid){
 		try {
@@ -164,7 +178,7 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
 			e.printStackTrace();
 		}
 	}
-	
+
 	public UserInfo passwordEncoder(UserInfo userInfo) {
 	    //密码不为空,则需要进行加密处理
 	    if(userInfo.getPassword()!=null && !userInfo.getPassword().equals("")) {
@@ -173,13 +187,13 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
             _logger.debug("decipherable : "+userInfo.getDecipherable());
             userInfo.setPassword(password);
             userInfo.setPasswordLastSetTime(DateUtils.getCurrentDateTimeAsString());
-            
+
             userInfo.setModifiedDate(DateUtils.getCurrentDateTimeAsString());
 	    }
         return userInfo;
 	}
-	
-	
+
+
 	public boolean changePassword(String oldPassword,
             String newPassword,
             String confirmPassword) {
@@ -191,37 +205,37 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
 	        changeUserInfo.setPassword(newPassword);
 	        changeUserInfo.setId(userInfo.getId());
 	        changeUserInfo.setDecipherable(userInfo.getDecipherable());
-	        
+
 	        if(newPassword.equals(confirmPassword)){
-	            if(oldPassword==null || 
+	            if(oldPassword==null ||
 	                    passwordEncoder.matches(oldPassword, userInfo.getPassword())){
 	                if(changePassword(changeUserInfo) ){
 	                    userInfo.setPassword(changeUserInfo.getPassword());
                         userInfo.setDecipherable(changeUserInfo.getDecipherable());
 	                    return true;
 	                }
-	                return false;	               
+	                return false;
 	            }else {
 	                if(oldPassword!=null &&
 	                        passwordEncoder.matches(newPassword, userInfo.getPassword())) {
-	                    WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT, 
+	                    WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT,
 	                            WebContext.getI18nValue("PasswordPolicy.OLD_PASSWORD_MATCH"));
 	                }else {
-	                    WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT, 
+	                    WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT,
 	                        WebContext.getI18nValue("PasswordPolicy.OLD_PASSWORD_NOT_MATCH"));
 	                }
 	            }
 	        }else {
-	            WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT, 
+	            WebContext.setAttribute(PasswordPolicyValidator.PASSWORD_POLICY_VALIDATE_RESULT,
 	                    WebContext.getI18nValue("PasswordPolicy.CONFIRMPASSWORD_NOT_MATCH"));
 	        }
 		 } catch (Exception e) {
              e.printStackTrace();
-         }    
-		    
+         }
+
 		return false;
 	}
-	
+
     public boolean changePassword(UserInfo changeUserInfo) {
         try {
             _logger.debug("decipherable old : " + changeUserInfo.getDecipherable());
@@ -251,11 +265,11 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
 
         return false;
     }
-	
+
 	public String randomPassword() {
 	    return passwordPolicyValidator.generateRandomPassword();
 	}
-	
+
 	public void changePasswordProvisioning(UserInfo userInfo) {
 	    if(userInfo.getPassword()!=null && !userInfo.getPassword().equals("")) {
     	    ChangePassword changePassword=new ChangePassword();
@@ -265,12 +279,12 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
             changePassword.setDecipherable(userInfo.getDecipherable());
             changePassword.setPassword(userInfo.getPassword());
             kafkaProvisioningService.send(
-                    KafkaIdentityTopic.PASSWORD_TOPIC, 
-                    changePassword, 
+                    KafkaIdentityTopic.PASSWORD_TOPIC,
+                    changePassword,
                     KafkaIdentityAction.PASSWORD_ACTION);
 	    }
 	}
-	
+
 	public boolean changeAppLoginPassword(UserInfo userinfo) {
 		try {
 			if(WebContext.getUserInfo() != null) {
@@ -283,8 +297,8 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
 		}
 		return false;
 	}
-	
-	
+
+
 	/**
 	 * 锁定用户:islock:1 用户解锁 2 用户锁定
 	 * @param userInfo
@@ -331,33 +345,33 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
 			e.printStackTrace();
 		}
 	}
-	
+
 	public boolean changeSharedSecret(UserInfo userInfo){
 		return getMapper().changeSharedSecret(userInfo)>0;
 	}
-	
+
 	public boolean changePasswordQuestion(UserInfo userInfo){
 		return getMapper().changePasswordQuestion(userInfo)>0;
 	}
-	
+
 	public boolean changeAuthnType(UserInfo userInfo){
 		return getMapper().changeAuthnType(userInfo)>0;
 	}
-	
+
 	public boolean changeEmail(UserInfo userInfo){
 		return getMapper().changeEmail(userInfo)>0;
 	}
-	
+
 	public boolean changeMobile(UserInfo userInfo){
 		return getMapper().changeMobile(userInfo)>0;
 	}
-	
+
     public UserInfo queryUserInfoByEmailMobile(String emailMobile) {
         return getMapper().queryUserInfoByEmailMobile(emailMobile);
     }
-    
+
     public int updateProfile(UserInfo userInfo){
-        
+
         return getMapper().updateProfile(userInfo);
     }
 

+ 128 - 101
maxkey-web-manage/src/main/java/org/maxkey/web/contorller/UserInfoController.java

@@ -172,107 +172,134 @@ public class UserInfoController {
 	 * @return
 	 */
 
-	@RequestMapping(value="/update") 
-	public ModelAndView updateUsers(@Valid  @ModelAttribute("userInfo")UserInfo userInfo,BindingResult result) {
-		_logger.debug(userInfo.toString());
-		if(result.hasErrors()){
-			// new Message(WebContext.getValidErrorText(),result);
-		}
-		_logger.info(userInfo.getExtraAttributeName());
-		_logger.info(userInfo.getExtraAttributeValue());
-		//userInfo.setNameZHShortSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), true));
-		//userInfo.setNameZHSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), false));
-		convertExtraAttribute(userInfo) ;
-		_logger.info(userInfo.getExtraAttribute());
-		if(userInfoService.update(userInfo)) {
-			new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),userInfo,MessageType.success,OperateType.add,MessageScope.DB);
-			
-		}
-	    new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
-		return   WebContext.forward("forwardUpdate/"+userInfo.getId());
-	}
-	
-	
-	/**
-	 * 批量删除用户
-	 * @param id
-	 * @return
-	 */
-	@ResponseBody
-	@RequestMapping(value="/batchDelete")  
-	public Message batchDeleteUsers(@RequestParam("id")String id) {
-		_logger.debug(id);
-		if(userInfoService.batchDelete(StringUtils.string2List(id, ","))) {
-			return  new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.success);
-			
-		} else {
-			return  new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_ERROR),MessageType.error);
-		}
-	}
-	
-	/**
-	 * 根据用户id删除用户
-	 * 
-	 * @param id
-	 * @return
-	 */
-	@ResponseBody
-	@RequestMapping(value="/delete")  
-	public Message deleteUsersById(@RequestParam("id") String id) {
-		_logger.debug(id);
-		if(userInfoService.batchDelete(StringUtils.string2List(id, ","))) {
-			//provisioningPrepare.prepare(userInfo, OPERATEACTION.DELETE_ACTION);
-			return  new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.success);
-		} else {
-			return  new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_ERROR),MessageType.error);
-		}
-	}
-	
-	protected void convertExtraAttribute(UserInfo userInfo) {
-		if(userInfo.getExtraAttributeValue()!=null){
-			String []extraAttributeLabel=userInfo.getExtraAttributeName().split(",");
-			String []extraAttributeValue=userInfo.getExtraAttributeValue().split(",");
-			Map<String,String> extraAttributeMap=new HashMap<String,String> ();
-			for(int i=0;i<extraAttributeLabel.length;i++){
-				extraAttributeMap.put(extraAttributeLabel[i], extraAttributeValue[i]);
-			}
-			String extraAttribute=JsonUtils.object2Json(extraAttributeMap);
-			userInfo.setExtraAttribute(extraAttribute);
-		}
-	}
-	
-	@RequestMapping(value={"/forwardChangePassword/{id}"})
-	public ModelAndView forwardChangePassword(@PathVariable("id")String id){
-		ModelAndView modelAndView=new ModelAndView("/userinfo/changePassword");
-		UserInfo userInfo=userInfoService.get(id);
-		
-		modelAndView.addObject("model", userInfo);
-		return modelAndView;
-	}
-	
-	@ResponseBody
-	@RequestMapping(value="/changePassword")  
-	public Message changePassword( @ModelAttribute("userInfo")UserInfo userInfo) {
-		_logger.debug(userInfo.getId());
-		if(userInfoService.changePassword(userInfo)) {
-			return  new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
-			
-		} else {
-			return  new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
-		}
-	}
-	
-	@InitBinder
-	public void binder(WebDataBinder binder) {
-		binder.registerCustomEditor(String.class, new PropertyEditorSupport() {
-		    @Override
-			public void setAsText(String value) {
-		        	if(StringUtils.isNullOrBlank(value)){
-		        		setValue(null);
-		        	}else{
-		        		setValue(value);
-		        	}
-		    }
+    @RequestMapping(value = "/update")
+    public ModelAndView updateUsers(@Valid @ModelAttribute("userInfo") UserInfo userInfo, BindingResult result) {
+        _logger.debug(userInfo.toString());
+        if (result.hasErrors()) {
+            // new Message(WebContext.getValidErrorText(),result);
+        }
+        _logger.info(userInfo.getExtraAttributeName());
+        _logger.info(userInfo.getExtraAttributeValue());
+        //userInfo.setNameZHShortSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), true));
+        //userInfo.setNameZHSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), false));
+        convertExtraAttribute(userInfo);
+        _logger.info(userInfo.getExtraAttribute());
+        if (userInfoService.update(userInfo)) {
+            new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS), userInfo, MessageType.success, OperateType.add, MessageScope.DB);
+
+        }
+        new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR), MessageType.error);
+        return WebContext.forward("forwardUpdate/" + userInfo.getId());
+    }
+
+    /**
+     * 用户excel导入
+     *
+     * @param userInfo
+     * @param result
+     * @return
+     */
+    /**
+     *
+     * @param file excel文件
+     * @param type //重名处理方式 0忽略 1覆盖 2终止
+     * @return
+     */
+    @RequestMapping(value = "/importing")
+    public Object importing(@RequestParam(value = "file") MultipartFile file,@RequestParam Integer type ) {
+    	// 判断当前上传文件是否存在
+        if (file == null || file.getSize() <= 0) {
+            return new Message(WebContext.getI18nValue(ConstantsOperateMessage.IMPORT_ERROR), MessageType.error);
+        }
+        if (file.getSize() > 1048576 * 256) {
+            return new Message(WebContext.getI18nValue(ConstantsOperateMessage.IMPORT_ERROR), MessageType.error);
+        }
+        _logger.debug(file.getOriginalFilename(),type);
+        return userInfoService.importing(file,type);
+    }
+
+
+    /**
+     * 批量删除用户
+     *
+     * @param id
+     * @return
+     */
+    @ResponseBody
+    @RequestMapping(value = "/batchDelete")
+    public Message batchDeleteUsers(@RequestParam("id") String id) {
+        _logger.debug(id);
+        if (userInfoService.batchDelete(StringUtils.string2List(id, ","))) {
+            return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS), MessageType.success);
+
+        } else {
+            return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_ERROR), MessageType.error);
+        }
+    }
+
+    /**
+     * 根据用户id删除用户
+     *
+     * @param id
+     * @return
+     */
+    @ResponseBody
+    @RequestMapping(value = "/delete")
+    public Message deleteUsersById(@RequestParam("id") String id) {
+        _logger.debug(id);
+        if (userInfoService.batchDelete(StringUtils.string2List(id, ","))) {
+            //provisioningPrepare.prepare(userInfo, OPERATEACTION.DELETE_ACTION);
+            return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS), MessageType.success);
+        } else {
+            return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_ERROR), MessageType.error);
+        }
+    }
+
+    protected void convertExtraAttribute(UserInfo userInfo) {
+        if (userInfo.getExtraAttributeValue() != null) {
+            String[] extraAttributeLabel = userInfo.getExtraAttributeName().split(",");
+            String[] extraAttributeValue = userInfo.getExtraAttributeValue().split(",");
+            Map<String, String> extraAttributeMap = new HashMap<String, String>();
+            for (int i = 0; i < extraAttributeLabel.length; i++) {
+                extraAttributeMap.put(extraAttributeLabel[i], extraAttributeValue[i]);
+            }
+            String extraAttribute = JsonUtils.object2Json(extraAttributeMap);
+            userInfo.setExtraAttribute(extraAttribute);
+        }
+    }
+
+    @RequestMapping(value = {"/forwardChangePassword/{id}"})
+    public ModelAndView forwardChangePassword(@PathVariable("id") String id) {
+        ModelAndView modelAndView = new ModelAndView("/userinfo/changePassword");
+        UserInfo userInfo = userInfoService.get(id);
+
+        modelAndView.addObject("model", userInfo);
+        return modelAndView;
+    }
+
+    @ResponseBody
+    @RequestMapping(value = "/changePassword")
+    public Message changePassword(@ModelAttribute("userInfo") UserInfo userInfo) {
+        _logger.debug(userInfo.getId());
+        if (userInfoService.changePassword(userInfo)) {
+            return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS), MessageType.success);
+
+        } else {
+            return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR), MessageType.error);
+        }
+    }
+
+    @InitBinder
+    public void binder(WebDataBinder binder) {
+        binder.registerCustomEditor(String.class, new PropertyEditorSupport() {
+            @Override
+            public void setAsText(String value) {
+                if (StringUtils.isNullOrBlank(value)) {
+                    setValue(null);
+                } else {
+                    setValue(value);
+                }
+            }
 
 		    
 		});