Re: fine grained authorization based on DN/X.509

2011-06-07 Thread lambda daku
Thanks for the reply.

I have few comments on your reply. 

Usually the certificate received at the server side has atleast 2
certificates - one is a public key of the client and the rest are n
trusted entries (in my case it is 1). 

As you have mentioned about the getRequest() method, where do you access it
in a resource or in a application class? I am intercepting the requests in
an application class (which extends from JaxRsApplication),  whereby I am
overriding the handle(req,res) method and and getting the desired
attributes, is the following were you referring to?:

public class MyJaxRsApplication extends JaxRsApplication{

@Override
public void handle(Request request, Response response) {
 Maplt;String, Objectgt; map = request.getAttributes();
 @SuppressWarnings(unchecked)
 ListX509Certificate lst =  (ListX509Certificate)
map.get(org.restlet.https.clientCertificates);
 //however the first item in the above list is the user's public key
 //here, delegation to the authorization PEP, PAP and PIP will be made
}
..

}


Many thanks
Daku

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/fine-grained-authorization-based-on-DN-X-509-tp6444949p6448938.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Is JAX-RS in Restlet experimental?

2011-06-07 Thread lambda daku
Hi,

I have just found while checking out jaxrs and test project's source code,
where the author is clearly stating that the support for jaxrs within
restlet is experimental. I wish if this is a typo which author (Mr. Koops)
forgot to omit.

Could you please confirm?

Daku

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/Is-JAX-RS-in-Restlet-experimental-tp6449217p6449217.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


fine grained authorization based on DN/X.509

2011-06-06 Thread lambda daku
Hi,

I have a Restlet application running on jetty usiing https (with client side
authn). The required behavior is to intercept the client request and extract
the DN on the server side (in-bound), on which the authorization will take
place. Whereby the DN/x.509 would be matched against some external entity
(ldap) where the DN/x.509 certs are stored.

Is there any standard way to add interceptors on the client as well as on
the server side to authorize the user based on a particular DN/x.509 or any
other credential?

Thanks
Daku



--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/fine-grained-authorization-based-on-DN-X-509-tp6444949p6444949.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Re: error 415 while posting json

2011-06-02 Thread lambda daku
I am not using the native restlet api for the resource interface but the
jax-rs annotations, which should be defined as:

