Christopher Schultz | 1 Jun 2011 21:23

Re: tomcat memory issue


André,

On 5/25/2011 11:14 AM, DAVIGNON Andre (Responsable du PANDOC) -
SG/SPSSI/CPII/DONP/PANDOC wrote:
> As far as I know, it is the same Tomcat engine that you run either on a
> 32 or 64 bits JVM. Only the JVM matters. If your JVM runs in 64 bits,
> Tomcat can use as much as memory allowed by the JVM.

+1

There is no "32-bit Tomcat", nor is there a "32-bit Cocoon": it all
depends upon the JVM.

AFAIK, both work just fine under a 64-bit JVM.

-chris
Des Magner | 8 Jun 2011 16:38

How to configure Velocity Tools

Hi 

Can anyone tell me how to configure my cocoon application in order that I can
use Velocity Tools in my velocity templates?

Thanks in Advance
Des
Paul Joseph | 8 Jun 2011 21:47
Picon
Gravatar

SPNEGO working in JSP, but how to bring it into Cocoon app?

Hi there,

By following this (http://spnego.sourceforge.net/spnego_tomcat.html) I was able to make a JSP page in my ROOT folder correctly display that my Single Sign On against Active Directory (Microsoft) was working.

Now my question is:  great, but how do I get my cocoon application, served by the same Tomcat instance, to use this capability?

Can I use the servlet somehow or do I have to use my flowscript to instantiate the classes involved?

The servelet requires the spnego.jar file in the library--so far so good.

But then in web.xml in the Tomcat conf, it has a number of settings for a "filter".

And then the JSP page itself has this single call that appears to be doing the magic: request.getRemoteUser();

Any pointers appreciated--I list the settings for the filter in the conf file web.xml below.

Bottom line question: how do I get the jsp call request.getRemoteUser() described above, reproduced in my cocoon application, which uses Flowscript and Java.

Paul

-------------
<filter> <filter-name>SpnegoHttpFilter</filter-name> <filter-class>net.sourceforge.spnego.SpnegoHttpFilter</filter-class> <init-param> <param-name>spnego.allow.basic</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>spnego.allow.localhost</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>spnego.allow.unsecure.basic</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>spnego.login.client.module</param-name> <param-value>spnego-client</param-value> </init-param> <init-param> <param-name>spnego.krb5.conf</param-name> <param-value>krb5.conf</param-value> </init-param> <init-param> <param-name>spnego.login.conf</param-name> <param-value>login.conf</param-value> </init-param> <init-param> <param-name>spnego.preauth.username</param-name> <param-value>Zeus</param-value> </init-param> <init-param> <param-name>spnego.preauth.password</param-name> <param-value>Z3usP <at> 55</param-value> </init-param> <init-param> <param-name>spnego.login.server.module</param-name> <param-value>spnego-server</param-value> </init-param> <init-param> <param-name>spnego.prompt.ntlm</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>spnego.logger.level</param-name> <param-value>1</param-value> </init-param> </filter> <filter-mapping> <filter-name>SpnegoHttpFilter</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping>
Paul Joseph | 12 Jun 2011 19:01
Picon
Gravatar

HttpServletRequest from Flowscript

Hi there,

Does anyone know how one can pass the Cocoon request to a java function 
that needs to use HttpServletRequest?

I passed in the cocoon.request  to the Java function using but inside 
the Java code I am not able to cast the cocoon request to the 
HttpServletRequest.

Any guidance would be appreciated.

Paul
Jos Snellings | 13 Jun 2011 06:00
Picon

Re: HttpServletRequest from Flowscript

Hi Paul,

C3 or C2.2?
In cocoon-3 you may want to use:

import org.apache.cocoon.servlet.util.HttpContextHelper;

HttpServletRequest request;

public void setup(Map<String, Object> parameters) {

     request = HttpContextHelper.getRequest(parameters);
     }
from within a cocoon generator.

Cheers,
Jos

On 06/12/2011 07:01 PM, Paul Joseph wrote:
> Hi there,
>
> Does anyone know how one can pass the Cocoon request to a java 
> function that needs to use HttpServletRequest?
>
> I passed in the cocoon.request  to the Java function using but inside 
> the Java code I am not able to cast the cocoon request to the 
> HttpServletRequest.
>
> Any guidance would be appreciated.
>
> Paul
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe <at> cocoon.apache.org
> For additional commands, e-mail: users-help <at> cocoon.apache.org
>
>
Paul Joseph | 13 Jun 2011 12:12
Picon
Gravatar

Re: HttpServletRequest from Flowscript

Hi Jos,

Thank your for your reply--I am using that old workhourse,  Cocoon 2.1 (.11)

I find that there it appears to be not that simple at all.  I use 
flowscript and Java and am trying to implement Windows Single SIgn On 
with SPNEGO.

The issue is that it needs HttpServletRequest while all I have in the 
flowscript is cocoon.request which is not the same.

I found the following method on the web.

a) get the application context (avalon)

     public void contextualize(Context context) throws ContextException {
             objectModel = ContextHelper.getObjectModel(context);
     }

