This project has retired. For details please refer to its Attic page.
EntryPoint xref
View Javadoc
1   /*
2    * Copyright 2014 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.juddi.v3.client.cli;
17  
18  import java.io.File;
19  import org.apache.juddi.v3.client.config.UDDIClient;
20  import org.apache.juddi.v3.client.config.UDDINode;
21  
22  /**
23   *
24   * @author Alex O'Ree
25   */
26  public class EntryPoint {
27  
28          public static void main(String[] args) throws Exception {
29  
30                  if (System.getProperty("javax.net.ssl.trustStore") == null) {
31                          File f = new File("../../juddi-tomcat/truststore.jks");
32                          if (f.exists()) {
33                                  System.setProperty("javax.net.ssl.trustStore", f.getAbsolutePath());
34  
35                          } else {
36                                  f = new File("../juddi-tomcat/truststore.jks");
37                                  if (f.exists()) {
38                                          System.setProperty("javax.net.ssl.trustStore", f.getAbsolutePath());
39  
40                                  } else {
41                                          f = new File("./juddi-tomcat/truststore.jks");
42                                          if (f.exists()) {
43                                                  System.setProperty("javax.net.ssl.trustStore", f.getAbsolutePath());
44  
45                                          }
46                                  }
47                          }
48  
49                          System.setProperty("javax.net.ssl.trustStorePassword", "password");
50                          //System.setProperty("javax.net.ssl.keyStore", "keystore.jks");
51  
52                          //System.setProperty("javax.net.ssl.keyStorePassword", "changeit");
53                  }
54                  //set up trust store
55  
56                  String trustStore = System.getProperty("javax.net.ssl.trustStore");
57                  if (trustStore == null) {
58                          System.out.println("javax.net.ssl.trustStore is not defined");
59                  } else {
60                          System.out.println("javax.net.ssl.trustStore = " + trustStore);
61                  }
62  
63                  if (System.getProperty("javax.net.ssl.keyStore") == null) {
64                          File f = new File("../../juddi-tomcat/keystore.jks");
65                          if (f.exists()) {
66                                  System.setProperty("javax.net.ssl.keyStore", f.getAbsolutePath());
67  
68                          } else {
69                                  f = new File("../juddi-tomcat/keyStore.jks");
70                                  if (f.exists()) {
71                                          System.setProperty("javax.net.ssl.keyStore", f.getAbsolutePath());
72  
73                                  } else {
74                                          f = new File("./juddi-tomcat/keystore.jks");
75                                          if (f.exists()) {
76                                                  System.setProperty("javax.net.ssl.keyStore", f.getAbsolutePath());
77  
78                                          }
79                                  }
80                          }
81  
82                          System.setProperty("javax.net.ssl.keyStorePassword", "password");
83                          //System.setProperty("javax.net.ssl.keyStore", "keystore.jks");
84  
85                          //System.setProperty("javax.net.ssl.keyStorePassword", "changeit");
86                  }
87                  //set up trust store
88  
89                  String keyStore = System.getProperty("javax.net.ssl.trustStore");
90                  if (keyStore == null) {
91                          System.out.println("javax.net.ssl.keyStore is not defined");
92                  } else {
93                          System.out.println("javax.net.ssl.keyStore = " + trustStore);
94                  }
95                  //first menu
96                  //connect to a node and do work on it
97                  //multinode 
98                  String input = null;
99                  do {
100                         System.out.println("____________________________");
101                         System.out.println("jUDDI Interactive Command Line Interface");
102                         System.out.println("____________________________");
103                         System.out.println(" 1) Connect and login to a Node");
104                         System.out.println(" 2) Multinode and Replication commands");
105                         System.out.println(" 3) Offline code examples");
106                         System.out.println("- [ jUDDI Client (this app) configuration ] -");
107                         //local config management
108                         System.out.println(" 4) Quick add the jUDDI cloud node to *this's configuration file");
109                         System.out.println(" 5) Add a node to *this's configuration file");
110                         System.out.println(" 6) View all registered nodes for this client");
111                         System.out.println(" q) Quit/exit");
112                         System.out.print("jUDDI Main# ");
113                         input = System.console().readLine();
114                         if ("1".equals(input)) {
115                                 goSingleNode();
116                         } else if ("2".equals(input)) {
117                                 goMultiNode();
118                         } else if ("3".equals(input)) {
119                                 goOfflineExamples();
120                         }  else if (input.equals("4")) {
121                                 //System.out.println("31) Quick add the jUDDI cloud node to *this's configuration file");
122                                 new JuddiAdminService(new UDDIClient(), null).quickRegisterLocalCloud();
123                         } else if (input.equals("5")) {
124                                 // System.out.println("32) Add a node to *this's configuration file");
125                                 UDDIClient clerkManager = new UDDIClient();
126                                 UDDINode node = new UDDINode();
127                                 System.out.print("Name (must be unique: ");
128                                 node.setClientName(System.console().readLine());
129                                 node.setName(node.getClientName());
130                                 System.out.print("Description: ");
131                                 node.setDescription(System.console().readLine());
132 
133                                 node.setHomeJUDDI(false);
134                                 System.out.print("Inquiry URL: ");
135                                 node.setInquiryUrl(System.console().readLine());
136 
137                                 System.out.print("Inquiry REST URL (optional): ");
138                                 node.setInquiryRESTUrl(System.console().readLine());
139 
140                                 System.out.print("jUDDI API URL (optional): ");
141                                 node.setJuddiApiUrl(System.console().readLine());
142                                 System.out.print("Custody Transfer URL: ");
143                                 node.setCustodyTransferUrl(System.console().readLine());
144                                 System.out.print("Publish URL: ");
145                                 node.setPublishUrl(System.console().readLine());
146                                 System.out.print("Replication URL: ");
147                                 node.setReplicationUrl(System.console().readLine());
148                                 System.out.print("Security URL: ");
149                                 node.setSecurityUrl(System.console().readLine());
150                                 System.out.print("Subscription URL: ");
151                                 node.setSubscriptionUrl(System.console().readLine());
152 
153                                 System.out.print("Subscription Listener URL: ");
154                                 node.setSubscriptionListenerUrl(System.console().readLine());
155 
156                                 System.out.print("Transport (defaults to JAXWS): ");
157                                 node.setProxyTransport(System.console().readLine());
158                                 if (node.getProxyTransport() == null || node.getProxyTransport().trim().equalsIgnoreCase("")) {
159                                         node.setProxyTransport(org.apache.juddi.v3.client.transport.JAXWSTransport.class.getCanonicalName());
160                                 }
161                                 System.out.print("Factory Initial (optional): ");
162                                 node.setFactoryInitial(System.console().readLine());
163                                 System.out.print("Factory Naming Provider (optional): ");
164                                 node.setFactoryNamingProvider(System.console().readLine());
165                                 System.out.print("Factory URL Packages (optional): ");
166                                 node.setFactoryURLPkgs(System.console().readLine());
167 
168                                 clerkManager.getClientConfig().addUDDINode(node);
169                                 clerkManager.getClientConfig().saveConfig();
170                                 System.out.println("Saved.");
171                         }
172                 } while (!"q".equalsIgnoreCase(input));
173         }
174 
175         static void goMultiNode() throws Exception {
176                 EntryPoitMultiNode.goMultiNode();
177         }
178 
179         static void goSingleNode() throws Exception {
180                 EntryPointSingleNode.goSingleNode();
181 
182         }
183 
184         private static void goOfflineExamples() throws Exception {
185                 String input = null;
186                 do {
187                         System.out.println("____________________________");
188                         System.out.println("Offline/Code Examples (you'll want to look at the source for some of these");
189                         System.out.println("____________________________");
190                         System.out.println(" 1) Compare Two Binding/tModelInstanceInfo - QOS Code Example");
191                         System.out.println("2) Digitally sign a UDDI entity from a file.");
192                         System.out.println(" q) Quit/exit");
193                         System.out.print("#");
194                         input = System.console().readLine();
195                         processOffline(input);
196                 } while (!"q".equalsIgnoreCase(input));
197 
198         }
199 
200         private static void processOffline(String input) throws Exception {
201                 if (input.equals("1")) {
202                         CompareByTModelInstanceInfoQOS.main(new String[0]);
203                 }
204                 if (input.equals("2")) {
205                         new UddiDigitalSignatureFile().fire(null, null, null);
206                 }
207         }
208 
209 }