X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-fs%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Ffs%2FAAF_FS.java;h=76041cef1767e6e58c9e453868ad7ac1ff5a1dcc;hb=ff1417ff60baee231a28272f9a16ef2c9c8ea0a2;hp=50791393762db8a1a4fc1e2674e0374fd27c551c;hpb=71037c39a37d3549dcfe31926832a657744fbe05;p=aaf%2Fauthz.git diff --git a/auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java b/auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java index 50791393..76041cef 100644 --- a/auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java +++ b/auth/auth-fs/src/main/java/org/onap/aaf/auth/fs/AAF_FS.java @@ -36,6 +36,7 @@ import org.onap.aaf.auth.rserv.CachingFileAccess; import org.onap.aaf.auth.rserv.HttpCode; 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.cadi.Access.Level; import org.onap.aaf.cadi.CadiException; import org.onap.aaf.cadi.LocatorException; @@ -48,68 +49,69 @@ import org.onap.aaf.misc.env.APIException; public class AAF_FS extends AbsService { - public AAF_FS(final AuthzEnv env) throws APIException, IOException, CadiException { - super(env.access(),env); - try { - /////////////////////// - // File Server - /////////////////////// - // creates StaticSlot, needed for CachingFileAccess, and sets to public Dir - env.staticSlot(CachingFileAccess.CFA_WEB_PATH,"aaf_public_dir"); + public AAF_FS(final AuthzEnv env) throws APIException, IOException, CadiException { + super(env.access(),env); + try { + /////////////////////// + // File Server + /////////////////////// + // creates StaticSlot, needed for CachingFileAccess, and sets to public Dir + env.staticSlot(CachingFileAccess.CFA_WEB_PATH,"aaf_public_dir"); - CachingFileAccess cfa = new CachingFileAccess(env); - route(env,GET,"/:key", cfa); - route(env,GET,"/:key/:cmd", cfa); - final String aaf_locate_url = access.getProperty(Config.AAF_LOCATE_URL, null); - if(aaf_locate_url == null) { - access.printf(Level.WARN, "Redirection requires property %s",Config.AAF_LOCATE_URL); - } else { - route(env,GET,"/", new Redirect(this,aaf_locate_url)); - } - } catch (Exception e) { - e.printStackTrace(); - } - } - - private static class Redirect extends HttpCode { - private final String url; + CachingFileAccess cfa = new CachingFileAccess(env); + route(env,GET,"/:key*", cfa); + final String aaf_locate_url = access.getProperty(Config.AAF_LOCATE_URL, null); + if (aaf_locate_url == null) { + access.printf(Level.WARN, "Redirection requires property %s",Config.AAF_LOCATE_URL); + } else { + route(env,GET,"/", new Redirect(this,aaf_locate_url)); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + private static class Redirect extends HttpCode { + private final String url; - public Redirect(AAF_FS context,String url) { - super(context, "Redirect to HTTP/S"); - this.url = url; - } + public Redirect(AAF_FS context,String url) { + super(context, "Redirect to HTTP/S"); + this.url = url; + } - @Override - public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { - trans.info().printf("Redirecting %s to HTTP/S %s", req.getRemoteAddr(), req.getLocalAddr()); - resp.sendRedirect(url); - } - }; - - @Override - public Filter[] filters() throws CadiException, LocatorException { - return new Filter[] { - new AuthzTransOnlyFilter(env) - }; - } + @Override + public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception { + trans.info().printf("Redirecting %s to HTTP/S %s", req.getRemoteAddr(), req.getLocalAddr()); + resp.sendRedirect(url); + } + }; + + @Override + public Filter[] _filters(Object ... additionalTafLurs) throws CadiException, LocatorException { + // Note: No TAFs and Lurs on FileServer + return new Filter[] { + new AuthzTransOnlyFilter(env) + }; + } - @SuppressWarnings("unchecked") - @Override - public Registrant[] registrants(final int port) throws CadiException, LocatorException { - return new Registrant[] { - new RemoteRegistrant(aafCon(),app_name,app_version,port) - }; - } - - public static void main(final String[] args) { - PropAccess propAccess = new PropAccess(args); - try { - AAF_FS service = new AAF_FS(new AuthzEnv(propAccess)); -// env.setLog4JNames("log4j.properties","authz","fs","audit","init",null); - JettyServiceStarter jss = new JettyServiceStarter(service); - jss.insecure().start(); - } catch (Exception e) { - e.printStackTrace(); - } - } + @SuppressWarnings("unchecked") + @Override + public Registrant[] registrants(final int port) throws CadiException, LocatorException { + return new Registrant[] { + new RemoteRegistrant(aafCon(),port) + }; + } + + public static void main(final String[] args) { + try { + Log4JLogIt logIt = new Log4JLogIt(args, "fs"); + PropAccess propAccess = new PropAccess(logIt,args); + + AAF_FS service = new AAF_FS(new AuthzEnv(propAccess)); + JettyServiceStarter jss = new JettyServiceStarter(service); + jss.insecure().start(); + } catch (Exception e) { + e.printStackTrace(); + } + } }