b) then with the objectModel, we can do:
         final HttpServletRequest httpRequest = (HttpServletRequest) 
objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT);

Good...but my problem is simple and after many hours I still don't know 
how to do this:

How does one access the Avalon context in Javascript and then pass it to 
the Java layer?

Now after much reading I find that I should probably write an Action and 
use the sitemap to fire the action.  I gather the sitemap will 
automatically make the objectmodel available to my action code and then 
I can proceed as in step b above.  My only problem is I have never 
written or used an action and so am a bit wary.

rgds
Paul

On 6/13/2011 12:00 AM, Jos Snellings wrote:
> Hi Paul,
>
> C3 or C2.2?
> In cocoon-3 you may want to use:
>
> import org.apache.cocoon.servlet.util.HttpContextHelper;
>
> HttpServletRequest request;
>
> public void setup(Map<String, Object> parameters) {
>
>     request = HttpContextHelper.getRequest(parameters);
>     }
> from within a cocoon generator.
>
> Cheers,
> Jos
>
> On 06/12/2011 07:01 PM, Paul Joseph wrote:
>> Hi there,
>>
>> Does anyone know how one can pass the Cocoon request to a java 
>> function that needs to use HttpServletRequest?
>>
>> I passed in the cocoon.request  to the Java function using but inside 
>> the Java code I am not able to cast the cocoon request to the 
>> HttpServletRequest.
>>
>> Any guidance would be appreciated.
>>
>> Paul
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe <at> cocoon.apache.org
>> For additional commands, e-mail: users-help <at> cocoon.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe <at> cocoon.apache.org
> For additional commands, e-mail: users-help <at> cocoon.apache.org
>
>
Jos Snellings | 14 Jun 2011 07:31
Picon

Re: HttpServletRequest from Flowscript

Well, that seems indeed like a rather complex way to achieve a simple thing.

How about this:
- 2.1 still has a horse called "xsp", which is a scripting language 
ensuring nicely balanced tags. Like an "xml-ized" jsp.
   an xsp page has direct access to request data, and you have access to 
pages. I can send you an example.
- in 3 there is no xsp anymore (it got accused of witchcraft or so ;-) ).

Cheers,
Jos

