diff options
37 files changed, 133 insertions, 77 deletions
diff --git a/.classpath b/.classpath index a3944fe8a..d6db524d1 100644 --- a/.classpath +++ b/.classpath @@ -45,20 +45,20 @@ <classpathentry kind="lib" path="lib/commons-io-2.5.jar"/> <classpathentry kind="lib" path="lib/slf4j-api-1.7.24.jar"/> <classpathentry kind="lib" path="lib/chardet.jar"/> - <classpathentry kind="lib" path="lib/jetty-client-9.2.21.v20170120.jar"/> - <classpathentry kind="lib" path="lib/jetty-continuation-9.2.21.v20170120.jar"/> - <classpathentry kind="lib" path="lib/jetty-deploy-9.2.21.v20170120.jar"/> - <classpathentry kind="lib" path="lib/jetty-http-9.2.21.v20170120.jar"/> - <classpathentry kind="lib" path="lib/jetty-io-9.2.21.v20170120.jar"/> - <classpathentry kind="lib" path="lib/jetty-jmx-9.2.21.v20170120.jar"/> - <classpathentry kind="lib" path="lib/jetty-proxy-9.2.21.v20170120.jar"/> - <classpathentry kind="lib" path="lib/jetty-security-9.2.21.v20170120.jar"/> - <classpathentry kind="lib" path="lib/jetty-server-9.2.21.v20170120.jar"/> - <classpathentry kind="lib" path="lib/jetty-servlet-9.2.21.v20170120.jar"/> - <classpathentry kind="lib" path="lib/jetty-servlets-9.2.21.v20170120.jar"/> - <classpathentry kind="lib" path="lib/jetty-util-9.2.21.v20170120.jar"/> - <classpathentry kind="lib" path="lib/jetty-webapp-9.2.21.v20170120.jar"/> - <classpathentry kind="lib" path="lib/jetty-xml-9.2.21.v20170120.jar"/> + <classpathentry kind="lib" path="lib/jetty-client-9.4.6.v20170531.jar"/> + <classpathentry kind="lib" path="lib/jetty-continuation-9.4.6.v20170531.jar"/> + <classpathentry kind="lib" path="lib/jetty-deploy-9.4.6.v20170531.jar"/> + <classpathentry kind="lib" path="lib/jetty-http-9.4.6.v20170531.jar"/> + <classpathentry kind="lib" path="lib/jetty-io-9.4.6.v20170531.jar"/> + <classpathentry kind="lib" path="lib/jetty-jmx-9.4.6.v20170531.jar"/> + <classpathentry kind="lib" path="lib/jetty-proxy-9.4.6.v20170531.jar"/> + <classpathentry kind="lib" path="lib/jetty-security-9.4.6.v20170531.jar"/> + <classpathentry kind="lib" path="lib/jetty-server-9.4.6.v20170531.jar"/> + <classpathentry kind="lib" path="lib/jetty-servlet-9.4.6.v20170531.jar"/> + <classpathentry kind="lib" path="lib/jetty-servlets-9.4.6.v20170531.jar"/> + <classpathentry kind="lib" path="lib/jetty-util-9.4.6.v20170531.jar"/> + <classpathentry kind="lib" path="lib/jetty-webapp-9.4.6.v20170531.jar"/> + <classpathentry kind="lib" path="lib/jetty-xml-9.4.6.v20170531.jar"/> <classpathentry kind="lib" path="lib/httpclient-4.5.3.jar"/> <classpathentry kind="lib" path="lib/httpmime-4.5.3.jar"/> <classpathentry kind="lib" path="lib/noggit-0.6.jar"/> @@ -202,20 +202,20 @@ <pathelement location="${lib}/javax.servlet-api-3.1.0.jar" /> <pathelement location="${lib}/jcifs-1.3.17.jar" /> <pathelement location="${lib}/jcl-over-slf4j-1.7.24.jar" /> - <pathelement location="${lib}/jetty-client-9.2.21.v20170120.jar" /> - <pathelement location="${lib}/jetty-continuation-9.2.21.v20170120.jar" /> - <pathelement location="${lib}/jetty-deploy-9.2.21.v20170120.jar" /> - <pathelement location="${lib}/jetty-http-9.2.21.v20170120.jar" /> - <pathelement location="${lib}/jetty-io-9.2.21.v20170120.jar" /> - <pathelement location="${lib}/jetty-jmx-9.2.21.v20170120.jar" /> - <pathelement location="${lib}/jetty-proxy-9.2.21.v20170120.jar" /> - <pathelement location="${lib}/jetty-security-9.2.21.v20170120.jar" /> - <pathelement location="${lib}/jetty-server-9.2.21.v20170120.jar" /> - <pathelement location="${lib}/jetty-servlet-9.2.21.v20170120.jar" /> - <pathelement location="${lib}/jetty-servlets-9.2.21.v20170120.jar" /> - <pathelement location="${lib}/jetty-util-9.2.21.v20170120.jar" /> - <pathelement location="${lib}/jetty-webapp-9.2.21.v20170120.jar" /> - <pathelement location="${lib}/jetty-xml-9.2.21.v20170120.jar" /> + <pathelement location="${lib}/jetty-client-9.4.6.v20170531.jar" /> + <pathelement location="${lib}/jetty-continuation-9.4.6.v20170531.jar" /> + <pathelement location="${lib}/jetty-deploy-9.4.6.v20170531.jar" /> + <pathelement location="${lib}/jetty-http-9.4.6.v20170531.jar" /> + <pathelement location="${lib}/jetty-io-9.4.6.v20170531.jar" /> + <pathelement location="${lib}/jetty-jmx-9.4.6.v20170531.jar" /> + <pathelement location="${lib}/jetty-proxy-9.4.6.v20170531.jar" /> + <pathelement location="${lib}/jetty-security-9.4.6.v20170531.jar" /> + <pathelement location="${lib}/jetty-server-9.4.6.v20170531.jar" /> + <pathelement location="${lib}/jetty-servlet-9.4.6.v20170531.jar" /> + <pathelement location="${lib}/jetty-servlets-9.4.6.v20170531.jar" /> + <pathelement location="${lib}/jetty-util-9.4.6.v20170531.jar" /> + <pathelement location="${lib}/jetty-webapp-9.4.6.v20170531.jar" /> + <pathelement location="${lib}/jetty-xml-9.4.6.v20170531.jar" /> <pathelement location="${lib}/jsch-0.1.54.jar" /> <pathelement location="${lib}/json-simple-1.1.1.jar" /> <pathelement location="${lib}/jsonic-1.2.0.jar" /> diff --git a/htroot/ConfigUser_p.java b/htroot/ConfigUser_p.java index 4572a1ae4..134b1bf16 100644 --- a/htroot/ConfigUser_p.java +++ b/htroot/ConfigUser_p.java @@ -25,6 +25,7 @@ import net.yacy.cora.protocol.RequestHeader; import net.yacy.cora.util.ConcurrentLog;
import net.yacy.data.UserDB;
import net.yacy.data.UserDB.AccessRight;
+import net.yacy.http.Jetty9HttpServerImpl;
import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
import net.yacy.server.serverObjects;
@@ -153,7 +154,8 @@ public class ConfigUser_p { } catch (final Exception e) {
ConcurrentLog.logException(e);
}
-
+ Jetty9HttpServerImpl jhttpserver = (Jetty9HttpServerImpl) sb.getHttpServer();
+ jhttpserver.resetUser(entry.getUserName());
} else {
prop.put("error", "1");
}
@@ -163,6 +165,8 @@ public class ConfigUser_p { prop.putHTML("username", username);
} else if (post.containsKey("delete")) {
sb.userDB.removeEntry(post.get("username"));
+ Jetty9HttpServerImpl jhttpserver = (Jetty9HttpServerImpl) sb.getHttpServer();
+ jhttpserver.removeUser(post.get("username"));
prop.put(serverObjects.ACTION_LOCATION, "ConfigAccountList_p.html"); // jump back to user list
}
diff --git a/lib/jetty-client-9.2.21.v20170120.jar b/lib/jetty-client-9.2.21.v20170120.jar Binary files differdeleted file mode 100644 index 40ab95909..000000000 --- a/lib/jetty-client-9.2.21.v20170120.jar +++ /dev/null diff --git a/lib/jetty-client-9.4.6.v20170531.jar b/lib/jetty-client-9.4.6.v20170531.jar Binary files differnew file mode 100644 index 000000000..8ff920208 --- /dev/null +++ b/lib/jetty-client-9.4.6.v20170531.jar diff --git a/lib/jetty-continuation-9.2.21.v20170120.jar b/lib/jetty-continuation-9.2.21.v20170120.jar Binary files differdeleted file mode 100644 index 4aac6404c..000000000 --- a/lib/jetty-continuation-9.2.21.v20170120.jar +++ /dev/null diff --git a/lib/jetty-continuation-9.4.6.v20170531.jar b/lib/jetty-continuation-9.4.6.v20170531.jar Binary files differnew file mode 100644 index 000000000..fb572848e --- /dev/null +++ b/lib/jetty-continuation-9.4.6.v20170531.jar diff --git a/lib/jetty-deploy-9.2.21.v20170120.jar b/lib/jetty-deploy-9.2.21.v20170120.jar Binary files differdeleted file mode 100644 index d535a6b2e..000000000 --- a/lib/jetty-deploy-9.2.21.v20170120.jar +++ /dev/null diff --git a/lib/jetty-deploy-9.4.6.v20170531.jar b/lib/jetty-deploy-9.4.6.v20170531.jar Binary files differnew file mode 100644 index 000000000..6b2759351 --- /dev/null +++ b/lib/jetty-deploy-9.4.6.v20170531.jar diff --git a/lib/jetty-http-9.2.21.v20170120.jar b/lib/jetty-http-9.2.21.v20170120.jar Binary files differdeleted file mode 100644 index 507952734..000000000 --- a/lib/jetty-http-9.2.21.v20170120.jar +++ /dev/null diff --git a/lib/jetty-http-9.4.6.v20170531.jar b/lib/jetty-http-9.4.6.v20170531.jar Binary files differnew file mode 100644 index 000000000..db4c0b89e --- /dev/null +++ b/lib/jetty-http-9.4.6.v20170531.jar diff --git a/lib/jetty-io-9.2.21.v20170120.jar b/lib/jetty-io-9.2.21.v20170120.jar Binary files differdeleted file mode 100644 index 5eafefc7c..000000000 --- a/lib/jetty-io-9.2.21.v20170120.jar +++ /dev/null diff --git a/lib/jetty-io-9.4.6.v20170531.jar b/lib/jetty-io-9.4.6.v20170531.jar Binary files differnew file mode 100644 index 000000000..170c6711a --- /dev/null +++ b/lib/jetty-io-9.4.6.v20170531.jar diff --git a/lib/jetty-jmx-9.2.21.v20170120.jar b/lib/jetty-jmx-9.2.21.v20170120.jar Binary files differdeleted file mode 100644 index 5f11c2fd4..000000000 --- a/lib/jetty-jmx-9.2.21.v20170120.jar +++ /dev/null diff --git a/lib/jetty-jmx-9.4.6.v20170531.jar b/lib/jetty-jmx-9.4.6.v20170531.jar Binary files differnew file mode 100644 index 000000000..6dd99d777 --- /dev/null +++ b/lib/jetty-jmx-9.4.6.v20170531.jar diff --git a/lib/jetty-proxy-9.2.21.v20170120.jar b/lib/jetty-proxy-9.2.21.v20170120.jar Binary files differdeleted file mode 100644 index b6469d17c..000000000 --- a/lib/jetty-proxy-9.2.21.v20170120.jar +++ /dev/null diff --git a/lib/jetty-proxy-9.4.6.v20170531.jar b/lib/jetty-proxy-9.4.6.v20170531.jar Binary files differnew file mode 100644 index 000000000..df606c047 --- /dev/null +++ b/lib/jetty-proxy-9.4.6.v20170531.jar diff --git a/lib/jetty-security-9.2.21.v20170120.jar b/lib/jetty-security-9.2.21.v20170120.jar Binary files differdeleted file mode 100644 index f54d07c38..000000000 --- a/lib/jetty-security-9.2.21.v20170120.jar +++ /dev/null diff --git a/lib/jetty-security-9.4.6.v20170531.jar b/lib/jetty-security-9.4.6.v20170531.jar Binary files differnew file mode 100644 index 000000000..e7d0eedac --- /dev/null +++ b/lib/jetty-security-9.4.6.v20170531.jar diff --git a/lib/jetty-server-9.2.21.v20170120.jar b/lib/jetty-server-9.2.21.v20170120.jar Binary files differdeleted file mode 100644 index 8a4c5fad4..000000000 --- a/lib/jetty-server-9.2.21.v20170120.jar +++ /dev/null diff --git a/lib/jetty-server-9.4.6.v20170531.jar b/lib/jetty-server-9.4.6.v20170531.jar Binary files differnew file mode 100644 index 000000000..4772d729f --- /dev/null +++ b/lib/jetty-server-9.4.6.v20170531.jar diff --git a/lib/jetty-servlet-9.2.21.v20170120.jar b/lib/jetty-servlet-9.2.21.v20170120.jar Binary files differdeleted file mode 100644 index 4fd13be32..000000000 --- a/lib/jetty-servlet-9.2.21.v20170120.jar +++ /dev/null diff --git a/lib/jetty-servlet-9.4.6.v20170531.jar b/lib/jetty-servlet-9.4.6.v20170531.jar Binary files differnew file mode 100644 index 000000000..a6138dc64 --- /dev/null +++ b/lib/jetty-servlet-9.4.6.v20170531.jar diff --git a/lib/jetty-servlets-9.2.21.v20170120.jar b/lib/jetty-servlets-9.2.21.v20170120.jar Binary files differdeleted file mode 100644 index c11519c1a..000000000 --- a/lib/jetty-servlets-9.2.21.v20170120.jar +++ /dev/null diff --git a/lib/jetty-servlets-9.4.6.v20170531.jar b/lib/jetty-servlets-9.4.6.v20170531.jar Binary files differnew file mode 100644 index 000000000..2387bb312 --- /dev/null +++ b/lib/jetty-servlets-9.4.6.v20170531.jar diff --git a/lib/jetty-util-9.2.21.v20170120.jar b/lib/jetty-util-9.2.21.v20170120.jar Binary files differdeleted file mode 100644 index edf6b9bea..000000000 --- a/lib/jetty-util-9.2.21.v20170120.jar +++ /dev/null diff --git a/lib/jetty-util-9.4.6.v20170531.jar b/lib/jetty-util-9.4.6.v20170531.jar Binary files differnew file mode 100644 index 000000000..c24989025 --- /dev/null +++ b/lib/jetty-util-9.4.6.v20170531.jar diff --git a/lib/jetty-webapp-9.2.21.v20170120.jar b/lib/jetty-webapp-9.2.21.v20170120.jar Binary files differdeleted file mode 100644 index a7f7dcd76..000000000 --- a/lib/jetty-webapp-9.2.21.v20170120.jar +++ /dev/null diff --git a/lib/jetty-webapp-9.4.6.v20170531.jar b/lib/jetty-webapp-9.4.6.v20170531.jar Binary files differnew file mode 100644 index 000000000..8665d3bf9 --- /dev/null +++ b/lib/jetty-webapp-9.4.6.v20170531.jar diff --git a/lib/jetty-xml-9.2.21.v20170120.jar b/lib/jetty-xml-9.2.21.v20170120.jar Binary files differdeleted file mode 100644 index f82eba9cf..000000000 --- a/lib/jetty-xml-9.2.21.v20170120.jar +++ /dev/null diff --git a/lib/jetty-xml-9.4.6.v20170531.jar b/lib/jetty-xml-9.4.6.v20170531.jar Binary files differnew file mode 100644 index 000000000..62b47dc5b --- /dev/null +++ b/lib/jetty-xml-9.4.6.v20170531.jar diff --git a/lib/jetty-9.2.19.v20160908.License b/lib/jetty.License index d64569567..d64569567 100644 --- a/lib/jetty-9.2.19.v20160908.License +++ b/lib/jetty.License @@ -36,7 +36,7 @@ <!-- the Solr version used in dependency section for all related dependencies --> <solr.version>6.6.0</solr.version> <!-- the Jetty version used in dependency section for all related dependencies --> - <jetty.version>9.2.21.v20170120</jetty.version> + <jetty.version>9.4.6.v20170531</jetty.version> <!-- properties used for filtering yacyBuildProperties.java --> <REPL_DATE>${DSTAMP}</REPL_DATE> diff --git a/source/net/yacy/http/Jetty9HttpServerImpl.java b/source/net/yacy/http/Jetty9HttpServerImpl.java index 4571cb34e..942ae52d9 100644 --- a/source/net/yacy/http/Jetty9HttpServerImpl.java +++ b/source/net/yacy/http/Jetty9HttpServerImpl.java @@ -340,7 +340,9 @@ public class Jetty9HttpServerImpl implements YaCyHttpServer { Jetty9YaCySecurityHandler hx = this.server.getChildHandlerByClass(Jetty9YaCySecurityHandler.class); if (hx != null) { YaCyLoginService loginservice = (YaCyLoginService) hx.getLoginService(); - loginservice.loadUser(username); + if (loginservice.removeUser(username)) { // remove old credential from cache + loginservice.loadUserInfo(username); + } } } diff --git a/source/net/yacy/http/MonitorHandler.java b/source/net/yacy/http/MonitorHandler.java index 8a7d22f63..e5b0c2acc 100644 --- a/source/net/yacy/http/MonitorHandler.java +++ b/source/net/yacy/http/MonitorHandler.java @@ -59,7 +59,7 @@ public class MonitorHandler extends AbstractHandler { final ConnectionInfo info = new ConnectionInfo( baseRequest.getScheme(), baseRequest.getRemoteAddr() + ":" + baseRequest.getRemotePort(), - baseRequest.getMethod() + " " + baseRequest.getUri().getPathAndParam(), + baseRequest.getMethod() + " " + baseRequest.getHttpURI().getPathQuery(), connection.hashCode(), baseRequest.getTimeStamp(), -1); diff --git a/source/net/yacy/http/YaCyLegacyCredential.java b/source/net/yacy/http/YaCyLegacyCredential.java index 13c217002..cb2f3785a 100644 --- a/source/net/yacy/http/YaCyLegacyCredential.java +++ b/source/net/yacy/http/YaCyLegacyCredential.java @@ -87,7 +87,7 @@ public class YaCyLegacyCredential extends Credential { } // normal users (and new admin pwd) for BASIC auth - if (hash.startsWith(MD5.__TYPE) && hash != null) { + if (hash.startsWith("MD5:") && hash != null) { boolean success = (Digest.encodeMD5Hex(foruser + ":" + Switchboard.getSwitchboard().getConfig(SwitchboardConstants.ADMIN_REALM,"YaCy")+":" + pw).equals(hash.substring(4))); // exception: allow the hash as pwd (used in bin/apicall.sh) if (!success && foruser.equals(Switchboard.getSwitchboard().getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"))) { diff --git a/source/net/yacy/http/YaCyLoginService.java b/source/net/yacy/http/YaCyLoginService.java index 998e73b98..cbcd1af92 100644 --- a/source/net/yacy/http/YaCyLoginService.java +++ b/source/net/yacy/http/YaCyLoginService.java @@ -2,7 +2,7 @@ // YaCyLoginService // Copyright 2011 by Florian Richter // First released 16.04.2011 at http://yacy.net -// +// // $LastChangedDate$ // $LastChangedRevision$ // $LastChangedBy$ @@ -11,12 +11,12 @@ // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. -// +// // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. -// +// // You should have received a copy of the GNU Lesser General Public License // along with this program in the file lgpl21.txt // If not, see <http://www.gnu.org/licenses/>. @@ -24,68 +24,118 @@ package net.yacy.http; -import java.io.IOException; import java.util.ArrayList; import net.yacy.data.UserDB.AccessRight; import net.yacy.data.UserDB.Entry; import net.yacy.search.Switchboard; import net.yacy.search.SwitchboardConstants; +import org.eclipse.jetty.security.AbstractLoginService; +import org.eclipse.jetty.security.HashLoginService; import org.eclipse.jetty.security.LoginService; -import org.eclipse.jetty.security.MappedLoginService; +import org.eclipse.jetty.security.UserStore; import org.eclipse.jetty.server.UserIdentity; import org.eclipse.jetty.util.security.Credential; /** - * jetty login service, provides admin and YaCy.UserDB users with role assignment - * with DIGEST auth by default Jetty uses the name of the loginSevice as realmname (which is part of all password hashes) + * jetty login service, provides admin and YaCy.UserDB users with role + * assignment with DIGEST auth by default Jetty uses the name of the loginSevice + * as realmname (which is part of all password hashes) */ -public class YaCyLoginService extends MappedLoginService implements LoginService { +public class YaCyLoginService extends HashLoginService implements LoginService { + + private UserStore _userStore; // user cache for known/authenticated users + + /** + * Initialize a user cache + * @throws Exception + */ + @Override + protected void doStart() throws Exception { + _userStore = new UserStore(); + this.setUserStore(_userStore); + super.doStart(); + } + + /** + * Free space used by user cache + * @throws Exception + */ + @Override + protected void doStop() throws Exception { + super.doStop(); + if (_userStore != null) { + _userStore.stop(); + _userStore = null; + } + } + /** + * Load the user from cache (of authenticated users) or from the YaCy user db + * @param username + * @return known user or null + */ @Override - protected UserIdentity loadUser(String username) { - if (username == null || username.isEmpty()) return null; // quick exit + protected AbstractLoginService.UserPrincipal loadUserInfo(String username) { + if (username == null || username.isEmpty()) { + return null; // quick exit + } - final Switchboard sb = Switchboard.getSwitchboard(); - String adminuser = sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"); - Credential credential = null; - String[] roles = null; - if (username.equals(adminuser)) { - final String adminAccountBase64MD5 = sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""); - // in YaCy the credential hash is composed of username:pwd so the username is needed to create valid credential - // not just the password (as usually in Jetty). As the accountname for the std. adminuser is not stored a useridentity - // is created for current user (and the pwd checked against the stored username:pwd setting) - credential = YaCyLegacyCredential.getCredentialForAdmin(username, adminAccountBase64MD5); - // TODO: YaCy user:pwd hashes should longterm likely be switched to separable username + pwd-hash entries - // and/or the standard admin account username should be fix = "admin" - roles = new String[]{AccessRight.ADMIN_RIGHT.toString()}; - } else { - Entry user = sb.userDB.getEntry(username); - if (user != null && user.getMD5EncodedUserPwd() != null) { - // assigning roles from userDB - ArrayList<String> roletmp = new ArrayList<String>(); - for (final AccessRight right : AccessRight.values()) { - if (user.hasRight(right)) { - roletmp.add(right.toString()); + AbstractLoginService.UserPrincipal theUser = super.loadUserInfo(username); // load from cache (the internal _userStore) + if (theUser == null) { + final Switchboard sb = Switchboard.getSwitchboard(); + String adminuser = sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"); + Credential credential = null; + String[] roles = null; + if (username.equals(adminuser)) { + final String adminAccountBase64MD5 = sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, ""); + // in YaCy the credential hash is composed of username:pwd so the username is needed to create valid credential + // not just the password (as usually in Jetty). As the accountname for the std. adminuser is not stored a useridentity + // is created for current user (and the pwd checked against the stored username:pwd setting) + credential = YaCyLegacyCredential.getCredentialForAdmin(username, adminAccountBase64MD5); + // TODO: YaCy user:pwd hashes should longterm likely be switched to separable username + pwd-hash entries + // and/or the standard admin account username should be fix = "admin" + roles = new String[]{AccessRight.ADMIN_RIGHT.toString()}; + } else { + Entry user = sb.userDB.getEntry(username); + if (user != null && user.getMD5EncodedUserPwd() != null) { + // assigning roles from userDB + ArrayList<String> roletmp = new ArrayList<String>(); + for (final AccessRight right : AccessRight.values()) { + if (user.hasRight(right)) { + roletmp.add(right.toString()); + } } + if (roletmp.size() > 0) { + roles = roletmp.toArray(new String[roletmp.size()]); + } + credential = YaCyLegacyCredential.getCredentialForUserDB(username, user.getMD5EncodedUserPwd()); } - if (roletmp.size() > 0) roles = roletmp.toArray(new String[roletmp.size()]); - credential = YaCyLegacyCredential.getCredentialForUserDB(username, user.getMD5EncodedUserPwd()); } - } - if (credential != null) { - if (roles != null) { - return putUser(username, credential, roles); + if (credential != null) { // if credential exist, user is known, create or get info + theUser = new AbstractLoginService.UserPrincipal(username, credential); + _userStore.addUser(username, credential, roles); // add to jetty user cache + _userStore.getUserIdentity(username).getUserPrincipal(); + theUser.authenticate(credential); } - return putUser(username, credential); // w/o role makes not much sense, but succeeds login.... } - return null; + return theUser; } - @Override - protected void loadUsers() throws IOException { - // don't load any users into MappedLoginService on startup - // we use loadUser for dynamic checking + /** + * Delete a user from the internal cache. If user found in cache user is + * loged out before delete. + * @param username + * @return true if user deleted, if not found in user cache false + */ + public boolean removeUser(String username) { + UserIdentity uid = _userStore.getUserIdentity(username); + if (uid != null) { + logout(uid); + _userStore.removeUser(username); + return true; + } + return false; } -} +}
\ No newline at end of file |
