Class HttpMessageSecurity


  • public class HttpMessageSecurity
    extends Object
    Implements message security protocol. Encrypts requests & decrypts responses.
    • Constructor Detail

      • HttpMessageSecurity

        public HttpMessageSecurity​(String clientSecurityToken,
                                   String clientSignatureKeyString,
                                   String serverEncryptionKeyString,
                                   String serverSignatureKeyString)
                            throws IOException
        Constructor.
        Parameters:
        clientSecurityToken - pop or bearer authentication token.
        clientSignatureKeyString - string with client signing key (public + private parts) or null if not supported
        serverEncryptionKeyString - string with server encryption key (public only) or null if not supported
        serverSignatureKeyString - string with server signing key (public only) or null if not supported
        Throws:
        IOException - throws IOException
      • HttpMessageSecurity

        public HttpMessageSecurity​(String clientSecurityToken,
                                   String clientSignatureKeyString,
                                   String serverEncryptionKeyString,
                                   String serverSignatureKeyString,
                                   JsonWebKey clientEncryptionKey)
                            throws IOException
        Constructor.
        Parameters:
        clientSecurityToken - pop or bearer authentication token.
        clientSignatureKeyString - string with client signing key (public + private parts) or null if not supported
        serverEncryptionKeyString - string with server encryption key (public only) or null if not supported
        serverSignatureKeyString - string with server signing key (public only) or null if not supported
        clientEncryptionKey - client encryption key (public + private parts) or null if not supported
        Throws:
        IOException - throws IOException
      • HttpMessageSecurity

        public HttpMessageSecurity​(String clientSecurityToken,
                                   String clientEncryptionString,
                                   String clientSignatureKeyString,
                                   String serverEncryptionKeyString,
                                   String serverSignatureKeyString,
                                   boolean testMode)
                            throws IOException
        Constructor (tests only).
        Parameters:
        clientSecurityToken - pop or bearer authentication token.
        clientEncryptionString - string with client signing key (public + private parts) or null if not supported
        clientSignatureKeyString - string with client signing key (public + private parts) or null if not supported
        serverEncryptionKeyString - string with server encryption key (public only) or null if not supported
        serverSignatureKeyString - string with server signing key (public only) or null if not supported
        testMode - true for test mode (uses 0 for timestamp)
        Throws:
        IOException - throws IOException
    • Method Detail

      • protectRequest

        public okhttp3.Request protectRequest​(okhttp3.Request request)
                                       throws IOException
        Protects existing request. Replaces its body with encrypted version.
        Parameters:
        request - existing request.
        Returns:
        new request with encrypted body if supported or existing request.
        Throws:
        IOException - throws IOException
      • unprotectResponse

        public okhttp3.Response unprotectResponse​(okhttp3.Response response)
                                           throws IOException
        Unprotects response if needed. Replaces its body with unencrypted version.
        Parameters:
        response - server response.
        Returns:
        new response with unencrypted body if supported or existing response.
        Throws:
        IOException - throws IOException