On 06/13/2011 12:12 PM, Paul Joseph wrote:
> Hi Jos,
>
> Thank your for your reply--I am using that old workhourse,  Cocoon 2.1 
> (.11)
>
> I find that there it appears to be not that simple at all.  I use 
> flowscript and Java and am trying to implement Windows Single SIgn On 
> with SPNEGO.
>
> The issue is that it needs HttpServletRequest while all I have in the 
> flowscript is cocoon.request which is not the same.
>
> I found the following method on the web.
>
> a) get the application context (avalon)
>
>     public void contextualize(Context context) throws ContextException {
>             objectModel = ContextHelper.getObjectModel(context);
>     }
>
>
> b) then with the objectModel, we can do:
>         final HttpServletRequest httpRequest = (HttpServletRequest) 
> objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT);
>
>
> Good...but my problem is simple and after many hours I still don't 
> know how to do this:
>
> How does one access the Avalon context in Javascript and then pass it 
> to the Java layer?
>
> Now after much reading I find that I should probably write an Action 
> and use the sitemap to fire the action.  I gather the sitemap will 
> automatically make the objectmodel available to my action code and 
> then I can proceed as in step b above.  My only problem is I have 
> never written or used an action and so am a bit wary.
>
> rgds
> Paul
>
> On 6/13/2011 12:00 AM, Jos Snellings wrote:
>> Hi Paul,
>>
>> C3 or C2.2?
>> In cocoon-3 you may want to use:
>>
>> import org.apache.cocoon.servlet.util.HttpContextHelper;
>>
>> HttpServletRequest request;
>>
>> public void setup(Map<String, Object> parameters) {
>>
>>     request = HttpContextHelper.getRequest(parameters);
>>     }
>> from within a cocoon generator.
>>
>> Cheers,
>> Jos
>>
>> On 06/12/2011 07:01 PM, Paul Joseph wrote:
>>> Hi there,
>>>
>>> Does anyone know how one can pass the Cocoon request to a java 
>>> function that needs to use HttpServletRequest?
>>>
>>> I passed in the cocoon.request  to the Java function using but 
>>> inside the Java code I am not able to cast the cocoon request to the 
>>> HttpServletRequest.
>>>
>>> Any guidance would be appreciated.
>>>
>>> Paul
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe <at> cocoon.apache.org
>>> For additional commands, e-mail: users-help <at> cocoon.apache.org
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe <at> cocoon.apache.org
>> For additional commands, e-mail: users-help <at> cocoon.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe <at> cocoon.apache.org
> For additional commands, e-mail: users-help <at> cocoon.apache.org
>
>
Paul Joseph | 14 Jun 2011 12:59
Picon
Gravatar

Re: HttpServletRequest from Flowscript

Hi Jos,

I pulled out my old Cocoon book by Mathew Langham and Carsten Ziegeler 
and found that there is a racehorse in the stable called Action.

On pp. 250 of this book they have a simple example on how to implement 
an "action" and I did that and lo and behold all works now.

I was trying to implement Single Sign On in the Cocoon app against 
Microsoft Active directory and to save others that trouble I shall 
writeup post how I did it.

Thanks again for all your help.

Paul

