本文整理匯總了Java中java.security.CodeSigner.equals方法的典型用法代碼示例。如果您正苦於以下問題:Java CodeSigner.equals方法的具體用法?Java CodeSigner.equals怎麽用?Java CodeSigner.equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.security.CodeSigner
的用法示例。
在下文中一共展示了CodeSigner.equals方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import java.security.CodeSigner; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
// 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()) {
throw new Exception("CodeSigner serialization test FAILED");
}
}