Subversion Repository Public Repository

litesoft

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

Diff revisions: vs.
  @@ -2,7 +2,6 @@
2 2
3 3 import java.util.*;
4 4
5 - import org.litesoft.core.simpletypes.*;
6 5 import org.litesoft.prioritizer.client.*;
7 6 import org.litesoft.security.*;
8 7 import org.litesoft.uispecification.*;
  @@ -13,7 +12,7 @@
13 12
14 13 public static synchronized ViewAccessControlManager get( UserView pUser )
15 14 {
16 - AccessKey zKey = new AccessKey( pUser );
15 + AccessKey zKey = pUser.getAccessKey();
17 16 ViewAccessControlManager zManager = CACHE.get( zKey );
18 17 if ( zManager == null )
19 18 {
  @@ -22,89 +21,6 @@
22 21 return zManager;
23 22 }
24 23
25 - private static class AccessKey
26 - {
27 - private int mFlags;
28 -
29 - private AccessKey( UserView pUser )
30 - {
31 - mFlags = bit( Role.BITS.sAdminFlag, pUser.getCanAdministrate() ) + //
32 - bit( Role.BITS.sRestrictedResourceMgrFlag, pUser.getRestrictedResourceManage() ) + //
33 - bit( Role.BITS.sSprAdminFlag, pUser.getSuperAdmin() ) + //
34 - bit( Role.BITS.sHelpDeskFlag, pUser.getHelpDeskMember() ) + //
35 - bit( Role.BITS.sNonGuestFlag, !pUser.isGuest() ) + //
36 - Role.BITS.BIT.none();
37 - TextLines zAllowedRoles = pUser.getCurrentRestrictedResourceAllowedRoles();
38 - for ( TextLine zRole : zAllowedRoles )
39 - {
40 - mFlags += Role.getBitFor( zRole.getLine() );
41 - }
42 - }
43 -
44 - private int bit( int zBit, Boolean zFlag )
45 - {
46 - return Boolean.TRUE.equals( zFlag ) ? zBit : 0;
47 - }
48 -
49 - private boolean isBit( int zBit )
50 - {
51 - return (0 != (mFlags & zBit));
52 - }
53 -
54 - public boolean isRole( Role pRole )
55 - {
56 - return isBit( pRole.getBit() );
57 - }
58 -
59 - public boolean isAdminFlag()
60 - {
61 - return isBit( Role.BITS.sAdminFlag );
62 - }
63 -
64 - public boolean isRestrictedResourceMgrFlag()
65 - {
66 - return isBit( Role.BITS.sRestrictedResourceMgrFlag );
67 - }
68 -
69 - public boolean isSprAdminFlag()
70 - {
71 - return isBit( Role.BITS.sSprAdminFlag );
72 - }
73 -
74 - public boolean isHelpDeskFlag()
75 - {
76 - return isBit( Role.BITS.sHelpDeskFlag );
77 - }
78 -
79 - public boolean isNonGuest()
80 - {
81 - return isBit( Role.BITS.sNonGuestFlag );
82 - }
83 -
84 - @Override
85 - public boolean equals( Object o )
86 - {
87 - if ( this == o )
88 - {
89 - return true;
90 - }
91 - if ( o == null || getClass() != o.getClass() )
92 - {
93 - return false;
94 - }
95 -
96 - AccessKey that = (AccessKey) o;
97 -
98 - return this.mFlags == that.mFlags;
99 - }
100 -
101 - @Override
102 - public int hashCode()
103 - {
104 - return mFlags;
105 - }
106 - }
107 -
108 24 private static void addSection( List<ViewDef[]> pSections, boolean pFlag, ViewDef[] pViewDefs )
109 25 {
110 26 if ( pFlag && (pViewDefs != null) )
  @@ -118,11 +34,11 @@
118 34 List<ViewDef[]> zSections = new ArrayList<ViewDef[]>();
119 35 zSections.add( ViewDefs.ANY_USER );
120 36
121 - // addSection( zSections, pKey.isNonGuest(), ViewDefs.ANY_NON_GUEST );
122 - addSection( zSections, pKey.isAdminFlag(), ViewDefs.CAN_RESTRICTED_RESOURCE_ADMIN );
123 - addSection( zSections, pKey.isHelpDeskFlag(), ViewDefs.CAN_HELP_DESK );
124 - addSection( zSections, pKey.isRestrictedResourceMgrFlag(), ViewDefs.CAN_MANAGE_RESTRICTED_RESOURCES );
125 - addSection( zSections, pKey.isSprAdminFlag(), ViewDefs.CAN_SUPER_ADMIN );
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 );
126 42
127 43 return new ViewAccessControlManager.Only( zSections );
128 44 }