|
|
|
@ -3,10 +3,13 @@ package com.fr.design.login.utils;
|
|
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
|
|
import com.fr.design.mainframe.toast.DesignerToastMsgUtil; |
|
|
|
|
import com.fr.general.CloudCenter; |
|
|
|
|
import com.fr.general.CloudCenterConfig; |
|
|
|
|
import com.fr.general.GeneralContext; |
|
|
|
|
import com.fr.general.http.HttpToolbox; |
|
|
|
|
import com.fr.general.log.MessageFormatter; |
|
|
|
|
import com.fr.json.JSONObject; |
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
import com.fr.third.org.bouncycastle.util.encoders.Hex; |
|
|
|
|
import java.awt.Window; |
|
|
|
|
import java.security.SecureRandom; |
|
|
|
@ -49,6 +52,9 @@ public class DesignerLoginUtils {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static String generateDesignerSSOUrl(String referrer) { |
|
|
|
|
if (!DesignerLoginUtils.isOnline()) { |
|
|
|
|
return referrer; |
|
|
|
|
} |
|
|
|
|
String ssoTemplate = CloudCenter.getInstance().acquireUrlByKind("designer.sso.api", "https://id.fanruan.com/api/app/?code={}&referrer={}"); |
|
|
|
|
try { |
|
|
|
|
String code = generateLoginCode(); |
|
|
|
@ -60,6 +66,19 @@ public class DesignerLoginUtils {
|
|
|
|
|
return referrer; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static boolean isOnline() { |
|
|
|
|
if (CloudCenterConfig.getInstance().isOnline()) { |
|
|
|
|
String ping = CloudCenter.getInstance().acquireConf("ping", StringUtils.EMPTY); |
|
|
|
|
if (StringUtils.isNotEmpty(ping)) { |
|
|
|
|
try { |
|
|
|
|
return StringUtils.isEmpty(HttpToolbox.get(ping)); |
|
|
|
|
} catch (Exception ignore) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static String generateLoginCode() throws Exception { |
|
|
|
|
DesignerEnvManager manager = DesignerEnvManager.getEnvManager(); |
|
|
|
|
JSONObject jo = JSONObject.create(); |
|
|
|
|