Browse Source

Merge branch 'master' of https://git.coding.net/aft/AFT.git

Conflicts:
	src/main/java/com/goafanti/common/utils/AesUtils.java
albertshaw 8 years ago
parent
commit
8a7f18495f

+ 24 - 5
src/main/java/com/goafanti/admin/controller/AdminTechProjectController.java

@@ -29,6 +29,7 @@ import com.goafanti.common.model.TechProject;
 import com.goafanti.common.model.TechProjectLog;
 import com.goafanti.common.model.TechWebsite;
 import com.goafanti.common.model.User;
+import com.goafanti.common.utils.AesUtils;
 import com.goafanti.common.utils.Base64Utils;
 import com.goafanti.common.utils.FileUtils;
 import com.goafanti.common.utils.LoggerUtils;
@@ -281,7 +282,11 @@ public class AdminTechProjectController extends CertifyApiController {
 			List<TechWebsiteListBo> l = (List<TechWebsiteListBo>) t.getList();
 			for (TechWebsiteListBo w : l) {
 				if (!StringUtils.isBlank(w.getPassword())) {
-					w.setPassword(Base64Utils.decodeData(w.getPassword()));
+					try {
+						w.setPassword(AesUtils.decrypt(w.getPassword(), aesSecretKey));
+					} catch (Exception e) {
+					}
+					//w.setPassword(Base64Utils.decodeData(w.getPassword()));
 				}
 			}
 			t.setList(l);
@@ -297,7 +302,7 @@ public class AdminTechProjectController extends CertifyApiController {
 	 * @return
 	 */
 	@RequestMapping(value = "/techWebsiteDetail", method = RequestMethod.POST)
-	public Result techWebsiteDetail(String id) {
+	public Result techWebsiteDetail(String id)  {
 		Result res = new Result();
 		if (!checkAdminLogin(res)) {
 			return res;
@@ -307,8 +312,15 @@ public class AdminTechProjectController extends CertifyApiController {
 		} else {
 			TechWebsiteDetailBo w = techWebsiteService.selectTechWebsiteDetail(id);
 			if (null != w && !StringUtils.isBlank(w.getPassword())) {
-				w.setPassword(Base64Utils.decodeData(w.getPassword()));
+				try {
+					w.setPassword(AesUtils.decrypt(w.getPassword(), aesSecretKey));
+				} catch (Exception e) {
+				}
 			}
+			
+			/*if (null != w && !StringUtils.isBlank(w.getPassword())) {
+				w.setPassword(Base64Utils.decodeData(w.getPassword()));
+			}*/
 				res.setData(w);
 		}
 		return res;
@@ -321,7 +333,7 @@ public class AdminTechProjectController extends CertifyApiController {
 	 * @return
 	 */
 	@RequestMapping(value = "/disposeTechWebsite", method = RequestMethod.POST)
-	public Result disposeTechWebsite(@Valid InputTechWebsite w, BindingResult bindingResult) {
+	public Result disposeTechWebsite(@Valid InputTechWebsite w, BindingResult bindingResult)  {
 		Result res = new Result();
 		if (bindingResult.hasErrors()) {
 			res.getError().add(buildErrorByMsg(bindingResult.getFieldError().getDefaultMessage(),
@@ -342,8 +354,15 @@ public class AdminTechProjectController extends CertifyApiController {
 			return res;
 		}
 		
-		if (null != w && null != (w.getPassword())) {
+		/*if (null != w && null != (w.getPassword())) {
 			w.setPassword(Base64Utils.encodeData(w.getPassword().trim()));
+		}*/
+		
+		if (null != w && null != (w.getPassword())) {
+			try {
+				w.setPassword(AesUtils.encrypt(w.getPassword().trim(), aesSecretKey));
+			} catch (Exception e) {
+			}
 		}
 		
 		TechWebsite tw = new TechWebsite();

+ 0 - 4
src/main/java/com/goafanti/common/utils/AesUtils.java

@@ -26,11 +26,9 @@ public class AesUtils {
 			IvParameterSpec ivspec = new IvParameterSpec(key.getBytes());
 
 			cipher.init(Cipher.ENCRYPT_MODE, keyspec, ivspec);
-
 			return Base64.encodeBase64String(cipher.doFinal(plaintext));
 
 		} catch (Exception e) {
-			e.printStackTrace();
 			return null;
 		}
 	}
@@ -38,7 +36,6 @@ public class AesUtils {
 	public static String decrypt(String content, String key) throws Exception {
 		try {
 			byte[] decoded = Base64.decodeBase64(content);
-
 			Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
 			SecretKeySpec keyspec = new SecretKeySpec(key.getBytes(), "AES");
 			IvParameterSpec ivspec = new IvParameterSpec(key.getBytes());
@@ -56,7 +53,6 @@ public class AesUtils {
 			System.arraycopy(original, 0, subarray, 0, i + 1);
 			return new String(subarray);
 		} catch (Exception e) {
-			e.printStackTrace();
 			return null;
 		}
 	}

+ 1 - 1
src/main/resources/props/config_dev.properties

@@ -61,4 +61,4 @@ accessSecret=ICGuiUnqzaar7urw4zecVcJrJ1MHg9
 
 avatar.host=//afts.hnzhiming.com
 
-aesSecretKey=aft666
+aesSecretKey=aft1234567890123

+ 1 - 1
src/main/resources/props/config_local.properties

@@ -63,4 +63,4 @@ accessSecret=ICGuiUnqzaar7urw4zecVcJrJ1MHg9
 
 avatar.host=//afts.hnzhiming.com
 
-aesSecretKey=aft666
+aesSecretKey=aft1234567890123

+ 1 - 1
src/main/resources/props/config_test.properties

@@ -63,4 +63,4 @@ accessSecret=ICGuiUnqzaar7urw4zecVcJrJ1MHg9
 
 avatar.host=//aftts.hnzhiming.com
 
-aesSecretKey = aft666
+aesSecretKey =aft1234567890123