Package org.apache.jetspeed.om.security

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


                roles = new HashMap();

            for (int ix = 0; ix < rels.size(); ix++)
            {
                TurbineUserGroupRole rel = (TurbineUserGroupRole)rels.get(ix);
                Role role = rel.getTurbineRole();
                roles.put(role.getName(), role);
            }
        }
        catch(Exception e)
        {
            logger.error( "Failed to retrieve roles ", e );
View Full Code Here


            {
                throw new RoleException("[" + rolename + "] is a system role and cannot be removed");
            }

            conn = Torque.getConnection();
            Role role = this.getRole(rolename);

            Criteria criteria = new Criteria();
            criteria.add(TurbineRolePeer.ROLE_NAME, rolename);

            if(cascadeDelete)
            {
                // CASCADE TURBINE_USER_GROUP_ROLE, TURBINE_ROLE_PERMISSION
                Criteria criteria1 = new Criteria();
                criteria1.add(TurbineUserGroupRolePeer.ROLE_ID, role.getId());
                TurbineUserGroupRolePeer.doDelete(criteria1, conn);

                Criteria criteria2 = new Criteria();
                criteria2.add(TurbineRolePermissionPeer.ROLE_ID, role.getId());
                TurbineRolePermissionPeer.doDelete(criteria2, conn);
            }

            TurbineRolePeer.doDelete(criteria, conn);
            PsmlManager.removeRoleDocuments(role);
View Full Code Here

        throws JetspeedSecurityException
    {
        try
        {
            JetspeedUser user = JetspeedSecurity.getUser(username);
            Role role = this.getRole(rolename);

            Criteria criteria = new Criteria();
            criteria.add(TurbineUserGroupRolePeer.USER_ID, user.getUserId());
            criteria.add(TurbineUserGroupRolePeer.GROUP_ID, JetspeedSecurity.JETSPEED_GROUP_ID);
            criteria.add(TurbineUserGroupRolePeer.ROLE_ID, role.getId());
            TurbineUserGroupRolePeer.doInsert(criteria);

            if (cachingEnable)
            {
                JetspeedSecurityCache.addRole(username, role);
View Full Code Here

        throws JetspeedSecurityException
    {
        try
        {
            JetspeedUser user = JetspeedSecurity.getUser(username);
            Role role = this.getRole(rolename);

            Criteria criteria = new Criteria();
            criteria.add(TurbineUserGroupRolePeer.USER_ID, user.getUserId());
            criteria.add(TurbineUserGroupRolePeer.GROUP_ID, JetspeedSecurity.JETSPEED_GROUP_ID);
            criteria.add(TurbineUserGroupRolePeer.ROLE_ID, role.getId());
            TurbineUserGroupRolePeer.doDelete(criteria);

            if (cachingEnable)
            {
                JetspeedSecurityCache.removeRole(username, rolename);
View Full Code Here

                {
                    return acl.hasRole(rolename);
                }
            }
            JetspeedUser user = JetspeedSecurity.getUser(username);
            Role role = this.getRole(rolename);

            Criteria criteria = new Criteria();
            criteria.add(TurbineUserGroupRolePeer.USER_ID, user.getUserId());
            criteria.add(TurbineUserGroupRolePeer.GROUP_ID, JetspeedSecurity.JETSPEED_GROUP_ID);
            criteria.add(TurbineUserGroupRolePeer.ROLE_ID, role.getId());
            roles = TurbineUserGroupRolePeer.doSelect(criteria);

        }
        catch(Exception e)
        {
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);

            // if we are updating or deleting - put the name in the context
            //
            if (mode != null && (mode.equals(SecurityConstants.PARAM_MODE_UPDATE) ||
                                 mode.equals(SecurityConstants.PARAM_MODE_DELETE)))
            {
                // get the primary key and put the object in the context
                String rolename = rundata.getParameters().getString(SecurityConstants.PARAM_ENTITY_ID);
                role = JetspeedSecurity.getRole(rolename);
                context.put(SecurityConstants.CONTEXT_ROLE, role);
            }

            //
            // if there was an error, display the message
            //
            String msgid = rundata.getParameters().getString(SecurityConstants.PARAM_MSGID);
            if (msgid != null)
            {
                int id = Integer.parseInt(msgid);
                if (id < SecurityConstants.MESSAGES.length)
                    context.put(SecurityConstants.PARAM_MSG, SecurityConstants.MESSAGES[id]);

                // get the bad entered data and put it back for convenient update
                Role tempRole = (Role)rundata.getUser().getTemp(TEMP_ROLE);
                if (tempRole != null)
                    context.put(SecurityConstants.CONTEXT_ROLE, tempRole);
            }
            context.put(SecurityConstants.PARAM_MODE, mode);

View Full Code Here

     * @param context The velocity context for this request.
     */
    public void doInsert(RunData rundata, Context context)
        throws Exception
    {
        Role role = null;
        try
        {
            //
            // validate that its not an 'blank' rolename -- not allowed
            //
            String name = rundata.getParameters().getString("name");
            if (name == null || name.trim().length() == 0)
            {
                DynamicURI duri = new DynamicURI (rundata);
                duri.addPathInfo(SecurityConstants.PANE_NAME, SecurityConstants.PANEID_ROLE_UPDATE);
                duri.addPathInfo(SecurityConstants.PARAM_MSGID, SecurityConstants.MID_INVALID_ENTITY_NAME);
                rundata.setRedirectURI(duri.toString());
                rundata.getUser().setTemp(TEMP_ROLE, null);
                return;
            }

            //
            // generate a new role
            //           
            // TODO: replace with Role factory
            role = new BaseJetspeedRole();
            role.setName(name);

            //
            // add the role
            ///
            JetspeedSecurity.addRole(role);
View Full Code Here

     * @param context The velocity context for this request.
     */
    public void doUpdate(RunData rundata, Context context)
        throws Exception
    {
        Role role = null;
        try
        {
            //
            // get the role object from the selected role entry in the browser
            //
            role = JetspeedSecurity.getRole(
                     rundata.getParameters().getString(SecurityConstants.PARAM_ENTITY_ID));

            //
            // update the role in the database
            //
            JetspeedSecurity.saveRole(role);

        }
        catch (Exception e)
        {
           // log the error msg
            logger.error("Exception", e);

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

           // save values that user just entered so they don't have to re-enter
           if (role != null)
View Full Code Here

     * @param context The velocity context for this request.
     */
    public void doDelete(RunData rundata, Context context)
        throws Exception
    {
        Role role = null;

        try
        {
            //
            // get the role object from the selected role entry in the browser
            //
            role = JetspeedSecurity.getRole(
                        rundata.getParameters().getString( SecurityConstants.PARAM_ENTITY_ID) );

            //
            // remove the role
            //
            JetspeedSecurity.removeRole(role.getName());

        }
        catch (Exception e)
        {
           // log the error msg
            logger.error("Exception", e);

            //
            // error on delete - display error message
            //
            DynamicURI duri = new DynamicURI (rundata);
            duri.addPathInfo(SecurityConstants.PANE_NAME, SecurityConstants.PANEID_ROLE_UPDATE);
            duri.addPathInfo(SecurityConstants.PARAM_MSGID, SecurityConstants.MID_DELETE_FAILED);
            if (role != null)
                duri.addPathInfo(SecurityConstants.PARAM_ENTITY_ID, role.getName());
            duri.addQueryData(SecurityConstants.PARAM_MODE, SecurityConstants.PARAM_MODE_DELETE);
            rundata.setRedirectURI(duri.toString());

            // save values that user just entered so they don't have to re-enter
           if (role != null)
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

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.