Re: Matlab With Restlet

2010-02-23 Thread Thierry Boileau
Hi,

it looks like the containsAll methods behaves oddly, it should return 
true for both com.noelios.restlet.ext.net.HttpClientHelper, and 
com.noelios.restlet.http.StreamClientHelper.
What may happen also is that the client is not properly initialized. 
Given its single protocol (HTTP), its member attribute protocols, 
which is a list, is set using the Arrays#asList method. Could you check 
that this method works properly by displaying the list of client's 
protocols?

Client client = new Client(Protocol.HTTP);

System.out.println(client.getProtocols());

If the list is empty, I suggest, as a workaround, to set the list using 
another way such as:
 client.setProtocols(new ArrayListProtocol());
 client.getProtocols().add(Protocol.HTTP);

Best regards,
Thierry Boileau
NB: Restlet v2 does not have a com.noelios.restlet package and jar. The 
org.restlet.jar contains now both the API and reference implementation.

 hi Thierry

 I have done the test suggested by you.Im using Restlet 1.1.8.Also i 
 have downloaded (version 2 milestone 7 but i was not able to find 
 com.noelios.restlet.jar inside lib folder. So i havent tried anything with 
 this release).

 The log from the Matlab Command Window is as follows:

 Diagnostics START
 Executing : com.noelios.restlet.Engine engine = (com.noelios.restlet.Engine) 
 org.restlet.util.Engine.getInstance();.And the Output Is:

 Executing : System.out.println( engine:  + engine);.And the Output Is:
 Engine : com.noelios.restlet.eng...@ae43b8

 Executing : System.out.println( client connectors:  + 
 engine.getRegisteredClients());.And the Output Is:
 client Connectors : [com.noelios.restlet.ext.net.httpclienthel...@54919e, 
 com.noelios.restlet.http.streamclienthel...@2437ef, 
 com.noelios.restlet.local.clapclienthel...@1d46259, 
 com.noelios.restlet.local.fileclienthel...@84fa6a]

 Executing : Client client = new Client(Protocol.HTTP);.And the Output Is:
 22.02.2010 18:52:44 com.noelios.restlet.Engine createHelper

 WARNUNG: No available client connector supports the required protocols: 
 'PROTOCOL.HTTP' . Please add the JAR of a matching connector to your 
 classpath.

 Client : org.restlet.cli...@18307be

 Executing : System.out.println( client helper:  + helper);.And the Output Is:
 Client Helper : com.noelios.restlet.ext.net.httpclienthel...@54919e

 Executing : System.out.print( client protocols:  + 
 helper.getProtocols());.And the Output Is:
 Client Protocols : [HTTP, HTTPS]

 Executing : System.out.println( =   + 
 helper.getProtocols().containsAll(client.getProtocols()));.And the Output Is:
 Value returned by (helper.getProtocols().containsAll(client.getProtocols())) 
 : 0

 Executing : System.out.println( client helper:  + helper);.And the Output Is:
 Client Helper : com.noelios.restlet.http.streamclienthel...@2437ef

 Executing : System.out.print( client protocols:  + 
 helper.getProtocols());.And the Output Is:
 Client Protocols : [HTTP]

 Executing : System.out.println( =   + 
 helper.getProtocols().containsAll(client.getProtocols()));.And the Output Is:
 Value returned by (helper.getProtocols().containsAll(client.getProtocols())) 
 : 0

 Executing : System.out.println( client helper:  + helper);.And the Output Is:
 Client Helper : com.noelios.restlet.local.clapclienthel...@1d46259

 Executing : System.out.print( client protocols:  + 
 helper.getProtocols());.And the Output Is:
 Client Protocols : [CLAP]

 Executing : System.out.println( =   + 
 helper.getProtocols().containsAll(client.getProtocols()));.And the Output Is:
 Value returned by (helper.getProtocols().containsAll(client.getProtocols())) 
 : 0

 Executing : System.out.println( client helper:  + helper);.And the Output Is:
 Client Helper : com.noelios.restlet.local.fileclienthel...@84fa6a

 Executing : System.out.print( client protocols:  + 
 helper.getProtocols());.And the Output Is:
 Client Protocols : [FILE]

 Executing : System.out.println( =   + 
 helper.getProtocols().containsAll(client.getProtocols()));.And the Output Is:
 Value returned by (helper.getProtocols().containsAll(client.getProtocols())) 
 : 0

 Executing : System.out.println( chosen helper:  + 
 Engine.getInstance().createHelper(client, null));.And the Output Is:
 22.02.2010 18:52:44 com.noelios.restlet.Engine createHelper

 WARNUNG: No available client connector supports the required protocols: 
 'PROTOCOL.HTTP' . Please add the JAR of a matching connector to your 
 classpath.

 chosen helper: The Value returned from 
 Engine.getInstance().createHelper(client, null)) is Empty

 Diagnostics END

 I hope  u can easily understand the above log file.
 If you need any more info pls let me know.
 Thanks.

 Regards
 Rashik.T

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



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

