Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
rights for Admin and Proxy. Adminrights are OR(old auth or new). Proxyrights are AND(you need Proxyrights and a not reached Timelimit)
allof97c303ebd65
diff --git a/htroot/User_p.html b/htroot/User_p.htmlindex 3d81d50a6..cace4c7eb 100644--- a/htroot/User_p.html+++ b/htroot/User_p.html@@ -58,8 +58,8 @@ Current User: #[username]#<tr><td>Rights</td><td>- <input type="checkbox" name="proxyRight" checked disabled>Proxy<br />- <input type="checkbox" name="adminRight" disabled>Admin<br />+ <input type="checkbox" name="proxyRight" #(proxyRight)#::checked#(/proxyRight)#>Proxy<br />+ <input type="checkbox" name="adminRight" #(adminRight)#::checked#(/adminRight)#>Admin<br /><input type="checkbox" name="uploadRight" #(uploadRight)#::checked#(/uploadRight)#>Fileshare-Upload<br /><input type="checkbox" name="downloadRight" #(downloadRight)#::checked#(/downloadRight)#>Fileshare-Download<br /></td>diff --git a/htroot/User_p.java b/htroot/User_p.javaindex aecd17ab0..3fa53f177 100644--- a/htroot/User_p.java+++ b/htroot/User_p.java@@ -77,8 +77,10 @@ public class User_p {prop.put("page_timelimit", "");prop.put("page_timeused", "");prop.put("page_timerange", "");+ prop.put("page_proxyRight", 1);prop.put("page_downloadRight", 0);prop.put("page_uploadRight", 0);+ prop.put("page_adminRight", 0);prop.put("page_users", 0);@@ -103,8 +105,10 @@ public class User_p {prop.put("page_address", entry.getAddress());prop.put("page_timelimit", entry.getTimeLimit());prop.put("page_timeused", entry.getTimeUsed());+ prop.put("page_proxyRight", (entry.hasProxyRight()?1:0));prop.put("page_uploadRight", (entry.hasUploadRight()?1:0));prop.put("page_downloadRight", (entry.hasDownloadRight()?1:0));+ prop.put("page_adminRight", (entry.hasAdminRight()?1:0));}else if( post.containsKey("delete_user") && !((String)post.get("user")).equals("newuser") ){sb.userDB.removeEntry((String)post.get("user"));}@@ -126,8 +130,10 @@ public class User_p {String address=(String)post.get("address");String timeLimit=(String)post.get("timelimit");String timeUsed=(String)post.get("timeused");+ String proxyRight=( post.containsKey("proxyRight")&&((String)post.get("proxyRight")).equals("on") ? "true" : "false");String uploadRight=( post.containsKey("uploadRight")&&((String)post.get("uploadRight")).equals("on") ? "true" : "false");String downloadRight=( post.containsKey("downloadRight")&&((String)post.get("downloadRight")).equals("on") ? "true" : "false");+ String adminRight=( post.containsKey("adminRight")&&((String)post.get("adminRight")).equals("on") ? "true" : "false");HashMap mem=new HashMap();if( post.get("current_user").equals("newuser")){ //new user@@ -139,8 +145,10 @@ public class User_p {mem.put(userDB.Entry.USER_ADDRESS, address);mem.put(userDB.Entry.TIME_LIMIT, timeLimit);mem.put(userDB.Entry.TIME_USED, timeUsed);+ mem.put(userDB.Entry.PROXY_RIGHT, proxyRight);mem.put(userDB.Entry.UPLOAD_RIGHT, uploadRight);mem.put(userDB.Entry.DOWNLOAD_RIGHT, downloadRight);+ mem.put(userDB.Entry.ADMIN_RIGHT, adminRight);entry=sb.userDB.createEntry(username, mem);sb.userDB.addEntry(entry);@@ -160,8 +168,10 @@ public class User_p {entry.setProperty(userDB.Entry.USER_ADDRESS, address);entry.setProperty(userDB.Entry.TIME_LIMIT, timeLimit);entry.setProperty(userDB.Entry.TIME_USED, timeUsed);+ entry.setProperty(userDB.Entry.PROXY_RIGHT, proxyRight);entry.setProperty(userDB.Entry.UPLOAD_RIGHT, uploadRight);entry.setProperty(userDB.Entry.DOWNLOAD_RIGHT, downloadRight);+ entry.setProperty(userDB.Entry.ADMIN_RIGHT, adminRight);}catch (IOException e){}}else{diff --git a/source/de/anomic/data/userDB.java b/source/de/anomic/data/userDB.javaindex fa64dcd64..fd47de044 100644--- a/source/de/anomic/data/userDB.java+++ b/source/de/anomic/data/userDB.java@@ -304,7 +304,12 @@ public final class userDB {}public boolean canSurf(){+ //TODO: more returnvalues.+ //Exception if false, or CONSTANTSlong timeUsed=this.updateLastAccess(true);+ if(this.hasProxyRight() == false)+ return false;+if( this.getTimeLimit() == null || this.getTimeLimit().longValue() <= 0 || ( timeUsed < this.getTimeLimit().longValue()) )//no timelimit or timelimit not reachedreturn true;elsediff --git a/source/de/anomic/http/httpdFileHandler.java b/source/de/anomic/http/httpdFileHandler.javaindex e58a14e8a..2823e2225 100644--- a/source/de/anomic/http/httpdFileHandler.java+++ b/source/de/anomic/http/httpdFileHandler.java@@ -109,6 +109,8 @@ import de.anomic.server.serverFileUtils;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;import de.anomic.server.logging.serverLog;+import de.anomic.data.userDB;+public final class httpdFileHandler extends httpdAbstractHandler implements httpdHandler {@@ -117,6 +119,7 @@ public final class httpdFileHandler extends httpdAbstractHandler implements httpprivate static final serverClassLoader provider;private static final HashMap templates = new HashMap();private static serverSwitch switchboard;+ private static plasmaSwitchboard sb = plasmaSwitchboard.getSwitchboard();private static File htRootPath = null;private static File htDocsPath = null;@@ -311,23 +314,28 @@ public final class httpdFileHandler extends httpdAbstractHandler implements httpheaders.put(httpHeader.WWW_AUTHENTICATE,"Basic realm=\"admin log-in\"");httpd.sendRespondHeader(conProp,out,httpVersion,401,headers);return;- } else if (adminAccountBase64MD5.equals(serverCodings.standardCoder.encodeMD5Hex(authorization.trim().substring(6)))) {- // Authentication successfull. remove brute-force flag- serverCore.bfHost.remove(conProp.getProperty("CLIENTIP"));} else {- // a wrong authentication was given. Ask again- String clientIP = conProp.getProperty("CLIENTIP", "unknown-host");- serverLog.logInfo("HTTPD", "Wrong log-in for account 'admin' in http file handler for path '" + path + "' from host '" + clientIP + "'");- Integer attempts = (Integer) serverCore.bfHost.get(clientIP);- if (attempts == null)- serverCore.bfHost.put(clientIP, new Integer(1));- else- serverCore.bfHost.put(clientIP, new Integer(attempts.intValue() + 1));+ userDB.Entry entry = sb.userDB.proxyAuth(authorization);+ if (adminAccountBase64MD5.equals(serverCodings.standardCoder.encodeMD5Hex(authorization.trim().substring(6)))) {+ // Authentication successfull. remove brute-force flag+ serverCore.bfHost.remove(conProp.getProperty("CLIENTIP"));+ }else if(entry != null && entry.hasAdminRight()){+ serverCore.bfHost.remove(conProp.getProperty("CLIENTIP"));+ } else {+ // a wrong authentication was given. Ask again+ String clientIP = conProp.getProperty("CLIENTIP", "unknown-host");+ serverLog.logInfo("HTTPD", "Wrong log-in for account 'admin' in http file handler for path '" + path + "' from host '" + clientIP + "'");+ Integer attempts = (Integer) serverCore.bfHost.get(clientIP);+ if (attempts == null)+ serverCore.bfHost.put(clientIP, new Integer(1));+ else+ serverCore.bfHost.put(clientIP, new Integer(attempts.intValue() + 1));- httpHeader headers = getDefaultHeaders(path);- headers.put(httpHeader.WWW_AUTHENTICATE,"Basic realm=\"admin log-in\"");- httpd.sendRespondHeader(conProp,out,httpVersion,401,headers);+ httpHeader headers = getDefaultHeaders(path);+ headers.put(httpHeader.WWW_AUTHENTICATE,"Basic realm=\"admin log-in\"");+ httpd.sendRespondHeader(conProp,out,httpVersion,401,headers);return;+ }}}diff --git a/source/de/anomic/http/httpdProxyAccount.java b/source/de/anomic/http/httpdProxyAccount.javadeleted file mode 100644index 7af175ee5..000000000--- a/source/de/anomic/http/httpdProxyAccount.java+++ /dev/null@@ -1,24 +0,0 @@-package de.anomic.http;--import java.net.InetAddress;--public final class httpdProxyAccount {- String username;- InetAddress ip;- int timeLimit; //max. Time for this user- int timeUsed;- boolean timeBlock; //count linear or only activity?-- public httpdProxyAccount(InetAddress myip){- ip=myip;- timeLimit=0;- timeUsed=0;- timeBlock=false;- }- public httpdProxyAccount(InetAddress myip, int mytimeLimit){- ip=myip;- timeLimit=mytimeLimit;- timeUsed=0;- timeBlock=false;- }-}