summaryrefslogtreecommitdiffstats
path: root/auth/auth-deforg
diff options
context:
space:
mode:
authorInstrumental <jcgmisc@stl.gathman.org>2018-04-18 10:52:42 -0500
committerInstrumental <jcgmisc@stl.gathman.org>2018-04-18 10:52:52 -0500
commit087706284431e63ea77b934859a47beeb59e4592 (patch)
treef96525f12d0a243f35739d6b909ae892068945bf /auth/auth-deforg
parent3c0e04b9064ff069f5e594a5023c2f18ba487e80 (diff)
Support Multiple Realms for DefaultOrg
Issue-ID: AAF-254 Change-Id: I89a9b1ceaa304861debd4c7dd21879e0b1fc902a Signed-off-by: Instrumental <jcgmisc@stl.gathman.org>
Diffstat (limited to 'auth/auth-deforg')
-rw-r--r--auth/auth-deforg/src/main/java/org/onap/aaf/org/DefaultOrg.java21
-rw-r--r--auth/auth-deforg/src/test/java/org/onap/aaf/org/test/JU_DefaultOrg.java5
2 files changed, 25 insertions, 1 deletions
diff --git a/auth/auth-deforg/src/main/java/org/onap/aaf/org/DefaultOrg.java b/auth/auth-deforg/src/main/java/org/onap/aaf/org/DefaultOrg.java
index 5674e247..935f99bf 100644
--- a/auth/auth-deforg/src/main/java/org/onap/aaf/org/DefaultOrg.java
+++ b/auth/auth-deforg/src/main/java/org/onap/aaf/org/DefaultOrg.java
@@ -56,9 +56,12 @@ public class DefaultOrg implements Organization {
final String realm;
private final String NAME,mailHost,mailFrom;
+ private final Set<String> supportedRealms;
public DefaultOrg(Env env, String realm) throws OrganizationException {
this.realm = realm;
+ supportedRealms=new HashSet<String>();
+ supportedRealms.add(realm);
domain=FQI.reverseDomain(realm);
atDomain = '@'+domain;
String s;
@@ -668,5 +671,21 @@ public class DefaultOrg implements Organization {
return addressArray;
}
-
+ private String extractRealm(final String r) {
+ int at;
+ if((at=r.indexOf('@'))>=0) {
+ return FQI.reverseDomain(r.substring(at+1));
+ }
+ return r;
+ }
+ @Override
+ public boolean supportsRealm(final String r) {
+ return supportedRealms.contains(extractRealm(r)) || r.endsWith(realm);
}
+
+ @Override
+ public synchronized void addSupportedRealm(final String r) {
+ supportedRealms.add(extractRealm(r));
+ }
+
+}
diff --git a/auth/auth-deforg/src/test/java/org/onap/aaf/org/test/JU_DefaultOrg.java b/auth/auth-deforg/src/test/java/org/onap/aaf/org/test/JU_DefaultOrg.java
index e6f058a4..d4606284 100644
--- a/auth/auth-deforg/src/test/java/org/onap/aaf/org/test/JU_DefaultOrg.java
+++ b/auth/auth-deforg/src/test/java/org/onap/aaf/org/test/JU_DefaultOrg.java
@@ -109,6 +109,11 @@ public class JU_DefaultOrg {
assertTrue(realmTest == REALM);
}
+ public void supportsRealm() {
+ String otherRealm = "org.ossaf.something";
+ defaultOrg.addSupportedRealm(otherRealm);
+ assertTrue(defaultOrg.supportsRealm(otherRealm));
+ }
//@Test
public void testGetName() throws OrganizationException{
String testName = defaultOrg.getName();