Java Code Examples for java.security.UnresolvedPermission#getUnresolvedCerts()

The following examples show how to use java.security.UnresolvedPermission#getUnresolvedCerts() . 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: AccessorMethods.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        // set CA cert in chain
        File f = new File(System.getProperty("test.src", "."), CA);
        FileInputStream fis = new FileInputStream(f);
        CertificateFactory fac = CertificateFactory.getInstance("X.509");
        Certificate cacert = fac.generateCertificate(fis);
        Certificate[] signercerts = new Certificate[4];
        signercerts[1] = cacert;
        signercerts[3] = cacert;

        // set signer certs
        f = new File(System.getProperty("test.src", "."), SIGNER1);
        fis = new FileInputStream(f);
        Certificate signer1 = fac.generateCertificate(fis);
        signercerts[0] = signer1;

        f = new File(System.getProperty("test.src", "."), SIGNER2);
        fis = new FileInputStream(f);
        Certificate signer2 = fac.generateCertificate(fis);
        signercerts[2] = signer2;

        UnresolvedPermission up = new UnresolvedPermission
                        ("type", "name", "actions", signercerts);
        if (!up.getUnresolvedType().equals("type") ||
            !up.getUnresolvedName().equals("name") ||
            !up.getUnresolvedActions().equals("actions")) {
            throw new SecurityException("Test 1 Failed");
        }

        Certificate[] certs = up.getUnresolvedCerts();
        if (certs == null || certs.length != 2) {
            throw new SecurityException("Test 2 Failed");
        }

        boolean foundSigner1 = false;
        boolean foundSigner2 = false;
        if (certs[0].equals(signer1) || certs[1].equals(signer1)) {
            foundSigner1 = true;
        }
        if (certs[0].equals(signer2) || certs[1].equals(signer2)) {
            foundSigner2 = true;
        }
        if (!foundSigner1 || !foundSigner2) {
            throw new SecurityException("Test 3 Failed");
        }
    }
 
Example 2
Source File: AccessorMethods.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        // set CA cert in chain
        File f = new File(System.getProperty("test.src", "."), CA);
        FileInputStream fis = new FileInputStream(f);
        CertificateFactory fac = CertificateFactory.getInstance("X.509");
        Certificate cacert = fac.generateCertificate(fis);
        Certificate[] signercerts = new Certificate[4];
        signercerts[1] = cacert;
        signercerts[3] = cacert;

        // set signer certs
        f = new File(System.getProperty("test.src", "."), SIGNER1);
        fis = new FileInputStream(f);
        Certificate signer1 = fac.generateCertificate(fis);
        signercerts[0] = signer1;

        f = new File(System.getProperty("test.src", "."), SIGNER2);
        fis = new FileInputStream(f);
        Certificate signer2 = fac.generateCertificate(fis);
        signercerts[2] = signer2;

        UnresolvedPermission up = new UnresolvedPermission
                        ("type", "name", "actions", signercerts);
        if (!up.getUnresolvedType().equals("type") ||
            !up.getUnresolvedName().equals("name") ||
            !up.getUnresolvedActions().equals("actions")) {
            throw new SecurityException("Test 1 Failed");
        }

        Certificate[] certs = up.getUnresolvedCerts();
        if (certs == null || certs.length != 2) {
            throw new SecurityException("Test 2 Failed");
        }

        boolean foundSigner1 = false;
        boolean foundSigner2 = false;
        if (certs[0].equals(signer1) || certs[1].equals(signer1)) {
            foundSigner1 = true;
        }
        if (certs[0].equals(signer2) || certs[1].equals(signer2)) {
            foundSigner2 = true;
        }
        if (!foundSigner1 || !foundSigner2) {
            throw new SecurityException("Test 3 Failed");
        }
    }
 
