add YaCy HttpCommand "authenticate" check to DefaultServlet

pull/1/head
reger 12 years ago
parent 1adb4b8741
commit da4ff5aefa

@ -49,6 +49,7 @@ import net.yacy.cora.date.GenericFormatter;
import net.yacy.cora.document.analysis.Classification; import net.yacy.cora.document.analysis.Classification;
import net.yacy.cora.protocol.HeaderFramework; import net.yacy.cora.protocol.HeaderFramework;
import net.yacy.cora.protocol.RequestHeader; import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.protocol.ResponseHeader;
import net.yacy.cora.util.ConcurrentLog; import net.yacy.cora.util.ConcurrentLog;
import net.yacy.kelondro.util.FileUtils; import net.yacy.kelondro.util.FileUtils;
import net.yacy.kelondro.util.MemoryControl; import net.yacy.kelondro.util.MemoryControl;
@ -121,7 +122,7 @@ import org.eclipse.jetty.util.resource.ResourceFactory;
* *
* </PRE> * </PRE>
*/ */
public abstract class YaCyDefaultServlet extends HttpServlet implements ResourceFactory { public abstract class YaCyDefaultServlet extends HttpServlet {
private static final long serialVersionUID = 4900000000000001110L; private static final long serialVersionUID = 4900000000000001110L;
protected ServletContext _servletContext; protected ServletContext _servletContext;
@ -209,7 +210,6 @@ public abstract class YaCyDefaultServlet extends HttpServlet implements Resource
* @param pathInContext The path to find a resource for. * @param pathInContext The path to find a resource for.
* @return The resource to serve. * @return The resource to serve.
*/ */
@Override
public Resource getResource(String pathInContext) { public Resource getResource(String pathInContext) {
Resource r = null; Resource r = null;
if (_relativeResourceBase != null) { if (_relativeResourceBase != null) {
@ -678,7 +678,13 @@ public abstract class YaCyDefaultServlet extends HttpServlet implements Resource
} }
// handle YaCy http commands // handle YaCy http commands
if (templatePatterns.containsKey(serverObjects.ACTION_LOCATION)) { // handle action auth: check if the servlets requests authentication
if (templatePatterns.containsKey(serverObjects.ACTION_AUTHENTICATE)) {
if (!request.authenticate(response)) {
return;
}
//handle action forward
} else if (templatePatterns.containsKey(serverObjects.ACTION_LOCATION)) {
String location = templatePatterns.get(serverObjects.ACTION_LOCATION, ""); String location = templatePatterns.get(serverObjects.ACTION_LOCATION, "");
if (location.isEmpty()) { if (location.isEmpty()) {

Loading…
Cancel
Save