On 6/14/2011 1:31 AM, Jos Snellings wrote:
> Well, that seems indeed like a rather complex way to achieve a simple 
> thing.
>
> How about this:
> - 2.1 still has a horse called "xsp", which is a scripting language 
> ensuring nicely balanced tags. Like an "xml-ized" jsp.
>   an xsp page has direct access to request data, and you have access 
> to pages. I can send you an example.
> - in 3 there is no xsp anymore (it got accused of witchcraft or so ;-) ).
>
> Cheers,
> Jos
>
> On 06/13/2011 12:12 PM, Paul Joseph wrote:
>> Hi Jos,
>>
>> Thank your for your reply--I am using that old workhourse,  Cocoon 
>> 2.1 (.11)
>>
>> I find that there it appears to be not that simple at all.  I use 
>> flowscript and Java and am trying to implement Windows Single SIgn On 
>> with SPNEGO.
>>
>> The issue is that it needs HttpServletRequest while all I have in the 
>> flowscript is cocoon.request which is not the same.
>>
>> I found the following method on the web.
>>
>> a) get the application context (avalon)
>>
>>     public void contextualize(Context context) throws ContextException {
>>             objectModel = ContextHelper.getObjectModel(context);
>>     }
>>
>>
>> b) then with the objectModel, we can do:
>>         final HttpServletRequest httpRequest = (HttpServletRequest) 
>> objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT);
>>
>>
>> Good...but my problem is simple and after many hours I still don't 
>> know how to do this:
>>
>> How does one access the Avalon context in Javascript and then pass it 
>> to the Java layer?
>>
>> Now after much reading I find that I should probably write an Action 
>> and use the sitemap to fire the action.  I gather the sitemap will 
>> automatically make the objectmodel available to my action code and 
>> then I can proceed as in step b above.  My only problem is I have 
>> never written or used an action and so am a bit wary.
>>
>> rgds
>> Paul
>>
>> On 6/13/2011 12:00 AM, Jos Snellings wrote:
>>> Hi Paul,
>>>
>>> C3 or C2.2?
>>> In cocoon-3 you may want to use:
>>>
>>> import org.apache.cocoon.servlet.util.HttpContextHelper;
>>>
>>> HttpServletRequest request;
>>>
>>> public void setup(Map<String, Object> parameters) {
>>>
>>>     request = HttpContextHelper.getRequest(parameters);
>>>     }
>>> from within a cocoon generator.
>>>
>>> Cheers,
>>> Jos
>>>
>>> On 06/12/2011 07:01 PM, Paul Joseph wrote:
>>>> Hi there,
>>>>
>>>> Does anyone know how one can pass the Cocoon request to a java 
>>>> function that needs to use HttpServletRequest?
>>>>
>>>> I passed in the cocoon.request  to the Java function using but 
>>>> inside the Java code I am not able to cast the cocoon request to 
>>>> the HttpServletRequest.
>>>>
>>>> Any guidance would be appreciated.
>>>>
>>>> Paul
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe <at> cocoon.apache.org
>>>> For additional commands, e-mail: users-help <at> cocoon.apache.org
>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe <at> cocoon.apache.org
>>> For additional commands, e-mail: users-help <at> cocoon.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe <at> cocoon.apache.org
>> For additional commands, e-mail: users-help <at> cocoon.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe <at> cocoon.apache.org
> For additional commands, e-mail: users-help <at> cocoon.apache.org
>
>
Paul Joseph | 14 Jun 2011 13:35
Picon
Gravatar

How to implement Single Sign On in a Cocoon application (Note: Cocoon 2.1.x)

Hi there,

I post this to save others needless hours of gazing into the "void."

The customer requested that Single Sign On (SSO) be implemented.

(Note: for newbies like me, I had to do some research and found that 
what this means.  Say like me, you have a cocoon application that is 
password protected and is on some server on the network.  With SSO, once 
a user is logged into their machine, they do not need to retype their 
username/password when they access this application.)

There are many implementations and a large number of acronyms and it was 
all very confusing.  But I found in the end, it was quite simple.

Let us say my Cocoon app is on a server called Cocoon_Server.  Now if 
the enterprise has SSO, then they have a "Domain Server" that we query 
to find out if the user has the proper credentials.  Lets say that the 
user is on a third machine called User_Computer.

There is a extremely useful resource http://spnego.sourceforge.net/ that 
provides everything you need with all the gobbledegook completely 
invisible to us.

Ideally, you would first implement the simple stand alone example that 
they provide to make sure that your SSO infrastructure and your 
development machine are setup correctly.
(http://spnego.sourceforge.net/pre_flight.html).  The one "GOTCHA" was 
that the is case sensitive and the documents at this link don't say 
that.  You must follow the exact case that they show in their example.

Once you have your SSO development infrastructure setup correctly, its 
time to integrate it into Cocoon.  I use flow script and Java, but there 
is a gotcha as at least in 2.1, cocoon.request returns a strange object 
that isn't quite compatible with HttpServletRequest and which is what 
you need for the spnego.jar file. To be able to do this, you need the 
ObjectModel passed to you and the easiest way I found was to do that 
using an "Action".

The first step is to put the spnego jar file from the site above into 
your lib directory.  I put it in cocoon/lib/local though probably 
putting it in the lib directory for my app would have been the more 
correct choice.

Then write a Cocoon "Action" as follows:

1) Put an entry for your action in your "root" sitemap:
<map:actions>
<map:action name="ssologin" 
src="org.apache.cocoon.myapplication.bean.SpnegoCocoonAuthenticator"/>
</map:actions>

