public int onLogonDialog ( ) { 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 ) ; LoginDialog dialog = new LoginDialog ( frame , true , strDisplay , strUserName ) ; if ( frame != null ) ScreenUtil . centerDialogInFrame ( dialog , frame ) ; dialog . setVisible ( true ) ; int iOption = dialog . getReturnStatus ( ) ; if ( iOption == LoginDialog . NEW_USER_OPTION ) iOption = this . createNewUser ( dialog ) ; if ( iOption != JOptionPane . OK_OPTION ) return iOption ; // Canceled dialog = You don't get in. strUserName = dialog . getUserName ( ) ; String strPassword = dialog . getPassword ( ) ; try { byte [ ] bytes = strPassword . getBytes ( Base64 . DEFAULT_ENCODING ) ; bytes = Base64 . encodeSHA ( bytes ) ; char [ ] chars = Base64 . encode ( bytes ) ; strPassword = new String ( chars ) ; } catch ( NoSuchAlgorithmException ex ) { ex . printStackTrace ( ) ; } catch ( UnsupportedEncodingException ex ) { ex . printStackTrace ( ) ; } String strDomain = this . getProperty ( Params . DOMAIN ) ; int iSuccess = this . getApplication ( ) . login ( this , strUserName , strPassword , strDomain ) ; if ( iSuccess == Constants . NORMAL_RETURN ) { // If they want to save the user... save it in a muffin. if ( this . getApplication ( ) . getMuffinManager ( ) != null ) if ( this . getApplication ( ) . getMuffinManager ( ) . isServiceAvailable ( ) ) { if ( dialog . getSaveState ( ) == true ) this . getApplication ( ) . getMuffinManager ( ) . setMuffin ( Params . USER_ID , this . getApplication ( ) . getProperty ( Params . USER_ID ) ) ; // Set muffin to current user. else this . getApplication ( ) . getMuffinManager ( ) . setMuffin ( Params . USER_ID , null ) ; // Set muffin to current user. } return iSuccess ; } // Otherwise, continue looping (3 times) } return this . setLastError ( strDisplay ) ; }
Display the logon dialog and login .