/**
* Alipay.com Inc.
* Copyright (c) 2005-2008 All Rights Reserved.
*/
package com.alipay.client.base;
import java.io.InputStream;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
/**
*
*
* @author feng.chenf
* @version $Id: ClientConfig.java, v 0.1 2008-12-24 ????09:31:39 feng.chenf Exp $
*/
public class ClientConfig {
/**
* ????????????????????? ????????https://wappaygw.alipay.com
*/
private String serverUrl = "http://115.124.16.16";
/**
* ????????????????????? ???????????????? ?????443???
*/
private String serverPort = "80";
/**
* ?????partnerId
*/
private String partnerId = "";
/**
* ??????????ú?
*/
private String secId = "";
/**
* ???????
*/
private String prikey = "";
/**
* ???????
*/
private String pubkey = "";
/**
* ????????????????????
*/
private String alipayVeriPubKey = "";
/**
* ?????????????????????????
*/
private String alipayEncPubKey = "";
/**
* ?????? ?????????????RSA
*/
private String signAlgo = "RSA";
/**
* ??????? ?????????????RSA
*/
private String encryptAlgo = "RSA";
public ClientConfig() {
try {
InputStream iss = this.getClass().getClassLoader().getResourceAsStream(
"com/alipay/client/config/config.xml");
DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();
DocumentBuilder dombuilder = domfac.newDocumentBuilder();
Document doc = dombuilder.parse(iss);
Element rootElement = doc.getDocumentElement();
NodeList paramNode = doc.getElementsByTagName("partnerId");
partnerId = paramNode.item(0).getFirstChild().getNodeValue().trim();
NodeList secNode = doc.getElementsByTagName("secId");
secId = secNode.item(0).getFirstChild().getNodeValue().trim();
NodeList signAlgoNode = doc.getElementsByTagName("signAlgo");
this.signAlgo = signAlgoNode.item(0).getFirstChild().getNodeValue().trim();
NodeList prikeyNode = doc.getElementsByTagName("prikey");
this.prikey = prikeyNode.item(0).getFirstChild().getNodeValue().trim();
NodeList pubkeyNode = doc.getElementsByTagName("pubkey");
this.pubkey = pubkeyNode.item(0).getFirstChild().getNodeValue().trim();
NodeList alipayVeriPubKeyNode = doc.getElementsByTagName("alipayVeriPubKey");
this.alipayVeriPubKey = alipayVeriPubKeyNode.item(0).getFirstChild().getNodeValue().trim();
NodeList alipayEncPubKeyNode = doc.getElementsByTagName("alipayEncPubKey");
this.alipayEncPubKey = alipayEncPubKeyNode.item(0).getFirstChild().getNodeValue().trim();
} catch (Exception e) {
//??????
//??????????? ????????????
e.printStackTrace();
}