org.apache.synapse.mediators.opa

## Class OPASynapseRequestGenerator

- java.lang.Object
- - org.apache.synapse.mediators.opa.OPASynapseRequestGenerator

- All Implemented Interfaces:
    OPARequestGenerator

      public class OPASynapseRequestGenerator
      extends java.lang.Object
      implements OPARequestGenerator

  Default implementation of the `OPARequestGenerator`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `OPASynapseRequestGenerator()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `java.lang.String` | `generateRequest(java.lang.String policyName, java.lang.String rule, java.util.Map<java.lang.String,java.lang.String> additionalParameters, org.apache.synapse.MessageContext messageContext)` Generate the OPA request payload from the provided message context and the additional Properties Map
    `boolean` | `handleResponse(java.lang.String policyName, java.lang.String rule, java.lang.String opaResponse, java.util.Map<java.lang.String,java.lang.String> additionalParameters, org.apache.synapse.MessageContext messageContext)` Handle the OPA response based on the implementation

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### OPASynapseRequestGenerator

          public OPASynapseRequestGenerator()

  - ### Method Detail

    - #### generateRequest

          public java.lang.String generateRequest(java.lang.String policyName,
                                                  java.lang.String rule,
                                                  java.util.Map<java.lang.String,java.lang.String> additionalParameters,
                                                  org.apache.synapse.MessageContext messageContext)
                                           throws OPASecurityException

      Description copied from interface: `OPARequestGenerator`
      Generate the OPA request payload from the provided message context and the additional Properties Map
      Specified by:
        `generateRequest` in interface `OPARequestGenerator`
      Parameters:
        `policyName` - Name of the policy validated
        `rule` - The rule of the policy
        `additionalParameters` - Additional parameters that can be used to construct the opa payload
        `messageContext` - The message to be validated with OPA server
      Returns:
        json input as a string and this will be sent to the OPA server for validation
      Throws:
        `OPASecurityException` - If an authentication failure or some other error occurs

    - #### handleResponse

          public boolean handleResponse(java.lang.String policyName,
                                        java.lang.String rule,
                                        java.lang.String opaResponse,
                                        java.util.Map<java.lang.String,java.lang.String> additionalParameters,
                                        org.apache.synapse.MessageContext messageContext)
                                 throws OPASecurityException

      Description copied from interface: `OPARequestGenerator`
      Handle the OPA response based on the implementation
      Specified by:
        `handleResponse` in interface `OPARequestGenerator`
      Parameters:
        `policyName` - Name of the policy validated
        `rule` - The rule of the policy
        `opaResponse` - The message to be authenticated
        `additionalParameters` - Additional parameters that can be used to handle the the opa response
        `messageContext` - The message to be authenticated
      Returns:
        true if the authentication is successful
      Throws:
        `OPASecurityException` - If an authentication failure or some other error occurs

Copyright © 2005-2022 Apache Software Foundation. All Rights Reserved.