Package org.apache.jetspeed.om.security

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


            duri.addPathInfo(SecurityConstants.PANE_NAME, SecurityConstants.PANEID_ROLEPERMISSION_UPDATE);
            duri.addPathInfo(SecurityConstants.PARAM_MSGID, SecurityConstants.MID_MISSING_PARAMETER);
            rundata.setRedirectURI(duri.toString());
            return;
        }
        Role role = JetspeedSecurity.getRole(entityid);
        if (null == role)
        {
            logger.error("RolePermissionBrowser: Failed to get role: " + entityid );
            DynamicURI duri = new DynamicURI (rundata);
            duri.addPathInfo(SecurityConstants.PANE_NAME, SecurityConstants.PANEID_ROLEPERMISSION_UPDATE);
            duri.addPathInfo(SecurityConstants.PARAM_MSGID, SecurityConstants.MID_MISSING_PARAMETER);
            rundata.setRedirectURI(duri.toString());
            return;
        }


        try
        {
            List permissions = (List)rundata.getUser().getTemp(SecurityConstants.CONTEXT_PERMISSIONS);
            List selected = (List)rundata.getUser().getTemp(SecurityConstants.CONTEXT_SELECTED);

            if (permissions == null || selected == null)
            {
                DynamicURI duri = new DynamicURI (rundata);
                duri.addPathInfo(SecurityConstants.PANE_NAME, SecurityConstants.PANEID_ROLEPERMISSION_UPDATE);
                duri.addPathInfo(SecurityConstants.PARAM_MSGID, SecurityConstants.MID_MISSING_PARAMETER);
                rundata.setRedirectURI(duri.toString());
                return;
            }

            //
            // walk thru all the permissions, see if anything changed
            // if changed, update the database
            //
            for (int ix = 0; ix < permissions.size(); ix++)
            {
                String permissionName = ((Permission)permissions.get(ix)).getName();
                boolean newValue = rundata.getParameters().getBoolean("box_" + permissionName, false);
                boolean oldValue = ((Boolean)selected.get(ix + 1)).booleanValue();
                if (newValue != oldValue)
                {
                    if (newValue == true)
                    {
                        // grant a permission to a role
                        JetspeedSecurity.grantPermission(role.getName(), permissionName);
                    }
                    else
                    {
                        // revoke a permission from a role
                        JetspeedSecurity.revokePermission(role.getName(), permissionName);
                    }
                }
            }

            // clear the temp values
            rundata.getUser().setTemp(SecurityConstants.CONTEXT_PERMISSIONS, null);
            rundata.getUser().setTemp(SecurityConstants.CONTEXT_SELECTED, null);


        }
        catch (Exception e)
        {
           // log the error msg
            logger.error("Failed update role+permission", e);

            //
            // error on update - display error message
            //
            DynamicURI duri = new DynamicURI (rundata);
            duri.addPathInfo(SecurityConstants.PANE_NAME, SecurityConstants.PANEID_ROLEPERMISSION_UPDATE);
            duri.addPathInfo(SecurityConstants.PARAM_MSGID, SecurityConstants.MID_UPDATE_FAILED);
            if (role != null)
                duri.addPathInfo(SecurityConstants.PARAM_ENTITY_ID, role.getName());
            rundata.setRedirectURI(duri.toString());

        }
    }
View Full Code Here


    {
        // get master list of permissions
        Iterator master = JetspeedSecurity.getPermissions();

        // get the user object
        Role role = JetspeedSecurity.getRole(roleName);
        if (null == role)
        {
            // no ACL found
            logger.error("RolePermissionBrowser: Failed to get role: " + roleName);
            return;
View Full Code Here

                                       Context context,
                                       RunData rundata )
    {
        try
        {
            Role role = null;
            /*
             * Grab the mode for the user form.
             */
            String mode = rundata.getParameters().getString(SecurityConstants.PARAM_MODE);

View Full Code Here

                if (newValue != oldValue)
                {
                    if (newValue == true)
                    {
                        // grant a role to a user
                        Role newRole = (Role) roles.get(ix);
                        JetspeedSecurity.grantRole( user.getUserName(), newRole.getName());

                        // If role profile merging is active, append profile for the new role
                        if (Profiler.useRoleProfileMerging())
                        {
                            appendNewRoleProfile((JetspeedRunData) rundata, user, newRole);
View Full Code Here

        int ix = 0;
        boolean sel = false;
        selected.add(ix, new Boolean(sel));
        while(roles.hasNext())
        {
            Role role = (Role)roles.next();
            //System.out.println("In buildUserRoleContext role="+role.getName());
            masterRoles.add(role);
            sel = JetspeedSecurity.hasRole(user.getUserName(), role.getName());
            //System.out.println("In buildUserRoleContext sel="+sel);
            ix = ix + 1;
            selected.add(ix, new Boolean(sel));
        }
        masterRoles.trimToSize();
View Full Code Here

    private 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(Profiler.PARAM_USER);
            String name = user.getUserName();
            if (null != name && name.length() > 0)
            {
                path.append(File.separator)
                    .append(name);
            }
        }
        else if (group != null)
        {
            path.append(Profiler.PARAM_GROUP);
            String name = group.getName();
            if (null != name && name.length() > 0)
            {
                path.append(File.separator)
                    .append(name);
            }
        }
        else if (null != role)
        {
            path.append(Profiler.PARAM_ROLE);
            String name = role.getName();
            if (null != name && name.length() > 0)
            {
                path.append(File.separator)
                    .append(name);
            }
View Full Code Here

    private 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(Profiler.PARAM_USER);
            String name = user.getUserName();
            if (null != name && name.length() > 0)
            {
                path.append(File.separator)
                .append(name);
            }
        }
        else if (group != null)
        {
            path.append(Profiler.PARAM_GROUP);
            String name = group.getName();
            if (null != name && name.length() > 0)
            {
                path.append(File.separator)
                .append(name);
            }
        }
        else if (null != role)
        {
            path.append(Profiler.PARAM_ROLE);
            String name = role.getName();
            if (null != name && name.length() > 0)
            {
                path.append(File.separator)
                .append(name);
            }
View Full Code Here

    public void setRoleByName( String roleName )
    {
        try
        {
            Role temp = JetspeedSecurity.getRole(roleName);
            if (null != temp)
            {
                role = temp;
            }
        }
View Full Code Here

            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

    {
        try
        {
            JetspeedUser user = JetspeedSecurity.getUser(username);
            Group group = this.getGroup(groupname);
            Role role = JetspeedSecurity.getRole(defaultRole);

            Criteria criteria = new Criteria();
            criteria.add(TurbineUserGroupRolePeer.USER_ID, user.getUserId());
            criteria.add(TurbineUserGroupRolePeer.GROUP_ID, group.getId());
            criteria.add(TurbineUserGroupRolePeer.ROLE_ID, role.getId());
            TurbineUserGroupRolePeer.doInsert(criteria);
        }
        catch(Exception e)
        {
            String message = "Join group '" + groupname + "' to user '" + username + "' failed: ";
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.