24.12.2014 Views

Download - Svetlin Nakov

Download - Svetlin Nakov

Download - Svetlin Nakov

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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 certificate file name and password for it. Allows the user<br />

* to choose a PFX file and enter a password for accessing it. The last used PFX<br />

* file is remembered in the config file called ".digital_signer_applet.config",<br />

* located in the user's home directory in order to be automatically shown the<br />

* next time when the same user access 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) 2003 by <strong>Svetlin</strong> <strong>Nakov</strong> - http://www.nakov.com<br />

* National Academy for Software Development - http://academy.devbg.org<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 CertificateFileAndPasswordDialog extends JDialog {<br />

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

private static final String PFX_FILE_NAME_KEY = "last-PFX-file-name";<br />

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

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

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

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

private JLabel mEnterPasswordLabel = 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 CertificateFileAndPasswordDialog() {<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 digital certificate");<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 />

mChooseCertFileLabel.setText(<br />

"Please select your certificate keystore file (.PFX / .P12) :");<br />

mChooseCertFileLabel.setBounds(new Rectangle(10, 5, 350, 15));<br />

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

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

mCertFileNameTextField.setBounds(new Rectangle(10, 25, 315, 20));<br />

82

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

Saved successfully!

Ooh no, something went wrong!