You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Chris Mylonas <ch...@opencsta.org> on 2014/11/12 04:48:19 UTC

[tapestry-security] PageService return page

Hi Tapestry Users,

I'm porting some 5.3 (tapestry-security 0.5.1) to 5.4 (tapestry-security  
0.6.2).
In my Signin page, there's a declaration to

import org.tynamo.security.services.PageService ;

which is no longer found/available in 0.6.x

What happened to it?  (or where's a changelog?)

Thanks
Chris







It is used to return the success page in a login.



     @Inject
     private PageService pageService;



     @OnEvent(EventConstants.SUCCESS)
     public Object submit() {
         Subject currentUser = securityService.getSubject();

         if (currentUser == null) {
             throw new IllegalStateException("Subject can`t be null");
         }

         UsernamePasswordToken token = new UsernamePasswordToken(username,  
password);

         try {
             currentUser.login(token);
         } catch (UnknownAccountException e) {
             alertManager.error("Account not exists");
             return null;
         } catch (IncorrectCredentialsException e) {
             alertManager.error("Wrong password");
             return null;
         } catch (LockedAccountException e) {
             alertManager.error("Account locked");
             return null;
         } catch (AuthenticationException e) {
             alertManager.error("Authentication Error");
             return null;
         }

         SavedRequest savedRequest =  
WebUtils.getAndClearSavedRequest(requestGlobals.getHTTPServletRequest());

         // TODO: try using shiro's own WebUtils.redirectToSavedRequest
         if (savedRequest != null &&  
savedRequest.getMethod().equalsIgnoreCase("GET")) {
             try {
                 response.sendRedirect(savedRequest.getRequestUrl());
                 return null;
             } catch (IOException e) {
                 logger.warn("Can't redirect to saved request.");
                 return pageService.getSuccessPage();
             }
         } else {
             return pageService.getSuccessPage();
         }
     }

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [tapestry-security] PageService return page

Posted by Chris Mylonas <ch...@opencsta.org>.
OK cool, thx for quick response!!
On 12/11/2014 3:03 pm, "Kalle Korhonen" <ka...@gmail.com> wrote:

> On Tue, Nov 11, 2014 at 7:48 PM, Chris Mylonas <ch...@opencsta.org> wrote:
>
> > Hi Tapestry Users,
> > I'm porting some 5.3 (tapestry-security 0.5.1) to 5.4 (tapestry-security
> > 0.6.2).
> > In my Signin page, there's a declaration to
> > import org.tynamo.security.services.PageService ;
> > which is no longer found/available in 0.6.x
> > What happened to it?  (or where's a changelog?)
> >
>
> Replaced by LoginContextService (which is so far internal because the API
> is still in flux). It was already done in 0.4.x, see
> https://jira.codehaus.org/browse/TYNAMO-163 but PageService might have
> still been around as deprecated in 0.5.x.
>
> Kalle
>
>
>
> >
> >
> > It is used to return the success page in a login.
> >
> >
> >
> >     @Inject
> >     private PageService pageService;
> >
> >
> >
> >     @OnEvent(EventConstants.SUCCESS)
> >     public Object submit() {
> >         Subject currentUser = securityService.getSubject();
> >
> >         if (currentUser == null) {
> >             throw new IllegalStateException("Subject can`t be null");
> >         }
> >
> >         UsernamePasswordToken token = new UsernamePasswordToken(username,
> > password);
> >
> >         try {
> >             currentUser.login(token);
> >         } catch (UnknownAccountException e) {
> >             alertManager.error("Account not exists");
> >             return null;
> >         } catch (IncorrectCredentialsException e) {
> >             alertManager.error("Wrong password");
> >             return null;
> >         } catch (LockedAccountException e) {
> >             alertManager.error("Account locked");
> >             return null;
> >         } catch (AuthenticationException e) {
> >             alertManager.error("Authentication Error");
> >             return null;
> >         }
> >
> >         SavedRequest savedRequest = WebUtils.getAndClearSavedRequest(
> > requestGlobals.getHTTPServletRequest());
> >
> >         // TODO: try using shiro's own WebUtils.redirectToSavedRequest
> >         if (savedRequest != null &&
> savedRequest.getMethod().equalsIgnoreCase("GET"))
> > {
> >             try {
> >                 response.sendRedirect(savedRequest.getRequestUrl());
> >                 return null;
> >             } catch (IOException e) {
> >                 logger.warn("Can't redirect to saved request.");
> >                 return pageService.getSuccessPage();
> >             }
> >         } else {
> >             return pageService.getSuccessPage();
> >         }
> >     }
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>

Re: [tapestry-security] PageService return page

Posted by Kalle Korhonen <ka...@gmail.com>.
On Tue, Nov 11, 2014 at 7:48 PM, Chris Mylonas <ch...@opencsta.org> wrote:

> Hi Tapestry Users,
> I'm porting some 5.3 (tapestry-security 0.5.1) to 5.4 (tapestry-security
> 0.6.2).
> In my Signin page, there's a declaration to
> import org.tynamo.security.services.PageService ;
> which is no longer found/available in 0.6.x
> What happened to it?  (or where's a changelog?)
>

Replaced by LoginContextService (which is so far internal because the API
is still in flux). It was already done in 0.4.x, see
https://jira.codehaus.org/browse/TYNAMO-163 but PageService might have
still been around as deprecated in 0.5.x.

Kalle



>
>
> It is used to return the success page in a login.
>
>
>
>     @Inject
>     private PageService pageService;
>
>
>
>     @OnEvent(EventConstants.SUCCESS)
>     public Object submit() {
>         Subject currentUser = securityService.getSubject();
>
>         if (currentUser == null) {
>             throw new IllegalStateException("Subject can`t be null");
>         }
>
>         UsernamePasswordToken token = new UsernamePasswordToken(username,
> password);
>
>         try {
>             currentUser.login(token);
>         } catch (UnknownAccountException e) {
>             alertManager.error("Account not exists");
>             return null;
>         } catch (IncorrectCredentialsException e) {
>             alertManager.error("Wrong password");
>             return null;
>         } catch (LockedAccountException e) {
>             alertManager.error("Account locked");
>             return null;
>         } catch (AuthenticationException e) {
>             alertManager.error("Authentication Error");
>             return null;
>         }
>
>         SavedRequest savedRequest = WebUtils.getAndClearSavedRequest(
> requestGlobals.getHTTPServletRequest());
>
>         // TODO: try using shiro's own WebUtils.redirectToSavedRequest
>         if (savedRequest != null && savedRequest.getMethod().equalsIgnoreCase("GET"))
> {
>             try {
>                 response.sendRedirect(savedRequest.getRequestUrl());
>                 return null;
>             } catch (IOException e) {
>                 logger.warn("Can't redirect to saved request.");
>                 return pageService.getSuccessPage();
>             }
>         } else {
>             return pageService.getSuccessPage();
>         }
>     }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>