导航:首页 > 编程语言 > sae部署java

sae部署java

发布时间:2024-11-23 00:52:54

A. 在SAE上部署的java微信应用,如何和微信接口

代码如下:

importjava.io.IOException;
importjava.io.PrintWriter;
importjava.math.BigInteger;
importjava.security.MessageDigest;
importjava.security.NoSuchAlgorithmException;
importjava.util.Arrays;
importjavax.servlet.ServletException;
importjavax.servlet.http.HttpServlet;
importjavax.servlet.http.HttpServletRequest;
importjavax.servlet.http.HttpServletResponse;

{
=1L;

privatestaticfinalStringTOKEN="sinavoice";
/**
*@seeHttpServlet#doGet(HttpServletRequestrequest,HttpServletResponseresponse)
*/
protectedvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{
PrintWriterout=response.getWriter();
Stringtimestamp=request.getParameter("timestamp");
Stringnonce=request.getParameter("nonce");
Stringsignature=request.getParameter("signature");
if(this.validataSignature(signature,timestamp,nonce)){
out.println(request.getParameter("echostr"));
}
else{
response.setStatus(HttpServletResponse.SC_HTTP_VERSION_NOT_SUPPORTED);
}
out.flush();
out.close();
}
/**
*@seeHttpServlet#doPost(HttpServletRequestrequest,HttpServletResponseresponse)
*/
protectedvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)throwsServletException,IOException{

PrintWriterout=response.getWriter();
//StringBufferpostText=StreamOfFileUtils.StreamForString(request.getInputStream());
//log.debug(postText.toString());
out.flush();
out.close();
}
/**
*@param_signature
*@param_timestamp
*@param_nonce
*@return
*/
(String_signature,String_timestamp,String_nonce){
String[]ttn=newString[3];
ttn[0]=TOKEN;
ttn[1]=_timestamp;
ttn[2]=_nonce;
Arrays.sort(ttn);
StringpwdSignature=String.format("%s%s%s",ttn[0],ttn[1],ttn[2]);
StringsrcSignature=_signature;
try{
MessageDigestmd=MessageDigest.getInstance("SHA1");
md.update(pwdSignature.getBytes());
pwdSignature=newBigInteger(1,md.digest()).toString(16);
}catch(NoSuchAlgorithmExceptione){
}
returnsrcSignature==null?false:srcSignature.equals(pwdSignature);
}
}

阅读全文

与sae部署java相关的资料

热点内容
php表单防注入 浏览:91
什么叫e筋加密锁 浏览:712
世界无敌简单的折纸解压球 浏览:943
安卓开服光遇什么季节 浏览:565
破解的系统怎么用银行app 浏览:265
java三层架构mvc 浏览:880
徐州编程教育加盟 浏览:899
苹果手机脸书app如何设置中文 浏览:538
pdf文件在线修改 浏览:399
服务器上如何搭建自己的网站 浏览:467
云南省青少年学习编程 浏览:480
c工程的编译时间 浏览:587
java判断字符串包含某个字符串中 浏览:977
3匹单相谷轮压缩机用多大的电容 浏览:784
比心app怎么样用 浏览:741
和平精英怎么改国际服的服务器 浏览:946
手机存储卡128是哪个文件夹 浏览:180
安北解压包密码 浏览:651
阿里巴巴app静态编译 浏览:725
命令世界怎么获得迷你币 浏览:651