summaryrefslogtreecommitdiff
path: root/source/net
diff options
context:
space:
mode:
authorMichael Peter Christen <mc@yacy.net>2026-07-11 11:11:06 +0200
committerMichael Peter Christen <mc@yacy.net>2026-07-11 11:11:06 +0200
commitb1380c4a9f479de4fc456b6305bee57bc752ad03 (patch)
treec0d42fb103edafa5e9b8e5f04f48bfdcc658441e /source/net
parentf2b0f41d8492ebf92b0e331e8c9c78e626f371c9 (diff)
cleaned up user authentication
this removes the userDB-exception in the normal authentication process which affected mostly wiki and blog which are not required any more. We also cleaned up translation messages as this function was not used at all. This is a required step forward a renovation of the jetty server.
Diffstat (limited to 'source/net')
-rw-r--r--source/net/yacy/cora/protocol/RequestHeader.java1
-rw-r--r--source/net/yacy/cora/protocol/ResponseHeader.java68
-rw-r--r--source/net/yacy/data/BlogBoard.java556
-rw-r--r--source/net/yacy/data/BlogBoardComments.java363
-rw-r--r--source/net/yacy/data/UserDB.java656
-rw-r--r--source/net/yacy/data/wiki/WikiBoard.java445
-rw-r--r--source/net/yacy/data/wiki/WikiCode.java18
-rw-r--r--source/net/yacy/htroot/Blog.java343
-rw-r--r--source/net/yacy/htroot/BlogComments.java331
-rw-r--r--source/net/yacy/htroot/Bookmarks.java22
-rw-r--r--source/net/yacy/htroot/ConfigAccountList_p.java106
-rw-r--r--source/net/yacy/htroot/ConfigAccounts_p.java294
-rw-r--r--source/net/yacy/htroot/ConfigRobotsTxt_p.java4
-rw-r--r--source/net/yacy/htroot/ConfigUser_p.java175
-rw-r--r--source/net/yacy/htroot/Network.java29
-rw-r--r--source/net/yacy/htroot/News.java28
-rw-r--r--source/net/yacy/htroot/SettingsAck_p.java25
-rw-r--r--source/net/yacy/htroot/Settings_p.java15
-rw-r--r--source/net/yacy/htroot/Surftips.java36
-rw-r--r--source/net/yacy/htroot/TransNews_p.java326
-rw-r--r--source/net/yacy/htroot/Translator_p.java174
-rw-r--r--source/net/yacy/htroot/User.java177
-rw-r--r--source/net/yacy/htroot/Wiki.java283
-rw-r--r--source/net/yacy/htroot/WikiCodeHelp.java (renamed from source/net/yacy/htroot/WikiHelp.java)6
-rw-r--r--source/net/yacy/htroot/api/bookmarks/get_bookmarks.java11
-rw-r--r--source/net/yacy/htroot/api/bookmarks/get_folders.java19
-rw-r--r--source/net/yacy/htroot/api/bookmarks/posts/add_p.java14
-rw-r--r--source/net/yacy/htroot/index.java17
-rw-r--r--source/net/yacy/htroot/robots.java2
-rw-r--r--source/net/yacy/htroot/yacychat.java97
-rw-r--r--source/net/yacy/htroot/yacysearch.java22
-rw-r--r--source/net/yacy/htroot/yacysearchitem.java40
-rw-r--r--source/net/yacy/htroot/yacysearchlatestinfo.java6
-rw-r--r--source/net/yacy/htroot/yacysearchtrailer.java5
-rw-r--r--source/net/yacy/http/YaCyHttpServer.java10
-rw-r--r--source/net/yacy/http/YaCyLegacyCredential.java16
-rw-r--r--source/net/yacy/http/YaCyLoginService.java34
-rw-r--r--source/net/yacy/http/YaCySecurityHandler.java3
-rw-r--r--source/net/yacy/http/servlets/LLMAdminProxyServlet.java3
-rw-r--r--source/net/yacy/http/servlets/SolrSelectServlet.java3
-rw-r--r--source/net/yacy/http/servlets/YaCyDefaultServlet.java11
-rw-r--r--source/net/yacy/migration.java29
-rw-r--r--source/net/yacy/peers/NewsPool.java62
-rw-r--r--source/net/yacy/search/SearchAccessRateConstants.java33
-rw-r--r--source/net/yacy/search/Switchboard.java94
-rw-r--r--source/net/yacy/search/SwitchboardConstants.java4
-rw-r--r--source/net/yacy/server/http/HTTPDemon.java13
-rw-r--r--source/net/yacy/server/http/RobotsTxtConfig.java24
-rw-r--r--source/net/yacy/server/serverObjects.java4
-rw-r--r--source/net/yacy/visualization/ImageViewer.java16
50 files changed, 205 insertions, 4868 deletions
diff --git a/source/net/yacy/cora/protocol/RequestHeader.java b/source/net/yacy/cora/protocol/RequestHeader.java
index 5a4494cdf..5c578b1c6 100644
--- a/source/net/yacy/cora/protocol/RequestHeader.java
+++ b/source/net/yacy/cora/protocol/RequestHeader.java
@@ -471,7 +471,6 @@ public class RequestHeader extends HeaderFramework implements HttpServletRequest
}
super.remove(AUTHORIZATION);
- // TODO: take care of legacy login cookie (and possibly cached UserDB login status)
}
diff --git a/source/net/yacy/cora/protocol/ResponseHeader.java b/source/net/yacy/cora/protocol/ResponseHeader.java
index c7be30fa7..cfcf34f23 100644
--- a/source/net/yacy/cora/protocol/ResponseHeader.java
+++ b/source/net/yacy/cora/protocol/ResponseHeader.java
@@ -20,11 +20,8 @@
package net.yacy.cora.protocol;
-import java.util.ArrayList;
import java.util.Date;
-import java.util.List;
import java.util.Map;
-import javax.servlet.http.Cookie;
import org.apache.http.Header;
@@ -123,69 +120,4 @@ public class ResponseHeader extends HeaderFramework {
return x_robots_tag.toLowerCase();
}
- /*
- * Patch BEGIN: (moved from HeaderFramework here (2016-11-20)
- * Name: Header Property Patch
- * Date: Fri. 13.01.2006
- * Description: Makes possible to send header properties such as cookies back to the client.
- * Part 1 of 5
- * Questions: sergej.z@list.ru
- */
- /**
- * Holds header properties
- */
- //Since properties such as cookies can be multiple, we cannot use HashMap here. We have to use Vector.
- private List<Cookie> cookieStore; // init on first access
-
- /**
- * Sets Cookie on the client machine.
- *
- * @param name Cookie name
- * @param value Cookie value
- * @param maxage time to live in seconds, none negative number, according to https://tools.ietf.org/html/rfc2109, 0=discard in https://tools.ietf.org/html/rfc2965
- * @param path Path the cookie belongs to. Default - "/". Can be <b>null</b>.
- * @param domain Domain this cookie belongs to. Default - domain name. Can be <b>null</b>.
- * @param secure If true cookie will be send only over safe connection such as https
- * @see <a href="http://docs.sun.com/source/816-6408-10/cookies.htm">further documentation at docs.sun.com</a>
- */
- public void setCookie(final String name, final String value, final Integer maxage, final String path, final String domain, final boolean secure)
- {
- /*
- * TODO:Here every value can be validated for correctness if needed
- * For example semicolon should be not in any of the values
- * However an exception in this case would be an overhead IMHO.
- */
- if (!name.isEmpty()) {
- if (this.cookieStore == null) this.cookieStore = new ArrayList<Cookie>();
- Cookie c = new Cookie (name, value);
- if (maxage != null && maxage >= 0) c.setMaxAge(maxage);
- if (path != null) c.setPath(path);
- if (domain != null) c.setDomain(domain);
- if (secure) c.setSecure(secure);
- this.cookieStore.add(c);
- }
- }
-
- /**
- * Sets Cookie on the client machine.
- *
- * @param name Cookie name
- * @param value Cookie value
- *
- * Note: this cookie will be sent over each connection independent if it is safe connection or not. This cookie never expires
- * @see further documentation: <a href="http://docs.sun.com/source/816-6408-10/cookies.htm">docs.sun.com</a>
- */
- public void setCookie(final String name, final String value )
- {
- setCookie( name, value, null, null, null, false);
- }
-
- public List<Cookie> getCookiesEntries() {
- return this.cookieStore;
- }
-
- /*
- * Patch END:
- * Name: Header Property Patch
- */
}
diff --git a/source/net/yacy/data/BlogBoard.java b/source/net/yacy/data/BlogBoard.java
deleted file mode 100644
index bb026fea5..000000000
--- a/source/net/yacy/data/BlogBoard.java
+++ /dev/null
@@ -1,556 +0,0 @@
-// BlogBoard.java
-// -------------------------------------
-// (C) by Michael Peter Christen; mc@yacy.net
-// first published on http://www.anomic.de
-// Frankfurt, Germany, 2004
-// last major change: 20.07.2004
-//
-// $LastChangedDate$
-// $LastChangedRevision$
-// $LastChangedBy$
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-// This file is contributed by Jan Sandbrink
-// based on the Code of wikiBoard.java
-
-package net.yacy.data;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.ParseException;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-import net.yacy.cora.date.GenericFormatter;
-import net.yacy.cora.document.encoding.UTF8;
-import net.yacy.cora.order.Base64Order;
-import net.yacy.cora.order.NaturalOrder;
-import net.yacy.cora.protocol.Domains;
-import net.yacy.cora.util.ConcurrentLog;
-import net.yacy.cora.util.SpaceExceededException;
-import net.yacy.data.wiki.WikiBoard;
-import net.yacy.kelondro.blob.MapHeap;
-import net.yacy.kelondro.util.kelondroException;
-
-
-public class BlogBoard {
-
- private static final int KEY_LENGTH = 64;
-
- private MapHeap database = null;
-
- public BlogBoard(final File actpath) throws IOException {
- new File(actpath.getParent()).mkdir();
- //database = new MapView(BLOBTree.toHeap(actpath, true, true, keyLength, recordSize, '_', NaturalOrder.naturalOrder, newFile), 500, '_');
- this.database = new MapHeap(actpath, KEY_LENGTH, NaturalOrder.naturalOrder, 1024 * 64, 500, '_');
- }
-
- public int size() {
- return this.database.size();
- }
-
- /**
- * Tells if the database contains an element.
- * @param key the ID of the element
- * @return true if the database contains the element, else false
- */
- public boolean contains(final String key) {
- return this.database.containsKey(UTF8.getBytes(key));
- }
-
- public synchronized void close() {
- this.database.close();
- }
-
- private static String normalize(final String key) {
- return (key == null) ? "null" : key.trim().toLowerCase();
- }
-
- public static String webalize(final String key) {
- return (key == null) ? "null": key.trim().toLowerCase().replaceAll(" ", "%20");
- }
-
- public String guessAuthor(final String ip) {
- return WikiBoard.guessAuthor(ip);
- }
-
- /**
- * Create a new BlogEntry and return it
- * @param key
- * @param subject
- * @param author
- * @param ip
- * @param date
- * @param page the content of the Blogentry
- * @param comments
- * @param commentMode possible params are: 0 - no comments allowed, 1 - comments allowed, 2 - comments moderated
- * @return BlogEntry
- */
- public BlogEntry newEntry(final String key, final byte[] subject, final byte[] author, final String ip, final Date date, final byte[] page, final List<String> comments, final String commentMode) {
- return new BlogEntry(normalize(key), subject, author, ip, date, page, comments, commentMode);
- }
-
- /*
- * writes a new page and return the key
- */
- public String writeBlogEntry(final BlogEntry page) {
- String ret = null;
- try {
- this.database.insert(UTF8.getBytes(page.key), page.record);
- ret = page.key;
- } catch (final IOException ex) {
- ConcurrentLog.logException(ex);
- } catch (final SpaceExceededException ex) {
- ConcurrentLog.logException(ex);
- }
- return ret;
- }
-
- public BlogEntry readBlogEntry(final String key) {
- return this.readBlogEntry(key, this.database);
- }
-
- private BlogEntry readBlogEntry(final String key, final MapHeap base) {
- final String normalized = normalize(key);
- Map<String, String> record;
- try {
- record = base.get(UTF8.getBytes(normalized.substring(0, Math.min(normalized.length(), KEY_LENGTH))));
- } catch (final IOException e) {
- ConcurrentLog.logException(e);
- record = null;
- } catch (final SpaceExceededException e) {
- ConcurrentLog.logException(e);
- record = null;
- }
- return (record == null) ?
- this.newEntry(key, new byte[0], UTF8.getBytes("anonymous"), Domains.LOCALHOST, new Date(), new byte[0], null, null) :
- new BlogEntry(key, record);
- }
-
- public boolean importXML(final String input) {
- if (input != null && !input.isEmpty()) {
- final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- try {
- final DocumentBuilder builder = factory.newDocumentBuilder();
- return this.parseXMLimport(builder.parse(new ByteArrayInputStream(UTF8.getBytes(input))));
- } catch (final ParserConfigurationException ex) {
- ConcurrentLog.logException(ex);
- } catch (final SAXException ex) {
- ConcurrentLog.logException(ex);
- } catch (final IOException ex) {
- ConcurrentLog.logException(ex);
- }
- }
- return false;
- }
-
- public boolean importXML(final InputStream is) {
- if (is != null) {
- final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- try {
- final DocumentBuilder builder = factory.newDocumentBuilder();
- return this.parseXMLimport(builder.parse(is));
- } catch (final ParserConfigurationException ex) {
- ConcurrentLog.logException(ex);
- } catch (final SAXException ex) {
- ConcurrentLog.logException(ex);
- } catch (final IOException ex) {
- ConcurrentLog.logException(ex);
- }
- }
- return false;
- }
-
- private boolean parseXMLimport(final Document doc) {
- if(!"blog".equals(doc.getDocumentElement().getTagName())) {
- return false;
- }
-
- final NodeList items = doc.getDocumentElement().getElementsByTagName("item");
- if(items.getLength() == 0) {
- return false;
- }
-
- for (int i = 0, n = items.getLength(); i < n; ++i) {
- String key = null, ip = null, StrSubject = null, StrAuthor = null, StrPage = null, StrDate = null;
- Date date = null;
-
- if(!"item".equals(items.item(i).getNodeName())) continue;
-
- final NodeList currentNodeChildren = items.item(i).getChildNodes();
-
- for (int j = 0, m = currentNodeChildren.getLength(); j < m; ++j) {
- final Node currentNode = currentNodeChildren.item(j);
- if ("id".equals(currentNode.getNodeName())) {
- key = currentNode.getFirstChild().getNodeValue();
- } else if ("ip".equals(currentNode.getNodeName())) {
- ip = currentNode.getFirstChild().getNodeValue();
- } else if ("timestamp".equals(currentNode.getNodeName())) {
- StrDate = currentNode.getFirstChild().getNodeValue();
- } else if ("subject".equals(currentNode.getNodeName())) {
- StrSubject = currentNode.getFirstChild().getNodeValue();
- } else if ("author".equals(currentNode.getNodeName())) {
- StrAuthor = currentNode.getFirstChild().getNodeValue();
- } else if ("content".equals(currentNode.getNodeName())) {
- StrPage = currentNode.getFirstChild().getNodeValue();
- }
- }
-
- try {
- date = GenericFormatter.SHORT_SECOND_FORMATTER.parse(StrDate, 0).getTime();
- } catch (final ParseException e1) {
- date = new Date();
- }
-
- if(key == null || ip == null || StrSubject == null || StrAuthor == null || StrPage == null || date == null) {
- return false;
- }
-
- byte[] subject,author,page;
- subject = UTF8.getBytes(StrSubject);
- author = UTF8.getBytes(StrAuthor);
- page = UTF8.getBytes(StrPage);
- this.writeBlogEntry (this.newEntry(key, subject, author, ip, date, page, null, null));
- }
- return true;
- }
-
- public void deleteBlogEntry(final String key) {
- try {
- this.database.delete(UTF8.getBytes(normalize(key)));
- } catch (final IOException e) { }
- }
-
- public Iterator<byte[]> keys(final boolean up) throws IOException {
- return this.database.keys(up, false);
- }
-
- /**
- * Comparator to sort objects of type Blog according to their timestamps
- */
- public class BlogComparator implements Comparator<String> {
-
- private final boolean newestFirst;
-
- /**
- * @param newestFirst newest first, or oldest first?
- */
- public BlogComparator(final boolean newestFirst){
- this.newestFirst = newestFirst;
- }
-
- @Override
- public int compare(final String obj1, final String obj2) {
- final BlogEntry blogEntry1 = BlogBoard.this.readBlogEntry(obj1);
- final BlogEntry blogEntry2 = BlogBoard.this.readBlogEntry(obj2);
- if (blogEntry1 == null || blogEntry2 == null)
- return 0;
- if (this.newestFirst) {
- if (Long.parseLong(blogEntry2.getTimestamp()) - Long.parseLong(blogEntry1.getTimestamp()) > 0) {
- return 1;
- }
- return -1;
- }
- if (Long.parseLong(blogEntry1.getTimestamp()) - Long.parseLong(blogEntry2.getTimestamp()) > 0) {
- return 1;
- }
- return -1;
- }
- }
-
- public Iterator<String> getBlogIterator(final boolean priv){
- final Set<String> set = new TreeSet<>(new BlogComparator(true));
- final Iterator<BlogEntry> iterator = this.blogIterator(true);
- BlogEntry blogEntry;
- while (iterator.hasNext()) {
- blogEntry = iterator.next();
- if (priv || blogEntry.isPublic()) {
- set.add(blogEntry.getKey());
- }
- }
- return set.iterator();
- }
-
- public Iterator<BlogEntry> blogIterator(final boolean up){
- try {
- return new BlogIterator(up);
- } catch (final IOException e) {
- return new HashSet<BlogEntry>().iterator();
- }
- }
-
- /**
- * Subclass of blogBoard, which provides the blogIterator object-type
- */
- public class BlogIterator implements Iterator<BlogEntry> {
- Iterator<byte[]> blogIter;
- //blogBoard.BlogEntry nextEntry;
- public BlogIterator(final boolean up) throws IOException {
- this.blogIter = BlogBoard.this.database.keys(up, false);
- //this.nextEntry = null;
- }
-
- @Override
- public boolean hasNext() {
- try {
- return this.blogIter.hasNext();
- } catch (final kelondroException e) {
- //resetDatabase();
- return false;
- }
- }
-
- @Override
- public BlogEntry next() {
- try {
- return BlogBoard.this.readBlogEntry(UTF8.String(this.blogIter.next()));
- } catch (final kelondroException e) {
- //resetDatabase();
- return null;
- }
- }
-
- @Override
- public void remove() {
-// if (this.nextEntry != null) {
-// try {
-// final Object blogKey = this.nextEntry.getKey();
-// if (blogKey != null) deleteBlogEntry((String) blogKey);
-// } catch (final kelondroException e) {
-// //resetDatabase();
-// }
-// }
- throw new UnsupportedOperationException("Method not implemented yet.");
- }
- }
-
- public class BlogEntry {
-
- String key;
- Map<String, String> record;
-
- public BlogEntry(final String nkey, final byte[] subject, final byte[] author, final String ip, final Date date, final byte[] page, final List<String> comments, final String commentMode) {
- this.record = new HashMap<>();
- this.setKey(nkey);
- this.setDate(date);
- this.setSubject(subject);
- this.setAuthor(author);
- this.setIp(ip);
- this.setPage(page);
- this.setComments(comments);
- this.setCommentMode(commentMode);
-
- // TODO: implement this function
- this.record.put("privacy", "public");
-
- WikiBoard.setAuthor(ip, UTF8.String(author));
- }
-
- BlogEntry(final String key, final Map<String, String> record) {
- this.key = key;
- this.record = record;
- if (this.record.get("comments") == null) {
- this.record.put("comments", ListManager.collection2string(new ArrayList<>()));
- }
- if (this.record.get("commentMode") == null || this.record.get("commentMode").length() < 1) {
- this.record.put("commentMode", "2");
- }
- }
-
- private void setKey(final String key) {
- this.key = key.substring(0, Math.min(key.length(), KEY_LENGTH));
- }
-
- public String getKey() {
- return this.key;
- }
-
- public byte[] getSubject() {
- final String m = this.record.get("subject");
- if (m == null) {
- return new byte[0];
- }
- final byte[] b = Base64Order.enhancedCoder.decode(m);
- return (b == null) ? new byte[0] : b;
- }
-
- private void setSubject(final byte[] subject) {
- if (subject == null) {
- this.record.put("subject","");
- } else {
- this.record.put("subject", Base64Order.enhancedCoder.encode(subject));
- }
- }
-
- public Date getDate() {
- try {
- final String date = this.record.get("date");
- if (date == null) {
- if (ConcurrentLog.isFinest("Blog")) {
- ConcurrentLog.finest("Blog", "ERROR: date field missing in blogBoard");
- }
- return new Date();
- }
- return GenericFormatter.SHORT_SECOND_FORMATTER.parse(date, 0).getTime();
- } catch (final ParseException ex) {
- return new Date();
- }
- }
-
- private void setDate(final Date date) {
- Date ret = date;
- if (ret == null) {
- ret = new Date();
- }
- this.record.put("date", GenericFormatter.SHORT_SECOND_FORMATTER.format(ret));
- }
-
- public String getTimestamp() {
- final String timestamp = this.record.get("date");
- if (timestamp == null) {
- if (ConcurrentLog.isFinest("Blog")) {
- ConcurrentLog.finest("Blog", "ERROR: date field missing in blogBoard");
- }
- return GenericFormatter.SHORT_SECOND_FORMATTER.format();
- }
- return timestamp;
- }
-
- public byte[] getAuthor() {
- final String author = this.record.get("author");
- if (author == null) {
- return new byte[0];
- }
- final byte[] b = Base64Order.enhancedCoder.decode(author);
- return (b == null) ? new byte[0] : b;
- }
-
- private void setAuthor(final byte[] author) {
- if (author == null)
- this.record.put("author","");
- else
- this.record.put("author", Base64Order.enhancedCoder.encode(author));
- }
-
- public int getCommentsSize() {
- // This ist a Bugfix for Version older than 4443.
- if (this.record.get("comments").startsWith(",")) {
- this.record.put("comments", this.record.get("comments").substring(1));
- BlogBoard.this.writeBlogEntry(this);
- }
- final List<String> commentsize = ListManager.string2arraylist(this.record.get("comments"));
- return commentsize.size();
- }
-
- public List<String> getComments() {
- return ListManager.string2arraylist(this.record.get("comments"));
- }
-
- private void setComments(final List<String> comments) {
- if (comments == null) {
- this.record.put("comments", ListManager.collection2string(new ArrayList<>()));
- } else {
- this.record.put("comments", ListManager.collection2string(comments));
- }
- }
-
- public String getIp() {
- final String ip = this.record.get("ip");
- return (ip == null) ? Domains.LOCALHOST : ip;
- }
-
- private void setIp(final String ip) {
- String ret = ip;
- if ((ret == null) || (ret.isEmpty()))
- ret = "";
- this.record.put("ip", ret);
- }
-
- public byte[] getPage() {
- final String page = this.record.get("page");
- if (page == null) {
- return new byte[0];
- }
- final byte[] page_as_byte = Base64Order.enhancedCoder.decode(page);
- return (page_as_byte == null) ? new byte[0] : page_as_byte;
- }
-
- private void setPage(final byte[] page) {
- if (page == null) {
- this.record.put("page", "");
- } else {
- this.record.put("page", Base64Order.enhancedCoder.encode(page));
- }
- }
-
- public void addComment(final String commentID) {
- final List<String> comments = ListManager.string2arraylist(this.record.get("comments"));
- comments.add(commentID);
- this.record.put("comments", ListManager.collection2string(comments));
- }
-
- public boolean removeComment(final String commentID) {
- final List<String> comments = ListManager.string2arraylist(this.record.get("comments"));
- final boolean success = comments.remove(commentID);
- this.record.put("comments", ListManager.collection2string(comments));
- return success;
- }
-
- /**
- * returns the comment mode
- * 0 - no comments allowed
- * 1 - comments allowed
- * 2 - comments moderated
- * @return comment mode
- */
- public int getCommentMode(){
- return Integer.parseInt(this.record.get("commentMode"));
- }
-
- private void setCommentMode(final String mode) {
- if (mode == null) {
- this.record.put("commentMode", "2");
- } else {
- this.record.put("commentMode", mode);
- }
- }
-
- public boolean isPublic() {
- final String privacy = this.record.get("privacy");
- return (privacy == null || privacy.equalsIgnoreCase("public")) ? true : false;
- }
-
- }
-}
diff --git a/source/net/yacy/data/BlogBoardComments.java b/source/net/yacy/data/BlogBoardComments.java
deleted file mode 100644
index 9c1e03ba9..000000000
--- a/source/net/yacy/data/BlogBoardComments.java
+++ /dev/null
@@ -1,363 +0,0 @@
-// BlogBoardComments.java
-// -------------------------------------
-// (C) by Michael Peter Christen; mc@yacy.net
-// first published on http://www.anomic.de
-// Frankfurt, Germany, 2004
-// last major change: 20.07.2004
-//
-// $LastChangedDate$
-// $LastChangedRevision$
-// $LastChangedBy$
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-// This file is contributed by Jan Sandbrink
-// based on the Code of wikiBoard.java
-
-package net.yacy.data;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.TimeZone;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import net.yacy.cora.document.encoding.UTF8;
-import net.yacy.cora.order.Base64Order;
-import net.yacy.cora.order.NaturalOrder;
-import net.yacy.cora.protocol.Domains;
-import net.yacy.cora.util.ConcurrentLog;
-import net.yacy.cora.util.SpaceExceededException;
-import net.yacy.data.wiki.WikiBoard;
-import net.yacy.kelondro.blob.MapHeap;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-
-public class BlogBoardComments {
-
- private final static int KEY_LENGTH = 64;
- private final static String DATE_FORMAT = "yyyyMMddHHmmss";
-
- private final static SimpleDateFormat SIMPLE_DATE_FORMATTER = new SimpleDateFormat(DATE_FORMAT, Locale.US);
- static {
- SIMPLE_DATE_FORMATTER.setTimeZone(TimeZone.getTimeZone("GMT"));
- }
-
- private MapHeap database = null;
-
- public BlogBoardComments(final File actpath) throws IOException {
- new File(actpath.getParent()).mkdir();
- //database = new MapView(BLOBTree.toHeap(actpath, true, true, keyLength, recordSize, '_', NaturalOrder.naturalOrder, newFile), 500, '_');
- this.database = new MapHeap(actpath, KEY_LENGTH, NaturalOrder.naturalOrder, 1024 * 64, 500, '_');
- }
-
- public int size() {
- return this.database.size();
- }
-
- public synchronized void close() {
- this.database.close();
- }
-
- static String dateString(final Date date) {
- synchronized (SIMPLE_DATE_FORMATTER) {
- return SIMPLE_DATE_FORMATTER.format(date);
- }
- }
-
- private static String normalize(final String key) {
- return (key == null) ? "null" : key.trim().toLowerCase();
- }
- public static String webalize(final String key) {
- if (key == null) {
- return "null";
- }
- String ret = key.trim().toLowerCase();
- int p;
- while ((p = ret.indexOf(' ',0)) >= 0)
- ret = ret.substring(0, p) + "%20" + key.substring(p +1);
- return ret;
- }
-
- public String guessAuthor(final String ip) {
- return WikiBoard.guessAuthor(ip);
- }
-
- public CommentEntry newEntry(final String key, final byte[] subject, final byte[] author, final String ip, final Date date, final byte[] page) {
- return new CommentEntry(normalize(key), subject, author, ip, date, page);
- }
-
- public String write(final CommentEntry page) {
- // writes a new page and returns key
- try {
- this.database.insert(UTF8.getBytes(page.key), page.record);
- return page.key;
- } catch (final Exception e) {
- ConcurrentLog.logException(e);
- return null;
- }
- }
- public CommentEntry read(final String key) {
- //System.out.println("DEBUG: read from blogBoardComments");
- return read(key, this.database);
- }
-
- private CommentEntry read(final String key, final MapHeap base) {
- String copyOfKey = normalize(key);
- copyOfKey = copyOfKey.substring(0, Math.min(copyOfKey.length(), KEY_LENGTH));
- Map<String, String> record;
- try {
- record = base.get(UTF8.getBytes(copyOfKey));
- } catch (final IOException e) {
- ConcurrentLog.logException(e);
- record = null;
- } catch (final SpaceExceededException e) {
- ConcurrentLog.logException(e);
- record = null;
- }
- return (record == null) ?
- newEntry(copyOfKey, new byte[0], UTF8.getBytes("anonymous"), Domains.LOCALHOST, new Date(), new byte[0]) :
- new CommentEntry(copyOfKey, record);
- }
-
- public boolean importXML(final String input) {
- boolean ret = false;
- final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- try {
- final DocumentBuilder builder = factory.newDocumentBuilder();
- final Document doc = builder.parse(new ByteArrayInputStream(UTF8.getBytes(input)));
- ret = parseXMLimport(doc);
- }
- catch (final ParserConfigurationException e) {}
- catch (final SAXException e) {}
- catch (final IOException e) {}
-
- return ret;
- }
-
- private boolean parseXMLimport(final Document doc) {
- if(!"blog".equals(doc.getDocumentElement().getTagName())) {
- return false;
- }
-
- final NodeList items = doc.getDocumentElement().getElementsByTagName("item");
- if(items.getLength() == 0) {
- return false;
- }
-
- for(int i = 0, n = items.getLength(); i < n; ++i) {
- String key = null, ip = null, StrSubject = null, StrAuthor = null, StrPage = null, StrDate = null;
- Date date = null;
-
- if(!"item".equals(items.item(i).getNodeName()))
- continue;
-
- final NodeList currentNodeChildren = items.item(i).getChildNodes();
-
- for(int j=0, m = currentNodeChildren.getLength(); j < m; ++j) {
-
- final Node currentNode = currentNodeChildren.item(j);
- if ("id".equals(currentNode.getNodeName())) {
- key = currentNode.getFirstChild().getNodeValue();
- } else if("ip".equals(currentNode.getNodeName())) {
- ip = currentNode.getFirstChild().getNodeValue();
- } else if("timestamp".equals(currentNode.getNodeName())) {
- StrDate = currentNode.getFirstChild().getNodeValue();
- } else if("subject".equals(currentNode.getNodeName())) {
- StrSubject = currentNode.getFirstChild().getNodeValue();
- } else if("author".equals(currentNode.getNodeName())) {
- StrAuthor = currentNode.getFirstChild().getNodeValue();
- } else if("content".equals(currentNode.getNodeName())) {
- StrPage = currentNode.getFirstChild().getNodeValue();
- }
- }
-
- try {
- date = SIMPLE_DATE_FORMATTER.parse(StrDate);
- } catch (final ParseException ex) {
- date = new Date();
- }
-
- if (key == null || ip == null || StrSubject == null || StrAuthor == null || StrPage == null || date == null)
- return false;
-
- byte[] subject,author,page;
- subject = UTF8.getBytes(StrSubject);
- author = UTF8.getBytes(StrAuthor);
- page = UTF8.getBytes(StrPage);
- write (newEntry(key, subject, author, ip, date, page));
- }
-
- return true;
- }
-
- public void delete(final String key) {
- try {
- this.database.delete(UTF8.getBytes(normalize(key)));
- }
- catch (final IOException e) { }
- }
-
- public Iterator<byte[]> keys(final boolean up) throws IOException {
- return this.database.keys(up, false);
- }
-
- public static class CommentEntry {
-
- String key;
- Map<String, String> record;
-
- public CommentEntry(final String nkey, final byte[] subject, final byte[] author, final String ip, final Date date, final byte[] page) {
- this.record = new HashMap<String, String>();
-
- setKey(nkey);
- setDate(date);
- setSubject(subject);
- setAuthor(author);
- setIp(ip);
- setPage(page);
-
- WikiBoard.setAuthor(ip, UTF8.String(author));
- }
-
- CommentEntry(final String key, final Map<String, String> record) {
- this.key = key;
- this.record = record;
- if (this.record.get("comments") == null) {
- this.record.put("comments", ListManager.collection2string(new ArrayList<String>()));
- }
- }
-
- public String getKey() {
- return this.key;
- }
-
- private void setKey(final String var) {
- this.key = var.substring(0, Math.min(var.length(), KEY_LENGTH));
- }
-
- private void setSubject(final byte[] subject) {
- if (subject == null)
- this.record.put("subject","");
- else
- this.record.put("subject", Base64Order.enhancedCoder.encode(subject));
- }
- public byte[] getSubject() {
- final String subject = this.record.get("subject");
- if (subject == null) return new byte[0];
- final byte[] subject_bytes = Base64Order.enhancedCoder.decode(subject);
- if (subject_bytes == null) return new byte[0];
- return subject_bytes;
- }
- private void setDate(Date date) {
- if(date == null)
- date = new Date();
- this.record.put("date", dateString(date));
- }
- public Date getDate() {
- try {
- final String date = this.record.get("date");
- if (date == null) {
- if (ConcurrentLog.isFinest("Blog")) ConcurrentLog.finest("Blog", "ERROR: date field missing in blogBoard");
- return new Date();
- }
- synchronized (SIMPLE_DATE_FORMATTER) {
- return SIMPLE_DATE_FORMATTER.parse(date);
- }
- } catch (final ParseException e) {
- return new Date();
- }
- }
-
- public String getTimestamp() {
- final String timestamp = this.record.get("date");
- if (timestamp == null) {
- if (ConcurrentLog.isFinest("Blog")) ConcurrentLog.finest("Blog", "ERROR: date field missing in blogBoard");
- return dateString(new Date());
- }
- return timestamp;
- }
- private void setAuthor(final byte[] author) {
- if (author == null)
- this.record.put("author","");
- else
- this.record.put("author", Base64Order.enhancedCoder.encode(author));
- }
- public byte[] getAuthor() {
- final String author = this.record.get("author");
- if (author == null)
- return new byte[0];
- final byte[] author_byte = Base64Order.enhancedCoder.decode(author);
- if (author_byte == null)
- return new byte[0];
- return author_byte;
- }
- private void setIp(String ip) {
- if ((ip == null) || (ip.isEmpty()))
- ip = "";
- this.record.put("ip", ip);
- }
- public String getIp() {
- final String ip = this.record.get("ip");
- if (ip == null)
- return Domains.LOCALHOST;
- return ip;
- }
- private void setPage(final byte[] page) {
- if (page == null)
- this.record.put("page", "");
- else
- this.record.put("page", Base64Order.enhancedCoder.encode(page));
- }
- public byte[] getPage() {
- final String page = this.record.get("page");
- if (page == null)
- return new byte[0];
- final byte[] page_byte = Base64Order.enhancedCoder.decode(page);
- if (page_byte == null)
- return new byte[0];
- return page_byte;
- }
- /**
- * Is the comment allowed?
- * this is possible for moderated blog entry only and means
- * the administrator has explicit allowed the comment.
- * @return
- */
- public boolean isAllowed() {
- return "true".equals(this.record.get("moderated"));
- }
- public void allow() {
- this.record.put("moderated", "true");
- }
-
- }
-
-}
diff --git a/source/net/yacy/data/UserDB.java b/source/net/yacy/data/UserDB.java
deleted file mode 100644
index ae0f0511c..000000000
--- a/source/net/yacy/data/UserDB.java
+++ /dev/null
@@ -1,656 +0,0 @@
-//UserDB.java
-//-------------------------------------
-//part of YACY
-//
-//(C) 2005, 2006 by Martin Thelian
-// Alexander Schier
-//
-//$LastChangedDate$
-//$LastChangedRevision$
-//$LastChangedBy$
-//
-//This program is free software; you can redistribute it and/or modify
-//it under the terms of the GNU General Public License as published by
-//the Free Software Foundation; either version 2 of the License, or
-//(at your option) any later version.
-//
-//This program 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 General Public License for more details.
-//
-//You should have received a copy of the GNU General Public License
-//along with this program; if not, write to the Free Software
-//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-package net.yacy.data;
-
-import java.io.File;
-import java.io.IOException;
-import java.security.Principal;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Random;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-
-import net.yacy.cora.document.encoding.UTF8;
-import net.yacy.cora.order.Base64Order;
-import net.yacy.cora.order.CloneableIterator;
-import net.yacy.cora.order.Digest;
-import net.yacy.cora.order.NaturalOrder;
-import net.yacy.cora.protocol.RequestHeader;
-import net.yacy.cora.util.ConcurrentLog;
-import net.yacy.cora.util.SpaceExceededException;
-import net.yacy.kelondro.blob.MapHeap;
-import net.yacy.kelondro.util.FileUtils;
-import net.yacy.kelondro.util.kelondroException;
-import net.yacy.search.Switchboard;
-import net.yacy.search.SwitchboardConstants;
-
-/**
- * Holds details of users that can login to YaCy, their rights and credentials.
- * Caches succesfull login, holding cookie and/or ip information.
- *
- * In addition a systemadmin (static admin) account is available by default,
- * included in the global Switchboard configuration.
- *
- */
-public final class UserDB {
-
- private static final int USERNAME_MIN_LENGTH = 4;
-
- private MapHeap userTable;
- private final File userTableFile;
- private final Map<String, String> ipUsers = new HashMap<String, String>();
- private final Map<String, Entry> cookieUsers = new HashMap<String, Entry>(); // mapping to identify user by a login cookie "login=<token>"
-
- public UserDB(final File userTableFile) throws IOException {
- this.userTableFile = userTableFile;
- userTableFile.getParentFile().mkdirs();
- this.userTable = new MapHeap(userTableFile, 128, NaturalOrder.naturalOrder, 1024 * 64, 10, '_');
- }
-
- void resetDatabase() {
- // deletes the database and creates a new one
- if (userTable != null) {
- userTable.close();
- }
- FileUtils.deletedelete(userTableFile);
- userTableFile.getParentFile().mkdirs();
- try {
- userTable = new MapHeap(userTableFile, 128, NaturalOrder.naturalOrder, 1024 * 64, 10, '_');
- } catch (final IOException e) {
- ConcurrentLog.logException(e);
- }
- }
-
- public synchronized void close() {
- userTable.close();
- }
-
- public int size() {
- return userTable.size();
- }
-
- public void removeEntry(final String hostName) {
- try {
- userTable.delete(UTF8.getBytes(hostName));
- } catch (final IOException e) {
- ConcurrentLog.logException(e);
- }
- }
-
- public Entry getEntry(String userName) {
- if (userName.length() > 128) {
- userName = userName.substring(0, 127);
- }
- Map<String, String> record = null;
- try {
- record = userTable.get(UTF8.getBytes(userName));
- } catch (final IOException e) {
- ConcurrentLog.logException(e);
- } catch (final SpaceExceededException e) {
- ConcurrentLog.logException(e);
- }
-
- return (record != null) ? new Entry(userName, record) : null;
- }
-
- public Entry createEntry(final String userName, final Map<String, String> userProps) throws IllegalArgumentException{
- final Entry entry = new Entry(userName,userProps);
- return entry;
- }
-
- public String addEntry(final Entry entry) {
- try {
- userTable.insert(UTF8.getBytes(entry.userName), entry.mem);
- return entry.userName;
- } catch (final Exception e) {
- ConcurrentLog.logException(e);
- return null;
- }
- }
-
- /**
- * Use a ProxyAuth Value to authenticate user from HttpHeader.Authentication.
- * This supports only Basic authentication
- * @param header the current request HTTP headers including 'Authorization' header :
- * either "BASIC " followed by base64 Encoded String, which contains "username:pw" for basic authentication,
- * or "Digest" followed by valid user name, realm, nonce and other necessary parameters.
- * @return the user entry when the authentication header contains valid authentication information or null
- */
- public Entry proxyAuth(final RequestHeader header) {
- Entry entry = null;
- if(header == null) {
- return entry;
- }
- final String authHeader = header.get(RequestHeader.AUTHORIZATION, "").trim();
- if (authHeader.toUpperCase(Locale.ROOT).startsWith(HttpServletRequest.BASIC_AUTH)) {
- String auth = authHeader.substring(6); // take out prefix "BASIC"
- final String[] tmp = Base64Order.standardCoder.decodeString(auth.trim()).split(":");
- if (tmp.length == 2) {
- entry = this.passwordAuth(tmp[0], tmp[1]);
- if (entry == null) {
- entry = this.md5Auth(tmp[0], tmp[1]);
- }
- }
- } else if (authHeader.toUpperCase(Locale.ROOT).startsWith(HttpServletRequest.DIGEST_AUTH)) {
- // handle DIGEST auth by servlet container
- final Principal authenticatedUser = header.getUserPrincipal();
- if (authenticatedUser != null && authenticatedUser.getName() != null) { // user is authenticated by Servlet container
- entry = getEntry(authenticatedUser.getName());
- }
- }
- return entry;
- }
-
- /**
- * @param header the HTTP request headers
- * @return the authenticated user with valid authentication information found in the headers or null
- */
- public Entry getUser(final RequestHeader header){
- return getUser(header, header.getCookies());
- }
-
- /**
- * @param header HTTP request headers
- * @param cookies eventual client cookies
- * @return the authenticated user entry from headers or cookies or null
- */
- public Entry getUser(final RequestHeader header, final Cookie[] cookies){
- Entry entry = proxyAuth(header);
- if(entry == null && cookies != null) {
- entry=cookieAuth(cookies);
- }
- return entry;
- }
-
- /**
- * Determine if a user has admin rights from a 'Authorisation' http header field.
- * Tests both userDB and old style adminpw.
- *
- * @param header http-headerline for authorisation.
- * @param cookies
- */
- public boolean hasAdminRight(final RequestHeader header, final Cookie[] cookies) {
- final Entry entry = getUser(header, cookies);
- return (entry != null) ? entry.hasRight(AccessRight.ADMIN_RIGHT) : false;
- }
-
- /**
- * Use HTTP headers to authenticate user and save IP/username for ipAuth.
- * @param header HTTP request headers including 'Authorization' header with either base64 Encoded String, which contains "username:pw",
- * or Digest authentication information including notably user name, realm, and nonce.
- * @param ip IP address.
- */
- public Entry proxyAuth(final RequestHeader header, final String ip) {
- final Entry entry = proxyAuth(header);
- if (entry != null) {
- entry.updateLastAccess(false);
- this.ipUsers.put(ip, entry.getUserName());
- }
- return entry;
- }
-
- /**
- * Authenticate a user by ip, if he has used proxyAuth in the last 10 minutes.
- * @param ip IP address of user.
- */
- public Entry ipAuth(final String ip) {
- if(this.ipUsers.containsKey(ip)){
- final String user = this.ipUsers.get(ip);
- final Entry entry = this.getEntry(user);
- final Long entryTimestamp = entry.getLastAccess();
- if (entryTimestamp == null ||
- (System.currentTimeMillis()-entryTimestamp.longValue()) > (1000*60*10) ){ //no timestamp or older than 10 Minutes
- return null;
- }
- return entry; //All OK
- }
- return null;
- }
-
- public Entry passwordAuth(final String user, final String password) {
- final Entry entry = this.getEntry(user);
- final String md5pwd;
- if (entry != null && (md5pwd = entry.getMD5EncodedUserPwd()) != null) {
-
- boolean authok;
- if (md5pwd.startsWith("MD5:")) { // DIGEST style
- authok = md5pwd.equals("MD5:" + Digest.encodeMD5Hex(user + ":"
- + Switchboard.getSwitchboard().getConfig(SwitchboardConstants.ADMIN_REALM, "YaCy") + ":" + password));
- } else {
- authok = md5pwd.equals(Digest.encodeMD5Hex(user + ":" + password));
- }
- if (authok) {
- entry.updateLastAccess(false);
- return entry;
- }
- }
- return null;
- }
-
- public Entry passwordAuth(final String user, final String password, final String ip){
- final Entry entry = passwordAuth(user, password);
- if (entry != null) {
- entry.updateLastAccess(false);
- this.ipUsers.put(ip, entry.getUserName()); //XXX: This is insecure. TODO: use cookieauth
- }
- return entry;
- }
-
- public Entry md5Auth(final String user, final String md5) {
- final Entry entry = this.getEntry(user);
- if (entry != null && entry.getMD5EncodedUserPwd().endsWith(md5)) { // user pwd migth have prefix "MD5:"
- entry.updateLastAccess(false);
- return entry;
- }
- return null;
- }
-
- /**
- * Returns the user entry matching the cookie login token created and set
- * on login.
- *
- * @param cookies
- * @return user entry or null
- */
- public Entry cookieAuth(final Cookie[] cookies){
- final String token = getLoginToken(cookies);
- if (cookieUsers.containsKey(token)) {
- final Entry entry = cookieUsers.get(token);
- return entry;
- }
- return null;
- }
-
- public String getCookie(final Entry entry){
- final Random r = new Random();
- final String token = Long.toString(Math.abs(r.nextLong()), 36);
- cookieUsers.put(token, entry);
- return token;
- }
-
- /**
- * Extracts the token set as value in a cookie with name "login"
- * @param cookies
- * @return login token string
- */
- public static String getLoginToken(final Cookie[] cookies) {
- if (cookies != null) {
- for (final Cookie c : cookies) {
- if (c.getName().equals("login")) {
- return c.getValue().trim();
- }
- }
- }
- return "";
- }
-
- public enum AccessRight {
-
- //to create new rights, you just add them here
- UPLOAD_RIGHT("uploadRight", "Upload"),
- DOWNLOAD_RIGHT("downloadRight", "Download"),
- ADMIN_RIGHT("adminRight", "Admin"),
- PROXY_RIGHT("proxyRight", "Proxy usage"),
- BLOG_RIGHT("blogRight", "Blog"),
- WIKIADMIN_RIGHT("wikiAdminRight", "Wiki Admin"),
- BOOKMARK_RIGHT("bookmarkRight", "Bookmark"),
- EXTENDED_SEARCH_RIGHT("extendedSearchRight", "Extended Search");
-
- private String name;
- private String friendlyName;
-
- AccessRight(final String name, final String friendlyName) {
- this.friendlyName = friendlyName;
- this.name = name;
- }
-
- @Override
- public String toString() {
- return name;
- }
-
- public String getFriendlyName() {
- return friendlyName;
- }
-
- }
-
- public class Entry {
- public static final String MD5ENCODED_USERPWD_STRING = "MD5_user:pwd"; // value = "MD5:" + MD5Hex(username +":"+ realm + ":" pwd)
- // oldstyle = MD5Hex(username +":"+ pwd)
- public static final String USER_FIRSTNAME = "firstName";
- public static final String USER_LASTNAME = "lastName";
- public static final String USER_ADDRESS = "address";
- public static final String LAST_ACCESS = "lastAccess";
- public static final String TIME_USED = "timeUsed";
- public static final String TIME_LIMIT = "timeLimit";
- public static final String TRAFFIC_SIZE = "trafficSize";
- public static final String TRAFFIC_LIMIT = "trafficLimit";
-
- public static final int PROXY_ALLOK = 0; //can Surf
- public static final int PROXY_ERROR = 1; //unknown error
- public static final int PROXY_NORIGHT = 2; //no proxy right
- public static final int PROXY_TIMELIMIT_REACHED = 3;
-
- // this is a simple record structure that hold all properties of a user
- private Map<String, String> mem;
- private String userName;
- private final Calendar oldDate, newDate;
-
- public Entry(final String userName, final Map<String, String> mem) throws IllegalArgumentException {
- if ((userName == null) || (userName.isEmpty())) {
- throw new IllegalArgumentException("Username needed.");
- }
- if (userName.length()>128) {
- throw new IllegalArgumentException("Username too long!");
- }
-
- this.userName = userName.trim();
- if (this.userName.length() < USERNAME_MIN_LENGTH) {
- throw new IllegalArgumentException("Username too short. Length should be >= " + USERNAME_MIN_LENGTH);
- }
-
- this.mem = (mem == null) ? new HashMap<String, String>() : mem;
-
- this.oldDate=Calendar.getInstance();
- this.newDate=Calendar.getInstance();
- }
-
- public String getUserName() {
- return this.userName;
- }
-
- public String getFirstName() {
- return (this.mem.containsKey(USER_FIRSTNAME) ? this.mem.get(USER_FIRSTNAME) : null);
- }
-
- public String getLastName() {
- return (this.mem.containsKey(USER_LASTNAME) ? this.mem.get(USER_LASTNAME) : null);
- }
-
- public String getAddress() {
- return (this.mem.containsKey(USER_ADDRESS) ? this.mem.get(USER_ADDRESS) : null);
- }
-
- public long getTimeUsed() {
- long ret = 0L;
- String s = this.mem.get(TIME_USED);
- if (s != null && s.length() > 0) {
- try{
- ret = Long.parseLong(s);
- } catch (final NumberFormatException e){
- ConcurrentLog.logException(e);
- }
- } else {
- try {
- this.setProperty(TIME_USED,"0");
- } catch (final Exception e) {
- ConcurrentLog.logException(e);
- }
- }
- return ret;
- }
-
- public long getTimeLimit() {
- long ret = 0L;
- String s = this.mem.get(TIME_LIMIT);
- if (s != null && s.length() > 0) {
- try {
- ret = Long.parseLong(s);
- } catch (final NumberFormatException e){
- ConcurrentLog.logException(e);
- }
- } else {
- try {
- this.setProperty(TIME_LIMIT, "0");
- } catch (final Exception e) {
- ConcurrentLog.logException(e);
- }
- }
- return ret;
- }
-
- public long getTrafficSize() {
- long ret = 0L;
- String s = this.mem.get(TRAFFIC_SIZE);
- if (s != null && s.length() > 0) {
- try {
- ret = Long.parseLong(s);
- } catch (final NumberFormatException e) {
- ConcurrentLog.logException(e);
- }
- } else {
- try {
- this.setProperty(TRAFFIC_SIZE, "0");
- } catch (final Exception e) {
- ConcurrentLog.logException(e);
- }
- }
- return ret;
- }
-
- public Long getTrafficLimit() {
- return (this.mem.containsKey(TRAFFIC_LIMIT) ? Long.valueOf(this.mem.get(TRAFFIC_LIMIT)) : null);
- }
-
- public long updateTrafficSize(final long responseSize) {
- if (responseSize < 0) {
- throw new IllegalArgumentException("responseSize must be greater or equal zero.");
- }
-
- final long currentTrafficSize = getTrafficSize();
- final long newTrafficSize = currentTrafficSize + responseSize;
- try {
- this.setProperty(TRAFFIC_SIZE,Long.toString(newTrafficSize));
- } catch (final Exception e) {
- ConcurrentLog.logException(e);
- }
- return newTrafficSize;
- }
-
- public Long getLastAccess() {
- return (this.mem.containsKey(LAST_ACCESS) ? Long.valueOf(this.mem.get(LAST_ACCESS)) : null);
- }
-
- public int surfRight(){
- final long timeUsed=this.updateLastAccess(true);
- final int ret;
-
- if (!this.hasRight(AccessRight.PROXY_RIGHT)) {
- ret = PROXY_NORIGHT;
- } else if(! (this.getTimeLimit() <= 0 || (timeUsed < this.getTimeLimit())) ){ //no timelimit or timelimit not reached
- ret = PROXY_TIMELIMIT_REACHED;
- } else {
- ret = PROXY_ALLOK;
- }
- return ret;
- }
-
- public boolean canSurf(){
- return (this.surfRight() == PROXY_ALLOK);
- }
-
- public long updateLastAccess(final boolean incrementTimeUsed) {
- return updateLastAccess(System.currentTimeMillis(), incrementTimeUsed);
- }
-
- public long updateLastAccess(final long timeStamp, final boolean incrementTimeUsed) {
- if (timeStamp < 0) {
- throw new IllegalArgumentException();
- }
-
- final Long lastAccess = this.getLastAccess();
- long newTimeUsed = getTimeUsed();
-
- if (incrementTimeUsed) {
- if ((lastAccess == null) || (timeStamp - lastAccess.longValue() >= 1000*60)) {//1 minute
- newTimeUsed++;
- if (lastAccess != null) {
- this.oldDate.setTime(new Date(lastAccess.longValue()));
- this.newDate.setTime(new Date(System.currentTimeMillis()));
- if(
- this.oldDate.get(Calendar.DAY_OF_MONTH) != this.newDate.get(Calendar.DAY_OF_MONTH) ||
- this.oldDate.get(Calendar.MONTH) != this.newDate.get(Calendar.MONTH) ||
- this.oldDate.get(Calendar.YEAR) != this.newDate.get(Calendar.YEAR)
- ){ //new Day, reset time
- newTimeUsed=0;
- }
- }else{ //no access so far
- newTimeUsed=0;
- }
- this.mem.put(TIME_USED,Long.toString(newTimeUsed));
- this.mem.put(LAST_ACCESS,Long.toString(timeStamp)); //update Timestamp
- }
- } else {
- this.mem.put(LAST_ACCESS,Long.toString(timeStamp)); //update Timestamp
- }
-
- try {
- UserDB.this.userTable.insert(UTF8.getBytes(getUserName()), this.mem);
- } catch(final Exception e){
- ConcurrentLog.logException(e);
- }
- return newTimeUsed;
- }
-
- /**
- * @return encode credential = "MD5:" + MD5Hex(username +":"+ realm + ":" pwd) or null. (old style = MD5Hex(username +":"+ pwd)
- */
- public String getMD5EncodedUserPwd() {
- return (this.mem.containsKey(MD5ENCODED_USERPWD_STRING)) ? this.mem.get(MD5ENCODED_USERPWD_STRING) : null;
- }
-
- public Map<String, String> getProperties() {
- return this.mem;
- }
-
- public void setProperty(final String propName, final String newValue) throws IOException, SpaceExceededException {
- this.mem.put(propName, newValue);
- UserDB.this.userTable.insert(UTF8.getBytes(getUserName()), this.mem);
- }
-
- public String getProperty(final String propName, final String defaultValue) {
- return (this.mem.containsKey(propName) ? this.mem.get(propName) : defaultValue);
- }
-
- public boolean hasRight(final AccessRight accessRight){
- return (this.mem.containsKey(accessRight.toString())) ? this.mem.get(accessRight.toString()).equals("true") : false;
- }
-
- public void logout(final String ip, final String logintoken){
- logout(ip);
- if(cookieUsers.containsKey(logintoken)){
- cookieUsers.remove(logintoken);
- }
- }
-
- public void logout(final String ip) {
- try {
- if (ipUsers.containsKey(ip)){
- ipUsers.remove(ip);
- }
- } catch (final Exception e) {
- ConcurrentLog.logException(e);
- }
- }
-
- @Override
- public String toString() {
- final StringBuilder str = new StringBuilder();
-
- str.append((this.userName == null) ? "null" : this.userName).append(": ");
-
- if (this.mem != null) {
- str.append(this.mem.toString());
- }
-
- return str.toString();
- }
-
- }
-
- public Iterator<Entry> iterator(final boolean up) {
- // enumerates users
- try {
- return new userIterator(up);
- } catch (final IOException e) {
- return new HashSet<Entry>().iterator();
- }
- }
-
-
- public class userIterator implements Iterator<Entry> {
- // the iterator iterates all userNames
- CloneableIterator<byte[]> userIter;
- //userDB.Entry nextEntry;
-
- public userIterator(final boolean up) throws IOException {
- this.userIter = UserDB.this.userTable.keys(up, false);
- //this.nextEntry = null;
- }
-
- @Override
- public boolean hasNext() {
- try {
- return this.userIter.hasNext();
- } catch (final kelondroException e) {
- resetDatabase();
- return false;
- }
- }
-
- @Override
- public Entry next() {
- try {
- return getEntry(UTF8.String(this.userIter.next()));
- } catch (final kelondroException e) {
- resetDatabase();
- return null;
- }
- }
-
- @Override
- public void remove() {
-// if (this.nextEntry != null) {
-// try {
-// final Object userName = this.nextEntry.getUserName();
-// if (userName != null) removeEntry((String) userName);
-// } catch (final kelondroException e) {
-// resetDatabase();
-// }
-// }
- throw new UnsupportedOperationException("Method not implemented yet.");
- }
- }
-
-}
diff --git a/source/net/yacy/data/wiki/WikiBoard.java b/source/net/yacy/data/wiki/WikiBoard.java
deleted file mode 100644
index ebd3f4793..000000000
--- a/source/net/yacy/data/wiki/WikiBoard.java
+++ /dev/null
@@ -1,445 +0,0 @@
-//wikiBoard.java
-//-------------------------------------
-//(C) by Michael Peter Christen; mc@yacy.net
-//first published on http://www.anomic.de
-//Frankfurt, Germany, 2004
-//
-// $LastChangedDate$
-// $LastChangedRevision$
-// $LastChangedBy$
-//
-//This program is free software; you can redistribute it and/or modify
-//it under the terms of the GNU General Public License as published by
-//the Free Software Foundation; either version 2 of the License, or
-//(at your option) any later version.
-//
-//This program 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 General Public License for more details.
-//
-//You should have received a copy of the GNU General Public License
-//along with this program; if not, write to the Free Software
-//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-package net.yacy.data.wiki;
-
-import java.io.File;
-import java.io.IOException;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.TimeZone;
-
-import net.yacy.cora.document.encoding.ASCII;
-import net.yacy.cora.document.encoding.UTF8;
-import net.yacy.cora.order.Base64Order;
-import net.yacy.cora.order.NaturalOrder;
-import net.yacy.cora.protocol.Domains;
-import net.yacy.cora.util.CommonPattern;
-import net.yacy.cora.util.ConcurrentLog;
-import net.yacy.cora.util.SpaceExceededException;
-import net.yacy.kelondro.blob.MapHeap;
-
-/**
- *
- */
-public class WikiBoard {
-
- public static final int keyLength = 64;
- private static final String DATE_FORMAT = "yyyyMMddHHmmss";
- private static final String ANONYMOUS = "anonymous";
-
- private static final SimpleDateFormat SimpleFormatter = new SimpleDateFormat(DATE_FORMAT, Locale.US);
-
- static {
- SimpleFormatter.setTimeZone(TimeZone.getTimeZone("GMT"));
- }
-
- private MapHeap datbase = null;
- private MapHeap bkpbase = null;
- private static final Map<String, String> AUTHORS = new HashMap<String, String>();
-
- /**
- * Constructor.
- * @param actpath path of database which contains current wiki data.
- * @param bkppath path of backup database.
- * @throws IOException if error occurs during HDD access.
- */
- public WikiBoard(final File actpath, final File bkppath) throws IOException {
- new File(actpath.getParent()).mkdirs();
- if (this.datbase == null) {
- //datbase = new MapView(BLOBTree.toHeap(actpath, true, true, keyLength, recordSize, '_', NaturalOrder.naturalOrder, actpathNew), 500, '_');
- this.datbase = new MapHeap(actpath, keyLength, NaturalOrder.naturalOrder, 1024 * 64, 500, '_');
- }
- new File(bkppath.getParent()).mkdirs();
- if (this.bkpbase == null) {
- //bkpbase = new MapView(BLOBTree.toHeap(bkppath, true, true, keyLength + dateFormat.length(), recordSize, '_', NaturalOrder.naturalOrder, bkppathNew), 500, '_');
- this.bkpbase = new MapHeap(bkppath, keyLength + DATE_FORMAT.length(), NaturalOrder.naturalOrder, 1024 * 64, 500, '_');
- }
- }
-
- /**
- * Gets total number of entries of wiki DB and DB which contains backup entries.
- * @return number of entries in wiki plus number of old entries.
- */
- public int sizeOfTwo() {
- return this.datbase.size() + this.bkpbase.size();
- }
-
- /**
- * Gets number of entries of wiki DB.
- * @return number of entries in wiki.
- */
- public int size() {
- return this.datbase.size();
- }
-
- /**
- * Closes database files.
- */
- public synchronized void close() {
- this.datbase.close();
- this.bkpbase.close();
- }
-
- /**
- * Gets current date.
- * @return current date.
- */
- static String dateString() {
- return dateString(new Date());
- }
-
- /**
- * Gets String representation of a Date.
- * @param date the Date.
- * @return String representation of Date.
- */
- public static String dateString(final Date date) {
- synchronized (SimpleFormatter) {
- return SimpleFormatter.format(date);
- }
- }
-
- /**
- * Gets normalized version of a key.
- * @param key the key.
- * @return normalized version of key.
- */
- private static String normalize(final String key) {
- return (key != null) ? key.trim().toLowerCase() : "null";
- }
-
- /**
- * Normalizes key and replaces spaces by escape code.
- * @param key the key.
- * @return normalized and webalized version.
- */
- public static String webalize(final String key) {
- return (key != null) ? CommonPattern.SPACE.matcher(normalize(key)).replaceAll("%20") : "null";
- }
-
- /**
- * Tries to guess the name of the author by a given IP address.
- * @param ip the IP address.
- * @return
- */
- public static String guessAuthor(final String ip) {
- final String author = AUTHORS.get(ip);
- //yacyCore.log.logDebug("DEBUG: guessing author for ip = " + ip + " is '" + author + "', authors = " + authors.toString());
- return author;
- }
-
- /**
- * Adds an author name and a corresponding IP to internal Map.
- * @param ip IP address of the author.
- * @param author name of author.
- */
- public static void setAuthor(final String ip, final String author) {
- AUTHORS.put(ip,author);
- }
-
- /**
- * Creates new Entry.
- * @param subject subject of entry.
- * @param author author of entry.
- * @param ip IP address of author.
- * @param reason reason for new Entry (for example "edit").
- * @param page content of Entry.
- * @return new Entry.
- * @throws IOException
- */
- public Entry newEntry(final String subject, final String author, final String ip, final String reason, final byte[] page) throws IOException {
- return new Entry(normalize(subject), author, ip, reason, page);
- }
-
- /**
- * Contains information of wiki page.
- */
- public class Entry {
- private static final String ANONYMOUS = "anonymous";
-
- private final String key;
- private final Map<String, String> record;
-
- /**
- * Constructor which creates new Entry using given information.
- * @param subject subject of Entry.
- * @param author author of Entry.
- * @param ip IP address of author.
- * @param reason reason for new Entry (for example "edit").
- * @param page content of Entry.
- * @throws IOException
- */
- public Entry(final String subject, final String author, final String ip, final String reason, final byte[] page) throws IOException {
- this.record = new HashMap<String, String>();
- this.key = subject.substring(0, Math.min((subject != null) ? subject.length() : 0, keyLength));
- this.record.put("date", dateString());
- this.record.put("author", Base64Order.enhancedCoder.encodeString((author != null && author.length() > 0) ? author : ANONYMOUS));
- this.record.put("ip", (ip != null && ip.length() > 0) ? ip : "");
- this.record.put("reason", Base64Order.enhancedCoder.encodeString((reason != null && reason.length() > 0) ? reason : ""));
- this.record.put("page", (page != null) ? Base64Order.enhancedCoder.encode(page) : "");
- AUTHORS.put(ip, author);
- }
-
- /**
- * Constructor which creates Entry using key and record.
- * @param key key of Entry.
- * @param record record which contains data.
- */
- Entry(final String key, final Map<String, String> record) {
- this.key = key;
- this.record = record;
- }
-
- /**
- * Gets subject of Entry.
- * @return subject of entry.
- */
- public String subject() {
- return this.key;
- }
-
- /**
- * Gets date of Entry.
- * @return date of Entry.
- */
- public Date date() {
- Date ret;
- try {
- final String c = this.record.get("date");
- if (c == null) {
- System.out.println("DEBUG - ERROR: date field missing in wikiBoard");
- ret = new Date();
- } else {
- synchronized (SimpleFormatter) {
- ret = SimpleFormatter.parse(c);
- }
- }
- } catch (final ParseException e) {
- ret = new Date();
- }
- return ret;
- }
-
- /**
- * Gets author of Entry.
- * @return author of Entry.
- */
- public String author() {
- final String a = this.record.get("author");
- final byte[] b;
- return (a != null && (b = Base64Order.enhancedCoder.decode(a)) != null) ? UTF8.String(b) : ANONYMOUS;
- }
-
- /**
- * Gets reason for Entry.
- * @return reason for Entry.
- */
- public String reason() {
- final String ret;
- final String r = this.record.get("reason");
- if (r != null) {
- final byte[] b;
- ret = ((b = Base64Order.enhancedCoder.decode(r)) != null) ? UTF8.String(b) : "unknown";
- } else {
- ret = "";
- }
- return ret;
- }
-
- /**
- * Gets actual content of Entry.
- * @return content of Entry.
- */
- public byte[] page() {
- final String m = this.record.get("page");
- final byte[] b;
- return (m != null && (b = Base64Order.enhancedCoder.decode(m)) != null) ? b : new byte[0];
- }
-
- /**
- * Sets date of previous version of Entry.
- * @param date date of previous version of Entry.
- */
- void setAncestorDate(final Date date) {
- this.record.put("bkp", dateString(date));
- }
-
- /**
- * Gets date of previous version of Entry.
- * @return date of previous version of Entry.
- */
- private Date getAncestorDate() {
- Date ret = null;
- try {
- final String c = this.record.get("date");
- if (c != null) {
- synchronized (SimpleFormatter) {
- ret = SimpleFormatter.parse(c);
- }
- }
- } catch (final ParseException e) {
- ret = null;
- }
- return ret;
- }
-
- /**
- * Gets previous version of Entry.
- * @return previous version of Entry.
- */
- public Entry getAncestor() {
- final Date ancDate = getAncestorDate();
- return (ancDate == null) ? null : read(this.key + dateString(ancDate), WikiBoard.this.bkpbase);
- }
-
- /**
- * Adds child of current Entry.
- * @param subject subject of child of current Entry.
- */
- void setChild(final String subject) {
- this.record.put("child", Base64Order.enhancedCoder.encode(UTF8.getBytes(subject)));
- }
-
- /**
- * Gets name (= subject) of child of this Entry.
- * @return name of child of this Entry.
- */
- private String getChildName() {
- final String c = this.record.get("child");
- final byte[] subject;
- return (c != null && (subject = Base64Order.enhancedCoder.decode(c)) != null) ? ASCII.String(subject) : null;
- }
-
- /**
- * Tells if Entry has child.
- * @return true if has child, else false.
- */
- public boolean hasChild() {
- final String c = this.record.get("child");
- return (c != null && Base64Order.enhancedCoder.decode(c) != null) ? true : false;
- }
-
- /**
- * Gets child of this Entry.
- * @return child of this Entry.
- */
- public Entry getChild() {
- final String childName = getChildName();
- return (childName == null) ? null : read(childName, WikiBoard.this.datbase);
- }
- }
-
- /**
- * Writes content of Entry to database and returns key.
- * @param entry Entry to be written.
- * @return key of Entry.
- */
- public String write(final Entry entry) {
- // writes a new page and returns key
- String key = null;
- try {
- // first load the old page
- final Entry oldEntry = read(entry.key);
- // set the bkp date of the new page to the date of the old page
- final Date oldDate = oldEntry.date();
- entry.setAncestorDate(oldDate);
- oldEntry.setChild(entry.subject());
- // write the backup
- this.bkpbase.insert(UTF8.getBytes(entry.key + dateString(oldDate)), oldEntry.record);
- // write the new page
- this.datbase.insert(UTF8.getBytes(entry.key), entry.record);
- key = entry.key;
- } catch (final Exception e) {
- ConcurrentLog.logException(e);
- }
- return key;
- }
-
- /**
- * Reads content of Entry from database.
- * @param key key of Entry.
- * @return Entry which contains data.
- */
- public Entry read(final String key) {
- return read(key, this.datbase);
- }
-
- /**
- * Reads content of Entry from database.
- * @param key key of Entry.
- * @param base database containing data.
- * @return Entry which contains data.
- */
- Entry read(final String key, final MapHeap base) {
- Entry ret = null;
- try {
- String copyOfKey = normalize(key);
- if (copyOfKey.length() > keyLength) {
- copyOfKey = copyOfKey.substring(0, keyLength);
- }
- final Map<String, String> record = base.get(UTF8.getBytes(copyOfKey));
- ret = (record == null) ? newEntry(copyOfKey, ANONYMOUS, Domains.LOCALHOST, "New Page", UTF8.getBytes("")) : new Entry(copyOfKey, record);
- } catch (final IOException e) {
- ConcurrentLog.logException(e);
- } catch (final SpaceExceededException e) {
- ConcurrentLog.logException(e);
- }
- return ret;
- }
-
- /**
- * Reads old Entry from backup database.
- * @param key key of Entry.
- * @return the Entry.
- */
- public Entry readBkp(final String key) {
- return read(key, this.bkpbase);
- }
-
- /**
- * Gets Iterator of keys in database.
- * @param up
- * @return keys of Entries in database.
- * @throws IOException
- */
- public Iterator<byte[]> keys(final boolean up) throws IOException {
- return this.datbase.keys(up, false);
- }
-
- /**
- * Gets Iterator of keys in backup database.
- * @param up
- * @return keys of Entries in backup database.
- * @throws IOException
- */
- public Iterator<byte[]> keysBkp(final boolean up) throws IOException {
- return this.bkpbase.keys(up, false);
- }
-}
diff --git a/source/net/yacy/data/wiki/WikiCode.java b/source/net/yacy/data/wiki/WikiCode.java
index 2851b31bc..20d87ab81 100644
--- a/source/net/yacy/data/wiki/WikiCode.java
+++ b/source/net/yacy/data/wiki/WikiCode.java
@@ -37,8 +37,7 @@ import java.util.regex.Pattern;
import net.yacy.document.parser.html.CharacterCoding;
import net.yacy.server.serverCore;
-/** Provides methods to handle texts that have been posted in the yacyWiki or other
- * parts of YaCy which use wiki code, like the blog or the profile.
+/** Provides methods to render WikiCode used by MediaWiki import, messages and profiles.
*
* @author Alexander Schier [AS], Franz Brausze [FB], Marc Nause [MN]
*/
@@ -584,7 +583,7 @@ public class WikiCode extends AbstractWikiParser implements WikiParser {
/**
* Processes tags which are connected to links and images.
* @author [AS], [MN]
- * @param hostport (optional) host and port, added when not empty as the base of relative Wiki link URLs.
+ * @param hostport optional host and port used as the base of relative media URLs.
* @param line line of text to be transformed from wiki code to HTML
* @return HTML fragment
*/
@@ -661,17 +660,18 @@ public class WikiCode extends AbstractWikiParser implements WikiParser {
line = line.substring(0, positionOfOpeningTag) + "" + "<iframe src=\"http://player.vimeo.com/video/" + kl + "\" width=\"425\" height=\"350\" frameborder=\"0\" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>";
break;
}
- // if it's no image, it might be an internal link
- else {
+ // Internal links used to target the retired local Wiki application. Keep
+ // their labels as plain rendered text instead of producing dead links.
+ else {
if ((p = kl.indexOf(PIPE_ESCAPED)) > 0) {
kv = kl.substring(p + LEN_PIPE_ESCAPED);
kl = kl.substring(0, p);
} else {
kv = kl;
- }
- line = line.substring(0, positionOfOpeningTag) + "<a class=\"known\" href=\"Wiki.html?page=" + kl + "\">" + kv + "</a>" + line.substring(positionOfClosingTag + LEN_WIKI_CLOSE_LINK); // oob exception in append() !
- fromIndex = positionOfClosingTag + LEN_WIKI_CLOSE_LINK;
- }
+ }
+ line = line.substring(0, positionOfOpeningTag) + kv + line.substring(positionOfClosingTag + LEN_WIKI_CLOSE_LINK);
+ fromIndex = positionOfOpeningTag + kv.length();
+ }
}
fromIndex = 0;
diff --git a/source/net/yacy/htroot/Blog.java b/source/net/yacy/htroot/Blog.java
deleted file mode 100644
index d0067b298..000000000
--- a/source/net/yacy/htroot/Blog.java
+++ /dev/null
@@ -1,343 +0,0 @@
-// Blog.java
-// -----------------------
-// part of YACY
-// (C) by Michael Peter Christen; mc@yacy.net
-// first published on http://www.anomic.de
-// Frankfurt, Germany, 2004
-//
-// This File is contributed by Jan Sandbrink
-// Contains contributions from Marc Nause [MN]
-//
-//$LastChangedDate$
-//$LastChangedRevision$
-//$LastChangedBy$
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-// You must compile this file with
-// javac -classpath .:../classes Blog.java
-// if the shell's current path is HTROOT
-
-package net.yacy.htroot;
-
-import java.text.DateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import net.yacy.cora.document.encoding.UTF8;
-import net.yacy.cora.protocol.HeaderFramework;
-import net.yacy.cora.protocol.RequestHeader;
-import net.yacy.data.BlogBoard;
-import net.yacy.data.UserDB;
-import net.yacy.http.servlets.YaCyDefaultServlet;
-import net.yacy.peers.NewsPool;
-import net.yacy.peers.Seed;
-import net.yacy.search.Switchboard;
-import net.yacy.server.serverObjects;
-import net.yacy.server.serverSwitch;
-
-public class Blog {
-
- private static final String DEFAULT_PAGE = "blog_default";
-
- private static DateFormat SimpleFormatter = DateFormat.getDateTimeInstance(DateFormat.DEFAULT,DateFormat.DEFAULT, Locale.getDefault());
-
- /**
- * print localized date/time "yyyy/mm/dd HH:mm:ss"
- * @param date
- * @return
- */
- public static String dateString(final Date date) {
- return SimpleFormatter.format(date);
- }
-
- public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
- final Switchboard sb = (Switchboard) env;
- final serverObjects prop = new serverObjects();
- BlogBoard.BlogEntry page = null;
-
- boolean hasRights = sb.verifyAuthentication(header);
-
- //final int display = (hasRights || post == null) ? 1 : post.getInt("display", 0);
- //prop.put("display", display);
- prop.put("display", 1); // Fixed to 1
-
-
- final boolean xml = header.getPathInfo().endsWith(".xml");
- /* Peer URL base : used to generate absolute URLs in Blog.rss */
- final String context = YaCyDefaultServlet.getContext(header, sb);
-
- prop.put("mode_admin", hasRights ? "1" : "0");
-
- if (post == null) {
- prop.putHTML("peername", sb.peers.mySeed().getName());
- prop.put("context", context);
- return putBlogDefault(prop, sb, context, 0, 10, hasRights, xml);
- }
-
- final int start = post.getInt("start",0); //indicates from where entries should be shown
- final int num = post.getInt("num",10); //indicates how many entries should be shown
-
- if (!hasRights) {
- final UserDB.Entry userentry = sb.userDB.proxyAuth(header);
- if (userentry != null && userentry.hasRight(UserDB.AccessRight.BLOG_RIGHT)) {
- hasRights=true;
- } else if (post.containsKey("login")) {
- //opens login window if login link is clicked
- prop.authenticationRequired();
- }
- }
-
- String pagename = post.get("page", DEFAULT_PAGE);
- final String ip = header.getRemoteAddr();
-
- String strAuthor = post.get("author", "anonymous");
-
- if ("anonymous".equals(strAuthor)) {
- strAuthor = sb.blogDB.guessAuthor(ip);
-
- if (strAuthor == null || strAuthor.isEmpty()) {
- if (sb.peers.mySeed() == null) {
- strAuthor = "anonymous";
- } else {
- strAuthor = sb.peers.mySeed().get(Seed.NAME, "anonymous");
- }
- }
- }
-
- byte[] author;
- author = UTF8.getBytes(strAuthor);
-
- if (hasRights && post.containsKey("delete") && "sure".equals(post.get("delete"))) {
- page = sb.blogDB.readBlogEntry(pagename);
- for (final String comment : page.getComments()) {
- sb.blogCommentDB.delete(comment);
- }
- sb.blogDB.deleteBlogEntry(pagename);
- pagename = DEFAULT_PAGE;
- }
-
- if (post.containsKey("discard")) {
- pagename = DEFAULT_PAGE;
- }
-
- if (post.containsKey("submit") && hasRights) {
- // store a new/edited blog-entry
- byte[] content;
- content = UTF8.getBytes(post.get("content", ""));
-
- final Date date;
- List<String> comments = null;
-
- //set name for new entry or date for old entry
- if (DEFAULT_PAGE.equals(pagename)) {
- pagename = String.valueOf(System.currentTimeMillis());
- date = null;
- } else {
- page = sb.blogDB.readBlogEntry(pagename);
- comments = page.getComments();
- date = page.getDate();
- }
- final String commentMode = post.get("commentMode", "2");
- final String StrSubject = post.get("subject", "");
- byte[] subject;
- subject = UTF8.getBytes(StrSubject);
-
- sb.blogDB.writeBlogEntry(sb.blogDB.newEntry(pagename, subject, author, ip, date, content, comments, commentMode));
-
- // create a news message
- if (!sb.isRobinsonMode()) {
- final Map<String, String> map = new HashMap<>();
- map.put("page", pagename);
- map.put("subject", StrSubject.replace(',', ' '));
- map.put("author", strAuthor.replace(',', ' '));
- sb.peers.newsPool.publishMyNews(sb.peers.mySeed(), NewsPool.CATEGORY_BLOG_ADD, map);
- }
- }
-
- page = sb.blogDB.readBlogEntry(pagename); //maybe "if(page == null)"
-
- if (post.containsKey("edit")) {
- //edit an entry
- if(hasRights) {
- prop.put("mode", "1"); //edit
- prop.put("mode_commentMode", page.getCommentMode());
- prop.putHTML("mode_author", UTF8.String(page.getAuthor()));
- prop.put("mode_pageid", page.getKey());
- prop.putHTML("mode_subject", UTF8.String(page.getSubject()));
- prop.put("mode_page-code", UTF8.String(page.getPage()));
- }
- else {
- prop.put("mode", "3"); //access denied (no rights)
- }
- } else if(post.containsKey("preview")) {
- //preview the page
- if(hasRights) {
- prop.put("mode", "2");//preview
- prop.put("mode_commentMode", post.getInt("commentMode", 2));
- prop.putHTML("mode_pageid", pagename);
- prop.putHTML("mode_author", UTF8.String(author));
- prop.putHTML("mode_subject", post.get("subject",""));
- prop.put("mode_date", dateString(new Date()));
- prop.putWiki("mode_page", post.get("content", ""));
- prop.putHTML("mode_page-code", post.get("content", ""));
- }
- else {
- prop.put("mode", "3"); //access denied (no rights)
- }
- }
- else if("try".equals(post.get("delete", ""))) {
- if(hasRights) {
- prop.put("mode", "4");
- prop.putHTML("mode_pageid", pagename);
- prop.putHTML("mode_author",UTF8.String(page.getAuthor()));
- prop.putHTML("mode_subject",UTF8.String(page.getSubject()));
- }
- else prop.put("mode", "3"); //access denied (no rights)
- }
- else if (post.containsKey("import")) {
- prop.put("mode", "5");
- prop.put("mode_state", "0");
- }
- else if (post.containsKey("xmlfile")) {
- prop.put("mode", "5");
- if (sb.blogDB.importXML(post.getInputStream("xmlfile$file"))) {
- prop.put("mode_state", "1");
- }
- else {
- prop.put("mode_state", "2");
- }
- }
- else {
- // show blog-entry/entries
- prop.put("mode", "0"); //viewing
- if(DEFAULT_PAGE.equals(pagename)) {
- // XXX: where are "peername" and "address" used in the template?
- // XXX: "clientname" is already set to the peername, no need for a new setting
- prop.putHTML("peername", sb.peers.mySeed().getName());
- prop.put("context", context);
- //index all entries
- putBlogDefault(prop, sb, context, start, num, hasRights, xml);
- }
- else {
- //only show 1 entry
- prop.put("mode_entries", "1");
- putBlogEntry(prop, page, context, 0, hasRights, xml);
- }
- }
-
- // return rewrite properties
- return prop;
- }
-
- private static serverObjects putBlogDefault(
- final serverObjects prop,
- final Switchboard switchboard,
- final String context,
- int start,
- int num,
- final boolean hasRights,
- final boolean xml)
- {
- final Iterator<String> i = switchboard.blogDB.getBlogIterator(false);
-
- int count = 0; //counts how many entries are shown to the user
- if (xml) {
- num = 0;
- }
- final int nextstart = start+num; //indicates the starting offset for next results
- int prevstart = start-num; //indicates the starting offset for previous results
-
- while (i.hasNext() && (num == 0 || num > count)) {
- if(0 < start--) continue;
- putBlogEntry(
- prop,
- switchboard.blogDB.readBlogEntry(i.next()),
- context,
- count++,
- hasRights,
- xml);
- }
- prop.put("mode_entries", count);
-
- if (i.hasNext()) {
- prop.put("mode_moreentries", "1"); //more entries are availible
- prop.put("mode_moreentries_start", nextstart);
- prop.put("mode_moreentries_num", num);
- } else {
- prop.put("moreentries", "0");
- }
-
- if (start > 0) {
- prop.put("mode_preventries", "1");
- if (prevstart < 0) {
- prevstart = 0;
- }
- prop.put("mode_preventries_start", prevstart);
- prop.put("mode_preventries_num", num);
- } else prop.put("mode_preventries", "0");
-
- return prop;
- }
-
- private static serverObjects putBlogEntry(
- final serverObjects prop,
- final BlogBoard.BlogEntry entry,
- final String context,
- final int number,
- final boolean hasRights,
- final boolean xml)
- {
- prop.putHTML("mode_entries_" + number + "_subject", UTF8.String(entry.getSubject()));
-
- prop.putHTML("mode_entries_" + number + "_author", UTF8.String(entry.getAuthor()));
-
- // comments
- if (entry.getCommentMode() == 0) {
- prop.put("mode_entries_" + number + "_commentsactive", "0");
- } else {
- prop.put("mode_entries_" + number + "_commentsactive", "1");
- prop.put("mode_entries_" + number + "_commentsactive_pageid", entry.getKey());
- prop.put("mode_entries_" + number + "_commentsactive_context", context);
- prop.put("mode_entries_" + number + "_commentsactive_comments", entry.getCommentsSize());
- }
-
- prop.put("mode_entries_" + number + "_date", dateString(entry.getDate()));
- prop.put("mode_entries_" + number + "_rfc822date", HeaderFramework.formatRFC1123(entry.getDate()));
- prop.put("mode_entries_" + number + "_pageid", entry.getKey());
- prop.put("mode_entries_" + number + "_context", context);
- prop.put("mode_entries_" + number + "_ip", entry.getIp());
-
- if (xml) {
- prop.put("mode_entries_" + number + "_page", entry.getPage());
- prop.put("mode_entries_" + number + "_timestamp", entry.getTimestamp());
- } else {
- prop.putWiki("mode_entries_" + number + "_page", entry.getPage());
- }
-
- if (hasRights) {
- prop.put("mode_entries_" + number + "_admin", "1");
- prop.put("mode_entries_" + number + "_admin_pageid",entry.getKey());
- } else {
- prop.put("mode_entries_" + number + "_admin", "0");
- }
-
- return prop;
- }
-}
diff --git a/source/net/yacy/htroot/BlogComments.java b/source/net/yacy/htroot/BlogComments.java
deleted file mode 100644
index 8dbb43536..000000000
--- a/source/net/yacy/htroot/BlogComments.java
+++ /dev/null
@@ -1,331 +0,0 @@
-// BlogComments.java
-// -----------------------
-// part of YACY
-// (C) by Michael Peter Christen; mc@yacy.net
-// first published on http://www.anomic.de
-// Frankfurt, Germany, 2004
-//
-// This File is contributed by Jan Sandbrink
-//
-//$LastChangedDate$
-//$LastChangedRevision$
-//$LastChangedBy$
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-// You must compile this file with
-// javac -classpath .:../Classes Blacklist_p.java
-// if the shell's current path is HTROOT
-
-package net.yacy.htroot;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Date;
-import java.util.Iterator;
-
-import com.google.common.io.Files;
-
-import net.yacy.cora.document.encoding.UTF8;
-import net.yacy.cora.protocol.Domains;
-import net.yacy.cora.protocol.HeaderFramework;
-import net.yacy.cora.protocol.RequestHeader;
-import net.yacy.cora.util.CommonPattern;
-import net.yacy.cora.util.ConcurrentLog;
-import net.yacy.data.BlogBoard;
-import net.yacy.data.BlogBoard.BlogEntry;
-import net.yacy.data.BlogBoardComments;
-import net.yacy.data.MessageBoard;
-import net.yacy.data.UserDB;
-import net.yacy.peers.Network;
-import net.yacy.peers.Seed;
-import net.yacy.search.Switchboard;
-import net.yacy.search.SwitchboardConstants;
-import net.yacy.server.serverObjects;
-import net.yacy.server.serverSwitch;
-
-
-public class BlogComments {
-
- private static final String DEFAULT_PAGE = "blog_default";
-
- public static String dateString(final Date date) {
- return Blog.dateString(date);
- }
-
- public static serverObjects respond(final RequestHeader header, serverObjects post, final serverSwitch env) {
- final Switchboard sb = (Switchboard) env;
- final serverObjects prop = new serverObjects();
- boolean hasRights = sb.verifyAuthentication(header);
-
- prop.put("mode_admin", hasRights ? "1" : "0");
-
- if (post == null) {
- post = new serverObjects();
- post.put("page", "blog_default");
- }
-
- if (!hasRights) {
- final UserDB.Entry userentry = sb.userDB.proxyAuth(header);
- if (userentry != null && userentry.hasRight(UserDB.AccessRight.BLOG_RIGHT)) {
- hasRights = true;
- } else if (post.containsKey("login")) {
- //opens login window if login link is clicked
- prop.authenticationRequired();
- }
- }
-
- final String pagename = post.get("page", DEFAULT_PAGE);
- final String ip = post.get(HeaderFramework.CONNECTION_PROP_CLIENTIP, Domains.LOCALHOST);
-
- String strAuthor = post.get("author", "anonymous");
-
- if ("anonymous".equals(strAuthor)) {
- strAuthor = sb.blogDB.guessAuthor(ip);
-
- if (strAuthor == null || strAuthor.isEmpty()) {
- if (sb.peers.mySeed() == null) {
- strAuthor = "anonymous";
- } else {
- strAuthor = sb.peers.mySeed().get(Seed.NAME, "anonymous");
- }
- }
- }
-
- byte[] author;
- author = UTF8.getBytes(strAuthor);
-
- final BlogBoard.BlogEntry page = sb.blogDB.readBlogEntry(pagename); //maybe "if(page == null)"
- final boolean pageExists = sb.blogDB.contains(pagename);
-
- // comments not allowed
- prop.put("mode_allow", (page.getCommentMode() == 0) ? 0 : 1);
-
- if (post.containsKey("submit") && page.getCommentMode() != 0 && pageExists) {
- // store a new/edited blog-entry
- byte[] content;
- if (!"".equals(post.get("content", ""))) {
- if ("".equals(post.get("subject", ""))) {
- post.putHTML("subject", "no title");
- }
- content = UTF8.getBytes(post.get("content", ""));
-
- final Date date = null;
-
- //set name for new entry or date for old entry
- final String StrSubject = post.get("subject", "");
- byte[] subject;
- subject = UTF8.getBytes(StrSubject);
- final String commentID = String.valueOf(System.currentTimeMillis());
- final BlogEntry blogEntry = sb.blogDB.readBlogEntry(pagename);
- blogEntry.addComment(commentID);
- sb.blogDB.writeBlogEntry(blogEntry);
- sb.blogCommentDB.write(sb.blogCommentDB.newEntry(commentID, subject, author, ip, date, content));
- prop.putHTML(serverObjects.ACTION_LOCATION,"BlogComments.html?page=" + pagename);
-
- final MessageBoard.entry msgEntry = sb.messageDB.newEntry(
- "blogComment",
- strAuthor,
- sb.peers.mySeed().hash,
- sb.peers.mySeed().getName(), sb.peers.mySeed().hash,
- "new blog comment: " + UTF8.String(blogEntry.getSubject()), content);
- sb.messageDB.write(msgEntry);
-
- messageForwardingViaEmail(sb, msgEntry);
-
- // finally write notification
- final File notifierSource = new File(sb.getAppPath(), sb.getConfig(SwitchboardConstants.HTROOT_PATH, SwitchboardConstants.HTROOT_PATH_DEFAULT) + "/env/grafics/message.gif");
- final File notifierDest = new File(sb.getDataPath(SwitchboardConstants.HTDOCS_PATH, SwitchboardConstants.HTDOCS_PATH_DEFAULT), "notifier.gif");
- try {
- Files.copy(notifierSource, notifierDest);
- } catch (final IOException e) {
- ConcurrentLog.severe("MESSAGE", "NEW MESSAGE ARRIVED! (error: " + e.getMessage() + ")");
-
- }
- }
- }
-
- if (hasRights && post.containsKey("delete") && post.containsKey("page") &&
- post.containsKey("comment") && page.removeComment(post.get("comment"))) {
- sb.blogCommentDB.delete(post.get("comment"));
- }
-
- if (hasRights && post.containsKey("allow") && post.containsKey("page") && post.containsKey("comment")) {
- final BlogBoardComments.CommentEntry entry = sb.blogCommentDB.read(post.get("comment"));
- entry.allow();
- sb.blogCommentDB.write(entry);
- }
-
- if (post.containsKey("preview") && page.getCommentMode() != 0) {
- //preview the page
- prop.put("mode", "1");//preview
- prop.putHTML("mode_pageid", pagename);
- prop.putHTML("mode_allow_pageid", pagename);
- prop.putHTML("mode_author", UTF8.String(author));
- prop.putHTML("mode_allow_author", UTF8.String(author));
- prop.putHTML("mode_subject", post.get("subject",""));
- prop.put("mode_date", dateString(new Date()));
- prop.putWiki("mode_page", post.get("content", ""));
- prop.put("mode_page-code", post.get("content", ""));
- } else {
- // show blog-entry/entries
- prop.put("mode", "0"); //viewing
- if("blog_default".equals(pagename)) {
- prop.put(serverObjects.ACTION_LOCATION,"Blog.html");
- } else {
- //show 1 blog entry
- prop.put("mode_pageid", page.getKey());
- prop.putHTML("mode_allow_pageid", pagename);
- prop.putHTML("mode_subject", UTF8.String(page.getSubject()));
- prop.putHTML("mode_author", UTF8.String(page.getAuthor()));
- prop.putHTML("mode_allow_author", UTF8.String(author));
- prop.put("mode_comments", page.getCommentsSize());
- prop.put("mode_date", dateString(page.getDate()));
- prop.putWiki("mode_page", page.getPage());
- if (hasRights) {
- prop.put("mode_admin", "1");
- prop.put("mode_admin_pageid", page.getKey());
- }
- final Iterator<String> i = page.getComments().iterator();
- final int commentMode = page.getCommentMode();
- String pageid;
- BlogBoardComments.CommentEntry entry;
- final boolean xml = post.containsKey("xml");
- int count = 0; //counts how many entries are shown to the user
- int start = post.getInt("start",0); //indicates from where entries should be shown
- int num = post.getInt("num",10); //indicates how many entries should be shown
-
- if (xml) {
- num = 0;
- }
- if (start < 0) {
- start = 0;
- }
-
- final int nextstart = start + num; //indicates the starting offset for next results
- int prevstart = start - num; //indicates the starting offset for previous results
- while (i.hasNext() && count < num) {
-
- pageid = i.next();
-
- if(start > 0) {
- start--;
- continue;
- }
-
- entry = sb.blogCommentDB.read(pageid);
-
- if (commentMode == 2 && !hasRights && !entry.isAllowed()) {
- continue;
- }
-
- prop.put("mode", "0");
- prop.put("mode_entries_"+count+"_pageid", entry.getKey());
- if (!xml) {
- prop.putHTML("mode_entries_"+count+"_subject", UTF8.String(entry.getSubject()));
- prop.putHTML("mode_entries_"+count+"_author", UTF8.String(entry.getAuthor()));
- prop.putWiki("mode_entries_"+count+"_page", entry.getPage());
- } else {
- prop.putHTML("mode_entries_"+count+"_subject", UTF8.String(entry.getSubject()));
- prop.putHTML("mode_entries_"+count+"_author", UTF8.String(entry.getAuthor()));
- prop.put("mode_entries_"+count+"_page", entry.getPage());
- prop.put("mode_entries_"+count+"_timestamp", entry.getTimestamp());
- }
- prop.put("mode_entries_"+count+"_date", dateString(entry.getDate()));
- prop.put("mode_entries_"+count+"_ip", entry.getIp());
- if(hasRights) {
- prop.put("mode_entries_"+count+"_admin", "1");
- prop.put("mode_entries_"+count+"_admin_pageid", page.getKey());
- prop.put("mode_entries_"+count+"_admin_commentid", pageid);
- if(page.getCommentMode() == 2 && !entry.isAllowed()) {
- prop.put("mode_entries_"+count+"_admin_moderate", "1");
- prop.put("mode_entries_"+count+"_admin_moderate_pageid", page.getKey());
- prop.put("mode_entries_"+count+"_admin_moderate_commentid", pageid);
-
- }
- }
- else prop.put("mode_entries_"+count+"_admin", 0);
- ++count;
- }
- prop.put ("mode_entries", count);
- if (i.hasNext()) {
- prop.put("mode_moreentries", "1"); //more entries are availible
- prop.put("mode_moreentries_start", nextstart);
- prop.put("mode_moreentries_num", num);
- prop.put("mode_moreentries_pageid", page.getKey());
- }
- else prop.put("mode_moreentries", "0");
- if (start > 1) {
- prop.put("mode_preventries", "1");
- if (prevstart < 0) prevstart = 0;
- prop.put("mode_preventries_start", prevstart);
- prop.put("mode_preventries_num", num);
- prop.put("mode_preventries_pageid", page.getKey());
- } else prop.put("mode_preventries", "0");
- }
- }
-
- // return rewrite properties
- return prop;
- }
-
- private static void messageForwardingViaEmail(final Switchboard sb, final MessageBoard.entry msgEntry) {
- try {
- if (!sb.getConfigBool("msgForwardingEnabled",false)) {
- return;
- }
-
- // get the recipient address
- final String sendMailTo = sb.getConfig("msgForwardingTo","root@localhost").trim();
-
- // get the sendmail configuration
- final String sendMailStr = sb.getConfig("msgForwardingCmd","/usr/bin/sendmail")+" "+sendMailTo;
- final String[] sendMail = CommonPattern.SPACE.split(sendMailStr.trim());
-
- // build the message text
- final StringBuilder emailTxt = new StringBuilder();
- emailTxt.append("To: ")
- .append(sendMailTo)
- .append("\nFrom: ")
- .append("yacy@")
- .append(sb.peers.mySeed().getName())
- .append("\nSubject: [YaCy] ")
- .append(msgEntry.subject().replace('\n', ' '))
- .append("\nDate: ")
- .append(msgEntry.date())
- .append("\n")
- .append("\nMessage from: ")
- .append(msgEntry.author())
- .append("/")
- .append(msgEntry.authorHash())
- .append("\nMessage to: ")
- .append(msgEntry.recipient())
- .append("/")
- .append(msgEntry.recipientHash())
- .append("\nCategory: ")
- .append(msgEntry.category())
- .append("\n===================================================================\n")
- .append(UTF8.String(msgEntry.message()));
-
- final Process process=Runtime.getRuntime().exec(sendMail);
- final PrintWriter email = new PrintWriter(process.getOutputStream());
- email.print(new String(emailTxt));
- email.close();
- } catch (final Exception e) {
- Network.log.warn("message: message forwarding via email failed. ",e);
- }
- }
-}
diff --git a/source/net/yacy/htroot/Bookmarks.java b/source/net/yacy/htroot/Bookmarks.java
index 9ac240260..28a6ea053 100644
--- a/source/net/yacy/htroot/Bookmarks.java
+++ b/source/net/yacy/htroot/Bookmarks.java
@@ -53,7 +53,6 @@ import net.yacy.data.BookmarksDB;
import net.yacy.data.BookmarksDB.Bookmark;
import net.yacy.data.BookmarksDB.Tag;
import net.yacy.data.ListManager;
-import net.yacy.data.UserDB;
import net.yacy.document.Document;
import net.yacy.document.Parser;
import net.yacy.http.servlets.YaCyDefaultServlet;
@@ -62,6 +61,7 @@ import net.yacy.kelondro.workflow.BusyThread;
import net.yacy.peers.NewsPool;
import net.yacy.search.AutoSearch;
import net.yacy.search.Switchboard;
+import net.yacy.search.SwitchboardConstants;
import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch;
@@ -70,7 +70,6 @@ public class Bookmarks {
private static final serverObjects prop = new serverObjects();
private static Switchboard sb = null;
- private static UserDB.Entry user = null;
private static boolean isAdmin = false;
final static int SORT_ALPHA = 1;
@@ -88,18 +87,15 @@ public class Bookmarks {
int start=0;
int display = 0;
String tagName = "";
- String username="";
+ String username="";
prop.clear();
sb = (Switchboard) env;
- user = sb.userDB.getUser(header);
- isAdmin = (sb.verifyAuthentication(header) || user!= null && user.hasRight(UserDB.AccessRight.BOOKMARK_RIGHT));
-
- // set user name
- if (user != null) {
- username=user.getUserName();
- } else if(isAdmin) {
- username="admin";
+ isAdmin = sb.verifyAuthentication(header);
+
+ // set user name
+ if(isAdmin) {
+ username=sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin");
}
prop.putHTML("user", username);
@@ -164,10 +160,6 @@ public class Bookmarks {
bookmark.setProperty(BookmarksDB.Bookmark.BOOKMARK_TITLE, title);
bookmark.setProperty(BookmarksDB.Bookmark.BOOKMARK_DESCRIPTION, description);
- if (user!=null) {
- bookmark.setOwner(user.getUserName());
- }
-
if ("public".equals(post.get("public"))) {
bookmark.setPublic(true);
publishNews(url, title, description, tagsString);
diff --git a/source/net/yacy/htroot/ConfigAccountList_p.java b/source/net/yacy/htroot/ConfigAccountList_p.java
deleted file mode 100644
index 7a3dff960..000000000
--- a/source/net/yacy/htroot/ConfigAccountList_p.java
+++ /dev/null
@@ -1,106 +0,0 @@
-// ConfigAccountList_p.java
-// -------------------------
-// (c) 2017 by reger24; https://github.com/reger24
-//
-// This is a part of YaCy, a peer-to-peer based web search engine
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-package net.yacy.htroot;
-
-import java.util.Iterator;
-
-import net.yacy.cora.date.GenericFormatter;
-import net.yacy.cora.protocol.RequestHeader;
-import net.yacy.data.UserDB;
-import net.yacy.data.UserDB.AccessRight;
-import net.yacy.search.Switchboard;
-import net.yacy.server.serverObjects;
-import net.yacy.server.serverSwitch;
-
-public class ConfigAccountList_p {
-
- public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, @SuppressWarnings("unused") final serverObjects post, final serverSwitch env) {
-
- final serverObjects prop = new serverObjects();
- final Switchboard sb = (Switchboard) env;
- UserDB.Entry entry;
-
- if (sb.userDB == null) {
- prop.put("userlist", 0);
- return prop;
- }
-
- //Generate Userlist
- final Iterator<UserDB.Entry> it = sb.userDB.iterator(true);
- int numUsers = 0;
- while (it.hasNext()) {
- entry = it.next();
- if (entry == null) {
- continue;
- }
- prop.putHTML("userlist_" + numUsers + "_username", entry.getUserName());
- prop.putHTML("userlist_" + numUsers + "_lastname", entry.getLastName());
- prop.putHTML("userlist_" + numUsers + "_firstname", entry.getFirstName());
- prop.putHTML("userlist_" + numUsers + "_address", entry.getAddress());
- if (entry.getLastAccess() != null) {
- prop.put("userlist_" + numUsers + "_lastaccess",
- GenericFormatter.formatSafely(entry.getLastAccess(), GenericFormatter.FORMAT_SIMPLE));
- } else {
- prop.put("userlist_" + numUsers + "_lastaccess", "never");
- }
-
- final AccessRight[] rights = AccessRight.values();
- String rightStr = "";
- for (final AccessRight right : rights) {
- if (entry.hasRight(right)) {
- if (rightStr.isEmpty()) {
- rightStr = right.getFriendlyName();
- } else {
- rightStr += ", " + right.getFriendlyName();
- }
- }
- }
- prop.putHTML("userlist_" + numUsers + "_rights", rightStr);
-
- long percent;
- if (entry.getTrafficLimit() != null) {
- final long limit = entry.getTrafficLimit();
- final long used = entry.getTrafficSize();
- percent = used * 100 / limit;
- prop.put("userlist_" + numUsers + "_time", percent);
- } else {
- prop.put("userlist_" + numUsers + "_time", "");
- }
-
- percent = -1;
- if (entry.getTimeLimit() > 0) {
- final long limit = entry.getTimeLimit();
- final long used = entry.getTimeUsed();
- percent = used * 100 / limit;
- prop.put("userlist_" + numUsers + "_traffic", percent);
- } else {
- prop.put("userlist_" + numUsers + "_traffic", "");
- }
-
-
- numUsers++;
- }
- prop.put("userlist", numUsers);
-
- // return rewrite properties
- return prop;
- }
-}
diff --git a/source/net/yacy/htroot/ConfigAccounts_p.java b/source/net/yacy/htroot/ConfigAccounts_p.java
index c2c75b394..4ca771794 100644
--- a/source/net/yacy/htroot/ConfigAccounts_p.java
+++ b/source/net/yacy/htroot/ConfigAccounts_p.java
@@ -31,16 +31,8 @@
package net.yacy.htroot;
-import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import net.yacy.cora.protocol.RequestHeader;
-import net.yacy.cora.util.ConcurrentLog;
-import net.yacy.data.TransactionManager;
-import net.yacy.data.UserDB;
-import net.yacy.data.UserDB.AccessRight;
+import net.yacy.cora.protocol.RequestHeader;
+import net.yacy.data.TransactionManager;
import net.yacy.http.YaCyHttpServer;
import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
@@ -60,245 +52,53 @@ public class ConfigAccounts_p {
} catch (IllegalArgumentException e) {
sb.log.fine("access by unauthorized or unknown user: no transaction token delivered");
}
- UserDB.Entry entry = null;
-
- // admin password
- boolean localhostAccess = sb.getConfigBool(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, false);
-
- if (post != null && post.containsKey("setAccess")) {
- TransactionManager.checkPostTransaction(header, post);
- sb.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_All_PAGES, post.getBoolean(SwitchboardConstants.ADMIN_ACCOUNT_All_PAGES));
- }
-
- if (post != null && post.containsKey("setAdmin")) {
- TransactionManager.checkPostTransaction(header, post);
- localhostAccess = post.get("access", "").equals("localhost");
- final String user = post.get("adminuser", "");
- final String pw1 = post.get("adminpw1", "");
- final String pw2 = post.get("adminpw2", "");
- int inputerror=0;
- // may be overwritten if new password is given
- if (user.length() > 0 && pw1.equals(pw2)) {
- final String oldusername = env.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME,user);
- // check passed. set account:
- // old: // env.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, Digest.encodeMD5Hex(Base64Order.standardCoder.encodeString(user + ":" + pw1)));
- env.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, sb.encodeDigestAuth(user, pw1));
- env.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME,user);
- // make sure server accepts new credentials
- final YaCyHttpServer jhttpserver = sb.getHttpServer();
- if (!user.equals(oldusername)) jhttpserver.removeUser(oldusername);
- jhttpserver.resetUser(user);
- } else {
- if (!localhostAccess) {
- if (user.isEmpty()) {
- inputerror = 3;
- } else {
- inputerror = 2; // password match error
- }
- prop.put("error", inputerror);
- }
- }
-
- if (inputerror == 0) {
- if (localhostAccess) {
- sb.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, true);
- } else {
- sb.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, false);
- if (env.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").startsWith("0000")) {
- // make shure that the user can still use the interface after a random password was set
- env.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "");
- }
- }
- }
- }
+ // Page protection policy
+ if (post != null && post.containsKey("setAccess")) {
+ TransactionManager.checkPostTransaction(header, post);
+ sb.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_All_PAGES, post.getBoolean(SwitchboardConstants.ADMIN_ACCOUNT_All_PAGES));
+ }
+
+ // Unauthenticated administrator access for eligible localhost requests
+ if (post != null && post.containsKey("setLocalhostAccess")) {
+ TransactionManager.checkPostTransaction(header, post);
+ sb.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, post.getBoolean(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST));
+ }
+
+ // Built-in administrator credentials
+ if (post != null && post.containsKey("setAdmin")) {
+ TransactionManager.checkPostTransaction(header, post);
+ final String user = post.get("adminuser", "");
+ final String pw1 = post.get("adminpw1", "");
+ final String pw2 = post.get("adminpw2", "");
+ int inputerror = 0;
+ if (user.isEmpty()) {
+ inputerror = 3;
+ } else if (pw1.isEmpty()) {
+ inputerror = 4;
+ } else if (!pw1.equals(pw2)) {
+ inputerror = 2;
+ } else {
+ final String oldusername = env.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, user);
+ env.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, sb.encodeDigestAuth(user, pw1));
+ env.setConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, user);
+ // make sure server accepts new credentials
+ final YaCyHttpServer jhttpserver = sb.getHttpServer();
+ if (!user.equals(oldusername)) jhttpserver.removeUser(oldusername);
+ jhttpserver.resetUser(user);
+ }
+ prop.put("error", inputerror);
+ }
// set a warning in case that the default password was not changed
- String currpw = sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "");
- String dfltpw = SwitchboardConstants.ADMIN_ACCOUNT_B64MD5_DEFAULT;
- prop.put("changedfltpw", currpw.equals(dfltpw) ? "1" : "0");
-
- prop.put(SwitchboardConstants.ADMIN_ACCOUNT_All_PAGES + ".checked", sb.getConfigBool(SwitchboardConstants.ADMIN_ACCOUNT_All_PAGES, false) ? 1 : 0);
- prop.put("localhost.checked", (localhostAccess) ? 1 : 0);
- prop.put("account.checked", (localhostAccess) ? 0 : 1);
- prop.put("statusPassword", localhostAccess ? "0" : "1");
- prop.put("defaultUser", env.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"));
-
- //default values
- prop.put("current_user", "newuser");
- prop.put("username", "");
- prop.put("firstname", "");
- prop.put("lastname", "");
- prop.put("address", "");
- prop.put("timelimit", "");
- prop.put("timeused", "");
-
- final AccessRight[] rights = AccessRight.values();
- int c = 0;
- for (final AccessRight right : rights) {
- prop.put("rights_" + c + "_name", right.toString());
- prop.put("rights_" + c +"_friendlyName", right.getFriendlyName());
- prop.put("rights_" + c + "_set", "0");
- c++;
- }
- prop.put("rights", c);
-
- prop.put("users", "0");
-
- if (sb.userDB == null) {
- return prop;
- }
-
- if (post == null) {
- //do nothing
-
- //user != current_user
- //user=from userlist
- //current_user = edited user
- } else if (post.containsKey("user") && !"newuser".equals(post.get("user"))) {
- TransactionManager.checkPostTransaction(header, post);
- if (post.containsKey("change_user")) {
- //defaults for newuser are set above
- entry = sb.userDB.getEntry(post.get("user"));
- // program crashes if a submit with empty username was made on previous mask and the user clicked on the
- // link: "If you want to manage more Users, return to the user page." (parameter "user" is empty)
- if (entry != null) {
- //TODO: set username read-only in html
- prop.putHTML("current_user", post.get("user"));
- prop.putHTML("username", post.get("user"));
- prop.putHTML("firstname", entry.getFirstName());
- prop.putHTML("lastname", entry.getLastName());
- prop.putHTML("address", entry.getAddress());
- prop.put("timelimit", entry.getTimeLimit());
- prop.put("timeused", entry.getTimeUsed());
- int count = 0;
- for (final AccessRight right : rights){
- prop.put("rights_" + count + "_set", entry.hasRight(right) ? "1" : "0");
- count++;
- }
- prop.put("rights", count);
- }
- } else if (post.containsKey("delete_user") && !"newuser".equals(post.get("user"))){
- sb.userDB.removeEntry(post.get("user"));
- }
- } else if (post.containsKey("change")) { //New User / edit User
- TransactionManager.checkPostTransaction(header, post);
- prop.put("text", "0");
- prop.put("error", "0");
-
- final String username = post.get("username");
- final String pw1 = post.get("password");
- final String pw2 = post.get("password2");
-
- if (pw1 == null || !pw1.equals(pw2)) {
- prop.put("error", "2"); //PW does not match
- return prop;
- }
- // do not allow same username as staticadmin
- if (username.equalsIgnoreCase(sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME,"admin"))) {
- prop.put("error", "4");
- return prop;
- }
- final String firstName = post.get("firstname");
- final String lastName = post.get("lastname");
- final String address = post.get("address");
- final String timeLimit = post.get("timelimit");
- final String timeUsed = post.get("timeused");
- final Map<AccessRight, String> rightsSet = new EnumMap<AccessRight, String>(AccessRight.class);
-
- for(final AccessRight right : rights) {
- rightsSet.put(right, post.containsKey(right.toString()) && "on".equals(post.get(right.toString())) ? "true" : "false");
- }
-
- final Map<String, String> mem = new HashMap<String, String>();
- if( "newuser".equals(post.get("current_user"))){ //new user
-
- if (!"".equals(pw1)) { //change only if set
- // MD5 according to HTTP Digest RFC 2617 (3.2.2) name:realm:pwd (use seed.hash as realm)
- // with prefix of encoding method (supported MD5: )
- mem.put(UserDB.Entry.MD5ENCODED_USERPWD_STRING, sb.encodeDigestAuth(username, pw1));
- }
-
- mem.put(UserDB.Entry.USER_FIRSTNAME, firstName);
- mem.put(UserDB.Entry.USER_LASTNAME, lastName);
- mem.put(UserDB.Entry.USER_ADDRESS, address);
- mem.put(UserDB.Entry.TIME_LIMIT, timeLimit);
- mem.put(UserDB.Entry.TIME_USED, timeUsed);
-
- for (final AccessRight right : rights) {
- mem.put(right.toString(), rightsSet.get(right));
- }
-
- try {
- entry = sb.userDB.createEntry(username, mem);
- sb.userDB.addEntry(entry);
- prop.putHTML("text_username", username);
- prop.put("text", "1");
- } catch (final IllegalArgumentException e) {
- prop.put("error", "3");
- }
-
- } else { //edit user
-
- entry = sb.userDB.getEntry(username);
-
- if (entry != null) {
- try{
- // with prefix of encoding method (supported MD5: )
- entry.setProperty(UserDB.Entry.MD5ENCODED_USERPWD_STRING, sb.encodeDigestAuth(username, pw1));
- entry.setProperty(UserDB.Entry.USER_FIRSTNAME, firstName);
- entry.setProperty(UserDB.Entry.USER_LASTNAME, lastName);
- entry.setProperty(UserDB.Entry.USER_ADDRESS, address);
- entry.setProperty(UserDB.Entry.TIME_LIMIT, timeLimit);
- entry.setProperty(UserDB.Entry.TIME_USED, timeUsed);
-
- for(final AccessRight right : rights) {
- entry.setProperty(right.toString(), rightsSet.get(right));
- }
-
- } catch (final Exception e) {
- ConcurrentLog.logException(e);
- }
-
- } else {
- prop.put("error", "1");
- }
- prop.putHTML("text_username", username);
- prop.put("text", "2");
- }//edit user
-
- prop.putHTML("username", username);
- if (entry != null) {
- //TODO: set username read-only in html
- prop.putHTML("current_user", entry.getUserName());
- prop.putHTML("username", entry.getUserName());
- prop.putHTML("firstname", entry.getFirstName());
- prop.putHTML("lastname", entry.getLastName());
- prop.putHTML("address", entry.getAddress());
- prop.put("timelimit", entry.getTimeLimit());
- prop.put("timeused", entry.getTimeUsed());
- int count = 0;
- for (final AccessRight right : rights) {
- prop.put("rights_" + count + "_set", entry.hasRight(right) ? "1" : "0");
- count++;
- }
- prop.put("rights", count);
- }
- }
-
- //Generate Userlist
- final Iterator<UserDB.Entry> it = sb.userDB.iterator(true);
- int numUsers=0;
- while (it.hasNext()) {
- entry = it.next();
- if (entry == null) {
- continue;
- }
- prop.putHTML("users_"+numUsers+"_user", entry.getUserName());
- numUsers++;
- }
- prop.put("users", numUsers);
-
- // return rewrite properties
+ final String currpw = sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "");
+ final String dfltpw = SwitchboardConstants.ADMIN_ACCOUNT_B64MD5_DEFAULT;
+ prop.put("changedfltpw", currpw.equals(dfltpw) ? "1" : "0");
+
+ prop.put(SwitchboardConstants.ADMIN_ACCOUNT_All_PAGES + ".checked", sb.getConfigBool(SwitchboardConstants.ADMIN_ACCOUNT_All_PAGES, false) ? 1 : 0);
+ prop.put(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST + ".checked", sb.getConfigBool(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, false) ? 1 : 0);
+ prop.putHTML("defaultUser", env.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"));
+
+ // return rewrite properties
return prop;
}
}
diff --git a/source/net/yacy/htroot/ConfigRobotsTxt_p.java b/source/net/yacy/htroot/ConfigRobotsTxt_p.java
index eb559f6fd..62c871bb5 100644
--- a/source/net/yacy/htroot/ConfigRobotsTxt_p.java
+++ b/source/net/yacy/htroot/ConfigRobotsTxt_p.java
@@ -52,7 +52,6 @@ public class ConfigRobotsTxt_p {
if (post != null) {
if (post.containsKey("save")) {
rbc.setAllDisallowed(post.containsKey(RobotsTxtConfig.ALL));
- rbc.setBlogDisallowed(post.containsKey(RobotsTxtConfig.BLOG));
rbc.setBookmarksDisallowed(post.containsKey(RobotsTxtConfig.BOOKMARKS));
rbc.setDirsDisallowed(post.containsKey(RobotsTxtConfig.DIRS));
rbc.setFileshareDisallowed(post.containsKey(RobotsTxtConfig.FILESHARE));
@@ -62,14 +61,12 @@ public class ConfigRobotsTxt_p {
rbc.setNewsDisallowed(post.containsKey(RobotsTxtConfig.NEWS));
rbc.setStatusDisallowed(post.containsKey(RobotsTxtConfig.STATUS));
rbc.setSurftipsDisallowed(post.containsKey(RobotsTxtConfig.SURFTIPS));
- rbc.setWikiDisallowed(post.containsKey(RobotsTxtConfig.WIKI));
rbc.setProfileDisallowed(post.containsKey(RobotsTxtConfig.PROFILE));
env.setConfig(SwitchboardConstants.ROBOTS_TXT, rbc.toString());
}
}
prop.put(RobotsTxtConfig.ALL + ".checked", (rbc.isAllDisallowed()) ? "1" : "0");
- prop.put(RobotsTxtConfig.BLOG + ".checked", (rbc.isBlogDisallowed()) ? "1" : "0");
prop.put(RobotsTxtConfig.BOOKMARKS + ".checked", (rbc.isBookmarksDisallowed()) ? "1" : "0");
prop.put(RobotsTxtConfig.DIRS + ".checked", (rbc.isDirsDisallowed()) ? "1" : "0");
prop.put(RobotsTxtConfig.FILESHARE + ".checked", (rbc.isFileshareDisallowed()) ? "1" : "0");
@@ -79,7 +76,6 @@ public class ConfigRobotsTxt_p {
prop.put(RobotsTxtConfig.NEWS + ".checked", (rbc.isNewsDisallowed()) ? "1" : "0");
prop.put(RobotsTxtConfig.STATUS + ".checked", (rbc.isStatusDisallowed()) ? "1" : "0");
prop.put(RobotsTxtConfig.SURFTIPS + ".checked", (rbc.isSurftipsDisallowed()) ? "1" : "0");
- prop.put(RobotsTxtConfig.WIKI + ".checked", (rbc.isWikiDisallowed()) ? "1" : "0");
prop.put(RobotsTxtConfig.PROFILE + ".checked", (rbc.isProfileDisallowed()) ? "1" : "0");
return prop;
}
diff --git a/source/net/yacy/htroot/ConfigUser_p.java b/source/net/yacy/htroot/ConfigUser_p.java
deleted file mode 100644
index 9a5360662..000000000
--- a/source/net/yacy/htroot/ConfigUser_p.java
+++ /dev/null
@@ -1,175 +0,0 @@
-// ConfigUser_p.java
-// -----------------------
-// (c) 2017 by reger24; https://github.com/reger24
-//
-// This is a part of YaCy, a peer-to-peer based web search engine
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-package net.yacy.htroot;
-
-import java.util.EnumMap;
-import java.util.Map;
-
-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.YaCyHttpServer;
-import net.yacy.search.Switchboard;
-import net.yacy.search.SwitchboardConstants;
-import net.yacy.server.serverObjects;
-import net.yacy.server.serverSwitch;
-
-public class ConfigUser_p {
-
- public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, final serverSwitch env) {
-
- final serverObjects prop = new serverObjects();
- final Switchboard sb = (Switchboard) env;
-
- if (post != null && post.containsKey("cancel")) {
- prop.put(serverObjects.ACTION_LOCATION, "ConfigAccountList_p.html");
- return prop;
- }
-
- //default values
- prop.put("current_user", "newuser");
- prop.put("username", "");
- prop.put("firstname", "");
- prop.put("lastname", "");
- prop.put("address", "");
- prop.put("timelimit", "");
- prop.put("timeused", "");
-
- final AccessRight[] rights = AccessRight.values();
- int c = 0;
- for (final AccessRight right : rights) {
- prop.put("rights_" + c + "_name", right.toString());
- prop.put("rights_" + c + "_friendlyName", right.getFriendlyName());
- prop.put("rights_" + c + "_set", "0");
- c++;
- }
- prop.put("rights", c);
-
- prop.put("users", "0");
-
- if (sb.userDB == null) {
- return prop;
- }
-
- if (post == null) {
- //do nothing
- } else if (post.containsKey("user") && !"newuser".equals(post.get("user"))) {
-
- final UserDB.Entry entry = sb.userDB.getEntry(post.get("user"));
- if (entry != null) {
- //TODO: set username read-only in html
- prop.putHTML("current_user", entry.getUserName());
- prop.putHTML("username", entry.getUserName());
- prop.putHTML("firstname", entry.getFirstName());
- prop.putHTML("lastname", entry.getLastName());
- prop.putHTML("address", entry.getAddress());
- prop.put("timelimit", entry.getTimeLimit());
- prop.put("timeused", entry.getTimeUsed());
- int count = 0;
- for (final AccessRight right : rights) {
- prop.put("rights_" + count + "_set", entry.hasRight(right) ? "1" : "0");
- count++;
- }
- prop.put("rights", count);
- }
- } else if (post.containsKey("change")) { // edit User
- prop.put("text", "0");
- prop.put("error", "0");
-
- final String username = post.get("username");
- final String pw1 = post.get("password");
- final String pw2 = post.get("password2");
-
- if (pw1 == null || !pw1.equals(pw2)) {
- prop.put("error", "2"); //PW does not match
- return prop;
- }
- // do not allow same username as staticadmin
- if (username.equalsIgnoreCase(sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin"))) {
- prop.put("error", "4");
- return prop;
- }
- final String firstName = post.get("firstname");
- final String lastName = post.get("lastname");
- final String address = post.get("address");
- final String timeLimit = post.get("timelimit");
- final String timeUsed = post.get("timeused");
- final Map<AccessRight, String> rightsSet = new EnumMap<AccessRight, String>(AccessRight.class);
-
- for (final AccessRight right : rights) {
- rightsSet.put(right, post.containsKey(right.toString()) && "on".equals(post.get(right.toString())) ? "true" : "false");
- }
-
- final UserDB.Entry entry = sb.userDB.getEntry(username);
-
- if (entry != null) {
- try {
- // with prefix of encoding method (supported MD5: )
- entry.setProperty(UserDB.Entry.MD5ENCODED_USERPWD_STRING, sb.encodeDigestAuth(username, pw1));
- entry.setProperty(UserDB.Entry.USER_FIRSTNAME, firstName);
- entry.setProperty(UserDB.Entry.USER_LASTNAME, lastName);
- entry.setProperty(UserDB.Entry.USER_ADDRESS, address);
- entry.setProperty(UserDB.Entry.TIME_LIMIT, timeLimit);
- entry.setProperty(UserDB.Entry.TIME_USED, timeUsed);
-
- for (final AccessRight right : rights) {
- entry.setProperty(right.toString(), rightsSet.get(right));
- }
-
- //TODO: set username read-only in html
- prop.putHTML("current_user", entry.getUserName());
- prop.putHTML("username", entry.getUserName());
- prop.putHTML("firstname", entry.getFirstName());
- prop.putHTML("lastname", entry.getLastName());
- prop.putHTML("address", entry.getAddress());
- prop.put("timelimit", entry.getTimeLimit());
- prop.put("timeused", entry.getTimeUsed());
- int count = 0;
- for (final AccessRight right : rights) {
- prop.put("rights_" + count + "_set", entry.hasRight(right) ? "1" : "0");
- count++;
- }
- prop.put("rights", count);
-
- } catch (final Exception e) {
- ConcurrentLog.logException(e);
- }
- final YaCyHttpServer jhttpserver = sb.getHttpServer();
- jhttpserver.resetUser(entry.getUserName());
- } else {
- prop.put("error", "1");
- }
- prop.putHTML("text_username", username);
- prop.put("text", "2");
-
- prop.putHTML("username", username);
- } else if (post.containsKey("delete")) {
- sb.userDB.removeEntry(post.get("username"));
- final YaCyHttpServer jhttpserver = sb.getHttpServer();
- jhttpserver.removeUser(post.get("username"));
- prop.put(serverObjects.ACTION_LOCATION, "ConfigAccountList_p.html"); // jump back to user list
- }
-
- // return rewrite properties
- return prop;
- }
-}
diff --git a/source/net/yacy/htroot/Network.java b/source/net/yacy/htroot/Network.java
index a2cb5af59..f98f9cf14 100644
--- a/source/net/yacy/htroot/Network.java
+++ b/source/net/yacy/htroot/Network.java
@@ -303,8 +303,6 @@ public class Network {
// find updated Information using YaCyNews
final HashSet<String> updatedProfile = new HashSet<>();
- final HashMap<String, Map<String, String>> updatedWiki = new HashMap<>();
- final HashMap<String, Map<String, String>> updatedBlog = new HashMap<>();
final HashMap<String, String> isCrawling = new HashMap<>();
NewsDB.Record record;
final Iterator<NewsDB.Record> recordIterator = sb.peers.newsPool.recordIterator(NewsPool.INCOMING_DB);
@@ -314,11 +312,7 @@ public class Network {
continue;
} else if (record.category().equals(NewsPool.CATEGORY_PROFILE_UPDATE)) {
updatedProfile.add(record.originator());
- } else if (record.category().equals(NewsPool.CATEGORY_WIKI_UPDATE)) {
- updatedWiki.put(record.originator(), record.attributes());
- } else if (record.category().equals(NewsPool.CATEGORY_BLOG_ADD)) {
- updatedBlog.put(record.originator(), record.attributes());
- } else if (record.category().equals(NewsPool.CATEGORY_CRAWL_START)) {
+ } else if (record.category().equals(NewsPool.CATEGORY_CRAWL_START)) {
isCrawling.put(record.originator(), record.attributes().get("startURL"));
}
}
@@ -340,8 +334,6 @@ public class Network {
default: break;
}
String startURL;
- Map<String, String> wikiMap;
- Map<String, String> blogMap;
String userAgent, location;
int PPM;
double QPM;
@@ -382,8 +374,6 @@ public class Network {
continue;
}
prop.put(STR_TABLE_LIST + conCount + "_updatedProfile", 0);
- prop.put(STR_TABLE_LIST + conCount + "_updatedWikiPage", 0);
- prop.put(STR_TABLE_LIST + conCount + "_updatedBlog", 0);
prop.put(STR_TABLE_LIST + conCount + "_isCrawling", 0);
final String ip = ips.iterator().next();
if (conCount >= maxCount) { break; }
@@ -396,21 +386,6 @@ public class Network {
prop.put(STR_TABLE_LIST + conCount + "_updatedProfile", 1);
prop.put(STR_TABLE_LIST + conCount + "_updatedProfile_hash", seed.hash);
}
- if ((wikiMap = updatedWiki.get(seed.hash)) == null) {
- prop.put(STR_TABLE_LIST + conCount + "_updatedWiki", 0);
- } else {
- prop.put(STR_TABLE_LIST + conCount + "_updatedWiki", 1);
- prop.putHTML(STR_TABLE_LIST + conCount + "_updatedWiki_page", wikiMap.get("page"));
- prop.put(STR_TABLE_LIST + conCount + "_updatedWiki_address", seed.getPublicAddress(ip));
- }
- if ((blogMap = updatedBlog.get(seed.hash)) == null) {
- prop.put(STR_TABLE_LIST + conCount + "_updatedBlog", 0);
- } else {
- prop.put(STR_TABLE_LIST + conCount + "_updatedBlog", 1);
- prop.putHTML(STR_TABLE_LIST + conCount + "_updatedBlog_page", blogMap.get("page"));
- prop.putHTML(STR_TABLE_LIST + conCount + "_updatedBlog_subject", blogMap.get("subject"));
- prop.put(STR_TABLE_LIST + conCount + "_updatedBlog_address", seed.getPublicAddress(ip));
- }
PPM = seed.getPPM();
QPM = seed.getQPM();
if (((startURL = isCrawling.get(seed.hash)) != null) && (PPM >= 4)) {
@@ -559,4 +534,4 @@ public class Network {
return prop;
}
-} \ No newline at end of file
+}
diff --git a/source/net/yacy/htroot/News.java b/source/net/yacy/htroot/News.java
index 296e75cb0..90cc624b7 100644
--- a/source/net/yacy/htroot/News.java
+++ b/source/net/yacy/htroot/News.java
@@ -160,33 +160,7 @@ public class News {
link = record.attribute("url", "");
title = record.attribute("title", "");
description = record.attribute("url", "");
- } else if (category.equals(NewsPool.CATEGORY_WIKI_UPDATE)) {
- if(seed == null) {
- link = "";
- } else {
- final Set<String> ips = seed.getIPs();
- if(!ips.isEmpty()) {
- link = "http://" + seed.getPublicAddress(ips.iterator().next()) + "/Wiki.html?page=" + record.attribute("page", "");
- } else {
- link = "";
- }
- }
- title = record.attribute("author", "Anonymous") + ": " + record.attribute("page", "");
- description = "Wiki Update: " + record.attribute("description", "");
- } else if (category.equals(NewsPool.CATEGORY_BLOG_ADD)) {
- if(seed == null) {
- link = "";
- } else {
- final Set<String> ips = seed.getIPs();
- if(!ips.isEmpty()) {
- link = "http://" + seed.getPublicAddress(ips.iterator().next()) + "/Blog.html?page=" + record.attribute("page", "");
- } else {
- link = "";
- }
- }
- title = record.attribute("author", "Anonymous") + ": " + record.attribute("page", "");
- description = "Blog Entry: " + record.attribute("subject", "");
- } else {
+ } else {
link = "";
title = "";
description = "";
diff --git a/source/net/yacy/htroot/SettingsAck_p.java b/source/net/yacy/htroot/SettingsAck_p.java
index 735372552..e53d833d5 100644
--- a/source/net/yacy/htroot/SettingsAck_p.java
+++ b/source/net/yacy/htroot/SettingsAck_p.java
@@ -100,8 +100,8 @@ public class SettingsAck_p {
}
- // proxy password
- if (post.containsKey("proxyaccount")) {
+ // proxy client access filter
+ if (post.containsKey("proxyaccess")) {
// set backlink
prop.put("needsRestart_referer", "Settings_p.html?page=ProxyAccess");
@@ -112,14 +112,8 @@ public class SettingsAck_p {
prop.put("info_restart", "0");
// read and process data
- String filter = (post.get("proxyfilter")).trim();
- final boolean useProxyAccounts = post.containsKey("use_proxyaccounts") && post.get("use_proxyaccounts").equals("on");
+ String filter = post.get("proxyfilter", "").trim();
// do checks
- if (filter == null) {
- prop.put("info", "1");//error with submitted information
- return prop;
- }
-
if (filter.isEmpty()) filter = "*";
else if (!filter.equals("*")){
// testing proxy filter
@@ -142,17 +136,10 @@ public class SettingsAck_p {
}
}
- // check passed. set account:
+ // check passed: store the allowed proxy clients
env.setConfig("proxyClient", filter);
- env.setConfig("use_proxyAccounts", useProxyAccounts);
- if (!useProxyAccounts){
- prop.put("info", "6");//proxy account has changed(no pw)
- prop.putHTML("info_filter", filter);
- } else {
- prop.put("info", "7");//proxy account has changed
- //prop.put("info_user", user);
- prop.putHTML("info_filter", filter);
- }
+ prop.put("info", "6");
+ prop.putHTML("info_filter", filter);
return prop;
}
diff --git a/source/net/yacy/htroot/Settings_p.java b/source/net/yacy/htroot/Settings_p.java
index fc08514e6..f5afd08e2 100644
--- a/source/net/yacy/htroot/Settings_p.java
+++ b/source/net/yacy/htroot/Settings_p.java
@@ -122,21 +122,6 @@ public final class Settings_p {
// proxy access filter
prop.putHTML("proxyfilter", env.getConfig("proxyClient", "*"));
- // proxy password
- if (!env.getConfigBool("use_proxyAccounts", false)) {
- // no password has been specified
- prop.put("use_proxyAccounts", "0"); //unchecked
- } else {
- prop.put("use_proxyAccounts", "1"); //checked
- /*s = env.getConfig("proxyAccount", "proxy:void");
- pos = s.indexOf(':');
- if (pos < 0) {
- prop.put("proxyuser","proxy");
- } else {
- prop.put("proxyuser",s.substring(0, pos));
- }*/
- }
-
// Url proxy settings
prop.putHTML("urlproxyfilter", env.getConfig("proxyURL.access", "127.0.0.1,0:0:0:0:0:0:0:1"));
prop.putHTML("urlproxydomains", env.getConfig("proxyURL.rewriteURLs", "domainlist"));
diff --git a/source/net/yacy/htroot/Surftips.java b/source/net/yacy/htroot/Surftips.java
index 0f21dcd93..de31b8a3f 100644
--- a/source/net/yacy/htroot/Surftips.java
+++ b/source/net/yacy/htroot/Surftips.java
@@ -277,42 +277,6 @@ public class Surftips {
score = 5 + timeFactor(record.created());
}
- if (record.category().equals(NewsPool.CATEGORY_WIKI_UPDATE)) {
- Seed seed = sb.peers.getConnected(record.originator());
- if (seed == null) seed = sb.peers.getDisconnected(record.originator());
- if (seed != null) {
- final Set<String> ips = seed.getIPs();
- if(!ips.isEmpty()) {
- url = seed.getPublicURL(ips.iterator().next(), false) + "/Wiki.html?page=" + record.attribute("page", "");
- entry = rowdef.newEntry(new byte[][]{
- UTF8.getBytes(url),
- UTF8.getBytes(record.attribute("author", "Anonymous") + ": " + record.attribute("page", "")),
- UTF8.getBytes("Wiki Update: " + record.attribute("description", "")),
- UTF8.getBytes(record.id())
- });
- score = 4 + timeFactor(record.created());
- }
- }
- }
-
- if (record.category().equals(NewsPool.CATEGORY_BLOG_ADD)) {
- Seed seed = sb.peers.getConnected(record.originator());
- if (seed == null) seed = sb.peers.getDisconnected(record.originator());
- if (seed != null) {
- final Set<String> ips = seed.getIPs();
- if(!ips.isEmpty()) {
- url = seed.getPublicURL(ips.iterator().next(), false) + "/Blog.html?page=" + record.attribute("page", "");
- entry = rowdef.newEntry(new byte[][]{
- UTF8.getBytes(url),
- UTF8.getBytes(record.attribute("author", "Anonymous") + ": " + record.attribute("page", "")),
- UTF8.getBytes("Blog Entry: " + record.attribute("subject", "")),
- UTF8.getBytes(record.id())
- });
- score = 4 + timeFactor(record.created());
- }
- }
- }
-
// add/subtract votes and write record
if (entry != null) {
try {
diff --git a/source/net/yacy/htroot/TransNews_p.java b/source/net/yacy/htroot/TransNews_p.java
deleted file mode 100644
index 5883bec07..000000000
--- a/source/net/yacy/htroot/TransNews_p.java
+++ /dev/null
@@ -1,326 +0,0 @@
-// TransNews_p.java
-//
-// This is a part of YaCy, a peer-to-peer based web search engine
-// published on http://yacy.net
-//
-// This file is contributed by Burkhard Buelte
-//
-// $LastChangedDate$
-// $LastChangedRevision$
-// $LastChangedBy$
-//
-// LICENSE
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-package net.yacy.htroot;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import net.yacy.cora.protocol.RequestHeader;
-import net.yacy.cora.sorting.ConcurrentScoreMap;
-import net.yacy.cora.sorting.ScoreMap;
-import net.yacy.cora.util.SpaceExceededException;
-import net.yacy.peers.NewsDB;
-import net.yacy.peers.NewsPool;
-import net.yacy.search.Switchboard;
-import net.yacy.server.serverObjects;
-import net.yacy.server.serverSwitch;
-import net.yacy.utils.crypt;
-import net.yacy.utils.translation.TranslationManager;
-
-public class TransNews_p {
-
- public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, final serverSwitch env) {
- final Switchboard sb = (Switchboard) env;
- final serverObjects prop = new serverObjects();
-
- final String currentlang = sb.getConfig("locale.language", "default");
- prop.put("currentlang", currentlang);
-
- if ("default".equals(currentlang) || "browser".equals(currentlang)) {
- prop.put("errmsg", 1); // msg: activate diff lng
- prop.put("transsize", 0);
- return prop;
- }
- prop.put("errmsg", 0);
-
- TranslationManager transMgr = new TranslationManager();
- final File locallangFile = transMgr.getScratchFile(new File(currentlang + ".lng"));
- final Map<String, Map<String, String>> localTrans = transMgr.loadTranslationsLists(locallangFile);
- // calculate size of local translations list
- int size = 0;
- for (final Map<String, String> lst : localTrans.values()) {
- size += lst.size();
- }
- prop.put("transsize", size);
-
-
- // read voting
- if ((post != null) && post.containsKey("publishtranslation")) {
- final Iterator<String> filenameit = localTrans.keySet().iterator();
- int msgcounter = 0;
- while (filenameit.hasNext()) {
- final String file = filenameit.next();
- final Map<String, String> tmptrans = localTrans.get(file);
- for (final String sourcetxt : tmptrans.keySet()) {
- final String targettxt = tmptrans.get(sourcetxt);
- if (targettxt != null && !targettxt.isEmpty()) {
- boolean sendit = true;
- // check if already published (in newsPool)
- final Iterator<NewsDB.Record> it = sb.peers.newsPool.recordIterator(NewsPool.INCOMING_DB);
- while (it.hasNext()) {
- final NewsDB.Record rtmp = it.next();
- if (rtmp == null) {
- continue;
- }
- if (NewsPool.CATEGORY_TRANSLATION_ADD.equals(rtmp.category())) {
- final String tmplng = rtmp.attribute("language", null);
- final String tmpfile = rtmp.attribute("file", null);
- final String tmpsource = rtmp.attribute("source", null);
- //String tmptarget = rtmp.attribute("target", null);
-
- // if news with file and source exist (maybe from other peer) - skip sending another msg (to avoid confusion)
- if ((tmplng != null && tmplng.equals(currentlang)) && (tmpfile != null && tmpfile.equals(file))
- && (tmpsource != null && tmpsource.equals(sourcetxt))) {
- sendit = false;
- break;
- }
-
- }
- }
- if (sendit) {
- final HashMap<String, String> map = new HashMap<>();
- map.put("language", currentlang);
- map.put("file", file);
- map.put("source", sourcetxt);
- map.put("target", targettxt);
- map.put("#", Integer.toString(msgcounter++));
- sb.peers.newsPool.publishMyNews(sb.peers.mySeed(), NewsPool.CATEGORY_TRANSLATION_ADD, map);
- }
- }
- }
- }
- }
- String refid;
- if ((post != null) && ((refid = post.get("voteNegative", "")).length() > 0)) {
-
- // make new news message with voting
- if (!sb.isRobinsonMode()) {
- final HashMap<String, String> map = new HashMap<>();
- map.put("language", currentlang);
- map.put("file", crypt.simpleDecode(post.get("filename", "")));
- map.put("source", crypt.simpleDecode(post.get("source", "")));
- map.put("target", crypt.simpleDecode(post.get("target", "")));
- map.put("vote", "negative");
- map.put("refid", refid);
- sb.peers.newsPool.publishMyNews(sb.peers.mySeed(), NewsPool.CATEGORY_TRANSLATION_VOTE_ADD, map);
- try {
- sb.peers.newsPool.moveOff(NewsPool.INCOMING_DB, refid);
- } catch (IOException | SpaceExceededException ex) {
- }
- }
- }
-
- if ((post != null) && ((refid = post.get("votePositive", "")).length() > 0)) {
-
- final String filename = post.get("filename");
-
- final File lngfile = new File(sb.getAppPath("locale.source", "locales"), currentlang + ".lng");
- transMgr = new TranslationManager(lngfile); // load full language for check if entry is new (globally)
- if (transMgr.addTranslation(filename, post.get("source"), post.get("target"))) {
- // add to local translation extension
- transMgr.addTranslation(localTrans, filename, post.get("source"), post.get("target"));
- transMgr.saveAsLngFile(currentlang, locallangFile, localTrans); // save local-trans to local-file
- transMgr.translateFile(filename); // ad-hoc translate file with new/added text
- } // TODO: shall we post voting if translation is not new ?
-
- // make new news message with voting
- final HashMap<String, String> map = new HashMap<>();
- map.put("language", currentlang);
- map.put("file", crypt.simpleDecode(filename));
- map.put("source", crypt.simpleDecode(post.get("source", "")));
- map.put("target", crypt.simpleDecode(post.get("target", "")));
- map.put("vote", "positive");
- map.put("refid", refid);
- sb.peers.newsPool.publishMyNews(sb.peers.mySeed(), NewsPool.CATEGORY_TRANSLATION_VOTE_ADD, map);
- try {
- sb.peers.newsPool.moveOff(NewsPool.INCOMING_DB, refid);
- } catch (IOException | SpaceExceededException ex) {
- }
-
- }
-
- // create Translation voting list
- final HashMap<String, Integer> negativeHashes = new HashMap<>(); // a mapping from an url hash to Integer (count of votes)
- final HashMap<String, Integer> positiveHashes = new HashMap<>(); // a mapping from an url hash to Integer (count of votes)
- accumulateVotes(sb, negativeHashes, positiveHashes, NewsPool.INCOMING_DB);
- final ScoreMap<String> ranking = new ConcurrentScoreMap<>(); // score cluster for url hashes
- final HashMap<String, NewsDB.Record> translation = new HashMap<>(); // a mapping from an url hash to a kelondroRow.Entry with display properties
- accumulateTranslations(sb, translation, ranking, negativeHashes, positiveHashes, NewsPool.INCOMING_DB);
-
- // read out translation-news array and create property entries
- final Iterator<String> k = ranking.keys(false);
- int i = 0;
- NewsDB.Record row;
- String filename;
- String source;
- String target;
-
- while (k.hasNext()) {
-
- refid = k.next();
- if (refid == null) {
- continue;
- }
-
- row = translation.get(refid);
- if (row == null) {
- continue;
- }
-
- final String lang = row.attribute("language", null);
- filename = row.attribute("file", null);
- source = row.attribute("source", null);
- target = row.attribute("target", null);
- if ((lang == null) || (filename == null) || (source == null) || (target == null)) {
- continue;
- }
-
- if (!lang.equals(currentlang)) continue;
-
- String existingtarget = null; //transMgr.getTranslation(filename, source);
- final Map<String, String> tmpMap = localTrans.get(filename);
- if (tmpMap != null) {
- existingtarget = tmpMap.get(source);
- }
-
- final boolean altexist = existingtarget != null && !target.isEmpty() && !existingtarget.isEmpty() && !existingtarget.equals(target);
-
- prop.put("results_" + i + "_refid", refid);
- prop.put("results_" + i + "_url", filename); // url to local file
- prop.put("results_" + i + "_targetlanguage", lang);
- prop.put("results_" + i + "_filename", filename);
- prop.putHTML("results_" + i + "_source", source);
- prop.putHTML("results_" + i + "_target", target);
- prop.put("results_" + i + "_existing", altexist);
- prop.putHTML("results_" + i + "_existing_target", existingtarget);
- prop.put("results_" + i + "_score", ranking.get(refid));
- prop.put("results_" + i + "_peername", sb.peers.get(row.originator()).getName());
- i++;
-
- if (i >= 50) {
- break;
- }
- }
- prop.put("results", i);
-
- return prop;
- }
-
- private static void accumulateVotes(final Switchboard sb, final HashMap<String, Integer> negativeHashes, final HashMap<String, Integer> positiveHashes, final int dbtype) {
- final int maxCount = Math.min(1000, sb.peers.newsPool.size(dbtype));
- NewsDB.Record newsrecord;
- final Iterator<NewsDB.Record> recordIterator = sb.peers.newsPool.recordIterator(dbtype);
- int j = 0;
- while ((recordIterator.hasNext()) && (j++ < maxCount)) {
- newsrecord = recordIterator.next();
- if (newsrecord == null) {
- continue;
- }
-
- if (newsrecord.category().equals(NewsPool.CATEGORY_TRANSLATION_VOTE_ADD)) {
- final String refid = newsrecord.attribute("refid", "");
- final String vote = newsrecord.attribute("vote", "");
- final int factor = ((dbtype == NewsPool.OUTGOING_DB) || (dbtype == NewsPool.PUBLISHED_DB)) ? 2 : 1;
- if (vote.equals("negative")) {
- final Integer i = negativeHashes.get(refid);
- if (i == null) {
- negativeHashes.put(refid, Integer.valueOf(factor));
- } else {
- negativeHashes.put(refid, Integer.valueOf(i.intValue() + factor));
- }
- }
- if (vote.equals("positive")) {
- final Integer i = positiveHashes.get(refid);
- if (i == null) {
- positiveHashes.put(refid, Integer.valueOf(factor));
- } else {
- positiveHashes.put(refid, Integer.valueOf(i.intValue() + factor));
- }
- }
- }
- }
- }
-
- private static void accumulateTranslations(
- final Switchboard sb,
- final HashMap<String, NewsDB.Record> translationmsg, final ScoreMap<String> ranking,
- final HashMap<String, Integer> negativeHashes, final HashMap<String, Integer> positiveHashes, final int dbtype) {
- final int maxCount = Math.min(1000, sb.peers.newsPool.size(dbtype));
- NewsDB.Record newsrecord;
- final Iterator<NewsDB.Record> recordIterator = sb.peers.newsPool.recordIterator(dbtype);
- int j = 0;
- String refid = "";
- String targetlanguage ="";
- String filename="";
- String source="";
- String target="";
-
- int score = 0;
- Integer vote;
-
- while ((recordIterator.hasNext()) && (j++ < maxCount)) {
- newsrecord = recordIterator.next();
- if (newsrecord == null) {
- continue;
- }
-
- if ((newsrecord.category().equals(NewsPool.CATEGORY_TRANSLATION_ADD))
- && ((sb.peers.get(newsrecord.originator())) != null)) {
- refid = newsrecord.id();
- targetlanguage = newsrecord.attribute("language", "");
- filename = newsrecord.attribute("file", "");
- source = newsrecord.attribute("source", "");
- target = newsrecord.attribute("target", "");
- if (refid.isEmpty() || targetlanguage.isEmpty() || filename.isEmpty() || source.isEmpty() || target.isEmpty()) {
- continue;
- }
- score = 0;
- }
-
- // add/subtract votes and write record
-
- if ((vote = negativeHashes.get(refid)) != null) {
- score -= vote.intValue();
- }
- if ((vote = positiveHashes.get(refid)) != null) {
- score += vote.intValue();
- }
- // consider double-entries
- if (translationmsg.containsKey(refid)) {
- ranking.inc(refid, score);
- } else {
- ranking.set(refid, score);
- translationmsg.put(refid, newsrecord);
- }
-
- }
- }
-}
diff --git a/source/net/yacy/htroot/Translator_p.java b/source/net/yacy/htroot/Translator_p.java
deleted file mode 100644
index 872dddd15..000000000
--- a/source/net/yacy/htroot/Translator_p.java
+++ /dev/null
@@ -1,174 +0,0 @@
-
-/**
- * Translator_p
- * Copyright 2012 by Michael Peter Christen, mc@yacy.net, Frankfurt am Main, Germany
- * First released 14.09.2011 at https://yacy.net
- *
- * This library is free software; you can redistribute it and/or
- * 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/>.
- */
-package net.yacy.htroot;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
-
-import net.yacy.cora.protocol.RequestHeader;
-import net.yacy.cora.util.ConcurrentLog;
-import net.yacy.data.TransactionManager;
-import net.yacy.search.Switchboard;
-import net.yacy.search.SwitchboardConstants;
-import net.yacy.server.serverObjects;
-import net.yacy.server.serverSwitch;
-import net.yacy.server.servletProperties;
-import net.yacy.utils.translation.TranslationManager;
-
-public class Translator_p {
-
- public static servletProperties respond(final RequestHeader requestHeader, final serverObjects post, final serverSwitch env) {
- try {
- final servletProperties prop = new servletProperties();
- final Switchboard sb = (Switchboard) env;
-
- final String langcfg = sb.getConfig("locale.language", "default");
- prop.put("targetlang", langcfg);
- if ("default".equals(langcfg) || "browser".equals(langcfg)) {
- prop.put("errmsg", 1); // msg: activate diff lng
- return prop;
- }
- prop.put("errmsg", 0);
-
- final File localesFolder = sb.getAppPath("locale.source", "locales");
- final File lngfile = new File(localesFolder, langcfg + ".lng");
- final TranslationManager localTransMgr = new TranslationManager(/*new File ("locales","master.lng.xlf")*/);
-
- final File masterxlf = new File(localesFolder, "master.lng.xlf");
- if (!masterxlf.exists()) localTransMgr.createMasterTranslationLists(localesFolder, masterxlf);
- final Map<String, Map<String, String>> origTrans = localTransMgr.joinMasterTranslationLists(masterxlf, lngfile);
- final File locallngfile = localTransMgr.getScratchFile(lngfile);
- final Map<String, Map<String, String>> localTrans = localTransMgr.loadTranslationsLists(locallngfile); // TODO: this will read file twice
- int i = 0;
- if (origTrans.size() > 0) {
- String filename = origTrans.keySet().iterator().next();
- if (post != null && post.containsKey("sourcefile")) {
- filename = post.get("sourcefile", filename);
- }
-
- // prepare filename list for drop-down list
- final Iterator<String> filenameit = origTrans.keySet().iterator();
- final boolean filteruntranslated = post == null ? false : post.getBoolean("filteruntranslated");
- while (filenameit.hasNext()) {
- final String tmp = filenameit.next();
- if (filteruntranslated) { // filter filenames with untranslated entries
- final Map<String, String> tmptrans = origTrans.get(tmp);
- boolean hasuntrans = false;
- for (final String x : tmptrans.values()) {
- if (x == null || x.isEmpty()) {
- hasuntrans = true;
- break;
- }
- }
- if (!hasuntrans) continue;
- }
- prop.put("filelist_" + i + "_filename", tmp);
- prop.put("filelist_" + i + "_selected", tmp.equals(filename));
- i++;
- }
- prop.put("filelist", i);
-
- prop.add("sourcefile", filename);
- final Map<String, String> origTextList = origTrans.get(filename);
-
- i = 0;
- boolean editapproved = false; // to switch already approved translation in edit mode
- int textlistid = -1;
- if (post != null) {
- prop.put("filter.checked", filteruntranslated); // remember filter setting
- textlistid = post.getInt("approve", -1);
- if (post.containsKey("editapproved")) {
- textlistid = post.getInt("editapproved", -1);
- editapproved = true;
- }
- }
- boolean changed = false;
- for (final String sourcetext : origTextList.keySet()) {
- String targettxt = origTextList.get(sourcetext);
- boolean existinlocalTrans = localTrans.containsKey(filename) && localTrans.get(filename).containsKey(sourcetext);
-
- if (editapproved) existinlocalTrans |= (i == textlistid); // if edit of approved requested handle as/like existing in local to allow edit
-
- if (targettxt == null || targettxt.isEmpty() || existinlocalTrans) {
- prop.put("textlist_" + i + "_filteruntranslated", true);
- } else if (filteruntranslated) {
- continue;
- }
- // handle (modified) input text
- if (i == textlistid && post != null) {
- /* Check this is a valid transaction */
- TransactionManager.checkPostTransaction(requestHeader, post);
-
- if (editapproved) { // switch already translated in edit mode by copying to local translation
- // not saved here as not yet modified/approved
- localTransMgr.addTranslation(localTrans, filename, sourcetext, targettxt);
- } else {
- String t = post.get("targettxt" + Integer.toString(textlistid));
- // correct common partial html markup (part of text identification for words also used as html parameter)
- if (!t.isEmpty()) {
- if (sourcetext.startsWith(">") && !t.startsWith(">")) t=">"+t;
- if (sourcetext.endsWith("<") && !t.endsWith("<")) t=t+"<";
- }
- targettxt = t;
- // add changes to original (for display) and local (for save)
- origTextList.put(sourcetext, targettxt);
- changed = localTransMgr.addTranslation(localTrans, filename, sourcetext, targettxt);
- }
- }
- prop.putHTML("textlist_" + i + "_sourcetxt", sourcetext);
- prop.putHTML("textlist_" + i + "_targettxt", targettxt);
- prop.put("textlist_" + i + "_tokenid", Integer.toString(i));
- prop.put("textlist_" + i + "_filteruntranslated_tokenid", Integer.toString(i));
- i++;
- }
- if (post != null && post.containsKey("savetranslationlist")) {
- changed = true;
- }
- if (changed) {
- /* Check this is a valid transaction */
- TransactionManager.checkPostTransaction(requestHeader, post);
-
- localTransMgr.saveAsLngFile(langcfg, locallngfile, localTrans);
- // adhoc translate this file
- // 1. get/calc the path
- final String htRootPath = env.getConfig(SwitchboardConstants.HTROOT_PATH, SwitchboardConstants.HTROOT_PATH_DEFAULT);
- final File sourceDir = new File(env.getAppPath(), htRootPath);
- final File destDir = new File(env.getDataPath("locale.translated_html", "DATA/LOCALE/htroot"), locallngfile.getName().substring(0, locallngfile.getName().length() - 4));// cut .lng
- // get absolute file by adding relative filename from translationlist
- final File sourceFile = new File(sourceDir, filename);
- final File destFile = new File(destDir, filename);
- localTransMgr.translateFile(sourceFile, destFile, origTextList); // do the translation
- }
- }
-
- /* Acquire a transaction token for the next POST form submission */
- prop.put(TransactionManager.TRANSACTION_TOKEN_PARAM, TransactionManager.getTransactionToken(requestHeader));
-
- prop.put("textlist", i);
- return prop;
- } catch (final IOException ex) {
- ConcurrentLog.logException(ex);
- }
- return null;
- }
-}
diff --git a/source/net/yacy/htroot/User.java b/source/net/yacy/htroot/User.java
deleted file mode 100644
index 5c8e3f130..000000000
--- a/source/net/yacy/htroot/User.java
+++ /dev/null
@@ -1,177 +0,0 @@
-//User.java
-//-----------------------
-//part of the AnomicHTTPD caching proxy
-//(C) by Michael Peter Christen; mc@yacy.net
-//first published on http://www.anomic.de
-//Frankfurt, Germany, 2004
-//
-//This File is contributed by Alexander Schier
-//last major change: 12.11.2005
-//
-//This program is free software; you can redistribute it and/or modify
-//it under the terms of the GNU General Public License as published by
-//the Free Software Foundation; either version 2 of the License, or
-//(at your option) any later version.
-//
-//This program 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 General Public License for more details.
-//
-//You should have received a copy of the GNU General Public License
-//along with this program; if not, write to the Free Software
-//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-
-//You must compile this file with
-//javac -classpath .:../Classes Message.java
-//if the shell's current path is HTROOT
-
-package net.yacy.htroot;
-
-import javax.servlet.ServletException;
-
-import net.yacy.cora.order.Base64Order;
-import net.yacy.cora.order.Digest;
-import net.yacy.cora.protocol.RequestHeader;
-import net.yacy.cora.protocol.ResponseHeader;
-import net.yacy.cora.util.ConcurrentLog;
-import net.yacy.data.UserDB;
-import net.yacy.search.Switchboard;
-import net.yacy.search.SwitchboardConstants;
-import net.yacy.server.serverObjects;
-import net.yacy.server.serverSwitch;
-import net.yacy.server.servletProperties;
-
-public class User{
-
- public static servletProperties respond(final RequestHeader requestHeader, final serverObjects post, @SuppressWarnings("unused") final serverSwitch env) {
- final servletProperties prop = new servletProperties();
- final Switchboard sb = Switchboard.getSwitchboard();
- UserDB.Entry entry=null;
-
- //default values
- prop.put("logged_in", "0");
- prop.put("logged-in_limit", "0");
- prop.put("status", "0");
- prop.put("logged-in_username", "");
- prop.put("logged-in_returnto", "");
- //identified via HTTPPassword
- entry=sb.userDB.proxyAuth(requestHeader);
- if(entry != null){
- prop.put("logged-in_identified-by", "1");
- //try via cookie
- }else{
- entry=sb.userDB.cookieAuth(requestHeader.getCookies());
- prop.put("logged-in_identified-by", "2");
- //try via ip
- if(entry == null){
- final String ip = requestHeader.getRemoteAddr();
- entry = sb.userDB.ipAuth((ip != null ? ip : "xxxxxx"));
- if(entry != null){
- prop.put("logged-in_identified-by", "0");
- }
- }
- }
-
- //identified via userDB
- if(entry != null){
- prop.put("logged-in", "1");
- prop.put("logged-in_username", entry.getUserName());
- if(entry.getTimeLimit() > 0){
- prop.put("logged-in_limit", "1");
- final long limit=entry.getTimeLimit();
- final long used=entry.getTimeUsed();
- prop.put("logged-in_limit_timelimit", limit);
- prop.put("logged-in_limit_timeused", used);
- int percent=0;
- if(limit!=0 && used != 0)
- percent=(int)((float)used/(float)limit*100);
- prop.put("logged-in_limit_percent", percent/3);
- prop.put("logged-in_limit_percent2", (100-percent)/3);
- }
- //logged in via static Password
- }else if(sb.verifyAuthentication(requestHeader)){
- prop.put("logged-in", "2");
- //identified via form-login
- } else if (post != null && post.containsKey("username") && post.containsKey("password")) {
- if (post.containsKey("returnto"))
- prop.putHTML("logged-in_returnto", post.get("returnto"));
- final String username=post.get("username");
- final String password=post.get("password");
- prop.putHTML("logged-in_username", username);
-
- entry = sb.userDB.passwordAuth(username, password);
- boolean staticAdmin = false;
- if (entry == null) {
- // check for old style admin account
- staticAdmin = sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").equals(
- Digest.encodeMD5Hex(Base64Order.standardCoder.encodeString(username + ":" + password)));
- if (!staticAdmin) {
- // check for DIGEST authentication admin account
- final String realm = sb.getConfig(SwitchboardConstants.ADMIN_REALM, "YaCy");
- staticAdmin = sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_B64MD5, "").equals(
- "MD5:" + Digest.encodeMD5Hex(username + ":" + realm + ":" + password));
- }
- }
-
- String cookie="";
- if(entry != null) {
- //set a random token in a cookie
- cookie=sb.userDB.getCookie(entry);
- final ResponseHeader outgoingHeader=new ResponseHeader(200);
- outgoingHeader.setCookie("login", cookie);
- prop.setOutgoingHeader(outgoingHeader);
-
- prop.put("logged-in", "1");
- prop.put("logged-in_identified-by", "1");
- prop.putHTML("logged-in_username", username);
- if(post.containsKey("returnto")){
- prop.put(serverObjects.ACTION_LOCATION, post.get("returnto"));
- }
- }
- }
-
- if (post != null && entry != null) {
- if (post.containsKey("changepass")) {
- prop.put("status", "1"); //password
-
- if (entry.getMD5EncodedUserPwd().startsWith("MD5:") ?
- entry.getMD5EncodedUserPwd().equals(sb.encodeDigestAuth(entry.getUserName(), post.get("oldpass", ""))) :
- entry.getMD5EncodedUserPwd().equals(sb.encodeBasicAuth(entry.getUserName() , post.get("oldpass", "")))) {
- if (post.get("newpass").equals(post.get("newpass2"))) {
- if (!post.get("newpass", "").equals("")) {
- try {
- entry.setProperty(UserDB.Entry.MD5ENCODED_USERPWD_STRING, sb.encodeDigestAuth(entry.getUserName(), post.get("newpass", "")));
- prop.put("status_password", "0"); //changes
- } catch (final Exception e) {
- ConcurrentLog.logException(e);
- }
- } else {
- prop.put("status_password", "3"); //empty
- }
- } else {
- prop.put("status_password", "2"); //pws do not match
- }
- } else {
- prop.put("status_password", "1"); //old pw wrong
- }
- }
- }
- if(post!=null && post.containsKey("logout")){
- prop.put("logged-in", "0");
- if(entry != null){
- final String ip = requestHeader.getRemoteAddr();
- entry.logout((ip != null ? ip : "xxxxxx"), UserDB.getLoginToken(requestHeader.getCookies()));
- }
- try {
- requestHeader.logout(); // servlet container session logout
- } catch (final ServletException ex) {}
- if(post.containsKey("returnto")){
- prop.putHTML(serverObjects.ACTION_LOCATION, post.get("returnto"));
- }
- }
- // return rewrite properties
- return prop;
- }
-}
diff --git a/source/net/yacy/htroot/Wiki.java b/source/net/yacy/htroot/Wiki.java
deleted file mode 100644
index 22d01e274..000000000
--- a/source/net/yacy/htroot/Wiki.java
+++ /dev/null
@@ -1,283 +0,0 @@
-// Wiki.java
-// -----------------------
-// part of the AnomicHTTPD caching proxy
-// (C) by Michael Peter Christen; mc@yacy.net
-// first published on http://www.anomic.de
-// Frankfurt, Germany, 2004
-//
-//$LastChangedDate$
-//$LastChangedRevision$
-//$LastChangedBy$
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program 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 General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-// Contains contributions from Alexander Schier [AS]
-// and Marc Nause [MN]
-
-// You must compile this file with
-// javac -classpath .:../classes Wiki.java
-// if the shell's current path is HTROOT
-
-package net.yacy.htroot;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import net.yacy.cora.date.GenericFormatter;
-import net.yacy.cora.document.encoding.UTF8;
-import net.yacy.cora.protocol.Domains;
-import net.yacy.cora.protocol.HeaderFramework;
-import net.yacy.cora.protocol.RequestHeader;
-import net.yacy.data.Diff;
-import net.yacy.data.wiki.WikiBoard;
-import net.yacy.peers.NewsPool;
-import net.yacy.peers.Seed;
-import net.yacy.search.Switchboard;
-import net.yacy.server.serverObjects;
-import net.yacy.server.serverSwitch;
-
-public class Wiki {
- private static final String ANONYMOUS = "anonymous";
-
- //private static String ListLevel = "";
- //private static String numListLevel = "";
-
- public static String dateString(final Date date) {
- return GenericFormatter.SIMPLE_FORMATTER.format(date);
- }
-
-
- public static serverObjects respond(final RequestHeader header, serverObjects post, final serverSwitch env) throws IOException {
- final Switchboard sb = (Switchboard) env;
- final serverObjects prop = new serverObjects();
- if (post == null) {
- post = new serverObjects();
- post.put("page", "start");
- }
-
- prop.put("topmenu", sb.getConfigBool("publicTopmenu", true) ? 1 : 0);
-
- String access = sb.getConfig("WikiAccess", "admin");
- final String pagename = get(post, "page", "start");
- final String ip = get(post, HeaderFramework.CONNECTION_PROP_CLIENTIP, Domains.LOCALHOST);
- String author = get(post, "author", ANONYMOUS);
- if (author.equals(ANONYMOUS)) {
- author = WikiBoard.guessAuthor(ip);
- if (author == null) {
- author = (sb.peers.mySeed() == null) ? ANONYMOUS : sb.peers.mySeed().get(Seed.NAME, ANONYMOUS);
- }
- }
-
- if (post != null && post.containsKey("access")) {
- // only the administrator may change the access right
- if (!sb.verifyAuthentication(header)) {
- // check access right for admin
- prop.authenticationRequired();
- return prop;
- }
-
- access = post.get("access", "admin");
- sb.setConfig("WikiAccess", access);
- }
- if (access.equals("admin")) {
- prop.put("mode_access", "0");
- } else if (access.equals("all")) {
- prop.put("mode_access", "1");
- }
-
- WikiBoard.Entry page = sb.wikiDB.read(pagename);
-
- if (post != null && post.containsKey("submit")) {
-
- if ((access.equals("admin") && (!sb.verifyAuthentication(header)))) {
- // check access right for admin
- prop.authenticationRequired();
- return prop;
- }
-
- // store a new page
- byte[] content;
- content = UTF8.getBytes(post.get("content", ""));
- final WikiBoard.Entry newEntry = sb.wikiDB.newEntry(pagename, author, ip, post.get("reason", "edit"), content);
- sb.wikiDB.write(newEntry);
- // create a news message
- final Map<String, String> map = new HashMap<>();
- map.put("page", pagename);
- map.put("author", author.replace(',', ' '));
- if (!sb.isRobinsonMode() && post.get("content", "").trim().length() > 0 && !Arrays.equals(page.page(), content)) {
- sb.peers.newsPool.publishMyNews(sb.peers.mySeed(), NewsPool.CATEGORY_WIKI_UPDATE, map);
- }
- page = newEntry;
- prop.putHTML(serverObjects.ACTION_LOCATION, "Wiki.html?page=" + pagename);
- prop.put(serverObjects.ACTION_LOCATION, prop.get(serverObjects.ACTION_LOCATION));
- }
-
- if (post != null && post.containsKey("edit")) {
- if ((access.equals("admin") && (!sb.verifyAuthentication(header)))) {
- // check access right for admin
- prop.authenticationRequired();
- return prop;
- }
-
- prop.put("mode", "1"); //edit
- prop.putHTML("mode_author", author);
- prop.putHTML("mode_page-code", UTF8.String(page.page()));
- prop.putHTML("mode_pagename", pagename); }
-
- //contributed by [MN]
- else if (post != null && post.containsKey("preview")) {
- // preview the page
- prop.put("mode", "2");//preview
- prop.putHTML("mode_pagename", pagename);
- prop.putHTML("mode_author", author);
- prop.put("mode_date", dateString(new Date()));
- /* We do not fill hostport parameter : relative links should stay relative as it is more reliable
- * when the peer is behind any kind of reverse Proxy */
- prop.putWiki("mode_page", post.get("content", ""));
- prop.putHTML("mode_page-code", post.get("content", ""));
- }
- //end contrib of [MN]
-
- else if (post != null && post.containsKey("index")) {
- // view an index
- prop.put("mode", "3"); //Index
- try {
- final Iterator<byte[]> i = sb.wikiDB.keys(true);
- int count=0;
- while (i.hasNext()) {
- final String subject = UTF8.String(i.next());
- final WikiBoard.Entry entry = sb.wikiDB.read(subject);
- prop.putHTML("mode_pages_" + count + "_name",WikiBoard.webalize(subject));
- prop.putHTML("mode_pages_" + count + "_subject", subject);
- prop.put("mode_pages_" + count + "_date", dateString(entry.date()));
- prop.putHTML("mode_pages_" + count + "_author", entry.author());
- count++;
- }
- prop.put("mode_pages", count);
- } catch (final IOException e) {
- prop.put("mode_error", "1"); //IO Error reading Wiki
- prop.putHTML("mode_error_message", e.getMessage());
- }
- prop.putHTML("mode_pagename", pagename);
- } else if (post != null && post.containsKey("diff")) {
- // Diff
- prop.put("mode", "4");
- prop.putHTML("mode_page", pagename);
- prop.putHTML("mode_error_page", pagename);
-
- try {
- final Iterator<byte[]> it = sb.wikiDB.keysBkp(true);
- WikiBoard.Entry entry;
- WikiBoard.Entry oentry = null;
- WikiBoard.Entry nentry = null;
- int count = 0;
- boolean oldselected = false, newselected = false;
- while (it.hasNext()) {
- entry = sb.wikiDB.readBkp(UTF8.String(it.next()));
- prop.put("mode_error_versions_" + count + "_date", WikiBoard.dateString(entry.date()));
- prop.put("mode_error_versions_" + count + "_fdate", dateString(entry.date()));
- if (WikiBoard.dateString(entry.date()).equals(post.get("old", ""))) {
- prop.put("mode_error_versions_" + count + "_oldselected", "1");
- oentry = entry;
- oldselected = true;
- } else if (WikiBoard.dateString(entry.date()).equals(post.get("new", ""))) {
- prop.put("mode_error_versions_" + count + "_newselected", "1");
- nentry = entry;
- newselected = true;
- }
- count++;
- }
- count--; // don't show current version
-
- if (!oldselected) { // select latest old entry
- prop.put("mode_error_versions_" + (count - 1) + "_oldselected", "1");
- }
- if (!newselected) { // select latest new entry (== current)
- prop.put("mode_error_curselected", "1");
- }
-
- if (count == 0) {
- prop.put("mode_error", "2"); // no entries found
- } else {
- prop.put("mode_error_versions", count);
- }
-
- entry = sb.wikiDB.read(pagename);
- if (entry != null) {
- prop.put("mode_error_curdate", WikiBoard.dateString(entry.date()));
- prop.put("mode_error_curfdate", dateString(entry.date()));
- }
-
- if (nentry == null) {
- nentry = entry;
- }
- if (post.containsKey("compare") && oentry != null && nentry != null) {
- // TODO: split into paragraphs and compare them with the same diff-algo
- final Diff diff = new Diff(
- UTF8.String(oentry.page()),
- UTF8.String(nentry.page()), 3);
- prop.put("mode_versioning_diff", net.yacy.data.Diff.toHTML(new Diff[] { diff }));
- prop.put("mode_versioning", "1");
- } else if (post.containsKey("viewold") && oentry != null) {
- prop.put("mode_versioning", "2");
- prop.putHTML("mode_versioning_pagename", pagename);
- prop.putHTML("mode_versioning_author", oentry.author());
- prop.put("mode_versioning_date", dateString(oentry.date()));
- /* We do not fill hostport parameter : relative links should stay relative as it is more reliable
- * when the peer is behind any kind of reverse Proxy */
- prop.putWiki("mode_versioning_page", oentry.page());
- prop.putHTML("mode_versioning_page-code", UTF8.String(oentry.page()));
- }
- } catch (final IOException e) {
- prop.put("mode_error", "1"); //IO Error reading Wiki
- prop.putHTML("mode_error_message", e.getMessage());
- }
- }
-
- else {
- // show page
- prop.put("mode", "0"); //viewing
- prop.putHTML("mode_pagename", pagename);
- prop.putHTML("mode_author", page.author());
- prop.put("mode_date", dateString(page.date()));
- /* We do not fill hostport parameter : relative links should stay relative as it is more reliable
- * when the peer is behind any kind of reverse Proxy */
- prop.putWiki("mode_page", page.page());
-
- prop.put("controls", "0");
- prop.putHTML("controls_pagename", pagename);
- }
-
- // return rewrite properties
- return prop;
- }
-
-
- /**
- * get key from post, use dflt if (not present or post == null)
- *
- * @param post
- * @param string
- * @param string2
- * @return
- */
- private static String get(final serverObjects post, final String key, final String dflt) {
- return (post == null ? dflt : post.get(key, dflt));
- }
-}
diff --git a/source/net/yacy/htroot/WikiHelp.java b/source/net/yacy/htroot/WikiCodeHelp.java
index f22e4afa0..1ff85c139 100644
--- a/source/net/yacy/htroot/WikiHelp.java
+++ b/source/net/yacy/htroot/WikiCodeHelp.java
@@ -1,4 +1,4 @@
-// WikiHelp.java
+// WikiCodeHelp.java
// -----------------------
// part of the AnomicHTTPD caching proxy
// (C) by Michael Peter Christen; mc@yacy.net
@@ -24,7 +24,7 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// You must compile this file with
-// javac -classpath .:../classes WikiHelp.java
+// javac -classpath .:../classes WikiCodeHelp.java
// if the shell's current path is HTROOT
package net.yacy.htroot;
@@ -33,7 +33,7 @@ import net.yacy.cora.protocol.RequestHeader;
import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch;
-public class WikiHelp {
+public class WikiCodeHelp {
public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, @SuppressWarnings("unused") final serverObjects post, @SuppressWarnings("unused") final serverSwitch env) {
//final plasmaSwitchboard sb = (plasmaSwitchboard) env;
diff --git a/source/net/yacy/htroot/api/bookmarks/get_bookmarks.java b/source/net/yacy/htroot/api/bookmarks/get_bookmarks.java
index 0ee2a9799..ba2c05c8b 100644
--- a/source/net/yacy/htroot/api/bookmarks/get_bookmarks.java
+++ b/source/net/yacy/htroot/api/bookmarks/get_bookmarks.java
@@ -10,10 +10,10 @@ import net.yacy.cora.protocol.HeaderFramework;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.data.BookmarkHelper;
import net.yacy.data.BookmarksDB;
-import net.yacy.data.UserDB;
import net.yacy.document.parser.html.CharacterCoding;
import net.yacy.http.servlets.YaCyDefaultServlet;
import net.yacy.search.Switchboard;
+import net.yacy.search.SwitchboardConstants;
import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch;
@@ -21,7 +21,6 @@ public class get_bookmarks {
private static final serverObjects prop = new serverObjects();
private static Switchboard sb = null;
- private static UserDB.Entry user = null;
private static boolean isAdmin = false;
private static int R = 1; // TODO: solve the recursion problem an remove global variable
@@ -59,13 +58,11 @@ public class get_bookmarks {
prop.clear();
sb = (Switchboard) env;
- user = sb.userDB.getUser(header);
- isAdmin = (sb.verifyAuthentication(header) || user != null && user.hasRight(UserDB.AccessRight.BOOKMARK_RIGHT));
+ isAdmin = sb.verifyAuthentication(header);
// set user name
final String username;
- if(user != null) username=user.getUserName();
- else if(isAdmin) username="admin";
+ if(isAdmin) username=sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin");
else username = "unknown";
prop.putHTML("display_user", username);
@@ -290,4 +287,4 @@ public class get_bookmarks {
}
return count;
}
-} \ No newline at end of file
+}
diff --git a/source/net/yacy/htroot/api/bookmarks/get_folders.java b/source/net/yacy/htroot/api/bookmarks/get_folders.java
index 706a095bd..e03f9df09 100644
--- a/source/net/yacy/htroot/api/bookmarks/get_folders.java
+++ b/source/net/yacy/htroot/api/bookmarks/get_folders.java
@@ -8,9 +8,9 @@ import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.util.CommonPattern;
import net.yacy.data.BookmarkHelper;
import net.yacy.data.BookmarksDB;
-import net.yacy.data.UserDB;
import net.yacy.http.servlets.YaCyDefaultServlet;
import net.yacy.search.Switchboard;
+import net.yacy.search.SwitchboardConstants;
import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch;
@@ -18,21 +18,18 @@ public class get_folders {
private static final serverObjects prop = new serverObjects();
private static Switchboard sb = null;
- private static UserDB.Entry user = null;
private static boolean isAdmin = false;
public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
prop.clear();
sb = (Switchboard) env;
- user = sb.userDB.getUser(header);
- isAdmin = (sb.verifyAuthentication(header) || user != null && user.hasRight(UserDB.AccessRight.BOOKMARK_RIGHT));
-
- // set user name
- final String username;
- if(user != null) username=user.getUserName();
- else if(isAdmin) username="admin";
- else username = "unknown";
+ isAdmin = sb.verifyAuthentication(header);
+
+ // set user name
+ final String username;
+ if(isAdmin) username=sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin");
+ else username = "unknown";
prop.putHTML("display_user", username);
// set peer address base : used in get_bookmarks.xml to render the absolute API link URL
@@ -106,4 +103,4 @@ public class get_folders {
// return rewrite properties
return prop;
}
-} \ No newline at end of file
+}
diff --git a/source/net/yacy/htroot/api/bookmarks/posts/add_p.java b/source/net/yacy/htroot/api/bookmarks/posts/add_p.java
index 755cf4953..fed4e77b7 100644
--- a/source/net/yacy/htroot/api/bookmarks/posts/add_p.java
+++ b/source/net/yacy/htroot/api/bookmarks/posts/add_p.java
@@ -9,9 +9,9 @@ import net.yacy.cora.protocol.RequestHeader;
import net.yacy.data.BookmarkHelper;
import net.yacy.data.BookmarksDB;
import net.yacy.data.ListManager;
-import net.yacy.data.UserDB;
import net.yacy.peers.NewsPool;
import net.yacy.search.Switchboard;
+import net.yacy.search.SwitchboardConstants;
import net.yacy.server.serverObjects;
import net.yacy.server.serverSwitch;
@@ -20,19 +20,16 @@ public class add_p {
private static final serverObjects prop = new serverObjects();
private static Switchboard sb = null;
- private static UserDB.Entry user = null;
private static boolean isAdmin = false;
public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
sb = (Switchboard) env;
isAdmin=sb.verifyAuthentication(header);
- user = sb.userDB.getUser(header);
// set user name
- String username="";
- if(user != null) username=user.getUserName();
- else if(isAdmin) username="admin";
+ final String username = isAdmin
+ ? sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin") : "";
if (post != null) {
if (!isAdmin) {
@@ -53,9 +50,6 @@ public class add_p {
if(bookmark != null){
bookmark.setProperty(BookmarksDB.Bookmark.BOOKMARK_TITLE, title);
bookmark.setProperty(BookmarksDB.Bookmark.BOOKMARK_DESCRIPTION, description);
- if(user!=null){
- bookmark.setOwner(user.getUserName());
- }
if("public".equals(post.get("public"))){
bookmark.setPublic(true);
publishNews(url, title, description, tagsString);
@@ -88,4 +82,4 @@ public class add_p {
map.put("tags", tagsString.replace(',', ' '));
sb.peers.newsPool.publishMyNews(sb.peers.mySeed(), NewsPool.CATEGORY_BOOKMARK_ADD, map);
}
-} \ No newline at end of file
+}
diff --git a/source/net/yacy/htroot/index.java b/source/net/yacy/htroot/index.java
index 61e4acd97..3b8ee35a4 100644
--- a/source/net/yacy/htroot/index.java
+++ b/source/net/yacy/htroot/index.java
@@ -33,7 +33,6 @@ package net.yacy.htroot;
import net.yacy.cora.document.analysis.Classification;
import net.yacy.cora.document.analysis.Classification.ContentDomain;
import net.yacy.cora.protocol.RequestHeader;
-import net.yacy.data.UserDB;
import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
import net.yacy.search.schema.CollectionSchema;
@@ -55,18 +54,10 @@ public class index {
}
// access control
- String authenticatedUserName = null;
- final boolean adminAuthenticated = sb.verifyAuthentication(header);
-
- if(adminAuthenticated) {
- authenticatedUserName = sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin");
- } else {
- final UserDB.Entry user = sb.userDB != null ? sb.userDB.getUser(header) : null;
- if(user != null) {
- authenticatedUserName = user.getUserName();
- }
- }
- final boolean authenticated = adminAuthenticated || authenticatedUserName != null;
+ final boolean adminAuthenticated = sb.verifyAuthentication(header);
+ final String authenticatedUserName = adminAuthenticated
+ ? sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin") : null;
+ final boolean authenticated = adminAuthenticated;
if (post != null) {
if (post.containsKey("publicPage") && !adminAuthenticated) { // Old style parameter : still in use ?
prop.authenticationRequired();
diff --git a/source/net/yacy/htroot/robots.java b/source/net/yacy/htroot/robots.java
index 06b82ffd3..4b477b529 100644
--- a/source/net/yacy/htroot/robots.java
+++ b/source/net/yacy/htroot/robots.java
@@ -27,7 +27,6 @@ public class robots {
if (rbc.isAllDisallowed()) {
prop.put(RobotsTxtConfig.ALL, 1);
} else {
- if (rbc.isBlogDisallowed()) prop.put(RobotsTxtConfig.ALL + "_" + RobotsTxtConfig.BLOG, "1");
if (rbc.isBookmarksDisallowed()) prop.put(RobotsTxtConfig.ALL + "_" + RobotsTxtConfig.BOOKMARKS, "1");
if (rbc.isFileshareDisallowed()) prop.put(RobotsTxtConfig.ALL + "_" + RobotsTxtConfig.FILESHARE, "1");
if (rbc.isHomepageDisallowed()) prop.put(RobotsTxtConfig.ALL + "_" + RobotsTxtConfig.HOMEPAGE, "1");
@@ -35,7 +34,6 @@ public class robots {
if (rbc.isNewsDisallowed()) prop.put(RobotsTxtConfig.ALL + "_" + RobotsTxtConfig.NEWS, "1");
if (rbc.isStatusDisallowed()) prop.put(RobotsTxtConfig.ALL + "_" + RobotsTxtConfig.STATUS, "1");
if (rbc.isSurftipsDisallowed()) prop.put(RobotsTxtConfig.ALL + "_" + RobotsTxtConfig.SURFTIPS, "1");
- if (rbc.isWikiDisallowed()) prop.put(RobotsTxtConfig.ALL + "_" + RobotsTxtConfig.WIKI, "1");
if (rbc.isProfileDisallowed()) prop.put(RobotsTxtConfig.ALL + "_" + RobotsTxtConfig.PROFILE, "1");
if (rbc.isLockedDisallowed() || rbc.isDirsDisallowed()) {
diff --git a/source/net/yacy/htroot/yacychat.java b/source/net/yacy/htroot/yacychat.java
index 74c081dac..c9e7dfce4 100644
--- a/source/net/yacy/htroot/yacychat.java
+++ b/source/net/yacy/htroot/yacychat.java
@@ -1,8 +1,24 @@
-package net.yacy.htroot;
+/**
+ * yacychat
+ * Copyright 2025 by Michael Peter Christen
+ * First released 23.11.2025 at https://yacy.net
+ *
+ * This library is free software; you can redistribute it and/or
+ * 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/>.
+ */
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.json.JSONTokener;
+package net.yacy.htroot;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.search.Switchboard;
@@ -12,53 +28,38 @@ import net.yacy.server.serverSwitch;
public class yacychat {
- public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, final serverSwitch env) {
- // return variable that accumulates replacements
- final Switchboard sb = (Switchboard) env;
-
- final serverObjects prop = new serverObjects();
- String body = post == null ? "" : post.get("BODY", "");
- JSONObject bodyj = new JSONObject();
- if (body.length() > 0) {
- try {
- bodyj = new JSONObject(new JSONTokener(body));
- } catch (JSONException e) {
- // silently catch this
- }
- }
+ public static serverObjects respond(@SuppressWarnings("unused") final RequestHeader header, final serverObjects post, final serverSwitch env) {
+ // return variable that accumulates replacements
+ final serverObjects prop = new serverObjects();
- // system prompt comes from configuration; default is empty
- final String systemPrompt = sb.getConfig("ai.system-prompt", net.yacy.http.servlets.RAGProxyServlet.LLM_SYSTEM_PROMPT_DEFAULT);
- // escape for safe embedding in a JS single-quoted string literal
- final String systemPromptJs = systemPrompt
- .replace("\\", "\\\\")
- .replace("'", "\\'")
- .replace("\r\n", "\\n")
- .replace("\n", "\\n")
- .replace("\r", "\\n");
- prop.put("system_prompt", systemPromptJs);
- prop.put("topmenu", sb.getConfigBool("ai.shield.show-chat-link", false) ? (sb.getConfigBool("publicTopmenu", true) ? 1 : 0) : 2);
+ // system prompt comes from configuration; default is empty
+ final Switchboard sb = (Switchboard) env;
+ final String systemPrompt = sb.getConfig("ai.system-prompt", net.yacy.http.servlets.RAGProxyServlet.LLM_SYSTEM_PROMPT_DEFAULT);
+ // escape for safe embedding in a JS single-quoted string literal
+ final String systemPromptJs = systemPrompt.replace("\\", "\\\\").replace("'", "\\'").replace("\r\n", "\\n").replace("\n", "\\n").replace("\r", "\\n");
+ prop.put("system_prompt", systemPromptJs);
+ prop.put("topmenu",sb.getConfigBool("ai.shield.show-chat-link", false) ? (sb.getConfigBool("publicTopmenu", true) ? 1 : 0) : 2);
- String promoteChatPageGreeting = env.getConfig("promoteChatPageGreeting", "");
- if (env.getConfigBool(SwitchboardConstants.GREETING_NETWORK_NAME, false)) {
- promoteChatPageGreeting = env.getConfig("network.unit.description", "");
- }
- prop.put("promoteChatPageGreeting", promoteChatPageGreeting);
- prop.put("topmenu_promoteChatPageGreeting", promoteChatPageGreeting);
- prop.put(SwitchboardConstants.GREETING_HOMEPAGE, sb.getConfig(SwitchboardConstants.GREETING_HOMEPAGE, ""));
- prop.put("topmenu_" + SwitchboardConstants.GREETING_HOMEPAGE, sb.getConfig(SwitchboardConstants.GREETING_HOMEPAGE, ""));
- prop.put(SwitchboardConstants.GREETING_LARGE_IMAGE, sb.getConfig(SwitchboardConstants.GREETING_LARGE_IMAGE, ""));
- prop.put("topmenu_" + SwitchboardConstants.GREETING_LARGE_IMAGE, sb.getConfig(SwitchboardConstants.GREETING_LARGE_IMAGE, ""));
- prop.put(SwitchboardConstants.GREETING_IMAGE_ALT, sb.getConfig(SwitchboardConstants.GREETING_IMAGE_ALT, ""));
- prop.put("topmenu_" + SwitchboardConstants.GREETING_IMAGE_ALT, sb.getConfig(SwitchboardConstants.GREETING_IMAGE_ALT, ""));
+ String promoteChatPageGreeting = env.getConfig("promoteChatPageGreeting", "");
+ if (env.getConfigBool(SwitchboardConstants.GREETING_NETWORK_NAME, false)) promoteChatPageGreeting = env.getConfig("network.unit.description", "");
+
+ prop.put("promoteChatPageGreeting", promoteChatPageGreeting);
+ prop.put("topmenu_promoteChatPageGreeting", promoteChatPageGreeting);
+ prop.put(SwitchboardConstants.GREETING_HOMEPAGE, sb.getConfig(SwitchboardConstants.GREETING_HOMEPAGE, ""));
+ prop.put("topmenu_" + SwitchboardConstants.GREETING_HOMEPAGE, sb.getConfig(SwitchboardConstants.GREETING_HOMEPAGE, ""));
+ prop.put(SwitchboardConstants.GREETING_LARGE_IMAGE, sb.getConfig(SwitchboardConstants.GREETING_LARGE_IMAGE, ""));
+ prop.put("topmenu_" + SwitchboardConstants.GREETING_LARGE_IMAGE, sb.getConfig(SwitchboardConstants.GREETING_LARGE_IMAGE, ""));
+ prop.put(SwitchboardConstants.GREETING_IMAGE_ALT, sb.getConfig(SwitchboardConstants.GREETING_IMAGE_ALT, ""));
+ prop.put("topmenu_" + SwitchboardConstants.GREETING_IMAGE_ALT, sb.getConfig(SwitchboardConstants.GREETING_IMAGE_ALT, ""));
- // determine if P2P mode is active (global search available)
- final boolean indexReceiveGranted = sb.getConfigBool(net.yacy.search.SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, true) || (sb.isRobinsonMode() && sb.getConfig(net.yacy.search.SwitchboardConstants.CLUSTER_MODE, "").equals(net.yacy.search.SwitchboardConstants.CLUSTER_MODE_PUBLIC_CLUSTER));
- final boolean p2pmode = indexReceiveGranted;
- prop.put("p2p_mode", p2pmode ? 1 : 0);
+ // determine if P2P mode is active (global search available)
+ final boolean indexReceiveGranted =
+ sb.getConfigBool(net.yacy.search.SwitchboardConstants.INDEX_RECEIVE_ALLOW_SEARCH, true) ||
+ (sb.isRobinsonMode() && sb.getConfig(net.yacy.search.SwitchboardConstants.CLUSTER_MODE, "").equals(net.yacy.search.SwitchboardConstants.CLUSTER_MODE_PUBLIC_CLUSTER));
+ prop.put("p2p_mode", indexReceiveGranted ? 1 : 0);
- // return rewrite properties
- return prop;
- }
+ // return rewrite properties
+ return prop;
+ }
}
diff --git a/source/net/yacy/htroot/yacysearch.java b/source/net/yacy/htroot/yacysearch.java
index 05647672d..4709d4ce3 100644
--- a/source/net/yacy/htroot/yacysearch.java
+++ b/source/net/yacy/htroot/yacysearch.java
@@ -69,7 +69,6 @@ import net.yacy.cora.protocol.ResponseHeader;
import net.yacy.cora.util.ConcurrentLog;
import net.yacy.data.BookmarksDB.Bookmark;
import net.yacy.data.DidYouMean;
-import net.yacy.data.UserDB;
import net.yacy.document.LibraryProvider;
import net.yacy.document.Tokenizer;
import net.yacy.http.servlets.TemplateProcessingException;
@@ -111,22 +110,11 @@ public class yacysearch {
final Switchboard sb = (Switchboard) env;
sb.localSearchLastAccess = System.currentTimeMillis();
- String authenticatedUserName = null;
final boolean adminAuthenticated = sb.verifyAuthentication(header);
final boolean searchAllowed = sb.getConfigBool(SwitchboardConstants.PUBLIC_SEARCHPAGE, true) || adminAuthenticated;
-
- boolean extendedSearchRights = adminAuthenticated;
- boolean bookmarkRights = false;
- if (adminAuthenticated) {
- authenticatedUserName = sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin");
- } else {
- final UserDB.Entry user = sb.userDB != null ? sb.userDB.getUser(header) : null;
- if (user != null) {
- extendedSearchRights = user.hasRight(UserDB.AccessRight.EXTENDED_SEARCH_RIGHT);
- authenticatedUserName = user.getUserName();
- bookmarkRights = user.hasRight(UserDB.AccessRight.BOOKMARK_RIGHT);
- }
- }
+ final boolean extendedSearchRights = adminAuthenticated;
+ final String authenticatedUserName = adminAuthenticated
+ ? sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin") : null;
final boolean localhostAccess = header.accessFromLocalhost();
final String promoteSearchPageGreeting =
@@ -712,14 +700,14 @@ public class yacysearch {
// if a bookmarks-button was hit, create new bookmark entry
if (post != null && post.containsKey("bookmarkref")) {
- if (!sb.verifyAuthentication(header) && !bookmarkRights) {
+ if (!adminAuthenticated) {
prop.authenticationRequired();
return prop;
}
//final String bookmarkHash = post.get("bookmarkref", ""); // urlhash
final String urlstr = crypt.simpleDecode(post.get("bookmarkurl"));
if (urlstr != null) {
- final Bookmark bmk = sb.bookmarksDB.createorgetBookmark(urlstr, "admin");
+ final Bookmark bmk = sb.bookmarksDB.createorgetBookmark(urlstr, authenticatedUserName);
if (bmk != null) {
bmk.setProperty(Bookmark.BOOKMARK_QUERY, querystring);
bmk.addTag("/search"); // add to bookmark folder
diff --git a/source/net/yacy/htroot/yacysearchitem.java b/source/net/yacy/htroot/yacysearchitem.java
index a85679f0a..42cbe9ede 100644
--- a/source/net/yacy/htroot/yacysearchitem.java
+++ b/source/net/yacy/htroot/yacysearchitem.java
@@ -55,7 +55,6 @@ import net.yacy.cora.util.Memory;
import net.yacy.crawler.data.Cache;
import net.yacy.crawler.retrieval.Response;
import net.yacy.data.URLLicense;
-import net.yacy.data.UserDB;
import net.yacy.document.parser.html.IconEntry;
import net.yacy.http.servlets.TemplateMissingParameterException;
import net.yacy.kelondro.data.meta.URIMetadataNode;
@@ -103,16 +102,13 @@ public class yacysearchitem {
final String eventID = post.get("eventID", "");
final boolean adminAuthenticated = sb.verifyAuthentication(header);
- final UserDB.Entry user = sb.userDB != null ? sb.userDB.getUser(header) : null;
- final boolean authenticated = adminAuthenticated || user != null;
-
- final boolean extendedSearchRights = adminAuthenticated || (user != null && user.hasRight(UserDB.AccessRight.EXTENDED_SEARCH_RIGHT));
- //final boolean bookmarkRights = adminAuthenticated || (user != null && user.hasRight(UserDB.AccessRight.BOOKMARK_RIGHT));
+ final boolean authenticated = adminAuthenticated;
+ final boolean extendedSearchRights = adminAuthenticated;
final int item = post.getInt("item", -1);
final RequestHeader.FileType fileType = header.fileType();
- if (post.containsKey("auth") && !adminAuthenticated && user == null) {
+ if (post.containsKey("auth") && !adminAuthenticated) {
/*
* Access to authentication protected features is explicitely requested here
* but no authentication is provided : ask now for authentication.
@@ -188,20 +184,9 @@ public class yacysearchitem {
prop.put("content", 1); // switch on specific content
final String urlhash = ASCII.String(result.hash());
if (adminAuthenticated) { // only needed if authorized
- addAuthorizedActions(sb, prop, theSearch, resultUrlstring, resource, origQ, urlhash, null);
- } else if (authenticated && user != null) {
- addAuthorizedActions(sb, prop, theSearch, resultUrlstring, resource, origQ, urlhash, user);
+ addAuthorizedActions(sb, prop, theSearch, resultUrlstring, resource, origQ, urlhash);
} else
prop.put("content_authorized", "0"); // disable for not authorized user
-// for testing only
-// result
-// if local Admin - no admin_right
-// if admin authent -> admin_right = true, bookmark_right = false
- if (header.isUserInRole(UserDB.AccessRight.ADMIN_RIGHT.toString())) {
- if (header.isUserInRole(UserDB.AccessRight.BOOKMARK_RIGHT.toString())) {
- System.out.println("booki");
- }
- }
prop.putHTML("content_title", result.title());
prop.putXML("content_title-xml", result.title());
prop.putJSON("content_title-json", result.title());
@@ -677,17 +662,13 @@ public class yacysearchitem {
* @param resource resource scope ("local" or "global")
* @param origQ origin query terms
* @param urlhash URL hash of the result item
- * @param user current user or null if current user is admin
*/
private static void addAuthorizedActions(final Switchboard sb, final serverObjects prop,
final SearchEvent theSearch, final String resultUrlstring, final String resource, final String origQ,
- final String urlhash, final UserDB.Entry user) {
+ final String urlhash) {
// check if url exists in bookmarks
final boolean bookmarkexists = sb.bookmarksDB.getBookmark(urlhash) != null;
- if (user == null || user.hasRight(UserDB.AccessRight.BOOKMARK_RIGHT)) {
- prop.put("content_authorized_bookmark", !bookmarkexists);
- } else
- prop.put("content_authorized_bookmark", "0");
+ prop.put("content_authorized_bookmark", !bookmarkexists);
/* boolean blacklistislisted = false;
try {
DigestURL durl = new DigestURL(resultUrlstring);
@@ -722,13 +703,8 @@ public class yacysearchitem {
prop.put("content_authorized_recommend_deletelink", deleteLink);
prop.put("content_authorized_recommend_recommendlink", recommendLink);
- if (user == null || user.hasRight(UserDB.AccessRight.ADMIN_RIGHT)) {
- prop.put("content_authorized_recommend", (sb.peers.newsPool.getSpecific(NewsPool.OUTGOING_DB, NewsPool.CATEGORY_SURFTIPP_ADD, "url", resultUrlstring) == null) ? "1" : "0");
- prop.put("content_authorized_blacklist", "1");
- } else {
- prop.put("content_authorized_recommend", "0");
- prop.put("content_authorized_blacklist", "0");
- }
+ prop.put("content_authorized_recommend", (sb.peers.newsPool.getSpecific(NewsPool.OUTGOING_DB, NewsPool.CATEGORY_SURFTIPP_ADD, "url", resultUrlstring) == null) ? "1" : "0");
+ prop.put("content_authorized_blacklist", "1");
// prop.put("content_authorized_urlhash", urlhash); // not used 2022-02-09
prop.put("content_authorized", "1"); // enable authorized icons/content
}
diff --git a/source/net/yacy/htroot/yacysearchlatestinfo.java b/source/net/yacy/htroot/yacysearchlatestinfo.java
index c62239155..04d9ef601 100644
--- a/source/net/yacy/htroot/yacysearchlatestinfo.java
+++ b/source/net/yacy/htroot/yacysearchlatestinfo.java
@@ -1,7 +1,6 @@
package net.yacy.htroot;
import net.yacy.cora.protocol.RequestHeader;
-import net.yacy.data.UserDB;
import net.yacy.http.servlets.TemplateMissingParameterException;
import net.yacy.cora.util.ConcurrentLog;
import net.yacy.kelondro.util.Formatter;
@@ -23,10 +22,7 @@ public class yacysearchlatestinfo {
final serverObjects prop = new serverObjects();
final Switchboard sb = (Switchboard) env;
- final boolean adminAuthenticated = sb.verifyAuthentication(header);
- final UserDB.Entry user = sb.userDB != null ? sb.userDB.getUser(header) : null;
- final boolean userAuthenticated = (user != null && user.hasRight(UserDB.AccessRight.EXTENDED_SEARCH_RIGHT));
- final boolean authenticated = adminAuthenticated || userAuthenticated;
+ final boolean authenticated = sb.verifyAuthentication(header);
// find search event
final String eventID = post.get("eventID", "");
diff --git a/source/net/yacy/htroot/yacysearchtrailer.java b/source/net/yacy/htroot/yacysearchtrailer.java
index c3d7e67ea..5f6fe8e30 100644
--- a/source/net/yacy/htroot/yacysearchtrailer.java
+++ b/source/net/yacy/htroot/yacysearchtrailer.java
@@ -38,7 +38,6 @@ import net.yacy.cora.federate.yacy.CacheStrategy;
import net.yacy.cora.lod.vocabulary.Tagging;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.sorting.ScoreMap;
-import net.yacy.data.UserDB;
import net.yacy.document.DateDetection;
import net.yacy.document.LibraryProvider;
import net.yacy.http.servlets.TemplateMissingParameterException;
@@ -75,9 +74,7 @@ public class yacysearchtrailer {
final String eventID = post.get("eventID", "");
final boolean adminAuthenticated = sb.verifyAuthentication(header);
-
- final UserDB.Entry user = sb.userDB != null ? sb.userDB.getUser(header) : null;
- final boolean authenticated = adminAuthenticated || user != null;
+ final boolean authenticated = adminAuthenticated;
if (post.containsKey("auth") && !authenticated) {
/*
diff --git a/source/net/yacy/http/YaCyHttpServer.java b/source/net/yacy/http/YaCyHttpServer.java
index 55ac5476e..f53eb7f68 100644
--- a/source/net/yacy/http/YaCyHttpServer.java
+++ b/source/net/yacy/http/YaCyHttpServer.java
@@ -220,8 +220,8 @@ public class YaCyHttpServer {
allrequesthandlers.addHandler(new DefaultHandler()); // if not handled by other handler
final YaCyLoginService loginService = new YaCyLoginService();
- // this is very important (as it is part of the user password hash)
- // changes will ivalidate all current existing user-password-hashes (from userDB)
+ // This is part of the built-in administrator's DIGEST password hash.
+ // Changing it invalidates the configured administrator password hash.
loginService.setName(sb.getConfig(SwitchboardConstants.ADMIN_REALM,"YaCy"));
final YaCySecurityHandler securityHandler = new YaCySecurityHandler();
@@ -375,8 +375,8 @@ public class YaCyHttpServer {
}
/**
- * forces loginservice to reload user credentials
- * (used after setting new pwd in cfg file/db)
+ * Forces the login service to reload the built-in administrator credentials
+ * after they were changed in the configuration.
* @param username
*/
public void resetUser(final String username) {
@@ -390,7 +390,7 @@ public class YaCyHttpServer {
}
/**
- * removes user from knowuser cache of loginservice
+ * Removes the built-in administrator from the login service cache.
* @param username
*/
public void removeUser(final String username) {
diff --git a/source/net/yacy/http/YaCyLegacyCredential.java b/source/net/yacy/http/YaCyLegacyCredential.java
index 840c10630..961e5c529 100644
--- a/source/net/yacy/http/YaCyLegacyCredential.java
+++ b/source/net/yacy/http/YaCyLegacyCredential.java
@@ -125,20 +125,4 @@ public class YaCyLegacyCredential extends Credential {
return yc;
}
- /**
- * create Credential object from password
- *
- * @param username
- * @param configHash encodeMD5Hex("user:realm:pwd") as stored in UserDB
- * @return
- */
- public static Credential getCredentialForUserDB(String username, String configHash) {
- YaCyLegacyCredential yc = new YaCyLegacyCredential();
- yc.c = Credential.getCredential(configHash); // creates a MD5 hash credential
- yc.foruser = username;
- yc.isBase64enc = false;
- yc.hash = configHash;
- return yc;
- }
-
}
diff --git a/source/net/yacy/http/YaCyLoginService.java b/source/net/yacy/http/YaCyLoginService.java
index 78b1e1ee9..abc5ec2c7 100644
--- a/source/net/yacy/http/YaCyLoginService.java
+++ b/source/net/yacy/http/YaCyLoginService.java
@@ -24,9 +24,6 @@
package net.yacy.http;
-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;
@@ -37,8 +34,8 @@ 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
+ * Jetty login service for YaCy's built-in administrator account.
+ * With DIGEST auth Jetty uses the name of the login service
* as realmname (which is part of all password hashes)
*/
public class YaCyLoginService extends HashLoginService implements LoginService {
@@ -70,7 +67,7 @@ public class YaCyLoginService extends HashLoginService implements LoginService {
}
/**
- * Load the user from cache (of authenticated users) or from the YaCy user db
+ * Load the built-in administrator from the authenticated-user cache or configuration.
* @param username
* @return known user or null
*/
@@ -83,7 +80,7 @@ public class YaCyLoginService extends HashLoginService implements LoginService {
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");
+ final String adminuser = sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin");
Credential credential = null;
String[] roles = null;
if (username.equals(adminuser)) {
@@ -94,22 +91,7 @@ public class YaCyLoginService extends HashLoginService implements LoginService {
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());
- }
+ roles = new String[]{SwitchboardConstants.ADMIN_ACCOUNT_ROLE};
}
if (credential != null) { // if credential exist, user is known, create or get info
@@ -123,8 +105,8 @@ public class YaCyLoginService extends HashLoginService implements LoginService {
}
/**
- * Delete a user from the internal cache. If user found in cache user is
- * loged out before delete.
+ * Delete the administrator identity from the internal cache. When present,
+ * the identity is logged out before removal.
* @param username
* @return true if user deleted, if not found in user cache false
*/
@@ -138,4 +120,4 @@ public class YaCyLoginService extends HashLoginService implements LoginService {
return false;
}
-} \ No newline at end of file
+}
diff --git a/source/net/yacy/http/YaCySecurityHandler.java b/source/net/yacy/http/YaCySecurityHandler.java
index 68948a081..675b02b35 100644
--- a/source/net/yacy/http/YaCySecurityHandler.java
+++ b/source/net/yacy/http/YaCySecurityHandler.java
@@ -30,7 +30,6 @@ import net.yacy.cora.document.id.MultiProtocolURL;
import net.yacy.cora.order.Base64Order;
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.protocol.RequestHeader;
-import net.yacy.data.UserDB.AccessRight;
import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
import net.yacy.server.serverAccessTracker;
@@ -104,7 +103,7 @@ public class YaCySecurityHandler extends ConstraintSecurityHandler {
}
RoleInfo roleinfo = new RoleInfo();
roleinfo.setChecked(true); // RoleInfo.setChecked() : in Jetty this means - marked to have any security constraint
- roleinfo.addRole(AccessRight.ADMIN_RIGHT.toString()); // use AccessRights as role
+ roleinfo.addRole(SwitchboardConstants.ADMIN_ACCOUNT_ROLE);
return roleinfo;
}
return super.prepareConstraintInfo(pathInContext, request);
diff --git a/source/net/yacy/http/servlets/LLMAdminProxyServlet.java b/source/net/yacy/http/servlets/LLMAdminProxyServlet.java
index ff4ccd0d3..1f8ffd810 100644
--- a/source/net/yacy/http/servlets/LLMAdminProxyServlet.java
+++ b/source/net/yacy/http/servlets/LLMAdminProxyServlet.java
@@ -47,7 +47,6 @@ import org.json.JSONTokener;
import net.yacy.cora.protocol.Domains;
import net.yacy.cora.util.ConcurrentLog;
import net.yacy.cora.util.LogRedaction;
-import net.yacy.data.UserDB;
import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
@@ -227,7 +226,7 @@ public class LLMAdminProxyServlet extends HttpServlet {
*/
private static boolean requireAdmin(final HttpServletRequest hrequest, final HttpServletResponse hresponse) throws IOException {
final Switchboard sb = Switchboard.getSwitchboard();
- final String adminRole = UserDB.AccessRight.ADMIN_RIGHT.toString();
+ final String adminRole = SwitchboardConstants.ADMIN_ACCOUNT_ROLE;
if (sb.getConfigBool(SwitchboardConstants.ADMIN_ACCOUNT_FOR_LOCALHOST, false)
&& Domains.isLocalhost(hrequest.getRemoteAddr())) return true;
if (hrequest.isUserInRole(adminRole)) return true;
diff --git a/source/net/yacy/http/servlets/SolrSelectServlet.java b/source/net/yacy/http/servlets/SolrSelectServlet.java
index 5b29b9adc..fa4e54d65 100644
--- a/source/net/yacy/http/servlets/SolrSelectServlet.java
+++ b/source/net/yacy/http/servlets/SolrSelectServlet.java
@@ -49,7 +49,6 @@ import net.yacy.cora.federate.solr.responsewriter.SolrjResponseWriter;
import net.yacy.cora.federate.solr.responsewriter.YJsonResponseWriter;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.util.ConcurrentLog;
-import net.yacy.data.UserDB;
import net.yacy.search.Switchboard;
import net.yacy.search.SwitchboardConstants;
import net.yacy.search.query.AccessTracker;
@@ -130,7 +129,7 @@ public class SolrSelectServlet extends HttpServlet {
Switchboard sb = Switchboard.getSwitchboard();
// TODO: isUserInRole needs a login to jetty container (not done automatically on admin from localhost)
- boolean authenticated = hrequest.isUserInRole(UserDB.AccessRight.ADMIN_RIGHT.toString());
+ boolean authenticated = hrequest.isUserInRole(SwitchboardConstants.ADMIN_ACCOUNT_ROLE);
// count remote searches if this was part of a p2p search
if (mmsp.getMap().containsKey("partitions")) {
diff --git a/source/net/yacy/http/servlets/YaCyDefaultServlet.java b/source/net/yacy/http/servlets/YaCyDefaultServlet.java
index c52cb828c..54cb227a0 100644
--- a/source/net/yacy/http/servlets/YaCyDefaultServlet.java
+++ b/source/net/yacy/http/servlets/YaCyDefaultServlet.java
@@ -48,8 +48,7 @@ import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.UnavailableException;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
@@ -1072,13 +1071,7 @@ public class YaCyDefaultServlet extends HttpServlet {
}
}
}
- // handle login cookie
- if (tmpouthdr.getCookiesEntries() != null) {
- for (final Cookie c : tmpouthdr.getCookiesEntries()) {
- response.addCookie(c);
- }
- }
- }
+ }
} else {
templatePatterns = new servletProperties((serverObjects) tmp);
}
diff --git a/source/net/yacy/migration.java b/source/net/yacy/migration.java
index 7a6207003..fef897f33 100644
--- a/source/net/yacy/migration.java
+++ b/source/net/yacy/migration.java
@@ -206,35 +206,8 @@ public class migration {
ConcurrentLog.warn("MIGRATION", "could not delete "+ filename);
}
public static void migrateWorkFiles(final Switchboard sb){
- File file=new File(sb.getDataPath(), "DATA/SETTINGS/wiki.db");
+ File file;
File file2;
- if (file.exists()) {
- ConcurrentLog.info("MIGRATION", "Migrating wiki.db to "+ sb.workPath);
- sb.wikiDB.close();
- file2 = new File(sb.workPath, "wiki.db");
- try {
- Files.copy(file, file2);
- file.delete();
- } catch (final IOException e) {
- }
-
- file = new File(sb.getDataPath(), "DATA/SETTINGS/wiki-bkp.db");
- if (file.exists()) {
- ConcurrentLog.info("MIGRATION", "Migrating wiki-bkp.db to "+ sb.workPath);
- file2 = new File(sb.workPath, "wiki-bkp.db");
- try {
- Files.copy(file, file2);
- file.delete();
- } catch (final IOException e) {}
- }
- try {
- sb.initWiki();
- } catch (final IOException e) {
- ConcurrentLog.logException(e);
- }
- }
-
-
file=new File(sb.getDataPath(), "DATA/SETTINGS/message.db");
if(file.exists()){
ConcurrentLog.info("MIGRATION", "Migrating message.db to "+ sb.workPath);
diff --git a/source/net/yacy/peers/NewsPool.java b/source/net/yacy/peers/NewsPool.java
index 9fdfdb8cc..4eaa947ed 100644
--- a/source/net/yacy/peers/NewsPool.java
+++ b/source/net/yacy/peers/NewsPool.java
@@ -182,42 +182,6 @@ public class NewsPool {
*/
public static final String CATEGORY_SURFTIPP_VOTE_ADD = "stippavt";
- /* ------------------------------------------------------------------------
- * WIKI related CATEGORIES
- * ------------------------------------------------------------------------ */
- /**
- * a wiki page was updated
- */
- public static final String CATEGORY_WIKI_UPDATE = "wiki_upd";
- /**
- * a wiki page das deleted
- */
- private static final String CATEGORY_WIKI_DEL = "wiki_del";
-
- /* ------------------------------------------------------------------------
- * BLOG related CATEGORIES
- * ------------------------------------------------------------------------ */
- /**
- * a blog entry was added
- */
- public static final String CATEGORY_BLOG_ADD = "blog_add";
- /**
- * a blog page das deleted
- */
- private static final String CATEGORY_BLOG_DEL = "blog_del";
-
- /* ------------------------------------------------------------------------
- * TRANSLATION related CATEGORIES
- * ------------------------------------------------------------------------ */
- /**
- * a translation was added
- */
- public static final String CATEGORY_TRANSLATION_ADD = "transadd";
- /**
- * a vote on a translation
- */
- public static final String CATEGORY_TRANSLATION_VOTE_ADD = "transavt";
-
/* ========================================================================
* ARRAY of valid CATEGORIES
* ======================================================================== */
@@ -253,20 +217,8 @@ public class NewsPool {
CATEGORY_BOOKMARK_VOTE_DEL,
// SURFTIPP related CATEGORIES
- CATEGORY_SURFTIPP_ADD,
- CATEGORY_SURFTIPP_VOTE_ADD,
-
- // WIKI related CATEGORIE
- CATEGORY_WIKI_UPDATE,
- CATEGORY_WIKI_DEL,
-
- // BLOG related CATEGORIES
- CATEGORY_BLOG_ADD,
- CATEGORY_BLOG_DEL,
-
- // TRANSLATION related CATEGORIES
- CATEGORY_TRANSLATION_ADD,
- CATEGORY_TRANSLATION_VOTE_ADD
+ CATEGORY_SURFTIPP_ADD,
+ CATEGORY_SURFTIPP_VOTE_ADD
};
private static final Set<String> categories = new HashSet<String>();
static {
@@ -447,9 +399,7 @@ public class NewsPool {
String cat = record.category();
switch (cat) {
- case CATEGORY_WIKI_UPDATE:
- case CATEGORY_BLOG_ADD:
- case CATEGORY_PROFILE_UPDATE:
+ case CATEGORY_PROFILE_UPDATE:
if (duration > (3L * MILLISECONDS_PER_DAY)) {
return true;
}
@@ -465,12 +415,6 @@ public class NewsPool {
}
}
break;
- case CATEGORY_TRANSLATION_ADD:
- case CATEGORY_TRANSLATION_VOTE_ADD:
- if (duration > (7L * MILLISECONDS_PER_DAY)) {
- return true;
- }
- break;
default:
if (duration > MILLISECONDS_PER_DAY) {
// remove everything else after 1 day
diff --git a/source/net/yacy/search/SearchAccessRateConstants.java b/source/net/yacy/search/SearchAccessRateConstants.java
index 7b55a54dd..91e825bc6 100644
--- a/source/net/yacy/search/SearchAccessRateConstants.java
+++ b/source/net/yacy/search/SearchAccessRateConstants.java
@@ -31,88 +31,79 @@ public enum SearchAccessRateConstants {
/**
* Configuration for the maximum number of accesses within three seconds to the
- * search interface for unauthenticated users and authenticated users with no
- * extended search right
+ * search interface for unauthenticated users
*/
PUBLIC_MAX_ACCESS_3S("search.public.max.access.3s", 60),
/**
* Configuration for the maximum number of accesses within one minute to the
- * search interface for unauthenticated users and authenticated users with no
- * extended search right
+ * search interface for unauthenticated users
*/
PUBLIC_MAX_ACCESS_1MN("search.public.max.access.1mn", 600),
/**
* Configuration for the maximum number of accesses within ten minutes to the
- * search interface for unauthenticated users and authenticated users with no
- * extended search right
+ * search interface for unauthenticated users
*/
PUBLIC_MAX_ACCESS_10MN("search.public.max.access.10mn", 3000),
/**
* Configuration for the maximum number of accesses within three seconds to the
- * search interface in P2P mode for unauthenticated users and authenticated
- * users with no extended search right
+ * search interface in P2P mode for unauthenticated users
*/
PUBLIC_MAX_P2P_ACCESS_3S("search.public.max.p2p.access.3s", 1),
/**
* Configuration for the maximum number of accesses within one minute to the
- * search interface in P2P mode for unauthenticated users and authenticated
- * users with no extended search right
+ * search interface in P2P mode for unauthenticated users
*/
PUBLIC_MAX_P2P_ACCESS_1MN("search.public.max.p2p.access.1mn", 6),
/**
* Configuration for the maximum number of accesses within ten minutes to the
- * search interface in P2P mode for unauthenticated users and authenticated
- * users with no extended search right
+ * search interface in P2P mode for unauthenticated users
*/
PUBLIC_MAX_P2P_ACCESS_10MN("search.public.max.p2p.access.10mn", 60),
/**
* Configuration for the maximum number of accesses within three seconds to the
* search interface in P2P mode with browser-side JavaScript results resorting
- * enabled for unauthenticated users and authenticated users with no extended
- * search right
+ * enabled for unauthenticated users
*/
PUBLIC_MAX_P2P_JSRESORT_ACCESS_3S("search.public.max.p2p.jsresort.access.3s", 1),
/**
* Configuration for the maximum number of accesses within one minute to the
* search interface in P2P mode with browser-side JavaScript results resorting
- * enabled for unauthenticated users and authenticated users with no extended
- * search right
+ * enabled for unauthenticated users
*/
PUBLIC_MAX_P2P_JSRESORT_ACCESS_1MN("search.public.max.p2p.jsresort.access.1mn", 1),
/**
* Configuration for the maximum number of accesses within ten minutes to the
* search interface in P2P mode with browser-side JavaScript results resorting
- * enabled for unauthenticated users and authenticated users with no extended
- * search right
+ * enabled for unauthenticated users
*/
PUBLIC_MAX_P2P_JSRESORT_ACCESS_10MN("search.public.max.p2p.jsresort.access.10mn", 10),
/**
* Configuration for the maximum number of accesses within three seconds to the
* search interface to support fetching remote results snippets for
- * unauthenticated users and authenticated users with no extended search right
+ * unauthenticated users
*/
PUBLIC_MAX_REMOTE_SNIPPET_ACCESS_3S("search.public.max.remoteSnippet.access.3s", 1),
/**
* Configuration for the maximum number of accesses within one minute to the
* search interface to support fetching remote results snippets for
- * unauthenticated users and authenticated users with no extended search right
+ * unauthenticated users
*/
PUBLIC_MAX_REMOTE_SNIPPET_ACCESS_1MN("search.public.max.remoteSnippet.access.1mn", 4),
/**
* Configuration for the maximum number of accesses within ten minutes to the
* search interface to support fetching remote results snippets mode for
- * unauthenticated users and authenticated users with no extended search right
+ * unauthenticated users
*/
PUBLIC_MAX_REMOTE_SNIPPET_ACCESS_10MN("search.public.max.remoteSnippet.access.10mn", 20);
diff --git a/source/net/yacy/search/Switchboard.java b/source/net/yacy/search/Switchboard.java
index fb19d2a99..13fee0653 100644
--- a/source/net/yacy/search/Switchboard.java
+++ b/source/net/yacy/search/Switchboard.java
@@ -151,16 +151,11 @@ import net.yacy.crawler.data.ResultURLs.EventOrigin;
import net.yacy.crawler.retrieval.Request;
import net.yacy.crawler.retrieval.Response;
import net.yacy.crawler.robots.RobotsTxt;
-import net.yacy.data.BlogBoard;
-import net.yacy.data.BlogBoardComments;
import net.yacy.data.BookmarkHelper;
import net.yacy.data.BookmarksDB;
import net.yacy.data.ListManager;
import net.yacy.data.MessageBoard;
-import net.yacy.data.UserDB;
-import net.yacy.data.UserDB.AccessRight;
import net.yacy.data.WorkTables;
-import net.yacy.data.wiki.WikiBoard;
import net.yacy.data.wiki.WikiCode;
import net.yacy.data.wiki.WikiParser;
import net.yacy.document.Condenser;
@@ -278,15 +273,11 @@ public final class Switchboard extends serverSwitch {
public CrawlQueues crawlQueues;
public CrawlStacker crawlStacker;
public MessageBoard messageDB;
- public WikiBoard wikiDB;
- public BlogBoard blogDB;
- public BlogBoardComments blogCommentDB;
public RobotsTxt robots;
public Map<String, Object[]> outgoingCookies, incomingCookies;
public volatile long proxyLastAccess, localSearchLastAccess, remoteSearchLastAccess, adminAuthenticationLastAccess, optimizeLastRun;
public Network yc;
public ResourceObserver observer;
- public UserDB userDB;
public BookmarksDB bookmarksDB;
public WebStructureGraph webStructure;
public ConcurrentHashMap<String, TreeSet<Long>> localSearchTracker, remoteSearchTracker; // mappings from requesting host to a TreeSet of Long(access time)
@@ -830,36 +821,6 @@ public final class Switchboard extends serverSwitch {
ConcurrentLog.logException(e);
}
- // starting wiki
- try {
- this.initWiki();
- } catch (final IOException e) {
- ConcurrentLog.logException(e);
- }
-
- //starting blog
- try {
- this.initBlog();
- } catch (final IOException e) {
- ConcurrentLog.logException(e);
- }
-
- // init User DB
- this.log.config("Loading User DB");
- final File userDbFile = new File(this.getDataPath(), "DATA/SETTINGS/user.heap");
- try {
- this.userDB = new UserDB(userDbFile);
- this.log.config("Loaded User DB from file "
- + userDbFile.getName()
- + ", "
- + this.userDB.size()
- + " entries"
- + ", "
- + ppRamString(userDbFile.length() / 1024));
- } catch (final IOException e) {
- ConcurrentLog.logException(e);
- }
-
// init html parser evaluation scheme
File parserPropertiesPath = new File(appPath, "defaults/");
String[] settingsList = parserPropertiesPath.list();
@@ -996,7 +957,7 @@ public final class Switchboard extends serverSwitch {
TextSnippet.statistics.setEnabled(this.getConfigBool(SwitchboardConstants.DEBUG_SNIPPETS_STATISTICS_ENABLED,
SwitchboardConstants.DEBUG_SNIPPETS_STATISTICS_ENABLED_DEFAULT));
- // init the wiki
+ // Initialize the reusable WikiCode formatter used outside the retired local Wiki application.
wikiParser = new WikiCode();
// initializing the resourceObserver
@@ -1724,42 +1685,6 @@ public final class Switchboard extends serverSwitch {
+ ppRamString(messageDbFile.length() / 1024));
}
- public void initWiki() throws IOException {
- this.log.config("Starting Wiki Board");
- final File wikiDbFile = new File(this.workPath, "wiki.heap");
- this.wikiDB = new WikiBoard(wikiDbFile, new File(this.workPath, "wiki-bkp.heap"));
- this.log.config("Loaded Wiki Board DB from file "
- + wikiDbFile.getName()
- + ", "
- + this.wikiDB.size()
- + " entries"
- + ", "
- + ppRamString(wikiDbFile.length() / 1024));
- }
-
- public void initBlog() throws IOException {
- this.log.config("Starting Blog");
- final File blogDbFile = new File(this.workPath, "blog.heap");
- this.blogDB = new BlogBoard(blogDbFile);
- this.log.config("Loaded Blog DB from file "
- + blogDbFile.getName()
- + ", "
- + this.blogDB.size()
- + " entries"
- + ", "
- + ppRamString(blogDbFile.length() / 1024));
-
- final File blogCommentDbFile = new File(this.workPath, "blogComment.heap");
- this.blogCommentDB = new BlogBoardComments(blogCommentDbFile);
- this.log.config("Loaded Blog-Comment DB from file "
- + blogCommentDbFile.getName()
- + ", "
- + this.blogCommentDB.size()
- + " entries"
- + ", "
- + ppRamString(blogCommentDbFile.length() / 1024));
- }
-
public void initBookmarks() throws IOException {
this.log.config("Loading Bookmarks DB");
final File bookmarksFile = new File(this.workPath, "bookmarks.heap");
@@ -2014,10 +1939,6 @@ public final class Switchboard extends serverSwitch {
this.dhtDispatcher.close();
}
// de.anomic.http.client.Client.closeAllConnections();
- this.wikiDB.close();
- this.blogDB.close();
- this.blogCommentDB.close();
- this.userDB.close();
if ( this.bookmarksDB != null ) {
this.bookmarksDB.close(); // may null if concurrent initialization was not finished
}
@@ -3978,7 +3899,7 @@ public final class Switchboard extends serverSwitch {
// authorization (earlier) by servlet container with username/password
// as this stays true as long as authenticated browser is open (even after restart of YaCy) add a timeout check to look at credentials again
// TODO: same is true for credential checks below (at least with BASIC auth -> login should expire at least on restart
- if (requestHeader.isUserInRole(UserDB.AccessRight.ADMIN_RIGHT.toString())) {
+ if (requestHeader.isUserInRole(SwitchboardConstants.ADMIN_ACCOUNT_ROLE)) {
if (this.adminAuthenticationLastAccess + 60000 > System.currentTimeMillis()) // 1 minute
return 4; // hard-authenticated, quick return
}
@@ -4007,11 +3928,8 @@ public final class Switchboard extends serverSwitch {
} else {
// handle DIGEST auth by servlet container
if (requestHeader.getUserPrincipal() != null) { // user is authenticated (by Servlet container)
- if (requestHeader.isUserInRole(AccessRight.ADMIN_RIGHT.toString())) {
+ if (requestHeader.isUserInRole(SwitchboardConstants.ADMIN_ACCOUNT_ROLE)) {
// we could double check admin right (but we trust embedded container)
- // String username = requestHeader.getUserPrincipal().getName();
- // if ((username.equalsIgnoreCase(sb.getConfig(SwitchboardConstants.ADMIN_ACCOUNT_USER_NAME, "admin")))
- // || (sb.userDB.getEntry(username).hasRight(AccessRight.ADMIN_RIGHT)))
this.adminAuthenticationLastAccess = System.currentTimeMillis();
return 4; // has admin right
}
@@ -4027,12 +3945,6 @@ public final class Switchboard extends serverSwitch {
return 3; // soft-authenticated for localhost
}
- // authorization by hit in userDB (authtype username:encodedpassword - handed over by DefaultServlet)
- if ( this.userDB.hasAdminRight(requestHeader, requestHeader.getCookies()) ) {
- this.adminAuthenticationLastAccess = System.currentTimeMillis();
- return 4; //return, because 4=max
- }
-
// athorization by BASIC auth (realmValue = "adminname:password")
if (adminAccountBase64MD5.startsWith("MD5:")) {
// handle new option adminAccountBase64MD5="MD5:xxxxxxx" = encodeMD5Hex ("adminname:peername:password")
diff --git a/source/net/yacy/search/SwitchboardConstants.java b/source/net/yacy/search/SwitchboardConstants.java
index c846d88ec..8692c2759 100644
--- a/source/net/yacy/search/SwitchboardConstants.java
+++ b/source/net/yacy/search/SwitchboardConstants.java
@@ -56,6 +56,8 @@ public final class SwitchboardConstants {
public static final String ADMIN_ACCOUNT_FOR_LOCALHOST = "adminAccountForLocalhost";
public static final String ADMIN_ACCOUNT_All_PAGES = "adminAccountAllPages";
public static final String ADMIN_REALM = "adminRealm";
+ /** Servlet-container role assigned exclusively to the built-in administrator account. */
+ public static final String ADMIN_ACCOUNT_ROLE = "adminRight";
// server settings
public static final String SERVER_PORT = "port"; // port for the http server
@@ -488,7 +490,7 @@ public final class SwitchboardConstants {
/**
* <p><code>public static final String <strong>WORK_PATH</strong> = "wordPath"</code></p>
* <p>Name of the setting specifying the folder beginning from the YaCy-installation's top-folder, where all
- * DBs containing "work" of the user are saved. Such include bookmarks, messages, wiki, blog</p>
+ * DBs containing "work" of the user are saved. Such include bookmarks and messages.</p>
*
*/
public static final String WORK_PATH = "workPath";
diff --git a/source/net/yacy/server/http/HTTPDemon.java b/source/net/yacy/server/http/HTTPDemon.java
index 72631100a..c9d6e4738 100644
--- a/source/net/yacy/server/http/HTTPDemon.java
+++ b/source/net/yacy/server/http/HTTPDemon.java
@@ -34,8 +34,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map.Entry;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequest;
import net.yacy.cora.document.encoding.UTF8;
import net.yacy.cora.document.id.DigestURL;
import net.yacy.cora.protocol.HeaderFramework;
@@ -262,15 +261,7 @@ public final class HTTPDemon {
!responseHeader.containsKey(HeaderFramework.CONTENT_LENGTH))
responseHeader.put(HeaderFramework.CONTENT_LENGTH, "0");
- //read custom headers
- if (responseHeader.getCookiesEntries() != null) {
- for (Cookie c : responseHeader.getCookiesEntries()) {
- //Append user properties to the main String
- //TODO: Should we check for user properites. What if they intersect properties that are already in header?
- header.append(HeaderFramework.SET_COOKIE+": "+c.getName()).append("=").append(c.getValue()).append(";\r\n");
- }
- }
- // write header
+ // write header
final Iterator<String> i = responseHeader.keySet().iterator();
String key;
char tag;
diff --git a/source/net/yacy/server/http/RobotsTxtConfig.java b/source/net/yacy/server/http/RobotsTxtConfig.java
index e2958b3f1..214ea5d0e 100644
--- a/source/net/yacy/server/http/RobotsTxtConfig.java
+++ b/source/net/yacy/server/http/RobotsTxtConfig.java
@@ -34,8 +34,6 @@ import net.yacy.server.serverSwitch;
public final class RobotsTxtConfig {
- public static final String WIKI = "wiki";
- public static final String BLOG = "blog";
public static final String BOOKMARKS = "bookmarks";
public static final String HOMEPAGE = "homepage";
public static final String FILESHARE = "fileshare";
@@ -51,8 +49,6 @@ public final class RobotsTxtConfig {
private boolean allDisallowed = false;
private boolean lockedDisallowed = true;
private boolean dirsDisallowed = true;
- private boolean wikiDisallowed = false;
- private boolean blogDisallowed = false;
private boolean fileshareDisallowed = false;
private boolean homepageDisallowed = false;
private boolean newsDisallowed = false;
@@ -68,8 +64,6 @@ public final class RobotsTxtConfig {
if (active == null) return;
for (int i=0; i<active.length; i++) {
if (active[i] == null) continue;
- if (active[i].equals(BLOG)) { this.blogDisallowed = true; continue; }
- if (active[i].equals(WIKI)) { this.wikiDisallowed = true; continue; }
if (active[i].equals(BOOKMARKS)) { this.bookmarksDisallowed = true; continue; }
if (active[i].equals(HOMEPAGE)) { this.homepageDisallowed = true; continue; }
if (active[i].equals(FILESHARE)) { this.fileshareDisallowed = true; continue; }
@@ -94,7 +88,6 @@ public final class RobotsTxtConfig {
public String toString() {
if (this.allDisallowed) return ALL;
final StringBuilder sb = new StringBuilder(200);
- if (this.blogDisallowed) sb.append(BLOG).append(",");
if (this.bookmarksDisallowed) sb.append(BOOKMARKS).append(",");
if (this.dirsDisallowed) sb.append(DIRS).append(",");
if (this.fileshareDisallowed) sb.append(FILESHARE).append(",");
@@ -104,7 +97,6 @@ public final class RobotsTxtConfig {
if (this.newsDisallowed) sb.append(NEWS).append(",");
if (this.statusDisallowed) sb.append(STATUS).append(",");
if (this.surftipsDisallowed) sb.append(SURFTIPS).append(",");
- if (this.wikiDisallowed) sb.append(WIKI).append(",");
if (this.profileDisallowed) sb.append(PROFILE).append(",");
return sb.toString();
}
@@ -133,14 +125,6 @@ public final class RobotsTxtConfig {
this.dirsDisallowed = dirsDisallowed;
}
- public boolean isBlogDisallowed() {
- return blogDisallowed || this.allDisallowed;
- }
-
- public void setBlogDisallowed(final boolean blogDisallowed) {
- this.blogDisallowed = blogDisallowed;
- }
-
public boolean isBookmarksDisallowed() {
return bookmarksDisallowed || this.allDisallowed;
}
@@ -197,14 +181,6 @@ public final class RobotsTxtConfig {
this.surftipsDisallowed = surftipsDisallowed;
}
- public boolean isWikiDisallowed() {
- return wikiDisallowed || this.allDisallowed;
- }
-
- public void setWikiDisallowed(final boolean wikiDisallowed) {
- this.wikiDisallowed = wikiDisallowed;
- }
-
public boolean isProfileDisallowed() {
return profileDisallowed || this.allDisallowed;
}
diff --git a/source/net/yacy/server/serverObjects.java b/source/net/yacy/server/serverObjects.java
index 5c48a82f8..26505f96a 100644
--- a/source/net/yacy/server/serverObjects.java
+++ b/source/net/yacy/server/serverObjects.java
@@ -362,7 +362,7 @@ public class serverObjects implements Serializable, Cloneable {
/**
* Add a String to the map. The content of the String is first parsed and interpreted as Wiki code.
- * @param hostport (optional) peer host and port, added when not empty as the base of relative Wiki link URLs.
+ * @param hostport (optional) peer host and port, added when not empty as the base of relative media URLs.
* @param key key name as String.
* @param wikiCode wiki code content as String.
*/
@@ -381,7 +381,7 @@ public class serverObjects implements Serializable, Cloneable {
/**
* Add a byte array to the map. The content of the array is first parsed and interpreted as Wiki code.
- * @param hostport (optional) peer host and port, added when not empty as the base of relative Wiki link URLs.
+ * @param hostport (optional) peer host and port, added when not empty as the base of relative media URLs.
* @param key key name as String.
* @param wikiCode wiki code content as byte array.
*/
diff --git a/source/net/yacy/visualization/ImageViewer.java b/source/net/yacy/visualization/ImageViewer.java
index b73c26465..3c7e3cbc4 100644
--- a/source/net/yacy/visualization/ImageViewer.java
+++ b/source/net/yacy/visualization/ImageViewer.java
@@ -47,7 +47,6 @@ import net.yacy.cora.util.ConcurrentLog;
import net.yacy.crawler.retrieval.StreamResponse;
import net.yacy.data.InvalidURLLicenceException;
import net.yacy.data.URLLicense;
-import net.yacy.data.UserDB;
import net.yacy.http.servlets.TemplateMissingParameterException;
import net.yacy.peers.graphics.EncodedImage;
import net.yacy.repository.Blacklist.BlacklistType;
@@ -148,19 +147,8 @@ public class ImageViewer {
* @return true when full image view is allowed for this request
*/
public static boolean hasFullViewingRights(final RequestHeader header, final Switchboard sb) {
- boolean extendedSearchRights = false;
- if(sb != null && header != null) {
- final boolean adminAuthenticated = sb.verifyAuthentication(header);
- if (adminAuthenticated) {
- extendedSearchRights = true;
- } else {
- final UserDB.Entry user = sb.userDB != null ? sb.userDB.getUser(header) : null;
- if (user != null) {
- extendedSearchRights = user.hasRight(UserDB.AccessRight.EXTENDED_SEARCH_RIGHT);
- }
- }
- }
- return header != null && (extendedSearchRights || Domains.isLocalhost(header.getRemoteAddr()));
+ return header != null && ((sb != null && sb.verifyAuthentication(header))
+ || Domains.isLocalhost(header.getRemoteAddr()));
}
/**