Code example for ProtectionDomain

0
                return "p"; 
            } 
        }; 
        Principal[] principals = new Principal[] { p };
 
        ProtectionDomain domain = new ProtectionDomain(source, permissions,
                classLoader, principals);
 
        pd = combiner.combine(new ProtectionDomain[] { domain }, null);
 
        assertSame("CodeSource", source, pd[0].getCodeSource());
        assertSame("PermissionCollection", permissions, pd[0]
                .getPermissions());
        assertSame("ClassLoader", classLoader, pd[0].getClassLoader());
 
        assertEquals("Size", 1, pd[0].getPrincipals().length);
        assertSame("Principal", principal, (pd[0].getPrincipals())[0]);
 
        // test case: check inherited domains 
        pd = combiner.combine(null, new ProtectionDomain[] { domain });
        assertSame("Inherited domain", domain, pd[0]);
    } 
 
    public final void testSecurityException() { 
 
        denyPermission(new AuthPermission("getSubjectFromDomainCombiner"));