use of org.wso2.carbon.apimgt.common.gateway.dto.RequestContextDTO in project carbon-apimgt by wso2.
the class ExtensionListenerUtil method preProcessRequest.
/**
* Handles pre-process request by constructing the request context DTO, invoking the matching extension listener
* implementation and processing the extension listener response.
*
* @param messageContext Synapse Message Context
* @param type Extension type
* @return boolean indicating to continue normal handler response flow or respond back immediately
*/
public static boolean preProcessRequest(MessageContext messageContext, String type) {
ExtensionListener extensionListener = getExtensionListener(type);
if (extensionListener != null) {
RequestContextDTO requestContextDTO = generateRequestContextDTO(messageContext);
ExtensionResponseDTO responseDTO = extensionListener.preProcessRequest(requestContextDTO);
return handleExtensionResponse(messageContext, responseDTO);
}
return true;
}
use of org.wso2.carbon.apimgt.common.gateway.dto.RequestContextDTO in project carbon-apimgt by wso2.
the class ExtensionListenerUtil method postProcessRequest.
/**
* Handles post-process request by constructing the request context DTO, invoking the matching extension listener
* implementation and processing the extension listener response.
*
* @param messageContext Synapse Message Context
* @param type Extension type
* @return boolean indicating to continue normal handler response flow or respond back immediately
*/
public static boolean postProcessRequest(MessageContext messageContext, String type) {
ExtensionListener extensionListener = getExtensionListener(type);
if (extensionListener != null) {
RequestContextDTO requestContextDTO = generateRequestContextDTO(messageContext);
ExtensionResponseDTO responseDTO = extensionListener.postProcessRequest(requestContextDTO);
return handleExtensionResponse(messageContext, responseDTO);
}
return true;
}
use of org.wso2.carbon.apimgt.common.gateway.dto.RequestContextDTO in project carbon-apimgt by wso2.
the class ExtensionListenerUtil method generateRequestContextDTO.
/**
* Generates RequestContextDTO object using Synapse MessageContext.
*
* @param messageContext Synapse MessageContext
* @return RequestContextDTO
*/
private static RequestContextDTO generateRequestContextDTO(MessageContext messageContext) {
RequestContextDTO requestDTO = new RequestContextDTO();
MsgInfoDTO msgInfoDTO = generateMessageInfo(messageContext);
APIRequestInfoDTO apiRequestInfoDTO = generateAPIInfoDTO(messageContext);
requestDTO.setApiRequestInfo(apiRequestInfoDTO);
requestDTO.setMsgInfo(msgInfoDTO);
requestDTO.setCustomProperty(getCustomPropertyMapFromMsgContext(messageContext));
javax.security.cert.X509Certificate[] clientCerts = null;
try {
X509Certificate clientCertificate = Utils.getClientCertificate(((Axis2MessageContext) messageContext).getAxis2MessageContext());
if (clientCertificate != null) {
clientCerts = new X509Certificate[] { clientCertificate };
}
} catch (APIManagementException e) {
log.error("Error when getting client certificate", e);
}
requestDTO.setClientCerts(clientCerts);
return requestDTO;
}
Aggregations