/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008-2009 Sun Microsystems, Inc.
* Portions Copyright 2013 ForgeRock AS.
*/
/**
* This class is used to present the user a certificate to the user in order
* it to be accepted.
*/
{
/**
* The enumeration that defines the different answers that the user can
* provide for this dialog.
*/
public enum ReturnType
{
/**
* The user did not accept the certificate.
*/
/**
* The user accepted the certificate only for this session.
*/
/**
* The user accepted the certificate permanently.
*/
}
private boolean detailsAlreadyClicked;
CertificateDialog.class.getName());
/**
* Constructor of the certificate dialog.
* @param parent the parent frame for this dialog.
* @param ce the UserDataCertificateException we use to get the information
* about the certificate that was presented and the reason why it was
* rejected.
*/
{
super(parent);
setModal(true);
pack();
{
{
getPreferredSize().height));
}
}
pack();
minHeight));
{
public void windowClosing(WindowEvent e)
{
doNotAccept();
}
});
}
/**
* Wheter the user accepted the certificate or not.
* @return the ReturnType object defining what the user chose to do with the
* certificate.
*/
{
return returnValue;
}
/**
* Implements HyperlinkListener. When the user clicks on a link we assume
* accordingly.
*
* @param e the HyperlinkEvent.
*/
{
{
if (detailsVisible && !detailsAlreadyClicked)
{
detailsAlreadyClicked = true;
pack();
}
}
}
/**
* Creates and returns the panel of the dialog.
* @return the panel of the dialog.
*/
{
certificateDetails.setVisible(false);
return contentPanel;
}
/**
* Creates and returns the title sub panel.
* @return the title sub panel.
*/
{
JLabel l =
l.setOpaque(false);
return titlePanel;
}
/**
* Creates and returns the text sub panel.
* @return the text sub panel.
*/
{
{
}
else
{
}
p.setLayout(new GridBagLayout());
explanationPane.setOpaque(false);
explanationPane.setEditable(false);
{
}
else
{
}
return p;
}
/**
* ACCEPT PERMANENTLY sub panel.
* PERMANENTLY sub panel.
*/
{
}
});
}
});
{
{
doNotAccept();
}
});
return buttonsPanel;
}
/**
* Creates the panel containing a representation of the certificate chain.
* @return the panel containing a representation of the certificate chain.
*/
{
p.setLayout(new GridBagLayout());
{
{
};
{
JComponent[] components =
{
};
{
l.setLabelFor(components[j]);
if (j > 0)
{
}
}
}
{
}
else
{
l.setLabelFor(combo);
}
{
{
}
});
}
175));
return scroll;
}
{
return makeValueLabel(dn);
}
{
return makeValueLabel(dn);
}
{
JComponent c;
if (isNotValidYet)
{
}
else
{
c = makeValueLabel(value);
}
return c;
}
{
JComponent c;
if (isExpired)
{
}
else
{
c = makeValueLabel(value);
}
return c;
}
{
return makeValueLabel(type);
}
{
return makeValueLabel(serialNumber);
}
/**
* Returns the Message representation of the SHA1 fingerprint.
* @param cert the certificate object.
* @return the Message representation of the SHA1 fingerprint.
*/
{
try {
for (int i = 0; i < b.length; i++)
{
if (i > 0)
{
}
}
}
catch (NoSuchAlgorithmException nsae) {
}
catch (CertificateEncodingException cee) {
}
return msg;
}
/**
* Returns the Message representation of the MD5 fingerprint.
* @param cert the certificate object.
* @return the Message representation of the MD5 fingerprint.
*/
{
try {
for (int i = 0; i < b.length; i++)
{
if (i > 0)
{
}
}
}
catch (NoSuchAlgorithmException nsae) {
}
catch (CertificateEncodingException cee) {
}
return msg;
}
{
}
{
}
{
{
}
}
{
try
{
}
catch (Throwable t)
{
cert.getSubjectX500Principal(), t);
}
return name;
}
/**
* Method called when user clicks on ok.
*
*/
private void acceptForSession()
{
dispose();
}
/**
* Method called when user clicks on cancel.
*
*/
private void doNotAccept()
{
dispose();
}
/**
* Method called when user clicks on ok.
*
*/
private void acceptPermanently()
{
dispose();
}
/**
* Method written for testing purposes.
* @param args the arguments to be passed to the test program.
*/
/*
public static void main(String[] args)
{
try
{
// TODO
} catch (Exception ex)
{
ex.printStackTrace();
}
}
*/
}