You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Will N." <ll...@yahoo.fr> on 2013/08/11 18:31:10 UTC

Apache Shiro

Hi,
i have some issues using shiro in my tapestry application. So far login 
and logout work almost perfect. I have a custom logout link which is an 
image but one logout text is still i guess automatically generated, so i 
have my image and the "logout" text(link). how can i avoid that?
The second problem is that i would like to display a dynamic welcome 
message with the surname or lastname (not the username used to login) of 
the authenticated user! How can I get to this informations? there must 
be an easy way, which i did'nt find.

This is how my .tml file looks like

                                     <t:security.authenticated>
                                             <table>
                                                 <tr>
                                                     <td>
                                                         <h2 
class="wellcomeMessage">
Willkommen <t:security.user><!-- surname or/and lastname of the 
authenticated user--></t:security.user>!&nbsp;
</h2>
<t:actionlink  t:id="logoutLink" id="logoutLink">
<img src="${message:logoutButton}" alt="${message:logout-text}"/>
</t:actionlink>
                                                       </td>
                                                   </tr>
                                               </table>
</t:security.authenticated>
<t:security.loginlink/>
thanks

Will

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


Re: Apache Shiro

Posted by "D.R." <d....@googlemail.com>.
Hi,

there are serveral ways to do that. An easy way would be to store a user
object as a principal and then do something like that:

<t:security.authenticated>
     ${username}
</t:security.authenticated>


public String getUsername(){
        final Subject currentUser = SecurityUtils.getSubject();
        final SomeClass user;
        if(currentUser.getPrincipals() != null){
            user = currentUser.getPrincipals().oneByType(SomeClass.class);
            return user.getSurename();
        } else {
            return "";
        }
}

With kind regards
David

Am 12.08.2013 09:06, schrieb Willy Browne:
> I am glad i made you laugh. I know how this works with tapestry and also would like to do/know how to do this with shiro, without using the userExists property if there is a way.
>
> Gesendet über Yahoo! Mail für Android
>
>


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


AW: RE: Apache Shiro

Posted by Willy Browne <ll...@yahoo.fr>.
I am glad i made you laugh. I know how this works with tapestry and also would like to do/know how to do this with shiro, without using the userExists property if there is a way.

Gesendet über Yahoo! Mail für Android


RE: Apache Shiro

Posted by Nomen Nominus <ge...@outlook.com>.
Haha, man, you made me so laugh!! :))I am not sure whether or not are you trolling, but you made my day bumping with this Q. on my Q. :D Hahahaha :))

I am not acquinted well enough with tapestry shiro, but as for the tapestry itself, there is a great shortcut including

    @Property
    private boolean userExists;

in your java

and in tml

                    
<t:if test='userExists'>


                            ${message:welcome} ${user.name}

<t:actionlink  t:id="logoutLink" id="logoutLink">
<img src="${message:logoutButton}" alt="${message:logout-text}"/>
</t:actionlink>
<p:else>

// here goes just login button ... ( or even register, ye ) :)
</p:else>
</t:if>

                    

So, if your user exists, just put "user exists" html code in that section, and if not, in else section.  

> Date: Sun, 11 Aug 2013 18:31:10 +0200
> From: llcool_willyj@yahoo.fr
> To: users@tapestry.apache.org
> Subject: Apache Shiro
> 
> Hi,
> i have some issues using shiro in my tapestry application. So far login 
> and logout work almost perfect. I have a custom logout link which is an 
> image but one logout text is still i guess automatically generated, so i 
> have my image and the "logout" text(link). how can i avoid that?
> The second problem is that i would like to display a dynamic welcome 
> message with the surname or lastname (not the username used to login) of 
> the authenticated user! How can I get to this informations? there must 
> be an easy way, which i did'nt find.
> 
> This is how my .tml file looks like
> 
>                                      <t:security.authenticated>
>                                              <table>
>                                                  <tr>
>                                                      <td>
>                                                          <h2 
> class="wellcomeMessage">
> Willkommen <t:security.user><!-- surname or/and lastname of the 
> authenticated user--></t:security.user>!&nbsp;
> </h2>
> <t:actionlink  t:id="logoutLink" id="logoutLink">
> <img src="${message:logoutButton}" alt="${message:logout-text}"/>
> </t:actionlink>
>                                                        </td>
>                                                    </tr>
>                                                </table>
> </t:security.authenticated>
> <t:security.loginlink/>
> thanks
> 
> Will
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>