Package org.apache.karaf.jaas.boot.principal

Examples of org.apache.karaf.jaas.boot.principal.RolePrincipal


        }
    }

    @Test
    public void installUninstallCommand() throws Exception {
        String featureInstallOutput = executeCommand("feature:install -v eventadmin", new RolePrincipal("admin"));
        System.out.println(featureInstallOutput);
        assertFalse(featureInstallOutput.isEmpty());
        String featureListOutput = executeCommand("feature:list -i | grep eventadmin");
        System.out.println(featureListOutput);
        assertFalse(featureListOutput.isEmpty());
        System.out.println(executeCommand("feature:uninstall eventadmin", new RolePrincipal("admin")));
        featureListOutput = executeCommand("feature:list -i | grep eventadmin");
        System.out.println(featureListOutput);
        assertTrue(featureListOutput.isEmpty());
    }
View Full Code Here


        subject.getPrincipals().add(new UserPrincipal("karaf"));

        String roles = System.getProperty("karaf.local.roles");
        if (roles != null) {
            for (String role : roles.split("[,]")) {
                subject.getPrincipals().add(new RolePrincipal(role.trim()));
            }
        }

        final Terminal terminal = terminalFactory.getTerminal();
        Runnable callback = new Runnable() {
View Full Code Here

        final Object proxy = testCreateProxy(bc, new Class [] {TestServiceAPI.class, TestObjectWithoutInterface.class}, new CombinedTestService());

        // Run with the right credentials so we can test the expected roles
        Subject subject = new Subject();
        subject.getPrincipals().add(new RolePrincipal("b"));
        Subject.doAs(subject, new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                assertEquals("Doing it", ((TestServiceAPI) proxy).doit());
                if (!runningUnderCoverage) {
View Full Code Here

        final Object proxy = testCreateProxy(bc, new Class [] {TestServiceAPI.class, TestObjectWithoutInterface.class}, new CombinedTestService());

        // Run with the right credentials so we can test the expected roles
        Subject subject = new Subject();
        subject.getPrincipals().add(new RolePrincipal("b"));
        Subject.doAs(subject, new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                if (!runningUnderCoverage) {
                    assertEquals(-42L, ((TestObjectWithoutInterface) proxy).compute(42L));
View Full Code Here

        final Object proxy = testCreateProxy(bc, new Class [] {TestServiceAPI.class, TestServiceAPI2.class}, new MyService());

        // Run with the right credentials so we can test the expected roles
        Subject subject = new Subject();
        subject.getPrincipals().add(new RolePrincipal("c"));
        Subject.doAs(subject, new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                assertEquals("Doing it", ((TestServiceAPI) proxy).doit());
                return null;
            }
        });

        Subject subject2 = new Subject();
        subject2.getPrincipals().add(new RolePrincipal("b"));
        subject2.getPrincipals().add(new RolePrincipal("f"));
        Subject.doAs(subject2, new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                try {
                    assertEquals("Doing it", ((TestServiceAPI) proxy).doit());
View Full Code Here

        final Object proxy = testCreateProxy(bc, new Class [] {TestServiceAPI.class, TestObjectWithoutInterface.class}, new CombinedTestService());

        // Run with the right credentials so we can test the expected roles
        Subject subject = new Subject();
        subject.getPrincipals().add(new RolePrincipal("b"));
        Subject.doAs(subject, new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                assertEquals("Doing it", ((TestServiceAPI) proxy).doit());
                if (!runningUnderCoverage) {
View Full Code Here

            }
        });

        // Invoke the service with role 'c'.
        Subject subject = new Subject();
        subject.getPrincipals().add(new RolePrincipal("c"));
        Subject.doAs(subject, new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                assertEquals("The invocation under role 'c' should be ok, as there are no rules specified "
                        + "for this service at all.", "HELLO", ((TestServiceAPI2) proxy).doit("hello"));
View Full Code Here

            }
        });

        // Invoke the service with role 'c'.
        Subject subject = new Subject();
        subject.getPrincipals().add(new RolePrincipal("a"));
        subject.getPrincipals().add(new RolePrincipal("b"));
        subject.getPrincipals().add(new RolePrincipal("c"));
        Subject.doAs(subject, new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                try {
                    ((TestServiceAPI2) proxy).doit("hello");
View Full Code Here

                return null;
            }
        });

        Subject s2 = new Subject();
        s2.getPrincipals().add(new RolePrincipal("a"));
        s2.getPrincipals().add(new RolePrincipal("b"));
        s2.getPrincipals().add(new RolePrincipal("d"));
        Subject.doAs(s2, new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                TestServiceAPI3 obj = (TestServiceAPI3) proxy;
                assertEquals(42, obj.foo());
View Full Code Here

        BundleContext bc = mockConfigAdminBundleContext(c1);

        final Object proxy = testCreateProxy(bc, new Class [] {TestServiceAPI.class}, new TestService());

        Subject s1 = new Subject();
        s1.getPrincipals().add(new RolePrincipal("role1"));
        Subject.doAs(s1, new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                try {
                    ((TestServiceAPI) proxy).doit();
                    fail("Should have prevented this invocation as the custom role is required");
                } catch (SecurityException se) {
                    // good
                }
                return null;
            }
        });


        Subject s2 = new Subject();
        s2.getPrincipals().add(new MyRolePrincipal());
        Subject.doAs(s2, new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                ((TestServiceAPI) proxy).doit(); // Should work, the custom role is there
                return null;
            }
        });

        Subject s3 = new Subject();
        s3.getPrincipals().add(new MyRolePrincipal());
        s3.getPrincipals().add(new RolePrincipal("role1"));
        Subject.doAs(s3, new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                ((TestServiceAPI) proxy).doit(); // Should work, the custom role is there
                return null;
View Full Code Here

TOP

Related Classes of org.apache.karaf.jaas.boot.principal.RolePrincipal

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.