Return-Path: X-Original-To: apmail-struts-user-archive@www.apache.org Delivered-To: apmail-struts-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EF12610BDB for ; Fri, 12 Jul 2013 11:34:32 +0000 (UTC) Received: (qmail 37249 invoked by uid 500); 12 Jul 2013 11:34:31 -0000 Delivered-To: apmail-struts-user-archive@struts.apache.org Received: (qmail 37154 invoked by uid 500); 12 Jul 2013 11:34:31 -0000 Mailing-List: contact user-help@struts.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Struts Users Mailing List" Reply-To: "Struts Users Mailing List" Delivered-To: mailing list user@struts.apache.org Received: (qmail 37146 invoked by uid 99); 12 Jul 2013 11:34:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Jul 2013 11:34:30 +0000 X-ASF-Spam-Status: No, hits=2.2 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_NONE,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: error (athena.apache.org: local policy) Received: from [209.85.192.180] (HELO mail-pd0-f180.google.com) (209.85.192.180) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 12 Jul 2013 11:34:25 +0000 Received: by mail-pd0-f180.google.com with SMTP id 10so8449848pdi.11 for ; Fri, 12 Jul 2013 04:33:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:x-gm-message-state; bh=ETy4BWSppWYsQlLZuiiwkH63cchONkbST9NQLo6WnOo=; b=SU99AhdNzST4+G2+sD3homqQP3bsLxOLiXyTDNEb39hYqW3o5SJpOEA+5qhJ1qNVsu xKVVaoTHFHaY9m8yY3mtegvaUCQ8ud8gTtTeOsdDO0DSH5Rn8O9l4DDejcG0sOC/Cplm 8zlLGa3i3PF3idbAMBAbXc7K1UDVVWvMr5/G0XVg6vNvYoZo3aIBDstF6GS6n/CmMbRh a8G8BsBqnoefcVcqfFGRlfK1JTkJYaEyiXNSex4V9n9TFieaz3YtEA4qHDFPPi65+GWf TwajVyT2apVEKnMLdlW2xAm6zB90V+cnyrqFOjgsq/iUyDS8YG8Mjagt8mhXwJHb2adC Nhtg== MIME-Version: 1.0 X-Received: by 10.68.104.196 with SMTP id gg4mr41989253pbb.25.1373628823407; Fri, 12 Jul 2013 04:33:43 -0700 (PDT) Received: by 10.68.132.135 with HTTP; Fri, 12 Jul 2013 04:33:43 -0700 (PDT) In-Reply-To: <3755326.xmGJNfvh73@caridad> References: <1920484.F5dMfWpbVD@caridad> <4151683.X4RTdSuXFG@caridad> <3755326.xmGJNfvh73@caridad> Date: Fri, 12 Jul 2013 12:33:43 +0100 Message-ID: Subject: Re: S2 custom authentication: remembering original request From: Antonios Gkogkakis To: Struts Users Mailing List Content-Type: multipart/alternative; boundary=047d7b6705b9129a8704e14ee281 X-Gm-Message-State: ALoCoQljVj1iBXfCp/wkEu6jZS3fZLrcTQ5g5WDrZDWiFLSXXFHqBSLWbVeFn9JanFo8PgKNVUn+ X-Virus-Checked: Checked by ClamAV on apache.org --047d7b6705b9129a8704e14ee281 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable try request.setAttribute("url",invocation.getInvocationContext().getName()) in your interceptor. Antonios On 12 July 2013 12:03, Antonio S=E1nchez wrote: > I'm having problems with chaining. I have tried several ways but none > works. For instance: > > 1. http://localhost/mycontext/secure/protected =3D> Login.jsp > (${#request.url} is readable in jsp). > > 2. Login.jsp =3D> submit (correct user/pwd) =3D> ERROR: Infinite recursio= n > detected: [//authenticate!authenticate, //, //] (url not available as > request attribute) > > When submitting, request attribute 'url' is not present in the action, I > guess because result type of "input" is "dispatcher", not "chain", but > using type "chain" with a JSP causes St2 to complain, and won't find any > action. > > Pseudo-code: > > INTERCEPTOR > if (userInSession =3D=3D null) { > request.setAttribute("url", request.getServletPath()); > return "AUTHENTICATE"; > } > > return invocation.invoke(); > > STRUTS.XML > > - package base, namespace "" > - defines interceptor SECURE and default interceptor stack > (SECURE, DEFAULTSTACK). > - defines global result: > > authenticate > / > > > - package root extends base, namespace "/" > > > ${#request.url} > > /Login.jsp > > > - package secure extends base, namespace "/secure" > > /secure/Protected.jsp > > > ACTION AUTHENTICATE > > if (userInSession !=3D null ) { > request.getSession().setAttribute("USER_IN_SESSION", > userInSession); > //expecting original url is a request attribute > return SUCCESS; > } else { > return INPUT; > } > > At the moment I've not been able to implement the requirement. > > > El Mi=E9rcoles, 10 de julio de 2013 10:07:36 Paul Benedict escribi=F3: > > Forwarding to another action means you want to do chaining: > > http://struts.apache.org/release/2.3.x/docs/action-chaining.html > > > > > > autenticar > > > > > > > > On Wed, Jul 10, 2013 at 10:00 AM, Antonio S=E1nchez > > wrote: > > > > > Can't forward even without using global results: > > > > > > http://localhost:8084/mycontext/autenticar =3D> login.jsp - OK > > > > > > > > > /autenticar > > > > > > > > > http://localhost:8084/mycontext/forward =3D> 404 ERROR - > > > /mycontext/autenticar not available > > > > > > Which is the right way to forward to actions? > > > > > > Using 2.3.15. > > > > > > El Mi=E9rcoles, 10 de julio de 2013 15:29:51 usted escribi=F3: > > > > > Second question: because it's a redirect, hence a new request. > > > > > > > > http://localhost:8084/mycontext/autenticar =3D> login.jsp - OK > > > > > > > > Returned by interceptor: > > > > > > > > > > > > /autenticar > > > > > > > > > > > > http://localhost:8084/mycontext/admin/protected =3D> 404 ERROR - > > > /mycontext/autenticar not available > > > > > > > > How should I "forward" to actions? > > > > > > > > > > > > > > > > El Mi=E9rcoles, 10 de julio de 2013 07:43:38 Dave Newton escribi=F3= : > > > > > Second question: because it's a redirect, hence a new request. > > > > > > > > > > Dave > > > > > On Jul 10, 2013 7:28 AM, "Antonio S=E1nchez" < > juntandolineas@gmail.com> > > > > > > > > > > wrote: > > > > > > Use Case: request some protected resource -> redirect action fo= r > > > > > > authentication -> access protected resource. > > > > > > > > > > > > I'm using a custom interceptor that redirects (redirectAction) > to a > > > global > > > > > > result if no user object is found in session. The final action > > > result then > > > > > > redirects to a login page. > > > > > > > > > > > > The interceptor gets the original action requested (using > > > > > > request.getServletPath(), but not sure if this is right), and > puts > > > it in > > > > > > the value stack. It would be used with dynamic redirection in t= he > > > final > > > > > > result upon login success( ${nextAction} ) . This action must b= e > > > passed in > > > > > > between redirections. > > > > > > > > > > > > But I need to reuse the original request. Reconstructing the > request > > > with > > > > > > a query string is not an option. I need the original request: > > > GET/POST > > > > > > method, all parameters/values, maybe uploading binary content > > > > > > (inputstream), maybe headers... > > > > > > > > > > > > Is it possible to do this? How? > > > > > > > > > > > > ------ > > > > > > > > > > > > Partially related to this: I'm having problems with > redirections. The > > > > > > original request parameters are forwarded only using dispatcher > > > result . > > > > > > If > > > > > > I use redirectAction or redirect, original params are lost. Why= ? > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org > > > > > > For additional commands, e-mail: user-help@struts.apache.org > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org > > > For additional commands, e-mail: user-help@struts.apache.org > > > > > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org > For additional commands, e-mail: user-help@struts.apache.org > > > --047d7b6705b9129a8704e14ee281--