本文整理了Java中org.xipki.util.Base64.encodeToString()
方法的一些代码示例,展示了Base64.encodeToString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Base64.encodeToString()
方法的具体详情如下:
包路径:org.xipki.util.Base64
类名称:Base64
方法名:encodeToString
[英]The same as encodeToString(byte[], false).
[中]与encodeToString相同(字节[],false)。
代码示例来源:origin: org.xipki/util
/**
*
* The same as encodeToString(byte[], false).
*
* @param sArr
* The bytes to convert. If <code>null</code> or length 0 an empty array will be
* returned.
* @return A BASE64 encoded array without line separator. Never <code>null</code>.
*/
public static final String encodeToString(byte[] sArr) {
return encodeToString(sArr, false);
}
代码示例来源:origin: xipki/xipki
/**
*
* The same as encodeToString(byte[], false).
*
* @param sArr
* The bytes to convert. If <code>null</code> or length 0 an empty array will be
* returned.
* @return A BASE64 encoded array without line separator. Never <code>null</code>.
*/
public static final String encodeToString(byte[] sArr) {
return encodeToString(sArr, false);
}
代码示例来源:origin: xipki/xipki
public static String base64Encode(byte[] data, boolean withLineBreak) {
return Base64.encodeToString(data, withLineBreak);
}
代码示例来源:origin: org.xipki/util
public static String base64Encode(byte[] data, boolean withLineBreak) {
return Base64.encodeToString(data, withLineBreak);
}
代码示例来源:origin: org.xipki/ca-mgmt-api
private String getBase64Binary(FileOrBinaryType fileOrBinary, ZipFile zipFile)
throws IOException {
byte[] binary = getBinary(fileOrBinary, zipFile);
return (binary == null) ? null : Base64.encodeToString(binary);
}
代码示例来源:origin: org.xipki/ca-api
private String getBase64Binary(FileOrBinary fileOrBinary, Map<String, byte[]> zipEntries)
throws IOException {
byte[] binary = getBinary(fileOrBinary, zipEntries);
return (binary == null) ? null : Base64.encodeToString(binary);
}
代码示例来源:origin: org.xipki/security
public static String base64Hash(HashAlgo hashAlgo, byte[] data, int offset, int len) {
return Base64.encodeToString(hash(hashAlgo, data, offset, len));
}
代码示例来源:origin: org.xipki/security
public static String base64Sha1(byte[] data) {
return Base64.encodeToString(hash(HashAlgo.SHA1, data, 0, data.length));
}
代码示例来源:origin: org.xipki/security
public static String base64Sha256(byte[] data, int offset, int len) {
return Base64.encodeToString(hash(HashAlgo.SHA256, data, offset, len));
}
代码示例来源:origin: org.xipki/security
public static String base64Sha1(byte[] data, int offset, int len) {
return Base64.encodeToString(hash(HashAlgo.SHA1, data, offset, len));
}
代码示例来源:origin: org.xipki/security
public static String base64Hash(HashAlgo hashAlgo, byte[] data) {
return Base64.encodeToString(hash(hashAlgo, data, 0, data.length));
}
代码示例来源:origin: org.xipki/security
public static String base64Sha256(byte[] data) {
return Base64.encodeToString(hash(HashAlgo.SHA256, data, 0, data.length));
}
代码示例来源:origin: org.xipki/security
public static String toPemCert(X509Certificate cert) throws CertificateException {
Args.notNull(cert, "cert");
return StringUtil.concat("-----BEGIN CERTIFICATE-----\n",
Base64.encodeToString(cert.getEncoded(), true),
"\n-----END CERTIFICATE-----");
}
代码示例来源:origin: org.xipki/ca-api
static String formatCert(X509Certificate cert, boolean verbose) {
if (cert == null) {
return " null";
}
StringBuilder sb = new StringBuilder(verbose ? 1000 : 100);
sb.append(" issuer: ")
.append(X509Util.getRfc4519Name(cert.getIssuerX500Principal())).append('\n');
sb.append(" serialNumber: ").append(LogUtil.formatCsn(cert.getSerialNumber())).append('\n');
sb.append(" subject: ")
.append(X509Util.getRfc4519Name(cert.getSubjectX500Principal())).append('\n');
sb.append(" notBefore: ").append(cert.getNotBefore()).append("\n");
sb.append(" notAfter: ").append(cert.getNotAfter());
if (verbose) {
sb.append("\n encoded: ");
try {
sb.append(Base64.encodeToString(cert.getEncoded()));
} catch (CertificateEncodingException ex) {
sb.append("ERROR");
}
}
return sb.toString();
}
代码示例来源:origin: org.xipki/ca-mgmt-api
static String formatCert(X509Certificate cert, boolean verbose) {
if (cert == null) {
return " null";
}
StringBuilder sb = new StringBuilder(verbose ? 1000 : 100);
sb.append(" issuer: ")
.append(X509Util.getRfc4519Name(cert.getIssuerX500Principal())).append('\n');
sb.append(" serialNumber: ").append(LogUtil.formatCsn(cert.getSerialNumber())).append('\n');
sb.append(" subject: ")
.append(X509Util.getRfc4519Name(cert.getSubjectX500Principal())).append('\n');
sb.append(" notBefore: ").append(cert.getNotBefore()).append("\n");
sb.append(" notAfter: ").append(cert.getNotAfter());
if (verbose) {
sb.append("\n encoded: ");
try {
sb.append(Base64.encodeToString(cert.getEncoded()));
} catch (CertificateEncodingException ex) {
sb.append("ERROR");
}
}
return sb.toString();
}
代码示例来源:origin: org.xipki/ca-api
public MgmtEntry.Signer toSignerEntry() {
String base64Cert = null;
if (encodedCert != null) {
base64Cert = Base64.encodeToString(encodedCert);
}
MgmtEntry.Signer ret = new MgmtEntry.Signer(name, type, conf, base64Cert);
ret.setConfFaulty(faulty);
return ret;
}
}
代码示例来源:origin: org.xipki/ca-server
public long addRequest(byte[] request) throws OperationException {
Args.notNull(request, "request");
long id = idGenerator.nextId();
long currentTimeSeconds = System.currentTimeMillis() / 1000;
String b64Request = Base64.encodeToString(request);
final String sql = SQL_ADD_REQUEST;
PreparedStatement ps = borrowPreparedStatement(sql);
try {
ps.setLong(1, id);
ps.setLong(2, currentTimeSeconds);
ps.setString(3, b64Request);
ps.executeUpdate();
} catch (SQLException ex) {
throw new OperationException(DATABASE_FAILURE, datasource.translate(sql, ex).getMessage());
} finally {
datasource.releaseResources(ps, null);
}
return id;
}
代码示例来源:origin: org.xipki.shell/ca-mgmt-shell
@Override
protected Object execute0() throws Exception {
String cert = null;
if (CaManager.NULL.equalsIgnoreCase(certFile)) {
cert = CaManager.NULL;
} else if (certFile != null) {
Certificate bcCert = X509Util.parseBcCert(new File(certFile));
byte[] certBytes = bcCert.getEncoded();
cert = Base64.encodeToString(certBytes);
}
String msg = "signer " + name;
try {
caManager.changeSigner(name, type, getSignerConf(), cert);
println("updated " + msg);
return null;
} catch (CaMgmtException ex) {
throw new CmdFailure("could not update " + msg + ", error: " + ex.getMessage(), ex);
}
}
代码示例来源:origin: org.xipki/ca-server
public boolean addCert(CertificateInfo certInfo) {
Args.notNull(certInfo, "certInfo");
try {
addCert(certInfo.getIssuer(), certInfo.getCert(), certInfo.getSubjectPublicKey(),
certInfo.getProfile(), certInfo.getRequestor(), certInfo.getUser(), certInfo.getReqType(),
certInfo.getTransactionId(), certInfo.getRequestedSubject());
} catch (Exception ex) {
LOG.error("could not save certificate {}: {}. Message: {}",
new Object[]{certInfo.getCert().getSubject(),
Base64.encodeToString(certInfo.getCert().getEncodedCert(), true), ex.getMessage()});
LOG.debug("error", ex);
return false;
}
return true;
}
代码示例来源:origin: org.xipki.shell/ca-mgmt-shell
@Override
protected Object execute0() throws Exception {
if (!(certFile == null ^ password == null)) {
throw new CmdFailure("exactly one of cert and password must be specified");
}
MgmtEntry.Requestor entry;
if (certFile != null) {
X509Certificate cert = X509Util.parseCert(IoUtil.read(certFile));
entry = new MgmtEntry.Requestor(new NameId(null, name), MgmtEntry.Requestor.TYPE_CERT,
Base64.encodeToString(cert.getEncoded()));
} else {
entry = new MgmtEntry.Requestor(
new NameId(null, name), MgmtEntry.Requestor.TYPE_PBM, password);
String keyId = HashAlgo.SHA1.hexHash(entry.getIdent().getName().getBytes("UTF-8"));
println("The key ID is " + keyId);
}
String msg = "CMP requestor " + name;
try {
caManager.addRequestor(entry);
println("added " + msg);
return null;
} catch (CaMgmtException ex) {
throw new CmdFailure("could not add " + msg + ", error: " + ex.getMessage(), ex);
}
}
内容来源于网络,如有侵权,请联系作者删除!