summaryrefslogtreecommitdiffstats
path: root/auth/auth-core
diff options
context:
space:
mode:
Diffstat (limited to 'auth/auth-core')
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/org/OrganizationFactory.java12
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsServiceStarter.java8
-rw-r--r--auth/auth-core/src/main/java/org/onap/aaf/auth/server/JettyServiceStarter.java2
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/org/test/JU_OrganizationFactory.java15
-rw-r--r--auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java2
5 files changed, 30 insertions, 9 deletions
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 33201864..40c8c2d3 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
@@ -28,6 +28,7 @@ import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import org.onap.aaf.auth.env.AuthzTrans;
+import org.onap.aaf.cadi.config.Config;
import org.onap.aaf.cadi.util.FQI;
import org.onap.aaf.cadi.util.Split;
import org.onap.aaf.misc.env.Env;
@@ -62,6 +63,17 @@ public class OrganizationFactory {
}
}
}
+ if(firstOrg==null) { // attempt to load DefaultOrg
+ try {
+ Class<?> cls = Class.forName("org.onap.aaf.org.DefaultOrg");
+ @SuppressWarnings("unchecked")
+ Constructor<Organization> cnst = (Constructor<Organization>)cls.getConstructor(Env.class,String.class);
+ 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);
+ }
+ }
if (defaultOrg == null) {
defaultOrg = firstOrg;
}
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 8f0eb8aa..1bc367e6 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
@@ -41,13 +41,15 @@ public abstract class AbsServiceStarter<ENV extends RosettaEnv, TRANS extends Tr
protected AbsService<ENV,TRANS> service;
- public AbsServiceStarter(final AbsService<ENV,TRANS> service) {
+ public AbsServiceStarter(final AbsService<ENV,TRANS> service, boolean noexit) {
this.service = service;
try {
OrganizationFactory.init(service.env);
} catch (OrganizationException e) {
- service.access.log(e, "Missing defined Organzation Plugins");
- System.exit(3);
+ service.access.log(e, "Missing defined Organization Plugins");
+ if(!noexit) {
+ 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 413b7919..98503d11 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<ENV extends RosettaEnv, TRANS extends Trans> ex
private boolean secure;
public JettyServiceStarter(final AbsService<ENV,TRANS> service) throws OrganizationException {
- super(service);
+ super(service,false);
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 5124a506..36d071fd 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
@@ -22,20 +22,22 @@
package org.onap.aaf.auth.org.test;
+import static org.mockito.Mockito.mock;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
-import static org.mockito.Mockito.mock;
import org.onap.aaf.auth.env.AuthzEnv;
import org.onap.aaf.auth.env.AuthzTrans;
import org.onap.aaf.auth.org.OrganizationException;
import org.onap.aaf.auth.org.OrganizationFactory;
-import org.onap.aaf.misc.env.APIException;
import org.onap.aaf.misc.env.impl.BasicEnv;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.modules.junit4.PowerMockRunner;
+import junit.framework.Assert;
+
@RunWith(PowerMockRunner.class)
public class JU_OrganizationFactory {
private static final String ORG_SLOT = null;
@@ -53,8 +55,13 @@ public class JU_OrganizationFactory {
@SuppressWarnings("static-access")
@Test
- public void testInit() throws OrganizationException {
- organizationFactory.init(bEnv);
+ 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());
+ }
}
@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 2fa9e123..04d58d6b 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
@@ -76,7 +76,7 @@ public class JU_AbsServiceStarter {
private class AbsServiceStarterStub extends AbsServiceStarter {
public AbsServiceStarterStub(AbsService service) {
- super(service);
+ super(service, true);
// TODO Auto-generated constructor stub
}