Package javax.security.auth.kerberos

Examples of javax.security.auth.kerberos.ServicePermission


    /**
     * @tests javax.security.auth.kerberos.ServicePermission#ServicePermission(
     *        java.lang.String,java.lang.String)
     */
    public void testCtor() {
        ServicePermission sp = new ServicePermission("krbtgt/AAA.COM@BBB.COM", "initiate");
        ServicePermission sp1 = new ServicePermission("host/AAA.COM@BBB.COM", "accept");
        assertEquals("krbtgt/AAA.COM@BBB.COM",sp.getName());
        assertEquals("initiate",sp.getActions());
        assertEquals("host/AAA.COM@BBB.COM",sp1.getName());
        assertEquals("accept",sp1.getActions());
        ServicePermission sp2 = new ServicePermission("host/AAA.COM@BBB.COM", "accept, initiate");
        assertEquals("initiate,accept", sp2.getActions());

        try {
            // Regression for HARMONY-769
            // checks exception order: action parameter is verified first
            new ServicePermission(null, "initiate accept");
            fail("No expected IllegalArgumentException");
        } catch(IllegalArgumentException e){
        }
    }
View Full Code Here


        }
    }
   
    public void testFailedCtor() {
        try {
            new ServicePermission("krbtgt/AAA.COM@BBB.COM", "read");
          fail("incorrect actions");
        } catch(IllegalArgumentException e){
        }

        try {
            new ServicePermission("krbtgt/AAA.COM@BBB.COM", "");
          fail("actions is empty");
        } catch(IllegalArgumentException e){
        }

        try {
            new ServicePermission("krbtgt/AAA.COM@BBB.COM", null);
          fail("actions is null");
        } catch(NullPointerException e){
        } catch(IllegalArgumentException e){}

        try {
            new ServicePermission(null, "accept");
          fail("permission is null");
        } catch(NullPointerException e){
        }
        try {
            new ServicePermission("", "accept");
          //TODO: fail("No expected IAE");  //
        } catch(IllegalArgumentException e){}
        try {
            new ServicePermission("krbtgt/AAA.COM@BBB.COM", "accept, read");
          fail("Incorrect actions");
        } catch(IllegalArgumentException e){
        }
        try {
            new ServicePermission("krbtgt/AAA.COM@BBB.COM", "initiate, read");
          fail("Incorrect actions");
        } catch(IllegalArgumentException e){
        }
        try {
            new ServicePermission("krbtgt/AAA.COM@BBB.COM", "read, initiate ");
          fail("Incorrect actions");
        } catch(Exception e){
        }
        try {
            new ServicePermission("krbtgt/AAA.COM@BBB.COM", "read, accept ");
          fail("Incorrect actions");
        }catch(IllegalArgumentException e){
        }
        try {
            new ServicePermission("krbtgt/AAA.COM@BBB.COM", ", accept ");
          //TODO: fail("No expected IAE");
        } catch(IllegalArgumentException e){
        }
        try {
            new ServicePermission("krbtgt/AAA.COM@BBB.COM", "initiate, accept, read");
          fail("Incorrect actions");
        } catch(IllegalArgumentException e){
        }
        try {
            new ServicePermission("krbtgt/AAA.COM@BBB.COM", "initiate, read, accept");
          fail("Incorrect actions");
        } catch(IllegalArgumentException e){
        }
        try {
            new ServicePermission("krbtgt/AAA.COM@BBB.COM", "initiate, accept, accept");
          //TODO: fail("Incorrect actions");
        } catch(IllegalArgumentException e){
        }
        try {
            new ServicePermission("krbtgt/AAA.COM@BBB.COM", "initiate accept");
          fail("Incorrect actions");
        } catch(IllegalArgumentException e){
        }
    }
View Full Code Here

        } catch(IllegalArgumentException e){
        }
    }
   
    public void testEquals() {
        ServicePermission sp = new ServicePermission("host/AAA.COM@BBB.COM", "accept");
        ServicePermission sp1 = new ServicePermission("host/AAA.COM@BBB.COM", "initiate");
        ServicePermission sp2 = new ServicePermission("host/AAA.COM@BBB.COM", "initiate, accept");
        assertTrue(sp.equals(sp));
        assertTrue(sp.hashCode() == sp.hashCode());
        assertFalse(sp.equals(sp1));
        assertFalse(sp.hashCode() == sp1.hashCode());
        assertFalse(sp.equals(sp2));
        assertFalse(sp1.equals(sp2));
        assertTrue(sp2.equals(sp2));
        assertFalse(sp.equals(new DelegationPermission("\"AAA\" \"BBB\"", "action")));
        assertFalse(sp.equals(null));
    }
