Examples of RolePrincipal


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

    public List<RolePrincipal> listRoles(UserPrincipal user) {
        List<RolePrincipal> result = new ArrayList<RolePrincipal>();
        String userInfo = users.get(user.getName());
        String[] infos = userInfo.split(",");
        for (int i = 1; i < infos.length; i++) {
            result.add(new RolePrincipal(infos[i]));
        }
        return result;
    }
View Full Code Here

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

@ExamReactorStrategy(PerMethod.class)
public class SystemShutdownTest extends KarafTestSupport {

    @Test
    public void shutdownCommand() throws Exception {
        System.out.println(executeCommand("system:shutdown -f", new RolePrincipal("admin")));
    }
View Full Code Here

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

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

        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

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

        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

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

        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

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

        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

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

        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

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

            }
        });

        // 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

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

            }
        });

        // 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
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.