Remove Tabs, per Jococo
[aaf/authz.git] / auth / auth-core / src / main / java / org / onap / aaf / auth / server / JettyServiceStarter.java
index 2d0a82a..78a7702 100644 (file)
@@ -21,7 +21,6 @@
 package org.onap.aaf.auth.server;
 
 import java.io.IOException;
-import java.net.Inet4Address;
 import java.net.InetAddress;
 import java.util.Properties;
 
@@ -45,34 +44,21 @@ import org.eclipse.jetty.server.handler.AbstractHandler;
 import org.eclipse.jetty.util.ssl.SslContextFactory;
 import org.onap.aaf.auth.org.OrganizationException;
 import org.onap.aaf.auth.rserv.RServlet;
+import org.onap.aaf.cadi.Access.Level;
 import org.onap.aaf.cadi.CadiException;
 import org.onap.aaf.cadi.LocatorException;
-import org.onap.aaf.cadi.Access.Level;
 import org.onap.aaf.cadi.config.Config;
-import org.onap.aaf.cadi.config.SecurityInfo;
 import org.onap.aaf.misc.env.Trans;
 import org.onap.aaf.misc.env.util.Split;
 import org.onap.aaf.misc.rosetta.env.RosettaEnv;
 
 
 public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> extends AbsServiceStarter<ENV,TRANS> {
-    private boolean secure;
 
-    public JettyServiceStarter(final AbsService<ENV,TRANS> service) throws OrganizationException {
-        super(service);
-        secure = true;
+    public JettyServiceStarter(final AbsService<ENV,TRANS> service, boolean secure) throws OrganizationException {
+        super(service, secure);
     }
     
-    /**
-     * Specifically set this Service starter to Insecure (HTTP) Mode. 
-     * @return
-     */
-    public JettyServiceStarter<ENV,TRANS> insecure() {
-        secure = false;
-        return this;
-    }
-
-
     @Override
     public void _propertyAdjustment() {
 //        System.setProperty("com.sun.management.jmxremote.port", "8081");
@@ -81,7 +67,7 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex
         // Critical - if no Security Protocols set, then set it.  We'll just get messed up if not
         if ((httpproto=props.get(Config.CADI_PROTOCOLS))==null) {
             if ((httpproto=props.get(Config.HTTPS_PROTOCOLS))==null) {
-                props.put(Config.CADI_PROTOCOLS, (httpproto=SecurityInfo.HTTPS_PROTOCOLS_DEFAULT));
+                props.put(Config.CADI_PROTOCOLS, (httpproto=Config.HTTPS_PROTOCOLS_DEFAULT));
             } else {
                 props.put(Config.CADI_PROTOCOLS, httpproto);
             }
@@ -94,10 +80,6 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex
 
     @Override
     public void _start(RServlet<TRANS> rserv) throws Exception {
-        String hostname = access().getProperty(Config.HOSTNAME, null);
-        if (hostname==null) {
-            hostname = Inet4Address.getLocalHost().getHostName();
-        }
         final int port = Integer.parseInt(access().getProperty("port","0"));
         final String keystore = access().getProperty(Config.CADI_KEYSTORE, null);
         final int IDLE_TIMEOUT = Integer.parseInt(access().getProperty(Config.AAF_CONN_IDLE_TIMEOUT, Config.AAF_CONN_IDLE_TIMEOUT_DEF));
@@ -133,7 +115,7 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex
                 sslContextFactory.setTrustStorePassword(access().decrypt(truststorePassword, false)); 
             }
             // Be able to accept only certain protocols, i.e. TLSv1.1+
-            String subprotocols = access().getProperty(Config.CADI_PROTOCOLS, SecurityInfo.HTTPS_PROTOCOLS_DEFAULT);
+            String subprotocols = access().getProperty(Config.CADI_PROTOCOLS, Config.HTTPS_PROTOCOLS_DEFAULT);
             service.setSubprotocol(subprotocols);
             final String[] protocols = Split.splitTrim(',', subprotocols);
             sslContextFactory.setIncludeProtocols(protocols);
@@ -215,9 +197,15 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex
             }
         }
         try {
-            register(service.registrants(port));
+            String no_register = env().getProperty("aaf_no_register",null);
+            if(no_register==null) {
+                register(service.registrants(port));
+            } else {
+                access().printf(Level.INIT,"'aaf_no_register' is set.  %s will not be registered with Locator", service.app_name);
+            }
             access().printf(Level.INIT, "Starting Jetty Service for %s, version %s, on %s://%s:%d", service.app_name,service.app_version,protocol,hostname,port);
-            //server.join();
+            
+            rserv.postStartup(hostname, port);
         } catch (Exception e) {
             access().log(e,"Error registering " + service.app_name);
             String doExit = access().getProperty("cadi_exitOnFailure", "true");