2) in your Login page's sitemap, add the following:

<map:match pattern="ssologin">
<map:act type ="ssologin">
<map:call function="{ssologin}"/>
</map:act>
</map:match>

3) Write your action as follows, modifying  it if you need anything 
different:

package org.apache.cocoon.myapplication.bean;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URISyntaxException;
import java.security.Principal;
import java.security.PrivilegedActionException;
import java.util.HashMap;
import java.util.Map;

import javax.security.auth.login.LoginException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import net.sourceforge.spnego.SpnegoAuthenticator;
import net.sourceforge.spnego.SpnegoHttpFilter.Constants;
import net.sourceforge.spnego.SpnegoHttpServletResponse;
import net.sourceforge.spnego.SpnegoPrincipal;

import org.apache.catalina.LifecycleException;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
import org.ietf.jgss.GSSException;

import org.apache.cocoon.environment.http.HttpEnvironment;

import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.avalon.framework.parameters.Parameters;

import org.apache.cocoon.acting.Action;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.environment.SourceResolver;

public class SpnegoCocoonAuthenticator implements Action, Initializable, 
ThreadSafe {
     private HttpSession session = null;
     protected SpnegoAuthenticator authenticator = null;

     public final void initialize() throws LifecycleException {

         final Map<String, String> map = new HashMap<String, String>();
         map.put(Constants.ALLOW_BASIC, "true");
         map.put("spnego.allow.localhost", "true");
         map.put("spnego.allow.unsecure.basic", "true");
         map.put("spnego.login.client.module", "spnego-client");
         map.put("spnego.krb5.conf", "krb5.conf");
         map.put("spnego.login.conf", "login.conf");
         map.put("spnego.preauth.username", 
"Charlie_a_user_who_has_permissions_on_DOMAIN_SERVER");
         map.put("spnego.preauth.password", "StrongPassword");
         map.put("spnego.login.server.module", "spnego-server");
         map.put("spnego.prompt.ntlm", "true");
         map.put("spnego.allow.delegation", "true");
         map.put("spnego.logger.level", "1");

         try {
             authenticator = new SpnegoAuthenticator(map);
         } catch (LoginException e) {
             throw new LifecycleException(e);
         } catch (FileNotFoundException e) {
             throw new LifecycleException(e);
         } catch (GSSException e) {
             throw new LifecycleException(e);
         } catch (PrivilegedActionException e) {
             throw new LifecycleException(e);
         } catch (URISyntaxException e) {
             throw new LifecycleException(e);
         }
     }

     public Map act(Redirector redirector, SourceResolver resolver, Map 
objectModel, String src, Parameters parameters) throws Exception {

         final HttpServletRequest httpRequest = (HttpServletRequest) 
objectModel.get(HttpEnvironment.HTTP_REQUEST_OBJECT);

         final SpnegoHttpServletResponse spnegoResponse = new 
SpnegoHttpServletResponse(
                 (HttpServletResponse) (HttpServletResponse) 
objectModel.get(HttpEnvironment.HTTP_RESPONSE_OBJECT));

         final SpnegoPrincipal principal;

         try {
             principal = this.authenticator.authenticate(httpRequest, 
spnegoResponse);

         } catch (GSSException e) {
             throw new IOException(e);
         }

         //you now have the basic info.--if there is a valid name, the 
user is legit.
         //you can do more stuff if you need to like get her roles etc. 
but I didn't need any more.
         String userName = principal.getName();

         Map map = new HashMap(1);

         if(userName != null || !userName.equals(""))
             map.put("ssologin", "LoggedInScriptName");
         else
             map.put("ssologin", "InvalidUserScriptName");

         return map;
     }
}

