Add ability for BAuth by domain
[aaf/authz.git] / auth / auth-service / src / main / java / org / onap / aaf / auth / service / AAF_Service.java
index ad9ccc4..4064000 100644 (file)
@@ -38,6 +38,7 @@ import org.onap.aaf.auth.org.OrganizationFactory;
 import org.onap.aaf.auth.rserv.HttpMethods;
 import org.onap.aaf.auth.server.AbsService;
 import org.onap.aaf.auth.server.JettyServiceStarter;
+import org.onap.aaf.auth.server.Log4JLogIt;
 import org.onap.aaf.auth.service.api.API_Api;
 import org.onap.aaf.auth.service.api.API_Approval;
 import org.onap.aaf.auth.service.api.API_Creds;
@@ -53,12 +54,14 @@ import org.onap.aaf.auth.service.facade.AuthzFacadeFactory;
 import org.onap.aaf.auth.service.facade.AuthzFacade_2_0;
 import org.onap.aaf.auth.service.mapper.Mapper.API;
 import org.onap.aaf.cadi.CadiException;
+import org.onap.aaf.cadi.LocatorException;
 import org.onap.aaf.cadi.PropAccess;
 import org.onap.aaf.cadi.aaf.v2_0.AAFTrustChecker;
 import org.onap.aaf.cadi.aaf.v2_0.AbsAAFLocator;
 import org.onap.aaf.cadi.config.Config;
 import org.onap.aaf.cadi.register.Registrant;
 import org.onap.aaf.cadi.taf.basic.BasicHttpTaf;
+import org.onap.aaf.cadi.util.FQI;
 import org.onap.aaf.misc.env.APIException;
 import org.onap.aaf.misc.env.Data;
 import org.onap.aaf.misc.env.Env;
@@ -68,12 +71,8 @@ import com.datastax.driver.core.Cluster;
 public class AAF_Service extends AbsService<AuthzEnv,AuthzTrans> {
 
        private static final String ORGANIZATION = "Organization.";
-       private static final String DOMAIN = "aaf.att.com";
 
-// TODO Add Service Metrics
-//     private Metric serviceMetric;
        public final Question question;
-//     private final SessionFilter sessionFilter;
        private AuthzFacade_2_0 facade;
        private AuthzFacade_2_0 facade_XML;
        private DirectAAFUserPass directAAFUserPass;
@@ -159,21 +158,31 @@ public class AAF_Service extends AbsService<AuthzEnv,AuthzTrans> {
        }
        
        @Override
-       public Filter[] filters() throws CadiException {
+       public Filter[] _filters(Object ... additionalTafLurs) throws CadiException, LocatorException {
+               final String domain = FQI.reverseDomain(access.getProperty(Config.AAF_ROOT_NS,Config.AAF_ROOT_NS_DEF));
                try {
-                               return new Filter[] {new AuthzTransFilter(env, null /* no connection to AAF... it is AAF */,
-                                               new AAFTrustChecker((Env)env),
-                                               new DirectAAFLur(env,question), // Note, this will be assigned by AuthzTransFilter to TrustChecker
-                                               //new DirectOAuthTAF(env,question,OAFacadeFactory.directV1_0(oauthService)),
-                                               new BasicHttpTaf(env, directAAFUserPass,
-                                                       DOMAIN,Long.parseLong(env.getProperty(Config.AAF_CLEAN_INTERVAL, Config.AAF_CLEAN_INTERVAL_DEF)),
-                                                       false)
-                                       )};
+               Object[] atl=new Object[additionalTafLurs.length+2];
+               atl[0]=new DirectAAFLur(env,question); // Note, this will be assigned by AuthzTransFilter to TrustChecker
+                       atl[1]= new BasicHttpTaf(env, directAAFUserPass,
+                                       domain,Long.parseLong(env.getProperty(Config.AAF_CLEAN_INTERVAL, Config.AAF_CLEAN_INTERVAL_DEF)),
+                                       false);
+
+               if(additionalTafLurs.length>0) {
+                       System.arraycopy(additionalTafLurs, 0, atl, 2, additionalTafLurs.length);
+               }
+               
+                       return new Filter[] {
+                               new AuthzTransFilter(env,aafCon(),
+                               new AAFTrustChecker((Env)env),
+                               atl
+               )};
                } catch (NumberFormatException e) {
                        throw new CadiException("Invalid Property information", e);
                }
        }
 
+
+
        @SuppressWarnings("unchecked")
        @Override
        public Registrant<AuthzEnv>[] registrants(final int port) throws CadiException {
@@ -214,10 +223,11 @@ public class AAF_Service extends AbsService<AuthzEnv,AuthzTrans> {
         * Start up AAF_Service as Jetty Service
         */
        public static void main(final String[] args) {
-               PropAccess propAccess = new PropAccess(args);
                try {
-                       AAF_Service service = new AAF_Service(new AuthzEnv(propAccess));
-//                     service.env().setLog4JNames("log4j.properties","authz","authz|service","audit","init","trace");
+                       Log4JLogIt logIt = new Log4JLogIt(args, "authz");
+                       PropAccess propAccess = new PropAccess(logIt,args);
+                       
+                       AbsService<AuthzEnv, AuthzTrans> service = new AAF_Service(new AuthzEnv(propAccess));
                        JettyServiceStarter<AuthzEnv,AuthzTrans> jss = new JettyServiceStarter<AuthzEnv,AuthzTrans>(service);
                        jss.start();
                } catch (Exception e) {