javax.security.auth.SubjectDomainCombiner Java Examples

The following examples show how to use javax.security.auth.SubjectDomainCombiner. 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: Optimize.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {

        ProtectionDomain pd1 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);
        ProtectionDomain pd2 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);
        ProtectionDomain pd3 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);

        ProtectionDomain[] current = new ProtectionDomain[] {pd1, pd2};
        ProtectionDomain[] assigned = new ProtectionDomain[] {pd3, pd2};

        SubjectDomainCombiner sdc = new SubjectDomainCombiner(new Subject());
        ProtectionDomain[] combined = sdc.combine(current, assigned);

        // this depends on current SubjectDomainCombiner implementation
        // (ordering of returned domains)
        if (combined.length == 4 &&
            combined[0] != pd1 && combined[1] != pd2 &&
            combined[2] == pd3 && combined[3] == pd2) {
            System.out.println("test passed");
        } else {
            System.out.println("test failed");
            throw new SecurityException("Test Failed");
        }
    }
 
Example #2
Source File: Optimize.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {

        ProtectionDomain pd1 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);
        ProtectionDomain pd2 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);
        ProtectionDomain pd3 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);

        ProtectionDomain[] current = new ProtectionDomain[] {pd1, pd2};
        ProtectionDomain[] assigned = new ProtectionDomain[] {pd3, pd2};

        SubjectDomainCombiner sdc = new SubjectDomainCombiner(new Subject());
        ProtectionDomain[] combined = sdc.combine(current, assigned);

        // this depends on current SubjectDomainCombiner implementation
        // (ordering of returned domains)
        if (combined.length == 4 &&
            combined[0] != pd1 && combined[1] != pd2 &&
            combined[2] == pd3 && combined[3] == pd2) {
            System.out.println("test passed");
        } else {
            System.out.println("test failed");
            throw new SecurityException("Test Failed");
        }
    }
 
Example #3
Source File: Optimize.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {

        ProtectionDomain pd1 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions());
        ProtectionDomain pd2 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions());
        ProtectionDomain pd3 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions());

        ProtectionDomain[] current = new ProtectionDomain[] {pd1, pd2};
        ProtectionDomain[] assigned = new ProtectionDomain[] {pd3, pd2};

        SubjectDomainCombiner sdc = new SubjectDomainCombiner(new Subject());
        ProtectionDomain[] combined = sdc.combine(current, assigned);

        // this depends on current SubjectDomainCombiner implementation
        // (ordering of returned domains)
        if (combined.length == 4 &&
            combined[0] != pd1 && combined[1] != pd2 &&
            combined[2] == pd3 && combined[3] == pd2) {
            System.out.println("test passed");
        } else {
            System.out.println("test failed");
            throw new SecurityException("Test Failed");
        }
    }
 
Example #4
Source File: Optimize.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {

        ProtectionDomain pd1 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);
        ProtectionDomain pd2 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);
        ProtectionDomain pd3 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);

        ProtectionDomain[] current = new ProtectionDomain[] {pd1, pd2};
        ProtectionDomain[] assigned = new ProtectionDomain[] {pd3, pd2};

        SubjectDomainCombiner sdc = new SubjectDomainCombiner(new Subject());
        ProtectionDomain[] combined = sdc.combine(current, assigned);

        // this depends on current SubjectDomainCombiner implementation
        // (ordering of returned domains)
        if (combined.length == 4 &&
            combined[0] != pd1 && combined[1] != pd2 &&
            combined[2] == pd3 && combined[3] == pd2) {
            System.out.println("test passed");
        } else {
            System.out.println("test failed");
            throw new SecurityException("Test Failed");
        }
    }
 
Example #5
Source File: Optimize.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {

        ProtectionDomain pd1 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);
        ProtectionDomain pd2 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);
        ProtectionDomain pd3 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);

        ProtectionDomain[] current = new ProtectionDomain[] {pd1, pd2};
        ProtectionDomain[] assigned = new ProtectionDomain[] {pd3, pd2};

        SubjectDomainCombiner sdc = new SubjectDomainCombiner(new Subject());
        ProtectionDomain[] combined = sdc.combine(current, assigned);

        // this depends on current SubjectDomainCombiner implementation
        // (ordering of returned domains)
        if (combined.length == 4 &&
            combined[0] != pd1 && combined[1] != pd2 &&
            combined[2] == pd3 && combined[3] == pd2) {
            System.out.println("test passed");
        } else {
            System.out.println("test failed");
            throw new SecurityException("Test Failed");
        }
    }
 
