You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@river.apache.org by Sim IJskes - QCG <si...@qcg.nl> on 2010/02/10 13:28:51 UTC

servlet based JERI

Hello,

In order to make it possible to host a JERI server endpoint on a 
webserver, we need a servlet based server endpoint.

Is there anybody on the list who has done some work in this direction? 
Mark Brouwer is he on the list?

Does anybody know where to find "Customizing the Jini ERI Invocation and 
Transport Layers" cited in his jcm10 presentation?

Gr. Sim

-- 
QCG, Software voor het MKB, 071-5890970, http://www.qcg.nl
Quality Consultancy Group b.v., Leiderdorp, Kvk Leiden: 28088397

Re: servlet based JERI

Posted by Peter Firmstone <ji...@zeus.net.au>.
Sim IJskes - QCG wrote:
> Patrick Wright wrote:
>
>> If you are trying to host a service within a webserver itself, then
>> Bantam already does that.
>
> Yes i am. With 5 extra classes i think. Completely integratable with 
> River. Without extra dependencies. Who can object against that.
>
> Gr. Sim
>
> P.S. No, i mean the other Object. :-)
>
Sim, you have been busy, sounds interesting :-)

Cheers,

Peter.

Re: servlet based JERI

Posted by Sim IJskes - QCG <si...@qcg.nl>.
Patrick Wright wrote:

> If you are trying to host a service within a webserver itself, then
> Bantam already does that.

Yes i am. With 5 extra classes i think. Completely integratable with 
River. Without extra dependencies. Who can object against that.

Gr. Sim

P.S. No, i mean the other Object. :-)

-- 
QCG, Software voor het MKB, 071-5890970, http://www.qcg.nl
Quality Consultancy Group b.v., Leiderdorp, Kvk Leiden: 28088397

Re: servlet based JERI

Posted by Patrick Wright <pd...@gmail.com>.
> Thanks, its indeed in com.skillcorp.bantam.servlet.RemotingServlet
>
> The strange thing here is, that the http request once in the Servlet, is
> delegated once again to one of 4 'services'. Codebase, Remoting, Lookup and
> Proxy.
>
> If i take the shortest path, i would immediately step into the 'JERI
> unmarshalled domain' and provide those 'services' as jini services.

So you are just trying to use the servlet to act as a remoting proxy
for a service that is e.g. behind a firewall?

If you are trying to host a service within a webserver itself, then
Bantam already does that.

It would be good to get ahold of Tom Celluci on the Bantam mailing
list for feedback, he's been around the Jini community for quite a
while.

Re: servlet based JERI

Posted by Sim IJskes - QCG <si...@qcg.nl>.
Patrick Wright wrote:
> On Wed, Feb 10, 2010 at 1:28 PM, Sim IJskes - QCG <si...@qcg.nl> wrote:
>> Hello,
>>
>> In order to make it possible to host a JERI server endpoint on a webserver,
>> we need a servlet based server endpoint.
> 
> Bantam may have what you are looking for
> https://bantam.dev.java.net/

Thanks, its indeed in com.skillcorp.bantam.servlet.RemotingServlet

The strange thing here is, that the http request once in the Servlet, is 
delegated once again to one of 4 'services'. Codebase, Remoting, Lookup 
and Proxy.

If i take the shortest path, i would immediately step into the 'JERI 
unmarshalled domain' and provide those 'services' as jini services.

And to make sure you can find these services, export them on predefined 
  ID's (think jeri DGC).

Anyhow, i have to eat my pudding first.

Gr. Sim

-- 
QCG, Software voor het MKB, 071-5890970, http://www.qcg.nl
Quality Consultancy Group b.v., Leiderdorp, Kvk Leiden: 28088397

Re: servlet based JERI

Posted by Patrick Wright <pd...@gmail.com>.
On Wed, Feb 10, 2010 at 1:28 PM, Sim IJskes - QCG <si...@qcg.nl> wrote:
> Hello,
>
> In order to make it possible to host a JERI server endpoint on a webserver,
> we need a servlet based server endpoint.

Bantam may have what you are looking for
https://bantam.dev.java.net/

Re: servlet based JERI

Posted by Peter Firmstone <ji...@zeus.net.au>.
Peter Firmstone wrote:
> I guess it could be designed in by noting what permissions are 
> required in the source code. It is possible that the tool might miss a 
> permission based on the execution path.  That's one thing I like about 
> OSGi bundles, the author of the bundle specifies the permissions 
> required to execute the code in the bundle.
>
> The tool should be a good start.  Perhaps we might want to consider 
> privileged code blocks, so the permissions aren't used for gaining 
> access to anything else.  Just a thought.

Actually this might already be the case, which would explain the 
method's existence, not near the code at the moment to comment any 
further I'm afraid..

