导航:首页 > 编程语言 > 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相关的资料

热点内容
表格加密设置打印区域 浏览:437
卡耐基pdf下载 浏览:922
现在最流行的单片机 浏览:88
机顶盒刷机源码 浏览:985
编码pdf下载 浏览:944
隔壁同学app怎么 浏览:299
c语言宏命令 浏览:542
php卡死源码 浏览:574
time库中的clock函数python 浏览:989
cad视觉移动命令怎么打开 浏览:821
安卓java调用python 浏览:395
java标准时间 浏览:137
华为服务器湖北渠道商云主机 浏览:30
韩式面部护理解压视频 浏览:301
pdf换成jpg图片 浏览:897
dh加密算法 浏览:107
安卓手机如何隐藏微信信息提示 浏览:632
nodejs解压缩 浏览:262
直流双转子压缩机 浏览:952
pythonxmlstring 浏览:822