X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cadi%2Faaf%2Fsrc%2Ftest%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2Faaf%2Ftest%2FTestHClient.java;h=18e72b4be81c41dfc6450fca58e0c0da3ed1f676;hb=1296352d8eafee57f982a4342ad79ada4aa56d28;hp=9536cd90a3f6fb882f534b5f977a10b81be136cb;hpb=ceda6e8bc270202bcb24340b86617110289c902e;p=aaf%2Fauthz.git diff --git a/cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/test/TestHClient.java b/cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/test/TestHClient.java index 9536cd90..18e72b4b 100644 --- a/cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/test/TestHClient.java +++ b/cadi/aaf/src/test/java/org/onap/aaf/cadi/aaf/test/TestHClient.java @@ -7,9 +7,9 @@ * Licensed 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. @@ -24,11 +24,10 @@ package org.onap.aaf.cadi.aaf.test; import java.net.HttpURLConnection; import java.net.URI; -import org.onap.aaf.cadi.CadiException; -import org.onap.aaf.cadi.PropAccess; -import org.onap.aaf.cadi.SecuritySetter; import org.onap.aaf.cadi.Access.Level; +import org.onap.aaf.cadi.CadiException; import org.onap.aaf.cadi.Locator.Item; +import org.onap.aaf.cadi.PropAccess; import org.onap.aaf.cadi.aaf.v2_0.AAFLocator; import org.onap.aaf.cadi.aaf.v2_0.AbsAAFLocator; import org.onap.aaf.cadi.client.Future; @@ -36,52 +35,49 @@ import org.onap.aaf.cadi.client.Rcli; import org.onap.aaf.cadi.client.Retryable; import org.onap.aaf.cadi.config.Config; import org.onap.aaf.cadi.config.SecurityInfoC; -import org.onap.aaf.cadi.http.HBasicAuthSS; import org.onap.aaf.cadi.http.HMangr; import org.onap.aaf.misc.env.APIException; import org.onap.aaf.misc.env.impl.BasicTrans; public class TestHClient { - public static void main(String[] args) { - try { - PropAccess access = new PropAccess(args); - String aaf_url = access.getProperty(Config.AAF_URL); - if(aaf_url == null) { - access.log(Level.ERROR, Config.AAF_URL," is required"); - } else { - HMangr hman = null; - try { - SecurityInfoC si = SecurityInfoC.instance(access, HttpURLConnection.class); - AbsAAFLocator loc = new AAFLocator(si,new URI(aaf_url)); - for(Item item = loc.first(); item!=null; item=loc.next(item)) { - System.out.println(loc.get(item)); - } - SecuritySetter ss = new HBasicAuthSS(si); - // SecuritySetter ss = new X509SS(si, "aaf"); - - hman = new HMangr(access,loc); - final String path = String.format("/authz/perms/user/%s", - access.getProperty(Config.AAF_APPID,"xx9999@csp.att.com")); - hman.best(ss, new Retryable() { - @Override - public Void code(Rcli cli) throws APIException, CadiException { - Future ft = cli.read(path,"application/json"); - if(ft.get(10000)) { - System.out.println("Hurray,\n"+ft.body()); - } else { - System.out.println("not quite: " + ft.code()); - } - return null; - }}); - } finally { - if(hman!=null) { - hman.close(); - } - } - } - } catch (Exception e) { - e.printStackTrace(); - } - } - + public static void main(String[] args) { + try { + PropAccess access = new PropAccess(args); + String aaf_url = access.getProperty(Config.AAF_URL); + if (aaf_url == null) { + access.log(Level.ERROR, Config.AAF_URL," is required"); + } else { + HMangr hman = null; + try { + SecurityInfoC si = SecurityInfoC.instance(access, HttpURLConnection.class); + AbsAAFLocator loc = new AAFLocator(si,new URI(aaf_url)); + for (Item item = loc.first(); item!=null; item=loc.next(item)) { + System.out.println(loc.get(item)); + } + + hman = new HMangr(access,loc); + final String path = String.format("/authz/perms/user/%s", + access.getProperty(Config.AAF_APPID,"xx9999@people.osaaf.org")); + hman.best(si.defSS, new Retryable() { + @Override + public Void code(Rcli cli) throws APIException, CadiException { + Future ft = cli.read(path,"application/json"); + if (ft.get(10000)) { + System.out.println("Hurray,\n"+ft.body()); + } else { + System.out.println("not quite: " + ft.code()); + } + return null; + }}); + } finally { + if (hman!=null) { + hman.close(); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + } + }