Package org.apache.jetspeed.om.security

Examples of org.apache.jetspeed.om.security.Role


            String name = locator.getName();
            String mediaType = locator.getMediaType();
            String language = locator.getLanguage();
            String country = locator.getCountry();
            Group group = locator.getGroup();
            Role role = locator.getRole();

            return nameEquals(name)
//                   && locator.getId() == id
                   && mediaTypeEquals(mediaType)
                   && languageEquals(language)
View Full Code Here


        String language = locator.getLanguage();
        String country = locator.getCountry();
        String pageName = locator.getName();
        String roleName = null;

        Role role = locator.getRole();
        if (role != null) {
            roleName = role.getName();
        }

        if (roleName != null && roleName.length() > 0)
        {
            criteria.add(ROLE_NAME, roleName);
View Full Code Here

        try
        {
            JetspeedUser user = JetspeedSecurity.getUser("turbine");
            service.load(user.getUserName());
            Role role = service.getRole(user.getUserName(), "user");
            assertTrue(role.getName().equals("user"));
            assertTrue(service.hasRole(user.getUserName(), "user"));
            assertTrue(service.hasPermission("user", "view"));
            assertTrue(service.hasPermission("user", "customize"));
            assertTrue(service.hasPermission("user", "maximize"));
            assertTrue(!service.hasPermission("user", "failure"));
View Full Code Here

        try
        {
            JetspeedUser user = JetspeedSecurity.getUser("anon");
            service.load(user.getUserName());

            Role role1 = service.getRole(user.getUserName(), "guest");
            assertTrue(role1.getName().equals("guest"));
            assertTrue(service.hasPermission("guest", "view"));

            // add role
            Role role2 = JetspeedSecurity.getRole("user");
            service.addRole(user.getUserName(), role2);
            assertTrue(service.hasRole(user.getUserName(), "user"));
            assertTrue(service.getRole(user.getUserName(),"user").getName().equals("user"));

            // remove role
            service.removeRole(user.getUserName(), "user");
            assertTrue(!service.hasRole(user.getUserName(), "user"));
            Role role3 = service.getRole(user.getUserName(),"user");
            assertTrue(null == role3);

            // add permission
            Permission perm1 = JetspeedSecurity.getPermission("info");
            assertTrue(null != perm1);
View Full Code Here

    public void testRemoveAll() throws Exception
    {
        SecurityCacheService service = getService();
        try
        {
            Role role = JetspeedSecurity.getRole("admin");
            JetspeedUser anon = JetspeedSecurity.getUser("anon");
            service.load(anon.getUserName());
            JetspeedUser turbine = JetspeedSecurity.getUser("turbine");
            service.load(turbine.getUserName());

            service.addRole(anon.getUserName(), role);
            service.addRole(turbine.getUserName(), role);

            assertTrue(service.hasRole(anon.getUserName(), role.getName()));
            assertTrue(service.hasRole(turbine.getUserName(), role.getName()));

            service.removeAllRoles("admin");

            assertTrue(!service.hasRole(anon.getUserName(), role.getName()));
            assertTrue(!service.hasRole(turbine.getUserName(), role.getName()));

        }
        catch (Exception e)
        {
            fail(StringUtils.stackTrace(e));
View Full Code Here

        try
        {
            Iterator roles = JetspeedSecurity.getRoles();
            while (roles.hasNext())
            {
                Role role = (Role)roles.next();
                Map map = new HashMap();
                Iterator prms = JetspeedSecurity.getPermissions(role.getName());
                while (prms.hasNext())
                {
                    Permission perm = (Permission)prms.next();
                    map.put(perm.getName(), perm);
                }
                perms.put(role.getName(), map);
            }
        }
        catch (JetspeedSecurityException e)
        {
            logger.error("Exception", e);
View Full Code Here

   
    public void loadRolePermissions(String roleName)
    {
        try
        {
            Role role = null;
            try
            {
                JetspeedSecurity.getRole(roleName);
            }
            catch(RoleException e)
            {
                //no role found, nothing to do
            }
           
            if(role != null)
            {
              Map map = new HashMap();
              Iterator prms = JetspeedSecurity.getPermissions(role.getName());
              while (prms.hasNext())
              {
                  Permission perm = (Permission)prms.next();
                  map.put(perm.getName(), perm);
              }
              perms.put(role.getName(), map);
            }
        }
        catch (JetspeedSecurityException e)
        {
            logger.error("Exception", e);
View Full Code Here

                Profile profile = (Profile)entry.getDocument();
                if (null == profile)
                {
                    continue;
                }
                Role pRole = profile.getRole();
                if (null != pRole && pRole.getName().equals(role.getName()))
                {
                  it.remove();
                }
            }
        }
View Full Code Here

    protected String mapLocatorToFile(ProfileLocator locator)
    {
        StringBuffer path = new StringBuffer();

        // move the base dir is either user or role is specified
        Role role = locator.getRole();
        Group group = locator.getGroup();
        JetspeedUser user = locator.getUser();

        if (user != null)
        {
            path.append(PATH_USER);
            String name = user.getUserName();
            if (null != name && name.length() > 0)
            {
                path.append(File.separator)
                    .append(name);
            }
        }
        else if (group != null)
        {
            path.append(PATH_GROUP);
            String name = group.getName();
            if (null != name && name.length() > 0)
            {
                path.append(File.separator)
                    .append(name);
            }
        }
        else if (null != role)
        {
            path.append(PATH_ROLE);
            String name = role.getName();
            if (null != name && name.length() > 0)
            {
                path.append(File.separator)
                    .append(name);
            }
View Full Code Here

     */
    public Iterator query( QueryLocator locator )
    {
        List list = new LinkedList();

        Role role = locator.getRole();
        Group group = locator.getGroup();
        JetspeedUser user = locator.getUser();

        // search thru anonymous directories?
        int qm = locator.getQueryMode();
        if ((qm & QueryLocator.QUERY_USER) == QueryLocator.QUERY_USER)
        {
            Profile profile = createProfile();
            StringBuffer path = new StringBuffer();
            path.append(PATH_USER);
            String name = null;
            int state = STATE_INIT;
            if (null != user)
            {
                name = user.getUserName();
                profile.setUser( user );
                if (null != name)
                {
                    path.append(File.separator).append(name);
                    state = STATE_BASE;
                }
            }
            File base = this.rootDir;
            File file = new File(base, path.toString());
            String absPath = file.getAbsolutePath();
            QueryState qs = new QueryState( QUERY_BY_USER,
                                             profile,
                                             locator,
                                             list,
                                             name,
                                             state);
            subQuery(qs, absPath);
        }
        if ((qm & QueryLocator.QUERY_ROLE) == QueryLocator.QUERY_ROLE)
        {
            Profile profile = createProfile();
            StringBuffer path = new StringBuffer();
            path.append(PATH_ROLE);
            String name = null;
            int state = STATE_INIT;
            if (null != role)
            {
                name = role.getName();
                profile.setRole( role );
                if (null != name)
                {
                    path.append(File.separator).append(name);
                    state = STATE_BASE;
View Full Code Here

TOP

Related Classes of org.apache.jetspeed.om.security.Role

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.