Example 3
Source File: AccessorMethods.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        // set CA cert in chain
        File f = new File(System.getProperty("test.src", "."), CA);
        FileInputStream fis = new FileInputStream(f);
        CertificateFactory fac = CertificateFactory.getInstance("X.509");
        Certificate cacert = fac.generateCertificate(fis);
        Certificate[] signercerts = new Certificate[4];
        signercerts[1] = cacert;
        signercerts[3] = cacert;

        // set signer certs
        f = new File(System.getProperty("test.src", "."), SIGNER1);
        fis = new FileInputStream(f);
        Certificate signer1 = fac.generateCertificate(fis);
        signercerts[0] = signer1;

        f = new File(System.getProperty("test.src", "."), SIGNER2);
        fis = new FileInputStream(f);
        Certificate signer2 = fac.generateCertificate(fis);
        signercerts[2] = signer2;

        UnresolvedPermission up = new UnresolvedPermission
                        ("type", "name", "actions", signercerts);
        if (!up.getUnresolvedType().equals("type") ||
            !up.getUnresolvedName().equals("name") ||
            !up.getUnresolvedActions().equals("actions")) {
            throw new SecurityException("Test 1 Failed");
        }

        Certificate[] certs = up.getUnresolvedCerts();
        if (certs == null || certs.length != 2) {
            throw new SecurityException("Test 2 Failed");
        }

        boolean foundSigner1 = false;
        boolean foundSigner2 = false;
        if (certs[0].equals(signer1) || certs[1].equals(signer1)) {
            foundSigner1 = true;
        }
        if (certs[0].equals(signer2) || certs[1].equals(signer2)) {
            foundSigner2 = true;
        }
        if (!foundSigner1 || !foundSigner2) {
            throw new SecurityException("Test 3 Failed");
        }
    }
 
Example 4
Source File: AccessorMethods.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        // set CA cert in chain
        File f = new File(System.getProperty("test.src", "."), CA);
        FileInputStream fis = new FileInputStream(f);
        CertificateFactory fac = CertificateFactory.getInstance("X.509");
        Certificate cacert = fac.generateCertificate(fis);
        Certificate[] signercerts = new Certificate[4];
        signercerts[1] = cacert;
        signercerts[3] = cacert;

        // set signer certs
        f = new File(System.getProperty("test.src", "."), SIGNER1);
        fis = new FileInputStream(f);
        Certificate signer1 = fac.generateCertificate(fis);
        signercerts[0] = signer1;

        f = new File(System.getProperty("test.src", "."), SIGNER2);
        fis = new FileInputStream(f);
        Certificate signer2 = fac.generateCertificate(fis);
        signercerts[2] = signer2;

        UnresolvedPermission up = new UnresolvedPermission
                        ("type", "name", "actions", signercerts);
        if (!up.getUnresolvedType().equals("type") ||
            !up.getUnresolvedName().equals("name") ||
            !up.getUnresolvedActions().equals("actions")) {
            throw new SecurityException("Test 1 Failed");
        }

        Certificate[] certs = up.getUnresolvedCerts();
        if (certs == null || certs.length != 2) {
            throw new SecurityException("Test 2 Failed");
        }

        boolean foundSigner1 = false;
        boolean foundSigner2 = false;
        if (certs[0].equals(signer1) || certs[1].equals(signer1)) {
            foundSigner1 = true;
        }
        if (certs[0].equals(signer2) || certs[1].equals(signer2)) {
            foundSigner2 = true;
        }
        if (!foundSigner1 || !foundSigner2) {
            throw new SecurityException("Test 3 Failed");
        }
    }
 
