Hey.... What would be the easiest way to override "session.getAttribute" so a
default value is returned if no value exists in the session?

For example, if the following code was defined, I'd like to ensure some
defaults are returned if they haven't been set:

        Subject s = SecurityUtils.getSubject();
        Session session = s.getSession();
        
        String role = s.getAttribute("role") + ""; // I'd like this to
always return a value "test" if not defined.

What's the best way to intercept this? The problem I'm trying to solve is
this: 
- We have some sessions serialized to redis
- When we update our app and add new attributes to the session, the sessions
that are serialized in Redis don't have the new attributes
- When code goes to get the new attribute, it fails, because it's normally
set when the session was first created, not when it was deserialized from
Redis.











--
View this message in context: 
http://shiro-user.582556.n2.nabble.com/Ways-to-ensure-getAttribute-always-returns-a-default-value-tp7580338.html
Sent from the Shiro User mailing list archive at Nabble.com.

Reply via email to