2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
22 package org.onap.aaf.cadi.aaf.test;
24 import java.net.HttpURLConnection;
27 import org.onap.aaf.cadi.Access.Level;
28 import org.onap.aaf.cadi.CadiException;
29 import org.onap.aaf.cadi.Locator.Item;
30 import org.onap.aaf.cadi.PropAccess;
31 import org.onap.aaf.cadi.aaf.v2_0.AAFLocator;
32 import org.onap.aaf.cadi.aaf.v2_0.AbsAAFLocator;
33 import org.onap.aaf.cadi.client.Future;
34 import org.onap.aaf.cadi.client.Rcli;
35 import org.onap.aaf.cadi.client.Retryable;
36 import org.onap.aaf.cadi.config.Config;
37 import org.onap.aaf.cadi.config.SecurityInfoC;
38 import org.onap.aaf.cadi.http.HMangr;
39 import org.onap.aaf.misc.env.APIException;
40 import org.onap.aaf.misc.env.impl.BasicTrans;
42 public class TestHClient {
43 public static void main(String[] args) {
45 PropAccess access = new PropAccess(args);
46 String aaf_url = access.getProperty(Config.AAF_URL);
47 if (aaf_url == null) {
48 access.log(Level.ERROR, Config.AAF_URL," is required");
52 SecurityInfoC<HttpURLConnection> si = SecurityInfoC.instance(access, HttpURLConnection.class);
53 AbsAAFLocator<BasicTrans> loc = new AAFLocator(si,new URI(aaf_url));
54 for (Item item = loc.first(); item!=null; item=loc.next(item)) {
55 System.out.println(loc.get(item));
58 hman = new HMangr(access,loc);
59 final String path = String.format("/authz/perms/user/%s",
60 access.getProperty(Config.AAF_APPID,"xx9999@people.osaaf.org"));
61 hman.best(si.defSS, new Retryable<Void>() {
63 public Void code(Rcli<?> cli) throws APIException, CadiException {
64 Future<String> ft = cli.read(path,"application/json");
66 System.out.println("Hurray,\n"+ft.body());
68 System.out.println("not quite: " + ft.code());
78 } catch (Exception e) {