Search in sources :

Example 26 with BASE64Encoder

use of sun.misc.BASE64Encoder in project portal by ixinportal.

the class ReceiptConfigService method receiptTest.

// 电票查询票数测试
public Map<String, Object> receiptTest(String idCode) {
    Map<String, Object> re = new HashMap<String, Object>();
    re.put("retCode", false);
    re.put("retMsg", "测试失败");
    Call call;
    String val = "";
    String content = "<REQUEST_COMMON_FPKCCX class='REQUEST_COMMON_FPKCCX'>  <NSRSBH>" + idCode + "</NSRSBH> </REQUEST_COMMON_FPKCCX> ";
    try {
        String xml = getCommonXml("DFXJ1001", new BASE64Encoder().encodeBuffer(content.getBytes("UTF-8")));
        String ssl_store = "D:/cer/fapiao_ceshi.truststore";
        String ssl_pwd = "654321";
        System.setProperty("javax.net.ssl.trustStore", ssl_store);
        System.setProperty("javax.net.ssl.keyStorePassword", ssl_pwd);
        HostnameVerifier hv = new HostnameVerifier() {

            public boolean verify(String urlHostName, SSLSession session) {
                System.out.println("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost());
                return true;
            }
        };
        HttpsURLConnection.setDefaultHostnameVerifier(hv);
        Service s = new Service();
        call = (Call) s.createCall();
        call.setTargetEndpointAddress(new java.net.URL("https://202.104.113.26:8999/fpt_dsqz/services/DZFPService"));
        call.setOperation("doService");
        Object[] fn01 = { xml };
        System.out.println(xml);
        val = (String) call.invoke(fn01);
        if (StringUtils.isNotEmpty(val)) {
            re.put("retCode", true);
            re.put("retMsg", "测试成功");
        }
        System.out.println(val);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return re;
}
Also used : Call(org.apache.axis.client.Call) HashMap(java.util.HashMap) BASE64Encoder(sun.misc.BASE64Encoder) SSLSession(javax.net.ssl.SSLSession) Service(org.apache.axis.client.Service) HostnameVerifier(javax.net.ssl.HostnameVerifier)

Example 27 with BASE64Encoder

use of sun.misc.BASE64Encoder in project portal by ixinportal.

the class InvoiceTask method execute.

/**
 * 开票推送
 */
public void execute() {
    if (!isRun()) {
        return;
    }
    // 获取配置信息
    List<ReceiptConfig> list = sqlSession.selectList("com.itrus.portal.db.ReceiptConfigMapper.selectByExample", new ReceiptConfigExample());
    ReceiptConfig rc = list.get(0);
    // ReceiptConfig rc = sqlSession.selectOne("com.itrus.portal.db.ReceiptConfigMapper.selectByExample");
    if (null == rc || rc.getSend() != 1 || null == rc.getSpan()) {
        // 未配置信息、未开启、未配置时间间隔
        log.debug("未配置信息、未开启、未配置时间间隔");
        return;
    }
    // 上次时间为空,或者上次时间大于当前时间,则重新设置上次时间为当前时间的毫秒数
    if (null == rc.getCreateTime() || rc.getCreateTime().getTime() > System.currentTimeMillis()) {
        rc.setCreateTime(new Date());
        sqlSession.update("com.itrus.portal.db.ReceiptConfigMapper.updateByPrimaryKeySelective", rc);
    }
    // 判断是否在时间间隔内(当前时间小于 上次时间加上时间间隔)
    if (System.currentTimeMillis() < rc.getCreateTime().getTime() + (Integer.parseInt(rc.getSpan()) * 1000)) {
        log.debug("不在时间内");
        return;
    }
    rc.setCreateTime(new Date());
    sqlSession.update("com.itrus.portal.db.ReceiptConfigMapper.updateByPrimaryKeySelective", rc);
    log.debug("任务开始");
    DefaultTransactionDefinition def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
    TransactionStatus ts = null;
    try {
        /**
         * 	 进入test.cer所在目录,执行如下操作(注意配置环境变量),生成testclient.truststore文件:
         *   keytool -import -file test.cer -storepass 123456 -keystore testclient.truststore
         *   keytool -import -file fapiao_ceshi.cer -storepass ixin21060921 -keystore fapiao.truststore
         *   然后输入“y”,回车
         *   命令说明:
         *   keytool  JDK提供的证书生成工具,所有参数的用法参见keytool –help
         *   -import  执行导入
         *   -file test.cer  要导入的证书,即从ie上导出的证书
         *   -storepass 123456  证书的存取密码
         *   -keystore testclient.truststore 保存路径及文件名
         */
        // SysConfig sysConfig = sqlSession.selectOne("com.itrus.portal.db.SysConfigMapper.selectByType", SystemConfigService.TRUST_IMG);
        // 执行命令后,会生成该testclient.truststore
        String ssl_store = getClass().getClassLoader().getResource("").getPath() + File.separator + "fapiao.truststore";
        // 证书的存取密码,即执行命令时填写的密码
        String ssl_pwd = "ixin21060921";
        System.setProperty("javax.net.ssl.trustStore", ssl_store);
        System.setProperty("javax.net.ssl.keyStorePassword", ssl_pwd);
        // String url = "https://218.17.158.39:8999/fpt_dsqz/services/DZFPService?wsdl";
        HostnameVerifier hv = new HostnameVerifier() {

            public boolean verify(String urlHostName, SSLSession session) {
                System.out.println("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost());
                return true;
            }
        };
        HttpsURLConnection.setDefaultHostnameVerifier(hv);
        /*xml = "<?xml version='1.0' encoding='UTF-8' ?><interface xmlns=\"\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:schemaLocation=\"http://www.chinatax.gov.cn/tirip/dataspec/interfaces.xsd\" version=\"WLFP1.0\"> <globalInfo><appId>DZFP</appId><interfaceId></interfaceId><interfaceCode>DFXJ1001</interfaceCode><requestCode>DS</requestCode><requestTime>2015-12-28 10:05:17</requestTime><responseCode>DZFPQZ</responseCode><dataExchangeId>DZFPQZDFXJ10012015-12-28139070229</dataExchangeId></globalInfo><returnStateInfo><returnCode></returnCode><returnMessage>MDAwMA=="
			+"</returnMessage></returnStateInfo><Data><dataDescription><zipCode>0</zipCode><encryptCode>1</encryptCode><codeType /></dataDescription><content>PD94bWwgdmVyc2lvbj0iMS4wIj8+CjxSRVFVRVNUX0NPTU1PTl9GUEtKIGNsYXNzPSJSRVFVRVNU"
			+"X0NPTU1PTl9GUEtKIiB4bWxuczpuczI9Imh0dHA6Ly9kc3F6amsuZHpmcHF6IiB4bWxucz0iaHR0"
			+"cDovL3d3dy5mZWluaXUuY29tL2R6ZnAiPgogICAgPEZQUVFMU0g+MjAxNTEyMjgxNTAxMjI8L0ZQ"
			+"UVFMU0g+CiAgICA8S1BMWD4wPC9LUExYPgogICAgPFhTRl9OU1JTQkg+NDQwMzAwNTY4NTE5NzM3"
			+"PC9YU0ZfTlNSU0JIPgogICAgPFhTRl9NQz7nlLXlrZDlj5HnpajmtYvor5U8L1hTRl9NQz4KICAg"
			+"IDxYU0ZfRFpESD7ljZflsbHljLrom4flj6PjgIE4MzQ4NDk0OTwvWFNGX0RaREg+CiAgICA8WFNG"
			+"X1lIWkg+NDQwMzAwNTY4NTE5NzM3PC9YU0ZfWUhaSD4KICAgIDxHTUZfTlNSU0JIPjwvR01GX05T"
			+"UlNCSD4KICAgIDxHTUZfTUM+5byg5LiJPC9HTUZfTUM+CiAgICA8R01GX0RaREg+PC9HTUZfRFpE"
			+"SD4KICAgIDxHTUZfWUhaSD48L0dNRl9ZSFpIPgogICAgPEdNRl9TSkg+MTU5MjAwNjYzNDUsMTg5"
			+"NjQ3ODc4NzY8L0dNRl9TSkg+CiAgICA8R01GX0RaWVg+ZmVuZ2Zhbl95YW5AMTM5LmNvbTwvR01G"
			+"X0RaWVg+CiAgICA8RlBUX1pIPjwvRlBUX1pIPgogICAgPEtQUj7lsI/mmI48L0tQUj4KICAgIDxT"
			+"S1I+5p2O5ZubPC9TS1I+CiAgICA8RkhSPuWwj+eOizwvRkhSPgogICAgPFlGUF9ETT48L1lGUF9E"
			+"TT4KICAgIDxZRlBfSE0+PC9ZRlBfSE0+CiAgICA8SlNISj4xMTc8L0pTSEo+CiAgICA8SEpKRT4x"
			+"MDA8L0hKSkU+CiAgICA8SEpTRT4xNzwvSEpTRT4KICAgIDxCWj7lpIfms6g8L0JaPgogICAgPEhZ"
			+"TFg+MDwvSFlMWD4KICAgIDxCWTE+PC9CWTE+CiAgICA8QlkyPjwvQlkyPgogICAgPEJZMz48L0JZ"
			+"Mz4KICAgIDxCWTQ+PC9CWTQ+CiAgICA8Qlk1PjwvQlk1PgogICAgPEJZNj48L0JZNj4KICAgIDxC"
			+"WTc+PC9CWTc+CiAgICA8Qlk4PjwvQlk4PgogICAgPEJZOT48L0JZOT4KICAgIDxCWTEwPjwvQlkx"
			+"MD4KICAgIDxDT01NT05fRlBLSl9YTVhYUyBjbGFzcz0iQ09NTU9OX0ZQS0pfWE1YWCIgc2l6ZT0i"
			+"MiI+CiAgICAgICAgPENPTU1PTl9GUEtKX1hNWFg+CiAgICAgICAgICAgIDxGUEhYWj4wPC9GUEhY"
			+"Wj4KICAgICAgICAgICAgPFhNTUM+5rSX6KGj5rayPC9YTU1DPgogICAgICAgICAgICA8R0dYSD41"
			+"MDDlhYs8L0dHWEg+CiAgICAgICAgICAgIDxEVz7ooos8L0RXPgogICAgICAgICAgICA8WE1TTD4x"
			+"PC9YTVNMPgogICAgICAgICAgICA8WE1ESj41MDwvWE1ESj4KICAgICAgICAgICAgPFhNSkU+NTA8"
			+"L1hNSkU+CiAgICAgICAgICAgIDxTTD4wLjE3PC9TTD4KICAgICAgICAgICAgPFNFPjguNTwvU0U+"
			+"CiAgICAgICAgICAgIDxCWTE+PC9CWTE+CiAgICAgICAgICAgIDxCWTI+PC9CWTI+CiAgICAgICAg"
			+"ICAgIDxCWTM+PC9CWTM+CiAgICAgICAgICAgIDxCWTQ+PC9CWTQ+CiAgICAgICAgICAgIDxCWTU+"
			+"PC9CWTU+CiAgICAgICAgPC9DT01NT05fRlBLSl9YTVhYPgogICAgICAgIDxDT01NT05fRlBLSl9Y"
			+"TVhYPgogICAgICAgICAgICA8RlBIWFo+MDwvRlBIWFo+CiAgICAgICAgICAgIDxYTU1DPua0l+ih"
			+"o+a2sjwvWE1NQz4KICAgICAgICAgICAgPEdHWEg+NTAw5YWLPC9HR1hIPgogICAgICAgICAgICA8"
			+"RFc+6KKLPC9EVz4KICAgICAgICAgICAgPFhNU0w+MTwvWE1TTD4KICAgICAgICAgICAgPFhNREo+"
			+"NTA8L1hNREo+CiAgICAgICAgICAgIDxYTUpFPjUwPC9YTUpFPgogICAgICAgICAgICA8U0w+MC4x"
			+"NzwvU0w+CiAgICAgICAgICAgIDxTRT44LjU8L1NFPgogICAgICAgICAgICA8QlkxPjwvQlkxPgog"
			+"ICAgICAgICAgICA8QlkyPjwvQlkyPgogICAgICAgICAgICA8QlkzPjwvQlkzPgogICAgICAgICAg"
			+"ICA8Qlk0PjwvQlk0PgogICAgICAgICAgICA8Qlk1PjwvQlk1PgogICAgICAgIDwvQ09NTU9OX0ZQ"
			+"S0pfWE1YWD4KICAgIDwvQ09NTU9OX0ZQS0pfWE1YWFM+CjwvUkVRVUVTVF9DT01NT05fRlBLSj4="
			+"</content></Data></interface>]";*/
        org.apache.axis.client.Service s = new org.apache.axis.client.Service();
        Call call = (Call) s.createCall();
        call.setTargetEndpointAddress(new URL(rc.getAddress()));
        call.setOperation("doService");
        // log.error("*********rc.getAddress()*********="+rc.getAddress());
        // Client client = null;
        // String timeOut = "6000";
        // client = new Client(new URL(rc.getAddress()));
        // client.setProperty(CommonsHttpMessageSender.HTTP_TIMEOUT, timeOut);
        List<Map<String, Object>> billexall3 = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectByBillEreceipt", null);
        String xml;
        String val;
        Bill bill;
        Einvoice einvoice = null;
        Ereceipt ereceipt;
        Map<String, String> temp;
        String content;
        ReceiptConfig rcNew = null;
        int count = 0;
        for (Map<String, Object> data : billexall3) {
            ereceipt = sqlSession.selectOne("com.itrus.portal.db.EreceiptMapper.selectByPrimaryKey", data.get("eid"));
            if (ereceipt.getConfig() != rc.getId()) {
                rcNew = sqlSession.selectOne("com.itrus.portal.db.ReceiptConfigMapper.selectByPrimaryKey", ereceipt.getConfig());
            } else {
                rcNew = rc;
            }
            content = getContent(data, ereceipt);
            log.error("[input0]{}", content);
            xml = getCommonXml("DFXJ1001", new BASE64Encoder().encodeBuffer(content.getBytes("UTF-8")), rcNew.getAppId());
            log.error("[input1]{}", xml);
            Object[] fn01 = { xml };
            val = (String) call.invoke(fn01);
            log.error("[output]{}", val);
            temp = parseXml(val);
            if (!temp.get("returnCode").equals("0000")) {
                LogUtil.syslog(sqlSession, "开票推送", data.get("bill_id") + "开票推送失败,错误:" + temp.get("returnMessage"));
                log.error("ERRORLOG电子发票 {}", data.get("bill_id") + "开票推送失败,错误:" + temp.get("returnMessage"));
                continue;
            }
            temp = parseXml(new String(new BASE64Decoder().decodeBuffer(temp.get("content")), "UTF-8"));
            einvoice = sqlSession.selectOne("com.itrus.portal.db.EinvoiceMapper.selectByPrimaryKey", data.get("e_invoice"));
            einvoice.setInvoiceId(temp.get("FPQQLSH"));
            einvoice.setInvoiceCode(temp.get("FP_DM"));
            einvoice.setInvoiceNo(temp.get("FP_HM"));
            einvoice.setCheckCode(temp.get("JYM"));
            einvoice.setConfirmTime(sdf.parse(temp.get("KPRQ")));
            einvoice.setDlAddress(temp.get("PDF_URL"));
            einvoice.setStatus(1);
            einvoice.setInvoiceSum(Double.valueOf(String.valueOf(data.get("bill_sum"))));
            ts = transactionManager.getTransaction(def);
            sqlSession.update("com.itrus.portal.db.EinvoiceMapper.updateByPrimaryKeySelective", einvoice);
            bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", data.get("id"));
            bill.setIsInvoiced(1);
            bill.setBillTime(new Date());
            if (null == bill.getDelivery() && bill.getBillStatus() == 6) {
                bill.setBillStatus(ComNames.BILL_STATUS_8);
            }
            sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKeySelective", bill);
            transactionManager.commit(ts);
            count++;
        }
        LogUtil.syslog(sqlSession, "开票推送", "开票推送成功,推送" + billexall3.size() + "条,成功" + count + "条。");
        // 增值订单开票推送
        List<Map<String, Object>> extraBills = extraBillService.selectByBillEreceipt(null);
        ExtraBill extraBill;
        Integer count2 = 0;
        for (Map<String, Object> data : extraBills) {
            // hgh-4-电子发票的发票模版信息
            ereceipt = sqlSession.selectOne("com.itrus.portal.db.EreceiptMapper.selectByPrimaryKey", data.get("eid"));
            if (ereceipt.getConfig() != rc.getId()) {
                rcNew = sqlSession.selectOne("com.itrus.portal.db.ReceiptConfigMapper.selectByPrimaryKey", ereceipt.getConfig());
            } else {
                rcNew = rc;
            }
            // hgh-5-封装电票平台开票所需部分xml数据
            content = getContentInExtraBill(data, ereceipt);
            log.error("[input0]{}", content);
            // hgh-6-封装电票平台开票所需全部的xml数据
            xml = getCommonXml("DFXJ1001", new BASE64Encoder().encodeBuffer(content.getBytes("UTF-8")), rcNew.getAppId());
            log.error("[input1]{}", xml);
            Object[] fn01 = { xml };
            // hgh-7-发送开票数据到开票平台,并获得返回值信息
            val = (String) call.invoke(fn01);
            log.error("[output]{}", val);
            temp = parseXml(val);
            // 判断开票是否失败,如果开票失败,则记录失败原因
            if (!temp.get("returnCode").equals("0000")) {
                LogUtil.syslog(sqlSession, "开票推送", data.get("bill_id") + "开票推送失败,错误:" + temp.get("returnMessage"));
                log.error("ERRORLOG电子发票 {}", data.get("bill_id") + "开票推送失败,错误:" + temp.get("returnMessage"));
                continue;
            }
            // hgh-8-解析获得的内容信息,并记录到本地的电子开票记录表中
            temp = parseXml(new String(new BASE64Decoder().decodeBuffer(temp.get("content")), "UTF-8"));
            einvoice = sqlSession.selectOne("com.itrus.portal.db.EinvoiceMapper.selectByPrimaryKey", data.get("e_invoice"));
            einvoice.setInvoiceId(temp.get("FPQQLSH"));
            einvoice.setInvoiceCode(temp.get("FP_DM"));
            einvoice.setInvoiceNo(temp.get("FP_HM"));
            einvoice.setCheckCode(temp.get("JYM"));
            einvoice.setConfirmTime(sdf.parse(temp.get("KPRQ")));
            einvoice.setDlAddress(temp.get("PDF_URL"));
            einvoice.setStatus(1);
            einvoice.setInvoiceSum(Double.valueOf(String.valueOf(data.get("bill_sum"))));
            ts = transactionManager.getTransaction(def);
            sqlSession.update("com.itrus.portal.db.EinvoiceMapper.updateByPrimaryKeySelective", einvoice);
            extraBill = sqlSession.selectOne("com.itrus.portal.db.ExtraBillMapper.selectByPrimaryKey", data.get("id"));
            extraBill.setIsInvoiced(true);
            extraBill.setBillTime(new Date());
            extraBill.setBillStatus(ComNames.EXTRA_BILL_STATUS_7);
            extraBill.setFinishTime(new Date());
            extraBillService.updateByPrimaryKeySelective(extraBill);
            transactionManager.commit(ts);
            count2++;
        }
        LogUtil.syslog(sqlSession, "开票推送增值订单", "开票推送成功,推送" + extraBills.size() + "条,成功" + count2 + "条。");
        log.debug("任务结束");
    } catch (Exception e) {
        LogUtil.syslog(sqlSession, "开票推送", "开票推送失败,错误:" + e.toString());
        log.error("ERRORLOG电子发票 {}", "开票推送失败,错误:" + e.toString());
        e.printStackTrace();
    } finally {
        if (ts != null && !ts.isCompleted()) {
            transactionManager.rollback(ts);
        }
    }
}
Also used : DefaultTransactionDefinition(org.springframework.transaction.support.DefaultTransactionDefinition) TransactionStatus(org.springframework.transaction.TransactionStatus) URL(java.net.URL) BASE64Decoder(sun.misc.BASE64Decoder) Call(org.apache.axis.client.Call) BASE64Encoder(sun.misc.BASE64Encoder) SSLSession(javax.net.ssl.SSLSession) Service(org.springframework.stereotype.Service) Date(java.util.Date) UnknownHostException(java.net.UnknownHostException) UserInfoServiceException(com.itrus.portal.exception.UserInfoServiceException) HostnameVerifier(javax.net.ssl.HostnameVerifier) HashMap(java.util.HashMap) Map(java.util.Map)

Example 28 with BASE64Encoder

use of sun.misc.BASE64Encoder in project portal by ixinportal.

the class HMACSHA1 method getDigest.

/**
 * SUN提供的常用的算法名称有:MD2
 *							 MD5
 *							 SHA-1
 *							 SHA-256
 *							 SHA-384
 *							 SHA-512
 * @param originalStr
 * @return
 */
public static String getDigest(String algorithm, String originalStr) {
    try {
        // java.security.MessageDigest alg=java.security.MessageDigest.getInstance("MD5");
        MessageDigest alga = MessageDigest.getInstance(algorithm);
        alga.update(originalStr.getBytes("utf-8"));
        byte[] digesta = alga.digest();
        BASE64Encoder encoder = new sun.misc.BASE64Encoder();
        return encoder.encodeBuffer(digesta).trim();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : BASE64Encoder(sun.misc.BASE64Encoder) MessageDigest(java.security.MessageDigest) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 29 with BASE64Encoder

use of sun.misc.BASE64Encoder in project portal by ixinportal.

the class PDFSignServiceTest method getPDFBinary.

/**
 *  将PDF转换成base64编码
 *  1.使用BufferedInputStream和FileInputStream从File指定的文件中读取内容;
 *  2.然后建立写入到ByteArrayOutputStream底层输出流对象的缓冲输出流BufferedOutputStream
 *  3.底层输出流转换成字节数组,然后由BASE64Encoder的对象对流进行编码
 */
static byte[] getPDFBinary(File file) {
    FileInputStream fin = null;
    BufferedInputStream bin = null;
    ByteArrayOutputStream baos = null;
    BufferedOutputStream bout = null;
    try {
        // 建立读取文件的文件输出流
        fin = new FileInputStream(file);
        // 在文件输出流上安装节点流(更大效率读取)
        bin = new BufferedInputStream(fin);
        // 创建一个新的 byte 数组输出流,它具有指定大小的缓冲区容量
        baos = new ByteArrayOutputStream();
        // 创建一个新的缓冲输出流,以将数据写入指定的底层输出流
        bout = new BufferedOutputStream(baos);
        byte[] buffer = new byte[1024];
        int len = bin.read(buffer);
        while (len != -1) {
            bout.write(buffer, 0, len);
            len = bin.read(buffer);
        }
        // 刷新此输出流并强制写出所有缓冲的输出字节,必须这行代码,否则有可能有问题
        bout.flush();
        byte[] bytes = baos.toByteArray();
        // return bytes;
        // sun公司的API
        String strpdf = new BASE64Encoder().encodeBuffer(bytes).trim();
        return strpdf.getBytes("utf-8");
    // return encoder.encodeBuffer(bytes).trim();
    // apache公司的API
    // return Base64.encodeBase64String(bytes);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        // http://www.kmrlyy.com/lcnz/33460.html
        try {
            fin.close();
            bin.close();
            // 关闭 ByteArrayOutputStream 无效。此类中的方法在关闭此流后仍可被调用,而不会产生任何 IOException
            // baos.close();
            bout.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    // http://www.kmrlyy.com/penqiangyan/33461.html
    return null;
}
Also used : BufferedInputStream(java.io.BufferedInputStream) BASE64Encoder(sun.misc.BASE64Encoder) FileNotFoundException(java.io.FileNotFoundException) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) BufferedOutputStream(java.io.BufferedOutputStream) FileInputStream(java.io.FileInputStream)

Example 30 with BASE64Encoder

use of sun.misc.BASE64Encoder in project portal by ixinportal.

the class SignTool method signP1.

public String signP1(byte[] data) throws Exception {
    Signature signature = Signature.getInstance(signingAlgorithm);
    signature.initSign(privateKey);
    signature.update(data);
    byte[] sign = signature.sign();
    return new BASE64Encoder().encode(sign);
}
Also used : Signature(java.security.Signature) BASE64Encoder(sun.misc.BASE64Encoder)

Aggregations

BASE64Encoder (sun.misc.BASE64Encoder)45 IOException (java.io.IOException)17 ByteArrayOutputStream (java.io.ByteArrayOutputStream)12 MessageDigest (java.security.MessageDigest)8 FileInputStream (java.io.FileInputStream)7 BufferedInputStream (java.io.BufferedInputStream)6 BufferedOutputStream (java.io.BufferedOutputStream)6 FileNotFoundException (java.io.FileNotFoundException)6 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)4 Map (java.util.Map)4 HostnameVerifier (javax.net.ssl.HostnameVerifier)4 SSLSession (javax.net.ssl.SSLSession)4 Call (org.apache.axis.client.Call)4 BASE64Decoder (sun.misc.BASE64Decoder)4 File (java.io.File)3 URL (java.net.URL)3 Signature (java.security.Signature)3 X509Certificate (java.security.cert.X509Certificate)3 Date (java.util.Date)3