?? 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 + -