Subversion Repository Public Repository

litesoft

Diff Revisions 478 vs 479 for /trunk/GWT_Sandbox/Prioritizer/src/org/litesoft/prioritizer/client/boviews/UserViewAccessControlFactory.java

Diff revisions: vs.
  @@ -2,12 +2,18 @@
2 2
3 3 import java.util.*;
4 4
5 - import org.litesoft.prioritizer.client.*;
6 5 import org.litesoft.security.*;
7 6 import org.litesoft.uispecification.*;
8 7
9 8 public class UserViewAccessControlFactory
10 9 {
10 + private static ViewDefSecuredSet[] sViewDefSecuritySets;
11 +
12 + public static void setViewDefSecuritySets( ViewDefSecuredSet[] pViewDefSecuritySets )
13 + {
14 + sViewDefSecuritySets = pViewDefSecuritySets;
15 + }
16 +
11 17 private static final Map<AccessKey, ViewAccessControlManager> CACHE = new HashMap<AccessKey, ViewAccessControlManager>();
12 18
13 19 public static synchronized ViewAccessControlManager get( UserView pUser )
  @@ -21,25 +27,16 @@
21 27 return zManager;
22 28 }
23 29
24 - private static void addSection( List<ViewDef[]> pSections, boolean pFlag, ViewDef[] pViewDefs )
25 - {
26 - if ( pFlag && (pViewDefs != null) )
27 - {
28 - pSections.add( pViewDefs );
29 - }
30 - }
31 -
32 30 private static ViewAccessControlManager createManager( AccessKey pKey )
33 31 {
34 32 List<ViewDef[]> zSections = new ArrayList<ViewDef[]>();
35 - zSections.add( ViewDefs.ANY_USER );
36 -
37 - // addSection( zSections, Permissions.isNonGuest( pKey ), ViewDefs.ANY_NON_GUEST );
38 - addSection( zSections, Permissions.isAdminFlag( pKey ), ViewDefs.CAN_RESTRICTED_RESOURCE_ADMIN );
39 - addSection( zSections, Permissions.isHelpDeskFlag( pKey ), ViewDefs.CAN_HELP_DESK );
40 - addSection( zSections, Permissions.isRestrictedResourceMgrFlag( pKey ), ViewDefs.CAN_MANAGE_RESTRICTED_RESOURCES );
41 - addSection( zSections, Permissions.isSprAdminFlag( pKey ), ViewDefs.CAN_SUPER_ADMIN );
42 -
33 + for ( ViewDefSecuredSet zSet : sViewDefSecuritySets )
34 + {
35 + if ( zSet.isAllowed( pKey ) )
36 + {
37 + zSections.add( zSet.getViewDefs() );
38 + }
39 + }
43 40 return new ViewAccessControlManager.Only( zSections );
44 41 }
45 42 }