summaryrefslogtreecommitdiffstats
path: root/auth
diff options
context:
space:
mode:
Diffstat (limited to 'auth')
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/Batch.java7
-rw-r--r--auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/AAF_CM.java17
-rw-r--r--auth/auth-core/pom.xml5
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/env/AuthzEnv.java87
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java12
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/server/Log4JLogIt.java100
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzEnv.java18
-rw-r--r--auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java17
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/AAF_GUI.java20
-rw-r--r--auth/auth-hello/src/main/java/org/onap/aaf/auth/hello/AAF_Hello.java17
-rw-r--r--auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java17
-rw-r--r--auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/AAF_OAuth.java17
-rw-r--r--auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/DirectOAuthTAF.java1
-rw-r--r--auth/auth-service/.gitignore1
-rw-r--r--auth/auth-service/pom.xml6
-rw-r--r--auth/auth-service/src/main/java/org/onap/aaf/auth/service/AAF_Service.java28
16 files changed, 270 insertions, 100 deletions
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/Batch.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/Batch.java
index 64c09711..d4b582a3 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/Batch.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/Batch.java
@@ -422,12 +422,7 @@ public abstract class Batch {
// Flow all Env Logs to Log4j, with ENV
LogFileNamer lfn;
- if ((batchEnv = env.getProperty(CASS_ENV)) == null) {
- lfn = new LogFileNamer(logDir()).noPID();
- } else {
- lfn = new LogFileNamer(logDir()).noPID();
- }
-
+ lfn = new LogFileNamer(logDir(),"").noPID();
lfn.setAppender("authz-batch");
lfn.setAppender("aspr|ASPR");
lfn.setAppender("sync");
diff --git a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/AAF_CM.java b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/AAF_CM.java
index c1bc8202..aee48870 100644
--- a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/AAF_CM.java
+++ b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/AAF_CM.java
@@ -22,6 +22,7 @@
package org.onap.aaf.auth.cm;
+import java.io.File;
import java.lang.reflect.Constructor;
import java.util.Map;
import java.util.Map.Entry;
@@ -49,6 +50,7 @@ import org.onap.aaf.auth.env.AuthzTransFilter;
import org.onap.aaf.auth.rserv.HttpMethods;
import org.onap.aaf.auth.server.AbsService;
import org.onap.aaf.auth.server.JettyServiceStarter;
+import org.onap.aaf.auth.server.Log4JLogIt;
import org.onap.aaf.cadi.Access;
import org.onap.aaf.cadi.CadiException;
import org.onap.aaf.cadi.LocatorException;
@@ -226,10 +228,21 @@ public class AAF_CM extends AbsService<AuthzEnv, AuthzTrans> {
}
public static void main(final String[] args) {
- PropAccess propAccess = new PropAccess(args);
try {
+ String propsFile = getArg(AAF_LOG4J_PREFIX, args, "org.osaaf")+".log4j.props";
+ String log_dir = getArg(Config.CADI_LOGDIR,args,"./logs");
+ String log_level = getArg(Config.CADI_LOGLEVEL,args,"INFO");
+ File logs = new File(log_dir);
+ if(!logs.isDirectory()) {
+ logs.delete();
+ }
+ if(!logs.exists()) {
+ logs.mkdirs();
+ }
+ Log4JLogIt logIt = new Log4JLogIt(log_dir,log_level,propsFile, "cm");
+ PropAccess propAccess = new PropAccess(logIt,args);
+
AAF_CM service = new AAF_CM(new AuthzEnv(propAccess));
-// env.setLog4JNames("log4j.properties","authz","cm","audit","init","trace");
JettyServiceStarter<AuthzEnv,AuthzTrans> jss = new JettyServiceStarter<AuthzEnv,AuthzTrans>(service);
jss.start();
} catch (Exception e) {
diff --git a/auth/auth-core/pom.xml b/auth/auth-core/pom.xml
index d0d2fb6e..a7f60aea 100644
--- a/auth/auth-core/pom.xml
+++ b/auth/auth-core/pom.xml
@@ -119,7 +119,10 @@
<scope>compile</scope>
</dependency>
-
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
</dependencies>
<build>
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 300e4087..a396cd98 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
@@ -29,14 +29,11 @@ import java.util.Properties;
import org.onap.aaf.cadi.Access;
import org.onap.aaf.cadi.CadiException;
import org.onap.aaf.cadi.PropAccess;
-import org.onap.aaf.cadi.PropAccess.LogIt;
import org.onap.aaf.cadi.Symm;
import org.onap.aaf.cadi.config.Config;
-import org.onap.aaf.misc.env.APIException;
import org.onap.aaf.misc.env.Decryptor;
import org.onap.aaf.misc.env.Encryptor;
-import org.onap.aaf.misc.env.impl.Log4JLogTarget;
-import org.onap.aaf.misc.env.log4j.LogFileNamer;
+import org.onap.aaf.misc.env.LogTarget;
import org.onap.aaf.misc.rosetta.env.RosettaEnv;
@@ -79,39 +76,46 @@ public class AuthzEnv extends RosettaEnv implements Access {
access = pa;
times = new long[20];
idx = 0;
+ fatal = new AccessLogTarget(access, Level.ERROR);
+ error = fatal;
+ audit = new AccessLogTarget(access, Level.AUDIT);
+ init = new AccessLogTarget(access, Level.INIT);
+ warn = new AccessLogTarget(access, Level.WARN);
+ info = new AccessLogTarget(access, Level.INFO);
+ debug = new AccessLogTarget(access, Level.DEBUG);
+ trace = new AccessLogTarget(access, Level.TRACE);
}
- private class Log4JLogit implements LogIt {
+ private class AccessLogTarget implements LogTarget {
+ private final Level level;
+ private final Access access;
+
+ public AccessLogTarget(final Access access, final Level level) {
+ this.level = level;
+ this.access = access;
+ }
@Override
- public void push(Level level, Object... elements) {
- switch(level) {
- case AUDIT:
- audit.log(elements);
- break;
- case DEBUG:
- debug.log(elements);
- break;
- case ERROR:
- error.log(elements);
- break;
- case INFO:
- info.log(elements);
- break;
- case INIT:
- init.log(elements);
- break;
- case NONE:
- break;
- case WARN:
- warn.log(elements);
- break;
- }
-
+ public void log(Object... msgs) {
+ access.log(level, msgs);
+ }
+
+ @Override
+ public void log(Throwable e, Object... msgs) {
+ access.log(Level.ERROR, msgs);
+ }
+
+ @Override
+ public boolean isLoggable() {
+ return access.willLog(level);
+ }
+
+ @Override
+ public void printf(String fmt, Object... vars) {
+ access.printf(level, fmt, vars);
}
}
-
@Override
public AuthzTransImpl newTrans() {
synchronized(this) {
@@ -192,29 +196,6 @@ public class AuthzEnv extends RosettaEnv implements Access {
public void setLogLevel(Level level) {
access.setLogLevel(level);
}
-
- public void setLog4JNames(String path, String root, String _service, String _audit, String _init, String _trace) throws APIException {
- LogFileNamer lfn = new LogFileNamer(root);
- if(_service==null) {
- throw new APIException("AuthzEnv.setLog4JNames \"_service\" required (as default). Others can be null");
- }
- String service=_service=lfn.setAppender(_service); // when name is split, i.e. authz|service, the Appender is "authz", and "service"
- String audit=_audit==null?service:lfn.setAppender(_audit); // is part of the log-file name
- String init=_init==null?service:lfn.setAppender(_init);
- String trace=_trace==null?service:lfn.setAppender(_trace);
- //TODO Validate path on Classpath
- lfn.configure(path);
- super.fatal = new Log4JLogTarget(service,org.apache.log4j.Level.FATAL);
- super.error = new Log4JLogTarget(service,org.apache.log4j.Level.ERROR);
- super.warn = new Log4JLogTarget(service,org.apache.log4j.Level.WARN);
- super.audit = new Log4JLogTarget(audit,org.apache.log4j.Level.WARN);
- super.init = new Log4JLogTarget(init,org.apache.log4j.Level.WARN);
- super.info = new Log4JLogTarget(service,org.apache.log4j.Level.INFO);
- super.debug = new Log4JLogTarget(service,org.apache.log4j.Level.DEBUG);
- super.trace = new Log4JLogTarget(trace,org.apache.log4j.Level.TRACE);
-
- access.set(new Log4JLogit());
- }
private static final byte[] ENC="enc:".getBytes();
public String decrypt(String encrypted, final boolean anytext) throws IOException {
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 e1c01718..12b19d29 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
@@ -46,6 +46,7 @@ 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;
@@ -153,4 +154,15 @@ public abstract class AbsService<ENV extends BasicEnv, TRANS extends Trans> exte
public<RET> RET clientAsUser(TaggedPrincipal p,Retryable<RET> retryable) throws APIException, LocatorException, CadiException {
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;
+ String tagEQ = tag + '=';
+ for(String arg : args) {
+ if(arg.startsWith(tagEQ)) {
+ value = arg.substring(tagEQ.length());
+ }
+ }
+ return value;
+ }
}
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
new file mode 100644
index 00000000..0b91c9fc
--- /dev/null
+++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/server/Log4JLogIt.java
@@ -0,0 +1,100 @@
+/**
+ * ============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.text.SimpleDateFormat;
+
+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.misc.env.APIException;
+import org.onap.aaf.misc.env.log4j.LogFileNamer;
+
+public class Log4JLogIt implements LogIt {
+ // 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");
+
+ private final String service;
+ private final String audit;
+ private final String init;
+ private final String trace;
+
+ private final Logger lservice;
+ private final Logger laudit;
+ private final Logger linit;
+ private final Logger ltrace;
+
+
+ public Log4JLogIt(final String log_dir, final String log_level, final String propsFile, final String root) throws APIException {
+ 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"
+ audit=lfn.setAppender("audit"); // is part of the log-file name
+ init=lfn.setAppender("init");
+ trace=lfn.setAppender("trace");
+
+ lservice = Logger.getLogger(service);
+ laudit = Logger.getLogger(audit);
+ linit = Logger.getLogger(init);
+ ltrace = Logger.getLogger(trace);
+
+ lfn.configure(propsFile, log_level);
+ } catch (IOException e) {
+ throw new APIException(e);
+ }
+ }
+
+ @Override
+ public void push(Level level, Object... elements) {
+ switch(level) {
+ case AUDIT:
+ laudit.warn(PropAccess.buildMsg(audit, iso8601, level, elements));
+ break;
+ case INIT:
+ linit.warn(PropAccess.buildMsg(init, iso8601, level, elements));
+ break;
+ case ERROR:
+ lservice.error(PropAccess.buildMsg(service, iso8601, level, elements));
+ break;
+ case WARN:
+ lservice.warn(PropAccess.buildMsg(service, iso8601, level, elements));
+ break;
+ case INFO:
+ lservice.info(PropAccess.buildMsg(service, iso8601, level, elements));
+ break;
+ case DEBUG:
+ lservice.debug(PropAccess.buildMsg(service, iso8601, level, elements));
+ break;
+ case TRACE:
+ ltrace.trace(PropAccess.buildMsg(service, iso8601, level, elements));
+ break;
+ case NONE:
+ break;
+ default:
+ lservice.info(PropAccess.buildMsg(service, iso8601, level, elements));
+ break;
+
+ }
+
+ }
+}
diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzEnv.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzEnv.java
index 4d088c5a..6413b099 100644
--- a/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzEnv.java
+++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/env/test/JU_AuthzEnv.java
@@ -21,22 +21,20 @@
******************************************************************************/
package org.onap.aaf.auth.env.test;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.mock;
+
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
-import org.onap.aaf.cadi.Access;
-import static org.mockito.Mockito.when;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-import org.mockito.Mock;
import org.onap.aaf.auth.env.AuthzEnv;
+import org.onap.aaf.cadi.Access;
import org.onap.aaf.cadi.PropAccess;
-import org.onap.aaf.cadi.Access.Level;
-import org.onap.aaf.cadi.config.Config;
-import org.onap.aaf.misc.env.APIException;
import org.powermock.modules.junit4.PowerMockRunner;
import junit.framework.Assert;
@@ -85,12 +83,6 @@ public class JU_AuthzEnv {
Assert.assertNotNull(authzEnv.getProperties("test"));
}
- @Test(expected = APIException.class)
- public void checkSetLog4JNames() throws APIException {//TODO: Find better way to test instead of just seeing if strings pass
- authzEnv.setLog4JNames("path", "root","service","audit","init","trace");
- authzEnv.setLog4JNames("path", "root",null,"audit","init","trace");
- }
-
@Test
public void checkPropertyGetters(){
authzEnv.setProperty("key","value");
diff --git a/auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java b/auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java
index 50791393..719daaae 100644
--- a/auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java
+++ b/auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java
@@ -23,6 +23,7 @@ package org.onap.aaf.auth.fs;
import static org.onap.aaf.auth.rserv.HttpMethods.GET;
+import java.io.File;
import java.io.IOException;
import javax.servlet.Filter;
@@ -36,6 +37,7 @@ import org.onap.aaf.auth.rserv.CachingFileAccess;
import org.onap.aaf.auth.rserv.HttpCode;
import org.onap.aaf.auth.server.AbsService;
import org.onap.aaf.auth.server.JettyServiceStarter;
+import org.onap.aaf.auth.server.Log4JLogIt;
import org.onap.aaf.cadi.Access.Level;
import org.onap.aaf.cadi.CadiException;
import org.onap.aaf.cadi.LocatorException;
@@ -102,10 +104,21 @@ public class AAF_FS extends AbsService<AuthzEnv, AuthzTrans> {
}
public static void main(final String[] args) {
- PropAccess propAccess = new PropAccess(args);
try {
+ String propsFile = getArg(AAF_LOG4J_PREFIX, args, "org.osaaf")+".log4j.props";
+ String log_dir = getArg(Config.CADI_LOGDIR,args,"./logs");
+ String log_level = getArg(Config.CADI_LOGLEVEL,args,"INFO");
+ File logs = new File(log_dir);
+ if(!logs.isDirectory()) {
+ logs.delete();
+ }
+ if(!logs.exists()) {
+ logs.mkdirs();
+ }
+ Log4JLogIt logIt = new Log4JLogIt(log_dir,log_level,propsFile, "fs");
+ PropAccess propAccess = new PropAccess(logIt,args);
+
AAF_FS service = new AAF_FS(new AuthzEnv(propAccess));
-// env.setLog4JNames("log4j.properties","authz","fs","audit","init",null);
JettyServiceStarter<AuthzEnv,AuthzTrans> jss = new JettyServiceStarter<AuthzEnv,AuthzTrans>(service);
jss.insecure().start();
} catch (Exception e) {
diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/AAF_GUI.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/AAF_GUI.java
index be93d63c..676866bb 100644
--- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/AAF_GUI.java
+++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/AAF_GUI.java
@@ -25,6 +25,8 @@ import static org.onap.aaf.auth.rserv.HttpMethods.GET;
import static org.onap.aaf.auth.rserv.HttpMethods.POST;
import static org.onap.aaf.auth.rserv.HttpMethods.PUT;
+import java.io.File;
+
import javax.servlet.Filter;
import org.onap.aaf.auth.cmd.Cmd;
@@ -68,6 +70,7 @@ import org.onap.aaf.auth.gui.pages.WebCommand;
import org.onap.aaf.auth.rserv.CachingFileAccess;
import org.onap.aaf.auth.server.AbsService;
import org.onap.aaf.auth.server.JettyServiceStarter;
+import org.onap.aaf.auth.server.Log4JLogIt;
import org.onap.aaf.cadi.CadiException;
import org.onap.aaf.cadi.LocatorException;
import org.onap.aaf.cadi.PropAccess;
@@ -254,10 +257,21 @@ public class AAF_GUI extends AbsService<AuthzEnv, AuthzTrans> implements State<E
}
public static void main(final String[] args) {
- PropAccess propAccess = new PropAccess(args);
try {
- AAF_GUI service = new AAF_GUI(new AuthzEnv(propAccess));
-// env.setLog4JNames("log4j.properties","authz","gui","audit","init","trace ");
+ String propsFile = getArg(AAF_LOG4J_PREFIX, args, "org.osaaf")+".log4j.props";
+ String log_dir = getArg(Config.CADI_LOGDIR,args,"./logs");
+ String log_level = getArg(Config.CADI_LOGLEVEL,args,"INFO");
+ File logs = new File(log_dir);
+ if(!logs.isDirectory()) {
+ logs.delete();
+ }
+ if(!logs.exists()) {
+ logs.mkdirs();
+ }
+ Log4JLogIt logIt = new Log4JLogIt(log_dir,log_level,propsFile, "authz");
+ PropAccess propAccess = new PropAccess(logIt,args);
+
+ AAF_GUI service = new AAF_GUI(new AuthzEnv(propAccess));
JettyServiceStarter<AuthzEnv,AuthzTrans> jss = new JettyServiceStarter<AuthzEnv,AuthzTrans>(service);
jss.start();
} catch (Exception e) {
diff --git a/auth/auth-hello/src/main/java/org/onap/aaf/auth/hello/AAF_Hello.java b/auth/auth-hello/src/main/java/org/onap/aaf/auth/hello/AAF_Hello.java
index 97448bdd..b20bf168 100644
--- a/auth/auth-hello/src/main/java/org/onap/aaf/auth/hello/AAF_Hello.java
+++ b/auth/auth-hello/src/main/java/org/onap/aaf/auth/hello/AAF_Hello.java
@@ -22,6 +22,7 @@
package org.onap.aaf.auth.hello;
+import java.io.File;
import java.util.Map;
import javax.servlet.Filter;
@@ -34,6 +35,7 @@ import org.onap.aaf.auth.rserv.HttpCode;
import org.onap.aaf.auth.rserv.HttpMethods;
import org.onap.aaf.auth.server.AbsService;
import org.onap.aaf.auth.server.JettyServiceStarter;
+import org.onap.aaf.auth.server.Log4JLogIt;
import org.onap.aaf.cadi.CadiException;
import org.onap.aaf.cadi.LocatorException;
import org.onap.aaf.cadi.PropAccess;
@@ -116,10 +118,21 @@ public class AAF_Hello extends AbsService<AuthzEnv,AuthzTrans> {
}
public static void main(final String[] args) {
- PropAccess propAccess = new PropAccess(args);
try {
+ String propsFile = getArg(AAF_LOG4J_PREFIX, args, "org.osaaf")+".log4j.props";
+ String log_dir = getArg(Config.CADI_LOGDIR,args,"./logs");
+ String log_level = getArg(Config.CADI_LOGLEVEL,args,"INFO");
+ File logs = new File(log_dir);
+ if(!logs.isDirectory()) {
+ logs.delete();
+ }
+ if(!logs.exists()) {
+ logs.mkdirs();
+ }
+ Log4JLogIt logIt = new Log4JLogIt(log_dir,log_level,propsFile, "hello");
+ PropAccess propAccess = new PropAccess(logIt,args);
+
AAF_Hello service = new AAF_Hello(new AuthzEnv(propAccess));
-// env.setLog4JNames("log4j.properties","authz","hello","audit","init","trace");
JettyServiceStarter<AuthzEnv,AuthzTrans> jss = new JettyServiceStarter<AuthzEnv,AuthzTrans>(service);
jss.start();
} catch (Exception e) {
diff --git a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java
index 92fc88c7..31f67726 100644
--- a/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java
+++ b/auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java
@@ -22,6 +22,7 @@
package org.onap.aaf.auth.locate;
+import java.io.File;
import java.net.URI;
import java.util.Map;
@@ -46,6 +47,7 @@ import org.onap.aaf.auth.locate.mapper.Mapper.API;
import org.onap.aaf.auth.rserv.HttpMethods;
import org.onap.aaf.auth.server.AbsService;
import org.onap.aaf.auth.server.JettyServiceStarter;
+import org.onap.aaf.auth.server.Log4JLogIt;
import org.onap.aaf.cadi.CadiException;
import org.onap.aaf.cadi.Locator;
import org.onap.aaf.cadi.LocatorException;
@@ -230,10 +232,21 @@ public class AAF_Locate extends AbsService<AuthzEnv, AuthzTrans> {
}
public static void main(final String[] args) {
- PropAccess propAccess = new PropAccess(args);
try {
+ String propsFile = getArg(AAF_LOG4J_PREFIX, args, "org.osaaf")+".log4j.props";
+ String log_dir = getArg(Config.CADI_LOGDIR,args,"./logs");
+ String log_level = getArg(Config.CADI_LOGLEVEL,args,"INFO");
+ File logs = new File(log_dir);
+ if(!logs.isDirectory()) {
+ logs.delete();
+ }
+ if(!logs.exists()) {
+ logs.mkdirs();
+ }
+ Log4JLogIt logIt = new Log4JLogIt(log_dir,log_level,propsFile, "locate");
+ PropAccess propAccess = new PropAccess(logIt,args);
+
AAF_Locate service = new AAF_Locate(new AuthzEnv(propAccess));
-// service.env().setLog4JNames("log4j.properties","authz","gw","audit","init","trace");
JettyServiceStarter<AuthzEnv,AuthzTrans> jss = new JettyServiceStarter<AuthzEnv,AuthzTrans>(service);
jss.start();
} catch (Exception e) {
diff --git a/auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/AAF_OAuth.java b/auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/AAF_OAuth.java
index 1dac22fc..846d1a53 100644
--- a/auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/AAF_OAuth.java
+++ b/auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/AAF_OAuth.java
@@ -22,6 +22,7 @@
package org.onap.aaf.auth.oauth;
+import java.io.File;
import java.util.Map;
import javax.servlet.Filter;
@@ -45,6 +46,7 @@ import org.onap.aaf.auth.rserv.HttpCode;
import org.onap.aaf.auth.rserv.HttpMethods;
import org.onap.aaf.auth.server.AbsService;
import org.onap.aaf.auth.server.JettyServiceStarter;
+import org.onap.aaf.auth.server.Log4JLogIt;
import org.onap.aaf.cadi.CadiException;
import org.onap.aaf.cadi.LocatorException;
import org.onap.aaf.cadi.PropAccess;
@@ -183,10 +185,21 @@ public class AAF_OAuth extends AbsService<AuthzEnv,AuthzTrans> {
}
public static void main(final String[] args) {
- PropAccess propAccess = new PropAccess(args);
try {
+ String propsFile = getArg(AAF_LOG4J_PREFIX, args, "org.osaaf")+".log4j.props";
+ String log_dir = getArg(Config.CADI_LOGDIR,args,"./logs");
+ String log_level = getArg(Config.CADI_LOGLEVEL,args,"INFO");
+ File logs = new File(log_dir);
+ if(!logs.isDirectory()) {
+ logs.delete();
+ }
+ if(!logs.exists()) {
+ logs.mkdirs();
+ }
+ Log4JLogIt logIt = new Log4JLogIt(log_dir,log_level,propsFile, "oauth");
+ PropAccess propAccess = new PropAccess(logIt,args);
+
AAF_OAuth service = new AAF_OAuth(new AuthzEnv(propAccess));
-// env.setLog4JNames("log4j.properties","authz","oauth","audit","init","trace");
JettyServiceStarter<AuthzEnv,AuthzTrans> jss = new JettyServiceStarter<AuthzEnv,AuthzTrans>(service);
jss.start();
} catch (Exception e) {
diff --git a/auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/DirectOAuthTAF.java b/auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/DirectOAuthTAF.java
index e602e863..16d72686 100644
--- a/auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/DirectOAuthTAF.java
+++ b/auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/DirectOAuthTAF.java
@@ -101,6 +101,7 @@ public class DirectOAuthTAF implements HttpTaf {
}
if("application/x-www-form-urlencoded".equals(req.getContentType())) {
+ @SuppressWarnings("unchecked")
Map<String, String[]> map = req.getParameterMap();
String client_id=null,client_secret=null,username=null,password=null;
for(Map.Entry<String, String[]> es : map.entrySet()) {
diff --git a/auth/auth-service/.gitignore b/auth/auth-service/.gitignore
index 6028f0a5..f3bad092 100644
--- a/auth/auth-service/.gitignore
+++ b/auth/auth-service/.gitignore
@@ -2,3 +2,4 @@
/.settings/
/target/
/.project
+/logs/
diff --git a/auth/auth-service/pom.xml b/auth/auth-service/pom.xml
index 7f806f84..4acec253 100644
--- a/auth/auth-service/pom.xml
+++ b/auth/auth-service/pom.xml
@@ -28,7 +28,6 @@
<properties>
<maven.test.failure.ignore>true</maven.test.failure.ignore>
<!-- SONAR -->
- <sonar.skip>true</sonar.skip>
<jacoco.version>0.7.7.201606060606</jacoco.version>
<sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version>
<sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin>
@@ -90,11 +89,6 @@
<artifactId>jetty-servlet</artifactId>
</dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </dependency>
-
</dependencies>
<build>
diff --git a/auth/auth-service/src/main/java/org/onap/aaf/auth/service/AAF_Service.java b/auth/auth-service/src/main/java/org/onap/aaf/auth/service/AAF_Service.java
index ad9ccc4a..0040912f 100644
--- a/auth/auth-service/src/main/java/org/onap/aaf/auth/service/AAF_Service.java
+++ b/auth/auth-service/src/main/java/org/onap/aaf/auth/service/AAF_Service.java
@@ -21,6 +21,8 @@
package org.onap.aaf.auth.service;
+import java.io.File;
+
import javax.servlet.Filter;
import org.onap.aaf.auth.cache.Cache;
@@ -38,6 +40,7 @@ import org.onap.aaf.auth.org.OrganizationFactory;
import org.onap.aaf.auth.rserv.HttpMethods;
import org.onap.aaf.auth.server.AbsService;
import org.onap.aaf.auth.server.JettyServiceStarter;
+import org.onap.aaf.auth.server.Log4JLogIt;
import org.onap.aaf.auth.service.api.API_Api;
import org.onap.aaf.auth.service.api.API_Approval;
import org.onap.aaf.auth.service.api.API_Creds;
@@ -59,6 +62,7 @@ import org.onap.aaf.cadi.aaf.v2_0.AbsAAFLocator;
import org.onap.aaf.cadi.config.Config;
import org.onap.aaf.cadi.register.Registrant;
import org.onap.aaf.cadi.taf.basic.BasicHttpTaf;
+import org.onap.aaf.cadi.util.FQI;
import org.onap.aaf.misc.env.APIException;
import org.onap.aaf.misc.env.Data;
import org.onap.aaf.misc.env.Env;
@@ -68,12 +72,8 @@ import com.datastax.driver.core.Cluster;
public class AAF_Service extends AbsService<AuthzEnv,AuthzTrans> {
private static final String ORGANIZATION = "Organization.";
- private static final String DOMAIN = "aaf.att.com";
-// TODO Add Service Metrics
-// private Metric serviceMetric;
public final Question question;
-// private final SessionFilter sessionFilter;
private AuthzFacade_2_0 facade;
private AuthzFacade_2_0 facade_XML;
private DirectAAFUserPass directAAFUserPass;
@@ -160,13 +160,14 @@ public class AAF_Service extends AbsService<AuthzEnv,AuthzTrans> {
@Override
public Filter[] filters() throws CadiException {
+ final String domain = FQI.reverseDomain(access.getProperty("aaf_root_ns","org.osaaf.aaf"));
try {
return new Filter[] {new AuthzTransFilter(env, null /* no connection to AAF... it is AAF */,
new AAFTrustChecker((Env)env),
new DirectAAFLur(env,question), // Note, this will be assigned by AuthzTransFilter to TrustChecker
//new DirectOAuthTAF(env,question,OAFacadeFactory.directV1_0(oauthService)),
new BasicHttpTaf(env, directAAFUserPass,
- DOMAIN,Long.parseLong(env.getProperty(Config.AAF_CLEAN_INTERVAL, Config.AAF_CLEAN_INTERVAL_DEF)),
+ domain,Long.parseLong(env.getProperty(Config.AAF_CLEAN_INTERVAL, Config.AAF_CLEAN_INTERVAL_DEF)),
false)
)};
} catch (NumberFormatException e) {
@@ -214,10 +215,21 @@ public class AAF_Service extends AbsService<AuthzEnv,AuthzTrans> {
* Start up AAF_Service as Jetty Service
*/
public static void main(final String[] args) {
- PropAccess propAccess = new PropAccess(args);
try {
- AAF_Service service = new AAF_Service(new AuthzEnv(propAccess));
-// service.env().setLog4JNames("log4j.properties","authz","authz|service","audit","init","trace");
+ String propsFile = getArg(AAF_LOG4J_PREFIX, args, "org.osaaf")+".log4j.props";
+ String log_dir = getArg(Config.CADI_LOGDIR,args,"./logs");
+ String log_level = getArg(Config.CADI_LOGLEVEL,args,"INFO");
+ File logs = new File(log_dir);
+ if(!logs.isDirectory()) {
+ logs.delete();
+ }
+ if(!logs.exists()) {
+ logs.mkdirs();
+ }
+ Log4JLogIt logIt = new Log4JLogIt(log_dir,log_level,propsFile, "authz");
+ PropAccess propAccess = new PropAccess(logIt,args);
+
+ AbsService<AuthzEnv, AuthzTrans> service = new AAF_Service(new AuthzEnv(propAccess));
JettyServiceStarter<AuthzEnv,AuthzTrans> jss = new JettyServiceStarter<AuthzEnv,AuthzTrans>(service);
jss.start();
} catch (Exception e) {