⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 psiapp.java

📁 这个是自由下载的
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
//      other_paCert.setValue(otherpacert_out);
//      other_paCert.setSize(otherpacert_out.length);
//      flag = psi.pmiGetPACertInfo(other_paCert, other_paCertInfo);
//      if (flag == 0) {
//        xmlparse.setSource(other_paCertInfo.extensions.getValueString());
//        switch (algoKind) {
//          case 1: // '\001'
//            str_other_Alog = xmlparse.getValue("asymm");
//            break;
//
//          case 2: // '\002'
//            str_other_Alog = xmlparse.getValue("symm");
//            break;
//
//          case 3: // '\003'
//            str_other_Alog = xmlparse.getValue("hash");
//            break;
//
//          case 4: // '\004'
//            str_other_Alog = xmlparse.getValue("symm_t");
//            break;
//
//          case 5: // '\005'
//            str_other_Alog = xmlparse.getValue("symm_s");
//            break;
//
//          default:
//            str_other_Alog = xmlparse.getValue("hash");
//            break;
//        }
//      }
//      if (str_owner_Alog.equals(""))
//        return -18000;
//      if (str_other_Alog.equals(""))
//        return -18000;
//      str_owner_Alog = str_owner_Alog + ",";
//      str_other_Alog = str_other_Alog + ",";
//      Vector owneralgo = new Vector();
//      Vector otheralgo = new Vector();
//      do {
//        int site = str_owner_Alog.indexOf(",", 0);
//        if (site < 0)
//          break;
//        owneralgo.addElement(str_owner_Alog.substring(0, site));
//        str_owner_Alog = str_owner_Alog.substring(site + 1);
//      }
//      while (true);
//      do {
//        int site = str_other_Alog.indexOf(",", 0);
//        if (site < 0)
//          break;
//        otheralgo.addElement(str_other_Alog.substring(0, site));
//        str_other_Alog = str_other_Alog.substring(site + 1);
//      }
//      while (true);
//      Enumeration owneralgoEnum = owneralgo.elements();
//      Enumeration otheralgoEnum = otheralgo.elements();
//      if (priorityKind <= 0)
//        while (otheralgoEnum.hasMoreElements()) {
//          algostring = otheralgoEnum.nextElement().toString();
//          while (owneralgoEnum.hasMoreElements())
//            if (algostring.equals(owneralgoEnum.nextElement().toString())) {
//              p = true;
//              break;
//            }
//          if (p)
//            break;
//          owneralgoEnum = owneralgo.elements();
//        }
//      else
//        while (owneralgoEnum.hasMoreElements()) {
//          algostring = owneralgoEnum.nextElement().toString();
//          while (otheralgoEnum.hasMoreElements())
//            if (algostring.equals(otheralgoEnum.nextElement().toString())) {
//              p = true;
//              break;
//            }
//          if (p)
//            break;
//          otheralgoEnum = otheralgoEnum = otheralgo.elements();
//        }
//      if (!p)
//        algostring = "";
//      if (algostring.equals("SHA1"))
//        return 32772;
//      if (algostring.equals("MD5"))
//        return 32771;
//      if (algostring.equals("RSA"))
//        return 100;
//      if (algostring.equals("ECC"))
//        return 101;
//      if (algostring.equals("RC4"))
//        return 26625;
//      if (algostring.equals("3DES"))
//        return 26115;
//      if (algostring.equals("SSF33"))
//        return 9;
//      if (algostring.equals("PMC3DES1"))
//        return 11;
//      if (algostring.equals("PMC3DES2"))
//        return 12;
//      if (algostring.equals("PMC3DES3"))
//        return 13;
//      if (algostring.equals("PMC3DES4"))
//        return 14;
//      if (algostring.equals("PMC3DES5"))
//        return 15;
//      if (algostring.equals("PMCHASH"))
//        return 32773;
//      if (algostring.equals(""))
//        return 0;
//    }
//    return flag;
  }

//  public int AdvGetAttrCertInfo(PKI_DATA i_acCert, ATTR_CERTINFO o_attrCertInfo) {
//    int flag = -18000;
//    flag = psi.pmiGetAttrCertInfo(i_acCert, o_attrCertInfo);
//    return flag;
//  }

