The basic configuration is now very very easy! New users will not be confronted with account settings.

- moved account definition from Basic Configuration into the User_p servlet which was renamed to ConficAccounts_p
- moved and renamed submenu entries on Status page.

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@4805 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 17 years ago
parent 3bd1db776a
commit 30356ec980

@ -23,8 +23,38 @@
<p class="error">Passwords do not match.</p>
::
<p class="error">Username too short. Username must be >= 4 Characters.</p>
#(/error)#
#(/error)#
<fieldset><legend>Admin Account</legend>
<form action="ConfigAccounts_p.html" method="post">
<fieldset>
<legend>
<input type="radio" name="access" id="access" value="localhost"#(localhost.checked)#:: checked="checked"#(/localhost.checked)# />
<label for="localhost">Access from localhost without account</label>
</legend>
Access to your peer from your own computer (localhost access) is granted. No need to configure an administration account.
</fieldset>
<fieldset>
<legend>
<input type="radio" name="access" id="access" value="account"#(account.checked)#:: checked="checked"#(/account.checked)# />
<label for="account">Access only with qualified account</label>
</legend>
You need this only if you want a remote access to your peer.
<dl class="userConfig">
<dt><label for="adminuser">Peer User:</label></dt>
<dd><input type="text" name="adminuser" id="adminuser" value="#[defaultUser]#" size="16" maxlength="32" /></dd>
<dt><label for="adminpw1">New Peer Password:</label></dt>
<dd><input type="password" name="adminpw1" id="adminpw1" value="" size="16" maxlength="32" /></dd>
<dt><label for="adminpw2">Repeat Peer Password:</label></dt>
<dd><input type="password" name="adminpw2" id="adminpw2" value="" size="16" maxlength="32" /></dd>
</dl>
</fieldset>
<input type="submit" name="setAdmin" value="Define Administrator" />
</form>
</fieldset>
<fieldset><legend>User Accounts</legend>
<form action="User_p.html">
<fieldset><legend>Select user</legend>
<dl>
@ -44,7 +74,7 @@
</fieldset>
</form>
<form action="User_p.html" method="post">
<form action="ConfigAccounts_p.html" method="post">
<fieldset><legend>Edit current user: #[username]#</legend>
<!-- Hidden(text for debugging): <input type="text" name="current_user" value="#[current_user]#" readonly> -->
<input type="hidden" name="current_user" value="#[current_user]#" />
@ -75,7 +105,9 @@
<dd><input type="submit" name="change" value="Save User" /></dd>
</dl>
</fieldset>
</form>
</form>
</fieldset>
#%env/templates/footer.template%#
</body>
</html>

