public JsonObject createSession ( @ NotNull final String sessionId ) { final JsonObject session = new JsonObject ( ) . put ( "id" , sessionId ) ; put ( "session" , session ) ; response ( ) . headersHandler ( new Handler < Void > ( ) { @ Override public void handle ( Void event ) { int responseStatus = response ( ) . getStatusCode ( ) ; // Only save on success and redirect status codes if ( responseStatus >= 200 && responseStatus < 400 ) { JsonObject session = get ( "session" ) ; if ( session != null ) { store . set ( sessionId , session , new Handler < Object > ( ) { @ Override public void handle ( Object error ) { if ( error != null ) { // TODO: better handling of errors System . err . println ( error ) ; } } } ) ; } } } } ) ; return session ; }
Create a new Session with custom Id and store it with the underlying storage . Internally create a entry in the request context under the name session and add a end handler to save that object once the execution is terminated . Custom session id could be used with external auth provider like mod - auth - mgr .