forked from I2P_Developers/i2p.i2p
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:
@@ -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>";
|
||||
|
||||
@@ -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> ");
|
||||
|
||||
@@ -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() : "") + ")");
|
||||
|
||||
Reference in New Issue
Block a user