4) Write a flowscript to handle "LoggedInScriptName" that puts the user 
right into the app as though she had typed the username/password.  Also, 
to handle an invalid user, write the InvalidUserScriptName to handle the 
case of an invalid user.

That's it.  Seems to work!  I need to remove the username/pwd and other 
hardcoding and streamline it a bit, but the above is more or less all 
one needs.

Best.
Paul
Robby Pelssers | 17 Jun 2011 13:18

problem with serialization Cocoon2.2


Hi all,

I have a strange situation I don't really understand.

In my sitemap I have following patterns:

           <!-- 
             {1}: basictype-id
             {2}: state
             {3}: topic-id
            -->
           <map:match pattern="basictype/*/*/*">
             <map:generate src="xquery/getTopic.xquery" type="queryStringXquery">
               <map:parameter name="basictypeId" value="{1}"/>             
               <map:parameter name="state" value="{2}"/>
               <map:parameter name="topicId" value="{3}"/>               
             </map:generate>
             <map:transform src="xslt/postprocessXqueryResults.xslt" type="saxon"/>
             <map:transform src="xslt/urlTransformer.xslt" type="saxon">
               <map:parameter name="contextpath" value="{request:contextPath}"/>
               <map:parameter name="drawingExtension" value="{request-param:drawingExtension}"/>             
             </map:transform>             
             <map:serialize type="p-topic"/>       
           </map:match>

           <map:match pattern="topic2xhtml/**">
             <map:generate src="cocoon:/{1}"/>
             <map:transform src="xslt/dita/xslhtml/dita2xhtml.xsl" type="saxon"/>
             <map:serialize type="xhtml"/>
           </map:match>

           <map:match pattern="test">
             <map:generate src="data/pinning_information.xml"/>
             <map:serialize type="xml"/>
           </map:match>

And configured following serializer:

          <map:serializer name="p-topic" logger="sitemap.serializer.xml"  
             mime-type="text/xml;charset=utf-8" src="org.apache.cocoon.serialization.XMLSerializer">
            <encoding>UTF-8</encoding>
            <doctype-public>-//NXP//DTD P-Topic//EN</doctype-public>
            <doctype-system>${p-topic-dtd}</doctype-system>
          </map:serializer>

The pattern "basictype/*/*/*" generates a DITA topic by transforming the result of an Xquery.

When I invoke
http://localhost:8888/topics/basictype/PH3330L/released/pinning_information?drawingExtension=gif
in the browser and save the result [1] to filesystem I see that the doctype has been added correctly:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE p-topic PUBLIC "-//NXP//DTD P-Topic//EN" "http://nww.qa.spider.nxp.com:8311/xmetal/schemas/p-topic.dtd">
<p-topic id="pinning_information">
  ...
</p-topic>

When I invoke
http://localhost:8888/topics/topic2xhtml/basictype/PH3330L/released/pinning_information I
would expect the topic to get transformed correctly into XHTML.  This does not work however.  Just for
testing purpose I added [1] in my app into /data/pinning_information.xml and created a new match pattern
which reads [1] from disc

But when i now try to invoke http://localhost:8888/topics/topic2xhtml/test the DITA topic does get
transformed correctly.

Is there a difference between 
a)  calling a pipeline that generates a DITA topic on the fly and serializes it using my custom serializer
which is used as input for the 
    topic2xhtml/**  pattern
b)  reading the DITA topic from filesystem which is used as input for the topic2xhtml/**  pattern

It looks like the class attributes which should be added by the DTD are not added in use-case (a) which is why
the transform fails.

Any insight is appreciated.

Kind regards,
Robby Pelssers

Gmane