本文整理汇总了Java中sun.misc.BASE64Encoder.encodeBuffer方法的典型用法代码示例。如果您正苦于以下问题:Java BASE64Encoder.encodeBuffer方法的具体用法?Java BASE64Encoder.encodeBuffer怎么用?Java BASE64Encoder.encodeBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.misc.BASE64Encoder
的用法示例。
在下文中一共展示了BASE64Encoder.encodeBuffer方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: dumpCert
import sun.misc.BASE64Encoder; //导入方法依赖的package包/类
/**
* Dump the certificate base64 encoded.
*
* @param sb write certificate here
* @param certificate the certificate
* @return StringBuilder
*/
public StringBuilder dumpCert(StringBuilder sb, Certificate certificate ) throws CertificateException {
final BASE64Encoder base64encoder = new BASE64Encoder();
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final PrintStream ps = new PrintStream(baos);
try {
ps.println();
base64encoder.encodeBuffer(certificate.getEncoded(), ps);
// ps.flush();
// baos.flush();
} catch (IOException ioex) {
throw new CertificateException( "Cannot dump certificate", ioex );
} finally {
try {
baos.close();
} catch (IOException ex) {
// ignore it
}
}
sb.append( NbBundle.getMessage( KeyStoreFormatter.class, "dumpCert", baos.toString() ) );
return sb;
}
示例2: encryptBASE64
import sun.misc.BASE64Encoder; //导入方法依赖的package包/类
/**
* BASE64加密
*
* @param key
* @return
* @throws Exception
*/
public static String encryptBASE64(byte[] key) {
BASE64Encoder b64 = new BASE64Encoder();
String rs = b64.encodeBuffer(key);
rs = rs.replaceAll("\r\n", "");
return rs;
// return Base64.encode(key);
}
示例3: InputStreamtoB64OutputStream
import sun.misc.BASE64Encoder; //导入方法依赖的package包/类
public OutputStream InputStreamtoB64OutputStream(InputStream a_cadena)
throws Throwable
{
BASE64Encoder l_enco = new BASE64Encoder();
ByteArrayOutputStream l_stream = new ByteArrayOutputStream();
l_enco.encodeBuffer(a_cadena, l_stream);
return l_stream;
}
示例4: StringToB64OutputStream
import sun.misc.BASE64Encoder; //导入方法依赖的package包/类
public OutputStream StringToB64OutputStream(String as_cadena)
throws Throwable
{
BASE64Encoder l_enco = new BASE64Encoder();
ByteArrayOutputStream l_stream = new ByteArrayOutputStream();
l_enco.encodeBuffer(as_cadena.getBytes(FuncionesCadena.getCharset()), l_stream);
return l_stream;
}
示例5: dumpCert
import sun.misc.BASE64Encoder; //导入方法依赖的package包/类
private void dumpCert(java.security.cert.Certificate certificate, PrintStream printstream)
throws IOException, CertificateException {
if(rfc) {
BASE64Encoder base64encoder = new BASE64Encoder();
printstream.println("-----BEGIN CERTIFICATE-----");
base64encoder.encodeBuffer(certificate.getEncoded(), printstream);
printstream.println("-----END CERTIFICATE-----");
} else {
printstream.write(certificate.getEncoded());
}
}
示例6: base64Decode
import sun.misc.BASE64Encoder; //导入方法依赖的package包/类
public String base64Decode(byte[] arr) {
//String b64 = DatatypeConverter.printBase64Binary(arr);
long startTime = System.currentTimeMillis();
BASE64Encoder encoder = new BASE64Encoder();
String b64 = encoder.encodeBuffer(arr);
long endTime = System.currentTimeMillis();
Logger.log("Base64 decode time(ms): " + (endTime - startTime));
return b64;
}
示例7: getSendContent
import sun.misc.BASE64Encoder; //导入方法依赖的package包/类
private String getSendContent() {
java.util.Date currentTime = new java.util.Date();
String pDate = formatter.format(currentTime);
// String sendSeq = sendSeqFormatter.format(currentTime);
String retXML = null;
StringBuffer data = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
data.append("<upbp application=\"MTransRefund.Req\" version =\"1.0.0\" sendTime =\"")
.append(pDate).append("\" sendSeqId =\"").append(sendSeqId).append("\">\n");
data.append("<merchantName>").append(merchantName).append("</merchantName>\n");
data.append("<merchantId>").append(merchantId).append("</merchantId>\n");
data.append("<merchantOrderId>").append(merchantOrderId).append("</merchantOrderId>\n");
data.append("<merchantOrderTime>").append(merchantOrderTime).append("</merchantOrderTime>\n");
data.append("<merchantOrderAmt>").append(merchantOrderAmt).append("</merchantOrderAmt>\n");
data.append("<merchantOrderCurrency>").append(merchantOrderCurrency).append("</merchantOrderCurrency>\n");
data.append("<cupsQid>").append(cupsQid).append("</cupsQid>\n");
data.append("</upbp>");
LogUtil.printInfoLog("UnionPayRefund2", "getSendContent","Request: tseq=" + merchantOrderId + " cupsQid=" + cupsQid + "\n" + data.toString());
BASE64Encoder encoder = new BASE64Encoder();
BASE64Decoder decoder = new BASE64Decoder();
String merchantId2 = encoder.encodeBuffer(merchantId.getBytes());
String mm = MD5.getHashString(radomNu());
String keyPath = CertUtil.getCertPath("UNIONPAYWAP_USER_Sign_CRT");
String privateKey = EncDecUtil.getCertKey(keyPwd, keyPath);
try {
String desKey = encoder.encodeBuffer(RSACoder.encryptByPrivateKey(
mm.getBytes(), decoder.decodeBuffer(privateKey)));
byte[] bodyb = DesUtil2.encrypt(data.toString().getBytes("utf-8"),
mm.getBytes());
String miBody = encoder.encode(bodyb);
String sendXML = merchantId2 + "|" + desKey + "|" + miBody;
RemoteAccessor remoteAccessor = new RemoteAccessor();
String re = remoteAccessor.getResponseByStream("http://upwap.bypay.cn/gateWay/gate.html", "utf-8",sendXML);
LogUtil.printInfoLog("UnionPayRefund2", "getSendContent","Response: tseq=" + merchantOrderId + " cupsQid=" + cupsQid + "\n" + re);
String[] strArr = re.split("\\|");
String isSucRes=strArr[0];
/***
* 正确的返回格式:1|90eFDGOoutaOxuOocgZI4KkpBZvQSJULCm2TiLuxfyz4aUJ+WRjmOrw4kw5DbuiW2mvdJ8Q8IjE46BeUX2b124S/kXWCMZKJ6TimuilvhGvadjK3/ceko+ckH2P7oPBiUeqqml71R/F+PwUf/QDYRDQnoeFNcFHyoWnzC3IovgxvzBGEmm9f1KHsH0s/U2YKBPXc3k22Q8Atov+T6vGdl2P87mMie9O+l25KfuVJjr9b6kOgvbMWIaKb+87e9GV7B+ol4DhAMnkiLv7SAF5XqWWvd71RMjayEeDl27RVAL8XL4fVmNMYE+bBnrW4p0odxb3m8bLP+1wEIPzlYFM8BDzNb/DBq1CoKB7tSwyZYhllb4bc4HPUezJNFYNWzuXUCGABTjsNE7vFvebxss/7XK+R6l/rS3Q//ZB7Rmb5eIzFvebxss/7XLG0IzwQtlzgdiCfVrX8UqPir39ytwtw6C/oJjuyJSKY/ZB7Rmb5eIzFvebxss/7XABmqD7OFKsw0lSz33YuymRob5DkPXUxw1vx080zEzTjBhQBt2V5T5TTOSg292pZyH2RIV4DUy+7haT18+5MiJI43IPDpNkG5aii2ns38FEl2ZbJcgYl+g49TmKsmZznZ0Re4RRTg57QaUTYIpslvXmEOq4MZ0t148uhiTTjklHuI0E0EE8oB9XQ84CBSlMt8dRT2qKKE5hq+TOfCNemJ3E=|MWNkNGU0YTliMWM4ZTMyZjJhZDNmM2ZhZDgzM2M3NGM=
* 错误的返回格式:0|0003|5Y+C5pWw6ZSZ6K+v
*/
byte[] b=null;
if("1".equals(isSucRes)){
byte[] de = decoder.decodeBuffer(strArr[1]);
b = DesUtil2.decrypt(de, mm.getBytes());
retXML = new String(b, "utf-8");
}else{
String errorMsg=Base64.decodeToString(strArr[2]);
Map<String, String> map=new HashMap<String, String>();
map.put("isSucRes", isSucRes);
map.put("errorCode", strArr[1]);
map.put("errorMsg", errorMsg);
LogUtil.printInfoLog("UninPayRefund2", "getSendContent", "", map);
StringBuffer ret=new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>");
ret.append("<upbp>");
ret.append("<respCode>").append(strArr[1]).append("</respCode>");
ret.append("<respDesc>").append(errorMsg).append("</respDesc>");
ret.append("</upbp>");
retXML=ret.toString();
}
} catch (Exception e) {
LogUtil.printErrorLog("UninPayRefund2", "getSendContent", "tseq=" + merchantOrderId + " cupsQid=" + cupsQid, e);
}
return retXML;
}
示例8: getQueryXML
import sun.misc.BASE64Encoder; //导入方法依赖的package包/类
public String getQueryXML() {
java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat(
"yyyyMMddHHmmss");
java.text.SimpleDateFormat sendSeqFormatter = new java.text.SimpleDateFormat(
"yyMMddHHmmss");
java.util.Date currentTime = new java.util.Date();
String pDate = formatter.format(currentTime);
String sendSeq = sendSeqFormatter.format(currentTime);
String queryXML = null;
StringBuffer data = new StringBuffer(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
data.append(
"<upbp application=\"MTransInfo.Req\" version =\"1.0.0\" sendTime =\"")
.append(pDate).append("\" sendSeqId =\"").append(sendSeq)
.append("\">");
data.append("<transType>01</transType>");
data.append("<merchantId>872310045110201</merchantId>");
data.append("<merchantOrderId>").append(merchantOrderId)
.append("</merchantOrderId>");
data.append("<merchantOrderTime>").append(merchantOrderTime)
.append("</merchantOrderTime>");
data.append("</upbp>");
BASE64Encoder encoder = new BASE64Encoder();
BASE64Decoder decoder = new BASE64Decoder();
String merchantId = encoder.encodeBuffer("872310045110201".getBytes());
String mm = MD5.getHashString(radomNu());
String keyPath = CertUtil.getCertPath("UNIONPAYWAP_USER_Sign_CRT");
String privateKey = EncDecUtil.getCertKey("123456", keyPath);
try {
String desKey = encoder.encodeBuffer(RSACoder.encryptByPrivateKey(
mm.getBytes(), decoder.decodeBuffer(privateKey)));
byte[] bodyb = DesUtil2.encrypt(data.toString().getBytes("utf-8"),
mm.getBytes());
String miBody = encoder.encode(bodyb);
String sendXML = merchantId + "|" + desKey + "|" + miBody;
RemoteAccessor remoteAccessor = new RemoteAccessor();
String re = remoteAccessor.getResponseByStream(
"http://upwap.bypay.cn/gateWay/gate.html",
"utf-8", sendXML);
LogUtil.printInfoLog("UnionWapQuery", "UnionWapQuery", "" + re);
String[] strArr = re.split("\\|");
byte[] de = decoder.decodeBuffer(strArr[1]);
byte[] b = DesUtil2.decrypt(de, mm.getBytes());
queryXML = new String(b, "utf-8");
} catch (Exception e) {
e.printStackTrace();
}
return queryXML;
}
示例9: unionPayWapSign
import sun.misc.BASE64Encoder; //导入方法依赖的package包/类
public static String unionPayWapSign(Map<String, String> p) {
String xml = null;
String judgeRediPage = null;
String redirectPage = null;
try {
String sysDate = p.get("sysDate");
String sysTime = getStringTime(Integer.valueOf(p.get("sysTime")));
String orderTime = sysDate + sysTime;
java.text.SimpleDateFormat sendSeqFormatter = new java.text.SimpleDateFormat("yyMMddHHmmss");
java.util.Date currentTime = new java.util.Date();
java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat("yyyyMMddHHmmss");
String pDate = formatter.format(currentTime);
String sendSeq = sendSeqFormatter.format(currentTime);
String merchantOrderId = p.get("merchantOrderId");
// 设置回调地址
String ewp_path = ParamCache.getStrParamByName("EWP_PATH");
String backurl = ewp_path + "bk/union_pay_wap_ret";
String fronturl = ewp_path + "bk/union_pay_wap_page_ret?tseq=" + merchantOrderId;
// 组织请求报文
StringBuffer data = new StringBuffer();
data.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
data.append("<upbp application=\"MGw.Req\" version=\"1.0.0\" sendTime=\"" + pDate + "\" sendSeqId=\"" + sendSeq + "\">\n");
data.append(" <merchantId>872310045110201</merchantId>\n");
data.append(" <merchantOrderId>" + merchantOrderId + "</merchantOrderId>\n");
data.append(" <merchantOrderTime>" + orderTime + "</merchantOrderTime>\n");
data.append(" <merchantOrderAmt>" + p.get("merchantOrderAmt") + "</merchantOrderAmt>\n");
data.append(" <gwType>01</gwType>\n");
data.append(" <frontUrl>" + fronturl + "</frontUrl>\n");
data.append(" <backUrl>" + backurl + "</backUrl>\n");
data.append(" <merchantOrderCurrency>156</merchantOrderCurrency>\n");
data.append(" <mobileNum>" + p.get("mobileNum") + "</mobileNum>\n");
data.append(" <merchantOrderDesc>" + handleOrderDesc(p.get("merchantUserId")) + "</merchantOrderDesc>\n");
data.append("</upbp>");
LogUtil.printInfoLog("UnionPayWap", "unionPayWapSign","request xml:\n" + data.toString());
BASE64Encoder encoder = new BASE64Encoder();
BASE64Decoder decoder = new BASE64Decoder();
String merchantId = encoder.encodeBuffer("872310045110201".getBytes());
String mm = MD5.getHashString(radomNu());
String keyPath = CertUtil.getCertPath("UNIONPAYWAP_USER_Sign_CRT");
String privateKey = EncDecUtil.getCertKey("123456", keyPath);
String desKey = encoder.encodeBuffer(RSACoder.encryptByPrivateKey(
mm.getBytes(), decoder.decodeBuffer(privateKey)));
byte[] bodyb = DesUtil2.encrypt(data.toString().getBytes("utf-8"),
mm.getBytes());
String miBody = encoder.encode(bodyb);
xml = merchantId + "|" + desKey + "|" + miBody;
RemoteAccessor remoteAccessor = new RemoteAccessor();
String re = remoteAccessor.getResponseByStream(
"http://upwap.bypay.cn/gateWay/gate.html", "utf-8", xml);
String[] strArr = re.split("\\|");
judgeRediPage = strArr[0];
byte[] de = decoder.decodeBuffer(strArr[1]);
byte[] b = DesUtil2.decrypt(de, mm.getBytes());
String content = new String(b, "utf-8");
LogUtil.printInfoLog("UnionPayWap", "unionPayWapSign", "response xml:\n" + content);
Document document = DocumentHelper.parseText(content);
Element upbp = document.getRootElement();
if ("1".equals(judgeRediPage)) {
redirectPage = upbp.elementText("gwInvokeCmd");
} else {
redirectPage = "error";
}
LogUtil.printInfoLog("UnionPayWap", "unionPayWapSign", "response pay:" + redirectPage);
} catch (Exception e) {
StringWriter trace = new StringWriter();
e.printStackTrace(new PrintWriter(trace));
LogUtil.printErrorLog("UnionPayWap", "unionPayWapSign", trace.toString());
}
return redirectPage;
}