From 39596f5b6d2c67d8c2b357243ecfb2dd6d746796 Mon Sep 17 00:00:00 2001 From: Instrumental Date: Thu, 7 Feb 2019 18:53:11 -0600 Subject: Minor fixes starting from Scratch Issue-ID: AAF-698 Change-Id: Ie279c11f9f385e9cb179cbe3e16de35cbfa33ecf Signed-off-by: Instrumental --- .../main/java/org/onap/aaf/auth/batch/Batch.java | 3 ++ .../org/onap/aaf/auth/dao/cass/DelegateDAO.java | 6 ++-- .../org/onap/aaf/auth/org/OrganizationFactory.java | 2 +- .../onap/aaf/auth/server/AbsServiceStarter.java | 7 ++-- .../onap/aaf/auth/server/JettyServiceStarter.java | 2 +- .../aaf/auth/org/test/JU_OrganizationFactory.java | 9 ++--- .../aaf/auth/server/test/JU_AbsServiceStarter.java | 38 ++++------------------ .../aaf/auth/service/AuthzCassServiceImpl.java | 5 ++- .../onap/aaf/auth/service/mapper/Mapper_2_0.java | 2 +- auth/docker/d.props.init | 1 + 10 files changed, 22 insertions(+), 53 deletions(-) diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/Batch.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/Batch.java index d49f4faf..543564d9 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/Batch.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/Batch.java @@ -122,6 +122,9 @@ public abstract class Batch { } org = OrganizationFactory.init(env); + if(org==null) { + throw new OrganizationException("Organization MUST be defined for Batch"); + } org.setTestMode(dryRun); // Special names to allow behaviors beyond normal rules diff --git a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/DelegateDAO.java b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/DelegateDAO.java index ad862176..e7749bd5 100644 --- a/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/DelegateDAO.java +++ b/auth/auth-cass/src/main/java/org/onap/aaf/auth/dao/cass/DelegateDAO.java @@ -60,9 +60,9 @@ public class DelegateDAO extends CassDAOImpl { public static class Data implements Bytification { - public static String user; - public static String delegate; - public static Date expires; + public String user; + public String delegate; + public Date expires; @Override public ByteBuffer bytify() throws IOException { diff --git a/auth/auth-core/src/main/java/org/onap/aaf/auth/org/OrganizationFactory.java b/auth/auth-core/src/main/java/org/onap/aaf/auth/org/OrganizationFactory.java index 40c8c2d3..f4e6d14e 100644 --- a/auth/auth-core/src/main/java/org/onap/aaf/auth/org/OrganizationFactory.java +++ b/auth/auth-core/src/main/java/org/onap/aaf/auth/org/OrganizationFactory.java @@ -71,7 +71,7 @@ public class OrganizationFactory { String realm = env.getProperty(Config.AAF_DEFAULT_REALM,"people.osaaf.org"); defaultOrg = cnst.newInstance(env,realm); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | SecurityException | IllegalArgumentException | InvocationTargetException e) { - throw new OrganizationException("At least one Organization must be defined",e); + env.warn().log("Not Organization Moduled linked in",e); } } if (defaultOrg == null) { 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 1bc367e6..fe610e57 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 @@ -23,7 +23,6 @@ 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; @@ -41,15 +40,13 @@ public abstract class AbsServiceStarter service; - public AbsServiceStarter(final AbsService service, boolean noexit) { + public AbsServiceStarter(final AbsService service) { this.service = service; try { OrganizationFactory.init(service.env); } catch (OrganizationException e) { service.access.log(e, "Missing defined Organization Plugins"); - if(!noexit) { - System.exit(3); - } + System.exit(3); } // do_register - this is used for specialty Debug Situations. Developer can create an Instance for a remote system // for Debugging purposes without fear that real clients will start to call your debug instance 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 98503d11..413b7919 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 @@ -59,7 +59,7 @@ public class JettyServiceStarter ex private boolean secure; public JettyServiceStarter(final AbsService service) throws OrganizationException { - super(service,false); + super(service); secure = true; } diff --git a/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_OrganizationFactory.java b/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_OrganizationFactory.java index 36d071fd..20b47331 100644 --- a/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_OrganizationFactory.java +++ b/auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_OrganizationFactory.java @@ -55,13 +55,8 @@ public class JU_OrganizationFactory { @SuppressWarnings("static-access") @Test - public void testInit() { - try { - organizationFactory.init(bEnv); - Assert.fail("Expect an exception"); - } catch (OrganizationException e) { - Assert.assertEquals("At least one Organization must be defined", e.getMessage()); - } + public void testInit() throws OrganizationException { + Assert.assertEquals(null, organizationFactory.init(bEnv)); } @SuppressWarnings("static-access") //TODO:Fix this once real input is available AAF-111 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 04d58d6b..9b49216d 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 @@ -21,51 +21,25 @@ package org.onap.aaf.auth.server.test; -import static org.junit.Assert.*; +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; + +import javax.servlet.Filter; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.onap.aaf.auth.env.AuthzTrans; -import org.onap.aaf.auth.env.AuthzTransFilter; -import org.onap.aaf.auth.local.AbsData; -import org.onap.aaf.auth.local.DataFile; -import org.onap.aaf.auth.local.TextIndex; import org.onap.aaf.auth.rserv.RServlet; import org.onap.aaf.auth.server.AbsService; import org.onap.aaf.auth.server.AbsServiceStarter; -import org.onap.aaf.auth.server.test.JU_AbsService; import org.onap.aaf.cadi.Access; +import org.onap.aaf.cadi.Access.Level; import org.onap.aaf.cadi.CadiException; import org.onap.aaf.cadi.LocatorException; import org.onap.aaf.cadi.PropAccess; -import org.onap.aaf.cadi.Access.Level; import org.onap.aaf.cadi.config.Config; import org.onap.aaf.cadi.register.Registrant; import org.onap.aaf.misc.env.impl.BasicEnv; -import org.onap.aaf.auth.local.AbsData.Iter; -import org.onap.aaf.auth.local.AbsData.Reuse; - -import junit.framework.Assert; - -import static org.junit.Assert.*; -import static org.mockito.Matchers.*; -import static org.mockito.Mockito.*; - -import java.io.BufferedWriter; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.PrintStream; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.security.Principal; - -import javax.servlet.Filter; public class JU_AbsServiceStarter { @@ -76,7 +50,7 @@ public class JU_AbsServiceStarter { private class AbsServiceStarterStub extends AbsServiceStarter { public AbsServiceStarterStub(AbsService service) { - super(service, true); + super(service); // TODO Auto-generated constructor stub } diff --git a/auth/auth-service/src/main/java/org/onap/aaf/auth/service/AuthzCassServiceImpl.java b/auth/auth-service/src/main/java/org/onap/aaf/auth/service/AuthzCassServiceImpl.java index 67bf3b50..3bc06f11 100644 --- a/auth/auth-service/src/main/java/org/onap/aaf/auth/service/AuthzCassServiceImpl.java +++ b/auth/auth-service/src/main/java/org/onap/aaf/auth/service/AuthzCassServiceImpl.java @@ -33,7 +33,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; -import java.util.Comparator; import java.util.Date; import java.util.GregorianCalendar; import java.util.HashMap; @@ -2665,7 +2664,7 @@ public class AuthzCassServiceImpl