question: private void handleJsonSignIn ( RequestAndResponse requestAndResponse ) throws IOException , ServletException { requestAndResponse . setResponseContentTypeJson ( ) ; String userName ; String password ; String csrft ; try { final JsonNodeHelper json = getJsonNode ( requestAndResponse ) ; userName = json . getString ( "username" ) ; password = json . getString ( "password" ) ; csrft = json . getString ( "csrft" ) ; } catch ( final IOException e ) { returnJson400 ( requestAndResponse , servletText . errorJson ( ) ) ; return ; } if ( userName != null ) { userName = userName . toLowerCase ( ) ; } if ( isTheCsrftWrong ( requestAndResponse , csrft ) ) { returnJson400 ( requestAndResponse , servletText . errorWrongCsrft ( ) ) ; return ; } if ( userName == null || userName . isEmpty ( ) ) { returnJson400 ( requestAndResponse , servletText . errorUsernameMustNotBeBlank ( ) ) ; return ; } if ( password == null || password . isEmpty ( ) ) { returnJson400 ( requestAndResponse , servletText . errorPasswordMustNotBeBlank ( ) ) ; return ; } if ( ! AccountAttributeValidator . isUserNameValid ( userName ) ) { returnJson400 ( requestAndResponse , servletText . errorUserNameIsNotValid ( ) ) ; return ; } if ( ! AccountAttributeValidator . isPasswordValid ( password ) ) { returnJson400 ( requestAndResponse , servletText . errorPasswordIsNotValid ( ) ) ; return ; } try { final User user = dbLogic . getUserByUserName ( userName ) ; if ( user == null ) { returnJson400 ( requestAndResponse , servletText . errorNoAccountFound ( ) ) ; return ; } if ( user . getIsAccountClosed ( ) ) { returnJson400 ( requestAndResponse , servletText . errorAccountIsClosed ( ) ) ; return ; } final String realPassword = user . getPassword ( ) ; if ( realPassword == null || ! realPassword . equals ( DigestUtils . sha1Hex ( password ) ) ) { returnJson400 ( requestAndResponse , servletText . errorPasswordIsIncorrect ( ) ) ; return ; } mapSessionToUser ( requestAndResponse , user . getId ( ) ) ; dbLogic . commit ( ) ; returnJson200 ( requestAndResponse ) ; } catch ( final PersistenceException e ) { logger . log ( Level . INFO , "Exception" , e ) ; returnJson500 ( requestAndResponse , servletText . errorInternalDatabase ( ) ) ; } }
target:  Part of the JSON API. Handles sign in requests. 