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;
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<HttpURLConnection> si = SecurityInfoC.instance(access, HttpURLConnection.class);
- AbsAAFLocator<BasicTrans> 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<HttpURLConnection> ss = new HBasicAuthSS(si);
- // SecuritySetter<HttpURLConnection> 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<Void>() {
- @Override
- public Void code(Rcli<?> cli) throws APIException, CadiException {
- Future<String> 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<HttpURLConnection> si = SecurityInfoC.instance(access, HttpURLConnection.class);
+ AbsAAFLocator<BasicTrans> 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<Void>() {
+ @Override
+ public Void code(Rcli<?> cli) throws APIException, CadiException {
+ Future<String> 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();
+ }
+ }
+
}