org.xipki.util.Base64.decodeFast()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.2k)|赞(0)|评价(0)|浏览(220)

本文整理了Java中org.xipki.util.Base64.decodeFast()方法的一些代码示例,展示了Base64.decodeFast()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Base64.decodeFast()方法的具体详情如下:
包路径:org.xipki.util.Base64
类名称:Base64
方法名:decodeFast

Base64.decodeFast介绍

[英]Decodes a BASE64 encoded string that is known to be resonably well formatted. The method is about twice as fast as #decode(String). The preconditions are:

  • The array must have a line length of 76 chars OR no line separators at all (one line).
  • Line separator must be "\r\n", as specified in RFC 2045 + The array may not contain illegal characters within the encoded string
  • The array CAN have illegal characters at the beginning and end, those will be dealt with appropriately.
    [中]解码已知格式合理的BASE64编码字符串。这种方法的速度大约是#解码(字符串)的两倍。先决条件是:
    +数组的行长度必须为76个字符,或者根本没有行分隔符(一行)。
    +按照RFC 2045+中的规定,行分隔符必须为“\r\n”。该数组不能在编码字符串中包含非法字符
    +数组的开头和结尾可能有非法字符,这些字符将被适当处理。

代码示例

代码示例来源:origin: org.xipki/ca-mgmt-client

private String getBase64HashValue(ResultSet rs) throws SQLException {
  if (dbControl == DbControl.XIPKI_OCSP_v4) {
   return rs.getString("HASH");
  } else { // if (dbControl == DbControl.XIPKI_CA_v4) {
   if (certhashAlgo == HashAlgo.SHA1) {
    return rs.getString("SHA1");
   } else {
    String b64Cert = rs.getString("CERT");
    byte[] encodedCert = Base64.decodeFast(b64Cert);
    return certhashAlgo.base64Hash(encodedCert);
   }
  }
 }
}

代码示例来源:origin: org.xipki/ca-dbtool

private String getBase64HashValue(ResultSet rs) throws SQLException {
  if (dbControl == DbControl.XIPKI_OCSP_v4) {
   return rs.getString("HASH");
  } else { // if (dbControl == DbControl.XIPKI_CA_v4) {
   if (certhashAlgo == HashAlgo.SHA1) {
    return rs.getString("SHA1");
   } else {
    String b64Cert = rs.getString("CERT");
    byte[] encodedCert = Base64.decodeFast(b64Cert);
    return certhashAlgo.base64Hash(encodedCert);
   }
  }
 }
}

代码示例来源:origin: org.xipki/ca-mgmt-client

private static Map<Integer, byte[]> getCas(DataSourceWrapper datasource, DbControl dbControl)
  throws DataAccessException {
 // get a list of available CAs in the target database
 String sql = "SELECT ID,CERT FROM ";
 if (dbControl == DbControl.XIPKI_CA_v4) {
  sql += "CA";
 } else if (dbControl == DbControl.XIPKI_OCSP_v4) {
  sql += "ISSUER";
 } else {
  throw new IllegalArgumentException("unknown dbControl " + dbControl);
 }
 Statement stmt = datasource.createStatement();
 Map<Integer, byte[]> caIdCertMap = new HashMap<>(5);
 ResultSet rs = null;
 try {
  rs = stmt.executeQuery(sql);
  while (rs.next()) {
   caIdCertMap.put(rs.getInt("ID"), Base64.decodeFast(rs.getString("CERT")));
  }
 } catch (SQLException ex) {
  throw datasource.translate(sql, ex);
 } finally {
  datasource.releaseResources(stmt, rs);
 }
 return caIdCertMap;
}

代码示例来源:origin: org.xipki/ca-dbtool

private static Map<Integer, byte[]> getCas(DataSourceWrapper datasource, DbControl dbControl)
  throws DataAccessException {
 // get a list of available CAs in the target database
 String sql = "SELECT ID,CERT FROM ";
 if (dbControl == DbControl.XIPKI_CA_v4) {
  sql += "CA";
 } else if (dbControl == DbControl.XIPKI_OCSP_v4) {
  sql += "ISSUER";
 } else {
  throw new IllegalArgumentException("unknown dbControl " + dbControl);
 }
 Connection conn = datasource.getConnection();
 Statement stmt = datasource.createStatement(conn);
 Map<Integer, byte[]> caIdCertMap = new HashMap<>(5);
 ResultSet rs = null;
 try {
  rs = stmt.executeQuery(sql);
  while (rs.next()) {
   caIdCertMap.put(rs.getInt("ID"), Base64.decodeFast(rs.getString("CERT")));
  }
 } catch (SQLException ex) {
  throw datasource.translate(sql, ex);
 } finally {
  datasource.releaseResources(stmt, rs);
 }
 return caIdCertMap;
}

