Examples of RolePrincipal


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

  private void checkEditByFactoryPid() throws IOException,
      InvalidSyntaxException {
    executeCommand("config:edit '(service.factorypid=myconfig)'\n"
        + "config:property-set test1 data1new\n" + "config:update",
        new RolePrincipal("manager"));
    Configuration config = readConfig();
    assertEquals("data1new", config.getProperties().get("test1"));
    assertEquals("data2", config.getProperties().get("test2"));
  }
View Full Code Here

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

  private void CheckEditByArbitraryAttribute() throws IOException,
      InvalidSyntaxException {
    executeCommand("config:edit '(test2=data2)'\n"
        + "config:property-set test1 data1new2\n" + "config:update",
        new RolePrincipal("manager"));
    Configuration config = readConfig();
    assertEquals("data1new2", config.getProperties().get("test1"));
    assertEquals("data2", config.getProperties().get("test2"));
  }
View Full Code Here

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

        private Subject subject;

        private static Principal[] getPrincipals(String... roles) {
            List<Principal> principals = new ArrayList<Principal>();
            for (String role : roles) {
                principals.add(new RolePrincipal(role));
            }
            return principals.toArray(new Principal[]{});
        }
View Full Code Here

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

            final String user = userName;
            subject.getPrincipals().add(new UserPrincipal(user));
            String roles = System.getProperty("karaf.local.roles");
            if (roles != null) {
                for (String role : roles.split("[,]")) {
                    subject.getPrincipals().add(new RolePrincipal(role.trim()));
                }
            }
           
            JaasHelper.doAs(subject, new PrivilegedExceptionAction<Object>() {
                public Object run() throws Exception {
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

        private Subject subject;

        private static Principal[] getPrincipals(String... roles) {
            List<Principal> principals = new ArrayList<Principal>();
            for (String role : roles) {
                principals.add(new RolePrincipal(role));
            }
            return principals.toArray(new Principal[]{});
        }
View Full Code Here

Examples of org.apache.karaf.jaas.modules.RolePrincipal

        }

        principals = new HashSet<Principal>();
        principals.add(new UserPrincipal(user));
        for (int i = 1; i < infos.length; i++) {
            principals.add(new RolePrincipal(infos[i]));
        }

        users.clear();

        if (debug) {
View Full Code Here

Examples of org.apache.karaf.jaas.modules.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.modules.RolePrincipal

            while (namingEnumeration.hasMore()) {
                SearchResult result = (SearchResult) namingEnumeration.next();
                Attributes attributes = result.getAttributes();
                String role = (String) attributes.get(roleNameAttribute).get();
                if (role != null) {
                    principals.add(new RolePrincipal(role));
                }
            }
        } catch (Exception e) {
            throw new LoginException("Can't get user " + user + " roles: " + e.getMessage());
        }
View Full Code Here

Examples of org.apache.karaf.jaas.modules.RolePrincipal

            roleStatement = connection.prepareStatement(roleQuery);
            roleStatement.setString(1, user);
            roleResultSet = roleStatement.executeQuery();
            while (roleResultSet.next()) {
                String role = roleResultSet.getString(1);
                principals.add(new RolePrincipal(role));
            }
        } catch (Exception ex) {
            throw new LoginException("Error has occured while retrieving credentials from database:" + ex.getMessage());
        } finally {
            try {
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.