summaryrefslogtreecommitdiffstats
path: root/auth/auth-core
diff options
context:
space:
mode:
Diffstat (limited to 'auth/auth-core')
-rw-r--r--auth/auth-core/pom.xml2
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzEnv.java5
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java2
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java54
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java46
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java30
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/server/ServiceStarter.java2
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/server/TestKill.java65
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsService.java3
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java3
10 files changed, 147 insertions, 65 deletions
diff --git a/auth/auth-core/pom.xml b/auth/auth-core/pom.xml
index 96153818..a4b01cd9 100644
--- a/auth/auth-core/pom.xml
+++ b/auth/auth-core/pom.xml
@@ -25,7 +25,7 @@
<parent>
<groupId>org.onap.aaf.authz</groupId>
<artifactId>authparent</artifactId>
- <version>2.1.9-SNAPSHOT</version>
+ <version>2.1.10-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzEnv.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzEnv.java
index 56db6f60..497c13d6 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzEnv.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzEnv.java
@@ -102,7 +102,10 @@ public class AuthzEnv extends RosettaEnv implements Access {
@Override
public void log(Throwable e, Object... msgs) {
- access.log(Level.ERROR, msgs);
+ Object[] nm = new Object[msgs.length+1];
+ System.arraycopy(msgs, 0, nm, 1, msgs.length);
+ nm[0]=e;
+ access.log(Level.ERROR, nm);
}
@Override
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java
index 3e68e3ab..e064ade3 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/layer/Result.java
@@ -275,8 +275,6 @@ public class Result<RV> {
* @return
*/
public boolean isOKhasData() {
- System.out.println("specialCondition:"+specialCondition);
- System.out.println("specialCondition:"+(specialCondition & EMPTY_LIST));
return status == OK && (specialCondition & EMPTY_LIST) != EMPTY_LIST;
}
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java
index 435b8845..9ece4847 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java
@@ -54,42 +54,30 @@ public abstract class AbsService<ENV extends BasicEnv, TRANS extends Trans> exte
public final String app_name;
public final String app_version;
- public final String app_interface_version;
public final String ROOT_NS;
-
+
public AbsService(final Access access, final ENV env) throws CadiException {
- Define.set(access);
- ROOT_NS = Define.ROOT_NS();
+ Define.set(access);
+ ROOT_NS = Define.ROOT_NS();
this.access = access;
this.env = env;
- String component = access.getProperty(Config.AAF_COMPONENT, null);
- final String[] locator_deploy;
-
- if (component == null) {
- locator_deploy = null;
+ String str = access.getProperty(Config.AAF_LOCATOR_NAMES, null);
+ String[] scomp = Split.splitTrim(',', str);
+ if(scomp.length==0) {
+ throw new CadiException(Config.AAF_LOCATOR_NAMES + " must be defined.");
} else {
- locator_deploy = Split.splitTrim(':', component);
- if(locator_deploy.length>1 && "AAF_RELEASE".equals(locator_deploy[1])) {
- locator_deploy[1]=access.getProperty(Config.AAF_RELEASE, Defaults.AAF_VERSION);
- int snapshot = locator_deploy[1].indexOf("-SNAPSHOT");
- if(snapshot>0) {
- locator_deploy[1]=locator_deploy[1].substring(0, snapshot);
- }
- }
- }
-
- if (component == null || locator_deploy==null || locator_deploy.length<2) {
- throw new CadiException("AAF Component must include the " + Config.AAF_COMPONENT + " property, <fully qualified service name>:<full deployed version (i.e. 2.1.3.13)");
+ str = ROOT_NS + '.' + scomp[0];
}
- final String[] version = Split.splitTrim('.', locator_deploy[1]);
- if (version==null || version.length<2) {
- throw new CadiException("AAF Component Version must have at least Major.Minor version");
+ app_name = str;
+
+ str = access.getProperty(Config.AAF_LOCATOR_VERSION, null);
+ if(str==null) {
+ str = Defaults.AAF_VERSION;
+ env.setProperty(Config.AAF_LOCATOR_VERSION, str);
}
- app_name = Define.varReplace(locator_deploy[0]);
- app_version = locator_deploy[1];
- app_interface_version = version[0]+'.'+version[1];
-
+ app_version = str;
+
// Print Cipher Suites Available
if (access.willLog(Level.DEBUG)) {
SSLContext context;
@@ -111,7 +99,15 @@ public abstract class AbsService<ENV extends BasicEnv, TRANS extends Trans> exte
access.log(Level.DEBUG,sb);
}
}
+
+ public void setProtocol(String proto) {
+ env.setProperty(Config.AAF_LOCATOR_PROTOCOL, proto);
+ }
+ public void setSubprotocol(String subproto) {
+ env.setProperty(Config.AAF_LOCATOR_SUBPROTOCOL, subproto);
+ }
+
protected abstract Filter[] _filters(Object ... additionalTafLurs) throws CadiException, LocatorException;
/**
@@ -125,7 +121,7 @@ public abstract class AbsService<ENV extends BasicEnv, TRANS extends Trans> exte
return _filters();
}
- public abstract Registrant<ENV>[] registrants(final int port) throws CadiException, LocatorException;
+ public abstract Registrant<ENV>[] registrants(final int actualPort) throws CadiException, LocatorException;
// Lazy Instantiation
public synchronized AAFConHttp aafCon() throws CadiException, LocatorException {
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java
index 29166b0b..8f0eb8aa 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java
@@ -19,10 +19,17 @@
*
*/
package org.onap.aaf.auth.server;
+import java.io.IOException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+
import org.onap.aaf.auth.org.OrganizationException;
import org.onap.aaf.auth.org.OrganizationFactory;
import org.onap.aaf.auth.rserv.RServlet;
import org.onap.aaf.cadi.Access;
+import org.onap.aaf.cadi.Access.Level;
import org.onap.aaf.cadi.register.Registrant;
import org.onap.aaf.cadi.register.Registrar;
import org.onap.aaf.misc.env.Trans;
@@ -61,14 +68,30 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr
@Override
public final void start() throws Exception {
- _start(service);
- Runtime.getRuntime().addShutdownHook(new Thread() {
- @Override
- public void run() {
- shutdown();
- }
- });
+ ExecutorService es = Executors.newSingleThreadExecutor();
+ Future<?> app = es.submit(this);
+ final AbsServiceStarter<?,?> absSS = this;
+ Runtime.getRuntime().addShutdownHook(new Thread() {
+ @Override
+ public void run() {
+ absSS.access().printf(Level.INIT, "Shutting down %s:%s\n",absSS.service.app_name, absSS.service.app_version);
+ absSS.shutdown();
+ app.cancel(true);
+ }
+ });
+ if(System.getProperty("ECLIPSE", null)!=null) {
+ Thread.sleep(2000);
+ System.out.println("Service Started in Eclipse: ");
+ System.out.print(" Hit <enter> to end:");
+ try {
+ System.in.read();
+ System.exit(0);
+ } catch (IOException e) {
+ }
+ }
+
}
+
@SafeVarargs
public final synchronized void register(final Registrant<ENV> ... registrants) {
@@ -83,6 +106,15 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr
}
@Override
+ public void run() {
+ try {
+ _start(service);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
public void shutdown() {
if (registrar!=null) {
registrar.close(env());
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java
index c5849d05..d29b8f26 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java
@@ -56,7 +56,6 @@ 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 {
@@ -73,24 +72,6 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex
return this;
}
-// @Override
-// public void _propertyAdjustment() {
-// Properties props = access().getProperties();
-// Object temp = null;
-// // Critical - if no Security Protocols set, then set it. We'll just get messed up if not
-// if ((temp=props.get(Config.CADI_PROTOCOLS))==null) {
-// if ((temp=props.get(Config.HTTPS_PROTOCOLS))==null) {
-// props.put(Config.CADI_PROTOCOLS, SecurityInfo.HTTPS_PROTOCOLS_DEFAULT);
-// } else {
-// props.put(Config.CADI_PROTOCOLS, temp);
-// }
-// }
-//
-// if ("1.7".equals(System.getProperty("java.specification.version"))) {
-// System.setProperty(Config.HTTPS_CIPHER_SUITES, Config.HTTPS_CIPHER_SUITES_DEFAULT);
-// }
-// System.setProperty(Config.HTTPS_CIPHER_SUITES, temp.toString());
-// }
@Override
public void _propertyAdjustment() {
@@ -129,6 +110,7 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex
protocol = "http";
} else {
protocol = "https";
+
String keystorePassword = access().getProperty(Config.CADI_KEYSTORE_PASSWORD, null);
if (keystorePassword==null) {
@@ -151,7 +133,9 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex
sslContextFactory.setTrustStorePassword(access().decrypt(truststorePassword, true));
}
// Be able to accept only certain protocols, i.e. TLSv1.1+
- final String[] protocols = Split.splitTrim(',', access().getProperty(Config.CADI_PROTOCOLS, SecurityInfo.HTTPS_PROTOCOLS_DEFAULT));
+ String subprotocols = access().getProperty(Config.CADI_PROTOCOLS, SecurityInfo.HTTPS_PROTOCOLS_DEFAULT);
+ service.setSubprotocol(subprotocols);
+ final String[] protocols = Split.splitTrim(',', subprotocols);
sslContextFactory.setIncludeProtocols(protocols);
// Want to use Client Certificates, if they exist.
@@ -178,6 +162,8 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex
new HttpConnectionFactory(httpConfig)
);
}
+ service.setProtocol(protocol);
+
// Setup JMX
// TODO trying to figure out how to set up/log ports
@@ -220,7 +206,7 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex
server.start();
access().log(Level.INIT,server.dump());
} catch (Exception e) {
- access().log(e,"Error starting " + service.app_name);
+ access().log(e,"Error starting " + hostname + ':' + port + ' ' + InetAddress.getLocalHost().getHostAddress());
String doExit = access().getProperty("cadi_exitOnFailure", "true");
if (doExit == "true") {
System.exit(1);
@@ -231,7 +217,7 @@ public class JettyServiceStarter<ENV extends RosettaEnv, TRANS extends Trans> ex
try {
register(service.registrants(port));
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();
+ //server.join();
} catch (Exception e) {
access().log(e,"Error registering " + service.app_name);
String doExit = access().getProperty("cadi_exitOnFailure", "true");
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/ServiceStarter.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/ServiceStarter.java
index 6f2d4cb9..9004f76b 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/ServiceStarter.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/ServiceStarter.java
@@ -20,7 +20,7 @@
*/
package org.onap.aaf.auth.server;
-public interface ServiceStarter {
+public interface ServiceStarter extends Runnable {
public void start() throws Exception;
public void shutdown();
}
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/TestKill.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/TestKill.java
new file mode 100644
index 00000000..78172a22
--- /dev/null
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/TestKill.java
@@ -0,0 +1,65 @@
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ */
+
+package org.onap.aaf.auth.server;
+
+import java.io.IOException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+
+public class TestKill implements Runnable {
+
+ public static void main(String[] args) {
+ ExecutorService es = Executors.newSingleThreadExecutor();
+ TestKill tk = new TestKill();
+ Future<?> app = es.submit(tk);
+ Runtime.getRuntime().addShutdownHook(new Thread() {
+ @Override
+ public void run() {
+ System.out.println("Shutdown Hook, thread: setting interrupt");
+ app.cancel(true);
+ tk.longProcess();
+ es.shutdown();
+ }
+ });
+ System.out.println("Service Start");
+ System.out.print("Hit <enter> to end:");
+ try {
+ System.in.read();
+ System.exit(0);
+ } catch (IOException e) {
+ }
+ }
+
+ @Override
+ public void run() {
+ }
+
+ private void longProcess() {
+ System.out.println("Starting long cleanup process");
+ try {
+ Thread.sleep(10000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ System.out.println("Ending long cleanup process");
+ }
+}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsService.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsService.java
index a0ee9ef9..65f019f0 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsService.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsService.java
@@ -103,7 +103,8 @@ public class JU_AbsService {
BasicEnv bEnv = new BasicEnv();
PropAccess prop = new PropAccess();
- prop.setProperty(Config.AAF_COMPONENT, "te.st:te.st");
+ prop.setProperty(Config.AAF_LOCATOR_NAMES, "te.st");
+ prop.setProperty(Config.AAF_LOCATOR_VERSION, "te.st");
prop.setLogLevel(Level.DEBUG);
AbsServiceStub absServiceStub = new AbsServiceStub(prop, bEnv); //Testing other branches requires "fails" due to exception handling, will leave that off for now.
}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java
index 1f5d70ae..1fe98d84 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java
@@ -131,7 +131,8 @@ public class JU_AbsServiceStarter {
BasicEnv bEnv = new BasicEnv();
PropAccess prop = new PropAccess();
- prop.setProperty(Config.AAF_COMPONENT, "te.st:te.st");
+ prop.setProperty(Config.AAF_LOCATOR_NAMES, "te.st");
+ prop.setProperty(Config.AAF_LOCATOR_VERSION, "te.st");
prop.setLogLevel(Level.DEBUG);
absServiceStub = new AbsServiceStub(prop, bEnv);