question: private void handleJsonCreateAccount ( RequestAndResponse requestAndResponse ) throws IOException , ServletException { requestAndResponse . setResponseContentTypeJson ( ) ; String userName , password , password2 , email ; boolean mayContact = false ; String csrft ; try { final JsonNodeHelper json = getJsonNode ( requestAndResponse ) ; userName = json . getString ( "username" ) ; password = json . getString ( "password" ) ; password2 = json . getString ( "password2" ) ; email = json . getString ( "email" ) ; mayContact = json . getBoolean ( "mayContact" ) ; 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 ( ! allowSelfSignUp ) { returnJson400 ( requestAndResponse , servletText . errorSelfSignUpNotAllowed ( ) ) ; return ; } if ( userName == null || userName . isEmpty ( ) ) { returnJson400 ( requestAndResponse , servletText . errorUsernameMustNotBeBlank ( ) ) ; return ; } if ( password == null || password . isEmpty ( ) ) { returnJson400 ( requestAndResponse , servletText . errorFirstPasswordMustBeSet ( true , null ) ) ; return ; } if ( password == null || password2 . isEmpty ( ) ) { returnJson400 ( requestAndResponse , servletText . errorSecondPasswordMustBeSet ( true , null ) ) ; return ; } if ( ! password2 . equals ( password ) ) { returnJson400 ( requestAndResponse , servletText . errorPasswordsMustMatch ( ) ) ; return ; } if ( ! AccountAttributeValidator . isUserNameValid ( userName ) ) { returnJson400 ( requestAndResponse , servletText . errorUserNameIsNotValid ( ) ) ; return ; } if ( ! AccountAttributeValidator . isPasswordValid ( password ) ) { returnJson400 ( requestAndResponse , servletText . errorPasswordIsNotValid ( ) ) ; return ; } if ( email != null && email . isEmpty ( ) ) { email = null ; } if ( email != null && ! AccountAttributeValidator . isEmailValid ( email ) ) { returnJson400 ( requestAndResponse , servletText . errorEmailIsNotValid ( ) ) ; return ; } try { User user = dbLogic . getUserByUserName ( userName ) ; if ( user != null ) { returnJson400 ( requestAndResponse , servletText . errorUserNameIsAlreadyTaken ( ) ) ; return ; } user = dbLogic . createUser ( userName ) ; if ( user == null ) { returnJson400 ( requestAndResponse , servletText . errorCouldNotCreateAccount ( ) ) ; return ; } user . setPassword ( DigestUtils . sha1Hex ( password ) ) ; user . setEmail ( email ) ; user . setMayContact ( mayContact ) ; 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. 