01: /* Copyright 2003 The JA-SIG Collaborative. All rights reserved.
02: * See license distributed with this file and
03: * available online at http://www.uportal.org/license.html
04: */
05:
06: package org.jasig.portal.security.provider;
07:
08: import java.util.Arrays;
09: import java.util.Collections;
10:
11: import org.jasig.portal.EntityIdentifier;
12: import org.jasig.portal.security.IAuthorizationPrincipal;
13: import org.jasig.portal.security.IPermission;
14: import org.jasig.portal.security.IPermissionSet;
15:
16: /**
17: * @author Dan Ellentuck, de3@columbia.edu
18: * @version $Revision: 42158 $
19: *
20: * Aggregates <code>IPermissions</code> for a single
21: * <code>IAuthorizationPrincipal</code> so that the permissions can be
22: * cached as a unit by the <code>EntityCachingService</code>.
23: * <p>
24: * Separating caching of principals and permissions lets a client keep
25: * a reference to a principal over time while being guaranteed the
26: * latest version of its permissions.
27: */
28:
29: public class PermissionSetImpl implements IPermissionSet {
30:
31: private EntityIdentifier entityIdentifier;
32: private IPermission[] permissions;
33: private static Class IPS_TYPE = IPermissionSet.class;
34:
35: public PermissionSetImpl(IPermission[] perms,
36: IAuthorizationPrincipal principal) {
37: this (perms, principal.getPrincipalString(), IPS_TYPE);
38: }
39:
40: public PermissionSetImpl(IPermission[] perms, String key, Class type) {
41: super ();
42: permissions = perms;
43: entityIdentifier = new EntityIdentifier(key, type);
44: }
45:
46: /**
47: * @return IPermission[]
48: */
49: public IPermission[] getPermissions() {
50: return permissions;
51: }
52:
53: /**
54: * @return EntityIdentifier IPermission[]
55: */
56: public EntityIdentifier getEntityIdentifier() {
57: return entityIdentifier;
58: }
59:
60: public String toString() {
61: StringBuffer sb = new StringBuffer();
62: sb.append("PermissionSetImpl: entitityIdentifier=["
63: + this .entityIdentifier + "]");
64: sb.append(" permissions: [" + Arrays.toString(permissions)
65: + "]");
66: return sb.toString();
67: }
68:
69: }
|