summaryrefslogtreecommitdiffstats
path: root/cadi/oauth-enduser/src/main
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2018-09-07 12:21:34 -0500
committerInstrumental <jonathan.gathman@att.com>2018-09-07 12:22:50 -0500
commit4b5a7d721d994a49057e9bfb403c7bff1b376660 (patch)
treea36d03227b63a3e60346d6c3ca87b061087dae85 /cadi/oauth-enduser/src/main
parent824dc7b5fc0e1ccdf7f460479aff344727f0f01e (diff)
Mass removal of all Tabs (Style Warnings)
Issue-ID: AAF-473 Change-Id: Iaf0ef8120882937959bb0065f2f6ba74a021940f Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'cadi/oauth-enduser/src/main')
-rw-r--r--cadi/oauth-enduser/src/main/java/org/onap/aaf/cadi/enduser/ClientFactory.java36
-rw-r--r--cadi/oauth-enduser/src/main/java/org/onap/aaf/cadi/enduser/RESTException.java70
-rw-r--r--cadi/oauth-enduser/src/main/java/org/onap/aaf/cadi/enduser/SimpleRESTClient.java494
3 files changed, 300 insertions, 300 deletions
diff --git a/cadi/oauth-enduser/src/main/java/org/onap/aaf/cadi/enduser/ClientFactory.java b/cadi/oauth-enduser/src/main/java/org/onap/aaf/cadi/enduser/ClientFactory.java
index 50eaa759..2a1ecdeb 100644
--- a/cadi/oauth-enduser/src/main/java/org/onap/aaf/cadi/enduser/ClientFactory.java
+++ b/cadi/oauth-enduser/src/main/java/org/onap/aaf/cadi/enduser/ClientFactory.java
@@ -33,24 +33,24 @@ import org.onap.aaf.cadi.oauth.TokenClientFactory;
import org.onap.aaf.misc.env.APIException;
public class ClientFactory {
- private final TokenClientFactory tcf;
- public ClientFactory(final PropAccess access) throws APIException, CadiException {
- try {
- tcf = TokenClientFactory.instance(access);
- } catch (GeneralSecurityException | IOException e) {
- throw new CadiException(e);
- }
- }
-
- public ClientFactory(String[] args) throws APIException, CadiException {
- this(new PropAccess(args));
- }
+ private final TokenClientFactory tcf;
+ public ClientFactory(final PropAccess access) throws APIException, CadiException {
+ try {
+ tcf = TokenClientFactory.instance(access);
+ } catch (GeneralSecurityException | IOException e) {
+ throw new CadiException(e);
+ }
+ }
+
+ public ClientFactory(String[] args) throws APIException, CadiException {
+ this(new PropAccess(args));
+ }
- public SimpleRESTClient simpleRESTClient(final String endpoint, final String ... scopes) throws URISyntaxException, LocatorException, CadiException, APIException {
- return new SimpleRESTClient(tcf, Config.AAF_OAUTH2_TOKEN_URL, endpoint, scopes);
- }
+ public SimpleRESTClient simpleRESTClient(final String endpoint, final String ... scopes) throws URISyntaxException, LocatorException, CadiException, APIException {
+ return new SimpleRESTClient(tcf, Config.AAF_OAUTH2_TOKEN_URL, endpoint, scopes);
+ }
- public Access getAccess() {
- return tcf.access;
- }
+ public Access getAccess() {
+ return tcf.access;
+ }
}
diff --git a/cadi/oauth-enduser/src/main/java/org/onap/aaf/cadi/enduser/RESTException.java b/cadi/oauth-enduser/src/main/java/org/onap/aaf/cadi/enduser/RESTException.java
index 95c9fe85..107e1d89 100644
--- a/cadi/oauth-enduser/src/main/java/org/onap/aaf/cadi/enduser/RESTException.java
+++ b/cadi/oauth-enduser/src/main/java/org/onap/aaf/cadi/enduser/RESTException.java
@@ -23,44 +23,44 @@ package org.onap.aaf.cadi.enduser;
import org.onap.aaf.cadi.client.Future;
public class RESTException extends Exception {
- /**
- *
- */
- private static final long serialVersionUID = -5232371598208651058L;
- private Future<?> future;
+ /**
+ *
+ */
+ private static final long serialVersionUID = -5232371598208651058L;
+ private Future<?> future;
- public RESTException(Future<?> future) {
- this.future = future;
- }
-
- public int getCode() {
- return future.code();
- }
-
- public String getMsg() {
- return future.body();
- }
+ public RESTException(Future<?> future) {
+ this.future = future;
+ }
+
+ public int getCode() {
+ return future.code();
+ }
+
+ public String getMsg() {
+ return future.body();
+ }
- public String errorString() {
- String body = future.body();
- return "RESTClient Error: " + future.code() + ": " + (body.isEmpty()?"<no message in call>":body);
- }
+ public String errorString() {
+ String body = future.body();
+ return "RESTClient Error: " + future.code() + ": " + (body.isEmpty()?"<no message in call>":body);
+ }
- /* (non-Javadoc)
- * @see java.lang.Throwable#getMessage()
- */
- @Override
- public String getMessage() {
- return errorString();
- }
+ /* (non-Javadoc)
+ * @see java.lang.Throwable#getMessage()
+ */
+ @Override
+ public String getMessage() {
+ return errorString();
+ }
- /* (non-Javadoc)
- * @see java.lang.Throwable#getLocalizedMessage()
- */
- @Override
- public String getLocalizedMessage() {
- return errorString();
- }
-
+ /* (non-Javadoc)
+ * @see java.lang.Throwable#getLocalizedMessage()
+ */
+ @Override
+ public String getLocalizedMessage() {
+ return errorString();
+ }
+
}
diff --git a/cadi/oauth-enduser/src/main/java/org/onap/aaf/cadi/enduser/SimpleRESTClient.java b/cadi/oauth-enduser/src/main/java/org/onap/aaf/cadi/enduser/SimpleRESTClient.java
index 30344de5..7c633640 100644
--- a/cadi/oauth-enduser/src/main/java/org/onap/aaf/cadi/enduser/SimpleRESTClient.java
+++ b/cadi/oauth-enduser/src/main/java/org/onap/aaf/cadi/enduser/SimpleRESTClient.java
@@ -43,266 +43,266 @@ import org.onap.aaf.misc.env.APIException;
import org.onap.aaf.misc.env.util.StringBuilderWriter;
public class SimpleRESTClient {
- private static final String APPLICATION_JSON = "application/json";
- private static final String[] EMPTY = new String[0];
- private final TokenClient tokenClient;
- private final TzClient restClient;
- private int callTimeout;
- private String client_id;
- private String app;
- private String chain;
- private Headers headers = new Headers() {
- @Override
- public String[] headers() {
- return EMPTY;
- }};
-
- public SimpleRESTClient(final TokenClientFactory tcf, final String tokenURL, final String endpoint, final String[] scope) throws CadiException, LocatorException, APIException {
- callTimeout = Integer.parseInt(tcf.access.getProperty(Config.AAF_CALL_TIMEOUT,Config.AAF_CALL_TIMEOUT_DEF));
- tokenClient = tcf.newClient(tokenURL);
- Result<TimedToken> rtt = tokenClient.getToken(scope);
- if(rtt.isOK()) {
- restClient = tcf.newTzClient(endpoint);
-
- if((client_id = tcf.access.getProperty(Config.AAF_APPID, null))==null) {
- if((client_id = tcf.access.getProperty(Config.CADI_ALIAS, null))==null) {
- throw new CadiException(Config.AAF_APPID + " or " + Config.CADI_ALIAS + " needs to be defined");
- }
- }
- try {
- restClient.setToken(client_id,rtt.value);
- } catch (IOException e) {
- throw new CadiException(e);
- }
- } else {
- throw new CadiException(rtt.error);
- }
- }
-
- public SimpleRESTClient timeout(int newTimeout) {
- callTimeout = newTimeout;
- return this;
- }
+ private static final String APPLICATION_JSON = "application/json";
+ private static final String[] EMPTY = new String[0];
+ private final TokenClient tokenClient;
+ private final TzClient restClient;
+ private int callTimeout;
+ private String client_id;
+ private String app;
+ private String chain;
+ private Headers headers = new Headers() {
+ @Override
+ public String[] headers() {
+ return EMPTY;
+ }};
+
+ public SimpleRESTClient(final TokenClientFactory tcf, final String tokenURL, final String endpoint, final String[] scope) throws CadiException, LocatorException, APIException {
+ callTimeout = Integer.parseInt(tcf.access.getProperty(Config.AAF_CALL_TIMEOUT,Config.AAF_CALL_TIMEOUT_DEF));
+ tokenClient = tcf.newClient(tokenURL);
+ Result<TimedToken> rtt = tokenClient.getToken(scope);
+ if(rtt.isOK()) {
+ restClient = tcf.newTzClient(endpoint);
+
+ if((client_id = tcf.access.getProperty(Config.AAF_APPID, null))==null) {
+ if((client_id = tcf.access.getProperty(Config.CADI_ALIAS, null))==null) {
+ throw new CadiException(Config.AAF_APPID + " or " + Config.CADI_ALIAS + " needs to be defined");
+ }
+ }
+ try {
+ restClient.setToken(client_id,rtt.value);
+ } catch (IOException e) {
+ throw new CadiException(e);
+ }
+ } else {
+ throw new CadiException(rtt.error);
+ }
+ }
+
+ public SimpleRESTClient timeout(int newTimeout) {
+ callTimeout = newTimeout;
+ return this;
+ }
- //Format:<ID>:<APP>:<protocol>[:AS][,<ID>:<APP>:<protocol>]*
- public SimpleRESTClient endUser(Principal principal) {
- if(principal==null) {
- chain = null;
- } else {
- if(principal instanceof TaggedPrincipal) {
- TaggedPrincipal tp = (TaggedPrincipal)principal;
- chain = tp.getName() + ':' + (app==null?"":app) + ':' + tp.tag() + ":AS";
- } else {
- chain = principal.getName() + (app==null?"":':'+app);
- }
- }
- return this;
- }
-
- /**
- * Single Threaded Class for building up content
- * @author jg1555
- *
- */
- public static class Input {
- private static final byte[] EMPTY_STREAM_BYTES = "".getBytes();
+ //Format:<ID>:<APP>:<protocol>[:AS][,<ID>:<APP>:<protocol>]*
+ public SimpleRESTClient endUser(Principal principal) {
+ if(principal==null) {
+ chain = null;
+ } else {
+ if(principal instanceof TaggedPrincipal) {
+ TaggedPrincipal tp = (TaggedPrincipal)principal;
+ chain = tp.getName() + ':' + (app==null?"":app) + ':' + tp.tag() + ":AS";
+ } else {
+ chain = principal.getName() + (app==null?"":':'+app);
+ }
+ }
+ return this;
+ }
+
+ /**
+ * Single Threaded Class for building up content
+ * @author jg1555
+ *
+ */
+ public static class Input {
+ private static final byte[] EMPTY_STREAM_BYTES = "".getBytes();
- private String content;
- private StringBuilder sb;
-
- public Input() {
- content = null;
- sb = null;
- }
-
- public Input(final String content) {
- this.content = content;
- }
-
- public void set(final String content) {
- this.content = content;
- }
-
- public PrintWriter writer() {
- return new PrintWriter(new StringBuilderWriter(builder()));
- }
-
- public StringBuilder builder() {
- if(sb==null) {
- sb = new StringBuilder();
- content = null;
- }
- return sb;
- }
-
- /**
- * Reuse StringBuilder object
- */
- public void clear() {
- content = null;
- if(sb!=null) {
- sb.setLength(0);
- }
- }
-
- @Override
- public String toString() {
- if(content!=null) {
- return content;
- } else if(sb!=null) {
- return sb.toString();
- } else {
- return "";
- }
- }
+ private String content;
+ private StringBuilder sb;
+
+ public Input() {
+ content = null;
+ sb = null;
+ }
+
+ public Input(final String content) {
+ this.content = content;
+ }
+
+ public void set(final String content) {
+ this.content = content;
+ }
+
+ public PrintWriter writer() {
+ return new PrintWriter(new StringBuilderWriter(builder()));
+ }
+
+ public StringBuilder builder() {
+ if(sb==null) {
+ sb = new StringBuilder();
+ content = null;
+ }
+ return sb;
+ }
+
+ /**
+ * Reuse StringBuilder object
+ */
+ public void clear() {
+ content = null;
+ if(sb!=null) {
+ sb.setLength(0);
+ }
+ }
+
+ @Override
+ public String toString() {
+ if(content!=null) {
+ return content;
+ } else if(sb!=null) {
+ return sb.toString();
+ } else {
+ return "";
+ }
+ }
- public byte[] getBytes() {
- byte[] rv;
- if(content==null) {
- if(sb==null) {
- rv = EMPTY_STREAM_BYTES;
- } else {
- rv = sb.toString().getBytes();
- }
- } else {
- rv = content.getBytes();
- }
- content = null;
- return rv;
- }
- }
+ public byte[] getBytes() {
+ byte[] rv;
+ if(content==null) {
+ if(sb==null) {
+ rv = EMPTY_STREAM_BYTES;
+ } else {
+ rv = sb.toString().getBytes();
+ }
+ } else {
+ rv = content.getBytes();
+ }
+ content = null;
+ return rv;
+ }
+ }
- /////////////////////////////////////////////////////////////
- //
- // CREATE
- //
- /////////////////////////////////////////////////////////////
- public void create(final String path, final Input input) throws RESTException, CadiException, LocatorException, APIException {
- post(path,APPLICATION_JSON, input);
- }
+ /////////////////////////////////////////////////////////////
+ //
+ // CREATE
+ //
+ /////////////////////////////////////////////////////////////
+ public void create(final String path, final Input input) throws RESTException, CadiException, LocatorException, APIException {
+ post(path,APPLICATION_JSON, input);
+ }
- public void post(final String path, final Input input) throws RESTException, CadiException, LocatorException, APIException {
- post(path,APPLICATION_JSON, input);
- }
+ public void post(final String path, final Input input) throws RESTException, CadiException, LocatorException, APIException {
+ post(path,APPLICATION_JSON, input);
+ }
- public void post(final String path, final String contentType, final Input input) throws RESTException, CadiException, LocatorException, APIException {
- Future<Void> future = restClient.best(new Retryable<Future<Void>>() {
- @Override
- public Future<Void> code(Rcli<?> client) throws CadiException, ConnectException, APIException {
- return client.create(path, contentType, new ETransfer(input));
- }
- });
- if(!future.get(callTimeout)) {
- throw new RESTException(future);
- }
- }
+ public void post(final String path, final String contentType, final Input input) throws RESTException, CadiException, LocatorException, APIException {
+ Future<Void> future = restClient.best(new Retryable<Future<Void>>() {
+ @Override
+ public Future<Void> code(Rcli<?> client) throws CadiException, ConnectException, APIException {
+ return client.create(path, contentType, new ETransfer(input));
+ }
+ });
+ if(!future.get(callTimeout)) {
+ throw new RESTException(future);
+ }
+ }
- /////////////////////////////////////////////////////////////
- //
- // READ
- //
- /////////////////////////////////////////////////////////////
- public String read(final String path) throws RESTException, CadiException, LocatorException, APIException {
- return get(path,APPLICATION_JSON);
- }
+ /////////////////////////////////////////////////////////////
+ //
+ // READ
+ //
+ /////////////////////////////////////////////////////////////
+ public String read(final String path) throws RESTException, CadiException, LocatorException, APIException {
+ return get(path,APPLICATION_JSON);
+ }
- public String get(final String path) throws RESTException, CadiException, LocatorException, APIException {
- return get(path,APPLICATION_JSON);
- }
+ public String get(final String path) throws RESTException, CadiException, LocatorException, APIException {
+ return get(path,APPLICATION_JSON);
+ }
- public String get(final String path, final String accepts) throws RESTException, CadiException, LocatorException, APIException {
- Future<String> future = restClient.best(new Retryable<Future<String>>() {
- @Override
- public Future<String> code(Rcli<?> client) throws CadiException, ConnectException, APIException {
- return client.read(path,accepts, headers());
- }
- });
- if(future.get(callTimeout)) {
- return future.value;
- } else {
- throw new RESTException(future);
- }
- }
-
- /////////////////////////////////////////////////////////////
- //
- // UPDATE
- //
- /////////////////////////////////////////////////////////////
+ public String get(final String path, final String accepts) throws RESTException, CadiException, LocatorException, APIException {
+ Future<String> future = restClient.best(new Retryable<Future<String>>() {
+ @Override
+ public Future<String> code(Rcli<?> client) throws CadiException, ConnectException, APIException {
+ return client.read(path,accepts, headers());
+ }
+ });
+ if(future.get(callTimeout)) {
+ return future.value;
+ } else {
+ throw new RESTException(future);
+ }
+ }
+
+ /////////////////////////////////////////////////////////////
+ //
+ // UPDATE
+ //
+ /////////////////////////////////////////////////////////////
- public String update(final String path, final Input input) throws RESTException, CadiException, LocatorException, APIException {
- return put(path,APPLICATION_JSON, input);
- }
+ public String update(final String path, final Input input) throws RESTException, CadiException, LocatorException, APIException {
+ return put(path,APPLICATION_JSON, input);
+ }
- public String put(final String path, final Input input) throws RESTException, CadiException, LocatorException, APIException {
- return put(path,APPLICATION_JSON, input);
- }
+ public String put(final String path, final Input input) throws RESTException, CadiException, LocatorException, APIException {
+ return put(path,APPLICATION_JSON, input);
+ }
- public String put(final String path, final String contentType, final Input input) throws RESTException, CadiException, LocatorException, APIException {
- Future<String> future = restClient.best(new Retryable<Future<String>>() {
- @Override
- public Future<String> code(Rcli<?> client) throws CadiException, ConnectException, APIException {
- return client.update(path, contentType, new ETransfer(input));
- }
- });
- if(future.get(callTimeout)) {
- return future.value;
- } else {
- throw new RESTException(future);
- }
- }
+ public String put(final String path, final String contentType, final Input input) throws RESTException, CadiException, LocatorException, APIException {
+ Future<String> future = restClient.best(new Retryable<Future<String>>() {
+ @Override
+ public Future<String> code(Rcli<?> client) throws CadiException, ConnectException, APIException {
+ return client.update(path, contentType, new ETransfer(input));
+ }
+ });
+ if(future.get(callTimeout)) {
+ return future.value;
+ } else {
+ throw new RESTException(future);
+ }
+ }
- /////////////////////////////////////////////////////////////
- //
- // DELETE
- //
- /////////////////////////////////////////////////////////////
- public void delete(final String path) throws RESTException, CadiException, LocatorException, APIException {
- delete(path,APPLICATION_JSON);
- }
-
- public void delete(final String path, final String contentType) throws RESTException, CadiException, LocatorException, APIException {
- Future<Void> future = restClient.best(new Retryable<Future<Void>>() {
- @Override
- public Future<Void> code(Rcli<?> client) throws CadiException, ConnectException, APIException {
- return client.delete(path, contentType);
- }
- });
- if(!future.get(callTimeout)) {
- throw new RESTException(future);
- }
- }
+ /////////////////////////////////////////////////////////////
+ //
+ // DELETE
+ //
+ /////////////////////////////////////////////////////////////
+ public void delete(final String path) throws RESTException, CadiException, LocatorException, APIException {
+ delete(path,APPLICATION_JSON);
+ }
+
+ public void delete(final String path, final String contentType) throws RESTException, CadiException, LocatorException, APIException {
+ Future<Void> future = restClient.best(new Retryable<Future<Void>>() {
+ @Override
+ public Future<Void> code(Rcli<?> client) throws CadiException, ConnectException, APIException {
+ return client.delete(path, contentType);
+ }
+ });
+ if(!future.get(callTimeout)) {
+ throw new RESTException(future);
+ }
+ }
- /////////////////////////////////////////////////////////////
-
- private static class ETransfer implements EClient.Transfer {
- private Input input;
- public ETransfer(final Input input) {
- this.input = input;
- }
-
- @Override
- public void transfer(OutputStream os) throws IOException, APIException {
- os.write(input.getBytes());
- }
- }
+ /////////////////////////////////////////////////////////////
+
+ private static class ETransfer implements EClient.Transfer {
+ private Input input;
+ public ETransfer(final Input input) {
+ this.input = input;
+ }
+
+ @Override
+ public void transfer(OutputStream os) throws IOException, APIException {
+ os.write(input.getBytes());
+ }
+ }
- public interface Headers {
- String[] headers();
- }
-
- public String[] headers() {
- if(chain==null) {
- return headers.headers();
- } else {
- String[] strs = headers.headers();
- String[] rv = new String[strs.length+2];
- rv[0]=Config.CADI_USER_CHAIN;
- rv[1]=chain;
- for(int i = 0;i<strs.length;++i) {
- rv[i+2]=strs[i];
- }
- return rv;
- }
- }
+ public interface Headers {
+ String[] headers();
+ }
+
+ public String[] headers() {
+ if(chain==null) {
+ return headers.headers();
+ } else {
+ String[] strs = headers.headers();
+ String[] rv = new String[strs.length+2];
+ rv[0]=Config.CADI_USER_CHAIN;
+ rv[1]=chain;
+ for(int i = 0;i<strs.length;++i) {
+ rv[i+2]=strs[i];
+ }
+ return rv;
+ }
+ }
}