Example 5
Source File: AccessorMethods.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        // set CA cert in chain
        File f = new File(System.getProperty("test.src", "."), CA);
        FileInputStream fis = new FileInputStream(f);
        CertificateFactory fac = CertificateFactory.getInstance("X.509");
        Certificate cacert = fac.generateCertificate(fis);
        Certificate[] signercerts = new Certificate[4];
        signercerts[1] = cacert;
        signercerts[3] = cacert;

        // set signer certs
        f = new File(System.getProperty("test.src", "."), SIGNER1);
        fis = new FileInputStream(f);
        Certificate signer1 = fac.generateCertificate(fis);
        signercerts[0] = signer1;

        f = new File(System.getProperty("test.src", "."), SIGNER2);
        fis = new FileInputStream(f);
        Certificate signer2 = fac.generateCertificate(fis);
        signercerts[2] = signer2;

        UnresolvedPermission up = new UnresolvedPermission
                        ("type", "name", "actions", signercerts);
        if (!up.getUnresolvedType().equals("type") ||
            !up.getUnresolvedName().equals("name") ||
            !up.getUnresolvedActions().equals("actions")) {
            throw new SecurityException("Test 1 Failed");
        }

        Certificate[] certs = up.getUnresolvedCerts();
        if (certs == null || certs.length != 2) {
            throw new SecurityException("Test 2 Failed");
        }

        boolean foundSigner1 = false;
        boolean foundSigner2 = false;
        if (certs[0].equals(signer1) || certs[1].equals(signer1)) {
            foundSigner1 = true;
        }
        if (certs[0].equals(signer2) || certs[1].equals(signer2)) {
            foundSigner2 = true;
        }
        if (!foundSigner1 || !foundSigner2) {
            throw new SecurityException("Test 3 Failed");
        }
    }
 
Example 6
Source File: AccessorMethods.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        // set CA cert in chain
        File f = new File(System.getProperty("test.src", "."), CA);
        FileInputStream fis = new FileInputStream(f);
        CertificateFactory fac = CertificateFactory.getInstance("X.509");
        Certificate cacert = fac.generateCertificate(fis);
        Certificate[] signercerts = new Certificate[4];
        signercerts[1] = cacert;
        signercerts[3] = cacert;

        // set signer certs
        f = new File(System.getProperty("test.src", "."), SIGNER1);
        fis = new FileInputStream(f);
        Certificate signer1 = fac.generateCertificate(fis);
        signercerts[0] = signer1;

        f = new File(System.getProperty("test.src", "."), SIGNER2);
        fis = new FileInputStream(f);
        Certificate signer2 = fac.generateCertificate(fis);
        signercerts[2] = signer2;

        UnresolvedPermission up = new UnresolvedPermission
                        ("type", "name", "actions", signercerts);
        if (!up.getUnresolvedType().equals("type") ||
            !up.getUnresolvedName().equals("name") ||
            !up.getUnresolvedActions().equals("actions")) {
            throw new SecurityException("Test 1 Failed");
        }

        Certificate[] certs = up.getUnresolvedCerts();
        if (certs == null || certs.length != 2) {
            throw new SecurityException("Test 2 Failed");
        }

        boolean foundSigner1 = false;
        boolean foundSigner2 = false;
        if (certs[0].equals(signer1) || certs[1].equals(signer1)) {
            foundSigner1 = true;
        }
        if (certs[0].equals(signer2) || certs[1].equals(signer2)) {
            foundSigner2 = true;
        }
        if (!foundSigner1 || !foundSigner2) {
            throw new SecurityException("Test 3 Failed");
        }
    }
 