Example #6
Source File: Optimize.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {

        ProtectionDomain pd1 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);
        ProtectionDomain pd2 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);
        ProtectionDomain pd3 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);

        ProtectionDomain[] current = new ProtectionDomain[] {pd1, pd2};
        ProtectionDomain[] assigned = new ProtectionDomain[] {pd3, pd2};

        SubjectDomainCombiner sdc = new SubjectDomainCombiner(new Subject());
        ProtectionDomain[] combined = sdc.combine(current, assigned);

        // this depends on current SubjectDomainCombiner implementation
        // (ordering of returned domains)
        if (combined.length == 4 &&
            combined[0] != pd1 && combined[1] != pd2 &&
            combined[2] == pd3 && combined[3] == pd2) {
            System.out.println("test passed");
        } else {
            System.out.println("test failed");
            throw new SecurityException("Test Failed");
        }
    }
 
Example #7
Source File: Optimize.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {

        ProtectionDomain pd1 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);
        ProtectionDomain pd2 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);
        ProtectionDomain pd3 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);

        ProtectionDomain[] current = new ProtectionDomain[] {pd1, pd2};
        ProtectionDomain[] assigned = new ProtectionDomain[] {pd3, pd2};

        SubjectDomainCombiner sdc = new SubjectDomainCombiner(new Subject());
        ProtectionDomain[] combined = sdc.combine(current, assigned);

        // this depends on current SubjectDomainCombiner implementation
        // (ordering of returned domains)
        if (combined.length == 4 &&
            combined[0] != pd1 && combined[1] != pd2 &&
            combined[2] == pd3 && combined[3] == pd2) {
            System.out.println("test passed");
        } else {
            System.out.println("test failed");
            throw new SecurityException("Test Failed");
        }
    }
 
Example #8
Source File: AbstractConfiguredObject.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
protected final AccessControlContext getSystemTaskControllerContext(String taskName, Principal principal)
{
    final Subject subject = getSystemTaskSubject(taskName, principal);
    return AccessController.doPrivileged
            (new PrivilegedAction<AccessControlContext>()
            {
                @Override
                public AccessControlContext run()
                {
                    return new AccessControlContext
                            (AccessController.getContext(),
                             new SubjectDomainCombiner(subject));
                }
            }, null);
}
 
Example #9
Source File: AbstractAMQPConnection.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
@Override
public final AccessControlContext getAccessControlContextFromSubject(final Subject subject)
{
    final AccessControlContext acc = AccessController.getContext();
    return AccessController.doPrivileged(
            (PrivilegedAction<AccessControlContext>) () -> {
                if (subject == null)
                    return new AccessControlContext(acc, null);
                else
                    return new AccessControlContext
                            (acc,
                             new SubjectDomainCombiner(subject));
            });
}
 
Example #10
Source File: Optimize.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {

        ProtectionDomain pd1 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);
        ProtectionDomain pd2 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);
        ProtectionDomain pd3 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);

        ProtectionDomain[] current = new ProtectionDomain[] {pd1, pd2};
        ProtectionDomain[] assigned = new ProtectionDomain[] {pd3, pd2};

        SubjectDomainCombiner sdc = new SubjectDomainCombiner(new Subject());
        ProtectionDomain[] combined = sdc.combine(current, assigned);

        // this depends on current SubjectDomainCombiner implementation
        // (ordering of returned domains)
        if (combined.length == 4 &&
            combined[0] != pd1 && combined[1] != pd2 &&
            combined[2] == pd3 && combined[3] == pd2) {
            System.out.println("test passed");
        } else {
            System.out.println("test failed");
            throw new SecurityException("Test Failed");
        }
    }
 
