public void openKeyStore(File keyStoreFile,String defaultPassword){
  try {
    if (!keyStoreFile.isFile()) {
      JOptionPane.showMessageDialog(frame,MessageFormat.format(res.getString("OpenAction.NotFile.message"),keyStoreFile),res.getString("OpenAction.OpenKeyStore.Title"),JOptionPane.WARNING_MESSAGE);
      return;
    }
    if (isKeyStoreFileOpen(keyStoreFile)) {
      JOptionPane.showMessageDialog(frame,MessageFormat.format(res.getString("OpenAction.NoOpenKeyStoreAlreadyOpen.message"),keyStoreFile),res.getString("OpenAction.OpenKeyStore.Title"),JOptionPane.WARNING_MESSAGE);
      return;
    }
    Password password=(defaultPassword != null) ? new Password(defaultPassword.toCharArray()) : null;
    KeyStore openedKeyStore=null;
    boolean firstTry=true;
    while (true) {
      if (password == null) {
        password=showPasswordDialog(keyStoreFile);
      }
      if (password == null) {
        return;
      }
      try {
        openedKeyStore=KeyStoreUtil.load(keyStoreFile,password);
        break;
      }
 catch (      KeyStoreLoadException klex) {
        if (defaultPassword == null || !firstTry) {
          int tryAgainChoice=showErrorMessage(keyStoreFile,klex);
          if (tryAgainChoice == JOptionPane.NO_OPTION) {
            return;
          }
        }
      }
      password.nullPassword();
      password=null;
      firstTry=false;
    }
    if (openedKeyStore == null) {
      JOptionPane.showMessageDialog(frame,MessageFormat.format(res.getString("OpenAction.FileNotRecognisedType.message"),keyStoreFile.getName()),res.getString("OpenAction.OpenKeyStore.Title"),JOptionPane.WARNING_MESSAGE);
      return;
    }
    kseFrame.addKeyStore(openedKeyStore,keyStoreFile,password);
  }
 catch (  FileNotFoundException ex) {
    JOptionPane.showMessageDialog(frame,MessageFormat.format(res.getString("OpenAction.NoReadFile.message"),keyStoreFile),res.getString("OpenAction.OpenKeyStore.Title"),JOptionPane.WARNING_MESSAGE);
  }
catch (  Exception ex) {
    DError.displayError(frame,ex);
  }
}

public void openKeyStore ( File keyStoreFile , String defaultPassword ) { try { if ( ! keyStoreFile . isFile ( ) ) { JOptionPane . showMessageDialog ( frame , MessageFormat . format ( res . getString ( "OpenAction.NotFile.message" ) , keyStoreFile ) , res . getString ( "OpenAction.OpenKeyStore.Title" ) , JOptionPane . WARNING_MESSAGE ) ; return ; } if ( isKeyStoreFileOpen ( keyStoreFile ) ) { JOptionPane . showMessageDialog ( frame , MessageFormat . format ( res . getString ( "OpenAction.NoOpenKeyStoreAlreadyOpen.message" ) , keyStoreFile ) , res . getString ( "OpenAction.OpenKeyStore.Title" ) , JOptionPane . WARNING_MESSAGE ) ; return ; } Password password = ( defaultPassword != null ) ? new Password ( defaultPassword . toCharArray ( ) ) : null ; KeyStore openedKeyStore = null ; boolean firstTry = true ; while ( true ) { if ( password == null ) { password = showPasswordDialog ( keyStoreFile ) ; } if ( password == null ) { return ; } try { openedKeyStore = KeyStoreUtil . load ( keyStoreFile , password ) ; break ; } catch ( KeyStoreLoadException klex ) { if ( defaultPassword == null || ! firstTry ) { int tryAgainChoice = showErrorMessage ( keyStoreFile , klex ) ; if ( tryAgainChoice == JOptionPane . NO_OPTION ) { return ; } } } password . nullPassword ( ) ; password = null ; firstTry = false ; } if ( openedKeyStore == null ) { JOptionPane . showMessageDialog ( frame , MessageFormat . format ( res . getString ( "OpenAction.FileNotRecognisedType.message" ) , keyStoreFile . getName ( ) ) , res . getString ( "OpenAction.OpenKeyStore.Title" ) , JOptionPane . WARNING_MESSAGE ) ; return ; } kseFrame . addKeyStore ( openedKeyStore , keyStoreFile , password ) ; } catch ( FileNotFoundException ex ) { JOptionPane . showMessageDialog ( frame , MessageFormat . format ( res . getString ( "OpenAction.NoReadFile.message" ) , keyStoreFile ) , res . getString ( "OpenAction.OpenKeyStore.Title" ) , JOptionPane . WARNING_MESSAGE ) ; } catch ( Exception ex ) { DError . displayError ( frame , ex ) ; } }
open the supplied keystore file from disk .
