Browse Source

加token校验

master
hzzz 7 years ago
parent
commit
26401dbf5b
  1. 5
      designer/src/com/fr/design/mainframe/alphafine/search/manager/RecommendSearchManager.java
  2. 24
      designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java
  3. 2
      designer_base/src/com/fr/design/DesignModelAdapter.java
  4. 4
      designer_base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  5. 4
      designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java

5
designer/src/com/fr/design/mainframe/alphafine/search/manager/RecommendSearchManager.java

@ -1,6 +1,7 @@
package com.fr.design.mainframe.alphafine.search.manager; package com.fr.design.mainframe.alphafine.search.manager;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.SiteCenterToken;
import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.AlphaFineHelper;
import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.CellType;
@ -43,7 +44,9 @@ public class RecommendSearchManager implements AlphaFineSearchProcessor {
this.recommendModelList = new SearchResult(); this.recommendModelList = new SearchResult();
if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainRecommend()) { if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isContainRecommend()) {
String result; String result;
HttpClient httpClient = new HttpClient(AlphaFineConstants.SEARCH_API + CodeUtils.cjkEncode(searchText)); String url = AlphaFineConstants.SEARCH_API + CodeUtils.cjkEncode(searchText);
url = String.format("%s?token=%s", url, SiteCenterToken.generateToken());
HttpClient httpClient = new HttpClient(url);
httpClient.asGet(); httpClient.asGet();
if (!httpClient.isServerAlive()) { if (!httpClient.isServerAlive()) {
return getNoConnectList(); return getNoConnectList();

24
designer/src/com/fr/design/mainframe/errorinfo/ErrorInfoUploader.java

@ -1,6 +1,7 @@
package com.fr.design.mainframe.errorinfo; package com.fr.design.mainframe.errorinfo;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.mainframe.SiteCenterToken;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger; import com.fr.general.FRLogger;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
@ -11,8 +12,6 @@ import com.fr.json.JSONException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
import com.fr.license.function.VT4FR; import com.fr.license.function.VT4FR;
import com.fr.log.LogHandler; import com.fr.log.LogHandler;
import com.fr.regist.FRCoreContext;
import com.fr.regist.LicenseListener;
import com.fr.stable.CodeUtils; import com.fr.stable.CodeUtils;
import com.fr.stable.EnvChangedListener; import com.fr.stable.EnvChangedListener;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
@ -50,7 +49,7 @@ public class ErrorInfoUploader {
}); });
} }
}); });
} }
private ErrorInfoUploader() { private ErrorInfoUploader() {
@ -71,8 +70,8 @@ public class ErrorInfoUploader {
} }
// 从云中心更新最新的解决方案文件 // 从云中心更新最新的解决方案文件
private void checkUpdateSolution(){ private void checkUpdateSolution() {
if (!VT4FR.AlphaFine.support()) { if (!VT4FR.AlphaFine.support()) {
return; return;
} }
@ -94,6 +93,7 @@ public class ErrorInfoUploader {
private void downloadSolution(File localCacheZip) { private void downloadSolution(File localCacheZip) {
try { try {
String downloadURL = SiteCenter.getInstance().acquireUrlByKind("solution.download", "http://cloud.fanruan.com/api/solution"); String downloadURL = SiteCenter.getInstance().acquireUrlByKind("solution.download", "http://cloud.fanruan.com/api/solution");
downloadURL = String.format("%s?token=%s", downloadURL, SiteCenterToken.generateToken());
HttpClient hc = new HttpClient(downloadURL); HttpClient hc = new HttpClient(downloadURL);
hc.asGet(); hc.asGet();
InputStream in = hc.getResponseStream(); InputStream in = hc.getResponseStream();
@ -110,13 +110,14 @@ public class ErrorInfoUploader {
} }
private boolean needUpdate(File localCacheZip){ private boolean needUpdate(File localCacheZip) {
if (localCacheZip.exists()) { if (localCacheZip.exists()) {
// 判断本地文件大小. // 判断本地文件大小.
String checkURL = SiteCenter.getInstance().acquireUrlByKind("solution.check", "http://cloud.fanruan.com/api/checkUpdate"); String checkURL = SiteCenter.getInstance().acquireUrlByKind("solution.check", "http://cloud.fanruan.com/api/solution/cache/check");
checkURL = String.format("%s?token=%s", checkURL, SiteCenterToken.generateToken());
HttpClient client = new HttpClient(checkURL); HttpClient client = new HttpClient(checkURL);
client.asGet(); client.asGet();
if (client.isServerAlive()){ if (client.isServerAlive()) {
try { try {
JSONObject res = new JSONObject(client.getResponseText()); JSONObject res = new JSONObject(client.getResponseText());
// 简单粗暴, 直接判断文件大小. // 简单粗暴, 直接判断文件大小.
@ -129,7 +130,7 @@ public class ErrorInfoUploader {
return true; return true;
} }
public void sendErrorInfo(){ public void sendErrorInfo() {
// 判断更新解决方案缓存. // 判断更新解决方案缓存.
checkUpdateSolution(); checkUpdateSolution();
@ -171,8 +172,7 @@ public class ErrorInfoUploader {
private boolean sendErroInfo(String url, String content) { private boolean sendErroInfo(String url, String content) {
HashMap<String, String> para = new HashMap<>(); HashMap<String, String> para = new HashMap<>();
String date = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime()); para.put("token", SiteCenterToken.generateToken());
para.put("token", CodeUtils.md5Encode(date, "", "MD5"));
para.put("content", content); para.put("content", content);
HttpClient httpClient = new HttpClient(url, para, true); HttpClient httpClient = new HttpClient(url, para, true);
httpClient.asGet(); httpClient.asGet();
@ -181,7 +181,7 @@ public class ErrorInfoUploader {
return false; return false;
} }
String res = httpClient.getResponseText(); String res = httpClient.getResponseText();
boolean success; boolean success;
try { try {
success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success"); success = ComparatorUtils.equals(new JSONObject(res).get("status"), "success");

2
designer_base/src/com/fr/design/DesignModelAdapter.java

@ -26,7 +26,7 @@ public abstract class DesignModelAdapter<T extends IOFile, S extends JTemplatePr
public DesignModelAdapter(S jTemplate) { public DesignModelAdapter(S jTemplate) {
this.jTemplate = jTemplate; this.jTemplate = jTemplate;
setCurrentModelAdapter(this); setCurrentModelAdapter(this);
} }
public S getjTemplate() { public S getjTemplate() {

4
designer_base/src/com/fr/design/mainframe/DesignerFrameFileDealerPane.java

@ -60,8 +60,8 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
private OpenFolderAction openFolderAction = new OpenFolderAction(); private OpenFolderAction openFolderAction = new OpenFolderAction();
private RenameAction renameAction = new RenameAction(); private RenameAction renameAction = new RenameAction();
private DelFileAction delFileAction = new DelFileAction(); private DelFileAction delFileAction = new DelFileAction();
/** /**
* 刷新 * 刷新
*/ */

4
designer_base/src/com/fr/design/mainframe/templateinfo/TemplateInfoCollector.java

@ -6,6 +6,7 @@ import com.fr.base.io.IOFile;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.SiteCenterToken;
import com.fr.env.RemoteEnv; import com.fr.env.RemoteEnv;
import com.fr.general.*; import com.fr.general.*;
import com.fr.general.http.HttpClient; import com.fr.general.http.HttpClient;
@ -292,8 +293,7 @@ public class TemplateInfoCollector<T extends IOFile> implements Serializable, XM
private boolean sendSingleTemplateInfo(String url, String content) { private boolean sendSingleTemplateInfo(String url, String content) {
HashMap<String, String> para = new HashMap<>(); HashMap<String, String> para = new HashMap<>();
String date = new SimpleDateFormat("yyyy-MM-dd").format(Calendar.getInstance().getTime()); para.put("token", SiteCenterToken.generateToken());
para.put("token", CodeUtils.md5Encode(date, "", "MD5"));
para.put("content", content); para.put("content", content);
HttpClient httpClient = new HttpClient(url, para, true); HttpClient httpClient = new HttpClient(url, para, true);
httpClient.setTimeout(5000); httpClient.setTimeout(5000);

Loading…
Cancel
Save