|
@@ -9,79 +9,64 @@ |
9 |
9 |
|
import org.litesoft.security.*; |
10 |
10 |
|
|
11 |
11 |
|
public final class UserView extends UserViewGO implements Precommitable, |
12 |
|
- |
SecurityUserView<UserView> |
13 |
|
- |
{ |
|
12 |
+ |
SecurityUserView<UserView> { |
14 |
13 |
|
@Deprecated |
15 |
14 |
|
protected UserView() // For Serialization |
16 |
15 |
|
{ |
17 |
16 |
|
} |
18 |
17 |
|
|
19 |
|
- |
protected UserView( boolean pNew, org.litesoft.bo.views.TransactionSet pTransactionSet ) |
20 |
|
- |
{ |
|
18 |
+ |
protected UserView( boolean pNew, org.litesoft.bo.views.TransactionSet pTransactionSet ) { |
21 |
19 |
|
super( pNew, pTransactionSet ); |
22 |
20 |
|
} |
23 |
21 |
|
|
24 |
|
- |
public static UserView createNew() |
25 |
|
- |
{ |
|
22 |
+ |
public static UserView createNew() { |
26 |
23 |
|
UserView zVO = new UserView( true, UserViewDataProvider.getInstance().createTransactionSet() ); |
27 |
24 |
|
zVO.initialize(); |
28 |
25 |
|
return zVO; |
29 |
26 |
|
} |
30 |
27 |
|
|
31 |
28 |
|
@Override |
32 |
|
- |
public void aboutToCommit() |
33 |
|
- |
{ |
34 |
|
- |
if ( Objects.areNotNull( getCurrentPassword(), getNewPassword(), getConfirmPassword() ) ) |
35 |
|
- |
{ |
|
29 |
+ |
public void aboutToCommit() { |
|
30 |
+ |
if ( Objects.areNotNull( getCurrentPassword(), getNewPassword(), getConfirmPassword() ) ) { |
36 |
31 |
|
setResetPassword( false ); |
37 |
32 |
|
clearPasswordFields(); |
38 |
33 |
|
} |
39 |
34 |
|
} |
40 |
35 |
|
|
41 |
|
- |
public UserView clearPasswordFields() |
42 |
|
- |
{ |
|
36 |
+ |
public UserView clearPasswordFields() { |
43 |
37 |
|
setCurrentPassword( null ); |
44 |
38 |
|
setNewPassword( null ); |
45 |
39 |
|
setConfirmPassword( null ); |
46 |
40 |
|
return this; |
47 |
41 |
|
} |
48 |
42 |
|
|
49 |
|
- |
public String getFullName() |
50 |
|
- |
{ |
|
43 |
+ |
public String getFullName() { |
51 |
44 |
|
String rv = getFirstName() + " "; |
52 |
|
- |
if ( Strings.isNotNullOrEmpty( getMiddleInitial() ) ) |
53 |
|
- |
{ |
|
45 |
+ |
if ( Strings.isNotNullOrEmpty( getMiddleInitial() ) ) { |
54 |
46 |
|
rv += getMiddleInitial() + ". "; |
55 |
47 |
|
} |
56 |
48 |
|
return rv + getLastName(); |
57 |
49 |
|
} |
58 |
50 |
|
|
59 |
|
- |
public boolean canResetPassword() |
60 |
|
- |
{ |
|
51 |
+ |
public boolean canResetPassword() { |
61 |
52 |
|
return anyOf( getHelpDeskMember(), getRestrictedResourceManage(), getSuperAdmin() ); |
62 |
53 |
|
} |
63 |
54 |
|
|
64 |
|
- |
public boolean canChange_HelpDeskMember() |
65 |
|
- |
{ |
|
55 |
+ |
public boolean canChange_HelpDeskMember() { |
66 |
56 |
|
return anyOf( getHelpDeskMember(), getSuperAdmin() ); |
67 |
57 |
|
} |
68 |
58 |
|
|
69 |
|
- |
public boolean canChange_RestrictedResourceManage() |
70 |
|
- |
{ |
|
59 |
+ |
public boolean canChange_RestrictedResourceManage() { |
71 |
60 |
|
return anyOf( getRestrictedResourceManage(), getSuperAdmin() ); |
72 |
61 |
|
} |
73 |
62 |
|
|
74 |
|
- |
public boolean canChange_SuperAdmin() |
75 |
|
- |
{ |
|
63 |
+ |
public boolean canChange_SuperAdmin() { |
76 |
64 |
|
return Boolean.TRUE.equals( getSuperAdmin() ); |
77 |
65 |
|
} |
78 |
66 |
|
|
79 |
|
- |
private boolean anyOf( Boolean... pFlags ) |
80 |
|
- |
{ |
81 |
|
- |
for ( Boolean zFlag : pFlags ) |
82 |
|
- |
{ |
83 |
|
- |
if ( Boolean.TRUE.equals( zFlag ) ) |
84 |
|
- |
{ |
|
67 |
+ |
private boolean anyOf( Boolean... pFlags ) { |
|
68 |
+ |
for ( Boolean zFlag : pFlags ) { |
|
69 |
+ |
if ( Boolean.TRUE.equals( zFlag ) ) { |
85 |
70 |
|
return true; |
86 |
71 |
|
} |
87 |
72 |
|
} |
|
@@ -93,46 +78,38 @@ |
93 |
78 |
|
private AlternateRestrictedResourceOption[] mAlternateRestrictedResourceOptions; |
94 |
79 |
|
|
95 |
80 |
|
@Override |
96 |
|
- |
public AlternateRestrictedResourceOption[] getAlternateRestrictedResourceOptions() |
97 |
|
- |
{ |
|
81 |
+ |
public AlternateRestrictedResourceOption[] getAlternateRestrictedResourceOptions() { |
98 |
82 |
|
return mAlternateRestrictedResourceOptions; |
99 |
83 |
|
} |
100 |
84 |
|
|
101 |
|
- |
public void setAlternateRestrictedResourceOptions( AlternateRestrictedResourceOption[] pAlternateRestrictedResourceOptions ) |
102 |
|
- |
{ |
|
85 |
+ |
public void setAlternateRestrictedResourceOptions( AlternateRestrictedResourceOption[] pAlternateRestrictedResourceOptions ) { |
103 |
86 |
|
mAlternateRestrictedResourceOptions = pAlternateRestrictedResourceOptions; |
104 |
87 |
|
} |
105 |
88 |
|
|
106 |
89 |
|
private SecurityRestrictedResourceView mCurrentRestrictedResource; |
107 |
90 |
|
|
108 |
91 |
|
@Override |
109 |
|
- |
public SecurityRestrictedResourceView getCurrentRestrictedResource() |
110 |
|
- |
{ |
|
92 |
+ |
public SecurityRestrictedResourceView getCurrentRestrictedResource() { |
111 |
93 |
|
return mCurrentRestrictedResource; |
112 |
94 |
|
} |
113 |
95 |
|
|
114 |
|
- |
public void setCurrentRestrictedResource( SecurityRestrictedResourceView pCurrentRestrictedResource ) |
115 |
|
- |
{ |
|
96 |
+ |
public void setCurrentRestrictedResource( SecurityRestrictedResourceView pCurrentRestrictedResource ) { |
116 |
97 |
|
mCurrentRestrictedResource = pCurrentRestrictedResource; |
117 |
98 |
|
} |
118 |
99 |
|
|
119 |
|
- |
public boolean isDemo() |
120 |
|
- |
{ |
|
100 |
+ |
public boolean isDemo() { |
121 |
101 |
|
return Boolean.TRUE.equals( getDemoUser() ); |
122 |
102 |
|
} |
123 |
103 |
|
|
124 |
|
- |
public boolean isGuest() |
125 |
|
- |
{ |
|
104 |
+ |
public boolean isGuest() { |
126 |
105 |
|
return false; // Todo: Add real guest flag |
127 |
106 |
|
} |
128 |
107 |
|
|
129 |
|
- |
public static UserView get( IViewObject[] pViewObjects, int pIndex ) |
130 |
|
- |
{ |
|
108 |
+ |
public static UserView get( IViewObject[] pViewObjects, int pIndex ) { |
131 |
109 |
|
return ((pViewObjects != null) && (pIndex < pViewObjects.length)) ? (UserView) pViewObjects[pIndex] : null; |
132 |
110 |
|
} |
133 |
111 |
|
|
134 |
|
- |
public AccessKey getAccessKey() |
135 |
|
- |
{ |
|
112 |
+ |
public AccessKey getAccessKey() { |
136 |
113 |
|
int zFlags = BitFlag.bit( Permissions.sAdminFlag, getCanAdministrate() ) + // |
137 |
114 |
|
BitFlag.bit( Permissions.sRestrictedResourceMgrFlag, getRestrictedResourceManage() ) + // |
138 |
115 |
|
BitFlag.bit( Permissions.sSprAdminFlag, getSuperAdmin() ) + // |
|
@@ -140,8 +117,7 @@ |
140 |
117 |
|
BitFlag.bit( Permissions.sNonGuestFlag, !isGuest() ) + // |
141 |
118 |
|
Permissions.BIT.none(); |
142 |
119 |
|
TextLines zAllowedRoles = getCurrentRestrictedResourceAllowedRoles(); |
143 |
|
- |
for ( TextLine zRole : zAllowedRoles ) |
144 |
|
- |
{ |
|
120 |
+ |
for ( TextLine zRole : zAllowedRoles ) { |
145 |
121 |
|
zFlags += Role.getBitFor( zRole.getLine() ); |
146 |
122 |
|
} |
147 |
123 |
|
return new AccessKey( zFlags ); |