JettyStartups to improve new Filters 97/55297/2
authorInstrumental <jonathan.gathman@att.com>
Sat, 23 Jun 2018 16:01:25 +0000 (11:01 -0500)
committerInstrumental <jonathan.gathman@att.com>
Sat, 23 Jun 2018 16:13:11 +0000 (11:13 -0500)
Issue-ID: AAF-361
Change-Id: I74cac231ebac81466778c1c3ebca16c63ae6f78a
Signed-off-by: Instrumental <jonathan.gathman@att.com>
15 files changed:
auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/AAF_CM.java
auth/auth-core/src/main/java/org/onap/aaf/auth/server/AbsService.java
auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsService.java
auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_AbsServiceStarter.java
auth/auth-core/src/test/java/org/onap/aaf/auth/server/test/JU_JettyServiceStarter.java
auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java
auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/AAF_GUI.java
auth/auth-hello/src/main/java/org/onap/aaf/auth/hello/AAF_Hello.java
auth/auth-locate/src/main/java/org/onap/aaf/auth/locate/AAF_Locate.java
auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/AAF_OAuth.java
auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/DirectOAuthTAF.java
auth/auth-oauth/src/main/java/org/onap/aaf/auth/oauth/mapper/Mapper1_0.java
auth/auth-service/src/main/java/org/onap/aaf/auth/service/AAF_Service.java
cadi/core/src/main/java/org/onap/aaf/cadi/config/Config.java
cadi/core/src/test/java/org/onap/aaf/cadi/lur/test/JU_LocalLur.java

index 5c5ab96..17a42fc 100644 (file)
@@ -201,11 +201,12 @@ public class AAF_CM extends AbsService<AuthzEnv, AuthzTrans> {
        }
 
        @Override
-       public Filter[] filters() throws CadiException, LocatorException {
+       public Filter[] _filters(Object ... additionalTafLurs) throws CadiException, LocatorException {
                try {
                        return new Filter[] {
                                        new AuthzTransFilter(env,aafCon(),
-                                               new AAFTrustChecker((Env)env))
+                                       new AAFTrustChecker((Env)env),
+                                       additionalTafLurs)
                                };
                } catch (NumberFormatException e) {
                        throw new CadiException("Invalid Property information", e);
index d8c7311..af6c88d 100644 (file)
@@ -104,8 +104,18 @@ public abstract class AbsService<ENV extends BasicEnv, TRANS extends Trans> exte
                }
     }
 
-       public abstract Filter[] filters() throws CadiException,  LocatorException;
-
+       protected abstract Filter[] _filters(Object ... additionalTafLurs) throws CadiException,  LocatorException;
+       
+       /**
+        * Overload this method to add new TAF or LURs
+        * 
+        * @return
+        * @throws CadiException
+        * @throws LocatorException
+        */
+       public Filter[] filters() throws CadiException,  LocatorException {
+               return _filters();
+       }
 
     public abstract Registrant<ENV>[] registrants(final int port) throws CadiException, LocatorException;
 
index 453eeb8..cd73e86 100644 (file)
@@ -73,7 +73,7 @@ public class JU_AbsService {
                }
 
                @Override
