Examples of RolePrincipal


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

                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

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

        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

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

                principals.add(new GroupPrincipal(infos[i].substring(PropertiesBackingEngine.GROUP_PREFIX.length())));
                String groupInfo = (String) users.get(infos[i]);
                if (groupInfo != null) {
                    String[] roles = groupInfo.split(",");
                    for (int j = 1; j < roles.length; j++) {
                        principals.add(new RolePrincipal(roles[j]));
                    }
                }
            } else {
                // it's an user reference
                principals.add(new RolePrincipal(infos[i]));
            }
        }

        users.clear();
View Full Code Here

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

            ";jaas:group-role-add " + managerGroup + " manager" +
            ";jaas:user-add " + viewerUser + " " + viewerUser +
            ";jaas:role-add " + viewerUser + " viewer" +
            ";jaas:update" +
            ";jaas:realm-manage --realm karaf" +
            ";jaas:user-list", new RolePrincipal("admin")));

        JMXConnector connector = getJMXConnector(viewerUser, viewerUser);
        MBeanServerConnection connection = connector.getMBeanServerConnection();
        ObjectName systemMBean = new ObjectName("org.apache.karaf:type=system,name=root");
View Full Code Here

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

            ";jaas:group-role-add " + managerGroup + " manager" +
            ";jaas:user-add " + viewerUser + " " + viewerUser +
            ";jaas:role-add " + viewerUser + " viewer" +
            ";jaas:update" +
            ";jaas:realm-manage --realm karaf" +
            ";jaas:user-list", new RolePrincipal("admin")));

        JMXConnector connector = getJMXConnector(managerUser, managerUser);
        MBeanServerConnection connection = connector.getMBeanServerConnection();
        ObjectName systemMBean = new ObjectName("org.apache.karaf:type=system,name=root");
View Full Code Here

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

            ";jaas:group-role-add " + managerGroup + " manager" +
            ";jaas:user-add " + viewerUser + " " + viewerUser +
            ";jaas:role-add " + viewerUser + " viewer" +
            ";jaas:update" +
            ";jaas:realm-manage --realm karaf" +
            ";jaas:user-list", new RolePrincipal("admin")));

        try {
            getJMXConnector("admingroup", "group");
            fail("Login with a group name should have failed");
        } catch (SecurityException se) {
View Full Code Here

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

        expectServiceTracker(bc, "(objectClass=" + Converter.class.getName() + ")", listeners);
        expectServiceTracker(bc, "(objectClass=" + CommandSessionListener.class.getName() + ")", listeners);
        EasyMock.replay(bc);

        Subject subject = new Subject();
        subject.getPrincipals().add(new RolePrincipal("aaabbbccc"));

        Subject.doAs(subject, new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                MySecuredCommandProcessorImpl scp = new MySecuredCommandProcessorImpl(bc) {};
View Full Code Here

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

        final DelegateSession ds = (DelegateSession) console.session;
        assertNull("Precondition", ds.delegate);

        Subject subject = new Subject();
        subject.getPrincipals().add(new RolePrincipal("myrole"));

        Subject.doAs(subject, new PrivilegedAction<Object>() {
            @Override
            public Object run() {
                SecuredCommandProcessorImpl secCP = console.createSecuredCommandProcessor();
View Full Code Here

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

    }

    @Test
    public void startLevelCommand() throws Exception {
        assertContains("100", executeCommand("system:start-level",
                new RolePrincipal("admin"), new RolePrincipal("manager"), new RolePrincipal("viewer")));
    }
View Full Code Here

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

 
  @Test
  public void createNewFactoryConfig() throws Exception {
    executeCommand("config:edit --factory myconfig2\n"
        + "config:property-set test1 data1\n"
        + "config:update", new RolePrincipal("manager"));
    Configuration config = configAdmin.listConfigurations("(service.factorypid=myconfig2)")[0];
    assertEquals("data1", config.getProperties().get("test1"));
  }
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.