diff --git a/bin/passwd.sh b/bin/passwd.sh new file mode 100755 index 000000000..f2b61bc60 --- /dev/null +++ b/bin/passwd.sh @@ -0,0 +1,4 @@ +#!/bin/bash +cd "`dirname $0`" +./apicall.sh "/ConfigAccounts_p.html?setAdmin=&adminuser=admin&adminpw1=$1&adminpw2=$1&access=" > /dev/null +echo "Password for User Name 'admin' set to '$1'" \ No newline at end of file diff --git a/htroot/Blog.java b/htroot/Blog.java index b5570e20f..a15c93350 100644 --- a/htroot/Blog.java +++ b/htroot/Blog.java @@ -95,7 +95,7 @@ public class Blog { hasRights=true; } else if (post.containsKey("login")) { //opens login window if login link is clicked - prop.put("AUTHENTICATE","admin log-in"); + prop.authenticationRequired(); } } diff --git a/htroot/BlogComments.java b/htroot/BlogComments.java index 53fe6eb6e..048e066e5 100644 --- a/htroot/BlogComments.java +++ b/htroot/BlogComments.java @@ -76,7 +76,7 @@ public class BlogComments { hasRights = true; } else if (post.containsKey("login")) { //opens login window if login link is clicked - prop.put("AUTHENTICATE","admin log-in"); + prop.authenticationRequired(); } } diff --git a/htroot/Bookmarks.java b/htroot/Bookmarks.java index 5a8fd21ef..43ed0ec1a 100644 --- a/htroot/Bookmarks.java +++ b/htroot/Bookmarks.java @@ -126,7 +126,7 @@ public class Bookmarks { if (post != null) { if (!isAdmin) { if(post.containsKey("login")){ - prop.put("AUTHENTICATE","admin log-in"); + prop.authenticationRequired(); } } else if (post.containsKey("mode")) { final String mode=post.get("mode"); diff --git a/htroot/ConfigBasic.java b/htroot/ConfigBasic.java index 791d42584..c2af82208 100644 --- a/htroot/ConfigBasic.java +++ b/htroot/ConfigBasic.java @@ -67,7 +67,7 @@ public class ConfigBasic { final int authentication = sb.adminAuthenticated(header); if (authentication < 2) { // must authenticate - prop.put("AUTHENTICATE", "admin log-in"); + prop.authenticationRequired(); return prop; } diff --git a/htroot/ConfigParser.java b/htroot/ConfigParser.java index 1ac18f6f8..8ff2db54e 100644 --- a/htroot/ConfigParser.java +++ b/htroot/ConfigParser.java @@ -45,7 +45,7 @@ public class ConfigParser { if (post != null) { if (!sb.verifyAuthentication(header)) { // force log-in - prop.put("AUTHENTICATE", "admin log-in"); + prop.authenticationRequired(); return prop; } diff --git a/htroot/ConfigPortal.java b/htroot/ConfigPortal.java index 285ebc4fb..c6b82a3b0 100644 --- a/htroot/ConfigPortal.java +++ b/htroot/ConfigPortal.java @@ -44,7 +44,7 @@ public class ConfigPortal { // AUTHENTICATE if (!sb.verifyAuthentication(header)) { // force log-in - prop.putHTML("AUTHENTICATE","log-in"); + prop.authenticationRequired(); return prop; } diff --git a/htroot/CrawlResults.java b/htroot/CrawlResults.java index e2edb10c0..39c901113 100644 --- a/htroot/CrawlResults.java +++ b/htroot/CrawlResults.java @@ -94,12 +94,12 @@ public class CrawlResults { if (authorization.length() != 0) { if (! sb.verifyAuthentication(header)){ // force log-in (again, because wrong password was given) - prop.put("AUTHENTICATE", "admin log-in"); + prop.authenticationRequired(); return prop; } } else { // force log-in - prop.put("AUTHENTICATE", "admin log-in"); + prop.authenticationRequired(); return prop; } } diff --git a/htroot/Network.java b/htroot/Network.java index 54655caf1..9943c3889 100644 --- a/htroot/Network.java +++ b/htroot/Network.java @@ -190,7 +190,7 @@ public class Network { // AUTHENTICATE if (!requestHeader.containsKey(RequestHeader.AUTHORIZATION)) { - prop.putHTML("AUTHENTICATE","log-in"); + prop.authenticationRequired(); return prop; } diff --git a/htroot/News.java b/htroot/News.java index e51c2f000..1f6e986d3 100644 --- a/htroot/News.java +++ b/htroot/News.java @@ -52,7 +52,7 @@ public class News { if ((post.containsKey("deletespecific")) && (tableID >= 0)) { if (sb.adminAuthenticated(header) < 2) { - prop.put("AUTHENTICATE", "admin log-in"); + prop.authenticationRequired(); return prop; // this button needs authentication, force log-in } final Iterator e = post.keySet().iterator(); @@ -71,7 +71,7 @@ public class News { if ((post.containsKey("deleteall")) && (tableID >= 0)) { if (sb.adminAuthenticated(header) < 2) { - prop.put("AUTHENTICATE", "admin log-in"); + prop.authenticationRequired(); return prop; // this button needs authentication, force log-in } try { diff --git a/htroot/Status.java b/htroot/Status.java index bdea6a9cd..0f599d57a 100644 --- a/htroot/Status.java +++ b/htroot/Status.java @@ -74,7 +74,7 @@ public class Status if ( post != null && post.size() > 0 ) { if ( sb.adminAuthenticated(header) < 2 ) { - prop.put("AUTHENTICATE", "admin log-in"); + prop.authenticationRequired(); return prop; } boolean redirect = false; diff --git a/htroot/Steering.java b/htroot/Steering.java index 6e451dbcb..2424d2e1e 100644 --- a/htroot/Steering.java +++ b/htroot/Steering.java @@ -51,7 +51,7 @@ public class Steering { // handle access rights if (!sb.verifyAuthentication(header)) { Log.logInfo("STEERING", "log-in attempt for steering from " + requestIP); - prop.put("AUTHENTICATE", "admin log-in"); // force log-in + prop.authenticationRequired(); return prop; } diff --git a/htroot/Supporter.java b/htroot/Supporter.java index 2abcabb14..767bdadcc 100644 --- a/htroot/Supporter.java +++ b/htroot/Supporter.java @@ -72,7 +72,7 @@ public class Supporter { String hash; if ((post != null) && ((hash = post.get("voteNegative", null)) != null)) { if (!sb.verifyAuthentication(header)) { - prop.put("AUTHENTICATE", "admin log-in"); // force log-in + prop.authenticationRequired(); return prop; } // make new news message with voting @@ -86,7 +86,7 @@ public class Supporter { } if ((post != null) && ((hash = post.get("votePositive", null)) != null)) { if (!sb.verifyAuthentication(header)) { - prop.put("AUTHENTICATE", "admin log-in"); // force log-in + prop.authenticationRequired(); return prop; } // make new news message with voting diff --git a/htroot/Surftips.java b/htroot/Surftips.java index fedae9b06..682f66ee4 100644 --- a/htroot/Surftips.java +++ b/htroot/Surftips.java @@ -66,7 +66,7 @@ public class Surftips { final boolean authorizedAccess = sb.verifyAuthentication(header); if ((post != null) && (post.containsKey("publicPage"))) { if (!authorizedAccess) { - prop.put("AUTHENTICATE", "admin log-in"); // force log-in + prop.authenticationRequired(); return prop; } publicPage = post.get("publicPage", "0").equals("1"); @@ -79,7 +79,7 @@ public class Surftips { String hash; if ((post != null) && ((hash = post.get("voteNegative", null)) != null)) { if (!sb.verifyAuthentication(header)) { - prop.put("AUTHENTICATE", "admin log-in"); // force log-in + prop.authenticationRequired(); return prop; } // make new news message with voting @@ -93,7 +93,7 @@ public class Surftips { } if ((post != null) && ((hash = post.get("votePositive", null)) != null)) { if (!sb.verifyAuthentication(header)) { - prop.put("AUTHENTICATE", "admin log-in"); // force log-in + prop.authenticationRequired(); return prop; } // make new news message with voting diff --git a/htroot/User.java b/htroot/User.java index 2c4c5960f..69e478a7a 100644 --- a/htroot/User.java +++ b/htroot/User.java @@ -157,7 +157,7 @@ public class User{ } //XXX: This should not be needed anymore, because of isLoggedout if(! (requestHeader.get(RequestHeader.AUTHORIZATION, "xxxxxx")).equals("xxxxxx")){ - prop.put("AUTHENTICATE","admin log-in"); + prop.authenticationRequired(); } if(post.containsKey("returnto")){ prop.put("LOCATION", post.get("returnto")); diff --git a/htroot/ViewFile.java b/htroot/ViewFile.java index a77431a47..eef8fcac3 100644 --- a/htroot/ViewFile.java +++ b/htroot/ViewFile.java @@ -139,7 +139,7 @@ public class ViewFile { // it is therefore protected by the admin password if (!sb.verifyAuthentication(header)) { - prop.put("AUTHENTICATE", "admin log-in"); // force log-in + prop.authenticationRequired(); return prop; } diff --git a/htroot/Wiki.java b/htroot/Wiki.java index ef189bcdd..a0e949bdd 100644 --- a/htroot/Wiki.java +++ b/htroot/Wiki.java @@ -86,7 +86,7 @@ public class Wiki { // only the administrator may change the access right if (!sb.verifyAuthentication(header)) { // check access right for admin - prop.put("AUTHENTICATE", "admin log-in"); // force log-in + prop.authenticationRequired(); return prop; } @@ -105,7 +105,7 @@ public class Wiki { if ((access.equals("admin") && (!sb.verifyAuthentication(header)))) { // check access right for admin - prop.put("AUTHENTICATE", "admin log-in"); // force log-in + prop.authenticationRequired(); return prop; } @@ -129,7 +129,7 @@ public class Wiki { if (post != null && post.containsKey("edit")) { if ((access.equals("admin") && (!sb.verifyAuthentication(header)))) { // check access right for admin - prop.put("AUTHENTICATE", "admin log-in"); // force log-in + prop.authenticationRequired(); return prop; } diff --git a/htroot/api/bookmarks/posts/add_p.java b/htroot/api/bookmarks/posts/add_p.java index 918a5412b..8cd8025ea 100644 --- a/htroot/api/bookmarks/posts/add_p.java +++ b/htroot/api/bookmarks/posts/add_p.java @@ -36,7 +36,7 @@ public class add_p { if (!isAdmin) { // force authentication if desired if(post.containsKey("login")){ - prop.put("AUTHENTICATE","admin log-in"); + prop.authenticationRequired(); } return prop; } diff --git a/htroot/api/bookmarks/posts/delete_p.java b/htroot/api/bookmarks/posts/delete_p.java index 1e838e477..e081ec440 100644 --- a/htroot/api/bookmarks/posts/delete_p.java +++ b/htroot/api/bookmarks/posts/delete_p.java @@ -18,7 +18,7 @@ public class delete_p { if(!isAdmin){ // force authentication if desired if(post.containsKey("login")){ - prop.put("AUTHENTICATE","admin log-in"); + prop.authenticationRequired(); } return prop; } diff --git a/htroot/api/bookmarks/tags/getTag.java b/htroot/api/bookmarks/tags/getTag.java index 3135e32f0..4515c253a 100644 --- a/htroot/api/bookmarks/tags/getTag.java +++ b/htroot/api/bookmarks/tags/getTag.java @@ -27,7 +27,7 @@ public class getTag { if (!isAdmin) { // force authentication if desired if(post.containsKey("login")){ - prop.put("AUTHENTICATE","admin log-in"); + prop.authenticationRequired(); } } diff --git a/htroot/api/bookmarks/xbel/xbel.java b/htroot/api/bookmarks/xbel/xbel.java index 8c682542c..1551504b9 100644 --- a/htroot/api/bookmarks/xbel/xbel.java +++ b/htroot/api/bookmarks/xbel/xbel.java @@ -32,7 +32,7 @@ public class xbel { if(post != null) { if(!isAdmin) { if(post.containsKey("login")) { - prop.put("AUTHENTICATE","admin log-in"); + prop.authenticationRequired(); } } if(post.containsKey("tag")) { diff --git a/htroot/api/ymarks/add_ymark.java b/htroot/api/ymarks/add_ymark.java index c34520514..31cf093d3 100644 --- a/htroot/api/ymarks/add_ymark.java +++ b/htroot/api/ymarks/add_ymark.java @@ -85,7 +85,7 @@ public class add_ymark { prop.put("status", "0"); } } else { - prop.put(YMarkTables.USER_AUTHENTICATE,YMarkTables.USER_AUTHENTICATE_MSG); + prop.put(serverObjects.ACTION_AUTHENTICATE, YMarkTables.USER_AUTHENTICATE_MSG); } // return rewrite properties return prop; diff --git a/htroot/api/ymarks/delete_ymark.java b/htroot/api/ymarks/delete_ymark.java index e93a6160f..6dde75bac 100644 --- a/htroot/api/ymarks/delete_ymark.java +++ b/htroot/api/ymarks/delete_ymark.java @@ -44,7 +44,7 @@ public class delete_ymark { Log.logException(e); } } else { - prop.put(YMarkTables.USER_AUTHENTICATE,YMarkTables.USER_AUTHENTICATE_MSG); + prop.put(serverObjects.ACTION_AUTHENTICATE, YMarkTables.USER_AUTHENTICATE_MSG); } // return rewrite properties return prop; diff --git a/htroot/api/ymarks/get_metadata.java b/htroot/api/ymarks/get_metadata.java index dd0a0aa0e..f8641e480 100644 --- a/htroot/api/ymarks/get_metadata.java +++ b/htroot/api/ymarks/get_metadata.java @@ -84,7 +84,7 @@ public class get_metadata { prop.put("status", "error"); } } else { - prop.put(YMarkTables.USER_AUTHENTICATE,YMarkTables.USER_AUTHENTICATE_MSG); + prop.put(serverObjects.ACTION_AUTHENTICATE, YMarkTables.USER_AUTHENTICATE_MSG); } // return rewrite properties return prop; diff --git a/htroot/api/ymarks/get_treeview.java b/htroot/api/ymarks/get_treeview.java index 45baa9065..f7dd8e134 100644 --- a/htroot/api/ymarks/get_treeview.java +++ b/htroot/api/ymarks/get_treeview.java @@ -256,7 +256,7 @@ public class get_treeview { } } } else { - prop.put(YMarkTables.USER_AUTHENTICATE,YMarkTables.USER_AUTHENTICATE_MSG); + prop.put(serverObjects.ACTION_AUTHENTICATE, YMarkTables.USER_AUTHENTICATE_MSG); } // return rewrite properties return prop; diff --git a/htroot/api/ymarks/get_xbel.java b/htroot/api/ymarks/get_xbel.java index 35d7ef4c4..79de80b34 100644 --- a/htroot/api/ymarks/get_xbel.java +++ b/htroot/api/ymarks/get_xbel.java @@ -175,7 +175,7 @@ public class get_xbel { prop.put("xbel", count); } else { - prop.put(YMarkTables.USER_AUTHENTICATE,YMarkTables.USER_AUTHENTICATE_MSG); + prop.put(serverObjects.ACTION_AUTHENTICATE, YMarkTables.USER_AUTHENTICATE_MSG); } // return rewrite properties return prop; diff --git a/htroot/api/ymarks/get_ymark.java b/htroot/api/ymarks/get_ymark.java index 1fda4ae1b..acc8acc09 100644 --- a/htroot/api/ymarks/get_ymark.java +++ b/htroot/api/ymarks/get_ymark.java @@ -91,7 +91,7 @@ public class get_ymark { putProp(bookmarks, rp, page); } else { - prop.put(YMarkTables.USER_AUTHENTICATE,YMarkTables.USER_AUTHENTICATE_MSG); + prop.put(serverObjects.ACTION_AUTHENTICATE, YMarkTables.USER_AUTHENTICATE_MSG); } // return rewrite properties return prop; diff --git a/htroot/api/ymarks/import_ymark.java b/htroot/api/ymarks/import_ymark.java index 40a647483..85d9018a3 100644 --- a/htroot/api/ymarks/import_ymark.java +++ b/htroot/api/ymarks/import_ymark.java @@ -151,7 +151,7 @@ public class import_ymark { } } else if(post.containsKey("importer") && post.get("importer").equals("crawls")) { if(!isAdmin) { - prop.put(YMarkTables.USER_AUTHENTICATE,YMarkTables.ADMIN_AUTHENTICATE_MSG); + prop.authenticationRequired(); return prop; } try { @@ -178,7 +178,7 @@ public class import_ymark { } } else if(post.containsKey("importer") && post.get("importer").equals("bmks")) { if(!isAdmin) { - prop.put(YMarkTables.USER_AUTHENTICATE,YMarkTables.ADMIN_AUTHENTICATE_MSG); + prop.authenticationRequired(); return prop; } final Iterator bit=sb.bookmarksDB.getBookmarksIterator(isAdmin); @@ -221,7 +221,7 @@ public class import_ymark { } } } else { - prop.put(YMarkTables.USER_AUTHENTICATE,YMarkTables.USER_AUTHENTICATE_MSG); + prop.put(serverObjects.ACTION_AUTHENTICATE, YMarkTables.USER_AUTHENTICATE_MSG); } // return rewrite properties return prop; diff --git a/htroot/api/ymarks/manage_tags.java b/htroot/api/ymarks/manage_tags.java index 582f4ae06..d7f98596b 100644 --- a/htroot/api/ymarks/manage_tags.java +++ b/htroot/api/ymarks/manage_tags.java @@ -80,7 +80,7 @@ public class manage_tags { Log.logException(e); } } else { - prop.put(YMarkTables.USER_AUTHENTICATE,YMarkTables.USER_AUTHENTICATE_MSG); + prop.put(serverObjects.ACTION_AUTHENTICATE, YMarkTables.USER_AUTHENTICATE_MSG); } // return rewrite properties return prop; diff --git a/htroot/api/ynetSearch.java b/htroot/api/ynetSearch.java index fa12c2984..e38647f0f 100644 --- a/htroot/api/ynetSearch.java +++ b/htroot/api/ynetSearch.java @@ -23,7 +23,7 @@ public class ynetSearch { if(!isAdmin){ // force authentication if desired if(post.containsKey("login")){ - prop.put("AUTHENTICATE","admin log-in"); + prop.authenticationRequired(); } return prop; } else { diff --git a/htroot/index.java b/htroot/index.java index 3d3a54773..d9c077a6f 100644 --- a/htroot/index.java +++ b/htroot/index.java @@ -55,7 +55,7 @@ public class index { final boolean authorizedAccess = sb.verifyAuthentication(header); if ((post != null) && (post.containsKey("publicPage"))) { if (!authorizedAccess) { - prop.put("AUTHENTICATE", "admin log-in"); // force log-in + prop.authenticationRequired(); return prop; } } diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java index 5e9f54b22..bb345cd81 100644 --- a/htroot/yacysearch.java +++ b/htroot/yacysearch.java @@ -612,7 +612,7 @@ public class yacysearch { if ( post != null && post.containsKey("deleteref") ) { try { if ( !sb.verifyAuthentication(header) ) { - prop.put("AUTHENTICATE", "admin log-in"); // force log-in + prop.authenticationRequired(); return prop; } @@ -642,7 +642,7 @@ public class yacysearch { // if a plus-button was hit, create new voting message if ( post != null && post.containsKey("recommendref") ) { if ( !sb.verifyAuthentication(header) ) { - prop.put("AUTHENTICATE", "admin log-in"); // force log-in + prop.authenticationRequired(); return prop; } final String recommendHash = post.get("recommendref", ""); // urlhash @@ -679,7 +679,7 @@ public class yacysearch { // if a bookmarks-button was hit, create new bookmark entry if ( post != null && post.containsKey("bookmarkref") ) { if ( !sb.verifyAuthentication(header) ) { - prop.put("AUTHENTICATE", "admin log-in"); // force log-in + prop.authenticationRequired(); return prop; } final String bookmarkHash = post.get("bookmarkref", ""); // urlhash diff --git a/source/de/anomic/data/ymark/YMarkTables.java b/source/de/anomic/data/ymark/YMarkTables.java index b14455733..df807c0d6 100644 --- a/source/de/anomic/data/ymark/YMarkTables.java +++ b/source/de/anomic/data/ymark/YMarkTables.java @@ -87,9 +87,7 @@ public class YMarkTables { public final static String FOLDERS_ROOT = "/"; public final static String BOOKMARKS_LOG = "BOOKMARKS"; public final static String USER_ADMIN = "admin"; - public final static String USER_AUTHENTICATE = "AUTHENTICATE"; public final static String USER_AUTHENTICATE_MSG = "Bookmark user authentication required!"; - public final static String ADMIN_AUTHENTICATE_MSG = "Admin authentication required!"; public final static String p1 = "(?:^|.*,)"; public final static String p4 = "(?:,.*|$)"; diff --git a/source/de/anomic/http/server/HTTPDFileHandler.java b/source/de/anomic/http/server/HTTPDFileHandler.java index 9a03a7cb0..96696bf86 100644 --- a/source/de/anomic/http/server/HTTPDFileHandler.java +++ b/source/de/anomic/http/server/HTTPDFileHandler.java @@ -342,7 +342,7 @@ public final class HTTPDFileHandler { serverCore.bfHost.put(clientIP, Integer.valueOf(attempts.intValue() + 1)); final ResponseHeader responseHeader = getDefaultHeaders(path); - responseHeader.put(RequestHeader.WWW_AUTHENTICATE,"Basic realm=\"admin log-in\""); + responseHeader.put(RequestHeader.WWW_AUTHENTICATE, "Basic realm=\"" + serverObjects.ADMIN_AUTHENTICATE_MSG + "\""); final servletProperties tp=new servletProperties(); tp.put("returnto", path); HTTPDemon.sendRespondError(conProp, out, 5, 401, "Wrong Authentication", "", new File("proxymsg/authfail.inc"), tp, null, responseHeader); diff --git a/source/de/anomic/server/serverObjects.java b/source/de/anomic/server/serverObjects.java index 46d25502f..3d4097e70 100644 --- a/source/de/anomic/server/serverObjects.java +++ b/source/de/anomic/server/serverObjects.java @@ -66,6 +66,10 @@ import net.yacy.search.Switchboard; public class serverObjects extends HashMap implements Cloneable { + public static final String ACTION_AUTHENTICATE = "AUTHENTICATE"; + public static final String ACTION_LOCATION = "LOCATION"; + public final static String ADMIN_AUTHENTICATE_MSG = "admin log-in. If you don't know the password, set it with {yacyhome}/bin/passwd.sh {newpassword}"; + private final static Pattern patternNewline = Pattern.compile("\n"); private final static Pattern patternDoublequote = Pattern.compile("\""); private final static Pattern patternSlash = Pattern.compile("/"); @@ -91,6 +95,10 @@ public class serverObjects extends HashMap implements Cloneable super(input); } + public void authenticationRequired() { + this.put(ACTION_AUTHENTICATE, ADMIN_AUTHENTICATE_MSG); + } + private static final String removeByteOrderMark(final String s) { if (s == null || s.length() == 0) return s; if (s.charAt(0) == BOM) return s.substring(1); diff --git a/source/de/anomic/server/servletProperties.java b/source/de/anomic/server/servletProperties.java index 7fc91c031..7bf73a697 100644 --- a/source/de/anomic/server/servletProperties.java +++ b/source/de/anomic/server/servletProperties.java @@ -27,9 +27,6 @@ public class servletProperties extends serverObjects { private static final long serialVersionUID = 1L; - public static final String ACTION_AUTHENTICATE = "AUTHENTICATE"; - public static final String ACTION_LOCATION = "LOCATION"; - public static final String PEER_STAT_VERSION = "version"; public static final String PEER_STAT_UPTIME = "uptime"; public static final String PEER_STAT_MYTIME = "mytime";