代码示例来源:origin: org.xipki/ca-mgmt-client

hash = rs.getString("SHA1");
} else {
 hash = certhashAlgo.base64Hash(Base64.decodeFast(rs.getString("CERT")));

代码示例来源:origin: org.xipki/ca-dbtool

hash = rs.getString("SHA1");
} else {
 hash = certhashAlgo.base64Hash(Base64.decodeFast(rs.getString("CERT")));

代码示例来源:origin: org.xipki/ca-server

public byte[] getEncodedCrl(NameId ca, BigInteger crlNumber) throws OperationException {
 Args.notNull(ca, "ca");
 String sql = (crlNumber == null) ? sqlCrl : sqlCrlWithNo;
 ResultSet rs = null;
 PreparedStatement ps = borrowPreparedStatement(sql);
 String b64Crl = null;
 try {
  int idx = 1;
  ps.setInt(idx++, ca.getId());
  if (crlNumber != null) {
   ps.setLong(idx++, crlNumber.longValue());
  }
  rs = ps.executeQuery();
  long currentThisUpdate = 0;
  // iterate all entries to make sure that the latest CRL will be returned
  while (rs.next()) {
   long thisUpdate = rs.getLong("THISUPDATE");
   if (thisUpdate >= currentThisUpdate) {
    b64Crl = rs.getString("CRL");
    currentThisUpdate = thisUpdate;
   }
  }
 } catch (SQLException ex) {
  throw new OperationException(DATABASE_FAILURE, datasource.translate(sql, ex).getMessage());
 } finally {
  datasource.releaseResources(ps, rs);
 }
 return (b64Crl == null) ? null : Base64.decodeFast(b64Crl);
} // method getEncodedCrl

代码示例来源:origin: org.xipki/ca-server

byte[] encodedCert = Base64.decodeFast(b64Cert);

代码示例来源:origin: org.xipki/ca-server

return (b64Req == null) ? null : Base64.decodeFast(b64Req);

代码示例来源:origin: org.xipki/ca-server

byte[] encodedCert = Base64.decodeFast(b64Cert);
X509Certificate cert = X509Util.parseCert(encodedCert);
CertWithDbId certWithMeta = new CertWithDbId(cert, encodedCert);

代码示例来源:origin: org.xipki/ca-server

byte[] certBytes = Base64.decodeFast(b64Cert);
X509Certificate cert;
try {

代码示例来源:origin: org.xipki/ca-server

byte[] encodedCert = Base64.decodeFast(b64Cert);
X509Certificate cert = X509Util.parseCert(encodedCert);

代码示例来源:origin: org.xipki/ca-dbtool

byte[] certBytes = Base64.decodeFast(rs.getString("CERT"));
byte[] crlBytes = Base64.decodeFast(rs.getString("CRL"));
byte[] dataBytes = Base64.decodeFast(rs.getString("DATA"));
String sha1 = HashAlgo.SHA1.hexHash(dataBytes);
final String dataFilename = sha1 + ".req";

代码示例来源:origin: org.xipki/ca-mgmt-client

byte[] certBytes = Base64.decodeFast(rs.getString("CERT"));
 ((CaCertstore.Certs) entriesInCurrentFile).add(cert);
} else if (CaDbEntryType.CRL == type) {
 byte[] crlBytes = Base64.decodeFast(rs.getString("CRL"));
 ((CaCertstore.Crls) entriesInCurrentFile).add(crl);
} else if (CaDbEntryType.REQUEST == type) {
 byte[] dataBytes = Base64.decodeFast(rs.getString("DATA"));
 String sha1 = HashAlgo.SHA1.hexHash(dataBytes);
 final String dataFilename = sha1 + ".req";

代码示例来源:origin: org.xipki/ca-server

if (hdrValue.length() > 6) {
 String b64 = hdrValue.substring(6);
 byte[] userPwd = Base64.decodeFast(b64);
 int idx = -1;
 for (int i = 0; i < userPwd.length; i++) {

相关文章

微信公众号

最新文章

更多