use of sun.misc.HexDumpEncoder in project jdk8u_jdk by JetBrains.
the class ESSCertId method toString.
public String toString() {
StringBuffer buffer = new StringBuffer();
buffer.append("[\n\tCertificate hash (SHA-1):\n");
if (hexDumper == null) {
hexDumper = new HexDumpEncoder();
}
buffer.append(hexDumper.encode(certHash));
if (issuer != null && serialNumber != null) {
buffer.append("\n\tIssuer: " + issuer + "\n");
buffer.append("\t" + serialNumber);
}
buffer.append("\n]");
return buffer.toString();
}
use of sun.misc.HexDumpEncoder in project jdk8u_jdk by JetBrains.
the class LDAPCertStore method getCRLs.
/*
* Gets CRLs from an attribute id and location in the LDAP directory.
* Returns a Collection containing only the CRLs that match the
* specified CRLSelector.
*
* @param name the location holding the attribute
* @param id the attribute identifier
* @param sel a CRLSelector that the CRLs must match
* @return a Collection of CRLs found
* @throws CertStoreException if an exception occurs
*/
private Collection<X509CRL> getCRLs(LDAPRequest request, String id, X509CRLSelector sel) throws CertStoreException {
/* fetch the encoded crls from storage */
byte[][] encodedCRL;
try {
encodedCRL = request.getValues(id);
} catch (NamingException namingEx) {
throw new CertStoreException(namingEx);
}
int n = encodedCRL.length;
if (n == 0) {
return Collections.emptySet();
}
List<X509CRL> crls = new ArrayList<>(n);
/* decode each crl and check if it matches selector */
for (int i = 0; i < n; i++) {
try {
CRL crl = cf.generateCRL(new ByteArrayInputStream(encodedCRL[i]));
if (sel.match(crl)) {
crls.add((X509CRL) crl);
}
} catch (CRLException e) {
if (debug != null) {
debug.println("LDAPCertStore.getCRLs() encountered exception" + " while parsing CRL, skipping the bad data: ");
HexDumpEncoder encoder = new HexDumpEncoder();
debug.println("[ " + encoder.encodeBuffer(encodedCRL[i]) + " ]");
}
}
}
return crls;
}
use of sun.misc.HexDumpEncoder in project jdk8u_jdk by JetBrains.
the class InputRecord method readFully.
private int readFully(InputStream s, byte[] b, int off, int len) throws IOException {
int n = 0;
while (n < len) {
int readLen = s.read(b, off + n, len - n);
if (readLen < 0) {
return readLen;
}
if (debug != null && Debug.isOn("packet")) {
try {
HexDumpEncoder hd = new HexDumpEncoder();
ByteBuffer bb = ByteBuffer.wrap(b, off + n, readLen);
System.out.println("[Raw read]: length = " + bb.remaining());
hd.encodeBuffer(bb, System.out);
} catch (IOException e) {
}
}
n += readLen;
exlen += readLen;
}
return n;
}
use of sun.misc.HexDumpEncoder in project jdk8u_jdk by JetBrains.
the class OutputRecord method writeBuffer.
/*
* Actually do the write here. For SSLEngine's HS data,
* we'll override this method and let it take the appropriate
* action.
*/
void writeBuffer(OutputStream s, byte[] buf, int off, int len, int debugOffset) throws IOException {
s.write(buf, off, len);
s.flush();
// Output only the record from the specified debug offset.
if (debug != null && Debug.isOn("packet")) {
try {
HexDumpEncoder hd = new HexDumpEncoder();
System.out.println("[Raw write]: length = " + (len - debugOffset));
hd.encodeBuffer(new ByteArrayInputStream(buf, off + debugOffset, len - debugOffset), System.out);
} catch (IOException e) {
}
}
}
use of sun.misc.HexDumpEncoder in project jdk8u_jdk by JetBrains.
the class X509CertImpl method toString.
/**
* Returns a printable representation of the certificate. This does not
* contain all the information available to distinguish this from any
* other certificate. The certificate must be fully constructed
* before this function may be called.
*/
public String toString() {
if (info == null || algId == null || signature == null)
return "";
StringBuilder sb = new StringBuilder();
sb.append("[\n");
sb.append(info.toString() + "\n");
sb.append(" Algorithm: [" + algId.toString() + "]\n");
HexDumpEncoder encoder = new HexDumpEncoder();
sb.append(" Signature:\n" + encoder.encodeBuffer(signature));
sb.append("\n]");
return sb.toString();
}
Aggregations