Java 8 AccessControlContext - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 AccessControlContext class.

This code example shows how to use the following methods:equals
        ProtectionDomain null1[] = {null};
        ProtectionDomain null2[] = {null, null};
 
        AccessControlContext accZero = new AccessControlContext(zero);
        AccessControlContext accNull1 = new AccessControlContext(null1);
        AccessControlContext accNull2 = new AccessControlContext(null2);
 
        testEquals(accZero, accNull1);
        testEquals(accZero, accNull2);
        testEquals(accNull1, accNull2);
        testEquals(accNull1, accZero);
        testEquals(accNull2, accZero);
        testEquals(accNull2, accNull1);
    } 
 
    private static void testEquals(AccessControlContext acc1,
        AccessControlContext acc2) throws Exception {
        if (!acc1.equals(acc2)) {
            throw new Exception("AccessControlContexts should be equal");
        } 

6
CodeRank
This code example shows how to use the following methods:sleep
        TestLibrary.suggestSecurityManager(null); 
 
        Permissions perms = new Permissions();
        perms.add(new SocketPermission("*:1024-", "listen"));
        AccessControlContext acc =
            new AccessControlContext(new ProtectionDomain[] {
                new ProtectionDomain(
                    new CodeSource(null, (Certificate[]) null), perms) });
 
        Remote impl = new DGCImplInsulation();;
 
        try { 
            Remote stub = (Remote) java.security.AccessController.doPrivileged(
                new ExportAction(impl));
            System.err.println("exported remote object; local stub: " + stub);
 
            MarshalledObject mobj = new MarshalledObject(stub);
            stub = (Remote) mobj.get();
            System.err.println("marshalled/unmarshalled stub: " + stub);
 

6
CodeRank
This code example shows how to use the following methods:checkPermission
		} 
 
		final boolean[] result = new boolean[] { false };
		Thread th = new Thread(new Runnable() {
			public void run() { 
				AccessControlContext acc = new AccessControlContext(
						new ProtectionDomain[] { pd });
				try { 
					acc.checkPermission(perm);
					result[0] = true;
				} catch (SecurityException e) {
				} 
			} 
		}); 
		th.start();
		try { 
			th.join();
		} catch (InterruptedException e) {
			// ignore 
		} 
5
CodeRank
This code example shows how to use the following methods:
		} 
 
		ProtectionDomain[] domains = new ProtectionDomain[] { new ProtectionDomain(
				new CodeSource(null, (Certificate[]) null), new Permissions()) };
 
		AccessControlContext parent = new AccessControlContext(domains);
		AccessControlContext c0 = new AccessControlContext(parent,
				new MyCombiner(0)); 
		final AccessControlContext c1 = new AccessControlContext(parent,
				new MyCombiner(1)); 
 
                class TestPermission extends BasicPermission {
                    TestPermission(String s) {
                        super(s);
                    } 
                } 
 
	} 
} 
5
CodeRank
This code example shows how to use the following methods:equals
        ProtectionDomain zero[] = {};
        ProtectionDomain null1[] = {null};
        ProtectionDomain null2[] = {null, null};
 
        AccessControlContext accZero = new AccessControlContext(zero);
        AccessControlContext accNull1 = new AccessControlContext(null1);
        AccessControlContext accNull2 = new AccessControlContext(null2);
 
        testEquals(accZero, accNull1);
        testEquals(accZero, accNull2);
        testEquals(accNull1, accNull2);
        testEquals(accNull1, accZero);
        testEquals(accNull2, accZero);
        testEquals(accNull2, accNull1);
    } 
 
    private static void testEquals(AccessControlContext acc1,
        AccessControlContext acc2) throws Exception {
        if (!acc1.equals(acc2)) {
            throw new Exception("AccessControlContexts should be equal");

5
CodeRank
This code example shows how to use the following methods:equals
        ProtectionDomain null1[] = {null};
        ProtectionDomain null2[] = {null, null};
 
        AccessControlContext accZero = new AccessControlContext(zero);
        AccessControlContext accNull1 = new AccessControlContext(null1);
        AccessControlContext accNull2 = new AccessControlContext(null2);
 
        testEquals(accZero, accNull1);
        testEquals(accZero, accNull2);
        testEquals(accNull1, accNull2);
        testEquals(accNull1, accZero);
        testEquals(accNull2, accZero);
        testEquals(accNull2, accNull1);
    } 
 
    private static void testEquals(AccessControlContext acc1,
        AccessControlContext acc2) throws Exception {
        if (!acc1.equals(acc2)) {
            throw new Exception("AccessControlContexts should be equal");
        } 

5
CodeRank
This code example shows how to use the following methods:equals
        // check that empty PD array equals PD array of one or more nulls 
        ProtectionDomain zero[] = {};
        ProtectionDomain null1[] = {null};
        ProtectionDomain null2[] = {null, null};
 
        AccessControlContext accZero = new AccessControlContext(zero);
        AccessControlContext accNull1 = new AccessControlContext(null1);
        AccessControlContext accNull2 = new AccessControlContext(null2);
 
        testEquals(accZero, accNull1);
        testEquals(accZero, accNull2);
        testEquals(accNull1, accNull2);
        testEquals(accNull1, accZero);
        testEquals(accNull2, accZero);
        testEquals(accNull2, accNull1);
    } 
 
    private static void testEquals(AccessControlContext acc1,
        AccessControlContext acc2) throws Exception {
        if (!acc1.equals(acc2)) {

5
CodeRank
This code example shows how to use the following methods:sleep
        TestLibrary.suggestSecurityManager(null); 
 
        Permissions perms = new Permissions();
        perms.add(new SocketPermission("*:1024-", "listen"));
        AccessControlContext acc =
            new AccessControlContext(new ProtectionDomain[] {
                new ProtectionDomain(
                    new CodeSource(null, (Certificate[]) null), perms) });
 
        Remote impl = new DGCImplInsulation();;
 
        try { 
            Remote stub = (Remote) java.security.AccessController.doPrivileged(
                new ExportAction(impl));
            System.err.println("exported remote object; local stub: " + stub);
 
            MarshalledObject mobj = new MarshalledObject(stub);
            stub = (Remote) mobj.get();
            System.err.println("marshalled/unmarshalled stub: " + stub);
 

5
CodeRank
This code example shows how to use the following methods:
 
    public static void main(String[] args) throws Exception {
 
        ProtectionDomain domain = new ProtectionDomain(null, null);
 
        AccessController.doPrivileged(new PrivilegedAction<Object>() {
            public Object run() { 
 
                // this initialize ProxyLazyValues 
                UIManager.getLookAndFeel(); 
 
                return null; 
            } 
        }, new AccessControlContext(new ProtectionDomain[]{domain}));
 
        weakRef = new WeakReference<ProtectionDomain>(domain);
        domain = null;
 
        Util.generateOOME(); 
 
5
CodeRank
This code example shows how to use the following methods:sleep
        TestLibrary.suggestSecurityManager(null); 
 
        Permissions perms = new Permissions();
        perms.add(new SocketPermission("*:1024-", "listen"));
        AccessControlContext acc =
            new AccessControlContext(new ProtectionDomain[] {
                new ProtectionDomain(
                    new CodeSource(null, (Certificate[]) null), perms) });
 
        Remote impl = new DGCImplInsulation();;
 
        try { 
            Remote stub = (Remote) java.security.AccessController.doPrivileged(
                new ExportAction(impl));
            System.err.println("exported remote object; local stub: " + stub);
 
            MarshalledObject mobj = new MarshalledObject(stub);
            stub = (Remote) mobj.get();
            System.err.println("marshalled/unmarshalled stub: " + stub);
 

5
CodeRank
See Code Examples for Java 8 AccessControlContext Methods: