Package java.security

Examples of java.security.PermissionCollection.elements()


        Permission sp1 = new ServicePermission("BBB", "accept, initiate");
        Permission sp2 = new ServicePermission("CCC", "initiate");
        Permission sp3 = new ServicePermission("DDD", "accept");
       
        pc.add(sp1);
        en = pc.elements();
        assertTrue(en.hasMoreElements());
        assertTrue(sp1.equals(en.nextElement()));
        assertFalse(en.hasMoreElements());
        pc.add(sp2);
        pc.add(sp3);
View Full Code Here


        assertTrue(en.hasMoreElements());
        assertTrue(sp1.equals(en.nextElement()));
        assertFalse(en.hasMoreElements());
        pc.add(sp2);
        pc.add(sp3);
        en = pc.elements();
        Collection<Permission> c = new ArrayList<Permission>();
        while (en.hasMoreElements())
        {
            c.add(en.nextElement());
        }
View Full Code Here

            // Both parameters are null
            //

            c = p.getPermissions(null, null);
            assertFalse("Read only for empty", c.isReadOnly());
            assertFalse("Elements for empty", c.elements().hasMoreElements());

            //
            // Subject parameter is provided (CodeBase is not important)
            //
            // Principal javax.security.auth.MyPrincipal "duke"
View Full Code Here

            //

            // no principals at all
            subject = new Subject();
            c = p.getPermissions(subject, null);
            assertFalse("Elements: ", c.elements().hasMoreElements());

            // different name "kuke" not "duke"
            subject.getPrincipals().add(new MyPrincipal("kuke"));
            c = p.getPermissions(subject, null);
            assertFalse("Elements: ", c.elements().hasMoreElements());
View Full Code Here

            assertFalse("Elements: ", c.elements().hasMoreElements());

            // different name "kuke" not "duke"
            subject.getPrincipals().add(new MyPrincipal("kuke"));
            c = p.getPermissions(subject, null);
            assertFalse("Elements: ", c.elements().hasMoreElements());

            // different class with required principal's name
            subject.getPrincipals().add(new OtherPrincipal("duke"));
            c = p.getPermissions(subject, null);
            assertFalse("Elements: ", c.elements().hasMoreElements());
View Full Code Here

            assertFalse("Elements: ", c.elements().hasMoreElements());

            // different class with required principal's name
            subject.getPrincipals().add(new OtherPrincipal("duke"));
            c = p.getPermissions(subject, null);
            assertFalse("Elements: ", c.elements().hasMoreElements());

            // subclass with required principal's name
            subject.getPrincipals().add(new FakePrincipal("duke"));
            c = p.getPermissions(subject, null);
            assertFalse("Elements: ", c.elements().hasMoreElements());
View Full Code Here

            assertFalse("Elements: ", c.elements().hasMoreElements());

            // subclass with required principal's name
            subject.getPrincipals().add(new FakePrincipal("duke"));
            c = p.getPermissions(subject, null);
            assertFalse("Elements: ", c.elements().hasMoreElements());

            // add required principal's name
            subject.getPrincipals().add(new MyPrincipal("duke"));

            Enumeration<Permission> e = p.getPermissions(subject, null).elements();
View Full Code Here

            // check: CodeBase is not important
            source = new CodeSource(new URL("http://dummy.xxx"),
                    (Certificate[]) null);
            c = p.getPermissions(subject, source);
            assertTrue("Elements: ", c.elements().hasMoreElements());

            source = new CodeSource(new URL("http://dummy.xxx"),
                    (CodeSigner[]) null);
            c = p.getPermissions(subject, source);
            assertTrue("Elements: ", c.elements().hasMoreElements());
View Full Code Here

            assertTrue("Elements: ", c.elements().hasMoreElements());

            source = new CodeSource(new URL("http://dummy.xxx"),
                    (CodeSigner[]) null);
            c = p.getPermissions(subject, source);
            assertTrue("Elements: ", c.elements().hasMoreElements());

            //
            // Subject and CodeBase parameter are provided
            //
            // Principal javax.security.auth.MyPrincipal "dummy"
View Full Code Here

                    "createClassLoader"));

            // reset subject : no principals at all
            subject = new Subject();
            c = p.getPermissions(subject, source);
            assertFalse("Elements: ", c.elements().hasMoreElements());

            // different name "kuke" not "dummy"
            subject.getPrincipals().add(new MyPrincipal("kuke"));
            c = p.getPermissions(subject, null);
            assertFalse("Elements: ", c.elements().hasMoreElements());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.