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.

import java.awt.*;<br />

import java.awt.event.*;<br />

import javax.swing.*;<br />

import javax.swing.filechooser.FileFilter;<br />

import java.io.*;<br />

import java.util.Properties;<br />

/**<br />

* Dialog for choosing PKCS#11 implementation library file and PIN code for accessing<br />

* the smart card. Allows the user to choose a PKCS#11 library file (.dll / .so) and<br />

* enter a PIN code for the smart card. The last used library file name is remembered<br />

* in the config file called ".smart_card_signer_applet.config" located in the user's<br />

* home directory in order to be automatically shown the next time when the same user<br />

* accesses this dialog.<br />

*<br />

* This file is part of <strong>Nakov</strong>DocumentSigner digital document<br />

* signing framework for Java-based Web applications:<br />

* http://www.nakov.com/documents-signing/<br />

*<br />

* Copyright (c) 2005 by <strong>Svetlin</strong> <strong>Nakov</strong> - http://www.nakov.com<br />

* All rights reserved. This code is freeware. It can be used<br />

* for any purpose as long as this copyright statement is not<br />

* removed or modified.<br />

*/<br />

public class PKCS11LibraryFileAndPINCodeDialog extends JDialog {<br />

private static final String CONFIG_FILE_NAME=".smart_card_signer_applet.config";<br />

private static final String PKCS11_LIBRARY_FILE_NAME_KEY="last-PKCS11-file-name";<br />

private JButton mBrowseForLibraryFileButton = new JButton();<br />

private JTextField mLibraryFileNameTextField = new JTextField();<br />

private JLabel mChooseLibraryFileLabel = new JLabel();<br />

private JTextField mPINCodeTextField = new JPasswordField();<br />

private JLabel mEnterPINCodeLabel = new JLabel();<br />

private JButton mSignButton = new JButton();<br />

private JButton mCancelButton = new JButton();<br />

private boolean mResult = false;<br />

/**<br />

* Initializes the dialog - creates and initializes its GUI controls.<br />

*/<br />

public PKCS11LibraryFileAndPINCodeDialog() {<br />

// Initialize the dialog<br />

this.getContentPane().setLayout(null);<br />

this.setSize(new Dimension(426, 165));<br />

this.setBackground(SystemColor.control);<br />

this.setTitle("Select PKCS#11 library file and smart card PIN code");<br />

this.setResizable(false);<br />

// Center the dialog in the screen<br />

Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();<br />

Dimension dialogSize = this.getSize();<br />

int centerPosX = (screenSize.width - dialogSize.width) / 2;<br />

int centerPosY = (screenSize.height - dialogSize.height) / 2;<br />

setLocation(centerPosX, centerPosY);<br />

// Initialize certificate keystore file label<br />

mChooseLibraryFileLabel.setText(<br />

"Please select your PKCS#11 implementation library file (.dll / .so) :");<br />

mChooseLibraryFileLabel.setBounds(new Rectangle(10, 5, 400, 15));<br />

mChooseLibraryFileLabel.setFont(new Font("Dialog", 0, 12));<br />

// Initialize certificate keystore file name text field<br />

102

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

Saved successfully!

Ooh no, something went wrong!