24.12.2014 Views

Download - Svetlin Nakov

Download - Svetlin Nakov

Download - Svetlin Nakov

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

}<br />

mLibraryFileNameTextField.setText("");<br />

} finally {<br />

configFileStream.close();<br />

}<br />

/**<br />

* Saves the dialog settings to the dialog configuration file. These settings<br />

* consist of a single value - the last used library file name with its path.<br />

*/<br />

private void saveSettings()<br />

throws IOException {<br />

// Create a list of settings to store in the config file<br />

Properties configProps = new Properties();<br />

String currentLibraryFileName = mLibraryFileNameTextField.getText();<br />

configProps.setProperty(PKCS11_LIBRARY_FILE_NAME_KEY,currentLibraryFileName);<br />

}<br />

// Save the settings in the config file<br />

String configFileName = getConfigFileName();<br />

FileOutputStream configFileStream = new FileOutputStream(configFileName);<br />

try {<br />

configProps.store(configFileStream, "");<br />

} finally {<br />

configFileStream.close();<br />

}<br />

/**<br />

* @return the library file selected by the user.<br />

*/<br />

public String getLibraryFileName() {<br />

String libraryFileName = mLibraryFileNameTextField.getText();<br />

return libraryFileName;<br />

}<br />

/**<br />

* @return the PIN code entered by the user.<br />

*/<br />

public String getSmartCardPINCode() {<br />

String pinCode = mPINCodeTextField.getText();<br />

return pinCode;<br />

}<br />

/**<br />

* Shows the dialog and allow the user to choose library file and enter a PIN.<br />

* @return true if the user click sign button or false if the user cancel the<br />

* dialog.<br />

*/<br />

public boolean run() {<br />

try {<br />

loadSettings();<br />

} catch (IOException ioex) {<br />

// Loading settings failed. Default settings will be used.<br />

}<br />

setModal(true);<br />

this.setVisible(true);<br />

try {<br />

if (mResult) {<br />

saveSettings();<br />

}<br />

} catch (IOException ioex) {<br />

// Saving settings failed. Can not handle this problem.<br />

105

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!