001: /* Copyright 2001 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:
006: package org.jasig.portal.security.provider;
007:
008: import org.jasig.portal.AuthorizationException;
009: import org.jasig.portal.security.IAuthorizationPrincipal;
010: import org.jasig.portal.security.IPermission;
011: import org.jasig.portal.security.IPermissionManager;
012: import org.jasig.portal.security.IPermissionStore;
013:
014: /**
015: * @author Bernie Durfee (bdurfee@interactivebusiness.com)
016: * @author Dan Ellentuck (de3@columbia.edu)
017: * @version $Revision: 34778 $
018: */
019: public class PermissionManagerImpl implements IPermissionManager {
020: private AuthorizationImpl authorizationService;
021: protected static IPermissionStore permissionStore;
022: private java.lang.String owner;
023:
024: /**
025: * This constructor ensures that the PermissionManager will be created with an owner specified
026: * @param newOwner the new owner
027: * @param authService the authorization service
028: */
029: public PermissionManagerImpl(String newOwner,
030: AuthorizationImpl authService) {
031: super ();
032: owner = newOwner;
033: authorizationService = authService;
034: }
035:
036: /**
037: * Retrieve an array of <code>IPermission</code> objects based on the given parameters.
038: * Includes inherited <code>Permissions</code>. Any null parameters will be ignored.
039: *
040: * @param principal IAuthorizationPrincipal
041: * @param activity String
042: * @param target String
043: * @return IPermission[]
044: * @exception AuthorizationException
045: */
046: public IPermission[] getAllPermissions(
047: IAuthorizationPrincipal principal, String activity,
048: String target) throws AuthorizationException {
049: return principal
050: .getAllPermissions(getOwner(), activity, target);
051: }
052:
053: /**
054: * @return org.jasig.portal.security.provider.AuthorizationImpl
055: */
056: AuthorizationImpl getAuthorizationService() {
057: return authorizationService;
058: }
059:
060: /**
061: * Returns <code>IAuthorizationPrincipals</code> granted <code>IPermissions</code>
062: * by the owner of this <code>IPermissionManager</code>, for the given <code>activity</code>
063: * and <code>target</code>. If either parameter is null, it is ignored.
064: *
065: * @return IAuthorizationPrincipal[]
066: * @param activity String - the Permission activity
067: * @param target String - the Permission target
068: */
069: public IAuthorizationPrincipal[] getAuthorizedPrincipals(
070: String activity, String target)
071: throws AuthorizationException {
072: return getAuthorizationService().getAuthorizedPrincipals(
073: getOwner(), activity, target);
074: }
075:
076: /**
077: * @return java.lang.String
078: */
079: public java.lang.String getOwner() {
080: return owner;
081: }
082:
083: /**
084: * Retrieve an array of IPermission objects based on the given parameters. Any null parameters
085: * will be ignored.
086: *
087: * @param activity String
088: * @param target String
089: * @return IPermission[]
090: * @exception AuthorizationException
091: */
092: public IPermission[] getPermissions(String activity, String target)
093: throws AuthorizationException {
094: return getAuthorizationService().getPermissionsForOwner(
095: getOwner(), activity, target);
096: }
097:
098: /**
099: * Retrieve an array of IPermission objects based on the given parameters. Any null parameters
100: * will be ignored.
101: *
102: * @param principal IAuthorizationPrincipal
103: * @param activity String
104: * @param target String
105: * @return IPermission[]
106: * @exception AuthorizationException
107: */
108: public IPermission[] getPermissions(
109: IAuthorizationPrincipal principal, String activity,
110: String target) throws AuthorizationException {
111: return principal.getPermissions(getOwner(), activity, target);
112: }
113: }
|