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.io.FileInputStream;
\r
26 import java.net.URI;
\r
27 import java.util.Properties;
\r
29 import org.onap.aaf.cadi.Symm;
\r
31 import com.att.aft.dme2.api.DME2Client;
\r
32 import com.att.aft.dme2.api.DME2Manager;
\r
34 public class TestDME2Client {
\r
35 public static void main(String[] args) {
\r
37 Properties props = System.getProperties();
\r
38 props.put("AFT_LATITUDE","32.780140");
\r
39 props.put("AFT_LONGITUDE","-96.800451");
\r
40 props.put("AFT_ENVIRONMENT","AFTUAT");
\r
42 //props.put("keyStore","/Volumes/Data/src/authz/common/aaf.att.jks");
\r
43 props.put("AFT_DME2_KEYSTORE","/Volumes/Data/src/authz/common/aaf.att.jks");
\r
44 props.put("AFT_DME2_KEYSTORE_PASSWORD","enc:???");
\r
45 props.put("AFT_DME2_TRUSTSTORE","/Volumes/Data/src/authz/common/truststore.jks");
\r
46 props.put("AFT_DME2_TRUSTSTORE_PASSWORD","enc:???");
\r
48 // Local Testing on dynamic IP PC ***ONLY***
\r
49 // props.put("DME2_EP_REGISTRY_CLASS","DME2FS");
\r
50 // props.put("AFT_DME2_EP_REGISTRY_FS_DIR","/Volumes/Data/src/authz/dme2reg");
\r
51 // props.put("AFT_DME2_SSL_TRUST_ALL", "true");
\r
54 FileInputStream keyfile=new FileInputStream("/Volumes/Data/src/authz/common/keyfile");
\r
56 symm=Symm.obtain(keyfile);
\r
61 DME2Manager dm = new DME2Manager("DME2Manager TestHClient",props);
\r
62 // Standard RESOLVE format
\r
66 // "https://DME2RESOLVE/service=com.att.authz.AuthorizationService/version=2.0/envContext=DEV/routeOffer=BAU_SE"
\r
70 // new URI("https://mithrilcsp.sbc.com:8100/service=com.att.authz.AuthorizationService/version=2.0/envContext=DEV/routeOffer=BAU_SE");
\r
73 // new URI("https://mithrilcsp.sbc.com:8095");
\r
74 // prefix = "/proxy";
\r
76 // new URI("https://mithrilcsp.sbc.com:8095");
\r
77 new URI("https://DME2RESOLVE/service=com.att.authz.authz-gw/version=2.0/envContext=UAT/routeOffer=BAU_SE");
\r
80 DME2Client client = new DME2Client(dm,uri,3000);
\r
82 client.setCredentials("XX@NS", symm.depass("enc:???"));
\r
84 client.addHeader("Accept", "text/plain");
\r
85 client.setMethod("GET");
\r
86 client.setContext(prefix+"/authn/basicAuth");
\r
87 client.setPayload("");// Note: Even on "GET", you need a String in DME2
\r
89 String o = client.sendAndWait(5000); // There are other Asynchronous call options, see DME2 Docs
\r
91 System.out.println('[' + o + ']' + " (blank is good)");
\r
93 } catch (Exception e) {
\r
94 e.printStackTrace();
\r