Example 7
Source File: AccessorMethods.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        // set CA cert in chain
        File f = new File(System.getProperty("test.src", "."), CA);
        FileInputStream fis = new FileInputStream(f);
        CertificateFactory fac = CertificateFactory.getInstance("X.509");
        Certificate cacert = fac.generateCertificate(fis);
        Certificate[] signercerts = new Certificate[4];
        signercerts[1] = cacert;
        signercerts[3] = cacert;

        // set signer certs
        f = new File(System.getProperty("test.src", "."), SIGNER1);
        fis = new FileInputStream(f);
        Certificate signer1 = fac.generateCertificate(fis);
        signercerts[0] = signer1;

        f = new File(System.getProperty("test.src", "."), SIGNER2);
        fis = new FileInputStream(f);
        Certificate signer2 = fac.generateCertificate(fis);
        signercerts[2] = signer2;

        UnresolvedPermission up = new UnresolvedPermission
                        ("type", "name", "actions", signercerts);
        if (!up.getUnresolvedType().equals("type") ||
            !up.getUnresolvedName().equals("name") ||
            !up.getUnresolvedActions().equals("actions")) {
            throw new SecurityException("Test 1 Failed");
        }

        Certificate[] certs = up.getUnresolvedCerts();
        if (certs == null || certs.length != 2) {
            throw new SecurityException("Test 2 Failed");
        }

        boolean foundSigner1 = false;
        boolean foundSigner2 = false;
        if (certs[0].equals(signer1) || certs[1].equals(signer1)) {
            foundSigner1 = true;
        }
        if (certs[0].equals(signer2) || certs[1].equals(signer2)) {
            foundSigner2 = true;
        }
        if (!foundSigner1 || !foundSigner2) {
            throw new SecurityException("Test 3 Failed");
        }
    }
 
Example 8
Source File: AccessorMethods.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        // set CA cert in chain
        File f = new File(System.getProperty("test.src", "."), CA);
        FileInputStream fis = new FileInputStream(f);
        CertificateFactory fac = CertificateFactory.getInstance("X.509");
        Certificate cacert = fac.generateCertificate(fis);
        Certificate[] signercerts = new Certificate[4];
        signercerts[1] = cacert;
        signercerts[3] = cacert;

        // set signer certs
        f = new File(System.getProperty("test.src", "."), SIGNER1);
        fis = new FileInputStream(f);
        Certificate signer1 = fac.generateCertificate(fis);
        signercerts[0] = signer1;

        f = new File(System.getProperty("test.src", "."), SIGNER2);
        fis = new FileInputStream(f);
        Certificate signer2 = fac.generateCertificate(fis);
        signercerts[2] = signer2;

        UnresolvedPermission up = new UnresolvedPermission
                        ("type", "name", "actions", signercerts);
        if (!up.getUnresolvedType().equals("type") ||
            !up.getUnresolvedName().equals("name") ||
            !up.getUnresolvedActions().equals("actions")) {
            throw new SecurityException("Test 1 Failed");
        }

        Certificate[] certs = up.getUnresolvedCerts();
        if (certs == null || certs.length != 2) {
            throw new SecurityException("Test 2 Failed");
        }

        boolean foundSigner1 = false;
        boolean foundSigner2 = false;
        if (certs[0].equals(signer1) || certs[1].equals(signer1)) {
            foundSigner1 = true;
        }
        if (certs[0].equals(signer2) || certs[1].equals(signer2)) {
            foundSigner2 = true;
        }
        if (!foundSigner1 || !foundSigner2) {
            throw new SecurityException("Test 3 Failed");
        }
    }
 
Example 9
Source File: AccessorMethods.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        // set CA cert in chain
        File f = new File(System.getProperty("test.src", "."), CA);
        FileInputStream fis = new FileInputStream(f);
        CertificateFactory fac = CertificateFactory.getInstance("X.509");
        Certificate cacert = fac.generateCertificate(fis);
        Certificate[] signercerts = new Certificate[4];
        signercerts[1] = cacert;
        signercerts[3] = cacert;

        // set signer certs
        f = new File(System.getProperty("test.src", "."), SIGNER1);
        fis = new FileInputStream(f);
        Certificate signer1 = fac.generateCertificate(fis);
        signercerts[0] = signer1;

        f = new File(System.getProperty("test.src", "."), SIGNER2);
        fis = new FileInputStream(f);
        Certificate signer2 = fac.generateCertificate(fis);
        signercerts[2] = signer2;

        UnresolvedPermission up = new UnresolvedPermission
                        ("type", "name", "actions", signercerts);
        if (!up.getUnresolvedType().equals("type") ||
            !up.getUnresolvedName().equals("name") ||
            !up.getUnresolvedActions().equals("actions")) {
            throw new SecurityException("Test 1 Failed");
        }

        Certificate[] certs = up.getUnresolvedCerts();
        if (certs == null || certs.length != 2) {
            throw new SecurityException("Test 2 Failed");
        }

        boolean foundSigner1 = false;
        boolean foundSigner2 = false;
        if (certs[0].equals(signer1) || certs[1].equals(signer1)) {
            foundSigner1 = true;
        }
        if (certs[0].equals(signer2) || certs[1].equals(signer2)) {
            foundSigner2 = true;
        }
        if (!foundSigner1 || !foundSigner2) {
            throw new SecurityException("Test 3 Failed");
        }
    }
 