Example #11
Source File: Optimize.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {

        ProtectionDomain pd1 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions());
        ProtectionDomain pd2 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions());
        ProtectionDomain pd3 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions());

        ProtectionDomain[] current = new ProtectionDomain[] {pd1, pd2};
        ProtectionDomain[] assigned = new ProtectionDomain[] {pd3, pd2};

        SubjectDomainCombiner sdc = new SubjectDomainCombiner(new Subject());
        ProtectionDomain[] combined = sdc.combine(current, assigned);

        // this depends on current SubjectDomainCombiner implementation
        // (ordering of returned domains)
        if (combined.length == 4 &&
            combined[0] != pd1 && combined[1] != pd2 &&
            combined[2] == pd3 && combined[3] == pd2) {
            System.out.println("test passed");
        } else {
            System.out.println("test failed");
            throw new SecurityException("Test Failed");
        }
    }
 
Example #12
Source File: Optimize.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {

        ProtectionDomain pd1 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions());
        ProtectionDomain pd2 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions());
        ProtectionDomain pd3 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions());

        ProtectionDomain[] current = new ProtectionDomain[] {pd1, pd2};
        ProtectionDomain[] assigned = new ProtectionDomain[] {pd3, pd2};

        SubjectDomainCombiner sdc = new SubjectDomainCombiner(new Subject());
        ProtectionDomain[] combined = sdc.combine(current, assigned);

        // this depends on current SubjectDomainCombiner implementation
        // (ordering of returned domains)
        if (combined.length == 4 &&
            combined[0] != pd1 && combined[1] != pd2 &&
            combined[2] == pd3 && combined[3] == pd2) {
            System.out.println("test passed");
        } else {
            System.out.println("test failed");
            throw new SecurityException("Test Failed");
        }
    }
 
Example #13
Source File: Optimize.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {

        ProtectionDomain pd1 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);
        ProtectionDomain pd2 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);
        ProtectionDomain pd3 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions(),
            null, null);

        ProtectionDomain[] current = new ProtectionDomain[] {pd1, pd2};
        ProtectionDomain[] assigned = new ProtectionDomain[] {pd3, pd2};

        SubjectDomainCombiner sdc = new SubjectDomainCombiner(new Subject());
        ProtectionDomain[] combined = sdc.combine(current, assigned);

        // this depends on current SubjectDomainCombiner implementation
        // (ordering of returned domains)
        if (combined.length == 4 &&
            combined[0] != pd1 && combined[1] != pd2 &&
            combined[2] == pd3 && combined[3] == pd2) {
            System.out.println("test passed");
        } else {
            System.out.println("test failed");
            throw new SecurityException("Test Failed");
        }
    }
 
Example #14
Source File: Optimize.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {

        ProtectionDomain pd1 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions());
        ProtectionDomain pd2 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions());
        ProtectionDomain pd3 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions());

        ProtectionDomain[] current = new ProtectionDomain[] {pd1, pd2};
        ProtectionDomain[] assigned = new ProtectionDomain[] {pd3, pd2};

        SubjectDomainCombiner sdc = new SubjectDomainCombiner(new Subject());
        ProtectionDomain[] combined = sdc.combine(current, assigned);

        // this depends on current SubjectDomainCombiner implementation
        // (ordering of returned domains)
        if (combined.length == 4 &&
            combined[0] != pd1 && combined[1] != pd2 &&
            combined[2] == pd3 && combined[3] == pd2) {
            System.out.println("test passed");
        } else {
            System.out.println("test failed");
            throw new SecurityException("Test Failed");
        }
    }
 
Example #15
Source File: Optimize.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {

        ProtectionDomain pd1 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions());
        ProtectionDomain pd2 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions());
        ProtectionDomain pd3 = new ProtectionDomain(
            new CodeSource(null, (java.security.cert.Certificate[]) null),
            new Permissions());

        ProtectionDomain[] current = new ProtectionDomain[] {pd1, pd2};
        ProtectionDomain[] assigned = new ProtectionDomain[] {pd3, pd2};

        SubjectDomainCombiner sdc = new SubjectDomainCombiner(new Subject());
        ProtectionDomain[] combined = sdc.combine(current, assigned);

        // this depends on current SubjectDomainCombiner implementation
        // (ordering of returned domains)
        if (combined.length == 4 &&
            combined[0] != pd1 && combined[1] != pd2 &&
            combined[2] == pd3 && combined[3] == pd2) {
            System.out.println("test passed");
        } else {
            System.out.println("test failed");
            throw new SecurityException("Test Failed");
        }
    }