diff options
Diffstat (limited to 'auth/auth-gui')
17 files changed, 212 insertions, 58 deletions
diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/cui/CUI.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/cui/CUI.java index 121ee3f7..7859b7cc 100644 --- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/cui/CUI.java +++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/cui/CUI.java @@ -76,11 +76,11 @@ public class CUI extends HttpCode<AuthzTrans, Void> { aafcli.gui(true); String cmdStr = cmd.toString(); - if (!cmdStr.contains("--help")) { - cmdStr = cmdStr.replaceAll("help", "--help"); + if (cmdStr.contains("--help")) { + cmdStr = cmdStr.replaceAll("--help", "help"); } - if (!cmdStr.contains("--version")) { - cmdStr = cmdStr.replaceAll("version", "--version"); + if (cmdStr.contains("--version")) { + cmdStr = cmdStr.replaceAll("--version", "version"); } try { aafcli.eval(cmdStr); diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/AAF_GUI.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/AAF_GUI.java index 064a8a5c..359cb28b 100644 --- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/AAF_GUI.java +++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/AAF_GUI.java @@ -94,7 +94,7 @@ import certman.v1_0.Artifacts; import certman.v1_0.CertInfo; public class AAF_GUI extends AbsService<AuthzEnv, AuthzTrans> implements State<Env>{ - private static final String AAF_GUI_THEME = "aaf_gui_theme"; + public static final String AAF_GUI_THEME = "aaf_gui_theme"; public static final String AAF_GUI_COPYRIGHT = "aaf_gui_copyright"; public static final String HTTP_SERVLET_REQUEST = "HTTP_SERVLET_REQUEST"; public static final int TIMEOUT = 60000; @@ -113,15 +113,18 @@ public class AAF_GUI extends AbsService<AuthzEnv, AuthzTrans> implements State<E public final Slot slot_httpServletRequest; protected final String deployedVersion; private StaticSlot sThemeWebPath; - public final String theme; + private StaticSlot sDefaultTheme; +// public final String theme; public AAF_GUI(final AuthzEnv env) throws Exception { super(env.access(), env); - theme = env.getProperty(AAF_GUI_THEME,"theme/onap"); + sDefaultTheme = env.staticSlot(AAF_GUI_THEME); + env.put(sDefaultTheme, env.getProperty(AAF_GUI_THEME,"onap")); + sThemeWebPath = env.staticSlot(CachingFileAccess.CFA_WEB_PATH); if(env.get(sThemeWebPath)==null) { - env.put(sThemeWebPath,theme); + env.put(sThemeWebPath,"theme"); } slot_httpServletRequest = env.slot(HTTP_SERVLET_REQUEST); @@ -203,7 +206,9 @@ public class AAF_GUI extends AbsService<AuthzEnv, AuthzTrans> implements State<E /////////////////////// // WebContent Handler /////////////////////// - route(env,GET,"/"+env.get(sThemeWebPath)+"/:key", new CachingFileAccess<AuthzTrans>(env)); + CachingFileAccess<AuthzTrans> cfa = new CachingFileAccess<AuthzTrans>(env); + //route(env,GET,"/"+env.get(sThemeWebPath)+"/:key*", cfa); + route(env,GET,"/theme/:key*", cfa); /////////////////////// aafCon = aafCon(); lur = aafCon.newLur(); diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/BreadCrumbs.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/BreadCrumbs.java index 4f1a7e82..621257b2 100644 --- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/BreadCrumbs.java +++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/BreadCrumbs.java @@ -37,7 +37,7 @@ import org.onap.aaf.misc.xgen.Mark; import org.onap.aaf.misc.xgen.html.HTMLGen; public class BreadCrumbs extends NamedCode { - private Page[] breadcrumbs; + Page[] breadcrumbs; public BreadCrumbs(Page ... pages) { super(false,"breadcrumbs"); diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/Display.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/Display.java index de1a8461..877974bd 100644 --- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/Display.java +++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/Display.java @@ -31,7 +31,6 @@ import org.onap.aaf.auth.env.AuthzTrans; import org.onap.aaf.auth.rserv.HttpCode; import org.onap.aaf.auth.rserv.HttpMethods; import org.onap.aaf.misc.env.Slot; -import org.onap.aaf.misc.xgen.html.HTMLGen; public class Display { private final Page get; diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/Page.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/Page.java index 1e067c44..8924ba26 100644 --- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/Page.java +++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/Page.java @@ -27,21 +27,30 @@ import static org.onap.aaf.misc.xgen.html.HTMLGen.LI; import static org.onap.aaf.misc.xgen.html.HTMLGen.TITLE; import static org.onap.aaf.misc.xgen.html.HTMLGen.UL; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.Properties; +import java.util.TreeMap; +import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import org.onap.aaf.auth.common.Define; import org.onap.aaf.auth.env.AuthzEnv; import org.onap.aaf.auth.env.AuthzTrans; -import org.onap.aaf.auth.rserv.CachingFileAccess; +import org.onap.aaf.auth.gui.pages.Home; import org.onap.aaf.cadi.Permission; import org.onap.aaf.cadi.aaf.AAFPermission; +import org.onap.aaf.cadi.client.Holder; import org.onap.aaf.cadi.config.Config; import org.onap.aaf.cadi.principal.TaggedPrincipal; import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.Env; import org.onap.aaf.misc.env.Slot; import org.onap.aaf.misc.env.StaticSlot; import org.onap.aaf.misc.env.util.Split; @@ -71,11 +80,9 @@ public class Page extends HTMLCacheGen { public static final String PERM_NS = Define.ROOT_NS(); public static enum BROWSER {iPhone,html5,ie,ieOld}; - - public static final int MAX_LINE=20; + public static final int MAX_LINE = 20; protected static final String[] NO_FIELDS = new String[0]; - private static final String BROWSER_TYPE = "BROWSER_TYPE"; private final String bcName, bcUrl; @@ -151,14 +158,90 @@ public class Page extends HTMLCacheGen { private final int backdots; protected AuthzEnv env; private StaticSlot sTheme; + private static Map<String,List<String>> themes; + private static Map<String,Properties> themeProps; public PageCode(AuthzEnv env, int backdots, final ContentCode[] content) { this.content = content; this.backdots = backdots; browserSlot = env.slot(BROWSER_TYPE); - sTheme = env.staticSlot(CachingFileAccess.CFA_WEB_PATH); + sTheme = env.staticSlot(AAF_GUI.AAF_GUI_THEME); this.env = env; } + + private static synchronized List<String> getThemeFiles(Env env, String theme) { + if(themes==null) { + themes = new TreeMap<>(); + File themeD = new File("theme"); + if(themeD.exists() && themeD.isDirectory()) { + for (File t : themeD.listFiles()) { + if(t.isDirectory()) { + List<String> la = new ArrayList<>(); + for(File f : t.listFiles()) { + if(f.isFile()) { + if(f.getName().endsWith(".props")) { + Properties props; + if(themeProps == null) { + themeProps = new TreeMap<>(); + props = null; + } else { + props = themeProps.get(theme); + } + if(props==null) { + props = new Properties(); + themeProps.put(theme, props); + } + + try { + FileInputStream fis = new FileInputStream(f); + try { + props.load(fis); + } finally { + fis.close(); + } + } catch (IOException e) { + env.error().log(e); + } + } else { + la.add(f.getName()); + } + } + } + themes.put(t.getName(),la); + } + } + } + } + return themes.get(theme); + } + + protected Imports getImports(Env env, Holder<String> theme, String defaultTheme, int backdots, BROWSER browser) { + List<String> ls = getThemeFiles(env,theme.get()); + Imports imp = new Imports(backdots); + if(ls==null) { + theme.set(defaultTheme); + } + String prefix = "theme/" + theme.get() + '/'; + for(String f : ls) { + if(f.endsWith(".js")) { + imp.js(prefix + f); + } else if(f.endsWith(".css")) { + if(f.endsWith("iPhone.css")) { + if(BROWSER.iPhone.equals(browser)) { + imp.css(prefix + f); + } + } else if (f.endsWith("Desktop.css")){ + if(!BROWSER.iPhone.equals(browser)) { + imp.css(prefix + f); + } + // Make Console specific to Console page + } else if (!"console.js".equals(f)) { + imp.css(prefix + f); + } + } + } + return imp; + } @Override public void code(final Cache<HTMLGen> cache, final HTMLGen hgen) throws APIException, IOException { @@ -178,29 +261,34 @@ public class Page extends HTMLCacheGen { }); hgen.html(); final String title = env.getProperty(AAF_GUI_TITLE,"Authentication/Authorization Framework"); - final String theme = env.get(sTheme); + final String defaultTheme = env.get(sTheme); + final Holder<String> hTheme = new Holder<>(defaultTheme); + Mark head = hgen.head(); hgen.leaf(TITLE).text(title).end(); - hgen.imports(new Imports(backdots).css(theme + "/aaf5.css") - .js(theme + "/comm.js") - .js(theme + "/console.js") - .js(theme + "/common.js")); cache.dynamic(hgen, new DynamicCode<HTMLGen,AAF_GUI,AuthzTrans>() { @Override public void code(AAF_GUI state, AuthzTrans trans, final Cache<HTMLGen> cache, final HTMLGen hgen) throws APIException, IOException { - switch(browser(trans,browserSlot)) { - case iPhone: - hgen.imports(new Imports(backdots).css(theme + "/aaf5iPhone.css")); - break; + BROWSER browser = browser(trans,browserSlot); + Cookie[] cookies = trans.hreq().getCookies(); + if(cookies!=null) { + for(Cookie c : cookies) { + if("aaf_theme".equals(c.getName())) { + hTheme.set(c.getValue()); + } + } + } + hgen.imports(getImports(env,hTheme,defaultTheme,backdots,browser)); + switch(browser) { case ie: case ieOld: hgen.js().text("document.createElement('header');") .text("document.createElement('nav');") .done(); - case html5: - hgen.imports(new Imports(backdots).css(theme + "/aaf5Desktop.css")); break; + default: } + } }); hgen.end(head); @@ -274,9 +362,62 @@ public class Page extends HTMLCacheGen { hgen.end(inner); - // Navigation - Using older Nav to work with decrepit IE versions + // Navigation - Using older Nav to work with decrepit IE versions Mark nav = hgen.divID("nav"); + cache.dynamic(hgen, new DynamicCode<HTMLGen,AAF_GUI,AuthzTrans>() { + @Override + public void code(AAF_GUI state, AuthzTrans trans,Cache<HTMLGen> cache, HTMLGen xgen) throws APIException, IOException { + Properties props = themeProps.get(hTheme.get()); + if(props!=null && "TRUE".equalsIgnoreCase(props.getProperty("main_menu_in_nav"))) { + xgen.incr("h2").text("Navigation").end(); + Mark mark = new Mark(); + boolean selected = isSelected(trans.path(),Home.HREF); + //trans.path().endsWith("home"); + xgen.incr(mark,HTMLGen.UL) + .incr(HTMLGen.LI,selected?"class=selected":"") + .incr(HTMLGen.A, "href=home") + .text("Home") + .end(2); + boolean noSelection = !selected; + for(String[] mi : Home.MENU_ITEMS) { + //selected = trans.path().endsWith(mi[0]); + if(noSelection) { + selected = isSelected(trans.path(),mi[2]); + noSelection = !selected; + } else { + selected = false; + } + xgen.incr(HTMLGen.LI,selected?"class=selected":"") + .incr(HTMLGen.A, "href="+mi[0]) + .text(mi[1]) + .end(2); + } + xgen.end(mark); + } + } + + private boolean isSelected(String path, String item) { + if(item.equals(path)) { + return true; + } else { + for(ContentCode c : content) { + if(c instanceof BreadCrumbs) { + Page[] bc = ((BreadCrumbs)c).breadcrumbs; + if(bc!=null) { + for(int i = bc.length-1;i>0;--i) { + if(bc[i].url().equals(item)) { + return true; + } + } + return false; + } + } + } + } + return false; + } + }); hgen.incr("h2").text("Related Links").end(); hgen.incr(UL); String aaf_help = env.getProperty(AAF_URL_AAF_HELP,null); @@ -398,6 +539,5 @@ public class Page extends HTMLCacheGen { return values.length<1?null:values[0]; } - } diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/Home.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/Home.java index e0a73dca..e7a643ca 100644 --- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/Home.java +++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/Home.java @@ -37,10 +37,25 @@ import org.onap.aaf.misc.xgen.html.HTMLGen; public class Home extends Page { public static final String HREF = "/gui/home"; + /* + * Relative path, Menu Name, Full Path + */ + public static String[][] MENU_ITEMS = new String[][] { + {"myperms","My Permissions","/gui/myperms"}, + {"myroles","My Roles","/gui/myroles"}, + {"ns","My Namespaces","/gui/ns"}, + {"approve","My Approvals","/gui/approve"}, + {"myrequests","My Pending Requests","/gui/myrequests"}, + // Enable later + // {"onboard","Onboarding"}, + {"passwd","Password Management","/gui/passwd"}, + {"cui","Command Prompt","/gui/cui"}, + {"api","AAF API","/gui/api"} + }; public Home(final AAF_GUI gui) throws APIException, IOException { super(gui.env,"Home",HREF, NO_FIELDS, new NamedCode(false,"content") { @Override - public void code(final Cache<HTMLGen> cache, final HTMLGen xgen) throws APIException, IOException { + public void code(final Cache<HTMLGen> cache, final HTMLGen htmlGen) throws APIException, IOException { // // TEMP // JSGen jsg = xgen.js(); // jsg.function("httpPost","sURL","sParam") @@ -53,25 +68,14 @@ public class Home extends Page { // .text(text) // jsg.done(); // TEMP - final Mark pages = xgen.divID("Pages"); - xgen.leaf(H3).text("Choose from the following:").end() - .leaf(A,"href=myperms").text("My Permissions").end() - .leaf(A,"href=myroles").text("My Roles").end() - // TODO: uncomment when on cassandra 2.1.2 for MyNamespace GUI page - .leaf(A,"href=ns").text("My Namespaces").end() - .leaf(A,"href=approve").text("My Approvals").end() - .leaf(A, "href=myrequests").text("My Pending Requests").end() - // Enable later -// .leaf(A, "href=onboard").text("Onboarding").end() - // Password Change. If logged in as CSP/GSO, go to their page - .leaf(A,"href=passwd").text("Password Management").end() - .leaf(A,"href=cui").text("Command Prompt").end() - .leaf(A,"href=api").text("AAF API").end() - ; - - xgen.end(pages); + final Mark pages = htmlGen.divID("Pages"); + htmlGen.leaf(H3).text("Choose from the following:").end(); + for(String[] mi : MENU_ITEMS) { + htmlGen.leaf(A,"href="+mi[0]).text(mi[1]).end(); + } + htmlGen.end(pages); } }); } - + } diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/WebCommand.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/WebCommand.java index 6ad95e51..d0e834a5 100644 --- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/WebCommand.java +++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/WebCommand.java @@ -28,7 +28,9 @@ import org.onap.aaf.auth.gui.AAF_GUI; import org.onap.aaf.auth.gui.BreadCrumbs; import org.onap.aaf.auth.gui.NamedCode; import org.onap.aaf.auth.gui.Page; +import org.onap.aaf.auth.rserv.CachingFileAccess; import org.onap.aaf.misc.env.APIException; +import org.onap.aaf.misc.env.StaticSlot; import org.onap.aaf.misc.xgen.Cache; import org.onap.aaf.misc.xgen.DynamicCode; import org.onap.aaf.misc.xgen.Mark; @@ -41,6 +43,8 @@ public class WebCommand extends Page { super(gui.env, "Web Command Client",HREF, NO_FIELDS, new BreadCrumbs(breadcrumbs), new NamedCode(true, "content") { + StaticSlot sThemeWebPath = gui.env.staticSlot(CachingFileAccess.CFA_WEB_PATH); + StaticSlot sTheme = gui.env.staticSlot(AAF_GUI.AAF_GUI_THEME); @Override public void code(final Cache<HTMLGen> cache, final HTMLGen hgen) throws APIException, IOException { hgen.leaf("p","id=help_msg") @@ -56,31 +60,33 @@ public class WebCommand extends Page { hgen.end(); //console_area hgen.divID("options_link", "class=closed"); - hgen.img("src=../../"+gui.theme + "/options_down.png", "onclick=handleDivHiding('options',this);", - "id=options_img", "alt=Options", "title=Options") - .end(); //options_link - - hgen.divID("options"); cache.dynamic(hgen, new DynamicCode<HTMLGen,AAF_GUI,AuthzTrans>() { @Override public void code(AAF_GUI state, AuthzTrans trans, Cache<HTMLGen> cache, HTMLGen xgen) throws APIException, IOException { + String image_root = "src=../../"+state.env.get(sThemeWebPath).toString() + '/' + state.env.get(sTheme) + "/images/icons"; + hgen.img(image_root + "/options_down.png", "onclick=handleDivHiding('options',this);", + "id=options_img", "alt=Options", "title=Options") + .end(); //options_link + + hgen.divID("options"); + switch(browser(trans,trans.env().slot(getBrowserType()))) { case ie: case ieOld: // IE doesn't support file save break; default: - xgen.img("src=../../"+gui.theme+"/AAFdownload.png", "onclick=saveToFile();", + xgen.img(image_root+"/AAF_download.png", "onclick=saveToFile();", "alt=Save log to file", "title=Save log to file"); } -// xgen.img("src=../../"+gui.theme+"/AAFemail.png", "onclick=emailLog();", +// xgen.img("src=../../"+gui.theme+"/AAF_email.png", "onclick=emailLog();", // "alt=Email log to me", "title=Email log to me"); - xgen.img("src=../../"+gui.theme+"/AAF_font_size.png", "onclick=handleDivHiding('text_slider',this);", + xgen.img(image_root+"/AAF_font_size.png", "onclick=handleDivHiding('text_slider',this);", "id=fontsize_img", "alt=Change text size", "title=Change text size"); - xgen.img("src=../../"+gui.theme+"/AAF_details.png", "onclick=selectOption(this,0);", + xgen.img(image_root+"/AAF_details.png", "onclick=selectOption(this,0);", "id=details_img", "alt=Turn on/off details mode", "title=Turn on/off details mode"); - xgen.img("src=../../"+gui.theme+"/AAF_maximize.png", "onclick=maximizeConsole(this);", + xgen.img(image_root+"/AAF_maximize.png", "onclick=maximizeConsole(this);", "id=maximize_img", "alt=Maximize Console Window", "title=Maximize Console Window"); } }); diff --git a/auth/auth-gui/theme/onap/images/AAF_details.png b/auth/auth-gui/theme/onap/images/AAF_details.png Binary files differnew file mode 100644 index 00000000..5c187459 --- /dev/null +++ b/auth/auth-gui/theme/onap/images/AAF_details.png diff --git a/auth/auth-gui/theme/onap/images/AAF_font_size.png b/auth/auth-gui/theme/onap/images/AAF_font_size.png Binary files differnew file mode 100644 index 00000000..466cbfbc --- /dev/null +++ b/auth/auth-gui/theme/onap/images/AAF_font_size.png diff --git a/auth/auth-gui/theme/onap/images/AAF_maximize.png b/auth/auth-gui/theme/onap/images/AAF_maximize.png Binary files differnew file mode 100644 index 00000000..706603bb --- /dev/null +++ b/auth/auth-gui/theme/onap/images/AAF_maximize.png diff --git a/auth/auth-gui/theme/onap/images/AAFdownload.png b/auth/auth-gui/theme/onap/images/AAFdownload.png Binary files differnew file mode 100644 index 00000000..cebd9522 --- /dev/null +++ b/auth/auth-gui/theme/onap/images/AAFdownload.png diff --git a/auth/auth-gui/theme/onap/images/AAFemail.png b/auth/auth-gui/theme/onap/images/AAFemail.png Binary files differnew file mode 100644 index 00000000..6d487769 --- /dev/null +++ b/auth/auth-gui/theme/onap/images/AAFemail.png diff --git a/auth/auth-gui/theme/onap/images/LF_Collab_footer_gray.png b/auth/auth-gui/theme/onap/images/LF_Collab_footer_gray.png Binary files differnew file mode 100644 index 00000000..abbf4b1a --- /dev/null +++ b/auth/auth-gui/theme/onap/images/LF_Collab_footer_gray.png diff --git a/auth/auth-gui/theme/onap/images/LF_Collab_footer_gray_stripe.png b/auth/auth-gui/theme/onap/images/LF_Collab_footer_gray_stripe.png Binary files differnew file mode 100644 index 00000000..fb9b37a2 --- /dev/null +++ b/auth/auth-gui/theme/onap/images/LF_Collab_footer_gray_stripe.png diff --git a/auth/auth-gui/theme/onap/images/LF_Collab_header_gray.png b/auth/auth-gui/theme/onap/images/LF_Collab_header_gray.png Binary files differnew file mode 100644 index 00000000..43781fad --- /dev/null +++ b/auth/auth-gui/theme/onap/images/LF_Collab_header_gray.png diff --git a/auth/auth-gui/theme/onap/images/ONAP_LOGO.png b/auth/auth-gui/theme/onap/images/ONAP_LOGO.png Binary files differnew file mode 100644 index 00000000..55e37188 --- /dev/null +++ b/auth/auth-gui/theme/onap/images/ONAP_LOGO.png diff --git a/auth/auth-gui/theme/onap/images/logo_onap.png b/auth/auth-gui/theme/onap/images/logo_onap.png Binary files differnew file mode 100644 index 00000000..458e320c --- /dev/null +++ b/auth/auth-gui/theme/onap/images/logo_onap.png |