You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-user@portals.apache.org by Cubehead <cu...@gmail.com> on 2005/12/13 14:24:18 UTC

file download in portlet

Hi all,

I wish to create a JSR-168 compliant portlet that will display a list of
files with meta-data and then provide a link download the binary file.

The files will not be public and access control will be on a user by user
basis.

Has anyone figured out a way to do this?

thanks kindly,
Cubehead

Re: file download in portlet

Posted by Christophe Lombart <ch...@gmail.com>.
Yes it is done in the Graffito project and it running with J2.



On 12/13/05, Cubehead <cu...@gmail.com> wrote:
> Hi all,
>
> I wish to create a JSR-168 compliant portlet that will display a list of
> files with meta-data and then provide a link download the binary file.
>
> The files will not be public and access control will be on a user by user
> basis.
>
> Has anyone figured out a way to do this?
>
> thanks kindly,
> Cubehead
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: file download in portlet

Posted by Aaron Evans <aa...@yahoo.ca>.
Cubehead <cubehead <at> gmail.com> writes:

> 
> Hi all,
> 
> I wish to create a JSR-168 compliant portlet that will display a list of
> files with meta-data and then provide a link download the binary file.
> 
> The files will not be public and access control will be on a user by user
> basis.
> 
> Has anyone figured out a way to do this?
> 
> thanks kindly,
> Cubehead
> 

Cubehead,
IMHO, the java community has forgotten that the web was founded on file 
downloads when they came up with JSR-168. I believe (and hope) that the next
release of the portlet/portal spec will address file downloads from within
the context of a portlet.

I had the exact same problem and have solved it for the jetspeed 2 
environment on tomcat.

Here is a high-level description of how I have approached this problem:

I have a servlet/portlet application, running in a context called 
'my-application' (for example).  In this application, I have a portlet
which displays meta-data about some binary files and then provides links
to download them.  I do not create the download links as portal generated ones
but rather URIs to a download servlet, which is also in the 'my-application'
application.

Now for adding security.  What I have done is to enable SSO in tomcat. Then,
I move the jetspeed JAASRealm from the jetspeed context config element to 
the localhost engine config element in the appropriate tomcat config files.

Additionally, I have moved the tomcat manager UserDatabase realm from the
localhost engine config element servlet.xml to the manager application
manager.xml config file.  This leaves the manager app working against the
usual tomcat-users.xml file for its authentication.

Now, if I authenticate against jetspeed as the admin user with the admin
role, when I click the download link (which will bypass jetspeed) and
hit my download servlet, under SSO, I will be recognized as the admin user
in the admin role in that environment (using security methods on the
request object).

Now you have a variety of options for enforcing security.  If you just need
blanket role-based security against the download servlet, then the easiest
way to accomplish this is using the typical security constraint configurations
in the web.xml file.  

However, in your case (and in mine), you need user-by-user security 
enforcement (no doubt on the requested resource to download). Since you have 
access to the user principal name, you can use that within your servlet code
to do a security check and return not authorized if appropriate.

If you need more info than just their user name and roles to do your security
check, this is where it gets a little trickier.  You will need to look up any 
additional info in whatever data store that information is kept. If it is
jetspeed's default database where it is kept, then you will want to move
jetspeed's jdbc/jetspeed JNDI data source to the container level as well
so that you can access it from your serlvet.  Then you will need to do the
appropriate SQL lookups.

If it *is* jetspeed stored data you are after, there may be a way to get
access to the coarse grained security services and user attribute manager
from the servlet code, but I have not figured that out yet.

HTH,
aaron





---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: file download in portlet

