Retrieving multiple query string parameters

2009-08-27 Thread John Prystash
Hello, for the following request in my application:

  .../myresource?source=a&target=b

I'm trying to retrieve both the values of the parameters source and target:

  public class MyResource extends Resource {
  public MyResource(Context context, Request request, Response response) {
  super(context, request, response);
  for(Parameter p : request.getEntityAsForm()) {
  logger.warn("parameter: " + p.getName() + "; value: " + 
p.getValue());
  }
  }
  }

I am using Mule Restlet transport 1.2 and Restlet 1.1.1.

Output:
parameter: source; value: a

I would like to see:
parameter: source; value: a
parameter: target; value: b

Essentially only the first parameter is seen in the query string.  When I ask 
the form for the query string via getQueryString(),
I also only see the first parameter, as in "source=a".

I have also tried the following methods, but I would surmise they're equivalent:

Map parameters = reqeust.getQueryAsForm().getValuesMap();
String source = parameters.get("source");
String target = parameters.get("target");

Also:

Form form = request.getQueryAsForm()
String source = form.getFirstValue("source");
String target = form.getFirstValue("target");

I was wondering if I might be missing something?

Thanks in advance - John

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

Re: Retrieving multiple query string parameters

2009-08-27 Thread John Prystash
Oh my, this is an issue on the client end, not Restlet at all, I apologize for 
potentially wasting anyone's time.





From: John Prystash 
To: discuss@restlet.tigris.org
Sent: Wednesday, August 26, 2009 12:18:26 PM
Subject: Retrieving multiple query string parameters


Hello, for the following request in my application:

  .../myresource?source=a&target=b

I'm trying to retrieve both the values of the parameters source and target:

  public class MyResource extends Resource {
  public MyResource(Context context, Request request, Response response) {
  super(context, request, response);
  for(Parameter p : request.getEntityAsForm()) {
  logger.warn("parameter: " + p.getName() + "; value: " + 
p.getValue());
  }
  }
  }

I am using Mule Restlet transport 1.2 and Restlet 1.1.1.

Output:
parameter: source; value: a

I would like to see:
parameter: source; value: a
parameter: target; value: b

Essentially only the first parameter is seen in the query string.  When I ask 
the form for the query string via getQueryString(),
I also only see the first parameter, as in "source=a".

I have also tried the following methods, but I would surmise they're equivalent:

Map parameters = reqeust.getQueryAsForm().getValuesMap();
String source = parameters.get("source");
String target = parameters.get("target");

Also:

Form form = request.getQueryAsForm()
String source = form.getFirstValue("source");
String target = form.getFirstValue("target");

I was wondering if I might be missing something?

Thanks in advance - John

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

Re: Response for a 405 can't be parsed by SAX

2009-06-15 Thread John Prystash
Thanks for the replies guys.  I definitely don't need to parse it as XML, I'm 
using XMLUnit in my integration testing to compare the responses (my service 
returns XML entities).  Also, our QA tell prefers to compare XML.  So I wasn't 
pointing it out as a shortcoming by any means, just raising the discussion.



- Original Message 
From: Stephan Koops 
To: discuss@restlet.tigris.org
Sent: Sunday, June 14, 2009 7:51:45 AM
Subject: Re: Response for a 405 can't be parsed by SAX

Hi Rhett,
>>> SAX can't parse it because it's HTML, not XML.  ( alone is valid
>>> HTML.)  You should be able to determine whether it is HTML or XML in
>>> your client by examining the content type header.  Is restlet not
>>> setting that header correctly?
>>>
>>> If you want to provide XML-formatted error responses, I believe  
>>> you'll
>>> have to implement them yourself.
>>>  
>> But it is a problem, if Restlet would return  instead od  ?
>> Than it is also correct XML (and XHTML?)
>>
> I wouldn't have a problem with that.  At the same time, though, I  
> don't see why you'd need to parse it as XML.  The message is basically  
> just translating from the error code into English.  Since the error  
> code is already part of the response, doesn't it make more sense to  
> skip parsing the body if there's an error and the service you're  
> talking to doesn't define special error bodies?
>
> After all, if the representation being requested were JSON (or PNG, or  
> PDF, etc.), you'd get this same response body back with the error (by  
> default).  It's not Restlet's job to provide error bodies that are  
> parseable as the same content type as a success would be.
>
> Rhett
You are right. But XML parser will than have no problem with the 
content, also if it is not intended to be used by them. And it's very 
easy to implement. But we could leave it as it is.

best regards
  Stephan

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

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


Response for a 405 can't be parsed by SAX

2009-06-12 Thread John Prystash
Hello Everyone, I had a question about the 405 response message returned by 
Restlet 1.1.1.  When I try a parse the XML response, I get the following:

 [Fatal Error] :8:3: The element type "br" must be terminated by the 
matching end-tag "".

The entire response:



   Status page


The method specified in the request is not allowed for the resource 
identified by the request URIYou can get technical details http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.6";>here.
Please continue your visit at our home page.




I'm sure I can edit the response before it gets out of my service, but I 
thought this might be something useful to bring up.

Thanks for any insight.

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


Setting WWW-Authenticate Header with a 401 Response

