1 /*******************************************************************************
2 * ============LICENSE_START==================================================
4 * * ===========================================================================
5 * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6 * * ===========================================================================
7 * * Licensed under the Apache License, Version 2.0 (the "License");
8 * * you may not use this file except in compliance with the License.
9 * * You may obtain a copy of the License at
11 * * http://www.apache.org/licenses/LICENSE-2.0
13 * * Unless required by applicable law or agreed to in writing, software
14 * * distributed under the License is distributed on an "AS IS" BASIS,
15 * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * * See the License for the specific language governing permissions and
17 * * limitations under the License.
18 * * ============LICENSE_END====================================================
20 * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 ******************************************************************************/
25 import org.eclipse.jetty.http.HttpVersion;
26 import org.eclipse.jetty.servlet.*;
27 import org.eclipse.jetty.util.ssl.*;
28 import org.eclipse.jetty.server.*;
29 import org.apache.log4j.Logger;
32 * Example stand alone subscriber
34 public class SSASubscriber {
35 private static final int Port = 8447;
36 private static final String KeyStoreType = "jks";
37 private static final String KeyStoreFile = "/root/sub/subscriber.jks";
38 //private static final String KeyStoreFile = "c:/tmp/subscriber.jks";
39 private static final String KeyStorePassword = "changeit";
40 private static final String KeyPassword = "changeit";
41 private static final String ContextPath = "/";
42 private static final String URLPattern = "/*";
44 public static void main(String[] args) throws Exception {
45 //User story # US792630 -Jetty Upgrade to 9.3.11
46 //SSASubscriber register Jetty server.
47 Server server = new Server();
48 HttpConfiguration http_config = new HttpConfiguration();
49 http_config.setSecureScheme("https");
50 http_config.setSecurePort(Port);
51 http_config.setRequestHeaderSize(8192);
54 ServerConnector http = new ServerConnector(server,
55 new HttpConnectionFactory(http_config));
57 http.setIdleTimeout(30000);
59 // SSL Context Factory
60 SslContextFactory sslContextFactory = new SslContextFactory();
61 sslContextFactory.setKeyStoreType(KeyStoreType);
62 sslContextFactory.setKeyStorePath(KeyStoreFile);
63 sslContextFactory.setKeyStorePassword(KeyStorePassword);
64 sslContextFactory.setKeyManagerPassword(KeyPassword);
66 // sslContextFactory.setTrustStorePath(ncm.getKSFile());
67 // sslContextFactory.setTrustStorePassword("changeit");
68 sslContextFactory.setExcludeCipherSuites("SSL_RSA_WITH_DES_CBC_SHA",
69 "SSL_DHE_RSA_WITH_DES_CBC_SHA", "SSL_DHE_DSS_WITH_DES_CBC_SHA",
70 "SSL_RSA_EXPORT_WITH_RC4_40_MD5",
71 "SSL_RSA_EXPORT_WITH_DES40_CBC_SHA",
72 "SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA",
73 "SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA");
75 // SSL HTTP Configuration
76 HttpConfiguration https_config = new HttpConfiguration(http_config);
77 https_config.addCustomizer(new SecureRequestCustomizer());
80 ServerConnector sslConnector = new ServerConnector(server,
81 new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()),
82 new HttpConnectionFactory(https_config));
83 sslConnector.setPort(Port);
84 server.addConnector(sslConnector);
87 sslContextFactory.addExcludeProtocols("SSLv3");
88 System.out.println("Excluded protocols SSASubscriber-"+sslContextFactory.getExcludeProtocols().toString());
89 /**End of SSLv3 Fixes*/
91 // HTTPS Configuration
92 ServerConnector https = new ServerConnector(server,
93 new SslConnectionFactory(sslContextFactory,HttpVersion.HTTP_1_1.asString()),
94 new HttpConnectionFactory(https_config));
96 https.setIdleTimeout(30000);
97 //server.setConnectors(new Connector[] { http, https });
98 server.setConnectors(new Connector[] { http });
99 ServletContextHandler ctxt = new ServletContextHandler(0);
100 ctxt.setContextPath(ContextPath);
101 server.setHandler(ctxt);
103 ctxt.addServlet(new ServletHolder(new SubscriberServlet()), "/*");
107 } catch ( Exception e ) {
108 System.out.println("Jetty failed to start. Reporting will we unavailable-"+e);
112 System.out.println("Subscriber started-"+ server.getState());