@POST
@Consumes(MediaType.JSON)
public void doPost(JSONObject jo){


consequently the exception is being thrown at the client side. Thus, what
helps as a work-around is  I have changed the param type to String.

Thanks
Daku


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

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


error 415 while posting json

2011-05-30 Thread lambda daku
Hi,

I have been trying to execute post on a resource, while putting json object
as a part of its body. The call to the server fails with the following
return message: 

However it works fine with the workaround, which is to replace JSONObject
with the String type parameter of the post method

Unsupported Media Type (415) - Unsupported Media Type
at org.restlet.resource.ClientResource.handle(ClientResource.java:858)
at org.restlet.resource.ClientResource.handle(ClientResource.java:823)
at org.restlet.resource.ClientResource.post(ClientResource.java:1162)
at
TestServiceAdminResource.testAddService(TestServiceAdminResource.java:31)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Daku

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

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


javax.net.ssl.SSLHandshakeException: no cipher suites in common

2011-05-30 Thread lambda daku
Hi

I was trying to use https with the restlet+jetty, thus far didn't have any
success in accessing the https protected server. The following is on the
server side with -Djava.net.debug=all flag

qtp1345041684-16, fatal error: 40: no cipher suites in common
javax.net.ssl.SSLHandshakeException: no cipher suites in common
qtp1345041684-16, SEND TLSv1 ALERT:  fatal, description = handshake_failure
qtp1345041684-16, WRITE: TLSv1 Alert, length = 2
qtp1345041684-16, fatal: engine already closed.  Rethrowing
javax.net.ssl.SSLHandshakeException: no cipher suites in common

while on the client side:

Restlet-1875244867, received EOFException: error
Restlet-1875244867, handling exception: javax.net.ssl.SSLHandshakeException:
Remote host closed connection during handshake
Restlet-1875244867, SEND TLSv1 ALERT:  fatal, description =
handshake_failure

I wonder if someone have encountered this already. 

I really appreciate for any hints.

Daku

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/javax-net-ssl-SSLHandshakeException-no-cipher-suites-in-common-tp6420883p6420883.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Re: jaxrs + embedded jetty

2011-05-29 Thread lambda daku
Many thanks Thierry! 

The latest dependency being used inside restlet-jee is 7.0.x which is quite
old. 
http://maven.restlet.org/org/restlet/jee/org.restlet.ext.jetty/

However, I am using the bit latest version (v7.4.2), I know its a hassle to
keep up-to-date with the releases of jetty or other extensions.Therefore I
thought of using different approach to embed jetty within the restlet, but
didn't succeed so far:


The main class:
ServletHolder sh = new ServletHolder(ServerServlet.class);
sh.setInitParameter(javax.ws.rs.Application,
DummyApplication.class.getCanonicalName());
Server server = new Server();
ServletContextHandler context = new ServletContextHandler(
ServletContextHandler.SESSIONS);
context.setContextPath(/);
server.setHandler(context);
context.addServlet(sh, /*);
server.start();

// client side
ClientResource c = new 
ClientResource(http://localhost:/dummy;);
System.out.println(c.get());

server.stop();

The DummyApplication class:
public class DummyApplication extends Application{

@Override
public Setlt;Classlt;?gt; getClasses() {
Setlt;Classlt;?gt; rrcs = new HashSetlt;Classlt;?gt;();
rrcs.add(DummyResourceImpl.class);
return rrcs;
}

 }


The error in response:
INFO: 2011-05-2918:57:16127.0.0.1   -   
127.0.0.1   GET /dummy  -
404 0   0   1   http://localhost:   Restlet-Framework/2.0.7 
-
Exception in thread main Not Found (404) - Not Found
at org.restlet.resource.ClientResource.handle(ClientResource.java:858)
at org.restlet.resource.ClientResource.handle(ClientResource.java:763)
at org.restlet.resource.ClientResource.get(ClientResource.java:496)
at demo.jersey.Main.main(Main.java:33)

The resource class:
  @Path(/dummy)
  public class DummyResourceImpl{
@GET
public String sayHello() {
return Hello;
}
  }


Could you please guide/point me if something is wrong in the aforementioned
code?

Thanks,
Daku




--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/jaxrs-embedded-jetty-tp6394909p6416844.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Re: jaxrs + embedded jetty

2011-05-29 Thread lambda daku
Resolved! 
I am not sure if it is a good place (probably on restlet wiki website) to
post it here, despite of that, I am posting the solution here in case if
someone wants to use the embedded jetty with restlet.

Use the following in the code pasted in my last email on this thread:

Replace the following lines
ServletHolder sh = new ServletHolder(ServerServlet.class);
sh.setInitParameter(javax.ws.rs.Application, 
DummyApplication.class.getCanonicalName()); 
with   
   ServletHolder sh = new ServletHolder(ServerServlet.class);
  
sh.setInitParameter(org.restlet.application,DummyJaxRsApplication.class.getCanonicalName());


the DummyJaxRsApplication.java class:

public class DummyJaxRsApplication extends JaxRsApplication{
public DummyJaxRsApplication(Context context) {
super(context);
this.add(new DummyApplication()); //also shown in the previous
thread
}
}


The result:
Hello :)

and the maven dependencies
dependencies
dependency
groupIdorg.restlet.jee/groupId
artifactIdorg.restlet.ext.jaxrs/artifactId
version${restlet.version}/version
/dependency
dependency
groupIdorg.restlet.jee/groupId
artifactIdorg.restlet.ext.json/artifactId
version${restlet.version}/version
/dependency
dependency
groupIdorg.restlet.jee/groupId
artifactIdorg.restlet.ext.servlet/artifactId
version${restlet.version}/version
/dependency


dependency
groupIdorg.eclipse.jetty/groupId
artifactIdjetty-server/artifactId
version${jetty.version}/version
/dependency
dependency
groupIdorg.eclipse.jetty/groupId
artifactIdjetty-security/artifactId
version${jetty.version}/version
/dependency
dependency
groupIdorg.eclipse.jetty/groupId
artifactIdjetty-servlets/artifactId
version${jetty.version}/version
/dependency
dependency
groupIdorg.eclipse.jetty/groupId
artifactIdjetty-webapp/artifactId
version${jetty.version}/version
/dependency
dependency
groupIdorg.eclipse.jetty/groupId
artifactIdjetty-deploy/artifactId
version${jetty.version}/version
/dependency
/dependencies
properties

jetty.version7.4.2.v20110526/jetty.version
restlet.version2.0.7/restlet.version
/properties
repositories
repository
idmaven-restlet/id
namePublic online Restlet repository/name
urlhttp://maven.restlet.org/url
/repository
/repositories

Cheers,
Daku

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/jaxrs-embedded-jetty-tp6394909p6416887.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Error in returning a list on Get Method

2011-05-27 Thread lambda daku
Hi

I have a GET method, which on a request performs some database operation as
a result returns a list of records, which are then converted into a list of
type JSONObject.

the calling code:
ClientResource.get(/some_query_params) I get 500 - internal error as a
response along with the following warning:  

The error on the server side:
May 27, 2011 10:47:08 PM
org.restlet.ext.jaxrs.internal.util.ExceptionHandler noMessageBodyWriter
WARNING: No message body writer found for class class java.util.ArrayList,
genericType java.util.Listorg.json.JSONObject; response media type should
be: application/xml; accepted media types are: [[*/*]]