Posted by David Sean Taylor <da...@bluesunrise.com>.
Aaron Evans wrote:
> David Sean Taylor <david <at> bluesunrise.com> writes:
> 
> 
>>Have you looked at the file server pipeline?
>>There is a simple example of the demo page (pdf.link) of the default 
>>install.
>>
>>Example:
>>
>>/jetspeed/fileserver/_content/sample_pdf.pdf
>>
> 
> 
> David,
> I was unaware of this capability. 
> 
> So I took a look at serveral resources in the jetspeed source including 
> pdf.link, /assembly/pipelines.xml, the FilePortlet and the FileServerValve.
> 
> What is unclear to me is the link between the path in pdf.link and 
> the FileServerValve itself.  I assume that the fact that the path contains
> fileserver/_content triggers the use of the whole mechanism. But I cannot
> find where this is configured.
> 
> I am not that familiar with the pipeline (although I have checked out the
> online documentation), but I assume that every Valve in the pipeline is always
> invoked (ie. there is no forking/logic that produces different paths through
> the pipeline).
> 
> So if that is the case, what causes the URI above to be directed to the
> portlet configured for the FileServerValve (demo::ContentViewer in
> pipelines.xml)?
> 
Thats where we could use a better configuration
Right now, the mapping is done here:

http://svn.apache.org/viewcvs.cgi/portals/jetspeed-2/trunk/components/profiler/src/java/org/apache/jetspeed/profiler/rules/impl/PathSessionResolver.java?rev=333096&view=log

See the mapPath method


> Also, the documentation for the pipeline is a good start, but what is missing
> is a guide to adding your own valve to the pipeline describing where in the
> pipeline a custom valve should be placed (eg. there are probably some key 
> valves that should go before it and perhaps some that must go after it
> depending on what you are doing), how to configure it, etc.
> 
Agreed. I have some slides on pipelines.
Need to get those back into the docs

> I think in my case, I would want to leave the existing file server mechanism
> in place (although it uses a demo portlet, so I'm not sure how that will
> be impacted if I build/deploy without the demo application).
> 
> So I'd want to set up a similar mechanism so that I can create a link with
> a URI with some parameters, eg /jetspeed/mybinaries/binary?resourceID=XYZ
> that will get directed to a portlet in my portlet application that will
> be similar to the FilePortlet.  
> 
> In the FilePortlet I will have to use the request parameters to identify
> the correct resource on the filesystem (it will not be deployed as part of
> any servlet/portlet application), do a number of security checks and finally
> change the response type and render the binary content.
> 
> So, I assume I'd need to insert another valve component similar to the
> FileServerValve and configure it in a similar way.  But how do you tie
> the rest together?
> 
See the File Portlet, it has several ways of looking for the resource

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: file download in portlet

Posted by Aaron Evans <aa...@yahoo.ca>.
David Sean Taylor <david <at> bluesunrise.com> writes:

> 
> Have you looked at the file server pipeline?
> There is a simple example of the demo page (pdf.link) of the default 
> install.
> 
> Example:
> 
> /jetspeed/fileserver/_content/sample_pdf.pdf
> 

David,
I was unaware of this capability. 

So I took a look at serveral resources in the jetspeed source including 
pdf.link, /assembly/pipelines.xml, the FilePortlet and the FileServerValve.

What is unclear to me is the link between the path in pdf.link and 
the FileServerValve itself.  I assume that the fact that the path contains
fileserver/_content triggers the use of the whole mechanism. But I cannot
find where this is configured.

I am not that familiar with the pipeline (although I have checked out the
online documentation), but I assume that every Valve in the pipeline is always
invoked (ie. there is no forking/logic that produces different paths through
the pipeline).

So if that is the case, what causes the URI above to be directed to the
portlet configured for the FileServerValve (demo::ContentViewer in
pipelines.xml)?

Also, the documentation for the pipeline is a good start, but what is missing
is a guide to adding your own valve to the pipeline describing where in the
pipeline a custom valve should be placed (eg. there are probably some key 
valves that should go before it and perhaps some that must go after it
depending on what you are doing), how to configure it, etc.

I think in my case, I would want to leave the existing file server mechanism
in place (although it uses a demo portlet, so I'm not sure how that will
be impacted if I build/deploy without the demo application).

