Re: how do I redirect in an Action?
Peter Lerche wrote: Hi, I have followed this thread with interest and noted what Chris wrote. Edgar, AFAIK this is not true. map:act can contain all other tags that are allowed within a pipeline. However, what about nested map:act tags. No problem. An example is the mod-db sample sitemap. (In scratchpad for 2.0.x.) Not sure whether nesting works with action-sets, though. map:match pattern=form/validation/* map:act type=form-validator/ map:parameter name=descriptor value=descriptor.xml/ map:parameter name=validate-set value={1}/ !-- form validation OK -- map:act type=db-saveform/ !-- ??? '/' closes tag ??? -- !-- thus following parameters belong to form-validator ? -- map:parameter name=table value=formtest/ !-- form validation OK -- !-- form saved in db OK -- map:generator yy/ map:serialize xx/ /map:act !-- form saved in db ERROR -- map:generator z/ map:serialize v/ /map:act !-- form validation Error -- map:generator ww/ map:serialize qq/ /map:match Apart from the comment this looks reasonable. I have tried to get this working but without any luck. Does an error show up in your logs? Chris. -- C h r i s t i a n H a u l [EMAIL PROTECTED] fingerprint: 99B0 1D9D 7919 644A 4837 7D73 FEF9 6856 335A 9E08 - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how do I redirect in an Action?
Hi, I have followed this thread with interest and noted what Chris wrote. Edgar, AFAIK this is not true. map:act can contain all other tags that are allowed within a pipeline. However, what about nested map:act tags. eg. map:match pattern=form/validation/* map:act type=form-validator/ map:parameter name=descriptor value=descriptor.xml/ map:parameter name=validate-set value={1}/ !-- form validation OK -- map:act type=db-saveform/ map:parameter name=table value=formtest/ !-- form validation OK -- !-- form saved in db OK -- map:generator yy/ map:serialize xx/ /map:act !-- form saved in db ERROR -- map:generator z/ map:serialize v/ /map:act !-- form validation Error -- map:generator ww/ map:serialize qq/ /map:match I have tried to get this working but without any luck. What is the correct way of doing this ? Peter Lerche On Thu, 2002-05-23 at 18:08, Christian Haul wrote: On 23.May.2002 -- 05:00 PM, Graaf, Edgar de (fin) wrote: Christopher, map:act... can't contain matchers, how else would cocoon know that the action should be run? Edgar, AFAIK this is not true. map:act can contain all other tags that are allowed within a pipeline. Depending on the amount of pipeline fragments protected by the action it would be worthwhile to use a subsitemap, though. Another misconception in this thread seems to be that the tags after the action will always be processed. That is only true if it was determined that they are part of the actual pipeline. The whole process is made in two steps: 1) determine what the pipeline actually contains by evaluating actions, matchers, selectors, call and redirect tags. A pipeline is terminated when a serializer is found. For the sake of brevity I consider a reader here to be a (generator + serializer). 2) Use the components (readers, generators, transformers, serializers) determined in step 1. Note that in this step no actions, matchers, or selectors are used. IOW if a serializer is nested inside a map:act tag, it effectively terminates the pipeline and tags beneath the map:act will not be considered. It works just like it was mentioned with redirects or calls. HTH Chris. -- C h r i s t i a n H a u l [EMAIL PROTECTED] fingerprint: 99B0 1D9D 7919 644A 4837 7D73 FEF9 6856 335A 9E08 - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
AW: how do I redirect in an Action?
Nested actions work - at least for me. Anyway, the xml snippet you send isn't valid: your second map:act is an empty tag but several lines down you close it the second time. Judith -Ursprüngliche Nachricht- Von: Peter Lerche [SMTP:[EMAIL PROTECTED]] Gesendet am: Dienstag, 28. Mai 2002 12:48 An: [EMAIL PROTECTED] Betreff: Re: how do I redirect in an Action? Hi, I have followed this thread with interest and noted what Chris wrote. Edgar, AFAIK this is not true. map:act can contain all other tags that are allowed within a pipeline. However, what about nested map:act tags. eg. map:match pattern=form/validation/* map:act type=form-validator/ map:parameter name=descriptor value=descriptor.xml/ map:parameter name=validate-set value={1}/ !-- form validation OK -- map:act type=db-saveform/ map:parameter name=table value=formtest/ !-- form validation OK -- !-- form saved in db OK -- map:generator yy/ map:serialize xx/ /map:act !-- form saved in db ERROR -- map:generator z/ map:serialize v/ /map:act !-- form validation Error -- map:generator ww/ map:serialize qq/ /map:match I have tried to get this working but without any luck. What is the correct way of doing this ? Peter Lerche On Thu, 2002-05-23 at 18:08, Christian Haul wrote: On 23.May.2002 -- 05:00 PM, Graaf, Edgar de (fin) wrote: Christopher, map:act... can't contain matchers, how else would cocoon know that the action should be run? Edgar, AFAIK this is not true. map:act can contain all other tags that are allowed within a pipeline. Depending on the amount of pipeline fragments protected by the action it would be worthwhile to use a subsitemap, though. Another misconception in this thread seems to be that the tags after the action will always be processed. That is only true if it was determined that they are part of the actual pipeline. The whole process is made in two steps: 1) determine what the pipeline actually contains by evaluating actions, matchers, selectors, call and redirect tags. A pipeline is terminated when a serializer is found. For the sake of brevity I consider a reader here to be a (generator + serializer). 2) Use the components (readers, generators, transformers, serializers) determined in step 1. Note that in this step no actions, matchers, or selectors are used. IOW if a serializer is nested inside a map:act tag, it effectively terminates the pipeline and tags beneath the map:act will not be considered. It works just like it was mentioned with redirects or calls. HTH Chris. -- C h r i s t i a n H a u l [EMAIL PROTECTED] fingerprint: 99B0 1D9D 7919 644A 4837 7D73 FEF9 6856 335A 9E08 - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: how do I redirect in an Action?
It totally depends on what you want to replace with your resource... if you have the pipeline like: == map:pipeline ... ... map:match pattern=page1.html map:generate src=page1.xml/ map:transform src=pageTohtml.xsl/ map:serialize type=html/ You can change this to the following: = map:resources map:resource name=standard map:transform src=pageTohtml.xsl/ map:serialize type=html/ /map:resource /map:resources map:pipelines map:pipeline ... ... map:match pattern=page1.html map:generate src=page1.xml/ map:call resource=standard/ /map:match ... /map:pipeline .. /map:pipelines The advantage is that if you change the stylesheet pageTohtml.xsl you only have to change it in one place. -Oorspronkelijk bericht- Van: Christopher Painter-Wakefield [mailto:[EMAIL PROTECTED]] Verzonden: donderdag 23 mei 2002 17:39 Aan: [EMAIL PROTECTED] Onderwerp: RE: how do I redirect in an Action? Thanks for all the suggestions. I'm pretty confused at this point, as I haven't used map:resource or map:select previously, so I need to spend some time understanding the code you've offered. One thing in particular I don't see is where I should put my normal generate, transform, and serialize steps for the protected URL. Do they just go after the call to the resource? -Christopher Hi Christopher and Edgar, Couple things. I could be wrong, but I believe in Edgar's example, the redirect would always execute (since it sits outside the action). Also, depending on how many protected url matchers you have, you can also delegate all work to a resource where you could put all your authentication and redirect logic (so you don't have to have it in each matcher). So you could do something like this: map:match pattern=some protected url map:call resource=authenticatedAccess map:parameter name=someIDForThisPipe value=foo/ ... any other params you might need to process this pipe ... /map:call /map:match map:match pattern=some other protected url map:call resource=authenticatedAccess map:parameter name=someIDForThisPipe value=bar/ ... any other params you might need to process this pipe ... /map:call /map:match And the resource might look like: map:resource name=authenticatedAccess map:act type=my-authenticator map:select type=parameter map:parameter name=parameter-selector-test value={authStatus}/ map:when test=success ... stuff to process pipeline based on params /map:when map:otherwise map:redirect-to uri=loginpage.html/ /map:otherwise /map:select /map:act /map:resource Anyway, hope that helps! Harry - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: how do I redirect in an Action?
This is how it works in my project. Christian Haul says the same I guess: Another misconception in this thread seems to be that the tags after the action will always be processed. That is only true if it was determined that they are part of the actual pipeline. -Oorspronkelijk bericht- Van: Lai, Harry [mailto:[EMAIL PROTECTED]] Verzonden: donderdag 23 mei 2002 17:49 Aan: '[EMAIL PROTECTED]' Onderwerp: RE: how do I redirect in an Action? Hi Edgar, I may be misunderstanding how actions work, but at least for how we've used them in our project, anything after an action always executes, regardless of whether the action returns a null Map or not. If an action returns a null Map, it skips the steps inside the act tag, but it will continue executing the steps after the act tag. If this isn't always the case, please let me know. I'll be the first to admit that my understanding of Cocoon is far from perfect! =) Harry -Original Message- From: Graaf, Edgar de (fin) [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 23, 2002 10:25 AM To: '[EMAIL PROTECTED]' Subject: RE: how do I redirect in an Action? Harry, I have to look in to you example later. But the last redirect is to a page that ask you to try again... when the action doesn't fail(the password is right) that redirect is not executed (that between the map:act is). -Oorspronkelijk bericht- Van: Lai, Harry [mailto:[EMAIL PROTECTED]] Verzonden: donderdag 23 mei 2002 17:19 Aan: '[EMAIL PROTECTED]' Onderwerp: RE: how do I redirect in an Action? Hi Christopher and Edgar, Couple things. I could be wrong, but I believe in Edgar's example, the redirect would always execute (since it sits outside the action). Also, depending on how many protected url matchers you have, you can also delegate all work to a resource where you could put all your authentication and redirect logic (so you don't have to have it in each matcher). So you could do something like this: map:match pattern=some protected url map:call resource=authenticatedAccess map:parameter name=someIDForThisPipe value=foo/ ... any other params you might need to process this pipe ... /map:call /map:match map:match pattern=some other protected url map:call resource=authenticatedAccess map:parameter name=someIDForThisPipe value=bar/ ... any other params you might need to process this pipe ... /map:call /map:match And the resource might look like: map:resource name=authenticatedAccess map:act type=my-authenticator map:select type=parameter map:parameter name=parameter-selector-test value={authStatus}/ map:when test=success ... stuff to process pipeline based on params /map:when map:otherwise map:redirect-to uri=loginpage.html/ /map:otherwise /map:select /map:act /map:resource Anyway, hope that helps! Harry -Original Message- X-Sybari-Space: From: Graaf, Edgar de (fin) [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 23, 2002 10:01 AM To: '[EMAIL PROTECTED]' Subject: RE: how do I redirect in an Action? Christopher, map:act... can't contain matchers, how else would cocoon know that the action should be run? try: map:match pattern=some protected url map:act type=my-authenticator ... /map:act map:redirect-to uri=loginpage.html/ /map:match map:match pattern=some other protected url map:act type=my-authenticator ... /map:act map:redirect-to uri=loginpage.html/ /map:match regards Edgar -Oorspronkelijk bericht- Van: Christopher Painter-Wakefield [mailto:[EMAIL PROTECTED]] Verzonden: donderdag 23 mei 2002 15:52 Aan: [EMAIL PROTECTED] Onderwerp: Re: how do I redirect in an Action? I'm trying to implement a homegrown authentication scheme. One of our types of users will be authenticated by coming into the system with appropriate credentials as request parameters in the URL (we will e-mail them their unique URL). This is to avoid generating a large number of user ids and requiring all these users to remember credentials for a system they will likely use once or twice a year. None of the existing server-level authentication schemes would seem to support this. Once the user has logged in by providing the correct credentials, I planned to store their identity and the fact that they have been authenticated in their session. So, each time a request is made to a protected page, I need to first check
RE: how do I redirect in an Action?
I tried the following: map:act type=session-validator map:parameter name=descriptor value=context://bugtrack//descriptors/params.xml/ map:parameter name=validate value=username,password/ map:match bla bla == protected area == /map:act !-- WHEN LOGIN DOESN'T FAIL THIS IS NEVER EXECUTED-- map:match pattern=* map:redirect-to uri=login/ /map:match Login is of course outside the protected area. It sets the session variable when the password is right. It is not high security, I know... This worked. So you where both right that a matcher can be inside map:act. Thanks! Regards -Oorspronkelijk bericht- Van: Christian Haul [mailto:[EMAIL PROTECTED]] Verzonden: donderdag 23 mei 2002 18:08 Aan: [EMAIL PROTECTED] Onderwerp: Re: how do I redirect in an Action? On 23.May.2002 -- 05:00 PM, Graaf, Edgar de (fin) wrote: Christopher, map:act... can't contain matchers, how else would cocoon know that the action should be run? Edgar, AFAIK this is not true. map:act can contain all other tags that are allowed within a pipeline. Depending on the amount of pipeline fragments protected by the action it would be worthwhile to use a subsitemap, though. Another misconception in this thread seems to be that the tags after the action will always be processed. That is only true if it was determined that they are part of the actual pipeline. The whole process is made in two steps: 1) determine what the pipeline actually contains by evaluating actions, matchers, selectors, call and redirect tags. A pipeline is terminated when a serializer is found. For the sake of brevity I consider a reader here to be a (generator + serializer). 2) Use the components (readers, generators, transformers, serializers) determined in step 1. Note that in this step no actions, matchers, or selectors are used. IOW if a serializer is nested inside a map:act tag, it effectively terminates the pipeline and tags beneath the map:act will not be considered. It works just like it was mentioned with redirects or calls. HTH Chris. -- C h r i s t i a n H a u l [EMAIL PROTECTED] fingerprint: 99B0 1D9D 7919 644A 4837 7D73 FEF9 6856 335A 9E08 - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: how do I redirect in an Action?
On 23.May.2002 -- 05:00 PM, Graaf, Edgar de (fin) wrote: Christopher, map:act... can't contain matchers, how else would cocoon know that the action should be run? Edgar, AFAIK this is not true. map:act can contain all other tags that are allowed within a pipeline. EDGAR - Okay prob. Then euh.. sorry Cristopher for misleading you. I have to adapt my program I guess. But I thought I copied the example provided by Cocoon. But still my example works (read on) Depending on the amount of pipeline fragments protected by the action it would be worthwhile to use a subsitemap, though. Another misconception in this thread seems to be that the tags after the action will always be processed. That is only true if it was determined that they are part of the actual pipeline. EDGAR - Agreed, because that is the whole concept my sollution is based upon. It works, that is for sure. Only maybe it is not the best sollution - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how do I redirect in an Action?
Liam Morley On Wed, 22 May 2002, Nicola Ken Barozzi wrote: From: Christopher Painter-Wakefield [EMAIL PROTECTED] What is the proper way to redirect in an Action? Why do you have to redirect in an action? I would not suggest it. Redirect instead in the sitemap based on the results of the Action. I've always used the redirect method of the Redirector class. I'm assuming that redirect uses a local, relative path (for internal links) and globalRedirect uses a global path (for external links), but I haven't tested this and can't be sure. I also assume that sessionmode dictates whether or not to pass the session cookie on (there is a similar attribute in the sitemap redirect-to), but again I'm not sure and haven't tested. there have been times where I have wanted to redirect to the referer from an action, so that the action simply changes the state of something on the website (for instance, a log-in). I suppose I could pass the referer's address to the sitemap.. I'd be interested in hearing reasons of keeping the redirect in the sitemap, other than the fact that any changes to java code mean recompiling/restarting.. but changes to the sitemap also require recompiling and restarting tomcat, which seem to take longer for me (as the sitemap can no longer be loaded from cache). Changes to the sitemap don't require recompiling and restarting tomcat. If you need to do it, there is something plainly wrong with your Cocoon; I can't imagine how you managed to keep using cocoon given this :-O Anyway, the main reason is architectural. Cocoon was made with a sitemap because this makes the flow control and the component declaration in a central place; the whole site is much easier to administer and the components are easier to reuse. If your Action redirects to a specific url, it's difficult to reuse it in other sitemaps. -- Nicola Ken Barozzi [EMAIL PROTECTED] - verba volant, scripta manent - (discussions get forgotten, just code remains) - - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: C2: how do I redirect in an Action?
map:match pattern=redirect map:act type=myaction map:redirect-to uri={dest}/ /map:act /map:match is the proper way. In the action 'myaction' a sitemap parameter is set that sets the nextpage, here it is called 'dest'... regards -Oorspronkelijk bericht- Van: Christopher Painter-Wakefield [mailto:[EMAIL PROTECTED]] Verzonden: woensdag 22 mei 2002 21:23 Aan: [EMAIL PROTECTED] Onderwerp: C2: how do I redirect in an Action? What is the proper way to redirect in an Action? I presume we are supposed to use the Redirector object, since nothing else seems able. I've looked at the Redirector interface, but the API docs have zero explanation (g!) of the methods. If this is the right object, then: 1) what is the difference between redirect() and globalRedirect() and which one should I use? 2) what is the meaning of the boolean sessionmode parameter? I've searched the list archives and looked through the source and am none the wiser. Thanks, Christopher - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how do I redirect in an Action?
I'm trying to implement a homegrown authentication scheme. One of our types of users will be authenticated by coming into the system with appropriate credentials as request parameters in the URL (we will e-mail them their unique URL). This is to avoid generating a large number of user ids and requiring all these users to remember credentials for a system they will likely use once or twice a year. None of the existing server-level authentication schemes would seem to support this. Once the user has logged in by providing the correct credentials, I planned to store their identity and the fact that they have been authenticated in their session. So, each time a request is made to a protected page, I need to first check the session to see if the user is already authenticated. If not, I need to check the request parameters, if available, against the database. If both of these fail, I need to redirect the user to a polite login failure page (at some point we will have users that use a traditional login mechanism, at which point we'll probably redirect to a login form). I read the Action docs and searched through the mail archives, and I thought I could do something like this: map:act type=my-authenticator map:match pattern=some protected url ... /map:match map:match pattern=some other protected url ... /map:match /map:act As I understood it, if the authentication fails, I would redirect to my failure page in the Action and return null to prevent anything inside the map:act element from running. If the authentication succeeds, I return an empty Map and the stuff inside the map:act element will run as usual. Now that I'm saying all that it doesn't sound very likely, but I swear I got it all from the docs. Any suggestions? -Christopher From: Christopher Painter-Wakefield [EMAIL PROTECTED] What is the proper way to redirect in an Action? Why do you have to redirect in an action? I would not suggest it. Redirect instead in the sitemap based on the results of the Action. -- Nicola Ken Barozzi [EMAIL PROTECTED] - verba volant, scripta manent - (discussions get forgotten, just code remains) - - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: how do I redirect in an Action?
Christopher, map:act... can't contain matchers, how else would cocoon know that the action should be run? try: map:match pattern=some protected url map:act type=my-authenticator ... /map:act map:redirect-to uri=loginpage.html/ /map:match map:match pattern=some other protected url map:act type=my-authenticator ... /map:act map:redirect-to uri=loginpage.html/ /map:match regards Edgar -Oorspronkelijk bericht- Van: Christopher Painter-Wakefield [mailto:[EMAIL PROTECTED]] Verzonden: donderdag 23 mei 2002 15:52 Aan: [EMAIL PROTECTED] Onderwerp: Re: how do I redirect in an Action? I'm trying to implement a homegrown authentication scheme. One of our types of users will be authenticated by coming into the system with appropriate credentials as request parameters in the URL (we will e-mail them their unique URL). This is to avoid generating a large number of user ids and requiring all these users to remember credentials for a system they will likely use once or twice a year. None of the existing server-level authentication schemes would seem to support this. Once the user has logged in by providing the correct credentials, I planned to store their identity and the fact that they have been authenticated in their session. So, each time a request is made to a protected page, I need to first check the session to see if the user is already authenticated. If not, I need to check the request parameters, if available, against the database. If both of these fail, I need to redirect the user to a polite login failure page (at some point we will have users that use a traditional login mechanism, at which point we'll probably redirect to a login form). I read the Action docs and searched through the mail archives, and I thought I could do something like this: map:act type=my-authenticator map:match pattern=some protected url ... /map:match map:match pattern=some other protected url ... /map:match /map:act As I understood it, if the authentication fails, I would redirect to my failure page in the Action and return null to prevent anything inside the map:act element from running. If the authentication succeeds, I return an empty Map and the stuff inside the map:act element will run as usual. Now that I'm saying all that it doesn't sound very likely, but I swear I got it all from the docs. Any suggestions? -Christopher From: Christopher Painter-Wakefield [EMAIL PROTECTED] What is the proper way to redirect in an Action? Why do you have to redirect in an action? I would not suggest it. Redirect instead in the sitemap based on the results of the Action. -- Nicola Ken Barozzi [EMAIL PROTECTED] - verba volant, scripta manent - (discussions get forgotten, just code remains) - - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: how do I redirect in an Action?
Hi Christopher and Edgar, Couple things. I could be wrong, but I believe in Edgar's example, the redirect would always execute (since it sits outside the action). Also, depending on how many protected url matchers you have, you can also delegate all work to a resource where you could put all your authentication and redirect logic (so you don't have to have it in each matcher). So you could do something like this: map:match pattern=some protected url map:call resource=authenticatedAccess map:parameter name=someIDForThisPipe value=foo/ ... any other params you might need to process this pipe ... /map:call /map:match map:match pattern=some other protected url map:call resource=authenticatedAccess map:parameter name=someIDForThisPipe value=bar/ ... any other params you might need to process this pipe ... /map:call /map:match And the resource might look like: map:resource name=authenticatedAccess map:act type=my-authenticator map:select type=parameter map:parameter name=parameter-selector-test value={authStatus}/ map:when test=success ... stuff to process pipeline based on params /map:when map:otherwise map:redirect-to uri=loginpage.html/ /map:otherwise /map:select /map:act /map:resource Anyway, hope that helps! Harry -Original Message- From: Graaf, Edgar de (fin) [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 23, 2002 10:01 AM To: '[EMAIL PROTECTED]' Subject: RE: how do I redirect in an Action? Christopher, map:act... can't contain matchers, how else would cocoon know that the action should be run? try: map:match pattern=some protected url map:act type=my-authenticator ... /map:act map:redirect-to uri=loginpage.html/ /map:match map:match pattern=some other protected url map:act type=my-authenticator ... /map:act map:redirect-to uri=loginpage.html/ /map:match regards Edgar -Oorspronkelijk bericht- Van: Christopher Painter-Wakefield [mailto:[EMAIL PROTECTED]] Verzonden: donderdag 23 mei 2002 15:52 Aan: [EMAIL PROTECTED] Onderwerp: Re: how do I redirect in an Action? I'm trying to implement a homegrown authentication scheme. One of our types of users will be authenticated by coming into the system with appropriate credentials as request parameters in the URL (we will e-mail them their unique URL). This is to avoid generating a large number of user ids and requiring all these users to remember credentials for a system they will likely use once or twice a year. None of the existing server-level authentication schemes would seem to support this. Once the user has logged in by providing the correct credentials, I planned to store their identity and the fact that they have been authenticated in their session. So, each time a request is made to a protected page, I need to first check the session to see if the user is already authenticated. If not, I need to check the request parameters, if available, against the database. If both of these fail, I need to redirect the user to a polite login failure page (at some point we will have users that use a traditional login mechanism, at which point we'll probably redirect to a login form). I read the Action docs and searched through the mail archives, and I thought I could do something like this: map:act type=my-authenticator map:match pattern=some protected url ... /map:match map:match pattern=some other protected url ... /map:match /map:act As I understood it, if the authentication fails, I would redirect to my failure page in the Action and return null to prevent anything inside the map:act element from running. If the authentication succeeds, I return an empty Map and the stuff inside the map:act element will run as usual. Now that I'm saying all that it doesn't sound very likely, but I swear I got it all from the docs. Any suggestions? -Christopher From: Christopher Painter-Wakefield [EMAIL PROTECTED] What is the proper way to redirect in an Action? Why do you have to redirect in an action? I would not suggest it. Redirect instead in the sitemap based on the results of the Action. -- Nicola Ken Barozzi [EMAIL PROTECTED] - verba volant, scripta manent - (discussions get forgotten, just code remains
RE: how do I redirect in an Action?
Thanks for all the suggestions. I'm pretty confused at this point, as I haven't used map:resource or map:select previously, so I need to spend some time understanding the code you've offered. One thing in particular I don't see is where I should put my normal generate, transform, and serialize steps for the protected URL. Do they just go after the call to the resource? -Christopher Hi Christopher and Edgar, Couple things. I could be wrong, but I believe in Edgar's example, the redirect would always execute (since it sits outside the action). Also, depending on how many protected url matchers you have, you can also delegate all work to a resource where you could put all your authentication and redirect logic (so you don't have to have it in each matcher). So you could do something like this: map:match pattern=some protected url map:call resource=authenticatedAccess map:parameter name=someIDForThisPipe value=foo/ ... any other params you might need to process this pipe ... /map:call /map:match map:match pattern=some other protected url map:call resource=authenticatedAccess map:parameter name=someIDForThisPipe value=bar/ ... any other params you might need to process this pipe ... /map:call /map:match And the resource might look like: map:resource name=authenticatedAccess map:act type=my-authenticator map:select type=parameter map:parameter name=parameter-selector-test value={authStatus}/ map:when test=success ... stuff to process pipeline based on params /map:when map:otherwise map:redirect-to uri=loginpage.html/ /map:otherwise /map:select /map:act /map:resource Anyway, hope that helps! Harry - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: how do I redirect in an Action?
Hi Edgar, I may be misunderstanding how actions work, but at least for how we've used them in our project, anything after an action always executes, regardless of whether the action returns a null Map or not. If an action returns a null Map, it skips the steps inside the act tag, but it will continue executing the steps after the act tag. If this isn't always the case, please let me know. I'll be the first to admit that my understanding of Cocoon is far from perfect! =) Harry -Original Message- From: Graaf, Edgar de (fin) [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 23, 2002 10:25 AM To: '[EMAIL PROTECTED]' Subject: RE: how do I redirect in an Action? Harry, I have to look in to you example later. But the last redirect is to a page that ask you to try again... when the action doesn't fail(the password is right) that redirect is not executed (that between the map:act is). -Oorspronkelijk bericht- Van: Lai, Harry [mailto:[EMAIL PROTECTED]] Verzonden: donderdag 23 mei 2002 17:19 Aan: '[EMAIL PROTECTED]' Onderwerp: RE: how do I redirect in an Action? Hi Christopher and Edgar, Couple things. I could be wrong, but I believe in Edgar's example, the redirect would always execute (since it sits outside the action). Also, depending on how many protected url matchers you have, you can also delegate all work to a resource where you could put all your authentication and redirect logic (so you don't have to have it in each matcher). So you could do something like this: map:match pattern=some protected url map:call resource=authenticatedAccess map:parameter name=someIDForThisPipe value=foo/ ... any other params you might need to process this pipe ... /map:call /map:match map:match pattern=some other protected url map:call resource=authenticatedAccess map:parameter name=someIDForThisPipe value=bar/ ... any other params you might need to process this pipe ... /map:call /map:match And the resource might look like: map:resource name=authenticatedAccess map:act type=my-authenticator map:select type=parameter map:parameter name=parameter-selector-test value={authStatus}/ map:when test=success ... stuff to process pipeline based on params /map:when map:otherwise map:redirect-to uri=loginpage.html/ /map:otherwise /map:select /map:act /map:resource Anyway, hope that helps! Harry -Original Message- From: Graaf, Edgar de (fin) [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 23, 2002 10:01 AM To: '[EMAIL PROTECTED]' Subject: RE: how do I redirect in an Action? Christopher, map:act... can't contain matchers, how else would cocoon know that the action should be run? try: map:match pattern=some protected url map:act type=my-authenticator ... /map:act map:redirect-to uri=loginpage.html/ /map:match map:match pattern=some other protected url map:act type=my-authenticator ... /map:act map:redirect-to uri=loginpage.html/ /map:match regards Edgar -Oorspronkelijk bericht- Van: Christopher Painter-Wakefield [mailto:[EMAIL PROTECTED]] Verzonden: donderdag 23 mei 2002 15:52 Aan: [EMAIL PROTECTED] Onderwerp: Re: how do I redirect in an Action? I'm trying to implement a homegrown authentication scheme. One of our types of users will be authenticated by coming into the system with appropriate credentials as request parameters in the URL (we will e-mail them their unique URL). This is to avoid generating a large number of user ids and requiring all these users to remember credentials for a system they will likely use once or twice a year. None of the existing server-level authentication schemes would seem to support this. Once the user has logged in by providing the correct credentials, I planned to store their identity and the fact that they have been authenticated in their session. So, each time a request is made to a protected page, I need to first check the session to see if the user is already authenticated. If not, I need to check the request parameters, if available, against the database. If both of these fail, I need to redirect the user to a polite login failure page (at some point we will have users that use a traditional login mechanism, at which point we'll probably redirect to a login form). I read the Action docs and searched through the mail archives, and I thought I could do something like this: map:act type=my-authenticator map:match
RE: how do I redirect in an Action?
Hi Christopher, Sorry for not being clearer on that. Your normal generate, transform, and serialize steps would go where I have the vague ... stuff to process pipeline based on params text. =) Feel free to send me any other questions you have once you get a chance to look at resources and selects! Harry -Original Message- From: Christopher Painter-Wakefield [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 23, 2002 10:39 AM To: [EMAIL PROTECTED] Subject: RE: how do I redirect in an Action? Thanks for all the suggestions. I'm pretty confused at this point, as I haven't used map:resource or map:select previously, so I need to spend some time understanding the code you've offered. One thing in particular I don't see is where I should put my normal generate, transform, and serialize steps for the protected URL. Do they just go after the call to the resource? -Christopher Hi Christopher and Edgar, Couple things. I could be wrong, but I believe in Edgar's example, the redirect would always execute (since it sits outside the action). Also, depending on how many protected url matchers you have, you can also delegate all work to a resource where you could put all your authentication and redirect logic (so you don't have to have it in each matcher). So you could do something like this: map:match pattern=some protected url map:call resource=authenticatedAccess map:parameter name=someIDForThisPipe value=foo/ ... any other params you might need to process this pipe ... /map:call /map:match map:match pattern=some other protected url map:call resource=authenticatedAccess map:parameter name=someIDForThisPipe value=bar/ ... any other params you might need to process this pipe ... /map:call /map:match And the resource might look like: map:resource name=authenticatedAccess map:act type=my-authenticator map:select type=parameter map:parameter name=parameter-selector-test value={authStatus}/ map:when test=success ... stuff to process pipeline based on params /map:when map:otherwise map:redirect-to uri=loginpage.html/ /map:otherwise /map:select /map:act /map:resource Anyway, hope that helps! Harry - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how do I redirect in an Action?
On 23.May.2002 -- 05:00 PM, Graaf, Edgar de (fin) wrote: Christopher, map:act... can't contain matchers, how else would cocoon know that the action should be run? Edgar, AFAIK this is not true. map:act can contain all other tags that are allowed within a pipeline. Depending on the amount of pipeline fragments protected by the action it would be worthwhile to use a subsitemap, though. Another misconception in this thread seems to be that the tags after the action will always be processed. That is only true if it was determined that they are part of the actual pipeline. The whole process is made in two steps: 1) determine what the pipeline actually contains by evaluating actions, matchers, selectors, call and redirect tags. A pipeline is terminated when a serializer is found. For the sake of brevity I consider a reader here to be a (generator + serializer). 2) Use the components (readers, generators, transformers, serializers) determined in step 1. Note that in this step no actions, matchers, or selectors are used. IOW if a serializer is nested inside a map:act tag, it effectively terminates the pipeline and tags beneath the map:act will not be considered. It works just like it was mentioned with redirects or calls. HTH Chris. -- C h r i s t i a n H a u l [EMAIL PROTECTED] fingerprint: 99B0 1D9D 7919 644A 4837 7D73 FEF9 6856 335A 9E08 - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how do I redirect in an Action?
Chris, if I do a redirect in an Action, does that effectively terminate the pipeline also? Also, is my understanding correct that if I create an Action that merely returns a new Map, this is essentially a no-action and will leave the pipeline unaffected? -Christopher On 23.May.2002 -- 05:00 PM, Graaf, Edgar de (fin) wrote: Christopher, map:act... can't contain matchers, how else would cocoon know that the action should be run? Edgar, AFAIK this is not true. map:act can contain all other tags that are allowed within a pipeline. Depending on the amount of pipeline fragments protected by the action it would be worthwhile to use a subsitemap, though. Another misconception in this thread seems to be that the tags after the action will always be processed. That is only true if it was determined that they are part of the actual pipeline. The whole process is made in two steps: 1) determine what the pipeline actually contains by evaluating actions, matchers, selectors, call and redirect tags. A pipeline is terminated when a serializer is found. For the sake of brevity I consider a reader here to be a (generator + serializer). 2) Use the components (readers, generators, transformers, serializers) determined in step 1. Note that in this step no actions, matchers, or selectors are used. IOW if a serializer is nested inside a map:act tag, it effectively terminates the pipeline and tags beneath the map:act will not be considered. It works just like it was mentioned with redirects or calls. HTH Chris. -- C h r i s t i a n H a u l [EMAIL PROTECTED] fingerprint: 99B0 1D9D 7919 644A 4837 7D73 FEF9 6856 335A 9E08 - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how do I redirect in an Action?
On 23.May.2002 -- 01:15 PM, Christopher Painter-Wakefield wrote: if I do a redirect in an Action, does that effectively terminate the pipeline also? Yes it does. I have never used the redirector object but it should do exactly that. Using the redirector object and redirecting on sitemap level should be equivalent. Also, is my understanding correct that if I create an Action that merely returns a new Map, this is essentially a no-action and will leave the pipeline unaffected? If a map is returned, the tags nested within the action are included in the pipeline. If no map (null) is returned, they are not included. This obviously does not prevent you from using side effects of your action. A database action could still modify data. BTW it is not required to nest anything inside an action. Hence, if nothing is nested, it doesn't matter whether your action returns a map or not. HTH Chris. -- C h r i s t i a n H a u l [EMAIL PROTECTED] fingerprint: 99B0 1D9D 7919 644A 4837 7D73 FEF9 6856 335A 9E08 - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: how do I redirect in an Action?
Hi Chris, Thanks for the clarification on pipeline termination! I'd never actually tried that since I assumed pipelines that used actions followed the same rules as normal pipelines (it's a sitemap compilation error if a normal pipeline has anything after the serialize tag). Learn something new everyday. =) Harry -Original Message- From: Christian Haul [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 23, 2002 11:08 AM To: [EMAIL PROTECTED] Subject: Re: how do I redirect in an Action? snip/ Another misconception in this thread seems to be that the tags after the action will always be processed. That is only true if it was determined that they are part of the actual pipeline. The whole process is made in two steps: 1) determine what the pipeline actually contains by evaluating actions, matchers, selectors, call and redirect tags. A pipeline is terminated when a serializer is found. For the sake of brevity I consider a reader here to be a (generator + serializer). 2) Use the components (readers, generators, transformers, serializers) determined in step 1. Note that in this step no actions, matchers, or selectors are used. IOW if a serializer is nested inside a map:act tag, it effectively terminates the pipeline and tags beneath the map:act will not be considered. It works just like it was mentioned with redirects or calls. HTH Chris. -- C h r i s t i a n H a u l [EMAIL PROTECTED] fingerprint: 99B0 1D9D 7919 644A 4837 7D73 FEF9 6856 335A 9E08 - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
C2: how do I redirect in an Action?
What is the proper way to redirect in an Action? I presume we are supposed to use the Redirector object, since nothing else seems able. I've looked at the Redirector interface, but the API docs have zero explanation (g!) of the methods. If this is the right object, then: 1) what is the difference between redirect() and globalRedirect() and which one should I use? 2) what is the meaning of the boolean sessionmode parameter? I've searched the list archives and looked through the source and am none the wiser. Thanks, Christopher - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how do I redirect in an Action?
From: Christopher Painter-Wakefield [EMAIL PROTECTED] What is the proper way to redirect in an Action? Why do you have to redirect in an action? I would not suggest it. Redirect instead in the sitemap based on the results of the Action. -- Nicola Ken Barozzi [EMAIL PROTECTED] - verba volant, scripta manent - (discussions get forgotten, just code remains) - - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: how do I redirect in an Action?
I've always used the redirect method of the Redirector class. I'm assuming that redirect uses a local, relative path (for internal links) and globalRedirect uses a global path (for external links), but I haven't tested this and can't be sure. I also assume that sessionmode dictates whether or not to pass the session cookie on (there is a similar attribute in the sitemap redirect-to), but again I'm not sure and haven't tested. there have been times where I have wanted to redirect to the referer from an action, so that the action simply changes the state of something on the website (for instance, a log-in). I suppose I could pass the referer's address to the sitemap.. I'd be interested in hearing reasons of keeping the redirect in the sitemap, other than the fact that any changes to java code mean recompiling/restarting.. but changes to the sitemap also require recompiling and restarting tomcat, which seem to take longer for me (as the sitemap can no longer be loaded from cache). Liam Morley On Wed, 22 May 2002, Nicola Ken Barozzi wrote: From: Christopher Painter-Wakefield [EMAIL PROTECTED] What is the proper way to redirect in an Action? Why do you have to redirect in an action? I would not suggest it. Redirect instead in the sitemap based on the results of the Action. - Please check that your question has not already been answered in the FAQ before posting. http://xml.apache.org/cocoon/faqs.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]