the method declaration is:
@GET
@Path(/query)
public ListJSONObject queryUsers(@Context UriInfo queryParams){


Is there a way to resolve this?

Presumably its not the standard way, interested in knowing if there is any
recommended alternative in such situations?

Thanks in advance,
Daku

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

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


Re: Unable to find a converter for this representation : [application/json,UTF-8]

2011-05-26 Thread lambda daku
Thanks Thierry, it works now!!!

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/Unable-to-find-a-converter-for-this-representation-application-json-UTF-8-tp6397213p6406350.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Unable to find a converter for this representation : [application/json,UTF-8]

2011-05-23 Thread lambda daku
Hi,
I have a very simple jaxrs application, having the resource class containing
a method returning a JSONObject. However on the client side I am trying to
print the returning while calling the get (see below)

Client side:   
ClientResource cr = new
ClientResource(http://localhost:8182/service;);
cr.getConverterService().setEnabled(true);
   
cr.get(MediaType.APPLICATION_JSON).write(System.out);
   
cr.get(ServiceResourceImpl.class).getServiceDescription();
String jo =
cr.get(ServiceResourceImpl.class).getServiceDescription();

The last two methods return the following errors:

WARNING: Unable to find a converter for this representation :
[application/json,UTF-8]
Exception in thread main java.lang.NullPointerException
at eu.emi.core.Client.main(Client.java:23)

and

WARNING: Unable to find a converter for this representation :
[application/json,UTF-8]
Exception in thread main java.lang.NullPointerException
at eu.emi.core.Client.main(Client.java:23)

respectively (its the same)!

Strangely the first one with ...write(System.out) works fine. 

On the server side, the resource method is being called without any
problems.

Here is the resource class:

@Path(/service)
public class ServiceResourceImpl{

/* (non-Javadoc)
 * @see eu.emi.ServiceResource#getServiceDescription(java.lang.String)
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
public JSONObject getServiceDescription() {
System.out.println(getting service description);
Maplt;String, Stringgt; map = new HashMaplt;String, Stringgt;();
map.put(id, 1);
map.put(name, data);
   
return new JSONObject(map);
}
}

Software version:

* JDK 1.6
* Restlet v 2.0.7 with corresponding jaxrs extension

Could you please help me in resolving this?

Thanks in advance,
Daku

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/Unable-to-find-a-converter-for-this-representation-application-json-UTF-8-tp6396319p6396319.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


Re: Unable to find a converter for this representation : [application/json,UTF-8]

2011-05-23 Thread lambda daku
Ok, I have found the solution, written as follows:

One has to add the following maven dependency into the project's pom file:
dependency
groupIdorg.restlet.jee/groupId
artifactIdorg.restlet.ext.json/artifactId
version${restlet.version}/version
/dependency

At the client side:
   ClientResource cr = new ClientResource(
http://localhost:8182/service/description;);
JsonConverter c = new JsonConverter();
JSONObject jo = c.toObject(cr.get(MediaType.APPLICATION_JSON),
JSONObject.class, cr);
System.out.println(jo);

cheers,
Daku

--
View this message in context: 
http://restlet-discuss.1400322.n2.nabble.com/Unable-to-find-a-converter-for-this-representation-application-json-UTF-8-tp6396319p6396468.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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