forked from fanruan/design
Browse Source
* commit '419b80d655c08ecfe42e2dff365bc4e8bb0fcb5d': REPORT-5143 设计器支持手机邮箱登录 1/3master
superman
7 years ago
12 changed files with 354 additions and 341 deletions
@ -0,0 +1,42 @@
|
||||
package com.fr.design.extra.exe; |
||||
|
||||
import com.fr.design.extra.LoginWebBridge; |
||||
import com.fr.design.extra.Process; |
||||
|
||||
/** |
||||
* @author vito |
||||
* @date 2017/10/31 |
||||
*/ |
||||
public class PluginLoginExecutor implements Executor { |
||||
private String result = "[]"; |
||||
|
||||
private String username; |
||||
private String password; |
||||
|
||||
public PluginLoginExecutor(String username, String password) { |
||||
this.username = username; |
||||
this.password = password; |
||||
} |
||||
|
||||
@Override |
||||
public String getTaskFinishMessage() { |
||||
return result; |
||||
} |
||||
|
||||
@Override |
||||
public Command[] getCommands() { |
||||
return new Command[]{ |
||||
new Command() { |
||||
@Override |
||||
public String getExecuteMessage() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void run(Process<String> process) { |
||||
result = LoginWebBridge.getHelper().login(username, password); |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
} |
@ -0,0 +1,120 @@
|
||||
package com.fr.design.extra.ucenter; |
||||
|
||||
import com.fr.base.Base64; |
||||
import com.fr.base.FRContext; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import java.io.UnsupportedEncodingException; |
||||
import java.net.URLEncoder; |
||||
import java.security.MessageDigest; |
||||
import java.security.NoSuchAlgorithmException; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @author lp |
||||
* @date 2016/9/9 |
||||
*/ |
||||
public abstract class AbstractClient { |
||||
|
||||
static final String UC_API_MYSQL = "ucApiMysql"; |
||||
static final String UC_API_POST = "ucApiPost"; |
||||
|
||||
protected String urlEncode(String value) { |
||||
return URLEncoder.encode(value); |
||||
} |
||||
|
||||
protected String md5(String input) { |
||||
MessageDigest md; |
||||
try { |
||||
md = MessageDigest.getInstance("MD5"); |
||||
} catch (NoSuchAlgorithmException e) { |
||||
FRContext.getLogger().info(e.getMessage()); |
||||
return ""; |
||||
} |
||||
return byte2hex(md.digest(input.getBytes())); |
||||
} |
||||
|
||||
protected String md5(long input) { |
||||
return md5(String.valueOf(input)); |
||||
} |
||||
|
||||
protected String base64Decode(String input) { |
||||
try { |
||||
return new String(Base64.decode(input)); |
||||
} catch (Exception e) { |
||||
FRContext.getLogger().info(e.getMessage()); |
||||
return ""; |
||||
} |
||||
} |
||||
|
||||
protected String base64Encode(String input) { |
||||
try { |
||||
return Base64.encode(input.getBytes("iso-8859-1")); |
||||
} catch (Exception e) { |
||||
FRContext.getLogger().info(e.getMessage()); |
||||
return ""; |
||||
} |
||||
} |
||||
|
||||
protected String byte2hex(byte[] b) { |
||||
StringBuilder hs = new StringBuilder(); |
||||
String stmp = ""; |
||||
for (byte aB : b) { |
||||
stmp = (Integer.toHexString(aB & 0XFF)); |
||||
if (stmp.length() == 1) { |
||||
hs.append("0").append(stmp); |
||||
} else { |
||||
hs.append(stmp); |
||||
} |
||||
} |
||||
return hs.toString(); |
||||
} |
||||
|
||||
protected String subStr(String input, int begin, int length) { |
||||
return input.substring(begin, begin + length); |
||||
} |
||||
|
||||
protected String subStr(String input, int begin) { |
||||
if (begin > 0) { |
||||
return input.substring(begin); |
||||
} else { |
||||
return input.substring(input.length() + begin); |
||||
} |
||||
} |
||||
|
||||
protected long microTime() { |
||||
return System.currentTimeMillis(); |
||||
} |
||||
|
||||
protected long time() { |
||||
return System.currentTimeMillis() / 1000; |
||||
} |
||||
|
||||
protected String sprintf(String format, long input) { |
||||
String temp = "0000000000" + input; |
||||
return temp.substring(temp.length() - 10); |
||||
} |
||||
|
||||
protected String callUserFunc(String function, String model, String action, Map<String, Object> args) { |
||||
if (UC_API_MYSQL.equals(function)) { |
||||
return this.ucApiMysql(model, action, args); |
||||
} |
||||
if (UC_API_POST.equals(function)) { |
||||
return this.ucApiPost(model, action, args); |
||||
} |
||||
return StringUtils.EMPTY; |
||||
} |
||||
|
||||
public abstract String ucApiPost(String module, String action, Map<String, Object> arg); |
||||
|
||||
public abstract String ucApiMysql(String model, String action, Map args); |
||||
|
||||
protected String urlEncode(String value, String code) { |
||||
try { |
||||
return URLEncoder.encode(value, code); |
||||
} catch (UnsupportedEncodingException e) { |
||||
FRContext.getLogger().info(e.getMessage()); |
||||
} |
||||
return ""; |
||||
} |
||||
} |
@ -1,113 +0,0 @@
|
||||
package com.fr.design.extra.ucenter; |
||||
|
||||
import java.io.UnsupportedEncodingException; |
||||
import java.net.URLEncoder; |
||||
import java.security.MessageDigest; |
||||
import java.security.NoSuchAlgorithmException; |
||||
import java.util.Map; |
||||
import com.fr.base.Base64; |
||||
import com.fr.base.FRContext; |
||||
|
||||
/** |
||||
* Created by lp on 2016/9/9. |
||||
*/ |
||||
public abstract class PHPFunctions { |
||||
|
||||
protected String urlencode(String value){ |
||||
return URLEncoder.encode(value); |
||||
} |
||||
|
||||
protected String md5(String input){ |
||||
MessageDigest md; |
||||
try { |
||||
md = MessageDigest.getInstance("MD5"); |
||||
} catch (NoSuchAlgorithmException e) { |
||||
FRContext.getLogger().info(e.getMessage()); |
||||
return ""; |
||||
} |
||||
return byte2hex(md.digest(input.getBytes())); |
||||
} |
||||
|
||||
protected String md5(long input){ |
||||
return md5(String.valueOf(input)); |
||||
} |
||||
|
||||
protected String base64_decode(String input){ |
||||
try { |
||||
return new String(Base64.decode(input)); |
||||
} catch (Exception e) { |
||||
FRContext.getLogger().info(e.getMessage()); |
||||
return ""; |
||||
} |
||||
} |
||||
|
||||
protected String base64_encode(String input){ |
||||
try { |
||||
return new String(Base64.encode(input.getBytes("iso-8859-1"))); |
||||
} catch (Exception e) { |
||||
FRContext.getLogger().info(e.getMessage()); |
||||
return ""; |
||||
} |
||||
} |
||||
|
||||
protected String byte2hex(byte[] b) { |
||||
StringBuffer hs = new StringBuffer(); |
||||
String stmp = ""; |
||||
for (int n = 0; n < b.length; n++) { |
||||
stmp = (java.lang.Integer.toHexString(b[n] & 0XFF)); |
||||
if (stmp.length() == 1) |
||||
hs.append("0").append(stmp); |
||||
else |
||||
hs.append(stmp); |
||||
} |
||||
return hs.toString(); |
||||
} |
||||
|
||||
protected String substr(String input,int begin, int length){ |
||||
return input.substring(begin, begin+length); |
||||
} |
||||
|
||||
protected String substr(String input,int begin){ |
||||
if(begin > 0){ |
||||
return input.substring(begin); |
||||
}else{ |
||||
return input.substring(input.length()+ begin); |
||||
} |
||||
} |
||||
|
||||
protected long microtime(){ |
||||
return System.currentTimeMillis(); |
||||
} |
||||
|
||||
protected long time(){ |
||||
return System.currentTimeMillis()/1000; |
||||
} |
||||
|
||||
protected String sprintf(String format, long input){ |
||||
String temp = "0000000000"+input; |
||||
return temp.substring(temp.length()-10); |
||||
} |
||||
|
||||
protected String call_user_func(String function, String model, String action, Map<String,Object> args){ |
||||
if("uc_api_mysql".equals(function)){ |
||||
return this.uc_api_mysql(model, action, args); |
||||
} |
||||
if("uc_api_post".equals(function)){ |
||||
return this.uc_api_post(model, action, args); |
||||
} |
||||
return ""; |
||||
} |
||||
|
||||
public abstract String uc_api_post(String $module, String $action, Map<String,Object> $arg ); |
||||
|
||||
public abstract String uc_api_mysql(String $model, String $action, Map $args); |
||||
|
||||
protected String urlencode(String value,String code){ |
||||
try { |
||||
return URLEncoder.encode(value,code); |
||||
} catch (UnsupportedEncodingException e) { |
||||
FRContext.getLogger().info(e.getMessage()); |
||||
} |
||||
return ""; |
||||
} |
||||
} |
Loading…
Reference in new issue