I'm trying to implement a custom authenticator class and I'm a little stumped 
by the behavior so far.  When I override the authenticate() method to always 
return false, I get back an HTTP 204 error.  However, if I have it always 
return true, then the request goes through correctly, so I think I have 
everything wired up the right way.  Based on my reading of the available 
documentation, if authentication is set as required in the Authenticator 
subclass (which is the default setting), then a 401 response should be sent.  
Is this a bug?  Or am I missing a required step in my subclass implementation?

Thanks,
Matt

The following illustrates the problem (in Groovy):

import org.restlet.*;
import org.restlet.data.*;
import org.restlet.security.Authenticator;
import org.restlet.representation.*;

class TestAuthenticator extends Authenticator
{
  @Override 
  public TestAuthenticator(Context ctx){ super(ctx); }

  @Override
  protected boolean authenticate(Request request, Response response)
  {
    return false;
    //return true;
  }
}

class TestRestlet extends Restlet
{
  @Override
  public void handle(Request request, Response response) 
  {
    response.setEntity(new StringRepresentation("hello, world\n", 
MediaType.TEXT_PLAIN));
  }
}

def component = new Component();
Server http = component.servers.add(Protocol.HTTP, 8181);
component.clients.add(Protocol.FILE);
Context workingCtx = http.context;
def guard = new TestAuthenticator(workingCtx);
def restlet = new TestRestlet();
guard.setNext(restlet);
component.defaultHost.attach(guard);
component.start();

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2426801

Reply via email to