Update AAF Version 1.0.0
[aaf/cadi.git] / client / src / test / java / org / onap / aaf / client / test / TestDME2Client.java
1 /*******************************************************************************\r
2  * ============LICENSE_START====================================================\r
3  * * org.onap.aaf\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
10  * * \r
11  *  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * * \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
19  * *\r
20  * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
21  * *\r
22  ******************************************************************************/\r
23 package org.onap.aaf.client.test;\r
24 \r
25 import java.io.FileInputStream;\r
26 import java.net.URI;\r
27 import java.util.Properties;\r
28 \r
29 import org.onap.aaf.cadi.Symm;\r
30 \r
31 import com.att.aft.dme2.api.DME2Client;\r
32 import com.att.aft.dme2.api.DME2Manager;\r
33 \r
34 public class TestDME2Client {\r
35         public static void main(String[] args) {\r
36                 try {\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
41                         \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
47                         \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
52 \r
53                         Symm symm;\r
54                         FileInputStream keyfile=new FileInputStream("/Volumes/Data/src/authz/common/keyfile");\r
55                         try {\r
56                                 symm=Symm.obtain(keyfile);\r
57                         } finally {\r
58                                 keyfile.close();\r
59                         }\r
60 \r
61                         DME2Manager dm = new DME2Manager("DME2Manager TestHClient",props);\r
62                                           // Standard RESOLVE format\r
63                         String prefix;\r
64                         URI uri = \r
65 //                                      new URI(\r
66 //                                        "https://DME2RESOLVE/service=com.att.authz.AuthorizationService/version=2.0/envContext=DEV/routeOffer=BAU_SE"\r
67 //                                      );\r
68 //                              prefix = "";\r
69 //                                 Direct Format\r
70 //                                 new URI("https://mithrilcsp.sbc.com:8100/service=com.att.authz.AuthorizationService/version=2.0/envContext=DEV/routeOffer=BAU_SE");\r
71 //                                 prefix = "";\r
72 //                                 Go through PROXY\r
73 //                                 new URI("https://mithrilcsp.sbc.com:8095");\r
74 //                                 prefix = "/proxy";\r
75                                         \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
78 //                                 prefix = "";\r
79                                    prefix = "/proxy";\r
80                         DME2Client client = new DME2Client(dm,uri,3000);\r
81 \r
82                         client.setCredentials("XX@NS", symm.depass("enc:???"));\r
83                         \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
88                         \r
89                         String o = client.sendAndWait(5000); // There are other Asynchronous call options, see DME2 Docs\r
90                         \r
91                         System.out.println('[' + o + ']' + " (blank is good)");\r
92                         \r
93                 } catch (Exception e) {\r
94                         e.printStackTrace();\r
95                 }\r
96         }\r
97         \r
98 }\r