View Full Code Here

        assertFalse(sp.equals(new DelegationPermission("\"AAA\" \"BBB\"", "action")));
        assertFalse(sp.equals(null));
    }
   
    public void testImplies() {
        ServicePermission sp1;
        ServicePermission sp = new ServicePermission("host/AAA.COM@BBB.COM", "accept");
        sp1 = new ServicePermission("*", "initiate, accept");
        assertTrue(sp.implies(sp));
        assertFalse(sp.implies(sp1));
        assertTrue(sp1.implies(sp));
        assertTrue(sp1.implies(sp1));
        sp1 = new ServicePermission("*", "accept");
        assertTrue(sp1.implies(sp));
        sp1 = new ServicePermission("*", "initiate");
        assertFalse(sp1.implies(sp));
        assertFalse(sp1.implies(new ServicePermission("*", "accept, initiate")));
        assertTrue(new ServicePermission("host/AAA.COM@BBB.COM", "initiate, accept").implies(sp));
        assertTrue(new ServicePermission("host/AAA.COM@BBB.COM", "accept").implies(sp));
        assertFalse(new ServicePermission("host/AAA.COM@BBB.COM", "initiate").implies(sp));
        assertFalse(sp1.implies(null));
    }
View Full Code Here

    }
   
    // tests for KrbServicePermissionCollection
   
    public void testAddCollection() {
        ServicePermission sp = new ServicePermission("AAA", "accept");
        PermissionCollection pc  = sp.newPermissionCollection();
       
        try {
            pc.add(new DelegationPermission("\"aaa\" \"bbb\""));
            fail("Should not add non DelegationPermission");
        } catch (IllegalArgumentException e) {
        }
       
        try {
            pc.add(null);
            fail("no expected IAE");
        } catch (IllegalArgumentException e) {
        }
       
        pc.add(new ServicePermission("AAA", "accept"));
        pc.add(new ServicePermission("BBB", "accept, initiate"));
       
        pc.setReadOnly();
        try {
            pc.add(sp);
            fail("read-only flag is ignored");
View Full Code Here

    }
   
    public void testImpliesCollection(){
       
        Permission ap = new AllPermission();
        Permission p = new ServicePermission("AAA", "accept");
        PermissionCollection pc = p.newPermissionCollection();
        assertFalse(pc.implies(ap));
        assertFalse(pc.implies(p));
        pc.add(p);
        assertTrue(pc.implies(p));
        assertFalse(pc.implies(null));
        assertFalse(pc.implies(new ServicePermission("BBB", "initiate")));
        assertFalse(pc.implies(new ServicePermission("CCC", "accept")));
        pc.add(new ServicePermission("*", "accept, initiate"));
        assertTrue(pc.implies(new ServicePermission("*", "accept")));
        assertTrue(pc.implies(new ServicePermission("*", "initiate")));
        assertTrue(pc.implies(new ServicePermission("BBB", "initiate")));
        assertTrue(pc.implies(new ServicePermission("CCC", "accept")));

       
    }
View Full Code Here

       
    }
   
    public void testElements() {
        Permission p = new ServicePermission("AAA", "accept");
        PermissionCollection pc = p.newPermissionCollection();
       
    try {
      pc.elements().nextElement();
      fail("expected NoSuchElementException");
    } catch (NoSuchElementException e) {
    }

        Enumeration<Permission> en = pc.elements();
        assertNotNull(en);
        assertFalse(en.hasMoreElements());
       
        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()));
View Full Code Here

                "InitiatE", //  first & last upper case
                "Accept, initiatE" //  first & last upper case
        };

        for (String element : validActions) {
            new ServicePermission("*", element);
        }

        String[] invalidActions = new String[] { "accept initiate", // space
                "accept\ninitiate", // delimiter \n
                "accept\tinitiate", // delimiter \t
                "accept\tinitiate", // delimiter \r
                "accept, ", // ','
                "accept,", // ','
                " ,accept" // ','
        };
        for (String element : invalidActions) {
            try {
                new ServicePermission("*", element);
                fail("No expected IllegalArgumentException for action: "
                        + element);
            } catch (IllegalArgumentException e) {
            }
        }
View Full Code Here

        authPerm,
        new AuthPermission("doAs"),
        new RuntimePermission("modifyThread"),
        new RuntimePermission("modifyThreadGroup"),
        new RuntimePermission("setContextClassLoader"),
        new ServicePermission(serverPrincipal.getName(), "accept")
    };
      }

      this.returnErrMsg = returnErrMsg;
      this.illArgErrMsg = illArgErrMsg;
View Full Code Here

                String serverPrincipal =
                    kerberosKeys[0].getPrincipal().getName();
                SecurityManager sm = System.getSecurityManager();
                try {
                   if (sm != null) {
                      sm.checkPermission(new ServicePermission(serverPrincipal,
                                                "accept"), acc);
                   }
                } catch (SecurityException se) {
                   kerberosKeys = null;
                   // %%% destroy keys? or will that affect Subject?
View Full Code Here

TOP

Related Classes of javax.security.auth.kerberos.ServicePermission

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.