X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=restapi-call-node%2Fprovider%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fccsdk%2Fsli%2Fplugins%2Frestapicall%2FRestapiCallNode.java;h=bd2fc826791a1ff1517a1cbc8b752f8ffd890f13;hb=600aab4f869d5b632f055dce5cb910ce1d5a348e;hp=ea2d259b78e38fe08fc4064eadeb22f8bca73d89;hpb=2642a03e5aee31ce5d51719adce283f7cd96c7b9;p=ccsdk%2Fsli%2Fplugins.git
diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java
index ea2d259b..bd2fc826 100644
--- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java
+++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RestapiCallNode.java
@@ -62,6 +62,9 @@ import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
+import com.sun.jersey.oauth.client.OAuthClientFilter;
+import com.sun.jersey.oauth.signature.OAuthParameters;
+import com.sun.jersey.oauth.signature.OAuthSecrets;
import com.sun.jersey.client.urlconnection.HTTPSProperties;
public class RestapiCallNode implements SvcLogicJavaPlugin {
@@ -94,6 +97,10 @@ public class RestapiCallNode implements SvcLogicJavaPlugin {
*
restapiUrl | Mandatory | url to send the request to | https://sdncodl:8543/restconf/operations/L3VNF-API:create-update-vnf-request |
* restapiUser | Optional | user name to use for http basic authentication | sdnc_ws |
* restapiPassword | Optional | unencrypted password to use for http basic authentication | plain_password |
+ * oAuthConsumerKey | Optional | Consumer key to use for http oAuth authentication | plain_key |
+ * oAuthConsumerSecret | Optional | Consumer secret to use for http oAuth authentication | plain_secret |
+ * oAuthSignatureMethod | Optional | Consumer method to use for http oAuth authentication | method |
+ * oAuthVersion | Optional | Version http oAuth authentication | version |
* contentType | Optional | http content type to set in the http header | usually application/json or application/xml |
* format | Optional | should match request body format | json or xml |
* httpMethod | Optional | http method to use when sending the request | get post put delete patch |
@@ -216,6 +223,10 @@ public class RestapiCallNode implements SvcLogicJavaPlugin {
validateUrl(p.restapiUrl);
p.restapiUser = parseParam(paramMap, "restapiUser", false, null);
p.restapiPassword = parseParam(paramMap, "restapiPassword", false, null);
+ p.oAuthConsumerKey = parseParam(paramMap, "oAuthConsumerKey", false, null);
+ p.oAuthConsumerSecret = parseParam(paramMap, "oAuthConsumerSecret", false, null);
+ p.oAuthSignatureMethod = parseParam(paramMap, "oAuthSignatureMethod", false, null);
+ p.oAuthVersion = parseParam(paramMap, "oAuthVersion", false, null);
p.contentType = parseParam(paramMap, "contentType", false, null);
p.format = Format.fromString(parseParam(paramMap, "format", false, "json"));
p.httpMethod = HttpMethod.fromString(parseParam(paramMap, "httpMethod", false, "post"));
@@ -439,6 +450,17 @@ public class RestapiCallNode implements SvcLogicJavaPlugin {
client.setConnectTimeout(5000);
if (p.restapiUser != null && p.restapiPassword != null)
client.addFilter(new HTTPBasicAuthFilter(p.restapiUser, p.restapiPassword));
+ else if(p.oAuthConsumerKey != null && p.oAuthConsumerSecret != null && p.oAuthSignatureMethod != null && p.oAuthVersion != null)
+ {
+ OAuthParameters params = new OAuthParameters()
+ .signatureMethod(p.oAuthSignatureMethod)
+ .consumerKey(p.oAuthConsumerKey)
+ .version(p.oAuthVersion);
+
+ OAuthSecrets secrets = new OAuthSecrets()
+ .consumerSecret(p.oAuthConsumerSecret);
+ client.addFilter(new OAuthClientFilter(client.getProviders(), params, secrets));
+ }
WebResource webResource = client.resource(p.restapiUrl);
log.info("Sending request:");