25 |
25 |
import eu.etaxonomy.cdm.api.application.CdmApplicationState;
|
26 |
26 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
|
27 |
27 |
import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
|
|
28 |
import eu.etaxonomy.cdm.api.utility.CdmUserHelper;
|
|
29 |
import eu.etaxonomy.cdm.api.utility.RoleProber;
|
28 |
30 |
import eu.etaxonomy.cdm.model.permission.Group;
|
29 |
31 |
import eu.etaxonomy.cdm.model.permission.User;
|
30 |
32 |
import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
|
|
33 |
import eu.etaxonomy.cdm.persistence.hibernate.permission.Role;
|
31 |
34 |
import eu.etaxonomy.taxeditor.model.IContextListener;
|
32 |
35 |
import eu.etaxonomy.taxeditor.model.MessagingUtils;
|
33 |
36 |
|
... | ... | |
48 |
51 |
public static final String ACCOUNT_LOCKED_MESSAGE = "Account is locked";
|
49 |
52 |
public static final String EMPTY_CREDENTIALS_MESSAGE = "Login and/or Password empty";
|
50 |
53 |
|
|
54 |
|
|
55 |
private CdmUserHelper userHelper = null;
|
|
56 |
|
51 |
57 |
public LoginManager(){
|
52 |
58 |
CdmStore.getContextManager().addContextListener(this);
|
|
59 |
|
53 |
60 |
}
|
54 |
61 |
|
55 |
62 |
/**
|
... | ... | |
106 |
113 |
} catch(LockedException e){
|
107 |
114 |
throw new CdmAuthenticationException(ACCOUNT_LOCKED_MESSAGE, e);
|
108 |
115 |
} catch(IllegalArgumentException e){
|
|
116 |
e.printStackTrace();
|
109 |
117 |
throw new CdmAuthenticationException(EMPTY_CREDENTIALS_MESSAGE, e);
|
110 |
118 |
}
|
111 |
119 |
|
... | ... | |
163 |
171 |
* @return
|
164 |
172 |
*/
|
165 |
173 |
public boolean isAdmin() {
|
166 |
|
// FIXME until we have rights implemented properly we do this
|
167 |
|
// by a simple string check. This has to change
|
168 |
|
|
169 |
|
return "admin".equals(getAuthenticatedUser().getUsername());
|
|
174 |
if (userHelper == null){
|
|
175 |
userHelper = new CdmUserHelper();
|
|
176 |
}
|
|
177 |
boolean result = userHelper.userIs(new RoleProber(Role.ROLE_ADMIN));
|
|
178 |
return result;
|
170 |
179 |
}
|
171 |
180 |
|
|
181 |
/**
|
|
182 |
* Whether the current user has the role user manager
|
|
183 |
*
|
|
184 |
* @return
|
|
185 |
*/
|
|
186 |
public boolean isUserManager() {
|
|
187 |
if (userHelper == null){
|
|
188 |
userHelper = new CdmUserHelper();
|
|
189 |
}
|
|
190 |
boolean result = userHelper.userIs(new RoleProber(Role.ROLE_USER_MANAGER));
|
|
191 |
return result;
|
|
192 |
}
|
|
193 |
|
172 |
194 |
@Override
|
173 |
195 |
public void contextAboutToStop(IMemento memento, IProgressMonitor monitor) {
|
174 |
196 |
|
fix #8925: and fix #8927 use role_admin for check whether user is admin and check for user_manager for right to edit pwd