Switch Guards

2012-02-08 Thread Sebastian Wenninger
Hi!

Our App has some Resources guarded by an Authenticator which uses our own
Challenge Scheme (OAuth-Mac-Tokens).
Now we also want to have clients, who can access the same resources but not
using the Mac-Tokens, but plain Bearer-Tokens.
The way i would do this, is to create a new Challenge Scheme and a second
guard, and dynamically switch the guards before the route depending on what
Challenge Scheme a request uses.
Unfortunately I don't know if this is possible or how I can do this.
Can somebody point me in the right direction?

Regards,
Sebastian

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/Switch-Guards-tp7266201p7266201.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


RE: SSL on Google App Engine

2011-11-07 Thread Sebastian Wenninger
Hi Jerome,

thanks you're absolutely right of course.
I added this lines to my web.xml and now it demands a certificate when
accessing the Rest-services:



HTTPS Rest
/rest/*


CONFIDENTIAL



--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/SSL-on-Google-App-Engine-tp6954679p6970990.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


SSL on Google App Engine

2011-11-02 Thread Sebastian Wenninger
Hi!

I want to secure my Rest-Application on the Google App-Engine by only
allowing calls via HTTPS/SSL.
Because i didn't really know how to do this, i first removed the
HTTP-Connector from the list of available connectors in my web.xml.


RestletServlet
org.restlet.ext.servlet.ServerServlet

org.restlet.application
de.server.rest.ServiceApp



   
   org.restlet.clients
  HTTPS FILE
   


It's still possible to access my webservice via plain HTTP though.
What do i have to do to only allow HTTPS?
Do i have to provide my own SSL-Certificate, or does somebody know a way to
use the certificate provided by the appspot.com Domain?

Best Regards,
Sebastian


--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/SSL-on-Google-App-Engine-tp6954679p6954679.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Bug in 2.1M5

2011-08-11 Thread Sebastian Wenninger
Hi!
I have a ServerResource that looks like this:

@Post
public Representation store(Product product) {
ProductService service =
MyThreadLocal.getServiceFactory().productService();
if (null == getRequestAttributes().get("id")) {
Set> violations =
service.validate(product);
if (violations.size() == 0) {
product = service.create(product);
MyJacksonRepresentation response = new 
   
MyJacksonRepresentation(product);
setStatus(Status.SUCCESS_CREATED);
return response;
} else {
setStatus(Status.CLIENT_ERROR_BAD_REQUEST);
JSONObject response = new JSONObject();
try {
response.put("error", "Validation of 
this Product failed");
for (ConstraintViolation cv : 
violations) {
response.append("Violations", 
cv.getPropertyPath().toString() + " " +
cv.getMessage());
}
JsonRepresentation res = new 
JsonRepresentation(response);
return res;
} catch (JSONException e) {
setStatus(Status.SERVER_ERROR_INTERNAL, 
"Error generating the
Json-Error response.");
return null;
}
}
} else {
setStatus(Status.CLIENT_ERROR_BAD_REQUEST, "You must 
not provide an id
when creating a new Product.");
return null;
}
}

When i use Restlet 2.1 Milestone5 and Post an invalid Product-Json, i get a
Response with a 400 Status Code (as expected), but an empty Response body.
However, if i use Restlet 2.0.8 i get the correct JSON Response.
Don't know what, but something seems to be wrong (or just different) in M5
that causes this behaviour...
Someone here knows what it could be?

Regards,
Sebastian

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/Bug-in-2-1M5-tp6676452p6676452.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


RE: Re: IncompatibleClassChangeError with ConcurrentMap

2011-06-13 Thread Sebastian Wenninger
Thierry Boileau wrote:
> 
> Hello Sebastian,
> 
> you can also simplify your code as follow:
> 
> import org.json.JSONException;
> import org.json.JSONObject;
> import org.restlet.resource.Get;
> import org.restlet.resource.ServerResource;
> 
> public class TestJsonServerResource extends ServerResource {
> @Get
> public JSONObject doGet() throws JSONException {
> JSONObject json = new JSONObject();
> json.put("test", "Test");
> json.put("test2", "Test2");
> return json;
> }
> }
> 
> (please note that this simplification is not part of the zip file I've
> just sent to you.)
> 
> Best regards,
> Thierry Boileau
> 
> --
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2763663
> 

Hi Thierry,

unfortunately i din't get any zip file.
Yes i know i can write it like that, and it would work too.
But this way the headers are not set to application/json but to text/plain. 
http://restlet-discuss.1400322.n2.nabble.com/IncompatibleClassChangeError-with-ConcurrentMap-tp6393712p6453417.html
See here. 
When you run my code, is the field JsonValue in the JsonRepresentation set?

Best Regards,
Sebastian


--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/IncompatibleClassChangeError-with-ConcurrentMap-tp6393712p6469478.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Re: IncompatibleClassChangeError with ConcurrentMap

2011-06-12 Thread Sebastian Wenninger
Hi,

attached is a very simple code.
I ran it on the local gae environment.
When i create the JsonRepresentation, it's JsonValue is empty...
That's not the same behaviour as in my other project, but maybe that's
somehow causing the error.

Best Regards,
Sebastian

http://restlet-discuss.1400322.n2.nabble.com/file/n6466814/src.zip src.zip 

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/IncompatibleClassChangeError-with-ConcurrentMap-tp6393712p6466814.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Re: IncompatibleClassChangeError with ConcurrentMap

2011-06-08 Thread Sebastian Wenninger
Sorry for posting multiple responses...when i have time i'll try to create a
simple sample Project.
Today i debugged further into it, and it just gets stranger.
Until JsonRepresentation.write(Writer writer) all seems fine. 
writer.write() is called with the right JsonText at line 322.
But after this my Text somehow gets lost in the depths of Java.io and i
really don't see why.
I also tried it on another pc, but it didn't work there either.
When i change my ServerResource to return just the JSONObject, i get the
Text output, but 
the MediaType is set to text/plain because the JsonConverter uses
StringRepresentation.
Is there a way to change the MediaType of the JsonConverter?

Best Regards,
Sebastian

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/IncompatibleClassChangeError-with-ConcurrentMap-tp6393712p6453417.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Re: IncompatibleClassChangeError with ConcurrentMap

2011-06-07 Thread Sebastian Wenninger
Thierry Boileau wrote:
> 
> Hello Sebastian,
> 
>>What do you mean by sending the client code?
> I meant, either the line of codes of the java client, or the curl command
> line.
> 
> As I really don't realize what is wrong, can you provide a sample eclipse
> project?
> 
> Best regards,
> Thierry Boileau
> 
> --
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2759662
> 

Hello Thierry,

i have to ask my person in charge tomorrow if it's alright to share some
sample code.
Some thing i noticed is that the size property of the JsonRepresentation is
set to -1.
Maybe that's the problem?
Here's what the JsonRepresentation looks like:

available=true
characterSet=UTF-8
encodings=[]
indenting=false
indentingSize=3
isTransient=false
jsonRepresentation=null
jsonValue=JSONObject {"count":2}
languages=[]
mediaType=application/json
size=-1


swenninger wrote:
> 
> But at least i think i found what's causing the error:
> In the ConverterUtils class the method getBestHelper(Object source,
> Variant target,UniformResource resource) is called and hence the
> DefaultConverter is used instead of the JsonConverter...
> I think what should be called is getBestHelper(Representation
> source,Class target, UniformResource resource).
> Don't know yet why it's called like this though.
> 

Hmm...of course that's not the problem either.
DefaultConverter is used for Representations,and it returns a valid
JsonRepresentation with a jsonValue set to my JSONObject.
That's returned by the ServerResource in doHandle() later and is also set as
the Response-Entity...
I'm really hitting the end of the road here. 




--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/IncompatibleClassChangeError-with-ConcurrentMap-tp6393712p6451358.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Re: IncompatibleClassChangeError with ConcurrentMap

2011-06-07 Thread Sebastian Wenninger
Thierry Boileau wrote:
> 
> Hello Sebastian,
> 
> could you send the client code (java, gwt or curl?) It should precise the
> client preferences.
> If you have difficulties to set the preferences, could you try to add this
> query parameter to the resource's uri? : media=json
> 
> best regards,
> Thierry Boileau
> 
> http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2759649
> 

Hello Thierry,

tried adding the media=json query...doesn't change anything.
What do you mean by sending the client code?
Do you want to know which client i use to access the resource?
That's Google Chrome atm. But i tried also with curl.
What i get back is an empty page and the following headers:

Date: Tue, 07 Jun 2011 19:55:41 GMT
Transfer-Encoding: chunked
Server: Restlet-Framework/2.1snapshot
Vary: Accept-Charset, Accept-Encoding, Accept-Language, Accept
Content-Type: application/json; charset=UTF-8
Accept-Ranges: bytes

And Http-Status 200.

Best Regards,
Sebastian


--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/IncompatibleClassChangeError-with-ConcurrentMap-tp6393712p6451153.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Re: IncompatibleClassChangeError with ConcurrentMap

2011-06-07 Thread Sebastian Wenninger
wrote:
> Regarding you second issue - my code looks slightly different and provides
> valid json representation back. Maybe this works for you as well.
> Actually I'm not creating the JSONRepresentation by myself but just
> provide pure Java Objects back. The JSON-serialization is then handled by
> restlet itself. I'm using the Jackson-extension.
> 

Thanks, but my JacksonRepresentation works fine. I just want to create some
small Json to send back some Error codes, or OAuth Tokens for example.


Jason Guild-2 wrote:
> 
> Hi Sebastian:
> 
> I am using JsonRepresentation and it works just fine.
> 
> Did you enable JSON by addding the variant in the constructor of your
> resource?
> getVariants().add(new Variant(MediaType.APPLICATION_JSON));
> 
> And maybe your annotation should be @Get("json") as well.
> 
> Hope that helps,
> Jason
> 
 
Tried adding the Annotation and overriding doInit()...nothing works. 
But at least i think i found what's causing the error:
In the ConverterUtils class the method getBestHelper(Object source, Variant
target,UniformResource resource) is called and hence the DefaultConverter is
used instead of the JsonConverter...
I think what should be called is getBestHelper(Representation
source,Class target, UniformResource resource).
Don't know yet why it's called like this though.



--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/IncompatibleClassChangeError-with-ConcurrentMap-tp6393712p6451068.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Re: IncompatibleClassChangeError with ConcurrentMap

2011-06-07 Thread Sebastian Wenninger
I don't want to seem impatient, but this is a crucial part of my bachelor's
thesis, so i don't have that much time to solve it.
At least, can somebody else confirm that JsonRepresentations don't work
properly so i can exclude an error for my part?

Thanks,
Sebastian

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/IncompatibleClassChangeError-with-ConcurrentMap-tp6393712p6449749.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Re: Servlet integration with Restlet 2.0

2011-06-05 Thread Sebastian Wenninger
Hi,

according to the 
http://www.restlet.org/documentation/2.0/jee/ext/org/restlet/ext/servlet/ServerServlet.html
docs  it's org.restlet.ext.servlet.ServerServlet

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/Servlet-integration-with-Restlet-2-0-tp6440596p6442263.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Running First Application

2011-06-05 Thread Sebastian Wenninger
Hi!
Im having some problems getting the First Application example to run.
At first there was this 
http://restlet-discuss.1400322.n2.nabble.com/IncompatibleClassChangeError-with-ConcurrentMap-tp6393712p642.html
issue .

After upgrading the libs, i got this Error:

[WARN] No available client connector supports the required protocols: 'FILE'
. Please add the JAR of a matching connector to your classpath.

Resolved it by removing the FILE Client-Connector from the web.xml.
Now hitting the Get-Button gives me this: Can't parse the enclosed entity.
So it looks like something went wrong within the Jackson extension.
However, i couldn't find out what's causing the error so far.
Has anybody else experienced this before?

Thanks in advance,
Sebastian


--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/Running-First-Application-tp6442251p6442251.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Re: IncompatibleClassChangeError with ConcurrentMap

2011-06-03 Thread Sebastian Wenninger
Hello Thierry,

Thanks, i haven't tried it yet but im sure it will work now.

However, since i added the new Snapshot to my Project, i don't get any
JsonObjects back with an JsonRepresentation...
My methods all look like this:

@Get
public Representation get(){
JsonRepresentation response = new JsonRepresentation(SomeJsonObject);
getResponse().setStatus(Status.SUCCESS_OK);
return response;
}

When called, all i get is an Empty page in my browser, not even empty curly
brackets.
Curl doesn't give me anything either.
The Status is correctly set, as well as the JsonRepresentation as the
Response's Entity though.
Any ideas?

Best Regards,
Sebastian

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/IncompatibleClassChangeError-with-ConcurrentMap-tp6393712p6435505.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Re: Error in returning a list on Get Method

2011-06-03 Thread Sebastian Wenninger
Maybe you could try returning a JSONArray containing all the JSONObjects in
the List instead.

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/Error-in-returning-a-list-on-Get-Method-tp6412562p6435097.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


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=4447&dsMessageId=2756726


Re: error 415 while posting json

2011-06-01 Thread Sebastian Wenninger
When your Method looks like this:

@Post("json")
public void doPost(){...}

you have to set the Content-Type header of your Request to application/json



--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/error-415-while-posting-json-tp6418843p6427317.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Re: Using cURL to access OAuth protected resources

2011-05-31 Thread Sebastian Wenninger
It should be possible if you have a proper Token and know exactly how to
provide it (in the Headers, the Post-Body...) to your resource.
Depends on the Provider i guess.
You can also look at the  http://tools.ietf.org/html/draft-ietf-oauth-v2-16
OAuth-Specification 
for further information.

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/Using-cURL-to-access-OAuth-protected-resources-tp6419891p6421751.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Re: IncompatibleClassChangeError with ConcurrentMap

2011-05-31 Thread Sebastian Wenninger
Nobody got an idea?
It's also odd that i can run the testGWTRestlet-2.0 project without
problems.
Maybe because of the launch-Script provided with it?

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/IncompatibleClassChangeError-with-ConcurrentMap-tp6393712p6421735.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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