//  public int AdvGetPACertInfo(PKI_DATA i_paCert, PA_CERTINFO o_paCertInfo) {
//    int flag = -18000;
//    flag = psi.pmiGetPACertInfo(i_paCert, o_paCertInfo);
//    return flag;
//  }

//  public PKI_DATA[] AdvGetAttrCertListFromLDAP(int searchType,
//                                               String searchValue) {
//    LDAPProcess ldapprocess = new LDAPProcess();
//    switch (searchType) {
//      case 1: // '\001'
//        return ldapprocess.WHLDAP_GetAACertFromLDAPByUserID(searchValue);
//
//      case 2: // '\002'
//        return ldapprocess.WHLDAP_GetAACertFromLDAPByTime(searchValue);
//
//      case 3: // '\003'
//        PKI_DATA buf1[] = new PKI_DATA[1];
//        byte buf[] = ldapprocess.WHLDAP_GetSOAFromLDAP(searchValue);
//        if (buf != null) {
//          buf1[0] = new PKI_DATA(buf, buf.length);
//          return buf1;
//        }
//        else {
//          return null;
//        }
//
//      case 4: // '\004'
//        PKI_DATA buf2[] = new PKI_DATA[1];
//        byte buff[] = ldapprocess.WHLDAP_GetAATFromLDAP(searchValue);
//        if (buff != null) {
//          buf2[0] = new PKI_DATA(buff, buff.length);
//          return buf2;
//        }
//        else {
//          return null;
//        }
//    }
//    return null;
//  }

  private synchronized void write(byte bt[], String filepath) {
    try {
      FileOutputStream fout = new FileOutputStream(filepath);
      fout.write(bt);
      fout.flush();
      fout.close();
      CurStatus = 0;
    }
    catch (Exception err) {
      CurStatus = -18003;
    }
  }

  private synchronized byte[] read(String filepath) {
    byte buf[] = new byte[1024];
    int readSize = 0;
    byte b_arr[];
    try {
      ByteArrayOutputStream b_out = new ByteArrayOutputStream();
      FileInputStream fin = new FileInputStream(filepath);
      while ( (readSize = fin.read(buf, 0, buf.length)) != -1) {
        b_out.write(buf, 0, readSize);
        b_out.flush();
      }
      b_arr = b_out.toByteArray();
      b_out.close();
      fin.close();
      CurStatus = 0;
    }
    catch (Exception e) {
      CurStatus = -18002;
      b_arr = new byte[0];
    }
    return b_arr;
  }
  
   /**
    * @Description  从LDAP获取用户证书
    * @param i_searchType[IN]   查找类型
    *                              取值范围为
    *                              1 按用户ID查询
    *                              2 按用户邮件地址查询
    *                              3 按证书ID查询
    * @param  i_certType[IN]    证书类型
    *                               取值范围为
    *                               1 加密证书
    *                               2 签名证书
    *                           此参数对于按证书ID查询无效
    * @param  i_searchValue[IN]
    *                           当searchType取值为1时,此参数为用户ID字符串
    *                           当searchType取值为2时,此参数为用户邮件字符串
    *                           当searchType取值为1时,此参数为证书ID字符串
    * @return * @param  o_outCert[OUT]
    */
    public String AdvGetCertFromLDAP(int i_searchType, int i_certType, String i_searchValue)
    {
    	LDAPProcess ldapprocess=new LDAPProcess();
    	byte[] b_out;

    	String outStr="";
    	int flag=ABERROR;

    	try
    	{
    		switch(i_searchType)
    		{
    		    case 1:
    		        //b_out=ldapprocess.WHLDAP_GetCertByUserid(i_certType,i_searchValue);//不支持
                        b_out=new byte[0];
    		        break;
    		    case 2:
    		        //b_out=ldapprocess.WHLDAP_GetCertByMailAddr(i_certType,i_searchValue);//不支持
                        b_out=new byte[0];
    		        break;
    		    case 3:
    		        b_out=ldapprocess.WHLDAP_GetCertByCertID(i_searchValue);
    		        break;
    		    default:
    		        b_out=new byte[0];
    		}

    		PKI_DATA outCert=new PKI_DATA();
    		PKI_DATA encCert=new PKI_DATA();

    		outCert.setSize(b_out.length);
    		outCert.setValue(b_out);

    		flag=psi.pkiBase64Encode(outCert,encCert);

    		if(flag==0)
    		    outStr=encCert.getValueString();

			CurStatus=flag;
    	}
    	catch(Exception err)
    	{
		    CurStatus=ABERROR;
    	}

    	return outStr;
    }

    /**
    * @Description  从LDAP获取CRL列表
    * @return CRL数据
    */
    public String AdvGetCRLFromLDAP()
    {
    	byte[] CRLData;
    	LDAPProcess ldapprocess=new LDAPProcess();
    	String outStr="";
    	int flag=ABERROR;

        try
        {
        	PKI_DATA outCRL=new PKI_DATA();
        	PKI_DATA encCRL=new PKI_DATA();

            CRLData= ldapprocess.WHLDAP_GetCRLFromLDAP();

            outCRL.setSize(CRLData.length);
            outCRL.setValue(CRLData);

            flag=psi.pkiBase64Encode(outCRL,encCRL);

            if(flag==0)
                outStr=encCRL.getValueString();

			CurStatus=flag;

        }
        catch(Exception err)
        {
		    CurStatus=ABERROR;
		}

        return outStr;
    }




	

  
  
