2 * ============LICENSE_START====================================================
4 * ===========================================================================
5 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6 * ===========================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END====================================================
22 package org.onap.aaf.auth.gui.pages;
24 import java.io.IOException;
25 import java.net.URLDecoder;
27 import javax.servlet.http.HttpServletRequest;
29 import org.onap.aaf.auth.env.AuthzTrans;
30 import org.onap.aaf.auth.gui.AAF_GUI;
31 import org.onap.aaf.auth.gui.NamedCode;
32 import org.onap.aaf.auth.gui.Page;
33 import org.onap.aaf.cadi.config.Config;
34 import org.onap.aaf.misc.env.APIException;
35 import org.onap.aaf.misc.xgen.Cache;
36 import org.onap.aaf.misc.xgen.DynamicCode;
37 import org.onap.aaf.misc.xgen.Mark;
38 import org.onap.aaf.misc.xgen.html.HTMLGen;
40 public class LoginLanding extends Page {
41 public static final String HREF = "/login";
42 static final String NAME = "Login";
43 static final String fields[] = {"id","password","environment"};
44 static final String envs[] = {"DEV","TEST","PROD"};
46 public LoginLanding(final AAF_GUI gui, final Page ... breadcrumbs) throws APIException, IOException {
47 super(gui.env, NAME,HREF, fields, new NamedCode(true, "content") {
49 public void code(final Cache<HTMLGen> cache, final HTMLGen hgen) throws APIException, IOException {
50 hgen.leaf("p").text("No login credentials are found in your current session. " +
51 "Choose your preferred login option to continue.").end();
53 Mark loginPaths = hgen.divID("Pages");
55 cache.dynamic(hgen, new DynamicCode<HTMLGen, AAF_GUI, AuthzTrans>() {
57 public void code(AAF_GUI authGUI, AuthzTrans trans, Cache<HTMLGen> cache, HTMLGen xgen) throws APIException, IOException {
58 HttpServletRequest req = trans.get(gui.slot_httpServletRequest, null);
60 String query = req.getQueryString();
62 for (String qs : query.split("&")) {
63 int equals = qs.indexOf('=');
64 xgen.leaf(HTMLGen.A, "href="+URLDecoder.decode(qs.substring(equals+1),Config.UTF_8)).text(qs.substring(0,equals).replace('_', ' ')).end();
68 xgen.leaf(HTMLGen.A, "href=gui/home?Authentication=BasicAuth").text("AAF Basic Auth").end();
71 // hgen.leaf("a", "href=#","onclick=divVisibility('cso');").text("Global Login").end()
72 // .incr("p", "id=cso","style=display:none").text("this will redirect to global login").end()
73 // .leaf("a", "href=#","onclick=divVisibility('tguard');").text("tGuard").end()
74 // .incr("p", "id=tguard","style=display:none").text("this will redirect to tGuard login").end()
75 // hgen.leaf("a", "href=#","onclick=divVisibility('basicauth');").text("AAF Basic Auth").end();
78 // hgen.incr("form","method=post","style=display:none","id=basicauth","gui/home?Authentication=BasicAuth");
79 // Mark table = new Mark(TABLE);
81 // cache.dynamic(hgen, new DynamicCode<HTMLGen, AuthGUI, AuthzTrans>() {
83 // public void code(final AuthGUI gui, final AuthzTrans trans, final Cache<HTMLGen> cache, final HTMLGen hgen)
84 // throws APIException, IOException {
86 // .input(fields[0],"Username",true)
87 // .input(fields[1],"Password",true, "type=password");
88 // Mark selectRow = new Mark();
90 // .incr(selectRow, "tr")
92 // .incr("label", "for=envs", "required").text("Environment").end()
95 // .incr("select", "name=envs", "id=envs", "required")
96 // .incr("option", "value=").text("Select Environment").end();
97 // for (String env : envs) {
98 // hgen.incr("option", "value="+env).text(env).end();
107 // hgen.tagOnly("input", "type=submit", "value=Submit")
108 // .tagOnly("input", "type=reset", "value=Reset")