public int onChangePassword ( ) { String strDisplay = "Login required" ; strDisplay = this . getTask ( ) . getString ( strDisplay ) ; for ( int i = 1 ; i < 3 ; i ++ ) { String strUserName = this . getProperty ( Params . USER_NAME ) ; Frame frame = ScreenUtil . getFrame ( this ) ; ChangePasswordDialog dialog = new ChangePasswordDialog ( frame , true , strDisplay , strUserName ) ; ScreenUtil . centerDialogInFrame ( dialog , frame ) ; dialog . setVisible ( true ) ; int iOption = dialog . getReturnStatus ( ) ; if ( iOption != JOptionPane . OK_OPTION ) return iOption ; // Canceled dialog = You don't get in. strUserName = dialog . getUserName ( ) ; String strPassword = dialog . getCurrentPassword ( ) ; String strNewPassword = dialog . getNewPassword ( ) ; try { byte [ ] bytes = strPassword . getBytes ( Base64 . DEFAULT_ENCODING ) ; bytes = Base64 . encodeSHA ( bytes ) ; char [ ] chars = Base64 . encode ( bytes ) ; strPassword = new String ( chars ) ; bytes = strNewPassword . getBytes ( Base64 . DEFAULT_ENCODING ) ; bytes = Base64 . encodeSHA ( bytes ) ; chars = Base64 . encode ( bytes ) ; strNewPassword = new String ( chars ) ; } catch ( NoSuchAlgorithmException ex ) { ex . printStackTrace ( ) ; } catch ( UnsupportedEncodingException ex ) { ex . printStackTrace ( ) ; } int errorCode = this . getApplication ( ) . createNewUser ( this , strUserName , strPassword , strNewPassword ) ; if ( errorCode == Constants . NORMAL_RETURN ) return errorCode ; } return this . setLastError ( strDisplay ) ; }
Display the change password dialog and change the password .