|
@@ -9,38 +9,32 @@ |
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 |
36 |
|
@Override |
42 |
|
- |
public UserView clearPasswordFields() |
43 |
|
- |
{ |
|
37 |
+ |
public UserView clearPasswordFields() { |
44 |
38 |
|
setCurrentPassword( null ); |
45 |
39 |
|
setNewPassword( null ); |
46 |
40 |
|
setConfirmPassword( null ); |
|
@@ -48,47 +42,37 @@ |
48 |
42 |
|
} |
49 |
43 |
|
|
50 |
44 |
|
@Override |
51 |
|
- |
public String getFullName() |
52 |
|
- |
{ |
|
45 |
+ |
public String getFullName() { |
53 |
46 |
|
String rv = getFirstName() + " "; |
54 |
|
- |
if ( Strings.isNotNullOrEmpty( getMiddleInitial() ) ) |
55 |
|
- |
{ |
|
47 |
+ |
if ( Strings.isNotNullOrEmpty( getMiddleInitial() ) ) { |
56 |
48 |
|
rv += getMiddleInitial() + ". "; |
57 |
49 |
|
} |
58 |
50 |
|
return rv + getLastName(); |
59 |
51 |
|
} |
60 |
52 |
|
|
61 |
|
- |
public boolean canResetPassword() |
62 |
|
- |
{ |
|
53 |
+ |
public boolean canResetPassword() { |
63 |
54 |
|
return anyOf( getHelpDeskMember(), getRestrictedResourceManage(), getSuperAdmin() ); |
64 |
55 |
|
} |
65 |
56 |
|
|
66 |
|
- |
public boolean canSetCustomer() |
67 |
|
- |
{ |
|
57 |
+ |
public boolean canSetCustomer() { |
68 |
58 |
|
return anyOf( getHelpDeskMember(), getRestrictedResourceManage(), getSuperAdmin() ); |
69 |
59 |
|
} |
70 |
60 |
|
|
71 |
|
- |
public boolean canChange_HelpDeskMember() |
72 |
|
- |
{ |
|
61 |
+ |
public boolean canChange_HelpDeskMember() { |
73 |
62 |
|
return anyOf( getHelpDeskMember(), getSuperAdmin() ); |
74 |
63 |
|
} |
75 |
64 |
|
|
76 |
|
- |
public boolean canChange_RestrictedResourceManage() |
77 |
|
- |
{ |
|
65 |
+ |
public boolean canChange_RestrictedResourceManage() { |
78 |
66 |
|
return anyOf( getRestrictedResourceManage(), getSuperAdmin() ); |
79 |
67 |
|
} |
80 |
68 |
|
|
81 |
|
- |
public boolean canChange_SuperAdmin() |
82 |
|
- |
{ |
|
69 |
+ |
public boolean canChange_SuperAdmin() { |
83 |
70 |
|
return Boolean.TRUE.equals( getSuperAdmin() ); |
84 |
71 |
|
} |
85 |
72 |
|
|
86 |
|
- |
private boolean anyOf( Boolean... pFlags ) |
87 |
|
- |
{ |
88 |
|
- |
for ( Boolean zFlag : pFlags ) |
89 |
|
- |
{ |
90 |
|
- |
if ( Boolean.TRUE.equals( zFlag ) ) |
91 |
|
- |
{ |
|
73 |
+ |
private boolean anyOf( Boolean... pFlags ) { |
|
74 |
+ |
for ( Boolean zFlag : pFlags ) { |
|
75 |
+ |
if ( Boolean.TRUE.equals( zFlag ) ) { |
92 |
76 |
|
return true; |
93 |
77 |
|
} |
94 |
78 |
|
} |
|
@@ -99,47 +83,39 @@ |
99 |
83 |
|
|
100 |
84 |
|
private AlternateRestrictedResourceOption[] mAlternateRestrictedResourceOptions; |
101 |
85 |
|
|
102 |
|
- |
public AlternateRestrictedResourceOption[] getAlternateRestrictedResourceOptions() |
103 |
|
- |
{ |
|
86 |
+ |
public AlternateRestrictedResourceOption[] getAlternateRestrictedResourceOptions() { |
104 |
87 |
|
return mAlternateRestrictedResourceOptions; |
105 |
88 |
|
} |
106 |
89 |
|
|
107 |
|
- |
public void setAlternateRestrictedResourceOptions( AlternateRestrictedResourceOption[] pAlternateRestrictedResourceOptions ) |
108 |
|
- |
{ |
|
90 |
+ |
public void setAlternateRestrictedResourceOptions( AlternateRestrictedResourceOption[] pAlternateRestrictedResourceOptions ) { |
109 |
91 |
|
mAlternateRestrictedResourceOptions = pAlternateRestrictedResourceOptions; |
110 |
92 |
|
} |
111 |
93 |
|
|
112 |
94 |
|
private SecurityRestrictedResourceView mCurrentRestrictedResource; |
113 |
95 |
|
|
114 |
96 |
|
@Override |
115 |
|
- |
public SecurityRestrictedResourceView getCurrentRestrictedResource() |
116 |
|
- |
{ |
|
97 |
+ |
public SecurityRestrictedResourceView getCurrentRestrictedResource() { |
117 |
98 |
|
return mCurrentRestrictedResource; |
118 |
99 |
|
} |
119 |
100 |
|
|
120 |
|
- |
public void setCurrentRestrictedResource( SecurityRestrictedResourceView pCurrentRestrictedResource ) |
121 |
|
- |
{ |
|
101 |
+ |
public void setCurrentRestrictedResource( SecurityRestrictedResourceView pCurrentRestrictedResource ) { |
122 |
102 |
|
mCurrentRestrictedResource = pCurrentRestrictedResource; |
123 |
103 |
|
} |
124 |
104 |
|
|
125 |
|
- |
public boolean isDemo() |
126 |
|
- |
{ |
|
105 |
+ |
public boolean isDemo() { |
127 |
106 |
|
return Boolean.TRUE.equals( getDemoUser() ); |
128 |
107 |
|
} |
129 |
108 |
|
|
130 |
|
- |
public boolean isGuest() |
131 |
|
- |
{ |
|
109 |
+ |
public boolean isGuest() { |
132 |
110 |
|
return false; // Todo: Add real guest flag |
133 |
111 |
|
} |
134 |
112 |
|
|
135 |
|
- |
public static UserView get( IViewObject[] pViewObjects, int pIndex ) |
136 |
|
- |
{ |
|
113 |
+ |
public static UserView get( IViewObject[] pViewObjects, int pIndex ) { |
137 |
114 |
|
return ((pViewObjects != null) && (pIndex < pViewObjects.length)) ? (UserView) pViewObjects[pIndex] : null; |
138 |
115 |
|
} |
139 |
116 |
|
|
140 |
117 |
|
@Override |
141 |
|
- |
public AccessKey getAccessKey() |
142 |
|
- |
{ |
|
118 |
+ |
public AccessKey getAccessKey() { |
143 |
119 |
|
int zFlags = BitFlag.bit( Permissions.sAdminFlag, getCanAdministrate() ) + // |
144 |
120 |
|
BitFlag.bit( Permissions.sRestrictedResourceMgrFlag, getRestrictedResourceManage() ) + // |
145 |
121 |
|
BitFlag.bit( Permissions.sSprAdminFlag, getSuperAdmin() ) + // |
|
@@ -148,8 +124,7 @@ |
148 |
124 |
|
BitFlag.bit( Permissions.sNonGuestFlag, !isGuest() ) + // |
149 |
125 |
|
Permissions.BIT.none(); |
150 |
126 |
|
TextLines zAllowedRoles = getCurrentRestrictedResourceAllowedRoles(); |
151 |
|
- |
for ( TextLine zRole : zAllowedRoles ) |
152 |
|
- |
{ |
|
127 |
+ |
for ( TextLine zRole : zAllowedRoles ) { |
153 |
128 |
|
zFlags += Role.getBitFor( zRole.getLine() ); |
154 |
129 |
|
} |
155 |
130 |
|
return new AccessKey( zFlags ); |