public SignInResponse login ( final LoginCredentials loginCreds ) { logger . debug ( "login(" + loginCreds + ")" ) ; try { setLoginState ( LOGGING_IN ) ; if ( ! loginCreds . isEncrypted ( ) ) { PublicKey key = Crypto . pubKeyFromBytes ( getWebService ( ) . getPublicKey ( ) ) ; loginCreds . encryptPassword ( key ) ; } logger . debug ( "Login Creds: " + loginCreds ) ; ServerResponse < ValidCredentials > response = ServerResponse . from ( ValidCredentials . class , getWebService ( ) . login ( loginCreds ) ) ; BackendUser user ; if ( response . getStatus ( ) . isSuccess ( ) ) { user = setUser ( response . get ( ) ) ; } else { logger . error ( "Login Failure(" + loginCreds . getEmailAddress ( ) + "): " + response . getStatus ( ) . getCode ( ) + " " + response . getError ( ) ) ; setLoginState ( LOGGED_OUT ) ; return new SignInResponse ( null , Status . SERVER_ERROR_INTERNAL , "Login failed" ) ; } return new SignInResponse ( user , response . getStatus ( ) , response . getError ( ) ) ; } catch ( Exception e ) { logger . error ( "Login Failure(" + loginCreds . getEmailAddress ( ) + ")" , e ) ; setLoginState ( LOGGED_OUT ) ; return new SignInResponse ( null , Status . SERVER_ERROR_INTERNAL , e . getLocalizedMessage ( ) ) ; } }
Syncronously attempt to log into user account