zoukankan      html  css  js  c++  java
  • WebService

    public String  queryCreditInfo(Parameter parameter, String type)
       throws Exception {
      String jsonResult = null;
      try {
       if ("person".equals(type)) {
        HttpClient http = new HttpClient();
        System.out.println(parameter.getSign("person")); //加密
        String url = "https://www.alit.cn/reportserver/rest/ylService/personReport?name="+URLEncoder.encode(parameter.getName(), "utf-8")+ "&idCard="+ parameter.getIdCard()+ "&card="+ parameter.getCard()+ "&confirmCard="+ parameter.getConfirmCard()+ "&member="+ parameter.getMember()+ "&sign="+parameter.getSign("person");
        Protocol myhttps = new Protocol("https", new MySSL(), 443);
        Protocol.registerProtocol("https", myhttps);
        GetMethod method = new GetMethod(url);
        http.executeMethod(method);
        jsonResult = method.getResponseBodyAsString();
       }else {
        throw new Exception("查询报告类型不能为空");
       } 
      } catch (Exception e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
      }
      return jsonResult;
     }

    //加密方法

    public String getSign(String type) throws Exception {
      if("person".equals(type)){
        this.sign = Md5.md5(this.getName() + this.getIdCard() + this.getCard()+this.getConfirmCard() + this.getMember() + this.getKey());
       return sign;
      }else if("merchant".equals(type)){
       if(null==this.getBussesCode()||"".equals(this.getBussesCode())){
        this.bussesCode = null;
       }
       if(null==this.getMid()||"".equals(this.getMid())){
        this.mid = null;
       }
       this.sign = Md5.md5(this.getName() + this.bussesCode + this.getMid()+ this.getMember() + this.getKey());
       return sign;
      }else{
       throw new Exception("sign生成错误");
      }
     }

    //MD5加密类

    public class Md5 {  

    private static final String encryModel = "MD5";  

    /**   * md5加密方法   * @param str   * @return   */    

    public static String md5(String str) throws Exception {        

      return md5(encryModel, str.getBytes("utf-8"));    

    }

    public static String md5(String algorithm, byte[] data) {        

      try {            

        MessageDigest md = MessageDigest.getInstance(algorithm);            

        md.update(data);            

        StringBuffer sb = new StringBuffer();            

        byte[] bytes = md.digest();            

        for (int i = 0; i < bytes.length; i++) {                

          int b = bytes[i] & 0xFF;                

          if (b < 0x10) {                    

            sb.append('0');                

          }                

          sb.append(Integer.toHexString(b));            

        }            

      return sb.toString();        

    } catch (Exception e) {            

    return "";        

    }    

    }     

  • 相关阅读:
    matlab从ECG信号数据趋势项的消除
    matlab使用移动平均滤波器、重采样和Hampel过滤器进行信号平滑处理
    R语言如何做马尔科夫转换模型markov switching model
    python主题建模可视化LDA和T-SNE交互式可视化
    R语言Wald检验 vs 似然比检验
    R语言rjags使用随机效应进行臭氧数据分析
    matlab对MCMC贝叶斯方法用于加筋复合板的冲击载荷识别
    4. 纯 CSS 创作一个金属光泽 3D 按钮特效
    3.纯 CSS 创作一个容器厚条纹边框特效
    2.纯 CSS 创作一个矩形旋转 loader 特效
  • 原文地址:https://www.cnblogs.com/Defry/p/4607641.html
Copyright © 2011-2022 走看看