2005-09-17 jrandom

* Added the natively compiled jbigi and patched java service wrapper for
      OS X.  Thanks Bill Dorsey for letting me use your machine!
    * Don't build i2p.exe or i2pinstall.exe when run on OS X machines, as we
      don't bundle the binutils necessary (and there'd be a naming conflict
      if we did).
    * Added 'single user' functionality to syndie - if the single user
      checkbox on the admin page is checked, all users are allowed to control
      the instance and sync up with remote syndie nodes.
    * Temporarily disable the x-i2p-gzip in i2ptunnel until it is more closely
      debugged.
This commit is contained in:
jrandom
2005-09-17 07:31:48 +00:00
committed by zzz
parent 177e0ae6a3
commit d6c3ffde87
18 changed files with 216 additions and 17 deletions

View File

@ -371,7 +371,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
if (line.length() == 0) {
String ok = getTunnel().getContext().getProperty("i2ptunnel.gzip");
boolean gzip = true;
boolean gzip = false;
if (ok != null)
gzip = Boolean.valueOf(ok).booleanValue();
if (gzip)

View File

@ -240,11 +240,22 @@ public class BlogManager {
File cfg = getConfigFile();
return (cfg.exists());
}
/**
* If true, this syndie instance is meant for just one local user, so we don't need
* to password protect registration, remote.jsp, or admin.jsp
*
*/
public boolean isSingleUser() {
String isSingle = _context.getProperty("syndie.singleUser");
return ( (isSingle != null) && (Boolean.valueOf(isSingle).booleanValue()) );
}
public String getDefaultProxyHost() { return _context.getProperty("syndie.defaultProxyHost", ""); }
public String getDefaultProxyPort() { return _context.getProperty("syndie.defaultProxyPort", ""); }
public boolean authorizeAdmin(String pass) {
if (isSingleUser()) return true;
String admin = getAdminPasswordHash();
if ( (admin == null) || (admin.trim().length() <= 0) )
return false;
@ -252,15 +263,20 @@ public class BlogManager {
return (hash.equals(admin));
}
public boolean authorizeRemote(String pass) {
if (isSingleUser()) return true;
String rem = getRemotePasswordHash();
if ( (rem == null) || (rem.trim().length() <= 0) )
return false;
String hash = Base64.encode(_context.sha().calculateHash(DataHelper.getUTF8(pass.trim())).getData());
return (hash.equals(rem));
}
public boolean authorizeRemote(User user) {
if (isSingleUser()) return true;
return (!user.getAuthenticated() || !user.getAllowAccessRemote());
}
public void configure(String registrationPassword, String remotePassword, String adminPass, String defaultSelector,
String defaultProxyHost, int defaultProxyPort, Properties opts) {
String defaultProxyHost, int defaultProxyPort, boolean isSingleUser, Properties opts) {
File cfg = getConfigFile();
Writer out = null;
try {
@ -277,6 +293,7 @@ public class BlogManager {
out.write("syndie.defaultProxyHost="+defaultProxyHost.trim() + "\n");
if (defaultProxyPort > 0)
out.write("syndie.defaultProxyPort="+defaultProxyPort + "\n");
out.write("syndie.singleUser=" + isSingleUser + "\n");
if (opts != null) {
for (Iterator iter = opts.keySet().iterator(); iter.hasNext(); ) {
String key = (String)iter.next();
@ -327,7 +344,7 @@ public class BlogManager {
public String register(User user, String login, String password, String registrationPassword, String blogName, String blogDescription, String contactURL) {
System.err.println("Register [" + login + "] pass [" + password + "] name [" + blogName + "] descr [" + blogDescription + "] contact [" + contactURL + "] regPass [" + registrationPassword + "]");
String hashedRegistrationPassword = getRegistrationPasswordHash();
if (hashedRegistrationPassword != null) {
if ( (hashedRegistrationPassword != null) && (!isSingleUser()) ) {
try {
if (!hashedRegistrationPassword.equals(Base64.encode(_context.sha().calculateHash(registrationPassword.getBytes("UTF-8")).getData())))
return "<span class=\"b_regMsgErr\">Invalid registration password</span>";

View File

@ -351,7 +351,7 @@ public class HTMLRenderer extends EventReceiverImpl {
_bodyBuffer.append(getSpan("blogArchive")).append(" Archives: ");
for (int i = 0; i < locations.size(); i++) {
SafeURL surl = (SafeURL)locations.get(i);
if (_user.getAuthenticated() && _user.getAllowAccessRemote())
if (_user.getAuthenticated() && BlogManager.instance().authorizeRemote(_user) )
_bodyBuffer.append("<a ").append(getClass("blogArchiveView")).append(" href=\"").append(getArchiveURL(blog, surl)).append("\">").append(sanitizeString(surl.toString())).append("</a> ");
else
_bodyBuffer.append(getSpan("blogArchiveURL")).append(sanitizeString(surl.toString())).append("</span> ");

View File

@ -97,7 +97,7 @@ public class PostBean {
_filenames, localStreams, _fileTypes);
if (_log.shouldLog(Log.DEBUG))
_log.debug("Posted the entry " + uri.toString() + " (archive = " + _archive + ")");
if ( (uri != null) && (_user.getAllowAccessRemote()) ) {
if ( (uri != null) && BlogManager.instance().authorizeRemote(_user) ) {
PetName pn = _user.getPetNameDB().get(_archive);
if (_log.shouldLog(Log.DEBUG))
_log.debug("Archive to petname? " + pn + " (protocol: " + (pn != null ? pn.getProtocol() : "") + ")");

View File

@ -25,11 +25,18 @@ if (!user.getAuthenticated()) {
String proxyHost = request.getParameter("proxyhost");
String proxyPort = request.getParameter("proxyport");
String selector = request.getParameter("selector");
boolean isSingleUser = BlogManager.instance().isSingleUser();
String singleSet = request.getParameter("singleuser");
if (singleSet != null)
isSingleUser = true;
else
isSingleUser = false;
if (configured) {
if ( (adminPass != null) && (BlogManager.instance().authorizeAdmin(adminPass)) ) {
if (BlogManager.instance().authorizeAdmin(adminPass)) {
int port = -1;
try { port = Integer.parseInt(proxyPort); } catch (NumberFormatException nfe) { port = 4444; }
BlogManager.instance().configure(regPass, remotePass, adminPass, selector, proxyHost, port, null);
BlogManager.instance().configure(regPass, remotePass, adminPass, selector, proxyHost, port, isSingleUser, null);
%><span class="b_adminMsgOk">Configuration updated</span><%
} else {
%><span class="b_adminMsgErr">Invalid admin password. If you lost it, please update your syndie.config.</span><%
@ -37,11 +44,15 @@ if (!user.getAuthenticated()) {
} else {
int port = -1;
try { port = Integer.parseInt(proxyPort); } catch (NumberFormatException nfe) { port = 4444; }
BlogManager.instance().configure(regPass, remotePass, adminPass, selector, proxyHost, port, null);
BlogManager.instance().configure(regPass, remotePass, adminPass, selector, proxyHost, port, isSingleUser, null);
%><span class="b_adminMsgOk">Configuration saved</span><%
}
} else {
%><form action="admin.jsp" method="POST">
<em class="b_adminField">Single user?</em> <input type="checkbox" class="b_adminField" name="singleuser" <%=BlogManager.instance().isSingleUser() ? " checked=\"true\" " : ""%> /><br />
<span class="b_adminDescr">If this is checked, the registration, admin, and remote passwords are unnecessary - anyone
can register and administer Syndie, as well as use any remote functionality. This should not be checked if untrusted
parties can access this web interface.</span><br />
<em class="b_adminField">Registration password:</em> <input class="b_adminField" type="text" name="regpass" size="10" /><br />
<span class="b_adminDescr">Users must specify this password on the registration form to proceed. If this is
blank, anyone can register.</span><br />

View File

@ -97,7 +97,7 @@ if (!user.getAuthenticated()) {
post.renderPreview(out);
%><hr /><span class="b_postConfirm"><form action="post.jsp" method="POST">
Please confirm that the above is ok<% if (user.getAllowAccessRemote()) { %>, and select what additional archives you
Please confirm that the above is ok<% if (BlogManager.instance().authorizeRemote(user)) { %>, and select what additional archives you
want the post transmitted to. Otherwise, just hit your browser's back arrow and
make changes.
<select class="b_postConfirm" name="archive">

View File

@ -16,7 +16,7 @@ request.setCharacterEncoding("UTF-8");
<jsp:include page="_topnav.jsp" />
<td valign="top" align="left" rowspan="2" class="b_rightnav"><jsp:include page="_rightnav.jsp" /></td></tr>
<tr class="b_content"><td valign="top" align="left" colspan="3" class="b_content"><%
if (!user.getAuthenticated() || !user.getAllowAccessRemote()) {
if (!BlogManager.instance().authorizeRemote(user)) {
%><span class="b_remoteMsgErr">Sorry, you are not allowed to access remote archives from here. Perhaps you should install Syndie yourself?</span><%
} else { %><form action="remote.jsp" method="POST"><span class="b_remoteChooser"><span class="b_remoteChooserField">Import from:</span>
<select class="b_remoteChooserNet" name="schema">