So I'd want to set up a similar mechanism so that I can create a link with
a URI with some parameters, eg /jetspeed/mybinaries/binary?resourceID=XYZ
that will get directed to a portlet in my portlet application that will
be similar to the FilePortlet.  

In the FilePortlet I will have to use the request parameters to identify
the correct resource on the filesystem (it will not be deployed as part of
any servlet/portlet application), do a number of security checks and finally
change the response type and render the binary content.

So, I assume I'd need to insert another valve component similar to the
FileServerValve and configure it in a similar way.  But how do you tie
the rest together?

thanks,
aaron




---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: file download in portlet

Posted by Martin Dulisch <md...@gmail.com>.
No, I dont know the file server pipeline.

Is it possible to generate dynamic binary content by this pipeline?


2005/12/16, David Sean Taylor <da...@bluesunrise.com>:
> Have you looked at the file server pipeline?
> There is a simple example of the demo page (pdf.link) of the default
> install.
>
> Example:
>
> /jetspeed/fileserver/_content/sample_pdf.pdf
>
>
> Martin Dulisch wrote:
> > Hi,
> >
> > I am using a way that is supported by jetspeed. You can request
> > directly  a portlet by accessing it through the portlet-pipeline. Than
> > it is possible to write binary content into the PortletResponse.
> >
> > Martin
> >
> >
> > 2005/12/13, Cubehead <cu...@gmail.com>:
> >
> >>Hi all,
> >>
> >>I wish to create a JSR-168 compliant portlet that will display a list of
> >>files with meta-data and then provide a link download the binary file.
> >>
> >>The files will not be public and access control will be on a user by user
> >>basis.
> >>
> >>Has anyone figured out a way to do this?
> >>
> >>thanks kindly,
> >>Cubehead
> >>
> >>
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> > For additional commands, e-mail: jetspeed-user-help@portals.apache.org
> >
> >
> >
>
>
> --
> David Sean Taylor
> Bluesunrise Software
> david@bluesunrise.com
> [office] +01 707 773-4646
> [mobile] +01 707 529 9194
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: file download in portlet

Posted by David Sean Taylor <da...@bluesunrise.com>.
Have you looked at the file server pipeline?
There is a simple example of the demo page (pdf.link) of the default 
install.

Example:

/jetspeed/fileserver/_content/sample_pdf.pdf


Martin Dulisch wrote:
> Hi,
> 
> I am using a way that is supported by jetspeed. You can request
> directly  a portlet by accessing it through the portlet-pipeline. Than
> it is possible to write binary content into the PortletResponse.
> 
> Martin
> 
> 
> 2005/12/13, Cubehead <cu...@gmail.com>:
> 
>>Hi all,
>>
>>I wish to create a JSR-168 compliant portlet that will display a list of
>>files with meta-data and then provide a link download the binary file.
>>
>>The files will not be public and access control will be on a user by user
>>basis.
>>
>>Has anyone figured out a way to do this?
>>
>>thanks kindly,
>>Cubehead
>>
>>
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
> For additional commands, e-mail: jetspeed-user-help@portals.apache.org
> 
> 
> 


-- 
David Sean Taylor
Bluesunrise Software
david@bluesunrise.com
[office] +01 707 773-4646
[mobile] +01 707 529 9194

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org


Re: file download in portlet

Posted by Martin Dulisch <md...@gmail.com>.
Hi,

I am using a way that is supported by jetspeed. You can request
directly  a portlet by accessing it through the portlet-pipeline. Than
it is possible to write binary content into the PortletResponse.

Martin


2005/12/13, Cubehead <cu...@gmail.com>:
> Hi all,
>
> I wish to create a JSR-168 compliant portlet that will display a list of
> files with meta-data and then provide a link download the binary file.
>
> The files will not be public and access control will be on a user by user
> basis.
>
> Has anyone figured out a way to do this?
>
> thanks kindly,
> Cubehead
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-user-help@portals.apache.org