Bug 508835: Add additional check for username in UserVerifier
Change-Id: I7742b531264a0b0f45b576a40821ef08fd165d7b
diff --git a/bundles/org.eclipse.emf.emfstore.server/src/org/eclipse/emf/emfstore/internal/server/accesscontrol/authentication/verifiers/UserVerifier.java b/bundles/org.eclipse.emf.emfstore.server/src/org/eclipse/emf/emfstore/internal/server/accesscontrol/authentication/verifiers/UserVerifier.java
index e51a602..a234e77 100644
--- a/bundles/org.eclipse.emf.emfstore.server/src/org/eclipse/emf/emfstore/internal/server/accesscontrol/authentication/verifiers/UserVerifier.java
+++ b/bundles/org.eclipse.emf.emfstore.server/src/org/eclipse/emf/emfstore/internal/server/accesscontrol/authentication/verifiers/UserVerifier.java
@@ -64,16 +64,24 @@
checkClientVersion(clientVersionInfo);
final String preparedPassword = preparePassword(password);
+ final String superUser = ServerConfiguration.getProperties()
+ .getProperty(ServerConfiguration.SUPER_USER, ServerConfiguration.SUPER_USER_DEFAULT);
- if (verifySuperUser(username, preparedPassword) || verifyPassword(username, preparedPassword)) {
- final AuthenticationInformation createAuthenticationInfo = createAuthenticationInfo();
- createAuthenticationInfo.setResolvedACUser(ModelUtil.clone(findUser(username)));
- return createAuthenticationInfo.toAPI();
+ if (verifySuperUser(username, preparedPassword)) {
+ return createAuthInfo(username);
+ } else if (!username.equals(superUser) && verifyPassword(username, preparedPassword)) {
+ return createAuthInfo(username);
}
throw new AccessControlException();
}
+ private ESAuthenticationInformation createAuthInfo(String username) throws AccessControlException {
+ final AuthenticationInformation createAuthenticationInfo = createAuthenticationInfo();
+ createAuthenticationInfo.setResolvedACUser(ModelUtil.clone(findUser(username)));
+ return createAuthenticationInfo.toAPI();
+ }
+
/**
* Find the user with the given user name.
*