Class CertificateUI

  • All Implemented Interfaces:
    ICertificateUI

    public class CertificateUI
    extends java.lang.Object
    implements ICertificateUI
    The implementing class for Certificate UI callback for SSL.
    Author:
    Christopher Mindus
    • Constructor Summary

      Constructors 
      ConstructorDescription
      CertificateUI​(org.eclipse.swt.widgets.Shell shell)
      Constructs an instance of the Certificate UI for a shell.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      char[]getCertificatePassword​(java.lang.String certificate, java.lang.String msg)
      Gets the password for a client certificate.
      char[]getLastPassword()
      Gets the last password the user has entered.
      booleangetSavePassword()
      Gets the save-password flag, can be retrieved once the dialog is OK'ed.
      org.eclipse.swt.widgets.ShellgetShell()
      Gets the shell, can be overridden to provide a shell.
      char[]getStorePassword​(java.lang.String store, java.lang.String msg)
      Gets the password for a certificate store.
      booleanisApplet()
      Checks if the owner is an Applet.
      booleanisServerCertificateAccepted​(java.lang.String server, java.lang.String certInfo, java.security.cert.X509Certificate certificate)
      Asks the user if the server with the certificate is accepted.
      voidshowCertificateMessage​(java.lang.String msg)
      Show a message box for a client certificate.
      voidshowStoreMessage​(java.lang.String msg)
      Show a message box for a certificate store.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CertificateUI

        public CertificateUI​(org.eclipse.swt.widgets.Shell shell)
        Constructs an instance of the Certificate UI for a shell.
    • Method Detail

      • getLastPassword

        public char[] getLastPassword()
        Gets the last password the user has entered. When retrieved, it is immediately cleared.
        Returns:
        null if the user didn't enter a password, otherwise the password character array.
      • getSavePassword

        public boolean getSavePassword()
        Gets the save-password flag, can be retrieved once the dialog is OK'ed.
      • getShell

        public org.eclipse.swt.widgets.Shell getShell()
        Gets the shell, can be overridden to provide a shell.
      • getStorePassword

        public char[] getStorePassword​(java.lang.String store,
                                       java.lang.String msg)
        Gets the password for a certificate store.

        Note: it may be called from any thread.

        Specified by:
        getStorePassword in interface ICertificateUI
        Parameters:
        store - The certificate store "User Java key store" or "System Java key store".
        msg - A message such as "Invalid password for client certificates in the [store] Java key store, please reenter." or null for none.
        Returns:
        The password in a character array, or null for cancel.
      • showStoreMessage

        public void showStoreMessage​(java.lang.String msg)
        Show a message box for a certificate store.

        Note: it may be called from any thread.

        Specified by:
        showStoreMessage in interface ICertificateUI
        Parameters:
        msg - A message, such as "You have specified 3 invalid passwords for the client certificates in the [store] Java key store. These certificates will be ignored.".
      • getCertificatePassword

        public char[] getCertificatePassword​(java.lang.String certificate,
                                             java.lang.String msg)
        Gets the password for a client certificate.

        Note: it may be called from any thread.

        Specified by:
        getCertificatePassword in interface ICertificateUI
        Parameters:
        certificate - The certificate type "Client certificate for [server]".
        msg - A message such as "Enter the password for the Client Certificate." or "Incorrect Client Certificate password, please reenter.".
        Returns:
        The password in a character array, or null for cancel.
      • showCertificateMessage

        public void showCertificateMessage​(java.lang.String msg)
        Show a message box for a client certificate.

        Note: it may be called from any thread.

        Specified by:
        showCertificateMessage in interface ICertificateUI
        Parameters:
        msg - A message, such as "The file '[file]' is not a valid client certificate (i.e. PKCS#12 identity). The file is ignored." or "You have specified 3 invalid passwords for the client certificate file '[file]'.\n\nThe file is ignored.".
      • isApplet

        public boolean isApplet()
        Checks if the owner is an Applet.
        Specified by:
        isApplet in interface ICertificateUI
      • isServerCertificateAccepted

        public boolean isServerCertificateAccepted​(java.lang.String server,
                                                   java.lang.String certInfo,
                                                   java.security.cert.X509Certificate certificate)
        Asks the user if the server with the certificate is accepted.

        Note: it may be called from any thread.

        Specified by:
        isServerCertificateAccepted in interface ICertificateUI
        Parameters:
        server - The server host name.
        certInfo - The certificate information string including validity, error, etc.
        certificate - The X.509 certificate.
        Returns:
        true to accept it, false otherwise.