* 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.
/**
* Organization Plugin Mechanism
- *
- * Define a NameSpace for the company (i.e. com.att), and put in Properties as
- * "Organization.[your NS" and assign the supporting Class.
- *
+ *
+ * Define a NameSpace for the company (i.e. com.att), and put in Properties as
+ * "Organization.[your NS" and assign the supporting Class.
+ *
* Example:
* Organization.com.att=org.onap.aaf.auth.org.test.att.ATT
*
public static Organization init(BasicEnv env) throws OrganizationException {
int idx = ORGANIZATION_DOT.length();
Organization org,firstOrg = null;
-
+
for (Entry<Object, Object> es : env.getProperties().entrySet()) {
String key = es.getKey().toString();
if (key.startsWith(ORGANIZATION_DOT)) {
}
}
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) {
- env.init().log("Default Organization Module not linked in",e);
- }
+ 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) {
+ env.init().log("Default Organization Module not linked in",e);
+ }
}
if (defaultOrg == null) {
defaultOrg = firstOrg;
org.addSupportedRealm(r);
}
}
- } catch (ClassNotFoundException | NoSuchMethodException | SecurityException |
- InstantiationException | IllegalAccessException | IllegalArgumentException |
+ } catch (ClassNotFoundException | NoSuchMethodException | SecurityException |
+ InstantiationException | IllegalAccessException | IllegalArgumentException |
InvocationTargetException e) {
env.error().log(e, "Error on Organization Construction");
throw new OrganizationException(e);
}
env.init().printf("Instantiated %s with %s%s",orgNS,orgClass,(isDefault?" as default":""));
}
- if (org==null) {
- if (defaultOrg!=null) {
+ if ( (org==null) && (defaultOrg!=null)){
+
org=defaultOrg;
orgs.put(orgNS, org);
}
}
- }
+
return org;
}
- public static Organization get(AuthzTrans trans) throws OrganizationException {
+ public static Organization get(AuthzTrans trans){
String domain = FQI.reverseDomain(trans.user());
Organization org = orgs.get(domain);
if (org==null) {