You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shiro.apache.org by Cristiano Gavião <cv...@gmail.com> on 2012/02/08 11:44:52 UTC

How to know if exists a shiro session from a browser perspective ?

Hi,

I'm developing a integration test for my application using selenium2 + 
webdriver.

At code I test if the user is authenticated using: 
subject.isAuthenticated()when the home page is called. If he is not, 
then he is forwarded for the login page.

I would like to simulate such situation. So anyone knows if there is a 
way to know (from a browser perspective) if there is or not a shiro 
session ?

thanks

Cristiano


Re: How to know if exists a shiro session from a browser perspective ?

Posted by Cristiano Gavião <cv...@gmail.com>.
Thanks Les,

I've modified the app that now shows the session state in home page 
footer... and now I can use it to test properly.

cheers

Cristiano

On 08/02/12 14:50, Les Hazlewood wrote:
> You can use whatever mechanism you want (e.g. create a JSP tag, or in
> a scriptlet) to call:
>
> SecurityUtils.getSubject().getSession(false)
>
> http://shiro.apache.org/static/current/apidocs/org/apache/shiro/subject/Subject.html#getSession(boolean)
>
> Regards,
>
> Les
>
> On Wed, Feb 8, 2012 at 2:44 AM, Cristiano Gavião<cv...@gmail.com>  wrote:
>> Hi,
>>
>> I'm developing a integration test for my application using selenium2 +
>> webdriver.
>>
>> At code I test if the user is authenticated using: subject.isAuthenticated()
>> when the home page is called. If he is not, then he is forwarded for the
>> login page.
>>
>> I would like to simulate such situation. So anyone knows if there is a way
>> to know (from a browser perspective) if there is or not a shiro session ?
>>
>> thanks
>>
>> Cristiano


Re: How to know if exists a shiro session from a browser perspective ?

Posted by Les Hazlewood <lh...@apache.org>.
You can use whatever mechanism you want (e.g. create a JSP tag, or in
a scriptlet) to call:

SecurityUtils.getSubject().getSession(false)

http://shiro.apache.org/static/current/apidocs/org/apache/shiro/subject/Subject.html#getSession(boolean)

Regards,

Les

On Wed, Feb 8, 2012 at 2:44 AM, Cristiano Gavião <cv...@gmail.com> wrote:
> Hi,
>
> I'm developing a integration test for my application using selenium2 +
> webdriver.
>
> At code I test if the user is authenticated using: subject.isAuthenticated()
> when the home page is called. If he is not, then he is forwarded for the
> login page.
>
> I would like to simulate such situation. So anyone knows if there is a way
> to know (from a browser perspective) if there is or not a shiro session ?
>
> thanks
>
> Cristiano