Java Code Examples for java.security.CodeSigner#equals()

The following examples show how to use java.security.CodeSigner#equals() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Serialize.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
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");
        }
    }
 
Example 2
Source File: Serialize.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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");
        }
    }
 
Example 3
Source File: Serialize.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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");
        }
    }
 
Example 4
Source File: Serialize.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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");
        }
    }
 
Example 5
Source File: Serialize.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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");
        }
    }
 
Example 6
Source File: Serialize.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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");
        }
    }
 
Example 7
Source File: Serialize.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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");
        }
    }
 
Example 8
Source File: Serialize.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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");
        }
    }
 
Example 9
Source File: Serialize.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
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");
        }
    }
 
Example 10
Source File: Serialize.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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");
        }
    }
 
Example 11
Source File: Serialize.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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");
        }
    }
 
Example 12
Source File: Serialize.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
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");
        }
    }
 
Example 13
Source File: Serialize.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
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");
        }
    }