招商银行 支付接口开发 部署时出错分析 java.lang.NoClassDefFoundError: cmb/netpayment/Security Sette
在给招商银行做接口的时候出现了一个很奇怪的现象,在console下测试代码正常,可是到tomcat中跑却报java.lang.NoClassDefFoundError: cmb/netpayment/Security找不到类,我在网上看到也有一样的问题,但是没有解答,试了很多方法都不行,最后我把招行的类都反编译了,解决问题。
我想是不是因为招行给的jar包版本和我的jdk版本不一致到账找不到类的呢。
其实招行接口用的核心类就两个,一个是cmb/netpayment/Security,安全验证,一个是cmb/netpayment/Settle订单管理。
以下是我反编译后的代码,经测试是可以用的。
需要的朋友可以直接拷贝走,但是招行的cmbJava.zip还是要放到工程里,因为会有相关引用。
// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.// Jad home page: http://www.geocities.com/kpdus/jad.html// Decompiler options: packimports(3) deadcode ansi package cmb.netpayment;import cmb.MerchantCode;import java.io.*;import java.net.*;import java.util.*;// Referenced classes of package cmb.netpayment:// mybufpublic class Settle{ public Settle() { m_bHttps = true; m_strRootServer = new String(); m_strHttpServer = new String(); m_strPath = "NetPayment/BaseHttp.dll?"; m_strProxyIP = new String(); m_bLogin = false; m_strClientNo = new String(); m_strSerialNo = new String(); m_strCoNo = new String(); m_strPwd = new String(); szStatusInfo = new Vector(); szStatusInfo.addElement("Success"); szStatusInfo.addElement("Communication failed"); szStatusInfo.addElement("You have already loged in"); szStatusInfo.addElement("You have not loged in"); szStatusInfo.addElement("Login failed"); szStatusInfo.addElement("Logout failed"); szStatusInfo.addElement("Inputed parameters are not correct"); szStatusInfo.addElement("Can't query this order bill"); szStatusInfo.addElement("Can't get settled orders"); szStatusInfo.addElement("Can't get the count of unsettled order"); szStatusInfo.addElement("Can't get unsettled orders"); szStatusInfo.addElement("Can't settle or cancel this order bill"); szStatusInfo.addElement("Can't get single order"); szStatusInfo.addElement("Can't do refund for this order"); szStatusInfo.addElement("Can't find public key file"); szStatusInfo.addElement("This message can NOT be trusted"); szStatusInfo.addElement("Can't get refund data"); szStatusInfo.addElement("Some unknown error"); } public int CancelOrder(String s, String s1) { return ProcOrder(s, s1, "", "N"); } private String ContactServer(String s, String s1) { try { if(s1.length() == 0) s1 = "GET"; URL url = new URL(s); HttpURLConnection httpurlconnection = (HttpURLConnection)url.openConnection(); httpurlconnection.setRequestMethod(s1); BufferedInputStream bufferedinputstream = new BufferedInputStream(httpurlconnection.getInputStream()); byte abyte0[] = new byte[4096]; StringBuffer stringbuffer = new StringBuffer(); for(int i = 0; i != -1;) { i = bufferedinputstream.read(abyte0, 0, 4096); if(i != -1) { String s2 = new String(abyte0, 0, i, "GB2312"); stringbuffer.append(s2); } } bufferedinputstream.close(); httpurlconnection.disconnect(); String s3 = stringbuffer.toString(); return s3; } catch(Exception exception) { exception.printStackTrace(); } return ""; } private boolean DirectLoginC(String s, String s1, String s2, String s3, String s4) { boolean flag = true; String s6 = ""; String s7; if(m_bHttps) s7 = "https://"; else s7 = "http://"; s6 = s6 + "BranchID=" + s + "&CoNo=" + s1 + "&Pwd=" + s2 + "&ClientNo=" + s3 + "&SerialNo=" + s4; String s5 = DoPostCmd(s7 + m_strHttpServer + "/" + m_strPath + "DirectLogonC", s6); if(s5.length() != 0) { char c = s5.charAt(0); switch(c) { case 78: // 'N' m_strErrMsg = s5.substring(1, s5.length() - 1); flag = false; break; default: m_strErrMsg = "Can't recognize the returned flag"; flag = false; break; case 89: // 'Y' break; } return flag; } else { m_strErrMsg = s5; return false; } } private String DoPostCmd(String s, String s1) { String s2 = null; try { URL url = new URL(s); URLConnection urlconnection = url.openConnection(); urlconnection.setUseCaches(false); urlconnection.setDoInput(true); urlconnection.setDoOutput(true); BufferedOutputStream bufferedoutputstream = new BufferedOutputStream(urlconnection.getOutputStream()); byte abyte0[] = s1.getBytes("GB2312"); bufferedoutputstream.write(abyte0); bufferedoutputstream.close(); BufferedInputStream bufferedinputstream = new BufferedInputStream(urlconnection.getInputStream()); s2 = ReadByteStream(bufferedinputstream); bufferedinputstream.close(); } catch(IOException _ex) { return ""; } catch(Exception _ex) { return ""; } if(s2 == null) return ""; else return s2; } private boolean GetCookieInfo(Vector vector) { String s = new String(); String s1 = new String(); String s2 = new String(); String s4 = new String(); String s5; if(m_bHttps) s5 = "https://"; else s5 = "http://"; boolean flag = true; s4 = ContactServer(s5 + m_strHttpServer + "/" + m_strPath + "DirectEnter", ""); if(s4.length() != 0) { char c = s4.charAt(0); switch(c) { case 89: // 'Y' String s6 = s4.substring(2); s = GetText(s6, '\n'); s6 = s6.substring(s6.indexOf("\n") + 1); s1 = GetText(s6, '\n'); break; case 78: // 'N' s2 = s4.substring(1, s4.length() - 1); flag = false; break; default: s2 = "Can't recognize the returned flag"; flag = false; break; } vector.addElement(s); vector.addElement(s1); vector.addElement(s2); return flag; } else { String s3 = "return null"; vector.addElement(s); vector.addElement(s1); vector.addElement(s3); return false; } } public String GetLastErr(int i) { if(i > 17 || i < 0) return GetLastErr(17); String s = (String)szStatusInfo.elementAt(i); if(m_strErrMsg.length() != 0) s = s + ": " + m_strErrMsg; return s; } private String GetServerName(String s) { String s1 = "WWW.CMBCHINA.COM"; String s2; if(m_bHttps) s2 = "https://"; else s2 = "http://"; s = s.toUpperCase(); if(!s.equals(s1)) { String s3 = s; return s3; } else { String s4 = ContactServer(s2 + s1 + "/NetPayment/ServerName.txt", "GET"); return s4; } } private String GetText(String s, char c) { int i = s.length(); String s1 = new String(); int j = i - 1; for(int l = 0; l < i; l++) { char c1 = s.charAt(l); if(c1 == c) { int k = l; break; } s1 = s1 + c1; } return s1; } public int LoginC(String s, String s1, String s2) { m_strErrMsg = ""; if(m_bLogin) return 2; boolean flag = true; if(s.length() == 0 || s1.length() == 0 || s2.length() == 0) flag = false; if(!flag) return 6; String s3 = GetServerName(m_strRootServer); if(s3.length() != 0) m_strHttpServer = s3; else return 1; Vector vector = new Vector(); String s4; String s5; if(GetCookieInfo(vector)) { s4 = (String)vector.elementAt(0); s5 = (String)vector.elementAt(1); String s6 = (String)vector.elementAt(2); m_strClientNo = (String)vector.elementAt(0); m_strSerialNo = (String)vector.elementAt(1); } else { m_strErrMsg = (String)vector.elementAt(2); return 1; } if(!DirectLoginC(s, s1, s2, s4, s5)) { return 4; } else { m_strBranchID = s; m_strCoNo = s1; m_strPwd = s2; m_bLogin = true; return 0; } } public int Logout() { m_strErrMsg = ""; if(!m_bLogin) return 3; boolean flag = true; byte byte0 = 0; String s1 = ""; String s2; if(m_bHttps) s2 = "https://"; else s2 = "http://"; s1 = s1 + "ClientNo=" + m_strClientNo + "&SerialNo=" + m_strSerialNo; String s = DoPostCmd(s2 + m_strHttpServer + "/" + m_strPath + "DirectExit", s1); if(s.length() != 0) { char c = s.charAt(0); switch(c) { case 89: // 'Y' m_strCoNo = ""; m_strPwd = ""; m_strClientNo = ""; m_strSerialNo = ""; m_bLogin = false; break; default: m_strErrMsg = "Can't recognize the returned flag"; byte0 = 5; break; } } else { m_strErrMsg = s; byte0 = 5; } return byte0; } private int PageQuery(String s, String s1, int i, int j, String s2, StringBuffer stringbuffer) { if(!m_bLogin) return 3; boolean flag = true; int k = 0; String s4 = ""; String s5; if(m_bHttps) s5 = "https://"; else s5 = "http://"; s4 = "ClientNo=" + m_strClientNo + "&SerialNo=" + m_strSerialNo + "&pos=" + m_strLastPos + "&count=" + i; String s3 = DoPostCmd(s5 + m_strHttpServer + "/" + m_strPath + s, s4 + s1); if(s3.length() != 0) { char c = s3.charAt(0); switch(c) { case 89: // 'Y' int l = s3.indexOf('\n', 2); m_strLastPos = s3.substring(2, l); int i1 = s3.indexOf('\n', l + 1); m_bIsLastPage = s3.charAt(i1 - 1) != 'Y'; stringbuffer.append(s3.substring(i1 + 1)); break; case 78: // 'N' m_strErrMsg = s3.substring(1, s3.length() - 1); k = j; break; case 82: // 'R' m_bLogin = false; if(LoginC(m_strBranchID, m_strCoNo, m_strPwd) != 0) { m_strErrMsg = s2; k = 4; } else { k = PageQuery(s, s1, i, j, s2, stringbuffer); } break; default: m_strErrMsg = "Can't recognize the returned flag"; k = j; break; } } else { m_strErrMsg = "Server returns nothing"; k = j; } return k; } public void PageReset() { m_bIsLastPage = false; m_strLastPos = ""; } private int ProcOrder(String s, String s1, String s2, String s3) { m_strErrMsg = ""; if(!m_bLogin) return 3; String s4 = m_strCoNo; boolean flag = true; if(s4 == "" || s == "" || s == "") flag = false; if(!flag) return 6; String s5 = ""; String s6; if(m_bHttps) s6 = "https://"; else s6 = "http://"; boolean flag1 = true; int i = 0; String s7 = ""; if(s3 == "Y" || s3 == "N") { s7 = s7 + "CoNo=" + s4 + "&BillNo=" + s + "&RefNo=" + s1 + "&Validate=" + s3 + "&ClientNo=" + m_strClientNo + "&SerialNo=" + m_strSerialNo; s5 = DoPostCmd(s6 + m_strHttpServer + "/" + m_strPath + "DirectSettleOrder", s7); } if(s3 == "P") { if(s2 == "") return 6; if((double)Float.valueOf(s2).floatValue() == 0.0D) return 6; s7 = s7 + "CoNo=" + s4 + "&BillNo=" + s + "&RefNo=" + s1 + "&PartAmount=" + s2 + "&ClientNo=" + m_strClientNo + "&SerialNo=" + m_strSerialNo; s5 = DoPostCmd(s6 + m_strHttpServer + "/" + m_strPath + "DirectSettlePartOrder", s7); } if(s5.length() != 0) { char c = s5.charAt(0); switch(c) { case 78: // 'N' m_strErrMsg = s5.substring(1, s5.length() - 1); i = 11; break; case 82: // 'R' m_bLogin = false; if(LoginC(m_strBranchID, m_strCoNo, m_strPwd) != 0) { m_strErrMsg = "While Settle or cancel Order"; i = 4; } else { i = ProcOrder(s, s1, s2, s3); } break; default: m_strErrMsg = "Can't recognize the returned flag"; i = 11; break; case 89: // 'Y' break; } } else { m_strErrMsg = s5; i = 11; } return i; } public int QueryRefundByDate(String s, String s1, StringBuffer stringbuffer) { return concatPages("DirectQueryRefundByDate", "&BeginDate=" + s + "&EndDate=" + s1, 16, "While Query Refund", stringbuffer); } public int QueryRefundByDatePage(String s, String s1, int i, StringBuffer stringbuffer) { if(s.length() != 8 || s1.length() != 8) { m_strErrMsg = "Invalid Date format"; return 16; } else { return PageQuery("DirectQueryRefundByDate", "&BeginDate=" + s + "&EndDate=" + s1, i, 16, "While QueryRefundByDate", stringbuffer); } } public int QuerySettledOrder(String s, String s1, StringBuffer stringbuffer) { return QuerySettledOrder0(s, s1, 0, stringbuffer); } private int QuerySettledOrder0(String s, String s1, int i, StringBuffer stringbuffer) { return concatPages("DirectQuerySettledOrderByPage", "&BeginDate=" + s + "&EndDate=" + s1 + "&Type=" + i, 8, "While QuerySettledOrder", stringbuffer); } public int QuerySettledOrder0(String s, String s1, StringBuffer stringbuffer) { if(!m_bLogin) return 3; boolean flag = true; int i = 0; String s3 = ""; String s4; if(m_bHttps) s4 = "https://"; else s4 = "http://"; s3 = s3 + "CoNo=" + m_strCoNo + "&BeginData=" + s + "&EndDate=" + s1 + "&ClientNo=" + m_strClientNo + "&SerialNo=" + m_strSerialNo; String s2 = DoPostCmd(s4 + m_strHttpServer + "/" + m_strPath + "DirectQuerySettledOrder", s3); if(s2.length() != 0) { char c = s2.charAt(0); switch(c) { case 89: // 'Y' String s5 = s2.substring(2); String s6 = GetText(s5, '\n'); s5 = s5.substring(s5.indexOf("\n") + 1); s6 = GetText(s5, '\0'); int j = s6.length(); stringbuffer.append(s6); break; case 78: // 'N' m_strErrMsg = s2.substring(1, s2.length() - 1); i = 8; break; case 82: // 'R' m_bLogin = false; if(LoginC(m_strBranchID, m_strCoNo, m_strPwd) != 0) { m_strErrMsg = "While QuerySettledOrder"; i = 4; } else { i = QuerySettledOrder(s, s1, stringbuffer); } break; default: m_strErrMsg = "Can't recognize the returned flag"; i = 8; break; } } else { m_strErrMsg = s2; i = 8; } return i; } public int QuerySettledOrderByPage(String s, String s1, int i, StringBuffer stringbuffer) { return QuerySettledOrderByPage0(s, s1, i, 0, stringbuffer); } private int QuerySettledOrderByPage0(String s, String s1, int i, int j, StringBuffer stringbuffer) { return PageQuery("DirectQuerySettledOrderByPage", "&BeginDate=" + s + "&EndDate=" + s1 + "&Type=" + j, i, 8, "While QuerySettledOrder", stringbuffer); } public int QuerySettledOrderBySettleDate(String s, String s1, StringBuffer stringbuffer) { return QuerySettledOrder0(s, s1, 1, stringbuffer); } public int QuerySettledOrderBySettleDateByPage(String s, String s1, int i, StringBuffer stringbuffer) { return QuerySettledOrderByPage0(s, s1, i, 1, stringbuffer); } public int QuerySingleOrder(String s, String s1, StringBuffer stringbuffer) { return QuerySingleOrder0(m_strCoNo, s, s1, stringbuffer); } private int QuerySingleOrder0(String s, String s1, String s2, StringBuffer stringbuffer) { if(!m_bLogin) return 3; boolean flag = true; int i = 0; String s4 = ""; String s5; if(m_bHttps) s5 = "https://"; else s5 = "http://"; s4 = s4 + "CoNo=" + s + "&Date=" + s1 + "&BillNo=" + s2 + "&ClientNo=" + m_strClientNo + "&SerialNo=" + m_strSerialNo; String s3 = DoPostCmd(s5 + m_strHttpServer + "/" + m_strPath + "DirectQuerySingleOrder", s4); if(s3.length() != 0) { char c = s3.charAt(0); switch(c) { case 89: // 'Y' String s6 = s3.substring(2); String s7 = GetText(s6, '\0'); int j = s7.length(); stringbuffer.append(s7); break; case 82: // 'R' m_bLogin = false; if(LoginC(m_strBranchID, m_strCoNo, m_strPwd) != 0) { m_strErrMsg = "While Do Order Refund "; i = 4; } else { i = QuerySingleOrder(s1, s2, stringbuffer); } break; case 78: // 'N' m_strErrMsg = s3.substring(1, s3.length() - 1); i = 12; break; default: m_strErrMsg = "Can't recognize the returned flag"; i = 12; break; } } else { m_strErrMsg = s3; i = 12; } return i; } public int QuerySingleOrderSpecial(String s, String s1, StringBuffer stringbuffer) { return QuerySingleOrder0("Full", s, s1, stringbuffer); } public int QueryTransact(String s, StringBuffer stringbuffer) { return QuerySettledOrder0(s, s, 1, stringbuffer); } public int QueryTransactByPage(String s, int i, StringBuffer stringbuffer) { return QuerySettledOrderByPage0(s, s, i, 1, stringbuffer); } public int QueryUnsettledOrder(StringBuffer stringbuffer) { return concatPages("DirectQueryUnsettledOrderByPage", "", 10, "While Query Unsettled Order", stringbuffer); } public int QueryUnsettledOrder0(StringBuffer stringbuffer) { m_strErrMsg = ""; if(!m_bLogin) return 3; boolean flag = true; int i = 0; String s1 = ""; String s2; if(m_bHttps) s2 = "https://"; else s2 = "http://"; s1 = s1 + "CoNo=" + m_strCoNo + "&ClientNo=" + m_strClientNo + "&SerialNo=" + m_strSerialNo; String s = DoPostCmd(s2 + m_strHttpServer + "/" + m_strPath + "DirectQueryUnsettledOrder", s1); if(s.length() != 0) { char c = s.charAt(0); switch(c) { case 89: // 'Y' String s3 = s.substring(2); s3 = s3.substring(s3.indexOf("\n") + 1); String s4 = GetText(s3, '\0'); int j = s4.length(); stringbuffer.append(s4); break; case 78: // 'N' m_strErrMsg = s.substring(1, s.length() - 1); i = 10; break; case 82: // 'R' m_bLogin = false; if(LoginC(m_strBranchID, m_strCoNo, m_strPwd) != 0) { m_strErrMsg = "While QueryUnsettledOrder"; i = 4; } else { i = QueryUnsettledOrder(stringbuffer); } break; default: m_strErrMsg = "Can't recognize the returned flag"; i = 10; break; } } else { m_strErrMsg = s; i = 10; } return i; } public int QueryUnsettledOrderByPage(int i, StringBuffer stringbuffer) { return PageQuery("DirectQueryUnsettledOrderByPage", "", i, 10, "While QueryUnsettledOrder", stringbuffer); } private static String ReadByteStream(BufferedInputStream bufferedinputstream) throws IOException { LinkedList linkedlist = new LinkedList(); int i = 0; do { byte abyte0[] = new byte[128]; int j = bufferedinputstream.read(abyte0); if(j == -1) break; i += j; linkedlist.add(new mybuf(abyte0, j)); } while(true); byte abyte1[] = new byte[i]; int l = 0; for(ListIterator listiterator = linkedlist.listIterator(); listiterator.hasNext();) { mybuf mybuf1 = (mybuf)listiterator.next(); for(int k = 0; k < mybuf1.size;) { abyte1[l] = mybuf1.buf[k]; k++; l++; } } return new String(abyte1, "GB2312"); } public int RefundOrder(String s, String s1, String s2, String s3, String s4) { if(!m_bLogin) return 3; boolean flag = true; int i = 0; String s6; if(m_bHttps) s6 = "https://"; else s6 = "http://"; String s7 = ""; try { StringBuffer stringbuffer = new StringBuffer(); stringbuffer.append(m_strSerialNo); stringbuffer.append(s4); stringbuffer.append(m_strClientNo); stringbuffer.append(m_strBranchID); stringbuffer.append(m_strCoNo); stringbuffer.append(s); stringbuffer.append(s1); stringbuffer.append(s2); stringbuffer.append(s3); s7 = MerchantCode.hashString(stringbuffer.toString(), "SHA1"); } catch(Exception exception) { m_strErrMsg = "Do Digest error:" + exception.getMessage(); i = 13; return i; } StringBuffer stringbuffer1 = new StringBuffer(); stringbuffer1.append("Date="); stringbuffer1.append(s); stringbuffer1.append("&BillNo="); stringbuffer1.append(s1); stringbuffer1.append("&Amount="); stringbuffer1.append(s2); stringbuffer1.append("&Desc="); stringbuffer1.append(s3); stringbuffer1.append("&Vcode="); stringbuffer1.append(s7); stringbuffer1.append("&ClientNo="); stringbuffer1.append(m_strClientNo); stringbuffer1.append("&SerialNo="); stringbuffer1.append(m_strSerialNo); String s5 = DoPostCmd(s6 + m_strHttpServer + "/" + m_strPath + "DirectRefund", stringbuffer1.toString()); if(s5.length() != 0) { char c = s5.charAt(0); switch(c) { case 82: // 'R' m_bLogin = false; if(LoginC(m_strBranchID, m_strCoNo, m_strPwd) != 0) { m_strErrMsg = "While Do Order Refund "; i = 4; } else { i = RefundOrder(s, s1, s2, s3, s4); } break; case 78: // 'N' m_strErrMsg = s5.substring(1, s5.length() - 1); i = 13; break; default: m_strErrMsg = "Can't recognize the returned flag"; i = 13; break; case 89: // 'Y' break; } } else { m_strErrMsg = s5; i = 13; } return i; } public int SetOptions(String s) { String s1 = ""; String s2 = ""; m_strErrMsg = ""; boolean flag = true; if(s.length() == 0) flag = false; if(!flag) return 6; m_strRootServer = s; if(s1.length() != 0) m_strPort = s1; else if(m_bHttps) m_strPort = "443"; else m_strPort = "80"; if(s2.length() != 0) m_strProxyIP = s2; return 0; } public void SetProxy(String s, String s1) { java.util.Properties properties = System.getProperties(); properties.put("https.proxyHost", s); properties.put("https.proxyPort", s1); } public int SettleOrder(String s, String s1) { return ProcOrder(s, s1, "", "Y"); } public int SettlePartOrder(String s, String s1, String s2) { return ProcOrder(s, s1, s2, "P"); } private static String URLConnect(String s) throws Exception { URL url = new URL(s); URLConnection urlconnection = url.openConnection(); urlconnection.setUseCaches(false); urlconnection.setDoInput(true); BufferedInputStream bufferedinputstream = new BufferedInputStream(urlconnection.getInputStream()); String s1 = ReadByteStream(bufferedinputstream); bufferedinputstream.close(); return s1; } private int concatPages(String s, String s1, int i, String s2, StringBuffer stringbuffer) { PageReset(); int j; do j = PageQuery(s, s1, 100, i, s2, stringbuffer); while(j == 0 && !m_bIsLastPage); return j; } public void testit() { m_bHttps = false; } private static final int INET_SUCCESS = 0; private static final int INET_COMMUNICATION_FAILURE = 1; private static final int INET_ALREADY_LOGIN = 2; private static final int INET_NOT_LOGIN = 3; private static final int INET_LOGIN_FAILURE = 4; private static final int INET_LOGOUT_FAILURE = 5; private static final int INET_INPUTPARA_ERROR = 6; private static final int INET_CANNOT_QUERYONEORDER = 7; private static final int INET_CANNOT_QUERYSETTLEDORDER = 8; private static final int INET_CANNOT_QUERYCOUNT = 9; private static final int INET_CANNOT_QUERYUNSETTLEDORDER = 10; private static final int INET_CANNOT_SETTLEORDER = 11; private static final int INET_CANNOT_QUERYSINGLEORDER = 12; private static final int INET_CANNOT_REFUNDORDER = 13; private static final int INET_CANNOT_FIND_PUBLICKEYFILE = 14; private static final int INET_MESSAGE_UNTRUTHFUL = 15; private static final int INET_CANNOT_QUERYREFUND = 16; private static final int INET_UNKOWN_FAILURE = 17; private Vector szStatusInfo; private boolean m_bHttps; private String m_strRootServer; private String m_strHttpServer; private String m_strPort; private String m_strPath; private boolean m_bLogin; private String m_strClientNo; private String m_strSerialNo; private String m_strBranchID; private String m_strCoNo; private String m_strPwd; private String m_strProxyIP; private char m_szStatusBuf[]; private String m_strErrMsg; public boolean m_bIsLastPage; private String m_strLastPos;}
// Decompiled by DJ v2.9.9.61 Copyright 2000 Atanas Neshkov Date: 2012/11/22 1:08:45// Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for new version!// Decompiler options: packimports(3) deadcode ansi package cmb.netpayment;;import java.io.*;import java.security.*;// Referenced classes of package cmb.netpayment:// RSAPubKeypublic class Security{ public Security(String s) throws Exception { try { File file = new File(s); byte abyte0[] = new byte[(int)file.length()]; FileInputStream fileinputstream = new FileInputStream(s); fileinputstream.read(abyte0); fileinputstream.close(); SetPublicKey(abyte0); } catch(Throwable throwable) { throw new Exception("Load publickey files failed because: " + throwable.getMessage()); } } public Security(byte abyte0[]) throws Exception { try { SetPublicKey(abyte0); } catch(Throwable throwable) { throw new Exception("Load publickey files failed because: " + throwable.getMessage()); } } public boolean CheckSign(byte abyte0[], byte abyte1[]) { boolean flag = false; try { Signature signature = Signature.getInstance("SHA1withRSA"); signature.initVerify(m_RSAPubKey); signature.update(abyte0); flag = signature.verify(abyte1); } catch(NoSuchAlgorithmException nosuchalgorithmexception) { System.out.println("CheckSign: invalid Algorithm." + nosuchalgorithmexception.toString()); } catch(InvalidKeyException invalidkeyexception) { System.out.println("CheckSign: invalid public key." + invalidkeyexception.toString()); } catch(SignatureException signatureexception) { System.out.println("CheckSign: invalid sinature." + signatureexception.toString()); } catch(Exception exception) { System.out.println("CheckSign: " + exception.toString()); } return flag; } private void SetPublicKey(byte abyte0[]) throws Exception { m_RSAPubKey = new RSAPubKey(abyte0, "NETPAYMENT"); } public boolean checkInfoFromBank(String s) { byte abyte0[] = null; try { abyte0 = s.getBytes("GB2312"); } catch(Exception _ex) { return false; } return checkInfoFromBank(abyte0); } public boolean checkInfoFromBank(byte abyte0[]) { byte byte0 = 38; byte abyte1[] = null; byte abyte2[] = null; int i = abyte0.length; int l = -1; for(int j = i - 1; j >= 0; j--) { byte byte1 = abyte0[j]; if(byte1 != byte0) continue; l = j; break; } if(l == -1) return false; String s = "&signature="; int i1 = s.length(); abyte1 = new byte[l]; abyte2 = new byte[i - l - i1]; System.arraycopy(abyte0, 0, abyte1, 0, l); System.arraycopy(abyte0, l + i1, abyte2, 0, i - l - i1); int j1 = abyte2.length; byte0 = 124; l = 0; byte abyte3[] = new byte[1024]; String s1 = ""; for(int k = 0; k < j1; k++) { byte byte2 = abyte2[k]; if(byte2 == byte0) { int k1 = Integer.parseInt(s1); abyte3[l] = (byte)k1; l++; s1 = ""; } else { char c = (char)byte2; s1 = s1 + c; } } byte abyte4[] = new byte[l]; System.arraycopy(abyte3, 0, abyte4, 0, l); return CheckSign(abyte1, abyte4); } private RSAPubKey m_RSAPubKey;}