Example 10
Source File: AccessorMethods.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        // set CA cert in chain
        File f = new File(System.getProperty("test.src", "."), CA);
        FileInputStream fis = new FileInputStream(f);
        CertificateFactory fac = CertificateFactory.getInstance("X.509");
        Certificate cacert = fac.generateCertificate(fis);
        Certificate[] signercerts = new Certificate[4];
        signercerts[1] = cacert;
        signercerts[3] = cacert;

        // set signer certs
        f = new File(System.getProperty("test.src", "."), SIGNER1);
        fis = new FileInputStream(f);
        Certificate signer1 = fac.generateCertificate(fis);
        signercerts[0] = signer1;

        f = new File(System.getProperty("test.src", "."), SIGNER2);
        fis = new FileInputStream(f);
        Certificate signer2 = fac.generateCertificate(fis);
        signercerts[2] = signer2;

        UnresolvedPermission up = new UnresolvedPermission
                        ("type", "name", "actions", signercerts);
        if (!up.getUnresolvedType().equals("type") ||
            !up.getUnresolvedName().equals("name") ||
            !up.getUnresolvedActions().equals("actions")) {
            throw new SecurityException("Test 1 Failed");
        }

        Certificate[] certs = up.getUnresolvedCerts();
        if (certs == null || certs.length != 2) {
            throw new SecurityException("Test 2 Failed");
        }

        boolean foundSigner1 = false;
        boolean foundSigner2 = false;
        if (certs[0].equals(signer1) || certs[1].equals(signer1)) {
            foundSigner1 = true;
        }
        if (certs[0].equals(signer2) || certs[1].equals(signer2)) {
            foundSigner2 = true;
        }
        if (!foundSigner1 || !foundSigner2) {
            throw new SecurityException("Test 3 Failed");
        }
    }
 
Example 11
Source File: AccessorMethods.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        // set CA cert in chain
        File f = new File(System.getProperty("test.src", "."), CA);
        FileInputStream fis = new FileInputStream(f);
        CertificateFactory fac = CertificateFactory.getInstance("X.509");
        Certificate cacert = fac.generateCertificate(fis);
        Certificate[] signercerts = new Certificate[4];
        signercerts[1] = cacert;
        signercerts[3] = cacert;

        // set signer certs
        f = new File(System.getProperty("test.src", "."), SIGNER1);
        fis = new FileInputStream(f);
        Certificate signer1 = fac.generateCertificate(fis);
        signercerts[0] = signer1;

        f = new File(System.getProperty("test.src", "."), SIGNER2);
        fis = new FileInputStream(f);
        Certificate signer2 = fac.generateCertificate(fis);
        signercerts[2] = signer2;

        UnresolvedPermission up = new UnresolvedPermission
                        ("type", "name", "actions", signercerts);
        if (!up.getUnresolvedType().equals("type") ||
            !up.getUnresolvedName().equals("name") ||
            !up.getUnresolvedActions().equals("actions")) {
            throw new SecurityException("Test 1 Failed");
        }

        Certificate[] certs = up.getUnresolvedCerts();
        if (certs == null || certs.length != 2) {
            throw new SecurityException("Test 2 Failed");
        }

        boolean foundSigner1 = false;
        boolean foundSigner2 = false;
        if (certs[0].equals(signer1) || certs[1].equals(signer1)) {
            foundSigner1 = true;
        }
        if (certs[0].equals(signer2) || certs[1].equals(signer2)) {
            foundSigner2 = true;
        }
        if (!foundSigner1 || !foundSigner2) {
            throw new SecurityException("Test 3 Failed");
        }
    }
 
