001: /* Copyright 2005 The JA-SIG Collaborative. All rights reserved.
002: * See license distributed with this file and
003: * available online at http://www.uportal.org/license.html
004: */
005: package org.jasig.portal.channels.cusermanager;
006:
007: import java.util.Properties;
008: import java.util.Enumeration;
009:
010: import org.apache.commons.logging.Log;
011: import org.apache.commons.logging.LogFactory;
012: import org.jasig.portal.IPermissible;
013: import org.jasig.portal.channels.permissionsmanager.RDBMPermissibleRegistry;
014:
015: /**
016: * @author smb1@cornell.edu
017: * @version $Revision: 42081 $ $Date: 2007-06-13 14:20:56 -0700 (Wed, 13 Jun 2007) $
018: */
019: class CUserManagerPermissions implements IPermissible {
020:
021: protected final Log log = LogFactory.getLog(getClass());
022:
023: /**
024: * Values for use by the permissions manager
025: */
026: public static String[] activityTokens;
027:
028: /**
029: * Description of the Field
030: */
031: public static String[] activityNames;
032:
033: protected static final Properties activities = new Properties();
034:
035: static {
036:
037: activities.put(Constants.PERMISSION_MNGRRIGHT,
038: Constants.PERMISSION_MNGRRIGHTDESC);
039: activities.put(Constants.PERMISSION_PWDCHNGRIGHT,
040: Constants.PERMISSION_PWDCHNGRIGHTDESC);
041:
042: RDBMPermissibleRegistry
043: .registerPermissible(Constants.PERMISSION_OWNERTOKEN);
044: }// static
045:
046: /**
047: * Return a list of tokens representing all the activities this channel controls with permissions.
048: * These tokens can be used by the channel to ascertain permissions at runtime after they have
049: * been entered with the Permissions manager
050: */
051: public String[] getActivityTokens() {
052:
053: if (activityTokens == null) {
054:
055: activityTokens = new String[activities.size()];
056:
057: int i = 0;
058: Enumeration E = activities.keys();
059: while (E.hasMoreElements())
060: activityTokens[i++] = (String) E.nextElement();
061:
062: }// if
063:
064: return activityTokens;
065: }// getActivityTokens
066:
067: /**
068: * For a given activity token, return a human-readable string that describes the activity.
069: * Used in rendering the Permissions Manager GUI.
070: */
071: public String getActivityName(String token) {
072: return activities.getProperty(token);
073: }// getActivityName
074:
075: /**
076: * Return an array of tokens representing all targets this channel controls with permissions.
077: */
078: public String[] getTargetTokens() {
079: return new String[] { Constants.PERMISSION_OWNERTARGET };
080: }// getTargetTokens
081:
082: /**
083: * Return the human readable name of a target
084: */
085: public String getTargetName(String token) {
086: return Constants.PERMISSION_OWNERTARGET;
087: }// getTargetName
088:
089: /**
090: * Return the token used by this channel to represent itself as the owner of generated permissions.
091: * Can be arbitrary, but must be unique - I've been using classnames. This is also used by the channel
092: * to request a PermissionManager from the AuthorizationService at runtime.
093: */
094: public String getOwnerToken() {
095: return Constants.PERMISSION_OWNERTOKEN;
096: }// getOwnerToken
097:
098: /**
099: * Human-readable name of the owner - normally the Channel name.
100: */
101: public String getOwnerName() {
102: return Constants.PERMISSION_OWNERTARGET; //Constants.PERMISSION_OWNERNAME;
103: }// getOwnerName
104:
105: }// eoc
|