RE: Re: Custom Challenge Scheme

2011-06-04 Thread Paul Morris
Thanks for the input. I was able to get Restlet to recognize my helper. Not 
sure I understand the implications of setting the clientSide boolean value to 
true but anyway what I'm fighting with now is the line in my overridden 
parseResponse method for setting the raw value. Unfortunately when the program 
reached that line at runtime it just loops through these same methods 
indefinitely until it finally overflows:

at 
org.restlet.engine.adapter.HttpRequest.getChallengeResponse(HttpRequest.java:227)
at 
org.apius.identity.openam.MyAuthenticatorHelper.parseResponse(MyAuthenticatorHelper.java:48)
at 
org.restlet.engine.security.AuthenticatorUtils.parseResponse(AuthenticatorUtils.java:350)

Perhaps I'm not approaching this the right way. I simply want to 1) register my 
scheme with the engine (which you helped me do), 2) have the framework write 
the WWW-Authenticate header with the appropriate realm on 401s and 3) change 
getRawValue() so that it returns just token value and not token=token 
value. Any advice?

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


RE: Re: Custom Challenge Scheme

2011-06-04 Thread Paul Morris
I feel like an idiot (lol). I just needed to change my setRawValue method line 
so that it was using the ChallengeResponse argument in the method itself and 
not the HttpRequest adapter's getChallengeResponse(). It's understandable why 
that would have created an infinite loop. Anyway thanks again for the help.

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


Re: Custom Challenge Scheme

2011-06-03 Thread Sebastian Wenninger
I had the same problem.
If i remember correctly, i solved it by changing the Constructor of my
Custom scheme.
As you can see, the restlet-Engine automatically adds HTTP_ to your Scheme
name and searches the registered Schemes only for that name. Don't know if
its a bug or intended this way.
Either way, try to change your code like this:

public static final ChallengeScheme MYSCHEME = 
new ChallengeScheme( 
HTTP_MYSCHEME, 
MYSCHEME, 
A custom challenge authentication scheme.); 


--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/Custom-Challenge-Scheme-tp6434473p6435068.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Re: Custom Challenge Scheme

2011-06-03 Thread Rhett Sutphin
Hi Paul,

As Sebastian responded, part of the solution is to match up the ChallengeScheme 
name with what Restlet expects. The other part is to register your helper as 
being both for client-side and server-side. I'm not sure why this is, but 
Restlet[1] always looks for a client-side helper during parseResponse.

Rhett

[1]: At least in 2.0; I haven't looked at 2.1.

On Jun 2, 2011, at 5:59 PM, Paul Morris wrote:

 Having problems implementing a custom challenge scheme with an 
 AuthenticatorHelper. I've read the documentation but I am still receiving 
 this WARNING in the logs:
 
 WARNING: Couldn't find any helper support the HTTP_MYSCHEME challenge scheme.
 
 This is what I'm doing code-wise...
 
 public class MyAuthenticatorHelper extends 
 org.restlet.engine.security.AuthenticatorHelper 
 {
 
   public static final ChallengeScheme MYSCHEME = 
   new ChallengeScheme(
   MYSCHEME, 
   MYSCHEME, 
   A custom challenge authentication scheme.);
   
   public MyAuthenticatorHelper() 
   {
   super(MYSCHEME, false, true);
   }
   
   @Override
   public void formatRawRequest(ChallengeWriter cw, 

 ChallengeRequest cr, 
Response 
 response, 

 SeriesParameter httpHeaders) throws IOException
   
   {
   if (cr.getRealm() != null)
   cw.appendQuotedChallengeParameter(realm, 
 cr.getRealm());
   }
   
   @Override
   public void parseResponse(ChallengeResponse cr, 
 Request request, 
 SeriesParameter 
 httpHeaders)
   {
   
 cr.setRawValue(request.getChallengeResponse().getRawValue().replaceFirst(token=,
  ));
   }
 }
 
 Then to the Component I am adding this line:
 
 Engine.getInstance().getRegisteredAuthenticators().add(new 
 MyAuthenticatorHelper());
 
 Why isn't it seeing ny helper?
 
 --
 http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2756279

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