/** Creates new form DateTimePicker */ public DateTimePicker() { initComponents(); addListeners(); this.setToolTipText(Configuration.getInstance().getTimeZoneName()); TooltipHelper.registerComponentAtTooltipManager(this); }
@Override public void setMultiConfValues(String[] multiConfValues) { multiConfValuesModel = new DefaultComboBoxModel(multiConfValues); multiConfValuesBox = new JComboBox(); multiConfValuesBox.setModel(multiConfValuesModel); if (!Configuration.getInstance().isEuMode()) { multiConfValuesBox.setEditable(true); } }
/** * Opens a <code>ServiceDigitalIdentityPanel</code> and displays short information about a * certificate. * * @version $Revision: 1168 $ - $Date: 2012-03-05 12:28:27 +0100 (Mon, 05 Mar 2012) $ */ public class ServiceDigitalIdentityPanel extends javax.swing.JPanel implements ContentWatcher { private static final ResourceBundle uiKeys = ResourceBundle.getBundle( "eu/europa/ec/markt/tlmanager/uiKeysComponents", Configuration.getInstance().getLocale()); private MandatoryLabelHandler labelHandler; /** The default constructor for ServiceDigitalIdentityPanel. */ public ServiceDigitalIdentityPanel() { initComponents(); } /** Another constructor for ServiceDigitalIdentityPanel. */ public ServiceDigitalIdentityPanel(JFileChooser fileChooser) { initComponents(); } /** * This method is called from within the constructor to initialize the form. WARNING: Do NOT * modify this code. The content of this method is always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { distinguishedName = new javax.swing.JTextField(); certificateButton = new eu.europa.ec.markt.tlmanager.view.multivalue.MultivalueButton( MultiMode.MULTI_CERT, null, null); certificateButton.getMultivaluePanel().addContentWatcher(this); digitalIdLabel = new javax.swing.JLabel(); boxSN = new javax.swing.JCheckBox(); boxSKI = new javax.swing.JCheckBox(); boxCert = new javax.swing.JCheckBox(); distinguishedName.setEnabled(false); distinguishedName.setName("distinguishedName"); // NOI18N certificateButton.setName("certificateButton"); // NOI18N digitalIdLabel.setText(uiKeys.getString("Certificate.label.useForTL")); // NOI18N boxSN.setSelected(true); boxSN.setText(uiKeys.getString("Certificate.label.subjectName")); // NOI18N boxSN.setName("boxSN"); // NOI18N boxSN.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { boxSNActionPerformed(evt); } }); boxSKI.setSelected(true); boxSKI.setText(uiKeys.getString("Certificate.label.ski")); // NOI18N boxSKI.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { boxSKIActionPerformed(evt); } }); boxCert.setSelected(true); boxCert.setText(uiKeys.getString("Certificate.label.certificate")); // NOI18N boxCert.setEnabled(false); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent( distinguishedName, javax.swing.GroupLayout.DEFAULT_SIZE, 485, Short.MAX_VALUE) .addGroup( layout .createSequentialGroup() .addGap(20, 20, 20) .addComponent(digitalIdLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(boxCert) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(boxSN) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(boxSKI) .addContainerGap(198, Short.MAX_VALUE)) .addComponent( certificateButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); layout.setVerticalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addComponent( distinguishedName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent( certificateButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(digitalIdLabel) .addComponent(boxCert) .addComponent(boxSN) .addComponent(boxSKI)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); } // </editor-fold>//GEN-END:initComponents private void boxSKIActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_boxSKIActionPerformed alignSnSki(); } // GEN-LAST:event_boxSKIActionPerformed private void boxSNActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_boxSNActionPerformed alignSnSki(); } // GEN-LAST:event_boxSNActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JCheckBox boxCert; private javax.swing.JCheckBox boxSKI; private javax.swing.JCheckBox boxSN; public eu.europa.ec.markt.tlmanager.view.multivalue.MultivalueButton certificateButton; private javax.swing.JLabel digitalIdLabel; private javax.swing.JTextField distinguishedName; // End of variables declaration//GEN-END:variables /** * Sets the <code>MandatoryLabelHandler</code> * * @param labelHandler the handler */ public void setLabelHandler(MandatoryLabelHandler labelHandler) { this.labelHandler = labelHandler; } /** {@inheritDoc} */ @Override public void contentHasChanged(boolean empty, String text) { if (labelHandler != null) { labelHandler.handleLabelStateFor(this, empty); } // check or unceheck sn / ski checkboxes final ServiceDigitalIdentityMultivalueAdapter serviceDigitalIdentityMultivalueAdapter = (ServiceDigitalIdentityMultivalueAdapter) certificateButton.getMultivaluePanel().getMultivalueModel(); final List<DigitalIdentityType> digitalId = serviceDigitalIdentityMultivalueAdapter.getDigitalIdentityList().getDigitalId(); boolean hasSn = false; boolean hasSki = false; for (Iterator<DigitalIdentityType> iterator = digitalId.iterator(); iterator.hasNext(); ) { DigitalIdentityType digitalIdentityType = iterator.next(); if (digitalIdentityType.getX509SubjectName() != null) { hasSn = true; } if (digitalIdentityType.getX509SKI() != null) { hasSki = true; } } boxSN.setSelected(hasSn); boxSKI.setSelected(hasSki); alignSnSki(); } private void alignSnSki() { final ServiceDigitalIdentityMultivalueAdapter serviceDigitalIdentityMultivalueAdapter = (ServiceDigitalIdentityMultivalueAdapter) certificateButton.getMultivaluePanel().getMultivalueModel(); final List<DigitalIdentityType> digitalId = serviceDigitalIdentityMultivalueAdapter.getDigitalIdentityList().getDigitalId(); boolean useSn = boxSN.isSelected(); boolean useSki = boxSKI.isSelected(); serviceDigitalIdentityMultivalueAdapter.setSn(useSn); serviceDigitalIdentityMultivalueAdapter.setSki(useSki); boolean snAdded = false; boolean skiAdded = false; // cleanup existing SN & SKI (might not be aligned with the certificates chosen for (Iterator<DigitalIdentityType> iterator = digitalId.iterator(); iterator.hasNext(); ) { DigitalIdentityType digitalIdentityType = iterator.next(); if (digitalIdentityType.getX509SubjectName() != null) { iterator.remove(); } if (digitalIdentityType.getX509SKI() != null) { iterator.remove(); } } // cleanup SubjetName display distinguishedName.setText(""); distinguishedName.setCaretPosition(0); // search new values for (final String key : serviceDigitalIdentityMultivalueAdapter.getKeys()) { final DigitalIdentityModel digitalIdentityModel = serviceDigitalIdentityMultivalueAdapter.getValue(key); if (digitalIdentityModel != null) { final X509Certificate certificate = digitalIdentityModel.getCertificate(); if (certificate != null) { final DigitalIdentityType digitalIdentitySN = new DigitalIdentityType(); final String x509SubjectName = certificate.getSubjectX500Principal().getName(X500Principal.RFC2253); digitalIdentitySN.setX509SubjectName(x509SubjectName); // updateUI too // TODO: might be interesting to display all different subjectName (with error message) if // use has chosen different certificitates distinguishedName.setText(x509SubjectName); distinguishedName.setCaretPosition(0); if (!snAdded && useSn) { digitalId.add(digitalIdentitySN); snAdded = true; } if (!skiAdded && useSki) { final byte[] skiValue = DSSUtils.getSki(certificate); if (skiValue != null && skiValue.length > 0) { final DigitalIdentityType digitalIdentitySKI = new DigitalIdentityType(); digitalIdentitySKI.setX509SKI(skiValue); digitalId.add(digitalIdentitySKI); skiAdded = true; } } } } } } public ServiceDigitalIdentityMultivalueAdapter getServiceDigitalIdentityMultivalueAdapter() { final ServiceDigitalIdentityMultivalueAdapter multivalueModel = (ServiceDigitalIdentityMultivalueAdapter) certificateButton.getMultivaluePanel().getMultivalueModel(); return multivalueModel; } public void setServiceDigitalIdentityMultivalueAdapter( ServiceDigitalIdentityMultivalueAdapter serviceDigitalIdentityMultivalueAdapter) { certificateButton .getMultivaluePanel() .setMultivalueModel(serviceDigitalIdentityMultivalueAdapter); certificateButton.refreshContentInformation(); refreshContentInformation(); } public void refreshContentInformation() { final ServiceDigitalIdentityMultivalueAdapter multivalueModel = (ServiceDigitalIdentityMultivalueAdapter) certificateButton.getMultivaluePanel().getMultivalueModel(); contentHasChanged(multivalueModel.isEmpty(), ""); } public boolean isBoxSnSelected() { return boxSN.isSelected(); } public boolean isBoxSkiSelected() { return boxSKI.isSelected(); } }
/** * Panel that wraps the controls for the third signature step. * * @version $Revision: 2517 $ - $Date: 2013-09-10 09:33:15 +0200 (mar., 10 sept. 2013) $ */ public class SignatureStep3 extends javax.swing.JPanel { private static final ResourceBundle uiKeys = ResourceBundle.getBundle( "eu/europa/ec/markt/tlmanager/uiKeys", Configuration.getInstance().getLocale()); private SignatureWizardStep3 wizard; private DefaultListModel certificateModel; private ComboBoxModel digestAlgorithmsModel; /** Instantiates a new signature step3. */ public SignatureStep3() { certificateModel = new DefaultListModel(); digestAlgorithmsModel = new ListComboBoxModel<DigestAlgorithm>(Arrays.asList(DigestAlgorithm.values())); initComponents(); // finally, used shall not be able to choose the digest algorithm digestAlgorithmPanel.setVisible(false); certificatesTitle.setTitle(uiKeys.getString("SignatureStep3.certificatesTitle.title")); outputTitle.setTitle(uiKeys.getString("SignatureStep3.outputTitle.title")); } /** * Instantiates a new signature step3. * * @param wizard the related wizard */ public SignatureStep3(final SignatureWizardStep3 wizard) { this(); this.wizard = wizard; certificates.setCellRenderer( new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { String label = ((X509Certificate) value).getSubjectX500Principal().toString(); return super.getListCellRendererComponent(list, label, index, isSelected, cellHasFocus); } }); certificates.addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { wizard.setSelectedCertificate((Certificate) certificates.getSelectedValue()); } } }); digestAlgorithms.setRenderer( (new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { String label = ((DigestAlgorithm) value).getName(); return super.getListCellRendererComponent(list, label, index, isSelected, cellHasFocus); } })); digestAlgorithms.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { wizard.setDigestAlgorithm((DigestAlgorithm) digestAlgorithms.getSelectedItem()); } }); } /** * Clears the certificateModel and adds all available certificates. * * @param certificates the available certificates */ public void setCertificates(List<Certificate> certificates) { certificateModel.clear(); for (Certificate cert : certificates) { certificateModel.addElement(cert); } } /** Preselect the digest algorithm */ public void setDigestAlgorithm(DigestAlgorithm digestAlgorithm) { digestAlgorithms.setSelectedItem(digestAlgorithm); } /** * This method is called from within the constructor to initialize the form. WARNING: Do NOT * modify this code. The content of this method is always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { descriptionLabel = new javax.swing.JLabel(); certificatesTitle = new eu.europa.ec.markt.tlmanager.view.common.TitledPanel(); certificateScrollPane = new javax.swing.JScrollPane(); certificates = new javax.swing.JList(); outputTitle = new eu.europa.ec.markt.tlmanager.view.common.TitledPanel(); targetButton = new javax.swing.JButton(); targetTextField = new javax.swing.JTextField(); digestAlgorithmPanel = new eu.europa.ec.markt.tlmanager.view.common.TitledPanel(); digestAlgorithms = new javax.swing.JComboBox(); descriptionLabel.setText(uiKeys.getString("SignatureStep3.descriptionLabel.text")); // NOI18N certificates.setModel(certificateModel); certificateScrollPane.setViewportView(certificates); javax.swing.GroupLayout certificatesTitleLayout = new javax.swing.GroupLayout(certificatesTitle); certificatesTitle.setLayout(certificatesTitleLayout); certificatesTitleLayout.setHorizontalGroup( certificatesTitleLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( certificatesTitleLayout .createSequentialGroup() .addContainerGap() .addComponent( certificateScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 421, Short.MAX_VALUE) .addContainerGap())); certificatesTitleLayout.setVerticalGroup( certificatesTitleLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( certificatesTitleLayout .createSequentialGroup() .addComponent( certificateScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 68, Short.MAX_VALUE) .addContainerGap())); targetButton.setText(uiKeys.getString("SignatureStep3.targetButton.text")); // NOI18N targetButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { targetButtonActionPerformed(evt); } }); targetTextField.setEditable(false); javax.swing.GroupLayout outputTitleLayout = new javax.swing.GroupLayout(outputTitle); outputTitle.setLayout(outputTitleLayout); outputTitleLayout.setHorizontalGroup( outputTitleLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( outputTitleLayout .createSequentialGroup() .addContainerGap() .addComponent(targetButton) .addGap(18, 18, 18) .addComponent( targetTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 354, Short.MAX_VALUE) .addContainerGap())); outputTitleLayout.setVerticalGroup( outputTitleLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( outputTitleLayout .createSequentialGroup() .addContainerGap() .addGroup( outputTitleLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(targetButton) .addComponent( targetTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); digestAlgorithmPanel.setName("digestAlgorithPanel"); // NOI18N digestAlgorithmPanel.setTitle("Please choose the digest algorithm"); digestAlgorithms.setModel(digestAlgorithmsModel); javax.swing.GroupLayout digestAlgorithmPanelLayout = new javax.swing.GroupLayout(digestAlgorithmPanel); digestAlgorithmPanel.setLayout(digestAlgorithmPanelLayout); digestAlgorithmPanelLayout.setHorizontalGroup( digestAlgorithmPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( digestAlgorithmPanelLayout .createSequentialGroup() .addContainerGap() .addComponent( digestAlgorithms, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addContainerGap())); digestAlgorithmPanelLayout.setVerticalGroup( digestAlgorithmPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( digestAlgorithmPanelLayout .createSequentialGroup() .addContainerGap() .addComponent( digestAlgorithms, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addContainerGap() .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent( certificatesTitle, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent( outputTitle, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup( layout .createSequentialGroup() .addComponent(descriptionLabel) .addGap(0, 0, Short.MAX_VALUE)) .addComponent( digestAlgorithmPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap())); layout.setVerticalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addContainerGap() .addComponent(descriptionLabel) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent( certificatesTitle, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent( digestAlgorithmPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent( outputTitle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap())); } // </editor-fold>//GEN-END:initComponents private void targetButtonActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_targetButtonActionPerformed int returnValue = MainFrame.fileChooser.showSaveDialog(getRootPane()); if (returnValue == JFileChooser.APPROVE_OPTION) { File selectedFile = MainFrame.fileChooser.getSelectedFile(); wizard.setTarget(selectedFile); targetTextField.setText(selectedFile.getAbsolutePath()); } } // GEN-LAST:event_targetButtonActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JScrollPane certificateScrollPane; private javax.swing.JList certificates; private eu.europa.ec.markt.tlmanager.view.common.TitledPanel certificatesTitle; private javax.swing.JLabel descriptionLabel; private eu.europa.ec.markt.tlmanager.view.common.TitledPanel digestAlgorithmPanel; private javax.swing.JComboBox digestAlgorithms; private eu.europa.ec.markt.tlmanager.view.common.TitledPanel outputTitle; private javax.swing.JButton targetButton; private javax.swing.JTextField targetTextField; // End of variables declaration//GEN-END:variables }