summaryrefslogtreecommitdiffstats
path: root/auth/auth-gui
diff options
context:
space:
mode:
Diffstat (limited to 'auth/auth-gui')
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/cui/CUI.java12
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/AAF_GUI.java41
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/Page.java131
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/CMArtiChangeAction.java54
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/CredDetail.java5
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/CredHistory.java224
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/Home.java3
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/NsDetail.java2
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/NsHistory.java5
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PendingRequestsShow.java3
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PermDetail.java2
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PermHistory.java9
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RoleDetail.java2
-rw-r--r--auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RoleHistory.java10
-rw-r--r--auth/auth-gui/theme/onap/aaf5.css2
-rw-r--r--auth/auth-gui/theme/onap/console.js4
16 files changed, 409 insertions, 100 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 7859b7cc..f2d7522e 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
@@ -24,15 +24,17 @@
package org.onap.aaf.auth.cui;
import java.io.PrintWriter;
+import java.util.regex.Pattern;
import javax.servlet.ServletInputStream;
+import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.onap.aaf.auth.cmd.AAFcli;
import org.onap.aaf.auth.env.AuthzTrans;
-import org.onap.aaf.auth.env.AuthzEnv;
import org.onap.aaf.auth.gui.AAF_GUI;
+import org.onap.aaf.auth.gui.Page;
import org.onap.aaf.auth.rserv.HttpCode;
import org.onap.aaf.cadi.aaf.v2_0.AAFConHttp;
import org.onap.aaf.cadi.http.HTransferSS;
@@ -43,6 +45,7 @@ import org.onap.aaf.misc.env.TimeTaken;
public class CUI extends HttpCode<AuthzTrans, Void> {
private final AAF_GUI gui;
+ private final static Pattern userPerm = Pattern.compile("perm (create|delete).*@.*:id.*aaf.gui.*");
public CUI(AAF_GUI gui) {
@@ -84,6 +87,13 @@ public class CUI extends HttpCode<AuthzTrans, Void> {
}
try {
aafcli.eval(cmdStr);
+ if(userPerm.matcher(cmdStr).matches()) {
+ trans.clearCache();
+ Cookie cookie = new Cookie(Page.AAF_THEME,trans.getProperty(Page.AAF_THEME));
+ cookie.setMaxAge(-1);
+ cookie.setComment("Remove AAF GUI Theme");
+ trans.hresp().addCookie(cookie);
+ }
pw.flush();
} catch (Exception e) {
pw.flush();
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 c33f3d69..17916c24 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
@@ -26,6 +26,9 @@ import static org.onap.aaf.auth.rserv.HttpMethods.POST;
import static org.onap.aaf.auth.rserv.HttpMethods.PUT;
import javax.servlet.Filter;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.onap.aaf.auth.cmd.Cmd;
import org.onap.aaf.auth.cui.CUI;
@@ -40,6 +43,7 @@ import org.onap.aaf.auth.gui.pages.CMArtiChangeAction;
import org.onap.aaf.auth.gui.pages.CMArtiChangeForm;
import org.onap.aaf.auth.gui.pages.CMArtifactShow;
import org.onap.aaf.auth.gui.pages.CredDetail;
+import org.onap.aaf.auth.gui.pages.CredHistory;
import org.onap.aaf.auth.gui.pages.Home;
import org.onap.aaf.auth.gui.pages.LoginLanding;
import org.onap.aaf.auth.gui.pages.LoginLandingAction;
@@ -66,6 +70,7 @@ import org.onap.aaf.auth.gui.pages.UserRoleExtend;
import org.onap.aaf.auth.gui.pages.UserRoleRemove;
import org.onap.aaf.auth.gui.pages.WebCommand;
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;
@@ -114,19 +119,19 @@ public class AAF_GUI extends AbsService<AuthzEnv, AuthzTrans> implements State<E
protected final String deployedVersion;
private StaticSlot sThemeWebPath;
private StaticSlot sDefaultTheme;
-// public final String theme;
public AAF_GUI(final AuthzEnv env) throws Exception {
super(env.access(), env);
sDefaultTheme = env.staticSlot(AAF_GUI_THEME);
- env.put(sDefaultTheme, env.getProperty(AAF_GUI_THEME,"onap"));
+ String defTheme = env.getProperty(AAF_GUI_THEME,"onap");
+ env.put(sDefaultTheme, defTheme);
sThemeWebPath = env.staticSlot(CachingFileAccess.CFA_WEB_PATH);
if(env.get(sThemeWebPath)==null) {
env.put(sThemeWebPath,"theme");
}
-
+
slot_httpServletRequest = env.slot(HTTP_SERVLET_REQUEST);
deployedVersion = app_version;
@@ -157,8 +162,9 @@ public class AAF_GUI extends AbsService<AuthzEnv, AuthzTrans> implements State<E
// MyNameSpace
final Page myNamespaces = new Display(this, GET, new NssShow(this, start)).page();
Page nsDetail = new Display(this, GET, new NsDetail(this, start, myNamespaces)).page();
- new Display(this, GET, new NsHistory(this, start,myNamespaces,nsDetail));
+ new Display(this, GET, new NsHistory(this, start,myNamespaces,nsDetail));
Page crdDetail = new Display(this, GET, new CredDetail(this, start, myNamespaces, nsDetail)).page();
+ new Display(this, GET, new CredHistory(this,start,myNamespaces,nsDetail,crdDetail));
Page artiShow = new Display(this, GET, new CMArtifactShow(this, start, myNamespaces, nsDetail, crdDetail)).page();
Page artiCForm = new Display(this, GET, new CMArtiChangeForm(this, start, myNamespaces, nsDetail, crdDetail,artiShow)).page();
new Display(this, POST, new CMArtiChangeAction(this, start,artiShow,artiCForm));
@@ -204,6 +210,23 @@ public class AAF_GUI extends AbsService<AuthzEnv, AuthzTrans> implements State<E
// Command line Mechanism
route(env, PUT, "/gui/cui", new CUI(this),"text/plain;charset=utf-8","*/*");
+ route(env, GET, "/gui/clear", new HttpCode<AuthzTrans, Void>(null, "Clear"){
+ @Override
+ public void handle(AuthzTrans trans, HttpServletRequest req, HttpServletResponse resp) throws Exception {
+ trans.clearCache();
+ Cookie cookies[] = req.getCookies();
+ if(cookies!=null) {
+ for(Cookie c : cookies) {
+ if(c.getName().startsWith("aaf.gui.")) {
+ c.setMaxAge(0);
+ resp.addCookie(c);
+ }
+ }
+ }
+ resp.sendRedirect("/gui/home");
+ }
+ }, "text/plain;charset=utf-8","*/*");
+
///////////////////////
// WebContent Handler
///////////////////////
@@ -262,9 +285,13 @@ public class AAF_GUI extends AbsService<AuthzEnv, AuthzTrans> implements State<E
Log4JLogIt logIt = new Log4JLogIt(args, "gui");
PropAccess propAccess = new PropAccess(logIt,args);
- AAF_GUI service = new AAF_GUI(new AuthzEnv(propAccess));
- JettyServiceStarter<AuthzEnv,AuthzTrans> jss = new JettyServiceStarter<AuthzEnv,AuthzTrans>(service);
- jss.start();
+ try {
+ new JettyServiceStarter<AuthzEnv,AuthzTrans>(
+ new AAF_GUI(new AuthzEnv(propAccess)),true)
+ .start();
+ } catch (Exception e) {
+ propAccess.log(e);
+ }
} catch (Exception e) {
e.printStackTrace();
}
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 5b6eb016..18ec9f68 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
@@ -46,7 +46,6 @@ import org.onap.aaf.auth.env.AuthzTrans;
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;
@@ -70,6 +69,7 @@ import org.onap.aaf.misc.xgen.html.Imports;
*
*/
public class Page extends HTMLCacheGen {
+ public static final String AAF_THEME = "aaf_theme";
public static final String AAFURL_TOOLS = "aaf_url.tools";
public static final String AAF_URL_TOOL_DOT = "aaf_url.tool.";
public static final String AAF_URL_CUIGUI = "aaf_url.cuigui"; // link to help
@@ -151,7 +151,8 @@ public class Page extends HTMLCacheGen {
private static class PageCode implements Code<HTMLGen> {
- private static final String AAF_GUI_TITLE = "aaf_gui_title";
+ private static final String AAF_GUI_THEME = "aaf.gui.theme";
+ private static final String AAF_GUI_TITLE = "aaf_gui_title";
private final ContentCode[] content;
private final Slot browserSlot;
@@ -167,6 +168,7 @@ public class Page extends HTMLCacheGen {
browserSlot = env.slot(BROWSER_TYPE);
sTheme = env.staticSlot(AAF_GUI.AAF_GUI_THEME);
this.env = env;
+ getThemeFiles(env,""); //
}
private static synchronized List<String> getThemeFiles(Env env, String theme) {
@@ -185,11 +187,11 @@ public class Page extends HTMLCacheGen {
themeProps = new TreeMap<>();
props = null;
} else {
- props = themeProps.get(theme);
+ props = themeProps.get(t.getName());
}
if(props==null) {
props = new Properties();
- themeProps.put(theme, props);
+ themeProps.put(t.getName(), props);
}
try {
@@ -215,13 +217,10 @@ public class Page extends HTMLCacheGen {
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());
+ protected Imports getImports(Env env, String theme, int backdots, BROWSER browser) {
+ List<String> ls = getThemeFiles(env,theme);
Imports imp = new Imports(backdots);
- if(ls==null) {
- theme.set(defaultTheme);
- }
- String prefix = "theme/" + theme.get() + '/';
+ String prefix = "theme/" + theme + '/';
for(String f : ls) {
if(f.endsWith(".js")) {
imp.js(prefix + f);
@@ -262,7 +261,6 @@ public class Page extends HTMLCacheGen {
hgen.html();
final String title = env.getProperty(AAF_GUI_TITLE,"Authentication/Authorization Framework");
final String defaultTheme = env.get(sTheme,"onap");
- final Holder<String> hTheme = new Holder<>(defaultTheme);
Mark head = hgen.head();
hgen.leaf(TITLE).text(title).end();
@@ -270,15 +268,37 @@ public class Page extends HTMLCacheGen {
@Override
public void code(AAF_GUI state, AuthzTrans trans, final Cache<HTMLGen> cache, final HTMLGen hgen) throws APIException, IOException {
BROWSER browser = browser(trans,browserSlot);
+ String theme = null;
Cookie[] cookies = trans.hreq().getCookies();
if(cookies!=null) {
for(Cookie c : cookies) {
- if("aaf_theme".equals(c.getName())) {
- hTheme.set(c.getValue());
+ if(AAF_GUI_THEME.equals(c.getName())) {
+ theme=c.getValue();
+ if(!(themes.containsKey(theme))) {
+ theme = defaultTheme;
+ }
+ break;
}
}
}
- hgen.imports(getImports(env,hTheme,defaultTheme,backdots,browser));
+
+ if(theme==null) {
+ for(String t : themes.keySet()) {
+ if(!t.equals(defaultTheme) && trans.fish(new AAFPermission(null,trans.user()+":id", AAF_GUI_THEME, t))) {
+ theme=t;
+ break;
+ }
+ }
+ if(theme==null) {
+ theme = defaultTheme;
+ }
+ Cookie cookie = new Cookie(AAF_GUI_THEME,theme);
+ cookie.setMaxAge(604_800); // one week
+ trans.hresp().addCookie(cookie);
+ }
+ trans.setProperty(Page.AAF_THEME, theme);
+
+ hgen.imports(getImports(env,theme,backdots,browser));
switch(browser) {
case ie:
case ieOld:
@@ -350,7 +370,8 @@ public class Page extends HTMLCacheGen {
}
hgen.end(header);
-
+
+ hgen.divID("pageContent");
Mark inner = hgen.divID("inner");
// Content
for (int i=cIdx;i<content.length;++i) {
@@ -361,39 +382,65 @@ public class Page extends HTMLCacheGen {
}
hgen.end(inner);
+
+ 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 theme = trans.getProperty(Page.AAF_THEME);
+ Properties props;
+ if(theme==null) {
+ props = null;
+ } else {
+ props = themeProps==null?null:themeProps.get(theme);
+ }
+
+ if(props!=null && "TRUE".equalsIgnoreCase(props.getProperty("enable_nav_btn"))) {
+ xgen.leaf("button", "id=navBtn").end();
+ }
+ }
+ });
+ // Adding "nav Hamburger button"
// 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==null?null: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);
+ String theme = trans.getProperty(Page.AAF_THEME);
+ Properties props;
+ if(theme==null) {
+ props = null;
+ } else {
+ props = themeProps==null?null:themeProps.get(theme);
+ }
+
+ if(props!=null) {
+ if("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);
+ }
}
}
diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/CMArtiChangeAction.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/CMArtiChangeAction.java
index d32c7dc3..1e06b109 100644
--- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/CMArtiChangeAction.java
+++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/CMArtiChangeAction.java
@@ -82,32 +82,36 @@ trans.info().log("Step 1");
arti.getSans().add(s);
}
}
- // Disallow IP entries, except by special Permission
- if (!trans.fish(getPerm(ca,"ip"))) {
- boolean ok=true;
- if (IPValidator.ip(machine)) {
- ok=false;
- }
- if (ok) {
- for (String s: arti.getSans()) {
- if (IPValidator.ip(s)) {
- ok=false;
- break;
- }
- }
- }
- if (!ok) {
- hgen.p("Policy Failure: IPs in certificates are only allowed by Exception.");
- return;
- }
- }
- // Disallow Domain based Definitions without exception
- if (machine.startsWith("*")) { // Domain set
- if (!trans.fish(getPerm(ca, "domain"))) {
- hgen.p("Policy Failure: Domain Artifact Declarations are only allowed by Exception.");
- return;
- }
+ // These checks to not apply to deletions
+ if(!CMArtiChangeForm.DELETE.equals(trans.get(sCmd, ""))) {
+ // Disallow IP entries, except by special Permission
+ if (!trans.fish(getPerm(ca,"ip"))) {
+ boolean ok=true;
+ if (IPValidator.ip(machine)) {
+ ok=false;
+ }
+ if (ok) {
+ for (String s: arti.getSans()) {
+ if (IPValidator.ip(s)) {
+ ok=false;
+ break;
+ }
+ }
+ }
+ if (!ok) {
+ hgen.p("Policy Failure: IPs in certificates are only allowed by Exception.");
+ return;
+ }
+ }
+
+ // Disallow Domain based Definitions without exception
+ if (machine.startsWith("*")) { // Domain set
+ if (!trans.fish(getPerm(ca, "domain"))) {
+ hgen.p("Policy Failure: Domain Artifact Declarations are only allowed by Exception.");
+ return;
+ }
+ }
}
arti.setMechid((String)trans.get(sID,null));
diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/CredDetail.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/CredDetail.java
index 00e58c87..70d86933 100644
--- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/CredDetail.java
+++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/CredDetail.java
@@ -214,6 +214,7 @@ public class CredDetail extends Page {
StringWriter buttons = new StringWriter();
HTMLGen hgen = cd.clone(buttons);
hgen.leaf("button","onclick=divVisibility('"+key+"');","class=button").text("Expand").end();
+ hgen.leaf(HTMLGen.A,"class=button","class=greenbutton","href="+CredHistory.HREF+"?user="+ulm.getKey()).text("History").end();
StringWriter creds = new StringWriter();
hgen = cd.clone(creds);
@@ -302,8 +303,9 @@ public class CredDetail extends Page {
Chrono.niceDateStamp(oldest),
Chrono.niceDateStamp(newest)))
.end(uRow);
-
+
}
+
}
hgen.end(utable);
}
@@ -316,6 +318,7 @@ public class CredDetail extends Page {
new TextCell(creds.toString(),STYLE_WIDTH_70)
});
}
+
for (String missing : lns) {
StringWriter buttons = new StringWriter();
HTMLGen hgen = cd.clone(buttons);
diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/CredHistory.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/CredHistory.java
new file mode 100644
index 00000000..7e3962ec
--- /dev/null
+++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/CredHistory.java
@@ -0,0 +1,224 @@
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ *
+ */
+
+package org.onap.aaf.auth.gui.pages;
+
+
+import java.io.IOException;
+import java.net.ConnectException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Comparator;
+import java.util.List;
+
+import org.onap.aaf.auth.env.AuthzEnv;
+import org.onap.aaf.auth.env.AuthzTrans;
+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.gui.Table;
+import org.onap.aaf.auth.gui.Table.Cells;
+import org.onap.aaf.auth.gui.table.AbsCell;
+import org.onap.aaf.auth.gui.table.TableData;
+import org.onap.aaf.auth.gui.table.TextCell;
+import org.onap.aaf.cadi.CadiException;
+import org.onap.aaf.cadi.client.Future;
+import org.onap.aaf.cadi.client.Rcli;
+import org.onap.aaf.cadi.client.Retryable;
+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.TimeTaken;
+import org.onap.aaf.misc.xgen.Cache;
+import org.onap.aaf.misc.xgen.DynamicCode;
+import org.onap.aaf.misc.xgen.html.HTMLGen;
+
+import aaf.v2_0.History;
+import aaf.v2_0.History.Item;
+
+
+public class CredHistory extends Page {
+ static final String NAME="CredHistory";
+ static final String HREF = "/gui/credHistory";
+ static final String FIELDS[] = {"user","dates"};
+
+
+ public CredHistory(final AAF_GUI gui, final Page ... breadcrumbs) throws APIException, IOException {
+ super(gui.env,NAME,HREF, FIELDS,
+ new BreadCrumbs(breadcrumbs),
+ new Table<AAF_GUI,AuthzTrans>("History", gui.env.newTransNoAvg(),new Model(gui.env),"class=std"),
+ new NamedCode(true, "content") {
+ @Override
+ public void code(final Cache<HTMLGen> cache, final HTMLGen hgen) throws APIException, IOException {
+ final Slot user = gui.env.slot(NAME+".user");
+ cache.dynamic(hgen, new DynamicCode<HTMLGen, AAF_GUI, AuthzTrans>() {
+ @Override
+ public void code(final AAF_GUI gui, final AuthzTrans trans, final Cache<HTMLGen> cache, final HTMLGen hgen) throws APIException, IOException {
+ String obUser = trans.get(user, null);
+
+ // Use Javascript to make the table title more descriptive
+ hgen.js()
+ .text("var caption = document.querySelector(\".title\");")
+ .text("caption.innerHTML='History for User [ " + obUser + " ]';")
+ .done();
+
+ // Use Javascript to change Link Target to our last visited Detail page
+ String lastPage = CredDetail.HREF + "?role=" + obUser;
+ hgen.js()
+ .text("alterLink('roledetail', '"+lastPage + "');")
+ .done();
+
+ hgen.br();
+ hgen.leaf("a", "href=#advanced_search","onclick=divVisibility('advanced_search');","class=greenbutton").text("Advanced Search").end()
+ .divID("advanced_search", "style=display:none");
+ hgen.incr("table");
+
+ addDateRow(hgen,"Start Date");
+ addDateRow(hgen,"End Date");
+ hgen.incr("tr").incr("td");
+ hgen.tagOnly("input", "type=button","value=Get History",
+ "onclick=datesURL('"+HREF+"?user=" + obUser+"');","class=greenbutton");
+ hgen.end().end();
+ hgen.end();
+ hgen.end();
+ }
+ });
+ }
+ }
+
+ );
+
+ }
+
+ private static void addDateRow(HTMLGen hgen, String s) {
+ hgen
+ .incr("tr")
+ .incr("td")
+ .incr("label", "for=month", "required").text(s+"*").end()
+ .end()
+ .incr("td")
+ .incr("select", "name=month"+s.substring(0, s.indexOf(' ')), "id=month"+s.substring(0, s.indexOf(' ')), "required")
+ .incr("option", "value=").text("Month").end();
+ for(NsHistory.Month m : NsHistory.Month.values()) {
+ if (Calendar.getInstance().get(Calendar.MONTH) == m.ordinal()) {
+ hgen.incr("option", "selected", "value="+(m.ordinal()+1)).text(m.name()).end();
+ } else {
+ hgen.incr("option", "value="+(m.ordinal()+1)).text(m.name()).end();
+ }
+ }
+ hgen.end()
+ .end()
+ .incr("td")
+ .tagOnly("input","type=number","id=year"+s.substring(0, s.indexOf(' ')),"required",
+ "value="+Calendar.getInstance().get(Calendar.YEAR), "min=1900",
+ "max="+Calendar.getInstance().get(Calendar.YEAR),
+ "placeholder=Year").end()
+ .end();
+ }
+
+
+ /**
+ * Implement the Table Content for History
+ *
+ * @author Jonathan
+ *
+ */
+ private static class Model extends TableData<AAF_GUI,AuthzTrans> {
+ private static final String[] headers = new String[] {"Date","User","Memo"};
+ private Slot user;
+ private Slot dates;
+
+ public Model(AuthzEnv env) {
+ user = env.slot(NAME+".user");
+ dates = env.slot(NAME+".dates");
+ }
+
+ @Override
+ public String[] headers() {
+ return headers;
+ }
+
+ @Override
+ public Cells get(final AuthzTrans trans, final AAF_GUI gui) {
+ final String oName = trans.get(user,null);
+ final String oDates = trans.get(dates,null);
+
+ Cells rv = Cells.EMPTY;
+ if (oName!=null) {
+
+ try {
+ rv = gui.clientAsUser(trans.getUserPrincipal(), new Retryable<Cells>() {
+ @Override
+ public Cells code(Rcli<?> client) throws CadiException, ConnectException, APIException {
+ ArrayList<AbsCell[]> rv = new ArrayList<>();
+ TimeTaken tt = trans.start("AAF Get History for credential ["+oName+"]",Env.REMOTE);
+ String msg = null;
+ try {
+ if (oDates != null) {
+ client.setQueryParams("yyyymm="+oDates);
+ }
+ Future<History> fh = client.read("/authz/hist/subject/"+oName + "/cred",gui.getDF(History.class));
+ if (fh.get(AAF_GUI.TIMEOUT)) {
+ tt.done();
+ tt = trans.start("Load History Data", Env.SUB);
+ List<Item> histItems = fh.value.getItem();
+
+ java.util.Collections.sort(histItems, new Comparator<Item>() {
+ @Override
+ public int compare(Item o1, Item o2) {
+ return o2.getTimestamp().compare(o1.getTimestamp());
+ }
+ });
+
+ for (Item i : histItems) {
+ String user = i.getUser();
+ AbsCell userCell = new TextCell(user);
+
+ String memo = i.getMemo().replace("<script>", "&lt;script&gt;").replace("</script>", "&lt;/script&gt;");
+ rv.add(new AbsCell[] {
+ new TextCell(i.getTimestamp().toGregorianCalendar().getTime().toString()),
+ userCell,
+ new TextCell(memo)
+ });
+ }
+ } else {
+ if (fh.code()==403) {
+ rv.add(new AbsCell[] {new TextCell("You may not view History of Credentiol[" + oName + "]", "colspan = 3", "class=center")});
+ } else {
+ rv.add(new AbsCell[] {new TextCell("*** Data Unavailable ***", "colspan = 3", "class=center")});
+ }
+ }
+ } finally {
+ tt.done();
+ }
+ return new Cells(rv,msg);
+ }
+ });
+ } catch (Exception e) {
+ trans.error().log(e);
+ }
+ }
+ return rv;
+ }
+ }
+
+}
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 6fc4b5c1..463ee11a 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
@@ -50,7 +50,8 @@ public class Home extends Page {
// {"onboard","Onboarding"},
{"passwd","Password Management","/gui/passwd"},
{"cui","Command Prompt","/gui/cui"},
- {"api","AAF API","/gui/api"}
+ {"api","AAF API","/gui/api"},
+ {"clear","Clear Preferences","/gui/clear"}
};
public Home(final AAF_GUI gui) throws APIException, IOException {
diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/NsDetail.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/NsDetail.java
index 16a6c940..6b1c6120 100644
--- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/NsDetail.java
+++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/NsDetail.java
@@ -168,7 +168,7 @@ public class NsDetail extends Page {
}
String historyLink = NsHistory.HREF
+ "?name=" + nsName;
- rv.add(new AbsCell[] {new RefCell("See History",historyLink,false)});
+ rv.add(new AbsCell[] {new RefCell("See History",historyLink,false,"class=greenbutton")});
} finally {
tt.done();
}
diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/NsHistory.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/NsHistory.java
index bca6c92c..dc9119bf 100644
--- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/NsHistory.java
+++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/NsHistory.java
@@ -58,7 +58,6 @@ public class NsHistory extends Page {
static final String NAME="NsHistory";
static final String HREF = "/gui/nsHistory";
static final String FIELDS[] = {"name","dates"};
- static final String WEBPHONE = "http://webphone.att.com/cgi-bin/webphones.pl?id=";
static enum Month { JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY,
AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER };
@@ -88,7 +87,7 @@ public class NsHistory extends Page {
.done();
hgen.br();
- hgen.leaf("a","href=#advanced_search","onclick=divVisibility('advanced_search');").text("Advanced Search").end()
+ hgen.leaf("a","href=#advanced_search","onclick=divVisibility('advanced_search');","class=greenbutton").text("Advanced Search").end()
.divID("advanced_search", "style=display:none");
hgen.incr("table");
@@ -96,7 +95,7 @@ public class NsHistory extends Page {
addDateRow(hgen,"End Date");
hgen.incr("tr").incr("td");
hgen.tagOnly("input", "type=button","value=Get History",
- "onclick=datesURL('"+HREF+"?name=" + obName+"');");
+ "onclick=datesURL('"+HREF+"?name=" + obName+"');","class=greenbutton");
hgen.end().end();
hgen.end();
hgen.end();
diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PendingRequestsShow.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PendingRequestsShow.java
index 41711db2..ae5fe375 100644
--- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PendingRequestsShow.java
+++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PendingRequestsShow.java
@@ -60,8 +60,7 @@ import aaf.v2_0.Approvals;
public class PendingRequestsShow extends Page {
public static final String HREF = "/gui/myrequests";
public static final String NAME = "MyRequests";
- static final String WEBPHONE = "http://webphone.att.com/cgi-bin/webphones.pl?id=";
- static final String[] FIELDS = new String[] {"as_user"}; // as_user Checked in Display
+ private static final String[] FIELDS = new String[] {"as_user"}; // as_user Checked in Display
private static final String AS_USER=NAME+".as_user";
public PendingRequestsShow(final AAF_GUI gui, final Page ... breadcrumbs) throws APIException, IOException {
diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PermDetail.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PermDetail.java
index 7d31d0e4..7bf6447d 100644
--- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PermDetail.java
+++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PermDetail.java
@@ -135,7 +135,7 @@ public class PermDetail extends Page {
String historyLink = PermHistory.HREF
+ "?type=" + pType + "&instance=" + pInstance + "&action=" + pAction;
- rv.add(new AbsCell[] {new RefCell("See History",historyLink,false)});
+ rv.add(new AbsCell[] {new RefCell("See History",historyLink,false,"class=greenbutton")});
} else {
rv.add(new AbsCell[] {new TextCell(
fp.code()==HttpStatus.NOT_FOUND_404?
diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PermHistory.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PermHistory.java
index bbaf419f..4c3bd32e 100644
--- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PermHistory.java
+++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/PermHistory.java
@@ -60,9 +60,6 @@ public class PermHistory extends Page {
static final String NAME="PermHistory";
static final String HREF = "/gui/permHistory";
static final String FIELDS[] = {"type","instance","action","dates"};
- static final String WEBPHONE = "http://webphone.att.com/cgi-bin/webphones.pl?id=";
- static enum Month { JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY,
- AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER };
public PermHistory(final AAF_GUI gui, final Page ... breadcrumbs) throws APIException, IOException {
super(gui.env,NAME,HREF, FIELDS,
@@ -96,7 +93,7 @@ public class PermHistory extends Page {
.done();
hgen.br();
- hgen.leaf("a", "href=#advanced_search", "onclick=divVisibility('advanced_search');").text("Advanced Search").end()
+ hgen.leaf("a", "href=#advanced_search", "onclick=divVisibility('advanced_search');","class=greenbutton").text("Advanced Search").end()
.divID("advanced_search", "style=display:none");
hgen.incr("table");
@@ -106,7 +103,7 @@ public class PermHistory extends Page {
hgen.tagOnly("input", "type=button","value=Get History",
"onclick=datesURL('"+HREF+"?type=" + type
+ "&instance=" + instance
- + "&action=" + action+"');");
+ + "&action=" + action+"');","class=greenbutton");
hgen.end().end();
hgen.end();
hgen.end();
@@ -128,7 +125,7 @@ public class PermHistory extends Page {
.incr("td")
.incr("select", "name=month"+s.substring(0, s.indexOf(' ')), "id=month"+s.substring(0, s.indexOf(' ')), "required")
.incr("option", "value=").text("Month").end();
- for (Month m : Month.values()) {
+ for (NsHistory.Month m : NsHistory.Month.values()) {
if (Calendar.getInstance().get(Calendar.MONTH) == m.ordinal()) {
hgen.incr("option", "selected", "value="+(m.ordinal()+1)).text(m.name()).end();
} else {
diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RoleDetail.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RoleDetail.java
index bfc258bc..f69f4871 100644
--- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RoleDetail.java
+++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RoleDetail.java
@@ -266,7 +266,7 @@ public class RoleDetail extends Page {
// History
rv.add(new AbsCell[] {
- new RefCell("See History",RoleHistory.HREF + "?role=" + pRole,false)
+ new RefCell("See History",RoleHistory.HREF + "?role=" + pRole,false,"class=greenbutton")
});
} else {
rv.add(new AbsCell[]{
diff --git a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RoleHistory.java b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RoleHistory.java
index fdf6f9e3..a9f0eeb0 100644
--- a/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RoleHistory.java
+++ b/auth/auth-gui/src/main/java/org/onap/aaf/auth/gui/pages/RoleHistory.java
@@ -60,9 +60,7 @@ public class RoleHistory extends Page {
static final String NAME="RoleHistory";
static final String HREF = "/gui/roleHistory";
static final String FIELDS[] = {"role","dates"};
- static final String WEBPHONE = "http://webphone.att.com/cgi-bin/webphones.pl?id=";
- static enum Month { JANUARY, FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY,
- AUGUST, SEPTEMBER, OCTOBER, NOVEMBER, DECEMBER };
+
public RoleHistory(final AAF_GUI gui, final Page ... breadcrumbs) throws APIException, IOException {
super(gui.env,NAME,HREF, FIELDS,
@@ -90,7 +88,7 @@ public class RoleHistory extends Page {
.done();
hgen.br();
- hgen.leaf("a", "href=#advanced_search","onclick=divVisibility('advanced_search');").text("Advanced Search").end()
+ hgen.leaf("a", "href=#advanced_search","onclick=divVisibility('advanced_search');","class=greenbutton").text("Advanced Search").end()
.divID("advanced_search", "style=display:none");
hgen.incr("table");
@@ -98,7 +96,7 @@ public class RoleHistory extends Page {
addDateRow(hgen,"End Date");
hgen.incr("tr").incr("td");
hgen.tagOnly("input", "type=button","value=Get History",
- "onclick=datesURL('"+HREF+"?role=" + obRole+"');");
+ "onclick=datesURL('"+HREF+"?role=" + obRole+"');","class=greenbutton");
hgen.end().end();
hgen.end();
hgen.end();
@@ -120,7 +118,7 @@ public class RoleHistory extends Page {
.incr("td")
.incr("select", "name=month"+s.substring(0, s.indexOf(' ')), "id=month"+s.substring(0, s.indexOf(' ')), "required")
.incr("option", "value=").text("Month").end();
- for (Month m : Month.values()) {
+ for (NsHistory.Month m : NsHistory.Month.values()) {
if (Calendar.getInstance().get(Calendar.MONTH) == m.ordinal()) {
hgen.incr("option", "selected", "value="+(m.ordinal()+1)).text(m.name()).end();
} else {
diff --git a/auth/auth-gui/theme/onap/aaf5.css b/auth/auth-gui/theme/onap/aaf5.css
index 67f03b27..ca9b3a77 100644
--- a/auth/auth-gui/theme/onap/aaf5.css
+++ b/auth/auth-gui/theme/onap/aaf5.css
@@ -350,7 +350,7 @@ div.detail caption {
color: white;
font-family: "Lucida Console", Monaco, monospace;
overflow-y: scroll;
- height: 300px;
+ height: 600px;
min-width: 600px;
padding: 5px;
resize: vertical;
diff --git a/auth/auth-gui/theme/onap/console.js b/auth/auth-gui/theme/onap/console.js
index f65c17b4..fe4f6494 100644
--- a/auth/auth-gui/theme/onap/console.js
+++ b/auth/auth-gui/theme/onap/console.js
@@ -29,7 +29,7 @@ function getCommand() {
cmds = document.querySelector("#command_field").value.split(" ");
var cleanCmd = "";
if (document.querySelector("#details_img").getAttribute("class") == "selected")
- cleanCmd += "set details=true ";
+ cleanCmd += "details ";
for (var i = 0; i < cmds.length;i++) {
var trimmed = cmds[i].trim();
if (trimmed != "")
@@ -286,7 +286,7 @@ function maximizeConsole(img) {
content.removeAttribute("class");
footer.style.display="";
console_area.style.resize="vertical";
- console_area.style.height="300px";
+ console_area.style.height="600px";
}
selectOption(img,0);
}