use of org.apache.synapse.endpoints.oauth.OAuthHandler in project wso2-synapse by wso2.
the class HTTPEndpointFactory method createEndpoint.
@Override
protected Endpoint createEndpoint(OMElement epConfig, boolean anonymousEndpoint, Properties properties) {
OMAttribute nameAttr = epConfig.getAttribute(new QName(XMLConfigConstants.NULL_NAMESPACE, "name"));
String name = null;
if (nameAttr != null) {
name = nameAttr.getAttributeValue();
}
OMElement httpElement = epConfig.getFirstChildWithName(new QName(SynapseConstants.SYNAPSE_NAMESPACE, "http"));
HTTPEndpoint httpEndpoint;
OAuthHandler oAuthhandler = createOAuthHandler(httpElement, name);
if (oAuthhandler != null) {
httpEndpoint = new OAuthConfiguredHTTPEndpoint(oAuthhandler);
} else {
httpEndpoint = new HTTPEndpoint();
}
if (name != null) {
httpEndpoint.setName(name);
}
if (httpElement != null) {
EndpointDefinition definition = createEndpointDefinition(httpElement);
OMAttribute uriTemplateAttr = httpElement.getAttribute(new QName("uri-template"));
if (uriTemplateAttr != null) {
String uriValue = uriTemplateAttr.getAttributeValue();
uriValue = ResolverFactory.getInstance().getResolver(uriValue).resolve();
// get object and and resolve
if (uriValue.startsWith(HTTPEndpoint.legacyPrefix)) {
httpEndpoint.setUriTemplate(UriTemplate.fromTemplate(uriValue.substring(HTTPEndpoint.legacyPrefix.length())));
// Set the address to the initial template value.
definition.setAddress(uriValue.substring(HTTPEndpoint.legacyPrefix.length()));
httpEndpoint.setLegacySupport(true);
} else {
httpEndpoint.setUriTemplate(UriTemplate.fromTemplate(uriValue));
// Set the address to the initial template value.
definition.setAddress(uriValue);
httpEndpoint.setLegacySupport(false);
}
}
httpEndpoint.setDefinition(definition);
processAuditStatus(definition, httpEndpoint.getName(), httpElement);
OMAttribute methodAttr = httpElement.getAttribute(new QName("method"));
if (methodAttr != null) {
setHttpMethod(httpEndpoint, methodAttr.getAttributeValue());
} else {
// Method is not a mandatory parameter for HttpEndpoint. So methodAttr Can be null
if (log.isDebugEnabled()) {
log.debug("Method is not specified for HttpEndpoint. " + "Hence using the http method from incoming message");
}
}
}
processProperties(httpEndpoint, epConfig);
CommentListUtil.populateComments(epConfig, httpEndpoint.getCommentsList());
return httpEndpoint;
}
Aggregations