I am new to Restlet and am trying to get Http Digest authentication to work (I
currently get a 401 everytime). 

I create the guard as follows:
 
Guard g = new Guard(getContext(),ChallengeScheme.HTTP_DIGEST, "someRealm");

g.getSecrets().put("userName", "somePassword".toCharArray());

 
The relevant client code is:

Request request = new Request(Method.PUT, url, fr );//url of the server and a
representation of a file.

ChallengeScheme scheme = ChallengeScheme.HTTP_DIGEST;

ChallengeResponse authentication = new ChallengeResponse(scheme,"userName",
"somePassword");
  
request.setChallengeResponse(authentication);
  
// Ask to the HTTP client connector to handle the call Client client = new
Client(Protocol.HTTP); Response response = client.handle(request);

 
This works if I change the ChallengeScheme to ChallengeScheme.HTTP_BASIC.


Reply via email to