/**
 * @Description  按照查询条件获取属性证书
        @param searchType[IN]   查找类型
 *                              取值范围为
 *                              1 按属性证书对应的PKC证书用户ID搜索
 *                              2 按时间搜索
 *                              3 查找属性特权项
 *                              4 查找特权模板
        @param searchValue[IN]   查找值
 *                              当searchType为1时,此参数为用户ID号。
 *                              当searchType为2时,此参数为开始时间以及结束时间。
     *	                                   时间的形式为"20031113064115-20031213064115",精确到秒,
 *	                                   年为4位,月、日、时、分、秒均为2位。
 *                                      分隔符"-"之前为查询的起始时间,之后为查询的结束时间;
 *	                                   如果未给出分隔符"-"以及查询的结束时间,
 *	                                   如" 20031113064115",则默认查询结束时间为当前系统时间
 *	                                   (注:查询的起始时间必须在当前系统时间之前)。
 *                              当searchType为3时,此参数为证书序列号。
 *                              当searchType为4时,此参数为证书序列号。
 * @return 获取的所有属性证书数组
 */
  public PKI_DATA[] AdvGetAttrCertListFromLDAP(int searchType,String searchValue)
  {
            LDAPProcess ldapprocess=new LDAPProcess();

          switch(searchType)
          {
          case 1:
                  return ldapprocess.WHLDAP_GetAACertFromLDAPByUserID(searchValue);
          case 2:
                  return ldapprocess.WHLDAP_GetAACertFromLDAPByTime(searchValue);

          case 3:
                  System.out.println("Start WHLDAP_GetSOAFromLDAP");
                  PKI_DATA[] buf = ldapprocess.WHLDAP_GetSOAFromLDAP(searchValue);
                  return buf;

          case 4:
                  PKI_DATA[] buf2=new PKI_DATA[1];
                  byte buff[] = ldapprocess.WHLDAP_GetAATFromLDAP(searchValue);
                  if(!(buff==null))
                  {
                    buf2[0] = new PKI_DATA(buff, buff.length);
                    return buf2;
                  }
                  else
                  {
                    return null;
                  }


          default:
                  return null;

          }
  }   

  private PSIJni psi;
  private ClientConf conf;
  private String keyLabel;
  private static final int ABERROR = -18000;
  private static final int ENCCERT_NUM_ERROR = -18001;
  private static final int READ_FILE_ERROR = -18002;
  private static final int WRITE_FILE_ERROR = -18003;
  private static final int INFILE_IS_NULL = -18500;
  private static final int OUTFILE_IS_NULL = -18501;
  private static final int CLEARFILE_IS_NULL = -18502;
  private static final int SIGNFILE_IS_NULL = -18003;
  private static final int SHA1 = 32772;
  private static final int MD5 = 32771;
  private static final int RSA = 100;
  private static final int ECC = 101;
  private static final int RC4 = 26625;
  private static final int TRIDES = 26115;
  private static final int SSF33 = 9;
  private static final int PMC3DES1 = 11;
  private static final int PMC3DES2 = 12;
  private static final int PMC3DES3 = 13;
  private static final int PMC3DES4 = 14;
  private static final int PMC3DES5 = 15;
  private static final int PMCHASH = 32773;
  private int CurStatus;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -