- private static void basicAuthTest(Locator<URI> dl, SecuritySetter<HttpURLConnection> ss) {
- try {
- URI uri = dl.get(dl.best());
- System.out.println("Resolved to: " + uri);
- HClient client = new HClient(ss, uri, 3000);
- client.setMethod("GET");
- client.setPathInfo("/authn/basicAuth");
- client.addHeader("Accept", "text/plain");
- client.send();
-
-
- Future<String> future = client.futureReadString();
- if(future.get(7000)) {
- System.out.println("BasicAuth Validated");
- } else {
- System.out.println("Failure " + future.code() + ":" + future.body());
- }
- } catch (CadiException | LocatorException | APIException e) {
- e.printStackTrace();
- }
- }
+ private static void permTest(Locator<URI> dl, SecuritySetter<HttpURLConnection> ss) {
+ try {
+ URI uri = dl.get(dl.best());
+ if (uri==null) {
+ System.out.print("No URI available using " + ss.getClass().getSimpleName());
+ System.out.println();
+ return;
+ } else {
+ System.out.print("Resolved to: " + uri + " using " + ss.getClass().getSimpleName());
+ }
+ if (ss instanceof HRenewingTokenSS) {
+ System.out.println(" " + ((HRenewingTokenSS)ss).tokenURL());
+ } else {
+ System.out.println();
+ }
+ HClient client = new HClient(ss, uri, 3000);
+ client.setMethod("GET");
+ String user = ss.getID();
+
+ String pathInfo = "/authz/perms/user/"+user;
+ client.setPathInfo(pathInfo);
+ System.out.println(pathInfo);
+
+ client.send();
+ Future<String> future = client.futureReadString();
+ if (future.get(7000)) {
+ System.out.println(future.body());
+ } else {
+ if (future.code()==401 && ss instanceof HX509SS) {
+ System.out.println(" Authentication denied with 401 for Certificate.\n\t"
+ + "This means Certificate isn't valid for this environment, and has attempted another method of Authentication");
+ } else {
+ System.out.println(future.code() + ":" + future.body());
+ }
+ }
+ } catch (CadiException | LocatorException | APIException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ private static void basicAuthTest(Locator<URI> dl, SecuritySetter<HttpURLConnection> ss) {
+ try {
+ URI uri = dl.get(dl.best());
+ System.out.println("Resolved to: " + uri);
+ HClient client = new HClient(ss, uri, 3000);
+ client.setMethod("GET");
+ client.setPathInfo("/authn/basicAuth");
+ client.addHeader("Accept", "text/plain");
+ client.send();
+
+
+ Future<String> future = client.futureReadString();
+ if (future.get(7000)) {
+ System.out.println("BasicAuth Validated");
+ } else {
+ System.out.println("Failure " + future.code() + ":" + future.body());
+ }
+ } catch (CadiException | LocatorException | APIException e) {
+ e.printStackTrace();
+ }
+ }