1 /*******************************************************************************
2 * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved.
3 *******************************************************************************/
4 package com.att.authz.gui.pages;
6 import java.io.IOException;
7 import java.net.URLDecoder;
9 import javax.servlet.http.HttpServletRequest;
11 import com.att.authz.env.AuthzTrans;
12 import com.att.authz.gui.AuthGUI;
13 import com.att.authz.gui.NamedCode;
14 import com.att.authz.gui.Page;
15 import org.onap.aaf.cadi.config.Config;
16 import org.onap.aaf.inno.env.APIException;
17 import com.att.xgen.Cache;
18 import com.att.xgen.DynamicCode;
19 import com.att.xgen.Mark;
20 import com.att.xgen.html.HTMLGen;
22 public class LoginLanding extends Page {
23 public static final String HREF = "/login";
24 static final String NAME = "Login";
25 static final String fields[] = {"id","password","environment"};
26 static final String envs[] = {"DEV","TEST","PROD"};
28 public LoginLanding(final AuthGUI gui, final Page ... breadcrumbs) throws APIException, IOException {
29 super(gui.env, NAME,HREF, fields, new NamedCode(true, "content") {
31 public void code(Cache<HTMLGen> cache, HTMLGen hgen) throws APIException, IOException {
32 hgen.leaf("p").text("No login credentials are found in your current session. " +
33 "Choose your preferred login option to continue.").end();
35 Mark loginPaths = hgen.divID("Pages");
37 cache.dynamic(hgen, new DynamicCode<HTMLGen, AuthGUI, AuthzTrans>() {
39 public void code(AuthGUI authGUI, AuthzTrans trans, Cache<HTMLGen> cache, HTMLGen xgen) throws APIException, IOException {
40 HttpServletRequest req = trans.get(gui.slot_httpServletRequest, null);
42 String query = req.getQueryString();
44 for(String qs : query.split("&")) {
45 int equals = qs.indexOf('=');
46 xgen.leaf(HTMLGen.A, "href="+URLDecoder.decode(qs.substring(equals+1),Config.UTF_8)).text(qs.substring(0,equals).replace('_', ' ')).end();
50 xgen.leaf(HTMLGen.A, "href=gui/home?Authentication=BasicAuth").text("AAF Basic Auth").end();
53 // hgen.leaf("a", "href=#","onclick=divVisibility('cso');").text("Global Login").end()
54 // .incr("p", "id=cso","style=display:none").text("this will redirect to global login").end()
55 // .leaf("a", "href=#","onclick=divVisibility('tguard');").text("tGuard").end()
56 // .incr("p", "id=tguard","style=display:none").text("this will redirect to tGuard login").end()
57 // hgen.leaf("a", "href=#","onclick=divVisibility('basicauth');").text("AAF Basic Auth").end();
60 // hgen.incr("form","method=post","style=display:none","id=basicauth","gui/home?Authentication=BasicAuth");
61 // Mark table = new Mark(TABLE);
63 // cache.dynamic(hgen, new DynamicCode<HTMLGen, AuthGUI, AuthzTrans>() {
65 // public void code(AuthGUI gui, AuthzTrans trans, Cache<HTMLGen> cache, HTMLGen hgen)
66 // throws APIException, IOException {
68 // .input(fields[0],"Username",true)
69 // .input(fields[1],"Password",true, "type=password");
70 // Mark selectRow = new Mark();
72 // .incr(selectRow, "tr")
74 // .incr("label", "for=envs", "required").text("Environment").end()
77 // .incr("select", "name=envs", "id=envs", "required")
78 // .incr("option", "value=").text("Select Environment").end();
79 // for (String env : envs) {
80 // hgen.incr("option", "value="+env).text(env).end();
89 // hgen.tagOnly("input", "type=submit", "value=Submit")
90 // .tagOnly("input", "type=reset", "value=Reset")