Package org.apache.synapse.mediators.opa
Class OPASynapseRequestGenerator
- java.lang.Object
-
- org.apache.synapse.mediators.opa.OPASynapseRequestGenerator
-
- All Implemented Interfaces:
OPARequestGenerator
public class OPASynapseRequestGenerator extends Object implements OPARequestGenerator
Default implementation of theOPARequestGenerator
.
-
-
Constructor Summary
Constructors Constructor Description OPASynapseRequestGenerator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
generateRequest(String policyName, String rule, Map<String,String> additionalParameters, org.apache.synapse.MessageContext messageContext)
Generate the OPA request payload from the provided message context and the additional Properties Mapboolean
handleResponse(String policyName, String rule, String opaResponse, Map<String,String> additionalParameters, org.apache.synapse.MessageContext messageContext)
Handle the OPA response based on the implementation
-
-
-
Method Detail
-
generateRequest
public String generateRequest(String policyName, String rule, Map<String,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 interfaceOPARequestGenerator
- Parameters:
policyName
- Name of the policy validatedrule
- The rule of the policyadditionalParameters
- Additional parameters that can be used to construct the opa payloadmessageContext
- 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(String policyName, String rule, String opaResponse, Map<String,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 interfaceOPARequestGenerator
- Parameters:
policyName
- Name of the policy validatedrule
- The rule of the policyopaResponse
- The message to be authenticatedadditionalParameters
- Additional parameters that can be used to handle the the opa responsemessageContext
- The message to be authenticated- Returns:
- true if the authentication is successful
- Throws:
OPASecurityException
- If an authentication failure or some other error occurs
-
-