2009-04-22 Thread John Prystash
Hello, I'm extending Guard (Restlet 1.1.1) and would like to make sure the 
WWW-Authenticate header back in the Response.  I was wondering if someone could 
recommend a place in my extension that I can override to set the header.

I believe the header is added with setChallengeRequest() but I don't see where 
I have access to the Response, am going about this wrong?

Thanks in advance for any insight.

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


Re: [restlet] request.getEntity().getText() sets the InputStream to null

2009-02-13 Thread John Prystash
Makes perfect sense to me that the enitity be represented as a stream.  
Everythings working fine.  Thanks all.





From: Thierry Boileau 
To: discuss@restlet.tigris.org
Sent: Thursday, February 12, 2009 11:42:18 AM
Subject: Re: [restlet] request.getEntity().getText() sets the InputStream to  
null

Hello John,

as you point the InputRepresentation sets the stream to null in order to 
consider it empty.
The problem with input streams is that they can be read only once. Once 
the bytes are read, you can't get them back, unless you store them 
elsewhere.
That's why you can use a StringRepresentation which stores the bytes in 
memory.

best regards,
Thierry Boileau
> I should of mentioned I had used the approach you mentioned as a 
> "workaround".
>
> Representation entity = new StringRepresentation(text, ...)
> request.setEntity(entity)
>
> So is the call to setStream(null) just to ensure the stream is 
> considered empty?
>
> Thanks
>
> 
> *From:* Stephen Groucutt 
> *To:* discuss@restlet.tigris.org
> *Sent:* Wednesday, February 11, 2009 4:39:55 PM
> *Subject:* Re: [restlet] request.getEntity().getText() sets the 
> InputStream to null
>
> Hi John,
>
> I never tried this, so I'm not sure it works, but just to throw an 
> idea out...
>
> If you must look at the entity body in the Guard, could you try 
> putting the entity into a new representation and using 
> request.setEntity() to put it back on the Request once you were done?  
> I'm assuming that this is text data, so maybe a DOMRepresentation or a 
> StringRepresentation would do?  (This probably would cause your Guard 
> to have to know everything about type negotiation that your resources 
> would - so, maybe not a good idea.)
>
> On Wed, Feb 11, 2009 at 4:33 PM, Stephan Koops  <mailto:stephan.ko...@web.de>> wrote:
>
> Hi John,
>
> if you want to create the entity as String, you have to read the
> String.
> But if it is read, the data is read ... and no available in the Stream
> anymore.
>
> best regards
>   Stephan
>
> John Prystash schrieb:
> > Hey Everyone, I encountered this behavior and was wondering if it is
> > intentional.  I'm sure it is, but if so I was wondering about the
> > reasoning behind it.
> >
> > In my Guard override, during authorize() I need to inspect the
> body of
> > the request:
> >
> > @Override
> >   public boolean authorize(Request request) {
> >  ...
> >  String text= request.getEntity().getText();
> >  ...
> >   }
> >
> >
> > When I get the Resource method, the body is null:
> >
> > @Override
> >   public void post(Representation entity) {
> >   ...
> >   String text = entity.getText(); // is null
> > ...
> >   }
> >
> > From InputRepresentation:
> >
> > @Override
> > public InputStream getStream() throws IOException {
> >  final InputStream result = this.stream;
> >  setStream(null);
> >  return result;
> >   }
> >
> >   @Override
> >   public String getText() throws IOException {
> >   return ByteUtils.toString(getStream(), getCharacterSet());
> >   }
> >
> > I was wondering if the setStream(null) is intended behavior (or
> if I'm
> > abusing the purpose of the Guard) and if so, some background for my
> > education would be much appreciated.  Thanks!
> >
>
> --
>
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1140979
> 
> <http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1140979>
>
>
>

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

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

Re: [restlet] request.getEntity().getText() sets the InputStream to null

2009-02-11 Thread John Prystash
I should of mentioned I had used the approach you mentioned as a "workaround".


Representation entity = new StringRepresentation(text, ...)
request.setEntity(entity)

So is the call to setStream(null) just to ensure the stream is considered empty?

Thanks




From: Stephen Groucutt 
To: discuss@restlet.tigris.org
Sent: Wednesday, February 11, 2009 4:39:55 PM
Subject: Re: [restlet] request.getEntity().getText() sets the InputStream to  
null

Hi John,

I never tried this, so I'm not sure it works, but just to throw an idea out...

If you must look at the entity body in the Guard, could you try putting the 
entity into a new representation and using request.setEntity() to put it back 
on the Request once you were done?  I'm assuming that this is text data, so 
maybe a DOMRepresentation or a StringRepresentation would do?  (This probably 
would cause your Guard to have to know everything about type negotiation that 
your resources would - so, maybe not a good idea.)


On Wed, Feb 11, 2009 at 4:33 PM, Stephan Koops  wrote:

Hi John,

if you want to create the entity as String, you have to read the String.
But if it is read, the data is read ... and no available in the Stream
anymore.

best regards
  Stephan

John Prystash schrieb:

> Hey Everyone, I encountered this behavior and was wondering if it is
> intentional.  I'm sure it is, but if so I was wondering about the
> reasoning behind it.
>
> In my Guard override, during authorize() I need to inspect the body of
> the request:
>
> @Override
>   public boolean authorize(Request request) {
>  ...
>  String text= request.getEntity().getText();
>  ...
>   }
>
>
> When I get the Resource method, the body is null:
>
> @Override
>   public void post(Representation entity) {
>   ...
>   String text = entity.getText(); // is null
> ...
>   }
>
> From InputRepresentation:
>
> @Override
> public InputStream getStream() throws IOException {
>  final InputStream result = this.stream;
>  setStream(null);
>  return result;
>   }
>
>   @Override
>   public String getText() throws IOException {
>   return ByteUtils.toString(getStream(), getCharacterSet());
>   }
>
> I was wondering if the setStream(null) is intended behavior (or if I'm
> abusing the purpose of the Guard) and if so, some background for my
> education would be much appreciated.  Thanks!
>

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

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

[restlet] request.getEntity().getText() sets the InputStream to null

2009-02-11 Thread John Prystash
Hey Everyone, I encountered this behavior and was wondering if it is 
intentional.  I'm sure it is, but if so I was wondering about the reasoning 
behind it.

In my Guard override, during authorize() I need to inspect the body of the 
request:

@Override
  public boolean authorize(Request request) {
 ...
 String text= request.getEntity().getText();
 ...
  }


When I get the Resource method, the body is null:

@Override
  public void post(Representation entity) {
  ...
  String text = entity.getText(); // is null
...
  }

>From InputRepresentation:

   @Override
public InputStream getStream() throws IOException {
 final InputStream result = this.stream;
 setStream(null);
 return result;
  }

  @Override
  public String getText() throws IOException {
  return ByteUtils.toString(getStream(), getCharacterSet());
  }

I was wondering if the setStream(null) is intended behavior (or if I'm abusing 
the purpose of the Guard) and if so, some background for my education would be 
much appreciated.  Thanks!

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

Re: [restlet-user] Retrieving Credentials sent by HttpClient

2009-01-28 Thread John Prystash
I was asked to post a JIRA issue for this with the Mule Restlet Transport
http://www.mulesource.org/jira/browse/RESTLET-9





From: John Prystash 
To: discuss@restlet.tigris.org
Sent: Tuesday, January 27, 2009 8:54:08 PM
Subject: Re: [restlet-user] Retrieving Credentials sent by HttpClient


Thanks for taking a look Jerome.

I've sent an email over to the Mule User list.  I got help with the Mule 
Restlet transport on this list before so I thought this might of been the place 
to try again.

I'll be sure to post back when this is all resolved :)

Here's a link to the Markmail entry for the email:
http://markmail.org/search/?q=prystash+mule-user+credentials#query:prystash%20mule-user%20credentials+page:1+mid:ex4joce6pu3yih2i+state:results





From: Jerome Louvel 
To: discuss@restlet.tigris.org
Sent: Tuesday, January 27, 2009 4:45:29 PM
Subject: RE: [restlet-user] Retrieving Credentials sent by HttpClient


Hi John,
 
I'm puzzled as well. If the header is present it should 
work.
 
It sounds like it is an issue with the way Mule is integrated with 
Restlet. Have you tried contacting the Mule mailing list?
 
Best regards,
Jerome 
Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios 
Technologies ~ Co-founder ~ http://www.noelios.com

 

____
 De : John Prystash 
[mailto:stash1...@yahoo.com] 
Envoyé : lundi 26 janvier 2009 
23:33
À : discuss@restlet.tigris.org
Objet : Re: 
[restlet-user] Retrieving Credentials sent by HttpClient


I do see an Authorization header:

DEBUG  - 
org.restlet.http.headers:[Accept: */*, Authorization: Basic 
aGFyYm9yOmhhcmJvcg==, Host: localhost:28080, User-Agent: 
Noelios-Restlet-Engine/1..1..1]





____
 From: John Prystash 

To: discuss@restlet.tigris.org
Sent: Monday, January 26, 2009 5:12:54 
PM
Subject: Re: [restlet-user] 
Retrieving Credentials sent by HttpClient


To follow-up some more...
I tried using the Restlet Client code provided 
by the example in the tutorial 
(http://www.restlet.org/documentation/1.1/tutorial#part09) and 
went back to using my Guard extension.  In short, the ChallengeResponse() 
appears to always be null when coming through the Mule Restlet Transport 
(unless 
of course I'm missing something).


@Override
public int authenticate(Request request) 
{
ChallengeResponse cr = 
request.getChallengeResponse();
if (cr 
== null) {

logger.debug("ChallengeResponse is 
NULL");
}

...
}

Iterating through 
getSecrets() above gives me the Secrets I set up in my Application class.  
Also, getScheme() returns HTTP_BASIC.

Could I possibly be missing a step 
that invokes the ChallengeResponse from the client?  My relevant client 
code:

Client client = new 
Client(Protocol.HTTP)
Request request = new 
Request(Method.GET, uri)

ChallengeScheme scheme = 
ChallengeScheme.HTTP_BASIC
ChallengeResponse 
authentication = new ChallengeResponse(scheme, username, 
password)

request.setChallengeResponse(authentication)

Response 
response = client.handle(request)


Sorry to 
keep pinging here, but I'm running out of ideas :)


____
 From: John Prystash 

To: discuss@restlet.tigris.org
Sent: Monday, January 26, 2009 10:47:01 
AM
Subject: Re: [restlet-user] 
Retrieving Credentials sent by HttpClient


To follow-up, I tried following the example found in the tutorial and let 
the standard Guard class handle the 
authentication (http://www.restlet.org/documentation/1.1/tutorial#part09).

In 
my Application extension:

 
Guard guard = new 
Guard(getContext(), ChallengeScheme.HTTP_BASIC, REALM);
guard.getSecrets().put("john", "john".toCharArray());
guard.setNext(MyResource.class);

In my client, I set the credentials as before:

def credentials = 
new UsernamePasswordCredentials("john", "john") 
And I get a 401.  
So with this simpler approach where Guard.authenticate() is being invoked, the 
credentials from HttpClient do not seem 
to get noticed:

 
Credentials:
Username: harbor
Password: harbor
 
Response received.
Status: 401
 
Response Body:


   Status 
page


The request requires user 
authenticationYou can get technical details http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2";>here.
Please continue your visit at our home 
page.








 From: John Prystash 

To: discuss@restlet.tigris.org
Sent: Sunday, January 25, 2009 5:40:06 
PM
Subject: [restlet-user] 
Retrieving Credentials sent by HttpClient



Hi, I'm trying to retrieve the credentials set in by HttpClient in my 
Restlet service.
I'm using Mule 2.0.2 with 1.1.3 of the Mule Restlet 
Transport (uses Restlet 1.1.1).

In my Guard class, 
request.getChallengeResponse() is return 

Re: [restlet-user] Retrieving Credentials sent by HttpClient

2009-01-27 Thread John Prystash
Thanks for taking a look Jerome.

I've sent an email over to the Mule User list.  I got help with the Mule 
Restlet transport on this list before so I thought this might of been the place 
to try again.

I'll be sure to post back when this is all resolved :)

Here's a link to the Markmail entry for the email:
http://markmail.org/search/?q=prystash+mule-user+credentials#query:prystash%20mule-user%20credentials+page:1+mid:ex4joce6pu3yih2i+state:results





From: Jerome Louvel 
To: discuss@restlet.tigris.org
Sent: Tuesday, January 27, 2009 4:45:29 PM
Subject: RE: [restlet-user] Retrieving Credentials sent by HttpClient


Hi John,
 
I'm puzzled as well. If the header is present it should 
work.
 
It sounds like it is an issue with the way Mule is integrated with 
Restlet. Have you tried contacting the Mule mailing list?
 
Best regards,
Jerome 
Louvel
--
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
Noelios 
Technologies ~ Co-founder ~ http://www.noelios.com

 

____
 De : John Prystash 
[mailto:stash1...@yahoo.com] 
Envoyé : lundi 26 janvier 2009 
23:33
À : discuss@restlet.tigris.org
Objet : Re: 
[restlet-user] Retrieving Credentials sent by HttpClient


I do see an Authorization header:

DEBUG  - 
org.restlet.http.headers:[Accept: */*, Authorization: Basic 
aGFyYm9yOmhhcmJvcg==, Host: localhost:28080, User-Agent: 
Noelios-Restlet-Engine/1.1..1]





____
 From: John Prystash 

To: discuss@restlet.tigris.org
Sent: Monday, January 26, 2009 5:12:54 
PM
Subject: Re: [restlet-user] 
Retrieving Credentials sent by HttpClient


