1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.miloss.fgsms.presentation;
21
22 import java.io.File;
23 import java.io.IOException;
24 import java.net.MalformedURLException;
25 import java.net.URL;
26 import java.net.URLEncoder;
27 import java.util.ArrayList;
28 import java.util.List;
29 import java.util.Map;
30 import java.util.Properties;
31 import javax.servlet.ServletContext;
32 import javax.servlet.http.HttpServletRequest;
33 import javax.servlet.http.HttpServletResponse;
34 import javax.xml.ws.BindingProvider;
35 import javax.xml.ws.handler.Handler;
36 import org.apache.juddi.v3.client.UDDIService;
37 import org.miloss.fgsms.common.Constants.AuthMode;
38 import org.miloss.fgsms.common.Utility;
39 import org.miloss.fgsms.services.interfaces.agentcallbackservice.RemoteAgentCallbackPort;
40 import org.miloss.fgsms.services.interfaces.agentcallbackservice.RemoteAgentCallbackService;
41 import org.miloss.fgsms.services.interfaces.automatedreportingservice.AutomatedReportingService;
42 import org.miloss.fgsms.services.interfaces.automatedreportingservice.AutomatedReportingService_Service;
43 import org.miloss.fgsms.services.interfaces.dataaccessservice.DataAccessService;
44 import org.miloss.fgsms.services.interfaces.dataaccessservice.DataAccessService_Service;
45 import org.miloss.fgsms.services.interfaces.policyconfiguration.PCS;
46 import org.miloss.fgsms.services.interfaces.policyconfiguration.PolicyConfigurationService;
47 import org.miloss.fgsms.services.interfaces.reportingservice.ReportingService;
48 import org.miloss.fgsms.services.interfaces.reportingservice.ReportingService_Service;
49 import org.miloss.fgsms.services.interfaces.status.OpStatusService;
50 import org.miloss.fgsms.services.interfaces.status.StatusService;
51 import org.miloss.fgsms.services.interfaces.status.StatusServiceService;
52 import org.apache.log4j.Level;
53 import org.miloss.fgsms.common.Logger;;
54 import org.miloss.fgsms.common.Constants;
55
56
57
58
59
60
61
62
63
64 public class ProxyLoaderCXF implements IProxyLoader {
65
66 private URL propertiesFile = null;
67 static final Logger log = LogHelper.getLog();
68
69 public ProxyLoaderCXF(ServletContext application) throws MalformedURLException, IOException {
70
71 URL prop = application.getResource("/META-INF/config.properties");
72 p = Helper.loadForJSP(prop);
73 propertiesFile = prop;
74 authmode = AuthMode.valueOf(p.getProperty(FGSMS_AUTH_MODE));
75 String tmp = System.getProperty("jboss.server.config.url");
76 if (Utility.stringIsNullOrEmpty(tmp)) {
77
78 try {
79 tmp = System.getProperty("jboss.server.config.dir");
80 File f = new File(tmp);
81 tmp = f.toURI().toURL().toString();
82 tmp += File.separator;
83 } catch (Exception e) {
84 log.log(Level.DEBUG, null, e);
85 }
86 }
87 tmp = System.getenv("CATALINA_HOME");
88 if (!Utility.stringIsNullOrEmpty(tmp)) {
89
90 tmp = tmp + File.separator + "conf";
91
92 }
93 storelocation = tmp;
94 if (storelocation==null)
95 storelocation="";
96 }
97 private String storelocation = "";
98 private Properties p = null;
99
100 private AuthMode authmode = AuthMode.None;
101
102 @Override
103 public AuthMode getAuthmode() {
104 return authmode;
105 }
106
107 @Override
108 public boolean uddiConfigured() {
109 return p.containsKey(UDDIURL_INQUIRY);
110 }
111
112
113
114
115
116
117
118
119
120
121 @Override
122 public PCS GetPCSForUsernamePasswordLogin(ServletContext application, String username, String password) {
123 if (authmode != AuthMode.UsernamePassword) {
124 throw new IllegalArgumentException("authmode is not username/password");
125 }
126 try {
127 URL pcsurl2 = new URL(p.getProperty(POLICYCONFIG));
128
129 authmode = AuthMode.valueOf(p.getProperty(FGSMS_AUTH_MODE));
130
131 PolicyConfigurationService svc = new PolicyConfigurationService();
132 PCS p2 = svc.getPCSPort();
133 BindingProvider bpPCS1 = (BindingProvider) p2;
134 Map<String, Object> contextPCS = bpPCS1.getRequestContext();
135
136 contextPCS.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, pcsurl2.toString());
137 if (authmode == AuthMode.UsernamePassword) {
138
139 contextPCS.put(BindingProvider.USERNAME_PROPERTY, username);
140 contextPCS.put(BindingProvider.PASSWORD_PROPERTY, password);
141 }
142
143
144
145
146
147
148
149 return p2;
150 } catch (Exception ex) {
151 LogHelper.getLog().log(Level.ERROR, "error caught loading login proxy", ex);
152 }
153 return null;
154 }
155
156 @Override
157 public PCS GetPCS(ServletContext application, HttpServletRequest request, HttpServletResponse response) throws IOException {
158 URL pcsurl2 = null;
159 String usernameheader = "";
160 String passwordheader = "";
161
162 try {
163
164
165
166 pcsurl2 = new URL(p.getProperty(POLICYCONFIG));
167
168 authmode = AuthMode.valueOf(p.getProperty(FGSMS_AUTH_MODE));
169 if (authmode == AuthMode.UsernamePassword) {
170 if (Utility.stringIsNullOrEmpty((String) request.getSession().getAttribute("loginusername")) || Utility.stringIsNullOrEmpty((String) request.getSession().getAttribute("loginpassword"))) {
171 response.sendRedirect("login.jsp");
172 }
173 if (authmode == AuthMode.UsernamePassword) {
174 usernameheader = (String) request.getSession().getAttribute("loginusername");
175 passwordheader = (String) request.getSession().getAttribute("loginpassword");
176 }
177 }
178
179 PolicyConfigurationService svc = new PolicyConfigurationService();
180 PCS p2 = svc.getPCSPort();
181 BindingProvider bpPCS1 = (BindingProvider) p2;
182 Map<String, Object> contextPCS = bpPCS1.getRequestContext();
183 contextPCS.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, pcsurl2.toString());
184 if (authmode == AuthMode.UsernamePassword) {
185 contextPCS.put(BindingProvider.USERNAME_PROPERTY, usernameheader);
186 contextPCS.put(BindingProvider.PASSWORD_PROPERTY, Utility.DE(passwordheader));
187 }
188 if (pcsurl2.toString().toLowerCase().startsWith("https")) {
189 if (!Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLTRUST_STORE)) && !Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLTRUST_STORE_PASSWORD))) {
190 contextPCS.put(JAVAXNETSSLTRUST_STORE_PASSWORD, Utility.DE(p.getProperty(JAVAXNETSSLTRUST_STORE_PASSWORD)));
191 contextPCS.put(JAVAXNETSSLTRUST_STORE, storelocation + p.getProperty(JAVAXNETSSLTRUST_STORE));
192 }
193 }
194 if (authmode == AuthMode.PKI) {
195 List<Handler> currenthandlers = bpPCS1.getBinding().getHandlerChain();
196 if (currenthandlers == null) {
197 currenthandlers = new ArrayList<Handler>();
198 }
199 currenthandlers.add(new PKIHandler(request.getUserPrincipal()));
200 bpPCS1.getBinding().setHandlerChain(currenthandlers);
201
202 contextPCS.put(JAVAXNETSSLKEY_STORE_PASSWORD, Utility.DE(p.getProperty(JAVAXNETSSLKEY_STORE_PASSWORD)));
203 contextPCS.put(JAVAXNETSSLKEY_STORE, storelocation + p.getProperty(JAVAXNETSSLKEY_STORE));
204
205 }
206 return p2;
207 } catch (Exception ex) {
208 LogHelper.getLog().log(Level.ERROR, "error caught loading proxy", ex);
209 response.sendError(500);
210 }
211 return null;
212 }
213
214 @Override
215 public DataAccessService GetDAS(ServletContext application, HttpServletRequest request, HttpServletResponse response) throws IOException {
216 URL pcsurl2 = null;
217 String usernameheader = "";
218 String passwordheader = "";
219
220 try {
221
222
223
224 pcsurl2 = new URL(p.getProperty(DATAACCESS));
225
226 authmode = AuthMode.valueOf(p.getProperty(FGSMS_AUTH_MODE));
227 if (authmode == AuthMode.UsernamePassword) {
228 if (Utility.stringIsNullOrEmpty((String) request.getSession().getAttribute("loginusername")) || Utility.stringIsNullOrEmpty((String) request.getSession().getAttribute("loginpassword"))) {
229 response.sendRedirect("login.jsp");
230 }
231 if (authmode == AuthMode.UsernamePassword) {
232 usernameheader = (String) request.getSession().getAttribute("loginusername");
233 passwordheader = (String) request.getSession().getAttribute("loginpassword");
234 }
235 }
236
237 DataAccessService_Service svc = new DataAccessService_Service();
238 DataAccessService p2 = svc.getDASPort();
239 BindingProvider bpPCS1 = (BindingProvider) p2;
240 Map<String, Object> contextPCS = bpPCS1.getRequestContext();
241
242 contextPCS.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, pcsurl2.toString());
243 if (authmode == AuthMode.UsernamePassword) {
244
245 contextPCS.put(BindingProvider.USERNAME_PROPERTY, usernameheader);
246 contextPCS.put(BindingProvider.PASSWORD_PROPERTY, Utility.DE(passwordheader));
247 }
248 if (pcsurl2.toString().toLowerCase().startsWith("https")) {
249 if (!Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLTRUST_STORE)) && !Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLTRUST_STORE_PASSWORD))) {
250 contextPCS.put(JAVAXNETSSLTRUST_STORE_PASSWORD, Utility.DE(p.getProperty(JAVAXNETSSLTRUST_STORE_PASSWORD)));
251 contextPCS.put(JAVAXNETSSLTRUST_STORE, storelocation + p.getProperty(JAVAXNETSSLTRUST_STORE));
252 }
253 }
254
255 if (authmode == AuthMode.PKI) {
256 List<Handler> currenthandlers = bpPCS1.getBinding().getHandlerChain();
257 if (currenthandlers == null) {
258 currenthandlers = new ArrayList<Handler>();
259 }
260 currenthandlers.add(new PKIHandler(request.getUserPrincipal()));
261 bpPCS1.getBinding().setHandlerChain(currenthandlers);
262 contextPCS.put(JAVAXNETSSLKEY_STORE_PASSWORD, Utility.DE(p.getProperty(JAVAXNETSSLKEY_STORE_PASSWORD)));
263 contextPCS.put(JAVAXNETSSLKEY_STORE, storelocation + p.getProperty(JAVAXNETSSLKEY_STORE));
264 }
265 return p2;
266 } catch (Exception ex) {
267 LogHelper.getLog().log(Level.ERROR, "error caught loading proxy", ex);
268 response.sendError(500);
269 }
270 return null;
271 }
272
273 @Override
274 public ReportingService GetRS(ServletContext application, HttpServletRequest request, HttpServletResponse response) throws IOException {
275 URL pcsurl2 = null;
276 String usernameheader = "";
277 String passwordheader = "";
278
279 try {
280
281
282
283 pcsurl2 = new URL(p.getProperty(REPORTING));
284
285 authmode = AuthMode.valueOf(p.getProperty(FGSMS_AUTH_MODE));
286 if (authmode == AuthMode.UsernamePassword) {
287 if (Utility.stringIsNullOrEmpty((String) request.getSession().getAttribute("loginusername")) || Utility.stringIsNullOrEmpty((String) request.getSession().getAttribute("loginpassword"))) {
288 response.sendRedirect("login.jsp");
289 }
290 if (authmode == AuthMode.UsernamePassword) {
291 usernameheader = (String) request.getSession().getAttribute("loginusername");
292 passwordheader = (String) request.getSession().getAttribute("loginpassword");
293 }
294 }
295
296 ReportingService_Service svc = new ReportingService_Service();
297 ReportingService p2 = svc.getReportingServicePort();
298 BindingProvider bpPCS1 = (BindingProvider) p2;
299 Map<String, Object> contextPCS = bpPCS1.getRequestContext();
300
301 contextPCS.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, pcsurl2.toString());
302 if (authmode == AuthMode.UsernamePassword) {
303 contextPCS.put(BindingProvider.USERNAME_PROPERTY, usernameheader);
304 contextPCS.put(BindingProvider.PASSWORD_PROPERTY, Utility.DE(passwordheader));
305 }
306 if (pcsurl2.toString().toLowerCase().startsWith("https")) {
307 if (!Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLTRUST_STORE)) && !Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLTRUST_STORE_PASSWORD))) {
308 contextPCS.put(JAVAXNETSSLTRUST_STORE_PASSWORD, Utility.DE(p.getProperty(JAVAXNETSSLTRUST_STORE_PASSWORD)));
309 contextPCS.put(JAVAXNETSSLTRUST_STORE, storelocation + p.getProperty(JAVAXNETSSLTRUST_STORE));
310 }
311 }
312
313 if (authmode == AuthMode.PKI) {
314 List<Handler> currenthandlers = bpPCS1.getBinding().getHandlerChain();
315 if (currenthandlers == null) {
316 currenthandlers = new ArrayList<Handler>();
317 }
318 currenthandlers.add(new PKIHandler(request.getUserPrincipal()));
319 bpPCS1.getBinding().setHandlerChain(currenthandlers);
320 contextPCS.put(JAVAXNETSSLKEY_STORE_PASSWORD, Utility.DE(p.getProperty(JAVAXNETSSLKEY_STORE_PASSWORD)));
321 contextPCS.put(JAVAXNETSSLKEY_STORE, storelocation + p.getProperty(JAVAXNETSSLKEY_STORE));
322 }
323 return p2;
324 } catch (Exception ex) {
325 LogHelper.getLog().log(Level.ERROR, "error caught loading proxy", ex);
326 response.sendError(500);
327 }
328 return null;
329 }
330
331 @Override
332 public AutomatedReportingService GetARS(ServletContext application, HttpServletRequest request, HttpServletResponse response) throws IOException {
333 URL pcsurl2 = null;
334 String usernameheader = "";
335 String passwordheader = "";
336
337 try {
338
339
340
341 pcsurl2 = new URL(p.getProperty(ARS));
342
343 authmode = AuthMode.valueOf(p.getProperty(FGSMS_AUTH_MODE));
344 if (authmode == AuthMode.UsernamePassword) {
345 if (Utility.stringIsNullOrEmpty((String) request.getSession().getAttribute("loginusername")) || Utility.stringIsNullOrEmpty((String) request.getSession().getAttribute("loginpassword"))) {
346 response.sendRedirect("login.jsp");
347 }
348 if (authmode == AuthMode.UsernamePassword) {
349 usernameheader = (String) request.getSession().getAttribute("loginusername");
350 passwordheader = (String) request.getSession().getAttribute("loginpassword");
351 }
352 }
353
354 AutomatedReportingService_Service svc = new AutomatedReportingService_Service();
355 AutomatedReportingService p2 = svc.getAutomatedReportingServicePort();
356 BindingProvider bpPCS1 = (BindingProvider) p2;
357 Map<String, Object> contextPCS = bpPCS1.getRequestContext();
358
359 contextPCS.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, pcsurl2.toString());
360 if (authmode == AuthMode.UsernamePassword) {
361
362 contextPCS.put(BindingProvider.USERNAME_PROPERTY, usernameheader);
363 contextPCS.put(BindingProvider.PASSWORD_PROPERTY, Utility.DE(passwordheader));
364 }
365 if (pcsurl2.toString().toLowerCase().startsWith("https")) {
366 if (!Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLTRUST_STORE)) && !Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLTRUST_STORE_PASSWORD))) {
367 contextPCS.put(JAVAXNETSSLTRUST_STORE_PASSWORD, Utility.DE(p.getProperty(JAVAXNETSSLTRUST_STORE_PASSWORD)));
368 contextPCS.put(JAVAXNETSSLTRUST_STORE, storelocation + p.getProperty(JAVAXNETSSLTRUST_STORE));
369 }
370 }
371
372 if (authmode == AuthMode.PKI) {
373 List<Handler> currenthandlers = bpPCS1.getBinding().getHandlerChain();
374 if (currenthandlers == null) {
375 currenthandlers = new ArrayList<Handler>();
376 }
377 currenthandlers.add(new PKIHandler(request.getUserPrincipal()));
378 bpPCS1.getBinding().setHandlerChain(currenthandlers);
379 contextPCS.put(JAVAXNETSSLKEY_STORE_PASSWORD, Utility.DE(p.getProperty(JAVAXNETSSLKEY_STORE_PASSWORD)));
380 contextPCS.put(JAVAXNETSSLKEY_STORE, storelocation + p.getProperty(JAVAXNETSSLKEY_STORE));
381 }
382 return p2;
383 } catch (Exception ex) {
384 LogHelper.getLog().log(Level.ERROR, "error caught loading proxy", ex);
385 response.sendError(500);
386 }
387 return null;
388 }
389
390 @Override
391 public StatusService GetSS(ServletContext application, HttpServletRequest request, HttpServletResponse response) throws IOException {
392 URL pcsurl2 = null;
393 String usernameheader = "";
394 String passwordheader = "";
395
396 try {
397
398
399
400 pcsurl2 = new URL(p.getProperty(STATUS));
401
402 authmode = AuthMode.valueOf(p.getProperty(FGSMS_AUTH_MODE));
403 if (authmode == AuthMode.UsernamePassword) {
404 if (Utility.stringIsNullOrEmpty((String) request.getSession().getAttribute("loginusername")) || Utility.stringIsNullOrEmpty((String) request.getSession().getAttribute("loginpassword"))) {
405 response.sendRedirect("login.jsp");
406 }
407 if (authmode == AuthMode.UsernamePassword) {
408 usernameheader = (String) request.getSession().getAttribute("loginusername");
409 passwordheader = (String) request.getSession().getAttribute("loginpassword");
410 }
411 }
412
413 StatusServiceService svc = new StatusServiceService();
414 StatusService p2 = svc.getStatusServicePort();
415 BindingProvider bpPCS1 = (BindingProvider) p2;
416 Map<String, Object> contextPCS = bpPCS1.getRequestContext();
417 contextPCS.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, pcsurl2.toString());
418 if (authmode == AuthMode.UsernamePassword) {
419 contextPCS.put(BindingProvider.USERNAME_PROPERTY, usernameheader);
420 contextPCS.put(BindingProvider.PASSWORD_PROPERTY, Utility.DE(passwordheader));
421 }
422 if (pcsurl2.toString().toLowerCase().startsWith("https")) {
423 if (!Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLTRUST_STORE)) && !Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLTRUST_STORE_PASSWORD))) {
424 contextPCS.put(JAVAXNETSSLTRUST_STORE_PASSWORD, Utility.DE(p.getProperty(JAVAXNETSSLTRUST_STORE_PASSWORD)));
425 contextPCS.put(JAVAXNETSSLTRUST_STORE, storelocation + p.getProperty(JAVAXNETSSLTRUST_STORE));
426 }
427 }
428 if (authmode == AuthMode.PKI) {
429 List<Handler> currenthandlers = bpPCS1.getBinding().getHandlerChain();
430 if (currenthandlers == null) {
431 currenthandlers = new ArrayList<Handler>();
432 }
433 currenthandlers.add(new PKIHandler(request.getUserPrincipal()));
434 bpPCS1.getBinding().setHandlerChain(currenthandlers);
435 contextPCS.put(JAVAXNETSSLKEY_STORE_PASSWORD, Utility.DE(p.getProperty(JAVAXNETSSLKEY_STORE_PASSWORD)));
436 contextPCS.put(JAVAXNETSSLKEY_STORE, storelocation + p.getProperty(JAVAXNETSSLKEY_STORE));
437 }
438 return p2;
439 } catch (Exception ex) {
440 LogHelper.getLog().log(Level.ERROR, "error caught loading proxy", ex);
441 response.sendError(500);
442 }
443 return null;
444 }
445
446 @Override
447 public UDDIConfig GetUDDIInquiryConfig(ServletContext application, HttpServletRequest request, HttpServletResponse response) throws IOException {
448 UDDIConfig config = new UDDIConfig();
449 String usernameheader = "";
450 String passwordheader = "";
451
452 if (Utility.stringIsNullOrEmpty(p.getProperty(UDDIURL_INQUIRY))) {
453 return null;
454 }
455 try {
456
457
458
459 config.secendpoint = p.getProperty(UDDIURL_SECURITY);
460 config.inquiryendpoint = p.getProperty(UDDIURL_INQUIRY);
461 config.publishendpoint = p.getProperty(UDDIURL_PUBLISH);
462 authmode = AuthMode.valueOf(p.getProperty(FGSMS_AUTH_MODE));
463 if (authmode == AuthMode.UsernamePassword) {
464 if (Utility.stringIsNullOrEmpty((String) request.getSession().getAttribute("loginusername")) || Utility.stringIsNullOrEmpty((String) request.getSession().getAttribute("loginpassword"))) {
465 response.sendRedirect("login.jsp");
466 }
467 if (authmode == AuthMode.UsernamePassword) {
468 usernameheader = (String) request.getSession().getAttribute("loginusername");
469 passwordheader = (String) request.getSession().getAttribute("loginpassword");
470 }
471 }
472
473 String t = p.getProperty(UDDIUSE_HTTP_CLIENT_CERT);
474 if (!Utility.stringIsNullOrEmpty(t)) {
475 try {
476 config.useHTTPClientCert = Boolean.parseBoolean(t);
477 } catch (Exception ex) {
478 config.useHTTPClientCert = false;
479 }
480 }
481 t = p.getProperty(UDDIUSE_UDDI_USERNAME_PASSWORD);
482 if (!Utility.stringIsNullOrEmpty(t)) {
483 try {
484 config.useUDDI = Boolean.parseBoolean(t);
485 } catch (Exception ex) {
486 config.useUDDI = false;
487 }
488 }
489 t = p.getProperty(UDDIUSE_HTTP_USERNAME_PASSWORD);
490 if (!Utility.stringIsNullOrEmpty(t)) {
491 try {
492 config.useHTTPUsernamePassword = Boolean.parseBoolean(t);
493 } catch (Exception ex) {
494 config.useHTTPUsernamePassword = false;
495 }
496 }
497
498 UDDIService uddi = new UDDIService();
499
500 config.inquiry = uddi.getUDDIInquiryPort();
501 BindingProvider bpPCS1 = (BindingProvider) config.inquiry;
502 Map<String, Object> contextPCS = bpPCS1.getRequestContext();
503
504 contextPCS.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, config.inquiryendpoint);
505
506 if (config.inquiryendpoint.toLowerCase().startsWith("https")) {
507 if (!Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLTRUST_STORE)) && !Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLTRUST_STORE_PASSWORD))) {
508 contextPCS.put(JAVAXNETSSLTRUST_STORE_PASSWORD, Utility.DE(p.getProperty(JAVAXNETSSLTRUST_STORE_PASSWORD)));
509 contextPCS.put(JAVAXNETSSLTRUST_STORE, storelocation + p.getProperty(JAVAXNETSSLTRUST_STORE));
510 }
511
512 if (config.useHTTPClientCert) {
513 if (!Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLKEY_STORE_PASSWORD)) && !Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLKEY_STORE))) {
514 contextPCS.put(JAVAXNETSSLKEY_STORE_PASSWORD, Utility.DE(p.getProperty(JAVAXNETSSLKEY_STORE_PASSWORD)));
515 contextPCS.put(JAVAXNETSSLKEY_STORE, storelocation + p.getProperty(JAVAXNETSSLKEY_STORE));
516 } else {
517 LogHelper.getLog().log(Level.ERROR, "presentation uddi config is set for client certificates, however one was not defined in the config file");
518 }
519 }
520 }
521 if (config.useHTTPUsernamePassword) {
522 contextPCS.put(BindingProvider.USERNAME_PROPERTY, usernameheader);
523 contextPCS.put(BindingProvider.PASSWORD_PROPERTY, Utility.DE(passwordheader));
524 }
525
526
527 if (!Utility.stringIsNullOrEmpty(config.publishendpoint)) {
528
529 config.publish = uddi.getUDDIPublicationPort();
530 bpPCS1 = (BindingProvider) config.publish;
531 contextPCS = bpPCS1.getRequestContext();
532
533 contextPCS.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, config.publishendpoint);
534
535 if (config.publishendpoint.toLowerCase().startsWith("https")) {
536 if (!Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLTRUST_STORE)) && !Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLTRUST_STORE_PASSWORD))) {
537 contextPCS.put(JAVAXNETSSLTRUST_STORE_PASSWORD, Utility.DE(p.getProperty(JAVAXNETSSLTRUST_STORE_PASSWORD)));
538 contextPCS.put(JAVAXNETSSLTRUST_STORE, storelocation + p.getProperty(JAVAXNETSSLTRUST_STORE));
539 }
540
541 if (config.useHTTPClientCert) {
542 if (!Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLKEY_STORE_PASSWORD)) && !Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLKEY_STORE))) {
543 contextPCS.put(JAVAXNETSSLKEY_STORE_PASSWORD, Utility.DE(p.getProperty(JAVAXNETSSLKEY_STORE_PASSWORD)));
544 contextPCS.put(JAVAXNETSSLKEY_STORE, storelocation + p.getProperty(JAVAXNETSSLKEY_STORE));
545 } else {
546 LogHelper.getLog().log(Level.ERROR, "presentation uddi config is set for client certificates, however one was not defined in the config file");
547 }
548 }
549 }
550 if (config.useHTTPUsernamePassword) {
551 contextPCS.put(BindingProvider.USERNAME_PROPERTY, usernameheader);
552 contextPCS.put(BindingProvider.PASSWORD_PROPERTY, Utility.DE(passwordheader));
553 }
554 }
555
556
557 if (config.useUDDI) {
558 config.encryptedPassword = passwordheader;
559 config.username = usernameheader;
560
561 config.security = uddi.getUDDISecurityPort();
562 bpPCS1 = (BindingProvider) config.security;
563 contextPCS = bpPCS1.getRequestContext();
564 contextPCS.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, config.secendpoint);
565 if (config.secendpoint.toLowerCase().startsWith("https")) {
566 if (!Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLTRUST_STORE)) && !Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLTRUST_STORE_PASSWORD))) {
567 contextPCS.put(JAVAXNETSSLTRUST_STORE_PASSWORD, Utility.DE(p.getProperty(JAVAXNETSSLTRUST_STORE_PASSWORD)));
568 contextPCS.put(JAVAXNETSSLTRUST_STORE, storelocation + p.getProperty(JAVAXNETSSLTRUST_STORE));
569 }
570
571 if (config.useHTTPClientCert) {
572 if (!Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLKEY_STORE_PASSWORD)) && !Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLKEY_STORE))) {
573 contextPCS.put(JAVAXNETSSLKEY_STORE_PASSWORD, Utility.DE(p.getProperty(JAVAXNETSSLKEY_STORE_PASSWORD)));
574 contextPCS.put(JAVAXNETSSLKEY_STORE, storelocation + p.getProperty(JAVAXNETSSLKEY_STORE));
575 } else {
576 LogHelper.getLog().log(Level.ERROR, "presentation uddi config is set for client certificates, however one was not defined in the config file");
577 }
578 }
579 }
580 }
581 return config;
582
583 } catch (Exception ex) {
584 LogHelper.getLog().log(Level.ERROR, "error caught loading proxy", ex);
585 response.sendError(500);
586 }
587
588 return null;
589 }
590
591
592 @Override
593 public String getKeyStoreTrustStoreDirectory() {
594 return storelocation;
595 }
596
597 @Override
598 public Properties getRawConfiguration() {
599 return p;
600 }
601
602 @Override
603 public URL getRawConfigurationURL() {
604 return propertiesFile;
605 }
606
607 @Override
608 public OpStatusService GetOpStat(ServletContext application, HttpServletRequest request, HttpServletResponse response) throws IOException {
609 URL pcsurl2 = null;
610 String usernameheader = "";
611 String passwordheader = "";
612
613 try {
614
615
616
617 pcsurl2 = new URL(p.getProperty(STATUS));
618
619 authmode = AuthMode.valueOf(p.getProperty(FGSMS_AUTH_MODE));
620 if (authmode == AuthMode.UsernamePassword) {
621 if (Utility.stringIsNullOrEmpty((String) request.getSession().getAttribute("loginusername")) || Utility.stringIsNullOrEmpty((String) request.getSession().getAttribute("loginpassword"))) {
622 response.sendRedirect("login.jsp");
623 }
624 if (authmode == AuthMode.UsernamePassword) {
625 usernameheader = (String) request.getSession().getAttribute("loginusername");
626 passwordheader = (String) request.getSession().getAttribute("loginpassword");
627 }
628 }
629
630 StatusServiceService svc = new StatusServiceService();
631 OpStatusService p2 = svc.getOpStatusServiceBinding();
632 BindingProvider bpPCS1 = (BindingProvider) p2;
633 Map<String, Object> contextPCS = bpPCS1.getRequestContext();
634 contextPCS.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, pcsurl2.toString());
635 if (authmode == AuthMode.UsernamePassword) {
636 contextPCS.put(BindingProvider.USERNAME_PROPERTY, usernameheader);
637 contextPCS.put(BindingProvider.PASSWORD_PROPERTY, Utility.DE(passwordheader));
638 }
639 if (pcsurl2.toString().toLowerCase().startsWith("https")) {
640 if (!Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLTRUST_STORE)) && !Utility.stringIsNullOrEmpty(p.getProperty(JAVAXNETSSLTRUST_STORE_PASSWORD))) {
641 contextPCS.put(JAVAXNETSSLTRUST_STORE_PASSWORD, Utility.DE(p.getProperty(JAVAXNETSSLTRUST_STORE_PASSWORD)));
642 contextPCS.put(JAVAXNETSSLTRUST_STORE, storelocation + p.getProperty(JAVAXNETSSLTRUST_STORE));
643 }
644 }
645 if (authmode == AuthMode.PKI) {
646 List<Handler> currenthandlers = bpPCS1.getBinding().getHandlerChain();
647 if (currenthandlers == null) {
648 currenthandlers = new ArrayList<Handler>();
649 }
650 currenthandlers.add(new PKIHandler(request.getUserPrincipal()));
651 bpPCS1.getBinding().setHandlerChain(currenthandlers);
652 contextPCS.put(JAVAXNETSSLKEY_STORE_PASSWORD, Utility.DE(p.getProperty(JAVAXNETSSLKEY_STORE_PASSWORD)));
653 contextPCS.put(JAVAXNETSSLKEY_STORE, storelocation + p.getProperty(JAVAXNETSSLKEY_STORE));
654 }
655 return p2;
656 } catch (Exception ex) {
657 LogHelper.getLog().log(Level.ERROR, "error caught loading proxy", ex);
658 response.sendError(500);
659 }
660 return null;
661 }
662
663 @Override
664 public RemoteAgentCallbackPort GetAgentCallBack(ServletContext application, HttpServletRequest request, HttpServletResponse response) throws IOException {
665
666 return null;
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720 }
721
722 @Override
723 public OpStatusService GetAgentCallBackOpStat(ServletContext application, HttpServletRequest request, HttpServletResponse response) throws IOException {
724 return null;
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777 }
778
779 @Override
780 public boolean isSecure() {
781 if (!((String) p.get(REPORTING)).toLowerCase().startsWith("https")) {
782 return false;
783 }
784 if (!((String) p.get(DATAACCESS)).toLowerCase().startsWith("https")) {
785 return false;
786 }
787 if (!((String) p.get(POLICYCONFIG)).toLowerCase().startsWith("https")) {
788 return false;
789 }
790 if (!((String) p.get(STATUS)).toLowerCase().startsWith("https")) {
791 return false;
792 }
793 if (!((String) p.get(ARS)).toLowerCase().startsWith("https")) {
794 return false;
795 }
796 if (!((String) p.get(DCS)).toLowerCase().startsWith("https")) {
797 return false;
798 }
799 return true;
800 }
801 }