RE: XML mapper for GWT

2010-02-23 Thread Harald Pehl
Hi Jerome,

sounds good! I looked into ClientProxyGenerator.generateMethod() and noticed 
that the conversion is currently done using ObjectRepresentationT. If I get 
it right you want to replace this by the client side ConverterService? 

Do you already have something in place or are you in the design phase? Let me 
know as soon as you have something I can contribute to.

The idea to extend Piriti to also support other formats like JSON definitely 
makes sense. I will add this to the next major release of Piriti and let you 
know when it is ready to use. 

Best regards,
Harald Pehl

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


Minimum GWT code for ClientResource from a different host

2010-02-23 Thread MickeyMiner
Hi,

Could anyone please tell a rookie if there is any server side code
absolutely necessary in order to fetch data from a remote host? Later on I
will want to add authentication...

I have set up a working testGwtRestlet-2-0 example and added following lines
to onModuleLoad:


ClientResource r = new
ClientResource(http://www.remotedomein.com/RESTfulTest/resources/customers/pkey/2176172632;);
r.setOnReceived(new Uniform() {
public void handle(Request request, Response response) {
System.out.println(request.getResourceRef():  +
request.getResourceRef());
System.out.println(response.getStatus():  + 
response.getStatus());
}
});
r.get();

as a debug message a get:

request.getResourceRef():
http://www.remotedomein.com/RESTfulTest/resources/customers/pkey/2176172632
response.getStatus(): Internal Connector Error (1002) -
(NS_ERROR_NOT_AVAILABLE): Component returned failure code: 0x80040111
(NS_ERROR_NOT_AVAILABLE) [nsIXMLHttpRequest.statusText]
 QueryInterface: function QueryInterface() {
[native code]
}
 result: 2147746065
 filename: http://127.0.0.1:
 lineNumber: 36
 columnNumber: 0
 inner: null
 data: null
 initialize: function initialize() {
[native code]
}

Thank you for your help.

mm
-- 
View this message in context: 
http://n2.nabble.com/Minimum-GWT-code-for-ClientResource-from-a-different-host-tp4618429p4618429.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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


RE: Re: client-server file upload

2010-02-23 Thread Pierre Lecointre
2.0 m7 (android and Jee)

regards,
Pierre

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


GWT, ClientResource, Same Origin Policy (SOP)

2010-02-23 Thread asdfasdf
Good evening everyone,


What do I need to make from GWT a simple (GET and PUT) request to a
non-localhost service without having to implement any server side code? The
following example does not work. (Probably becouse of the Same Origin
Policy):

ClientResource r = new
ClientResource(http://xxx.xxx.xxx.xxx:/services/my_service;);
r.setOnReceived(new Uniform() {
public void handle(Request request, Response response) {
System.out.println(response.getStatus());
}
});
r.get();


Cheers,


ab

-- 
View this message in context: 
http://n2.nabble.com/GWT-ClientResource-Same-Origin-Policy-SOP-tp4619686p4619686.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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

Re: GWT, ClientResource, Same Origin Policy (SOP)

2010-02-23 Thread Thierry Boileau
Hello,

could you have a look at this thread? It should give you some ideas.

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

Best regards,
Thierry Boileau

 Good evening everyone,

 What do I need to make from GWT a simple (GET and PUT) request to a 
 *non-localhost* *service **without *having to implement any server 
 side code? The following example does not work. (Probably becouse of 
 the Same Origin Policy):
 ClientResource r = new 
 ClientResource(http://xxx.xxx.xxx.xxx:/services/my_service;);
 r.setOnReceived(new Uniform() {
  public void handle(Request request, Response response) {
  System.out.println(response.getStatus());
  }
 });
 r.get();

 Cheers,
 ab
 
 View this message in context: GWT, ClientResource, Same Origin Policy 
 (SOP) 
 http://n2.nabble.com/GWT-ClientResource-Same-Origin-Policy-SOP-tp4619686p4619686.html
 Sent from the Restlet Discuss mailing list archive 
 http://n2.nabble.com/Restlet-Discuss-f1400322.html at Nabble.com.

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

RE: Suspended thread doing Client.put

2010-02-23 Thread Jerome Louvel
Hi Jeff,

 

Did this problem get solved for you with 2.0 M7 or more recent snapshots?

 

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Technical Lead ~  http://www.restlet.org/
http://www.restlet.org
Noelios Technologies ~  http://www.noelios.com/ http://www.noelios.com

 

 

 

De : Thierry Boileau [mailto:thierry.boil...@noelios.com] 
Envoyé : lundi 1 février 2010 12:28
À : discuss@restlet.tigris.org
Objet : Re: Suspended thread doing Client.put

 

Hi Jeff,

could make a test with the 2.0m7? It helpes to automatically release
connection once the entity has been handled.

Best regards,
Thierry Boileau




Yes, we made sure to update and we did notice that there were recent changes
to the latch code.

 

-jeff

Thierry Boileau thierry.boil...@noelios.com wrote in message
news:4b62c277.1060...@noelios.com...

Hello Jeff,

did you try the latest snapshot (the internal connectors have been updated a
few days ago)?

Best regards,
Thierry Boileau




We're seeing the vm blocking forever on a call to Client.put that
worked fine on an earlier release of 2.0-SNAPSHOT:
 
Thread [main] (Suspended)
Unsafe.park(boolean, long) line: not available [native method]
LockSupport.park(Object) line: 158
 
CountDownLatch$Sync(AbstractQueuedSynchronizer).parkAndCheckInterrupt()
line: 747 [local variables unavailable]
 
CountDownLatch$Sync(AbstractQueuedSynchronizer).doAcquireSharedInterruptibly
(int)
line: 905
 
CountDownLatch$Sync(AbstractQueuedSynchronizer).acquireSharedInterruptibly(i
nt)
line: 1217
CountDownLatch.await() line: 207 [local variables unavailable]
HttpClientHelper(BaseClientHelper).handle(Request,
Response) line: 490
Client.handle(Request, Response) line: 268
Client.handle(Request) line: 259
Client.put(Reference, Representation) line: 508
 
Any ideas? Has anyone else seen this behavior?
 
-jeff
 
--
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447dsMessageId=2442
913 dsMessageId=2442913

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

RE: Comprehensive example of authentication in RESTLet 2.0?

2010-02-23 Thread Jerome Louvel
Hi all,

 

Based on Thierry’s reply, I’ve updated the main security page in the user
guide:

http://wiki.restlet.org/docs_2.0/13-restlet/27-restlet/46-restlet.html

 

That should help people getting started with Restlet 2.0 security API.

 

Best regards,
Jerome Louvel
--
Restlet ~ Founder and Technical Lead ~  http://www.restlet.org/
http://www.restlet.org
Noelios Technologies ~  http://www.noelios.com/ http://www.noelios.com

 

 

 

 

De : Thierry Boileau [mailto:thierry.boil...@noelios.com] 
Envoyé : lundi 1 février 2010 17:31
À : discuss@restlet.tigris.org
Objet : Re: Comprehensive example of authentication in RESTLet 2.0?

 

Hello,

Thanks Garry for your mail.
Just a few words about the security model in the Restlet framework.
The Restlet framework has set up its own model (see here [0], [1]) based on
some properties of the ClientInfo class: user and roles.
This model gets along with ones that are based on principals that are closer
or are based on JAAS. These models are distinct, and some bridges are
required in some situations in case you want to use JAAS.

The security model tries to distinguish the authentication and authorization
aspects.
The authentication steps relies on a dedicated filter which is a subclass of
Authenticator (e.g. ChallengeAuthenticator, or your own) which verifies the
credentials stored in the request (challengeResponse attribute) thanks to a
Verifier (e.g. a SecretVerifier), Then, the Enroler (if any) is called in
order to set the list of roles of the user.
Once the credentials have been authenticated and the User and Roles have
been set by the Authenticator/Verifier/Enroler, then the request is ready to
be routed to the right resource.
If the request is not authenticated, a Unauthorized (401) response is sent
back, by default.

According to your policy, some parts of the hierarchy of resource are only
authorized to some kinds of people. This is the role of the Authorizer
filter. In the sample code attached to this mail, I've implemented a
RoleAuthorizer filter, that checks according to a set of autorized roles.
You will see that the URIs hierarchy is splitted in two parts, each of them
is protected by itw own instance of RoleAuthorizer.
If a request is not authorized, a Forbidden (403) response is sent back,
by default.

Of course, you can customize each part: Authenticator, Verifier, Enroler,
Authorizer.

Regarding the Authenticator helper, this piece of code is used to handle the
conversion of header values (of the protocol, e.g. HTTP) with the Restlet
API model (Request/Response) in one direction, or both for a certain type of
Authentication challenge scheme. At this time, the following schemes are
supported:
  - HTTP_BASIC (client and server) with the core module
  - HTTP_DIGEST (client and server) with the crypto extension
  - Amazon S3, shared_key and shared_key_lite (client) with the crypto
extension
  - SMTP (client) with the core module

Best regards,
Thierry Boileau


[0]
http://wiki.restlet.org/developers/172-restlet/212-restlet.html#dsy212-restl
et_authenticationModel
[1]
http://wiki.restlet.org/developers/172-restlet/212-restlet.html#dsy212-restl
et_authorizationModel



Hi Drew,
 
I can't give a comprehensive example but I just built something along 
these lines recently and actually found the main building blocks to be 
quite straightforward.
 
I have a number of routes configured in my application, the first object 
in each is a custom class that extends org.restlet.security.Authenticator.
 
That class has an authenticate method that receives the request and 
response objects and returns a boolean result -- though you also need set 
the status code on the response if it's a non 200-code situation.
 
Within that method I check the custom values of the ChallengeResponse 
object that my AuthenticationHelper populates (see below) to make coarse 
authentication decisions.  The next objects in my routes are then 
different subclasses of org.restlet.security.Authorizer that have an 
authorize method analogous to the authenticate method in the 
Authenticator.  By this mechanism I have logic that has parsed the header 
into the user credentials, made a decision if this is a valid user and 
decided if they can use the resource before the resource is ever touched.
 
Re the AuthenticationHelper, I was initially confused by this but for me 
it was easier than I expected.  I wrote a subclass of 
org.restlet.engine.security.AuthenticatorHelper and overrode the 
parseResponse method.  This method receives the raw bytes from the 
Authorization header in the request and its in this method that I take 
this and use it to populate the ChallengeResponse object used by the 
authenticator.  So this is where you could do your database lookups to 
convert the raw auth data into fields on the ChallengeResponse object that 
the Authenticator will then use for its authentication decisions.
 
AuthenticationHelper has a bunch of other methods depending on whether or 
not you've 

How to write an Universal redirector

2010-02-23 Thread asdfasdf
Hello everybody,


Could please anyone help me to write a universal redirector to match all
requests and to redirected them to a remote host?


Example:

Start:   /redirect/RESTfulServices/resources/customers/pkey/2176172632
Finish: 
http://192.168.100.1:8080/RESTfulServices/resources/customers/pkey/2176172632



GWT Client side:

ClientResource r = new
ClientResource(/redirect/RESTfulServices/resources/customers/pkey/2176172632);



Server side class TestRestletApplication extends Application (my web.xml was
changed to forward all /redirect/* requests to TestRestletApplication)

Router router = new Router(getContext());
router.attach(/RESTfulServices, new MyRedirector(getContext(), null));  //  
-- this is wrong


and MyRedirector class:
public class MyRedirector extends Redirector {

public MyRedirector(Context context, String targetTemplate) {
// By default, the mode is MODE_CLIENT_DISPATCHER
super(context, targetTemplate);
}

@Override
protected Reference getTargetRef(Request request, Response response) {
Reference ref = request.getResourceRef();
ref.setHostDomain(192.168.100.1);
ref.setHostPort(8080);
//   -- here is missing something
return ref;
}
}


Thank you for helping me.


ab
-- 
View this message in context: 
http://n2.nabble.com/How-to-write-an-Universal-redirector-tp4620578p4620578.html
Sent from the Restlet Discuss mailing list archive at Nabble.com.

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