Update of /cvsroot/rapforums/src/source/edu/fullcoll/uportal/channels/rap/forum/permissions
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6028
Added Files:
RapPermissionsManager.java
Log Message:
no message
--- NEW FILE: RapPermissionsManager.java ---
/**
* Copyright (c) 2004, Fullerton College. All Rights Reserved.
* (http://www.fullcoll.edu)
*
* This software is distributed under the IBM Public Licence. Please see
* the license infomation for more details at http://www.opensource.org/licenses/ibmpl.php.
*
* EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED
* ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER
* EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS
* OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
* Each Recipient is solely responsible for determining the appropriateness of using
* and distributing the Program and assumes all risks associated with its exercise
* of rights under this Agreement, including but not limited to the risks and costs
* of program errors, compliance with applicable laws, damage to or loss of data,
* programs or equipment, and unavailability or interruption of operations.
*
* This software is OSI Certified Open Source Software.
* OSI Certified is a certification mark of the Open Source Initiative
*
*/
package edu.fullcoll.uportal.channels.rap.forum.permissions;
import org.jasig.portal.AuthorizationException;
import org.jasig.portal.groups.IGroupMember;
import org.jasig.portal.security.IAuthorizationPrincipal;
import org.jasig.portal.security.IPermission;
import org.jasig.portal.services.GroupService;
import org.jasig.portal.services.LogService;
import edu.fullcoll.uportal.channels.rap.forum.CForum;
import edu.fullcoll.uportal.channels.rap.forum.ForumSessionData;
/**
*
*
* @author Brad Rippe (br...@fu...), Chris Pereda (cp...@fu...)
* @version 0.9 $Revision %G%
*/
public class RapPermissionsManager {
/**
* This method determines if a user has the appropriate permission to execute a particular action,
* i.e. read, post, delete, create, or assign permissions for a particular forum.
* All Rap Forum Administrators have full implicit permissions to administer permissions.
* @param ap - the authorization principal for the particular user
* @param activity - the activity which the user should have permission
* @param forumid - the forum id which the user is requesting permission
* @return true if the user has been granted permission for execute an activity for a particular forum, otherwise, false
*
*/
public synchronized static boolean hasPermissionsForForum(IAuthorizationPrincipal ap,
String activity,
String forumid) {
try {
IPermission[] perms = ap.getAllPermissions("edu.fullcoll.uportal.channels.rap.forum.CForum",
activity, forumid);
if(perms.length == 0)
return false;
for(int i = 0; i < perms.length; i++) {
if(perms[i].getType().equals("GRANT")) {
return true;
} else {
return false;
}
}
return false;
} catch (AuthorizationException e) {
LogService.instance().log(LogService.ERROR, e);
}
return true;
}
}
|