Package javax.security.auth.kerberos

Examples of javax.security.auth.kerberos.DelegationPermission


    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 {
View Full Code Here


                String realm = delegateTo.getRealmAsString();
                buf.append(" \"krbtgt/").append(realm).append('@');
                buf.append(realm).append('\"');
                SecurityManager sm = System.getSecurityManager();
                if (sm != null) {
                    DelegationPermission perm =
                        new DelegationPermission(buf.toString());
                    sm.checkPermission(perm);
                }


                /*
 
View Full Code Here

            buf.append(targetStr).append("\" \"");
            buf.append(tgsStr).append('\"');
            String krbPrincPair = buf.toString();
            SunNativeProvider.debug("Checking DelegationPermission (" +
                                    krbPrincPair + ")");
            DelegationPermission perm =
                new DelegationPermission(krbPrincPair);
            sm.checkPermission(perm);
            skipDelegPermCheck = true;
        }
    }
View Full Code Here

                String realm = delegateTo.getRealmAsString();
                buf.append(" \"krbtgt/").append(realm).append('@');
                buf.append(realm).append('\"');
                SecurityManager sm = System.getSecurityManager();
                if (sm != null) {
                    DelegationPermission perm =
                        new DelegationPermission(buf.toString());
                    sm.checkPermission(perm);
                }


                /*
 
View Full Code Here

*/
public class KrbDelegationPermissionCollectionTest extends SerializationTest {

    @Override
    protected Object[] getData() {
        Permission p1 = new DelegationPermission("\"AAA\" \"BBB\"", "action");
        Permission p2 = new DelegationPermission("\"AAA\" \"CCC\"");
        Permission p3 = new DelegationPermission("\"BBB\" \"CCC\"");
        PermissionCollection pc1 = p1.newPermissionCollection();
        PermissionCollection pc2 = p1.newPermissionCollection();
        pc2.add(p3);
        PermissionCollection pc3 = p1.newPermissionCollection();
        pc3.add(p1);
View Full Code Here

public class DelegationPermissionTest extends SerializationTest {

    @Override
    protected Object[] getData() {
        return new Object[] {
                new DelegationPermission("\"AAA\" \"BBB\"", "action"),
                new DelegationPermission("\"AAA\" \"CCC\"") };
    }
View Full Code Here

    /**
     * testing of a correct ctor
     */
    public void testCtor() {
        String name1 = "\"aaa.bbb.com@CCC.COM\" \"ccc.ddd.com@DDD.COM\"";
        DelegationPermission dp;
        dp = new DelegationPermission(name1);
        assertEquals(name1, dp.getName());
        assertEquals("",dp.getActions());
        dp = new DelegationPermission(name1, "action");
        assertEquals("",dp.getActions());
        dp = new DelegationPermission(name1, null);
        assertEquals("",dp.getActions());
    }
View Full Code Here

    /**
     * testing of a incorrect ctor
     */
    public void testFailCtor() {
        try {
            new DelegationPermission(null);
            fail("no expected NPE");
        } catch(NullPointerException e){
        }
        try {
            new DelegationPermission("");
            fail("no expected IAE");
        } catch(IllegalArgumentException e){
        }
        try {
            new DelegationPermission("\"aaa.bbb.com\" ccc.ddd.com");
            fail("Target name must be enveloped by quotes");
        } catch(IllegalArgumentException e){
        }
        try {
            new DelegationPermission("\"aaa.bbb.com\" ccc.ddd.com\"");
            fail("Target name must be enveloped by quotes");
        } catch(IllegalArgumentException e){
        }
        try {
            new DelegationPermission("\"aaa.bbb.com\" \"ccc.ddd.com");
            fail("Target name must be enveloped by quotes");
        } catch(IllegalArgumentException e){
        }
        try {
            new DelegationPermission("\" \" \" \"");
            //TODO: fail("Target name is empty");
        }catch(IllegalArgumentException e){
        }
        try {
            new DelegationPermission("\"\"");
            fail("Target name is incorrect");
        } catch(IllegalArgumentException e){
        }
        try {
            new DelegationPermission("\"aaa.bbb.com\" \"\"");
            fail("service principal is empty");
        } catch(IllegalArgumentException e){
        }
        try {
            new DelegationPermission("\"\" \"aaa.bbb.com\"");
            fail("subordinate service principal is empty");
        } catch(IllegalArgumentException e){
        }

    }
View Full Code Here

    }

    public void testFailCtor_2() {
        try {
            new DelegationPermission("\"AAA\"");
            fail("target name should be specifies a pair of kerberos service principals");
        } catch (IllegalArgumentException e) {
        }
    }
View Full Code Here

    }
   
    // testing of the equals method
    @SuppressWarnings("serial")
    public void testEquals() {
        DelegationPermission dp1 = new DelegationPermission("\"AAA\" \"BBB\"");
        DelegationPermission dp2 = new DelegationPermission("\"AAA\" \"BBB\"");
       
        assertTrue(dp1.equals(dp1));
        assertFalse(dp1.equals(new DelegationPermission("\"aaa\" \"bbb\"")));
        assertTrue(dp2.equals(dp1));
        assertTrue(dp1.equals(dp2));
        assertTrue(dp1.hashCode() == dp2.hashCode());
        assertFalse(dp1.equals(new BasicPermission("\"AAA\""){}));
    }
View Full Code Here

TOP

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

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.