To follow-up some more...
I tried using the Restlet Client code provided 
by the example in the tutorial 
(http://www.restlet.org/documentation/1.1/tutorial#part09) and 
went back to using my Guard extension.  In short, the ChallengeResponse() 
appears to always be null when coming through the Mule Restlet Transport 
(unless 
of course I'm missing something).


@Override
public int authenticate(Request request) 
{
ChallengeResponse cr = 
request.getChallengeResponse();
if (cr 
== null) {

logger.debug("ChallengeResponse is 
NULL");
}

...
}

Iterating through 
getSecrets() above gives me the Secrets I set up in my Application class.  
Also, getScheme() returns HTTP_BASIC.

Could I possibly be missing a step 
that invokes the ChallengeResponse from the client?  My relevant client 
code:

Client client = new 
Client(Protocol.HTTP)
Request request = new 
Request(Method.GET, uri)

ChallengeScheme scheme = 
ChallengeScheme.HTTP_BASIC
ChallengeResponse 
authentication = new ChallengeResponse(scheme, username, 
password)

request.setChallengeResponse(authentication)

Response 
response = client.handle(request)


Sorry to 
keep pinging here, but I'm running out of ideas :)


____
 From: John Prystash 

To: discuss@restlet.tigris.org
Sent: Monday, January 26, 2009 10:47:01 
AM
Subject: Re: [restlet-user] 
Retrieving Credentials sent by HttpClient


To follow-up, I tried following the example found in the tutorial and let 
the standard Guard class handle the 
authentication (http://www.restlet.org/documentation/1.1/tutorial#part09).

In 
my Application extension:

 
Guard guard = new 
Guard(getContext(), ChallengeScheme.HTTP_BASIC, REALM);
guard.getSecrets().put("john", "john".toCharArray());
guard.setNext(MyResource.class);

In my client, I set the credentials as before:

def credentials = 
new UsernamePasswordCredentials("john", "john") 
And I get a 401.  
So with this simpler approach where Guard.authenticate() is being invoked, the 
credentials from HttpClient do not seem 
to get noticed:

 
Credentials:
Username: harbor
Password: harbor
 
Response received.
Status: 401
 
Response Body:


   Status 
page


The request requires user 
authenticationYou can get technical details http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2";>here.
Please continue your visit at our home 
page.








 From: John Prystash 

To: discuss@restlet.tigris.org
Sent: Sunday, January 25, 2009 5:40:06 
PM
Subject: [restlet-user] 
Retrieving Credentials sent by HttpClient



Hi, I'm trying to retrieve the credentials set in by HttpClient in my 
Restlet service.
I'm using Mule 2.0.2 with 1.1.3 of the Mule Restlet 
Transport (uses Restlet 1.1.1).

In my Guard class, 
request.getChallengeResponse() is return null.

My Guard 
extension:

public class MyGuard extends Guard 
{


@Override
public int 
authenticate(Request request) 
{
 
...
 
ChallengeResponse cr = request.getChallengeResponse(); // is null 
here
 
...
}

}

My Application class:

public class 
MyApplic

Re: [restlet-user] Retrieving Credentials sent by HttpClient

2009-01-26 Thread John Prystash
I do see an Authorization header:

DEBUG  - org.restlet.http.headers:[Accept: */*, Authorization: Basic 
aGFyYm9yOmhhcmJvcg==, Host: localhost:28080, User-Agent: 
Noelios-Restlet-Engine/1.1..1]






From: John Prystash 
To: discuss@restlet.tigris.org
Sent: Monday, January 26, 2009 5:12:54 PM
Subject: Re: [restlet-user] Retrieving Credentials sent by HttpClient


To follow-up some more...
I tried using the Restlet Client code provided by the example in the tutorial 
(http://www.restlet.org/documentation/1.1/tutorial#part09) and went back to 
using my Guard extension.  In short, the ChallengeResponse() appears to always 
be null when coming through the Mule Restlet Transport (unless of course I'm 
missing something).

@Override
public int authenticate(Request request) {
ChallengeResponse cr = request.getChallengeResponse();
if (cr == null) {
logger.debug("ChallengeResponse is NULL");
}
...
}

Iterating through getSecrets() above gives me the Secrets I set up in my 
Application class.  Also, getScheme() returns HTTP_BASIC.

Could I possibly be missing a step that invokes the ChallengeResponse from the 
client?  My relevant client code:

Client client = new Client(Protocol.HTTP)
Request request = new Request(Method.GET, uri)

ChallengeScheme scheme = ChallengeScheme.HTTP_BASIC
ChallengeResponse authentication = new ChallengeResponse(scheme, username, 
password)
request.setChallengeResponse(authentication)

Response response = client.handle(request)


Sorry to keep pinging here, but I'm running out of ideas :)


____
From: John Prystash 
To: discuss@restlet.tigris.org
Sent: Monday, January 26, 2009 10:47:01 AM
Subject: Re: [restlet-user] Retrieving Credentials sent by HttpClient


To follow-up, I tried following the example found in the tutorial and let the 
standard Guard class handle the authentication 
(http://www.restlet.org/documentation/1.1/tutorial#part09).

In my Application extension:

 
Guard guard = new Guard(getContext(),
ChallengeScheme.HTTP_BASIC, REALM);
guard.getSecrets().put("john",
"john".toCharArray());
guard.setNext(MyResource.class);

In my client, I set the credentials as before:

def credentials = new UsernamePasswordCredentials("john", "john") 
And I get a 401.  So with this simpler approach where Guard.authenticate() is 
being invoked, the credentials from HttpClient do not seem to get noticed:

 
Credentials:
Username: harbor
Password: harbor
 
Response received.
Status: 401
 
Response Body:


   Status page


The request requires user
authenticationYou can get technical details http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2";>here.
Please continue your visit at our home page.








From: John Prystash 
To: discuss@restlet.tigris.org
Sent: Sunday, January 25, 2009 5:40:06 PM
Subject: [restlet-user] Retrieving Credentials sent by HttpClient



Hi, I'm trying to retrieve the credentials set in by HttpClient in my Restlet 
service.
I'm using Mule 2.0.2 with 1.1.3 of the Mule Restlet Transport (uses Restlet 
1.1.1).

In my Guard class, request.getChallengeResponse() is return null.

My Guard extension:

public class MyGuard extends Guard {

@Override
public int authenticate(Request request) {
 ...
 ChallengeResponse cr = request.getChallengeResponse(); // is null 
here
 ...
}
}

My Application class:

public class MyApplication extends Application {
@Override
public Restlet createRoot() {
Guard guard = new MyGuard(getContext(), ChallengeScheme.HTTP_BASIC, 
"someRealm");
guard.setNext(MyResource.class);
...
}
}

I'm using HttpClient 3.1 (with Groovy) as my users will be:

def client = new HttpClient()
def httpMethod = new GetMethod(uri)

def authScope = new AuthScope(null, -1, "someRealm")
def credentials = new UsernamePasswordCredentials(username, password) 

client.getState().setCredentials(authScope, credentials);

// these lines print out what I expect
println "Username: " + 
client.getState().getCredentials(authScope).getUserName()
println "Password: " + 
client.getState().getCredentials(authScope).getPassword()

httpMethod.setDoAuthentication(true)
statusCode = client.executeMethod(httpMethod);

I found a similar posting here:
http://markmail.org/message/6n7hjc3pmbg7vcg5#query:restlet%20httpclient%20credentials+page:1+mid:5y3ldjbvcvwxaysp+state:results

Thanks for advance for any insight.

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

Re: [restlet-user] Retrieving Credentials sent by HttpClient

2009-01-26 Thread John Prystash
To follow-up some more...
I tried using the Restlet Client code provided by the example in the tutorial 
(http://www.restlet.org/documentation/1.1/tutorial#part09) and went back to 
using my Guard extension.  In short, the ChallengeResponse() appears to always 
be null when coming through the Mule Restlet Transport (unless of course I'm 
missing something).

@Override
public int authenticate(Request request) {
ChallengeResponse cr = request.getChallengeResponse();
if (cr == null) {
logger.debug("ChallengeResponse is NULL");
}
...
}

Iterating through getSecrets() above gives me the Secrets I set up in my 
Application class.  Also, getScheme() returns HTTP_BASIC.

Could I possibly be missing a step that invokes the ChallengeResponse from the 
client?  My relevant client code:

Client client = new Client(Protocol.HTTP)
Request request = new Request(Method.GET, uri)

ChallengeScheme scheme = ChallengeScheme.HTTP_BASIC
ChallengeResponse authentication = new ChallengeResponse(scheme, username, 
password)
request.setChallengeResponse(authentication)

Response response = client.handle(request)


Sorry to keep pinging here, but I'm running out of ideas :)


____
From: John Prystash 
To: discuss@restlet.tigris.org
Sent: Monday, January 26, 2009 10:47:01 AM
Subject: Re: [restlet-user] Retrieving Credentials sent by HttpClient


To follow-up, I tried following the example found in the tutorial and let the 
standard Guard class handle the authentication 
(http://www.restlet.org/documentation/1.1/tutorial#part09).

In my Application extension:

 
Guard guard = new Guard(getContext(),
ChallengeScheme.HTTP_BASIC, REALM);
guard.getSecrets().put("john",
"john".toCharArray());
guard.setNext(MyResource.class);

In my client, I set the credentials as before:

def credentials = new UsernamePasswordCredentials("john", "john") 
And I get a 401.  So with this simpler approach where Guard.authenticate() is 
being invoked, the credentials from HttpClient do not seem to get noticed:

 
Credentials:
Username: harbor
Password: harbor
 
Response received.
Status: 401
 
Response Body:


   Status page


The request requires user
authenticationYou can get technical details http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2";>here.
Please continue your visit at our home page.








From: John Prystash 
To: discuss@restlet.tigris.org
Sent: Sunday, January 25, 2009 5:40:06 PM
Subject: [restlet-user] Retrieving Credentials sent by HttpClient



Hi, I'm trying to retrieve the credentials set in by HttpClient in my Restlet 
service.
I'm using Mule 2.0.2 with 1.1.3 of the Mule Restlet Transport (uses Restlet 
1.1.1).

In my Guard class, request.getChallengeResponse() is return null.

My Guard extension:

public class MyGuard extends Guard {

@Override
public int authenticate(Request request) {
 ...
 ChallengeResponse cr = request.getChallengeResponse(); // is null 
here
 ...
}
}

My Application class:

public class MyApplication extends Application {
@Override
public Restlet createRoot() {
Guard guard = new MyGuard(getContext(), ChallengeScheme.HTTP_BASIC, 
"someRealm");
guard.setNext(MyResource.class);
...
}
}

I'm using HttpClient 3.1 (with Groovy) as my users will be:

def client = new HttpClient()
def httpMethod = new GetMethod(uri)

def authScope = new AuthScope(null, -1, "someRealm")
def credentials = new UsernamePasswordCredentials(username, password) 

client.getState().setCredentials(authScope, credentials);

// these lines print out what I expect
println "Username: " + 
client.getState().getCredentials(authScope).getUserName()
println "Password: " + 
client.getState().getCredentials(authScope).getPassword()

httpMethod.setDoAuthentication(true)
statusCode = client.executeMethod(httpMethod);

I found a similar posting here:
http://markmail.org/message/6n7hjc3pmbg7vcg5#query:restlet%20httpclient%20credentials+page:1+mid:5y3ldjbvcvwxaysp+state:results

Thanks for advance for any insight.

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

Re: [restlet-user] Retrieving Credentials sent by HttpClient

2009-01-26 Thread John Prystash
To follow-up, I tried following the example found in the tutorial and let the 
standard Guard class handle the authentication 
(http://www.restlet.org/documentation/1.1/tutorial#part09).

In my Application extension:


Guard guard = new Guard(getContext(),
ChallengeScheme.HTTP_BASIC, REALM);
guard.getSecrets().put("john",
"john".toCharArray());
guard.setNext(MyResource.class);

In my client, I set the credentials as before:

def credentials = new UsernamePasswordCredentials("john", "john") 
And I get a 401.  So with this simpler approach where Guard.authenticate() is 
being invoked, the credentials from HttpClient do not seem to get noticed:


Credentials:
Username: harbor
Password: harbor
 
Response received.
Status: 401
 
Response Body:


   Status page


The request requires user
authenticationYou can get technical details http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.2";>here.
Please continue your visit at our home page.








From: John Prystash 
To: discuss@restlet.tigris.org
Sent: Sunday, January 25, 2009 5:40:06 PM
Subject: [restlet-user] Retrieving Credentials sent by HttpClient



Hi, I'm trying to retrieve the credentials set in by HttpClient in my Restlet 
service.
I'm using Mule 2.0.2 with 1.1.3 of the Mule Restlet Transport (uses Restlet 
1.1.1).

In my Guard class, request.getChallengeResponse() is return null.

My Guard extension:

public class MyGuard extends Guard {

@Override
public int authenticate(Request request) {
 ...
 ChallengeResponse cr = request.getChallengeResponse(); // is null 
here
 ...
}
}

My Application class:

public class MyApplication extends Application {
@Override
public Restlet createRoot() {
Guard guard = new MyGuard(getContext(), ChallengeScheme.HTTP_BASIC, 
"someRealm");
guard.setNext(MyResource.class);
...
}
}

I'm using HttpClient 3.1 (with Groovy) as my users will be:

def client = new HttpClient()
def httpMethod = new GetMethod(uri)

def authScope = new AuthScope(null, -1, "someRealm")
def credentials = new UsernamePasswordCredentials(username, password) 

client.getState().setCredentials(authScope, credentials);

// these lines print out what I expect
println "Username: " + 
client.getState().getCredentials(authScope).getUserName()
println "Password: " + 
client.getState().getCredentials(authScope).getPassword()

httpMethod.setDoAuthentication(true)
statusCode = client.executeMethod(httpMethod);

I found a similar posting here:
http://markmail.org/message/6n7hjc3pmbg7vcg5#query:restlet%20httpclient%20credentials+page:1+mid:5y3ldjbvcvwxaysp+state:results

Thanks for advance for any insight.

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

[restlet-user] Retrieving Credentials sent by HttpClient

2009-01-25 Thread John Prystash
Hi, I'm trying to retrieve the credentials set in by HttpClient in my Restlet 
service.
I'm using Mule 2.0.2 with 1.1.3 of the Mule Restlet Transport (uses Restlet 
1.1.1).

In my Guard class, request.getChallengeResponse() is return null.

My Guard extension:

public class MyGuard extends Guard {

@Override
public int authenticate(Request request) {
 ...
 ChallengeResponse cr = request.getChallengeResponse(); // is null 
here
 ...
}
}

My Application class:

public class MyApplication extends Application {
@Override
public Restlet createRoot() {
Guard guard = new MyGuard(getContext(), ChallengeScheme.HTTP_BASIC, 
"someRealm");
guard.setNext(MyResource.class);
...
}
}

I'm using HttpClient 3.1 (with Groovy) as my users will be:

def client = new HttpClient()
def httpMethod = new GetMethod(uri)

def authScope = new AuthScope(null, -1, "someRealm")
def credentials = new UsernamePasswordCredentials(username, password) 

client.getState().setCredentials(authScope, credentials);

// these lines print out what I expect
println "Username: " + 
client.getState().getCredentials(authScope).getUserName()
println "Password: " + 
client.getState().getCredentials(authScope).getPassword()

httpMethod.setDoAuthentication(true)
statusCode = client.executeMethod(httpMethod);

I found a similar posting here:
http://markmail.org/message/6n7hjc3pmbg7vcg5#query:restlet%20httpclient%20credentials+page:1+mid:5y3ldjbvcvwxaysp+state:results

Thanks for advance for any insight.

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

Re: [restlet] Receiving generic OK Response in Client

2009-01-07 Thread John Prystash
With version 1.1.2 of the Mule Restlet transport using Mule 2.1.2, I'm able to 
get the actual status code in my response:

Response received.
Status: 201





From: Thierry Boileau 
To: discuss@restlet.tigris.org
Sent: Wednesday, November 12, 2008 9:56:29 AM
Subject: Re: [restlet] Receiving generic OK Response in Client

Hello all,

I've just tried in standalone mode and inside a servlet container
(tomcat 6.0.18) with Restlet 1.0.8, it works fine.
Let's try with Mule.

Best regards,
Thierry Boileau
--
Restlet
~ Core developer ~ http://www.restlet.org
Noelios Technologies ~ Co-founder ~ http://www.noelios.com

 
Thanks
for the quick response.
I do get text in the response, more client code:

if
(response.getStatus().isSuccess()) {
   
if (response.isEntityAvailable()) {
   
println "Retrieved entity:"
   
response.getEntity().write(System.out)
   
}
}

Which gives me the posted entity, in my client output:

   
Retrieved entity:
   
...

I'm using Mule as my container, and the following relevant jars are in
my client has the following jars (maybe I'm missing one, silly because
there are no errors but you never know):

com.noelios.restlet:com.noelios.restlet:jar:1.0.8
   
com.noelios.restlet:com.noelios.restlet.ext.httpclient:jar:1.0.8
   
commons-codec:commons-codec:jar:1.3
   
commons-httpclient:commons-httpclient:jar:3.1
   
org.restlet:org.restlet:jar:1.0.8

In my container, I have mule-restlet-transport-1.0-M3 and Mule 2.0.2,
the client example in the user guide was not working for me at all
quite frankly, so I decided to simplify things and follow the Restlet
client example.

Just noticed now the user guide was updated, and new version of the
transport is out 1.1.2 for Mule 2.1.0.  I could try it out if this
might be a container/server issue...

http://mule.mulesource.org/display/RESTLET/User%27s+Guide








From: Rob
Heittman 
To: discuss@restlet.tigris.org
Sent: Wednesday,
November 12, 2008 8:54:31 AM
Subject: Re: [restlet]
Receiving generic OK Response in Client

Is there any actual text in the response?  The only time I have seen
this in the past is where some versions of Tomcat will send a generic
200 response if a zero length or empty entity is submitted.  This may
or may not be relevant.  Which connector are you using?

On Wed, Nov 12, 2008 at 8:40 AM, John Prystash  wrote:
> I always get the following output from the client.  OK is always
the status
> regardless of what I set as the code in my post() method.  The
Resource does
> get posted/persisted during the request.
>
>Response received.
>Status: OK (200)
>Successful: true

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

Re: [restlet] Receiving generic OK Response in Client

2008-11-12 Thread John Prystash
Thanks for the quick response.
I do get text in the response, more client code:

if (response.getStatus().isSuccess()) {
if (response.isEntityAvailable()) {
println "Retrieved entity:"
response.getEntity().write(System.out)
}
}

Which gives me the posted entity, in my client output:

Retrieved entity:
...

I'm using Mule as my container, and the following relevant jars are in my 
client has the following jars (maybe I'm missing one, silly because there are 
no errors but you never know):

com.noelios.restlet:com.noelios.restlet:jar:1.0.8
com.noelios.restlet:com.noelios.restlet.ext.httpclient:jar:1.0.8
commons-codec:commons-codec:jar:1.3
commons-httpclient:commons-httpclient:jar:3.1
org.restlet:org.restlet:jar:1.0.8

In my container, I have mule-restlet-transport-1.0-M3 and Mule 2.0.2, the 
client example in the user guide was not working for me at all quite frankly, 
so I decided to simplify things and follow the Restlet client example.

Just noticed now the user guide was updated, and new version of the transport 
is out 1.1.2 for Mule 2.1.0.  I could try it out if this might be a 
container/server issue...

http://mule.mulesource.org/display/RESTLET/User%27s+Guide








From: Rob Heittman <[EMAIL PROTECTED]>
To: discuss@restlet.tigris.org
Sent: Wednesday, November 12, 2008 8:54:31 AM
Subject: Re: [restlet] Receiving generic OK Response in Client

Is there any actual text in the response?  The only time I have seen
this in the past is where some versions of Tomcat will send a generic
200 response if a zero length or empty entity is submitted.  This may
or may not be relevant.  Which connector are you using?

On Wed, Nov 12, 2008 at 8:40 AM, John Prystash <[EMAIL PROTECTED]> wrote:
> I always get the following output from the client.  OK is always the status
> regardless of what I set as the code in my post() method.  The Resource does
> get posted/persisted during the request.
>
> Response received.
> Status: OK (200)
> Successful: true



  

[restlet] Receiving generic OK Response in Client

2008-11-12 Thread John Prystash

Hi, my override of Resource.post() I setup the response much like the examples 
in the documentation.  Unfortunately, on the client side I am not getting same 
information in my Response object.  I am using Restlet 1.0.8 that comes with 
the Mule Restlet Transport.

The relevant code from my post() method in my extensions of Resource:

@Override
public void post(Representation entity) {
   
// ...
// the entity has been persisted...
// ...

getResponse().setStatus(Status.SUCCESS_CREATED);
Representation representation = new StringRepresentation(mapText, 
MediaType.TEXT_XML);

representation.setIdentifier(getRequest().getResourceRef().getIdentifier() + 
"/" + map.getId());   
getResponse().setEntity(representation);
   
if (logger.isDebugEnabled()) {
logger.debug("Response object created.");
logger.debug("Status: " + getResponse().getStatus());
logger.debug("Identifier: " + 
getResponse().getEntity().getIdentifier());
}
}

On the client side (Groovy but I get the same results in Java):

Representation representation = new StringRepresentation(mapText, 
MediaType.TEXT_XML)
Response response = client.post(uri, representation)

println "Status: " + response.getStatus()
println "Successful: " + response.getStatus().isSuccess()
println "Identifier: " + response.getEntity().getIdentifier()

I always get the following output from the client.  OK is always the status 
regardless of what I set as the code in my post() method.  The Resource does 
get posted/persisted during the request.

Response received.
Status: OK (200)
Successful: true

And a null pointer on the call to response.getEntity().getIdentifier().
The logging statements in my post method verify that I appear to have setup the 
response correctly:

Verifying response.
Status: Created (201)
Identifier: /services/myService/map/26

Essentially, it appears that I'm getting a generic OK-related Response object, 
the one I setup is not the one I appear to receive, am I maybe missing 
something on the client side?

Thanks in advance for any insight.