public static Session loadFromHttpSession ( Preset preset , HttpSession httpSession ) { String mnoSessEntry = ( String ) httpSession . getAttribute ( MAESTRANO_SESSION_ID ) ; if ( mnoSessEntry == null ) { return new Session ( preset ) ; } Map < String , String > sessionObj ; try { Gson gson = new Gson ( ) ; String decryptedSession = new String ( DatatypeConverter . parseBase64Binary ( mnoSessEntry ) , "UTF-8" ) ; Type type = new TypeToken < Map < String , String > > ( ) { } . getType ( ) ; sessionObj = gson . fromJson ( decryptedSession , type ) ; } catch ( Exception e ) { logger . error ( "could not deserialized maestrano session: " + mnoSessEntry , e ) ; throw new RuntimeException ( "could not deserialized maestrano session: " + mnoSessEntry , e ) ; } // Assign attributes String uid = sessionObj . get ( "uid" ) ; String groupUid = sessionObj . get ( "group_uid" ) ; String sessionToken = sessionObj . get ( "session" ) ; Date recheck ; // Session Recheck try { recheck = MnoDateHelper . fromIso8601 ( sessionObj . get ( "session_recheck" ) ) ; } catch ( Exception e ) { recheck = new Date ( ( new Date ( ) ) . getTime ( ) - 1 * 60 * 1000 ) ; } return new Session ( preset , uid , groupUid , recheck , sessionToken ) ; }
Retrieving Maestrano session from httpSession returns an empty Session if there is no Session