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

热点内容
有什么可以比飞翔解压的吗 浏览:845
黑暗之魂攻略pdf 浏览:904
世嘉20压缩比 浏览:148
瑞斯康达交换机命令 浏览:469
加密货币挤兑 浏览:575
scum服务器新手礼包都有什么 浏览:561
修改linux的编码格式 浏览:48
单片机232通信 浏览:223
则在该支座一侧箍筋加密 浏览:898
php缓存操作 浏览:658
程序员考公是什么意思 浏览:404
安卓手机怎么打开7z文件夹 浏览:818
领克app如何查看胎压 浏览:956
跳跳花app在哪里下载 浏览:673
内核编译论坛 浏览:874
pr预览渲染显示错误编译影片 浏览:723
php网站添加验证码 浏览:126
程序员有没有技师职称 浏览:274
一个程序员一年的感悟 浏览:80
单片机怎么安装 浏览:322