summaryrefslogtreecommitdiffstats
path: root/auth/auth-core/src
diff options
context:
space:
mode:
authorInstrumental <jcgmisc@stl.gathman.org>2018-04-05 20:17:18 -0500
committerInstrumental <jcgmisc@stl.gathman.org>2018-04-05 20:17:25 -0500
commit924b18d7469204ceaae60d7345712ea09f75a674 (patch)
treeb4584c2731c82f484a31feadcb71d75c3613af43 /auth/auth-core/src
parent33e7b1a9fa15b0b699d16e359b406195b7fe87be (diff)
Add Certs, Docker Build
Issue-ID: AAF-211 Change-Id: Idc7630578155586a6e53d7af80dd16e4e0ac41ca Signed-off-by: Instrumental <jcgmisc@stl.gathman.org>
Diffstat (limited to 'auth/auth-core/src')
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java21
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/server/Log4JLogIt.java37
2 files changed, 51 insertions, 7 deletions
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 12b19d29..d8c73117 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
@@ -22,6 +22,7 @@
package org.onap.aaf.auth.server;
import java.security.NoSuchAlgorithmException;
+import java.util.Properties;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
@@ -46,7 +47,6 @@ import org.onap.aaf.misc.env.Trans;
import org.onap.aaf.misc.env.impl.BasicEnv;
public abstract class AbsService<ENV extends BasicEnv, TRANS extends Trans> extends RServlet<TRANS> {
- protected static final String AAF_LOG4J_PREFIX = "aaf_log4j_prefix";
public final Access access;
public final ENV env;
private AAFConHttp aafCon;
@@ -155,14 +155,25 @@ public abstract class AbsService<ENV extends BasicEnv, TRANS extends Trans> exte
return aafCon.hman().best(new HTransferSS(p,app_name, aafCon.securityInfo()), retryable);
}
- protected static final String getArg(final String tag, final String args[], final String def) {
- String value = def;
+ protected static final String loadFromArgOrSystem(final Properties props, final String tag, final String args[], final String def) {
String tagEQ = tag + '=';
+ String value;
for(String arg : args) {
if(arg.startsWith(tagEQ)) {
- value = arg.substring(tagEQ.length());
+ props.put(tag, value=arg.substring(tagEQ.length()));
+ return value;
}
}
- return value;
+ // check System.properties
+ value = System.getProperty(tag);
+ if(value!=null) {
+ props.put(tag, value);
+ return value;
+ }
+
+ if(def!=null) {
+ props.put(tag,def);
+ }
+ return def;
}
}
diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/Log4JLogIt.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/Log4JLogIt.java
index 0b91c9fc..e295c867 100644
--- a/auth/auth-core/src/main/java/org/onap/aaf/auth/server/Log4JLogIt.java
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/Log4JLogIt.java
@@ -20,6 +20,7 @@
*/
package org.onap.aaf.auth.server;
+import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
@@ -27,10 +28,13 @@ import org.apache.log4j.Logger;
import org.onap.aaf.cadi.Access.Level;
import org.onap.aaf.cadi.PropAccess;
import org.onap.aaf.cadi.PropAccess.LogIt;
+import org.onap.aaf.cadi.config.Config;
import org.onap.aaf.misc.env.APIException;
import org.onap.aaf.misc.env.log4j.LogFileNamer;
public class Log4JLogIt implements LogIt {
+ protected static final String AAF_LOG4J_PREFIX = "aaf_log4j_prefix";
+
// Sonar says cannot be static... it's ok. not too many PropAccesses created.
private final SimpleDateFormat iso8601 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
@@ -45,7 +49,19 @@ public class Log4JLogIt implements LogIt {
private final Logger ltrace;
- public Log4JLogIt(final String log_dir, final String log_level, final String propsFile, final String root) throws APIException {
+ public Log4JLogIt(final String[] args, final String root) throws APIException {
+ String propsFile = getArgOrVM(AAF_LOG4J_PREFIX, args, "org.osaaf")+".log4j.props";
+ String log_dir = getArgOrVM(Config.CADI_LOGDIR,args,"/opt/app/osaaf/logs");
+ String etc_dir = getArgOrVM(Config.CADI_ETCDIR,args,"/opt/app/osaaf/etc");
+ String log_level = getArgOrVM(Config.CADI_LOGLEVEL,args,"INFO");
+ File logs = new File(log_dir);
+ if(!logs.isDirectory()) {
+ logs.delete();
+ }
+ if(!logs.exists()) {
+ logs.mkdirs();
+ }
+
LogFileNamer lfn = new LogFileNamer(log_dir,root);
try {
service=lfn.setAppender("service"); // when name is split, i.e. authz|service, the Appender is "authz", and "service"
@@ -58,12 +74,29 @@ public class Log4JLogIt implements LogIt {
linit = Logger.getLogger(init);
ltrace = Logger.getLogger(trace);
- lfn.configure(propsFile, log_level);
+ lfn.configure(etc_dir,propsFile, log_level);
} catch (IOException e) {
throw new APIException(e);
}
}
+ private static final String getArgOrVM(final String tag, final String args[], final String def) {
+ String tagEQ = tag + '=';
+ String value;
+ for(String arg : args) {
+ if(arg.startsWith(tagEQ)) {
+ return arg.substring(tagEQ.length());
+ }
+ }
+ // check System.properties
+ value = System.getProperty(tag);
+ if(value!=null) {
+ return value;
+ }
+
+ return def;
+ }
+
@Override
public void push(Level level, Object... elements) {
switch(level) {