use of sun.misc.HexDumpEncoder in project jdk8u_jdk by JetBrains.
the class BlockCipherParamsCore method toString.
/*
* Returns a formatted string describing the parameters.
*/
public String toString() {
String LINE_SEP = System.getProperty("line.separator");
String ivString = LINE_SEP + " iv:" + LINE_SEP + "[";
HexDumpEncoder encoder = new HexDumpEncoder();
ivString += encoder.encodeBuffer(this.iv);
ivString += "]" + LINE_SEP;
return ivString;
}
use of sun.misc.HexDumpEncoder in project jdk8u_jdk by JetBrains.
the class X509CertSelector method toString.
/**
* Return a printable representation of the {@code CertSelector}.
*
* @return a {@code String} describing the contents of the
* {@code CertSelector}
*/
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("X509CertSelector: [\n");
if (x509Cert != null) {
sb.append(" Certificate: " + x509Cert.toString() + "\n");
}
if (serialNumber != null) {
sb.append(" Serial Number: " + serialNumber.toString() + "\n");
}
if (issuer != null) {
sb.append(" Issuer: " + getIssuerAsString() + "\n");
}
if (subject != null) {
sb.append(" Subject: " + getSubjectAsString() + "\n");
}
sb.append(" matchAllSubjectAltNames flag: " + String.valueOf(matchAllSubjectAltNames) + "\n");
if (subjectAlternativeNames != null) {
sb.append(" SubjectAlternativeNames:\n");
Iterator<List<?>> i = subjectAlternativeNames.iterator();
while (i.hasNext()) {
List<?> list = i.next();
sb.append(" type " + list.get(0) + ", name " + list.get(1) + "\n");
}
}
if (subjectKeyID != null) {
HexDumpEncoder enc = new HexDumpEncoder();
sb.append(" Subject Key Identifier: " + enc.encodeBuffer(subjectKeyID) + "\n");
}
if (authorityKeyID != null) {
HexDumpEncoder enc = new HexDumpEncoder();
sb.append(" Authority Key Identifier: " + enc.encodeBuffer(authorityKeyID) + "\n");
}
if (certificateValid != null) {
sb.append(" Certificate Valid: " + certificateValid.toString() + "\n");
}
if (privateKeyValid != null) {
sb.append(" Private Key Valid: " + privateKeyValid.toString() + "\n");
}
if (subjectPublicKeyAlgID != null) {
sb.append(" Subject Public Key AlgID: " + subjectPublicKeyAlgID.toString() + "\n");
}
if (subjectPublicKey != null) {
sb.append(" Subject Public Key: " + subjectPublicKey.toString() + "\n");
}
if (keyUsage != null) {
sb.append(" Key Usage: " + keyUsageToString(keyUsage) + "\n");
}
if (keyPurposeSet != null) {
sb.append(" Extended Key Usage: " + keyPurposeSet.toString() + "\n");
}
if (policy != null) {
sb.append(" Policy: " + policy.toString() + "\n");
}
if (pathToGeneralNames != null) {
sb.append(" Path to names:\n");
Iterator<GeneralNameInterface> i = pathToGeneralNames.iterator();
while (i.hasNext()) {
sb.append(" " + i.next() + "\n");
}
}
sb.append("]");
return sb.toString();
}
use of sun.misc.HexDumpEncoder in project jdk8u_jdk by JetBrains.
the class NullX500Name method main.
public static void main(String[] argv) throws Exception {
X500Name subject;
String name = "";
subject = new X500Name(name);
System.out.println("subject:" + subject.toString());
System.out.println("getCN:" + subject.getCommonName());
System.out.println("getC:" + subject.getCountry());
System.out.println("getL:" + subject.getLocality());
System.out.println("getST:" + subject.getState());
System.out.println("getName:" + subject.getName());
System.out.println("getO:" + subject.getOrganization());
System.out.println("getOU:" + subject.getOrganizationalUnit());
System.out.println("getType:" + subject.getType());
// encode, getEncoded()
DerOutputStream dos = new DerOutputStream();
subject.encode(dos);
byte[] out = dos.toByteArray();
byte[] enc = subject.getEncoded();
HexDumpEncoder e = new HexDumpEncoder();
if (Arrays.equals(out, enc))
System.out.println("Sucess: out:" + e.encodeBuffer(out));
else {
System.out.println("Failed: encode:" + e.encodeBuffer(out));
System.out.println("getEncoded:" + e.encodeBuffer(enc));
}
X500Name x = new X500Name(enc);
if (x.equals(subject))
System.out.println("Sucess: X500Name(byte[]):" + x.toString());
else
System.out.println("Failed: X500Name(byte[]):" + x.toString());
}
use of sun.misc.HexDumpEncoder in project j2objc by google.
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 j2objc by google.
the class UnparseableExtension method parseExtension.
// Parse the encoded extension
private void parseExtension(Extension ext) throws IOException {
try {
Class extClass = OIDMap.getClass(ext.getExtensionId());
if (extClass == null) {
// Unsupported extension
if (ext.isCritical()) {
unsupportedCritExt = true;
}
if (map.put(ext.getExtensionId().toString(), ext) == null) {
return;
} else {
throw new IOException("Duplicate extensions not allowed");
}
}
Constructor cons = ((Class<?>) extClass).getConstructor(PARAMS);
Object[] passed = new Object[] { Boolean.valueOf(ext.isCritical()), ext.getExtensionValue() };
CertAttrSet certExt = (CertAttrSet) cons.newInstance(passed);
if (map.put(certExt.getName(), (Extension) certExt) != null) {
throw new IOException("Duplicate extensions not allowed");
}
} catch (InvocationTargetException invk) {
Throwable e = invk.getTargetException();
if (ext.isCritical() == false) {
// ignore errors parsing non-critical extensions
if (unparseableExtensions == null) {
unparseableExtensions = new TreeMap<String, Extension>();
}
unparseableExtensions.put(ext.getExtensionId().toString(), new UnparseableExtension(ext, e));
if (debug != null) {
debug.println("Error parsing extension: " + ext);
e.printStackTrace();
HexDumpEncoder h = new HexDumpEncoder();
System.err.println(h.encodeBuffer(ext.getExtensionValue()));
}
return;
}
if (e instanceof IOException) {
throw (IOException) e;
} else {
throw (IOException) new IOException(e.toString()).initCause(e);
}
} catch (IOException e) {
throw e;
} catch (Exception e) {
throw (IOException) new IOException(e.toString()).initCause(e);
}
}
Aggregations