Github user alopresto commented on a diff in the pull request:
https://github.com/apache/nifi/pull/2085#discussion_r174886395
--- Diff:
nifi-nar-bundles/nifi-oauth-bundle/nifi-oauth/src/main/java/org/apache/nifi/oauth/httpclient/OAuthHTTPConnectionClient.java
---
@@ -0,0 +1,252 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.nifi.oauth.httpclient;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.oltu.oauth2.client.HttpClient;
+import org.apache.oltu.oauth2.client.request.OAuthClientRequest;
+import org.apache.oltu.oauth2.client.response.OAuthAccessTokenResponse;
+import org.apache.oltu.oauth2.client.response.OAuthClientResponse;
+import org.apache.oltu.oauth2.common.OAuth;
+import org.apache.oltu.oauth2.common.exception.OAuthProblemException;
+import org.apache.oltu.oauth2.common.exception.OAuthSystemException;
+import org.apache.oltu.oauth2.common.token.BasicOAuthToken;
+import org.apache.oltu.oauth2.common.token.OAuthToken;
+import org.apache.oltu.oauth2.common.utils.OAuthUtils;
+import org.json.JSONObject;
+
+public class OAuthHTTPConnectionClient
+ implements HttpClient {
+
+ private String accessTokenName = null;
+ private String tokenTypeName = null;
+ private String scopeName = null;
+ private String expireInName = null;
+ private String expireTimeName = null;
+
+ public OAuthHTTPConnectionClient(String accessTokenName, String
tokenTypeName, String scopeName, String expireInName, String expireTimeName) {
+ this.accessTokenName = accessTokenName;
+ this.tokenTypeName = tokenTypeName;
+ this.scopeName = scopeName;
+ this.expireInName = expireInName;
+ this.expireTimeName = expireTimeName;
+ }
+
+ @Override
+ public <T extends OAuthClientResponse> T execute(OAuthClientRequest
request, Map<String, String> headers,
+ String requestMethod, Class<T> responseClass) throws
OAuthSystemException, OAuthProblemException {
+
+ InputStream responseBody = null;
+ URLConnection c;
+ Map<String, List<String>> responseHeaders = new HashMap<String,
List<String>>();
+ int responseCode;
+ try {
+ URL url = new URL(request.getLocationUri());
--- End diff --
This method needs to be improved to make a successful connection. Given the
two *auth server* values of `apachenifi.auth0.com` and
`https://apachenifi.auth0.com`, I got the following respective errors:
* `2018-03-15 11:24:03,761 ERROR [Timer-Driven Process Thread-4]
o.a.n.o.OAuth2ClientCredentialsGrantControllerService
OAuth2ClientCredentialsGrantControllerService[id=01621005-6aa2-173b-d160-59d53622ab46]
java.net.MalformedURLException: no protocol: apachenifi.auth0.com`
* `2018-03-15 11:25:49,002 ERROR [Timer-Driven Process Thread-3]
o.a.n.o.OAuth2ClientCredentialsGrantControllerService
OAuth2ClientCredentialsGrantControllerService[id=01621005-6aa2-173b-d160-59d53622ab46]
java.io.FileNotFoundException: https://apachenifi.auth0.com`
---