Class AwSSLEntrust

  • All Implemented Interfaces:
    AwSSL

    public class AwSSLEntrust
    extends java.lang.Object
    implements AwSSL
    Implements the AwSSL interface for the Entrust. The real implementation is in AwSSLEntrustUtil which is used by both jms and java api SSL

    This class is design to be stateless. i.e., there is no member variables in this class.

    See Also:
    AwSSL
    • Constructor Detail

      • AwSSLEntrust

        public AwSSLEntrust()
    • Method Detail

      • createSSLContext

        public AwSSLContext createSSLContext​(java.lang.String keyfile,
                                             java.lang.String password)
                                      throws java.lang.RuntimeException
        Description copied from interface: AwSSL
        Creates and initializes an SSL context. The returned context must be presented for all operations.
        Specified by:
        createSSLContext in interface AwSSL
        Parameters:
        keyfile - The name of the file containing the secret keys.
        password - The password for reading the keyfile.
        Returns:
        a context handle represented as a long.
        Throws:
        java.lang.RuntimeException - If an error occurs during initialization.
      • createContext

        public AwSSLContext createContext​(java.lang.String keyfile,
                                          java.lang.String trustfile,
                                          java.lang.String keystoreType,
                                          java.lang.String truststoreType,
                                          java.lang.String cipherSuites,
                                          java.lang.String password)
                                   throws java.lang.RuntimeException
        Specified by:
        createContext in interface AwSSL
        Throws:
        java.lang.RuntimeException
      • validateSslClientCertificate

        public void validateSslClientCertificate​(AwSSLContext context)
                                          throws java.lang.RuntimeException
        Throws:
        java.lang.RuntimeException
      • destroyContext

        public void destroyContext​(AwSSLContext context)
        Description copied from interface: AwSSL
        Destroys an SSL context. After destroying a context it is no longer valid.
        Specified by:
        destroyContext in interface AwSSL
        Parameters:
        context - A context handle to be destroyed.
      • isExportLibrary

        public boolean isExportLibrary()
        Description copied from interface: AwSSL
        Returns whether this library uses U.S. Domestic or exportable cipher strengths.
        Specified by:
        isExportLibrary in interface AwSSL
        Returns:
        true if the library is of export strength only.
      • modifyPassword

        public boolean modifyPassword​(AwSSLContext context,
                                      java.lang.String newpassword)
                               throws java.lang.RuntimeException
        Description copied from interface: AwSSL
        Changes the password protecting the keyfile. Rewrites the keyfile using the new password.
        Specified by:
        modifyPassword in interface AwSSL
        Parameters:
        context - A context handle.
        newpassword - The new password for the keyfile.
        Returns:
        true if the update succeded.
        Throws:
        java.lang.RuntimeException - If an error occurs during the update.
      • getDnList

        public java.lang.String[] getDnList​(AwSSLContext context)
                                     throws java.lang.RuntimeException
        Description copied from interface: AwSSL
        Returns the list of the Distinguished Names in the keyfile.
        Specified by:
        getDnList in interface AwSSL
        Parameters:
        context - A context handle.
        Returns:
        a list of strings each containing a Distinguished Name.
        Throws:
        java.lang.RuntimeException - If an error occurs during the operation.
      • getTRList

        public java.lang.String[] getTRList​(AwSSLContext context)
                                     throws java.lang.RuntimeException
        Description copied from interface: AwSSL
        Returns the list of the Distinguished Names of trusted roots in the keyfile.
        Specified by:
        getTRList in interface AwSSL
        Parameters:
        context - A context handle.
        Returns:
        a list of strings each containing a Distinguished Name for a trusted root.
        Throws:
        java.lang.RuntimeException - If an error occurs during the operation.
      • selectEncryptionDn

        public boolean selectEncryptionDn​(AwSSLContext context,
                                          java.lang.String dn)
                                   throws java.lang.RuntimeException
        Description copied from interface: AwSSL
        Selects the key of for the supplied Distinguished Name as the key for encryption.
        Specified by:
        selectEncryptionDn in interface AwSSL
        Parameters:
        context - A context handle.
        dn - The Distinguished Name whose key should be selected.
        Returns:
        true if the operation succeeded.
        Throws:
        java.lang.RuntimeException - If an error occurs during the operation.
      • isDnAvailable

        public boolean isDnAvailable​(AwSSLContext context,
                                     java.lang.String dn)
                              throws java.lang.RuntimeException
        Description copied from interface: AwSSL
        Returns whether or not a certificate for the supplied Distinguished Name is available in the keyfile.
        Specified by:
        isDnAvailable in interface AwSSL
        Parameters:
        context -
        dn -
        Returns:
        true if a certificate is available.
        Throws:
        java.lang.RuntimeException
      • getCertificate

        public AwSSLCertificate getCertificate​(AwSSLContext context)
                                        throws java.lang.RuntimeException
        Description copied from interface: AwSSL
        Returns the certificate for the supplied Distinguished Name.
        Specified by:
        getCertificate in interface AwSSL
        Parameters:
        context - A context handle.
        Returns:
        a reference to an AwSSLCertificate object if successful, or nil otherwise.
        Throws:
        java.lang.RuntimeException - If an error occurs during the operation.
        See Also:
        AwSSLCertificate
      • createClientSocket

        public AwSSLSocketInfo createClientSocket​(AwSSLContext context,
                                                  int secure,
                                                  java.lang.String host,
                                                  int port,
                                                  int block,
                                                  boolean encryption)
                                           throws java.lang.RuntimeException
        Description copied from interface: AwSSL
        Creates a client socket with the specified properties.
        Specified by:
        createClientSocket in interface AwSSL
        Parameters:
        context - A context handle.
        secure - The security properties of the socket (set to the selected CLIENT_* values above).
        host - The name of the host to which the socket should connect.
        port - The portnumber to which the socket should connect.
        block - Set to 1 if the socket should be blocking, 0 for non-blocking.
        Returns:
        a reference to an AwSSLSocketInfo object if successful, or nil otherwise.
        Throws:
        java.lang.RuntimeException - If an error occurs during the operation.
        See Also:
        AwSSLSocketInfo
      • closeSocket

        public void closeSocket​(AwSSLSocketInfo socket)
                         throws java.lang.RuntimeException
        Description copied from interface: AwSSL
        Closes a previously created socket.
        Specified by:
        closeSocket in interface AwSSL
        Parameters:
        socket - The sockethandle returned in the AwSSLSocketInfo object.
        Throws:
        java.lang.RuntimeException - If an error occurs during the operation.
      • read

        public byte[] read​(AwSSLSocketInfo socket,
                           int offset,
                           int bytesToRead)
                    throws java.lang.RuntimeException
        Description copied from interface: AwSSL
        Reads a number of bytes from the socket and returns the array.
        Specified by:
        read in interface AwSSL
        Parameters:
        socket - The sockethandle returned in the AwSSLSocketInfo object.
        bytesToRead - The number of bytes to read from the socket.
        Returns:
        an array of the bytes read from the socket if successful, or nil otherwise.
        Throws:
        java.lang.RuntimeException - If an error occurs during the operation.
      • read

        public int read​(AwSSLSocketInfo socket,
                        byte[] buffer,
                        int offset,
                        int bytesToRead)
                 throws java.lang.RuntimeException
        Description copied from interface: AwSSL
        Provided for Entrust Support
        Specified by:
        read in interface AwSSL
        Parameters:
        socket - The sockethandle
        buffer - The number of bytes to read from the socket.
        offset - Offset from where to read
        bytesToRead - Number of bytes to be read
        Returns:
        Number of bytes read.
        Throws:
        java.lang.RuntimeException
      • write

        public int write​(AwSSLSocketInfo socket,
                         byte[] writebuf)
                  throws java.lang.RuntimeException
        Description copied from interface: AwSSL
        Writes the array of bytes to the socket and returns the number of bytes written.
        Specified by:
        write in interface AwSSL
        Parameters:
        socket - The sockethandle returned in the AwSSLSocketInfo object.
        writebuf - The array of bytes to write to the socket.
        Returns:
        the number of bytes actually written to the socket.
        Throws:
        java.lang.RuntimeException - If an error occurs during the operation.
      • isMoreDataAvailable

        public int isMoreDataAvailable​(AwSSLSocketInfo socket)
                                throws java.lang.RuntimeException
        Description copied from interface: AwSSL
        Returns the number of bytes that are readable from the socket.
        Specified by:
        isMoreDataAvailable in interface AwSSL
        Parameters:
        socket - The sockethandle returned in the AwSSLSocketInfo object.
        Returns:
        the number of bytes readable from the socket.
        Throws:
        java.lang.RuntimeException - If an error occurs during the operation.
      • getOtherPartysCertificate

        public AwSSLCertificate getOtherPartysCertificate​(AwSSLSocketInfo socket)
                                                   throws java.lang.RuntimeException
        Description copied from interface: AwSSL
        Returns the certificate of the other party if the connection was authenticated.
        Specified by:
        getOtherPartysCertificate in interface AwSSL
        Parameters:
        socket - The sockethandle returned in the AwSSLSocketInfo object.
        Returns:
        an object reference to an AwSSLCertificate object if successful, or nil otherwise.
        Throws:
        java.lang.RuntimeException - If an error occurs during the operation.