diff options
Diffstat (limited to 'auth/auth-deforg/src')
-rw-r--r-- | auth/auth-deforg/src/main/java/org/onap/aaf/org/DefaultOrg.java | 21 | ||||
-rw-r--r-- | auth/auth-deforg/src/test/java/org/onap/aaf/org/test/JU_DefaultOrg.java | 5 |
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(); |