>
> If you come up with any thoughts or ideas, please let me know.
>
> Cheers,
>
> Peter.
>
>
> QCG - Sim IJskes wrote:
>> Peter Firmstone wrote:
>>> First use this tool to log the required set of permissions:
>>>
>>> com.sun.jini.tool.DebugDynamicPolicyProvider
>>
>> I can do that, but shouldn't these be designed instead of measured?
>>
>> Gr. Sim
>>
>>
>>
>>
>
>


Re: servlet based JERI

Posted by Peter Firmstone <ji...@zeus.net.au>.
Dennis,

I can give you some examples later if you like, not near any code at the 
moment.

Cheers,

Peter.

Peter Firmstone wrote:
> You place a file called permissions.perm inside a top level directory 
> in the bundle.
>
> OSGI-INF/permissions.perm
>
> The syntax is that used for java policy files.
>
> The format is the same as the encoded format of PermissionInfo for 
> that permission.
>
> The framework limits the permissions to this set, less permissions may 
> be granted of course, dependant on the bundle signer.
>
> Cheers,
>
> Peter.
>
> Dennis Reedy wrote:
>> On Feb 14, 2010, at 524PM, Peter Firmstone wrote:
>>
>>  
>>> I guess it could be designed in by noting what permissions are 
>>> required in the source code. It is possible that the tool might miss 
>>> a permission based on the execution path.  That's one thing I like 
>>> about OSGi bundles, the author of the bundle specifies the 
>>> permissions required to execute the code in the bundle.
>>>
>>>     
>>
>> I guess I could research this, but its easier to ask :)
>>
>> Can you give me example(s) of what bundle declared permissions look 
>> like?
>>
>> Thanks
>>
>> Dennis
>>
>>
>>   
>
>


Re: servlet based JERI

Posted by Peter Firmstone <ji...@zeus.net.au>.
Hi Dennis,

Clarification see inline:

Peter Firmstone wrote:
> You place a file called permissions.perm inside a top level directory 
> in the bundle.
>
> OSGI-INF/permissions.perm
>
> The syntax is that used for java policy files.

The above statement is incorrect, my apologies, it should have read "is 
similar to that" , sorry a bit tired, it's actually a simpler more 
restricted syntax than the policy files, although it will be instantly 
recognisable to anyone used to writing policy files, permissions.perm is 
a UTF-8 encoded text file, lines beginning with # or // are comments, it 
doesn't have grants etc.  It has only one permission per line.

Here's an example of OSGI-INF/permissions.perm :

# Quick and dirty example list of required permissions for some bundle
( java.util.PropertyPermission "jsk.home" "read" )
( java.util.PropertyPermission "jsk.port" "read, write" )
( java.io.FilePermission "<<ALL FILES>>" "read" )
//eof

Without OSGi Bundles, the identical permission's might appear like this 
in some Policy file's syntax :

// The same permissions in a policy file
grant codeBase "some codebase path" {
    permission java.util.PropertyPermission "jsk.home", "read";
    permission java.util.PropertyPermission "jsk.port", "read, write";
    permission java.io.FilePermission "<<ALL FILES>>", "read";
};
//eof

http://www.osgi.org/javadoc/r4v42/org/osgi/service/permissionadmin/PermissionInfo.html
>
> The format is the same as the encoded format of PermissionInfo for 
> that permission.
>
> The framework limits the permissions to this set, less permissions may 
> be granted of course, dependant on the bundle signer.
>
> Cheers,
>
> Peter.
>
> Dennis Reedy wrote:
>> On Feb 14, 2010, at 524PM, Peter Firmstone wrote:
>>
>>  
>>> I guess it could be designed in by noting what permissions are 
>>> required in the source code. It is possible that the tool might miss 
>>> a permission based on the execution path.  That's one thing I like 
>>> about OSGi bundles, the author of the bundle specifies the 
>>> permissions required to execute the code in the bundle.
>>>
>>>     
>>
>> I guess I could research this, but its easier to ask :)
>>
>> Can you give me example(s) of what bundle declared permissions look 
>> like?
>>
>> Thanks
>>
>> Dennis
>>
>>
>>   
>
>


Re: servlet based JERI

Posted by Peter Firmstone <ji...@zeus.net.au>.
You place a file called permissions.perm inside a top level directory in 
the bundle.

OSGI-INF/permissions.perm

The syntax is that used for java policy files.

The format is the same as the encoded format of PermissionInfo for that 
permission.

The framework limits the permissions to this set, less permissions may 
be granted of course, dependant on the bundle signer.

Cheers,

Peter.

Dennis Reedy wrote:
> On Feb 14, 2010, at 524PM, Peter Firmstone wrote:
>
>   
>> I guess it could be designed in by noting what permissions are required in the source code. It is possible that the tool might miss a permission based on the execution path.  That's one thing I like about OSGi bundles, the author of the bundle specifies the permissions required to execute the code in the bundle.
>>
>>     
>
> I guess I could research this, but its easier to ask :)
>
> Can you give me example(s) of what bundle declared permissions look like?
>
> Thanks
>
> Dennis
>
>
>   