Example 12
Source File: AccessorMethods.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        // set CA cert in chain
        File f = new File(System.getProperty("test.src", "."), CA);
        FileInputStream fis = new FileInputStream(f);
        CertificateFactory fac = CertificateFactory.getInstance("X.509");
        Certificate cacert = fac.generateCertificate(fis);
        Certificate[] signercerts = new Certificate[4];
        signercerts[1] = cacert;
        signercerts[3] = cacert;

        // set signer certs
        f = new File(System.getProperty("test.src", "."), SIGNER1);
        fis = new FileInputStream(f);
        Certificate signer1 = fac.generateCertificate(fis);
        signercerts[0] = signer1;

        f = new File(System.getProperty("test.src", "."), SIGNER2);
        fis = new FileInputStream(f);
        Certificate signer2 = fac.generateCertificate(fis);
        signercerts[2] = signer2;

        UnresolvedPermission up = new UnresolvedPermission
                        ("type", "name", "actions", signercerts);
        if (!up.getUnresolvedType().equals("type") ||
            !up.getUnresolvedName().equals("name") ||
            !up.getUnresolvedActions().equals("actions")) {
            throw new SecurityException("Test 1 Failed");
        }

        Certificate[] certs = up.getUnresolvedCerts();
        if (certs == null || certs.length != 2) {
            throw new SecurityException("Test 2 Failed");
        }

        boolean foundSigner1 = false;
        boolean foundSigner2 = false;
        if (certs[0].equals(signer1) || certs[1].equals(signer1)) {
            foundSigner1 = true;
        }
        if (certs[0].equals(signer2) || certs[1].equals(signer2)) {
            foundSigner2 = true;
        }
        if (!foundSigner1 || !foundSigner2) {
            throw new SecurityException("Test 3 Failed");
        }
    }
 
Example 13
Source File: AccessorMethods.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {

        // set CA cert in chain
        File f = new File(System.getProperty("test.src", "."), CA);
        FileInputStream fis = new FileInputStream(f);
        CertificateFactory fac = CertificateFactory.getInstance("X.509");
        Certificate cacert = fac.generateCertificate(fis);
        Certificate[] signercerts = new Certificate[4];
        signercerts[1] = cacert;
        signercerts[3] = cacert;

        // set signer certs
        f = new File(System.getProperty("test.src", "."), SIGNER1);
        fis = new FileInputStream(f);
        Certificate signer1 = fac.generateCertificate(fis);
        signercerts[0] = signer1;

        f = new File(System.getProperty("test.src", "."), SIGNER2);
        fis = new FileInputStream(f);
        Certificate signer2 = fac.generateCertificate(fis);
        signercerts[2] = signer2;

        UnresolvedPermission up = new UnresolvedPermission
                        ("type", "name", "actions", signercerts);
        if (!up.getUnresolvedType().equals("type") ||
            !up.getUnresolvedName().equals("name") ||
            !up.getUnresolvedActions().equals("actions")) {
            throw new SecurityException("Test 1 Failed");
        }

        Certificate[] certs = up.getUnresolvedCerts();
        if (certs == null || certs.length != 2) {
            throw new SecurityException("Test 2 Failed");
        }

        boolean foundSigner1 = false;
        boolean foundSigner2 = false;
        if (certs[0].equals(signer1) || certs[1].equals(signer1)) {
            foundSigner1 = true;
        }
        if (certs[0].equals(signer2) || certs[1].equals(signer2)) {
            foundSigner2 = true;
        }
        if (!foundSigner1 || !foundSigner2) {
            throw new SecurityException("Test 3 Failed");
        }
    }