// Create a certpath consisting of one certificate
File f = new File(System.getProperty("test.src", "."), "cert_file");
FileInputStream fis = new FileInputStream(f);
CertificateFactory cf = CertificateFactory.getInstance("X.509");
Certificate c = cf.generateCertificate(fis);
fis.close();
CertPath cp = cf.generateCertPath(Collections.singletonList(c));
// Create a code signer
CodeSigner cs = new CodeSigner(cp, new Timestamp(new Date(), cp));
// Serialize the code signer
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(byteOut);
out.writeObject(cs);
out.close();
// Deserialize the code signer byte[] data = byteOut.toByteArray();
CodeSigner cs2 = (CodeSigner) new ObjectInputStream( new ByteArrayInputStream(data)).readObject();
// Test for equality if (!cs.equals(cs2) || cs.hashCode() != cs2.hashCode()) { thrownew Exception("CodeSigner serialization test FAILED");
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.