How to configure session time out

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to configure session time out

J Prasanna Venkatesan
Hi All,

How to configure Session Time both through code and configuration file

Please let me know the same.

Thanks
J Prasanna
Reply | Threaded
Open this post in threaded view
|

Re: How to configure session time out

Tamas Cservenak
Hi there,

currently there is no "clean" way to do this. Nexus uses Shiro and it's default sessionTimeout (which is 30minutes).

But, from code, you could do something like below (is dirty): grab the SecuritySystem component

@Requirement
private SecuritySystem securitySystem;

and then use the code:

((AbstractSessionManager)((DefaultSecurityManager)securitySystem.getSecurityManager()).getSessionManager()).setGlobalSessionTimeout( XXX );

See Shiro Javadoc for net effect:


Also, as Javadoc states, you can do this per-session too, similarly like this:

        final Subject subject = ThreadContext.getSubject();
        final Session subjectSession = subject.getSession( false );
        if (subjectSession != null) {
            subjectSession.setTimeout( XXX );
        }


You have to be careful, as Nexus (since 1.9, but properly since 2.1 as Shiro was bumped to 1.2 featuring the noSessionCreation filter) explicitly sets "no session" for some clients... so be careful about session creation.

But i'd step back first: why and to what value you want to modify the session timeout?


Thanks,
~t~



On Mon, Sep 3, 2012 at 9:28 AM, J Prasanna Venkatesan <[hidden email]> wrote:
Hi All,

How to configure Session Time both through code and configuration file

Please let me know the same.

Thanks
J Prasanna



--
View this message in context: http://maven.40175.n5.nabble.com/How-to-configure-session-time-out-tp5719564.html
Sent from the Nexus Maven Repository Manager Dev List mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]