- TzClient tzClient = tcf.newTzClient(endServicesURL);
- tzClient.setToken(client_id, rtt.value);
- // Note: this is AAF's "Hello" server
- String rv = serviceCall(tzClient);
- System.out.println(rv);
- // Assert.assertEquals("Hello AAF OAuth2\n",rv);
- } else {
- System.out.println(rtt.code + ' ' + rtt.error);
- Assert.fail(rtt.code + ' ' + rtt.error);
- }
- } else {
- System.out.println(rtt.code + ' ' + rtt.error);
- Assert.fail(rtt.code + ' ' + rtt.error);
- }
- } else {
- Assert.fail(Config.AAF_ALT_OAUTH2_TOKEN_URL + " is required");
- }
- }
- } catch (Exception e) {
-// Assert.fail();
- }
- }
-
-
-// private TokenClient testROPCFlow(final String url, final String client_id, final String client_secret, String user, String password, final String ... scope) throws Exception {
-// TokenClient tclient = tcf.newClient(url,3000);
-// tclient.client_creds(client_id, client_secret);
-// if(user!=null && password!=null) {
-// tclient.password(user,password);
-// }
-// Result<TimedToken> rt = tclient.getToken(scope);
-// if(rt.isOK()) {
-// print(rt.value);
-// Result<Introspect> rti = tclient.introspect(rt.value.getAccessToken());
-// if(rti.isOK()) {
-// print(rti.value);
-// } else {
-// printAndFail(rti);
-// }
-// } else {
-// printAndFail(rt);
-// }
-// return tclient;
-// }
-
- private String serviceCall(TzClient tzClient) throws Exception {
- return tzClient.best(new Retryable<String>() {
- @Override
- public String code(Rcli<?> client) throws CadiException, ConnectException, APIException {
- Future<String> future = client.read(null,"text/plain");
- if(future.get(3000)) {
- return future.value;
- } else {
- throw new APIException(future.code() + future.body());
- }
- }
- });
- }
-// private void printAndFail(Result<?> rt) {
-// System.out.printf("HTTP Code %d: %s\n", rt.code, rt.error);
-// Assert.fail(rt.toString());
-// }
+ TzClient tzClient = tcf.newTzClient(endServicesURL);
+ tzClient.setToken(client_id, rtt.value);
+ // Note: this is AAF's "Hello" server
+ String rv = serviceCall(tzClient);
+ System.out.println(rv);
+ // Assert.assertEquals("Hello AAF OAuth2\n",rv);
+ } else {
+ System.out.println(rtt.code + ' ' + rtt.error);
+ Assert.fail(rtt.code + ' ' + rtt.error);
+ }
+ } else {
+ System.out.println(rtt.code + ' ' + rtt.error);
+ Assert.fail(rtt.code + ' ' + rtt.error);
+ }
+ } else {
+ Assert.fail(Config.AAF_ALT_OAUTH2_TOKEN_URL + " is required");
+ }
+ }
+ } catch (Exception e) {
+// Assert.fail();
+ }
+ }
+
+
+// private TokenClient testROPCFlow(final String url, final String client_id, final String client_secret, String user, String password, final String ... scope) throws Exception {
+// TokenClient tclient = tcf.newClient(url,3000);
+// tclient.client_creds(client_id, client_secret);
+// if(user!=null && password!=null) {
+// tclient.password(user,password);
+// }
+// Result<TimedToken> rt = tclient.getToken(scope);
+// if(rt.isOK()) {
+// print(rt.value);
+// Result<Introspect> rti = tclient.introspect(rt.value.getAccessToken());
+// if(rti.isOK()) {
+// print(rti.value);
+// } else {
+// printAndFail(rti);
+// }
+// } else {
+// printAndFail(rt);
+// }
+// return tclient;
+// }
+
+ private String serviceCall(TzClient tzClient) throws Exception {
+ return tzClient.best(new Retryable<String>() {
+ @Override
+ public String code(Rcli<?> client) throws CadiException, ConnectException, APIException {
+ Future<String> future = client.read(null,"text/plain");
+ if(future.get(3000)) {
+ return future.value;
+ } else {
+ throw new APIException(future.code() + future.body());
+ }
+ }
+ });
+ }
+// private void printAndFail(Result<?> rt) {
+// System.out.printf("HTTP Code %d: %s\n", rt.code, rt.error);
+// Assert.fail(rt.toString());
+// }