use of org.wso2.carbon.apimgt.common.gateway.dto.APIRequestInfoDTO in project carbon-apimgt by wso2.
the class ExtensionListenerUtil method generateAPIInfoDTO.
/**
* Generates APIRequestInfoDTO object using Synapse MessageContext.
*
* @param messageContext Synapse MessageContext
* @return APIRequestInfoDTO
*/
private static APIRequestInfoDTO generateAPIInfoDTO(MessageContext messageContext) {
APIRequestInfoDTO apiRequestInfoDTO = new APIRequestInfoDTO();
apiRequestInfoDTO.setContext((String) messageContext.getProperty(RESTConstants.REST_API_CONTEXT));
apiRequestInfoDTO.setVersion((String) messageContext.getProperty(RESTConstants.SYNAPSE_REST_API_VERSION));
apiRequestInfoDTO.setApiId((String) messageContext.getProperty(APIMgtGatewayConstants.API_UUID_PROPERTY));
AuthenticationContext authenticationContext = APISecurityUtils.getAuthenticationContext(messageContext);
if (authenticationContext != null) {
apiRequestInfoDTO.setUsername(authenticationContext.getUsername());
apiRequestInfoDTO.setConsumerKey(authenticationContext.getConsumerKey());
}
return apiRequestInfoDTO;
}
use of org.wso2.carbon.apimgt.common.gateway.dto.APIRequestInfoDTO in project carbon-apimgt by wso2.
the class ExtensionListenerUtil method generateResponseContextDTO.
/**
* Generates ResponseContextDTO object using Synapse MessageContext.
*
* @param messageContext Synapse MessageContext
* @return ResponseContextDTO
*/
private static ResponseContextDTO generateResponseContextDTO(MessageContext messageContext) {
ResponseContextDTO responseContextDTO = new ResponseContextDTO();
MsgInfoDTO msgInfoDTO = generateMessageInfo(messageContext);
APIRequestInfoDTO apiRequestInfoDTO = generateAPIInfoDTO(messageContext);
responseContextDTO.setApiRequestInfo(apiRequestInfoDTO);
responseContextDTO.setMsgInfo(msgInfoDTO);
responseContextDTO.setStatusCode((int) ((Axis2MessageContext) messageContext).getAxis2MessageContext().getProperty(NhttpConstants.HTTP_SC));
return responseContextDTO;
}
use of org.wso2.carbon.apimgt.common.gateway.dto.APIRequestInfoDTO 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