@ -52,18 +52,47 @@ import java.util.Iterator;
import de.anomic.data.userDB;
import de.anomic.http.httpHeader;
import de.anomic.http.httpd;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCodings;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
public class User_p {
public class ConfigAccounts_p {
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch<?> env) {
serverObjects prop = new serverObjects();
plasmaSwitchboard sb = plasmaSwitchboard.getSwitchboard();
userDB.Entry entry=null;
// admin password
boolean localhostAccess = sb.getConfigBool("adminAccountForLocalhost", false);
if ((post != null) && (post.containsKey("setAdmin"))) {
localhostAccess = post.get("access", "").equals("localhost");
String user = (post == null) ? "" : (String) post.get("adminuser", "");
String pw1 = (post == null) ? "" : (String) post.get("adminpw1", "");
String pw2 = (post == null) ? "" : (String) post.get("adminpw2", "");
sb.setConfig("adminAccountForLocalhost", localhostAccess);
// if an localhost access is configured, check if a local password is given
// if not, set a random password
if (post != null && localhostAccess && env.getConfig(httpd.ADMIN_ACCOUNT_B64MD5, "").length() == 0) {
// make a 'random' password
env.setConfig(httpd.ADMIN_ACCOUNT_B64MD5, "0000" + serverCodings.encodeMD5Hex(System.getProperties().toString() + System.currentTimeMillis()));
env.setConfig("adminAccount", "");
}
// may be overwritten if new password is given
if ((user.length() > 0) && (pw1.length() > 3) && (pw1.equals(pw2))) {
// check passed. set account:
env.setConfig(httpd.ADMIN_ACCOUNT_B64MD5, serverCodings.encodeMD5Hex(kelondroBase64Order.standardCoder.encodeString(user + ":" + pw1)));
env.setConfig("adminAccount", "");
}
}
prop.put("localhost.checked", (localhostAccess) ? 1 : 0);
prop.put("account.checked", (localhostAccess) ? 0 : 1);
prop.put("statusPassword", localhostAccess ? "0" : "1");
prop.put("defaultUser", "admin");
//default values
prop.put("current_user", "newuser");
prop.put("username", "");
@ -83,8 +112,8 @@ public class User_p {
prop.put("rights", i);
prop.put("users", "0");
if(sb.userDB == null)
if (sb.userDB == null)
return prop;
if(post == null){
@ -122,9 +151,9 @@ public class User_p {
String username=(String)post.get("username");
String pw=(String)post.get("password");
String pw1=(String)post.get("password");
String pw2=(String)post.get("password2");
if(! pw.equals(pw2)){
if(! pw1.equals(pw2)){
prop.put("error", "2"); //PW does not match
return prop;
}
@ -140,8 +169,8 @@ public class User_p {
HashMap<String, String> mem=new HashMap<String, String>();
if( post.get("current_user").equals("newuser")){ //new user
if(!pw.equals("")){ //change only if set
mem.put(userDB.Entry.MD5ENCODED_USERPWD_STRING, serverCodings.encodeMD5Hex(username+":"+pw));
if(!pw1.equals("")){ //change only if set
mem.put(userDB.Entry.MD5ENCODED_USERPWD_STRING, serverCodings.encodeMD5Hex(username+":"+pw1));
}
mem.put(userDB.Entry.USER_FIRSTNAME, firstName);
mem.put(userDB.Entry.USER_LASTNAME, lastName);
@ -166,8 +195,8 @@ public class User_p {
entry = sb.userDB.getEntry(username);
if(entry != null){
try{
if(! pw.equals("")){
entry.setProperty(userDB.Entry.MD5ENCODED_USERPWD_STRING, serverCodings.encodeMD5Hex(username+":"+pw));
if(! pw1.equals("")){
entry.setProperty(userDB.Entry.MD5ENCODED_USERPWD_STRING, serverCodings.encodeMD5Hex(username+":"+pw1));
}
entry.setProperty(userDB.Entry.USER_FIRSTNAME, firstName);
entry.setProperty(userDB.Entry.USER_LASTNAME, lastName);

@ -17,7 +17,7 @@
<body id="ConfigBasic">
#%env/templates/header.template%#
#%env/templates/submenuConfig.template%#
<h2>Access Configuration</h2>
<h2>Basic Configuration</h2>
<p>
Your YaCy Peer needs some basic information to operate properly
</p>
@ -31,36 +31,9 @@
<input type="radio" name="language" value="default" id="lang_en" #(langEnglish)#::checked="checked"#(/langEnglish)# /><label for="lang_en">English</label>
</fieldset>
</li>
<li>
#(statusPassword)#<img src="/env/grafics/ok.png" height="16" width="16" alt="warning" />&nbsp;Access to localhost granted without password::<img src="/env/grafics/ok.png" height="16" width="16" alt="ok" />&nbsp;Password is set#(/statusPassword)#<br />
<fieldset>
<legend>
<input type="radio" name="access" id="access" value="localhost"#(localhost.checked)#:: checked="checked"#(/localhost.checked)# />
<label for="localhost">Access from localhost without account</label>
</legend>
Access to your peer from your own computer (localhost access) is granted. No need to configure an administration account.
</fieldset>
<fieldset>
<legend>
<input type="radio" name="access" id="access" value="account"#(account.checked)#:: checked="checked"#(/account.checked)# />
<label for="account">Access only with account</label>
</legend>
You need this only if you want a remote access to your peer.
<dl class="userConfig">
<dt><label for="adminuser">Peer User:</label></dt>
<dd><input type="text" name="adminuser" id="adminuser" value="#[defaultUser]#" size="16" maxlength="32" /></dd>
<dt><label for="adminpw1">New Peer Password:</label></dt>
<dd><input type="password" name="adminpw1" id="adminpw1" value="" size="16" maxlength="32" /></dd>
<dt><label for="adminpw2">Repeat Peer Password:</label></dt>
<dd><input type="password" name="adminpw2" id="adminpw2" value="" size="16" maxlength="32" /></dd>
</dl>
</fieldset>
</li>
<li>
#(statusName)#<img src="/env/grafics/bad.png" height="16" width="16" alt="warning" />&nbsp;Your peer name has not been customized; please set your own peer name::<img src="/env/grafics/ok.png" height="16" width="16" alt="ok" />&nbsp;You have a nice peer name#(/statusName)#<br />
#(statusName)#<img src="/env/grafics/bad.png" height="16" width="16" alt="warning" />&nbsp;Your peer name has not been customized; please set your own peer name::<img src="/env/grafics/ok.png" height="16" width="16" alt="ok" />&nbsp;You may change your peer name#(/statusName)#<br />
<fieldset>
<dl>
<dt><label for="peername">Peer Name: </label></dt>

@ -52,11 +52,8 @@ import java.util.regex.Pattern;
import de.anomic.data.translator;
import de.anomic.http.httpHeader;
import de.anomic.http.httpd;
import de.anomic.http.httpdFileHandler;
import de.anomic.kelondro.kelondroBase64Order;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCodings;
import de.anomic.server.serverCore;
import de.anomic.server.serverDomains;
import de.anomic.server.serverInstantBusyThread;
@ -100,12 +97,6 @@ public class ConfigBasic {
translator.changeLang(env, langPath, post.get("language", "default") + ".lng");
}
// password settings
boolean localhostAccess = (post == null) ? sb.getConfigBool("adminAccountForLocalhost", false) : post.get("access", "").equals("localhost");
String user = (post == null) ? "" : (String) post.get("adminuser", "");
String pw1 = (post == null) ? "" : (String) post.get("adminpw1", "");
String pw2 = (post == null) ? "" : (String) post.get("adminpw2", "");
// peer name settings
String peerName = (post == null) ? env.getConfig("peerName","") : (String) post.get("peername", "");
@ -114,24 +105,6 @@ public class ConfigBasic {
if (post != null && Integer.parseInt((String) post.get("port")) > 1023) {
port = post.get("port", "8080");
}
// admin password
sb.setConfig("adminAccountForLocalhost", localhostAccess);
prop.put("localhost.checked", (localhostAccess) ? 1 : 0);
prop.put("account.checked", (localhostAccess) ? 0 : 1);
// if an localhost access is configured, check if a local password is given
// if not, set a random password
if (post != null && localhostAccess && env.getConfig(httpd.ADMIN_ACCOUNT_B64MD5, "").length() == 0) {
// make a 'random' password
env.setConfig(httpd.ADMIN_ACCOUNT_B64MD5, "0000" + serverCodings.encodeMD5Hex(System.getProperties().toString() + System.currentTimeMillis()));
env.setConfig("adminAccount", "");
}
// may be overwritten if new password is given
if ((user.length() > 0) && (pw1.length() > 3) && (pw1.equals(pw2))) {
// check passed. set account:
env.setConfig(httpd.ADMIN_ACCOUNT_B64MD5, serverCodings.encodeMD5Hex(kelondroBase64Order.standardCoder.encodeString(user + ":" + pw1)));
env.setConfig("adminAccount", "");
}
// check if peer name already exists
yacySeed oldSeed = sb.webIndex.seedDB.lookupByName(peerName);
@ -184,7 +157,6 @@ public class ConfigBasic {
}
prop.put("statusName", properName ? "1" : "0");
prop.put("statusPassword", localhostAccess ? "0" : "1");
prop.put("statusPort", properPort ? "1" : "0");
if (reconnect) {
prop.put("nextStep", NEXTSTEP_RECONNECT);
@ -198,7 +170,6 @@ public class ConfigBasic {
// set default values
prop.put("defaultName", env.getConfig("peerName", ""));
prop.put("defaultUser", "admin");
prop.put("defaultPort", env.getConfig("port", "8080"));
lang = env.getConfig("locale.language", "default"); // re-assign lang, may have changed
if (lang.equals("default")) {

@ -2,21 +2,21 @@
<h3>Peer Administration Console</h3>
<ul class="SubMenu">
<li><a href="/Status.html" class="MenuItemLink lock">Status</a></li>
<li><a href="/ConfigBasic.html" class="MenuItemLink lock">Access Config</a></li>
<li><a href="/ConfigNetwork_p.html" class="MenuItemLink lock">Network</a></li>
<li><a href="/ConfigLanguage_p.html" class="MenuItemLink lock">Language</a></li>
<li><a href="/ConfigBasic.html" class="MenuItemLink lock">Basic Configuration</a></li>
<li><a href="/ConfigAccounts_p.html" class="MenuItemLink lock">Accounts</a></li>
<li><a href="/ConfigProfile_p.html" class="MenuItemLink lock">User Profile</a></li>
<li><a href="/ConfigPeerProfile_p.html" class="MenuItemLink lock">Peer Appearance Profile</a></li>
<li><a href="/ConfigLanguage_p.html" class="MenuItemLink lock">Language</a></li>
<li><a href="/ConfigSkins_p.html" class="MenuItemLink lock">Skins</a></li>
<li><a href="/ConfigUpdate_p.html" class="MenuItemLink lock">System Update</a></li>
</ul>
</div>
<div class="SubMenu">
<ul class="SubMenu">
<li><a href="/ConfigNetwork_p.html" class="MenuItemLink lock">Network Configuration</a></li>
<li><a href="/ConfigRobotsTxt_p.html" class ="MenuItemLink lock">Local robots.txt</a></li>
<li><a href="/User_p.html" class="MenuItemLink lock">User Administration</a></li>
<li><a href="/ConfigPeerProfile_p.html" class="MenuItemLink lock">Peer Appearance Profile</a></li>
<li><a href="/Settings_p.html" class="MenuItemLink lock">Advanced Settings</a></li>
<li><a href="/ConfigProperties_p.html" class="MenuItemLink lock">Advanced Properties</a></li>
<li><a href="/ConfigUpdate_p.html" class="MenuItemLink lock">System Update</a></li>
</ul>
</div>
<div class="SubMenu">

Loading…
Cancel
Save