protected JsonResult login ( ) { T authToken ; authToken = loginViaBasicAuth ( servletRequest ) ; if ( authToken == null ) { authToken = loginViaRequestParams ( servletRequest ) ; } if ( authToken == null ) { log . warn ( "Login failed." ) ; return JsonResult . of ( HttpStatus . error401 ( ) . unauthorized ( "Login failed." ) ) ; } log . info ( "login OK!" ) ; final UserSession < T > userSession = new UserSession <> ( authToken , userAuth . tokenValue ( authToken ) ) ; userSession . start ( servletRequest , servletResponse ) ; // return token return tokenAsJson ( authToken ) ; }
Authenticate user and start user session .