📄 logonreceive.jsp
字号:
<%@page contentType="text/html; charset=GBK" %>
<%@page import="com.onewaveinc.portalman.webpro.*"%>
<%@page import="com.onewaveinc.portalman.webpro.entity.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*"%>
<%@ page import="java.security.*"%>
<%@ page import="java.net.URLEncoder"%>
<%!
public static String byte2HEX(byte b) {
return (""+"0123456789ABCDEF".charAt(0xf&b>>4)+"0123456789ABCDEF".charAt(b&0xF));
}
public static byte stringHEX2bytes(String str) {
return (byte) ("0123456789ABCDEF".indexOf(str.substring(0,1))*16 + "0123456789ABCDEF".indexOf(str.substring(1)));
}
public static String md5bytes2string(byte[] bytes){
String result = "";
for(int i=0; i<bytes.length; i++){
result += byte2HEX(bytes[i]);
}
return result;
}
public static byte[] md5string2bytes(String str){
byte[] b = new byte[str.length()/2];
for(int i=0; i<b.length; i++){
String s = str.substring(i*2,i*2+2);
b[i] = stringHEX2bytes(s);
}
return b;
}
public boolean checkValidate(String vnetloginname,String token,String verifycode){
try{
String seed = token + vnetloginname + "vnetvalidate";
MessageDigest md = MessageDigest.getInstance("MD5");
String mdresult = md5bytes2string(md.digest(seed.getBytes()));
return mdresult.equalsIgnoreCase(verifycode);
}catch(Exception e){
return false;
}
}
%>
<%
//取传回的参数
String token = request.getParameter("token");
String vnetloginname = request.getParameter("vnetloginname");
String verifycode = request.getParameter("verifycode");
if(vnetloginname == null || token ==null || verifycode==null){
out.println("非法请求,请退出重试!");
return;
}
//检查校验码是否正确,如果不正确,说明是用户修改了跳回时的参数值
if(!checkValidate(vnetloginname,token,verifycode)){
out.println("发现返回参数被修改,校验码不正确!");
return;
}
session.setAttribute("sessionVnetLoginName",vnetloginname);
//ICP在此根据Vnet用户名检查包月数据库,看用户是否在包月有效期内
//如果不在包月有效期内,下面代码为生成授权扣款请求
//ICP在Vnet上的服务代码
String serviceCode = "45454";
//ICP产品信息
String productInfo = "测试包月服务";
//ICP授权结果接受网页地址
String returnURL = "http://localhost:9000/demoicp/receive.jsp";
//ICP产品价格
int price = 1000;
String icpLoginName = "acnt1234";
OWAuthorizeRequest authRequest = new OWAuthorizeRequest();
//如果需要传入icp侧loginname,则为
OWAuthorizeRequest2 authRequest = new OWAuthorizeRequest2();
//0:由Vnet系统自动判断1:指明用在ADSL和163帐号中做检查2:指明用在现金帐号中做检查3:指定促消卡中扣款4:指定在业务卡中扣款
authRequest.setPayAccountCheckMode(0);
//ICP在Vnet上的服务代码
authRequest.setServiceCode(serviceCode);
//ICP需要强制跳回的URL
authRequest.setReturnURL(returnURL);
//如果是代收费模式,设置产品价格,单位为厘
authRequest.setExpenditure(price);
//设置产品信息
authRequest.setProductInfo(productInfo);
//设置Vnet用户名
authRequest.setVnetLoginName(vnetloginname);
//设置用户在icp一侧的帐号
authRequest.setIcpLoginName(icpLoginName);
//将OWAuthorizationRequest授权请求object变为请求String
String authString = WebProManager.getOWAuthentication().getOWAuthorizeRequestString(authRequest);
String jumpUrl = WebProManager.getAuthorizationJumpURL() + "?authorize_request=" + authString;
System.out.println(jumpUrl);
%>
<SCRIPT LANGUAGE="javascript">
window.location='<%=jumpUrl%>';
</SCRIPT>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -