diff --git a/apps/syndie/java/src/net/i2p/syndie/BlogManager.java b/apps/syndie/java/src/net/i2p/syndie/BlogManager.java index c0c2d13b4..708e3996b 100644 --- a/apps/syndie/java/src/net/i2p/syndie/BlogManager.java +++ b/apps/syndie/java/src/net/i2p/syndie/BlogManager.java @@ -72,10 +72,13 @@ public class BlogManager { for (Iterator iter = p.keySet().iterator(); iter.hasNext(); ) { String key = (String)iter.next(); System.setProperty(key, p.getProperty(key)); + System.out.println("Read config prop [" + key + "] = [" + p.getProperty(key) + "]"); } } catch (IOException ioe) { ioe.printStackTrace(); } + } else { + System.out.println("Config doesn't exist: " + config.getPath()); } } @@ -217,6 +220,30 @@ public class BlogManager { return pass; } + /** Password required to access the remote syndication functinoality (null means no password required) */ + public String getRemotePassword() { + String pass = _context.getProperty("syndie.remotePassword"); + + System.out.println("Remote password? [" + pass + "]"); + if ( (pass == null) || (pass.trim().length() <= 0) ) return null; + return pass; + } + + public String authorizeRemoteAccess(User user, String password) { + if (!user.getAuthenticated()) return "Not logged in"; + String remPass = getRemotePassword(); + if (remPass == null) + return "Remote access password not configured - please specify 'syndie.remotePassword' in your syndie.config"; + + if (remPass.equals(password)) { + user.setAllowAccessRemote(true); + saveUser(user); + return "Remote access authorized"; + } else { + return "Remote access denied"; + } + } + public void saveUser(User user) { if (!user.getAuthenticated()) return; String userHash = Base64.encode(_context.sha().calculateHash(DataHelper.getUTF8(user.getUsername())).getData()); diff --git a/apps/syndie/jsp/viewmetadata.jsp b/apps/syndie/jsp/viewmetadata.jsp index 0734eeba0..750b46ff8 100644 --- a/apps/syndie/jsp/viewmetadata.jsp +++ b/apps/syndie/jsp/viewmetadata.jsp @@ -1,5 +1,6 @@ -<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="net.i2p.syndie.web.*" %> +<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="net.i2p.syndie.web.*, net.i2p.syndie.*" %> <% request.setCharacterEncoding("UTF-8"); %> + SyndieMedia @@ -13,6 +14,20 @@ <% ArchiveViewerBean.renderMetadata(request.getParameterMap(), out); +if (user.getAuthenticated()) { + if ("Authorize".equals(request.getParameter("action"))) { + %><%=BlogManager.instance().authorizeRemoteAccess(user, request.getParameter("password"))%><% + } + if (!user.getAllowAccessRemote()) { + if (user.getBlog().toBase64().equals(request.getParameter("blog"))) { + %>
+" /> +To access remote instances from this instance, please supply the Syndie administration password: + +
<% + } + } +} %> \ No newline at end of file