-               public Filter[] filters() throws CadiException, LocatorException {
+               public Filter[] _filters(Object ... additionalTafLurs) throws CadiException, LocatorException {
                        // TODO Auto-generated method stub
                        return null;
                }
index 071a0f8..1a3f441 100644 (file)
@@ -100,7 +100,7 @@ public class JU_AbsServiceStarter {
                }
 
                @Override
-               public Filter[] filters() throws CadiException, LocatorException {
+               public Filter[] _filters(Object ... additionalTafLurs) throws CadiException, LocatorException {
                        // TODO Auto-generated method stub
                        return null;
                }
index 9a02b63..13bac17 100644 (file)
@@ -59,7 +59,7 @@ public class JU_JettyServiceStarter {
                }
 
                @Override
-               public Filter[] filters() throws CadiException, LocatorException {
+               public Filter[] _filters(Object ... additionalTafLurs) throws CadiException, LocatorException {
                        // TODO Auto-generated method stub
                        return null;
                }
index 0359b3e..ec50733 100644 (file)
@@ -88,7 +88,8 @@ public class AAF_FS extends AbsService<AuthzEnv, AuthzTrans>  {
        };
        
        @Override
-       public Filter[] filters() throws CadiException, LocatorException {
+       public Filter[] _filters(Object ... additionalTafLurs) throws CadiException, LocatorException {
+               // Note: No TAFs and Lurs on FileServer
                return new Filter[] {
                        new AuthzTransOnlyFilter(env)
                };
index 23713d8..3f26bad 100644 (file)
@@ -230,13 +230,15 @@ public class AAF_GUI extends AbsService<AuthzEnv, AuthzTrans> implements State<E
        public<RET> RET cmClientAsUser(TaggedPrincipal p,Retryable<RET> retryable) throws APIException, LocatorException, CadiException  {
                        return cmCon.hman().best(new HTransferSS(p,app, aafCon.securityInfo()), retryable);
        }
+       
        @Override
-       public Filter[] filters() throws CadiException, LocatorException {
+       public Filter[] _filters(Object ... additionalTafLurs) throws CadiException, LocatorException {
                try {
                        return new Filter[] {
                                        new XFrameFilter(XFrameFilter.TYPE.none),
                                        new AuthzTransFilter(env,aafCon(),
-                                               new AAFTrustChecker((Env)env)),
+                                               new AAFTrustChecker((Env)env),
+                                               additionalTafLurs),
                                        new OrgLookupFilter()
                                };
                } catch (NumberFormatException e) {
index 8a85b4e..9617f19 100644 (file)
@@ -97,11 +97,12 @@ public class AAF_Hello extends AbsService<AuthzEnv,AuthzTrans> {
        }
        
        @Override
-       public Filter[] filters() throws CadiException, LocatorException {
+       public Filter[] _filters(Object ... additionalTafLurs) throws CadiException, LocatorException {
                try {
                        return new Filter[] {
                                        new AuthzTransFilter(env,aafCon(),
-                                               new AAFTrustChecker((Env)env))
+                                       new AAFTrustChecker((Env)env),
+                                       additionalTafLurs)
                                };
                } catch (NumberFormatException e) {
                        throw new CadiException("Invalid Property information", e);
index 1cf3afb..efda67f 100644 (file)
@@ -202,11 +202,12 @@ public class AAF_Locate extends AbsService<AuthzEnv, AuthzTrans> {
 
 
        @Override
-       public Filter[] filters() throws CadiException, LocatorException {
+       public Filter[] _filters(Object ... additionalTafLurs) throws CadiException, LocatorException {
                try {
                        return new Filter[] {
                                new AuthzTransFilter(env, aafCon(), 
                                        new AAFTrustChecker((Env)env)
+                                       ,additionalTafLurs
                                )};
                } catch (NumberFormatException e) {
                        throw new CadiException("Invalid Property information", e);
index ecc2ae5..d73c3be 100644 (file)
@@ -140,19 +140,26 @@ public class AAF_OAuth extends AbsService<AuthzEnv,AuthzTrans> {
        }
        
        @Override
-       public Filter[] filters() throws CadiException, LocatorException {
+       public Filter[] _filters(Object ... additionalTafLurs) throws CadiException, LocatorException {
                try {
-               DirectOAuthTAF doat;
-                       return new Filter[] {new AuthzTransFilter(env,aafCon(),
+               DirectOAuthTAF doat = new DirectOAuthTAF(env,question,facade1_0);
+               Object[] atl=new Object[additionalTafLurs.length+2];
+               atl[0] = doat;
+               atl[1] = doat.directUserPass();
+
+               if(additionalTafLurs.length>0) {
+                       System.arraycopy(additionalTafLurs, 0, atl, 2, additionalTafLurs.length);
+               }
+               
+                       return new Filter[] {
+                               new AuthzTransFilter(env,aafCon(),
                                new AAFTrustChecker((Env)env),
-                               doat = new DirectOAuthTAF(env,question,facade1_0),
-                               doat.directUserPass()
-                               )};
+                               atl
+               )};
                } catch (NumberFormatException | APIException e) {
                        throw new CadiException("Invalid Property information", e);
                }
        }
-
        
        @SuppressWarnings("unchecked")
        @Override
index 16d7268..e602e86 100644 (file)
@@ -101,7 +101,6 @@ public class DirectOAuthTAF implements HttpTaf {
                }
 
                if("application/x-www-form-urlencoded".equals(req.getContentType())) {
-                       @SuppressWarnings("unchecked")
                        Map<String, String[]> map = req.getParameterMap();
                        String client_id=null,client_secret=null,username=null,password=null;
                        for(Map.Entry<String, String[]> es : map.entrySet()) {
index ee4237c..688a03c 100644 (file)
@@ -88,7 +88,6 @@ public class Mapper1_0 extends MapperIntrospect1_0 implements Mapper<TokenReques
        public TokenRequest tokenReqFromParams(HttpServletRequest req) {
                TokenRequest tr = new TokenRequest();
                boolean data = false;
-               @SuppressWarnings("unchecked")
                Map<String, String[]> map = req.getParameterMap();
                for(Entry<String, String[]> es : map.entrySet()) {
                        switch(es.getKey()) {
index bdabc39..3ae2fbf 100644 (file)
@@ -54,6 +54,7 @@ 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;
@@ -157,22 +158,31 @@ public class AAF_Service extends AbsService<AuthzEnv,AuthzTrans> {
        }
        
        @Override
-       public Filter[] filters() throws CadiException {
-               final String domain = FQI.reverseDomain(access.getProperty("aaf_root_ns","org.osaaf.aaf"));
+       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 {
index 7c897e3..c79c5cc 100644 (file)
@@ -143,6 +143,7 @@ public class Config {
        public static final String AAF_ENV = "aaf_env";
        public static final String AAF_URL = "aaf_url"; //URL for AAF... Use to trigger AAF configuration
        public static final String AAF_ROOT_NS = "aaf_root_ns";
+       public static final String AAF_ROOT_NS_DEF = "org.osaaf.aaf";
        public static final String AAF_ROOT_COMPANY = "aaf_root_company";
        public static final String AAF_LOCATE_URL = "aaf_locate_url"; //URL for AAF locator
        private static final String AAF_LOCATE_URL_TAG = "AAF_LOCATE_URL"; // Name of Above for use in Config Variables.
index d86a075..f61d1ca 100644 (file)
@@ -48,8 +48,6 @@ import org.onap.aaf.cadi.lur.LocalPermission;
 public class JU_LocalLur {
 
        private static final String password = "<pass>";
-       private String encrypted;
-
        private PropAccess access;
        private ByteArrayOutputStream outStream;
 
@@ -59,8 +57,6 @@ public class JU_LocalLur {
        public void setup() throws IOException {
                MockitoAnnotations.initMocks(this);
 
-               encrypted = rot13(password);
-
                outStream = new ByteArrayOutputStream();
                access = new PropAccess(new PrintStream(outStream), new String[0]) {
                        @Override public String decrypt(String encrypted, boolean anytext) throws IOException {
@@ -75,6 +71,8 @@ public class JU_LocalLur {
 
        @Test
        public void test() throws IOException {
+               final String encrypted = rot13(password);
+
                LocalLur lur;
                List<AbsUserCache<LocalPermission>.DumpInfo> info;