Package java.security

Examples of java.security.SecurityPermission


    /**
     * Tests that implies() does proper permission evaluation.
     */
    public void testImplies() {
        TestProvider policy = new TestProvider();
        SecurityPermission sp = new SecurityPermission("abc");
        policy.pc = sp.newPermissionCollection();
       
        policy.pc.add(sp);
        assertTrue(policy.implies(new ProtectionDomain(null, null), sp));
        assertFalse(policy.implies(null, sp));
        assertFalse(policy.implies(new ProtectionDomain(null, null), null));
View Full Code Here


     * the implementation class will be encapsulated (during construction) in
     * the thrown PolicyContextException
     */
    public static PolicyConfigurationFactory getPolicyConfigurationFactory() throws ClassNotFoundException, PolicyContextException {
        SecurityManager sm = System.getSecurityManager();
        if (sm != null) sm.checkPermission(new SecurityPermission("setPolicy"));

        if (policyConfigurationFactory != null) return policyConfigurationFactory;

        final String[] factoryClassName = { null };
        try {
View Full Code Here

        if (sm != null) {
            // before the new manager assumed office, make a pass through
            // the common operations and let it load needed classes (if any),
            // to avoid infinite recursion later on
            try {
                sm.checkPermission(new SecurityPermission("getProperty.package.access"));
            } catch (Exception ignore) {}
            try {
                sm.checkPackageAccess("java.lang");
            } catch (Exception ignore) {}
        }
View Full Code Here

     * the implementation class will be encapsulated (during construction) in
     * the thrown PolicyContextException
     */
    public static PolicyConfigurationFactory getPolicyConfigurationFactory() throws ClassNotFoundException, PolicyContextException {
        SecurityManager sm = System.getSecurityManager();
        if (sm != null) sm.checkPermission(new SecurityPermission("setPolicy"));

        if (policyConfigurationFactory != null) return policyConfigurationFactory;

        final String[] factoryClassName = { null };
        try {
View Full Code Here

        if (sm != null) {
            // before the new manager assumed office, make a pass through
            // the common operations and let it load needed classes (if any),
            // to avoid infinite recursion later on
            try {
                sm.checkPermission(new SecurityPermission("getProperty.package.access"));
            } catch (Exception ignore) {}
            try {
                sm.checkPackageAccess("java.lang");
            } catch (Exception ignore) {}
        }
View Full Code Here

        if (sm != null) {
            // before the new manager assumed office, make a pass through
            // the common operations and let it load needed classes (if any),
            // to avoid infinite recursion later on
            try {
                sm.checkPermission(new SecurityPermission("getProperty.package.access"));
            } catch (Exception ignore) {}
            try {
                sm.checkPackageAccess("java.lang");
            } catch (Exception ignore) {}
        }
View Full Code Here

     * @throws SecurityException
     *             if the calling thread is not allowed to perform
     *             {@code target}.
     */
    public void checkSecurityAccess(String target) {
        checkPermission(new SecurityPermission(target));
    }
View Full Code Here

        Subject.doAs(subject, emptyPEAction);
        Subject.doAsPrivileged(subject, emptyPAction, null);
        Subject.doAsPrivileged(subject, emptyPEAction, null);

        // each doAs* creates new ACContext
        denyPermission(new SecurityPermission("createAccessControlContext"));

        try {
            Subject.doAs(subject, emptyPAction);
            fail("No expected AccessControlException");
        } catch (AccessControlException e) {
View Full Code Here

        PermissionCollection pc1 = dp.newPermissionCollection();
        PermissionCollection pc2 = dp.newPermissionCollection();
        assertNotSame(pc1, pc2);
        pc1.add(new DelegationPermission("\"BBB\" \"AAA\""));
        try {
            pc1.add(new SecurityPermission("aaa"));
            fail("should not add non DelegationPermission");
        } catch (IllegalArgumentException e){
        }
    try {
        pc1.add(null);
View Full Code Here

        try {
            Policy.setPolicy(plc);

            Class<?> a = new Ldr().define();

            Permission p = new SecurityPermission("abc");
            assertFalse("impossible! misconfiguration?", a.getProtectionDomain().implies(p));

            plc.pc = p.newPermissionCollection();
            plc.pc.add(p);
            assertTrue("default domain is not dynamic", a.getProtectionDomain().implies(p));
        } finally {
            Policy.setPolicy(back);
        }
View Full Code Here

TOP

Related Classes of java.security.SecurityPermission

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.