1 /*******************************************************************************
\r
2 * ============LICENSE_START====================================================
\r
4 * * ===========================================================================
\r
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * * ===========================================================================
\r
7 * * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * * you may not use this file except in compliance with the License.
\r
9 * * You may obtain a copy of the License at
\r
11 * * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * * Unless required by applicable law or agreed to in writing, software
\r
14 * * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * * See the License for the specific language governing permissions and
\r
17 * * limitations under the License.
\r
18 * * ============LICENSE_END====================================================
\r
20 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
\r
22 ******************************************************************************/
\r
23 package org.onap.aaf.client.test;
\r
25 import java.net.HttpURLConnection;
\r
26 import java.net.URI;
\r
27 import java.util.Properties;
\r
29 import org.onap.aaf.cadi.CadiException;
\r
30 import org.onap.aaf.cadi.Locator;
\r
31 import org.onap.aaf.cadi.PropAccess;
\r
32 import org.onap.aaf.cadi.SecuritySetter;
\r
33 import org.onap.aaf.cadi.Locator.Item;
\r
34 import org.onap.aaf.cadi.client.Future;
\r
35 import org.onap.aaf.cadi.client.Rcli;
\r
36 import org.onap.aaf.cadi.client.Retryable;
\r
37 import org.onap.aaf.cadi.config.Config;
\r
38 import org.onap.aaf.cadi.config.SecurityInfoC;
\r
39 import org.onap.aaf.cadi.http.HBasicAuthSS;
\r
40 import org.onap.aaf.cadi.http.HMangr;
\r
41 import org.onap.aaf.cadi.locator.DME2Locator;
\r
43 import com.att.aft.dme2.api.DME2Manager;
\r
44 import org.onap.aaf.inno.env.APIException;
\r
46 public class TestHClient {
\r
47 public static void main(String[] args) {
\r
49 PropAccess access = new PropAccess();
\r
50 DME2Manager dm = new DME2Manager("DME2Manager TestHClient",access.getProperties());
\r
51 Locator<URI> loc = new DME2Locator(access,dm,"com.att.authz.AuthorizationService","2.0","DEV","BAU_SE");
\r
53 for(Item item = loc.first(); item!=null; item=loc.next(item)) {
\r
54 System.out.println(loc.get(item));
\r
58 SecurityInfoC<HttpURLConnection> si = new SecurityInfoC<HttpURLConnection>(access);
\r
59 SecuritySetter<HttpURLConnection> ss = new HBasicAuthSS("m12345@aaf.att.com",
\r
60 access.decrypt("enc:7K6yjLQqha_S9yApkIul2K_by5Moemcos1HRAVnhMXu",false), si);
\r
61 // SecuritySetter<HttpURLConnection> ss = new X509SS(si, "aaf");
\r
63 HMangr hman = new HMangr(access,loc);
\r
65 hman.best(ss, new Retryable<Void>() {
\r
67 public Void code(Rcli<?> cli) throws APIException, CadiException {
\r
68 Future<String> ft = cli.read("/authz/nss/com.att.aaf","text/json");
\r
70 System.out.println("Hurray,\n"+ft.body());
\r
72 System.out.println("not quite: " + ft.code());
\r
79 } catch (Exception e) {
\r
80 e.printStackTrace();
\r