Re: servlet based JERI

Posted by Dennis Reedy <de...@gmail.com>.
On Feb 14, 2010, at 524PM, Peter Firmstone wrote:

> I guess it could be designed in by noting what permissions are required in the source code. It is possible that the tool might miss a permission based on the execution path.  That's one thing I like about OSGi bundles, the author of the bundle specifies the permissions required to execute the code in the bundle.
> 

I guess I could research this, but its easier to ask :)

Can you give me example(s) of what bundle declared permissions look like?

Thanks

Dennis


Re: servlet based JERI

Posted by Peter Firmstone <ji...@zeus.net.au>.
I guess it could be designed in by noting what permissions are required 
in the source code. It is possible that the tool might miss a permission 
based on the execution path.  That's one thing I like about OSGi 
bundles, the author of the bundle specifies the permissions required to 
execute the code in the bundle.

The tool should be a good start.  Perhaps we might want to consider 
privileged code blocks, so the permissions aren't used for gaining 
access to anything else.  Just a thought.

If you come up with any thoughts or ideas, please let me know.

Cheers,

Peter.


QCG - Sim IJskes wrote:
> Peter Firmstone wrote:
>> First use this tool to log the required set of permissions:
>>
>> com.sun.jini.tool.DebugDynamicPolicyProvider
>
> I can do that, but shouldn't these be designed instead of measured?
>
> Gr. Sim
>
>
>
>


Re: servlet based JERI

Posted by QCG - Sim IJskes <si...@qcg.nl>.
Peter Firmstone wrote:
> First use this tool to log the required set of permissions:
> 
> com.sun.jini.tool.DebugDynamicPolicyProvider

I can do that, but shouldn't these be designed instead of measured?

Gr. Sim




Re: servlet based JERI

Posted by Peter Firmstone <ji...@zeus.net.au>.
First use this tool to log the required set of permissions:

com.sun.jini.tool.DebugDynamicPolicyProvider

Then checkPermissions() can check against the required permission using 
PermissionCollection.implies(), any party that doesn't have the required 
minimum permissions, gets a SecurityException.   Remember, 
PermissionCollection.implies() doesn't have to match the exact same 
permission, just one that implies the required permission.

Cheers,

Peter.

Sim IJskes - QCG wrote:
>
>
> Does anybody have a suggestion, what kind of permission we want to 
> test in ListenEndpoint.checkPermissions() ?
>
> Bearing in mind, it will most probably be deployed from a .war and 
> runs in its own webapp classloader.
>
> Gr. Sim
>


Re: servlet based JERI

Posted by Sim IJskes - QCG <si...@qcg.nl>.

Does anybody have a suggestion, what kind of permission we want to test 
in ListenEndpoint.checkPermissions() ?

Bearing in mind, it will most probably be deployed from a .war and runs 
in its own webapp classloader.

Gr. Sim

-- 
QCG, Software voor het MKB, 071-5890970, http://www.qcg.nl
Quality Consultancy Group b.v., Leiderdorp, Kvk Leiden: 28088397

Re: servlet based JERI

Posted by Sim IJskes - QCG <si...@qcg.nl>.
I've the following running:

A JeriServlet accepting incoming jeri requests. A ServletEndpoint 
connecting to the JeriServlet over HTTP.

It's build with 10 classes, and a dependency to Apache HTTPClient. I 
tried to re-use the HTTPEndpoint implementation, so it could be 
reintegrated by adding a request path to the HTTPEndpoint class. But i 
got a major headache while working on it, and i already had a similar 
(non-jeri) implementation running, so i took a shortcut.

It's completely without Constraints, i need to work on that. The number 
of classes is bigger than expected, because i abstracted some of the 
functionality into some baseclasses which i need for the service proxy.

There are several nasties in the code, such as the proxy handling, which 
is currently not per URL, the initialization of the JeriServlet which 
does not give me enough information to find the deployment URL. Also the 
MultiThreadedHttpConnectionManager and HttpClient are instanciated for 
every EndpointImpl.

The configuration is the following:

endpoint.server
{
     serverEndpoint = JeriServlet.getServerEndpoint();
}

or

endpoint.server
{
     serverEndpoint = 
JeriServlet.getServerEndpoint("http://jeri.qcg.nl/blah");
}

The last variant can be used to make sure the servlet is run on the 
proper basepath, and when one needs more than 1 serverEndpoint.

Gr. Sim

-- 
QCG, Software voor het MKB, 071-5890970, http://www.qcg.nl
Quality Consultancy Group b.v., Leiderdorp, Kvk Leiden: 28088397