source: contrib/MailArchiver/sources/src/serpro/mailarchiver/view/admin/AdminConsoleLoginForm.java @ 6785

Revision 6785, 5.1 KB checked in by rafaelraymundo, 12 years ago (diff)

Ticket #2946 - Liberado codigo do MailArchiver?. Documentação na subpasta DOCS.

Line 
1/**
2 * MailArchiver is an application that provides services for storing and managing e-mail messages through a Web Services SOAP interface.
3 * Copyright (C) 2012  Marcio Andre Scholl Levien and Fernando Alberto Reuter Wendt and Jose Ronaldo Nogueira Fonseca Junior
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as
7 * published by the Free Software Foundation, either version 3 of the
8 * License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 */
18
19/******************************************************************************\
20*
21*  This product was developed by
22*
23*        SERVIÇO FEDERAL DE PROCESSAMENTO DE DADOS (SERPRO),
24*
25*  a government company established under Brazilian law (5.615/70),
26*  at Department of Development of Porto Alegre.
27*
28\******************************************************************************/
29
30package serpro.mailarchiver.view.admin;
31
32import java.io.UnsupportedEncodingException;
33
34import com.vaadin.terminal.gwt.client.ApplicationConnection;
35import com.vaadin.ui.LoginForm;
36
37public class AdminConsoleLoginForm extends LoginForm {
38
39    @Override
40    protected byte[] getLoginHTML() {
41        StringBuilder sb = new StringBuilder();
42
43        sb.append(
44
45  "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n"
46+ "<html>\n"
47+ "    <head>\n"
48+ "        <script type='text/javascript'>\n"
49+ "            var setTarget = function() {\n"
50+ "                var uri = '").append(getApplication().getURL().toString()).append(getWindow().getName()).append("/loginHandler';\n"
51+ "                var f = document.getElementById('loginf');\n"
52+ "                document.forms[0].action = uri;document.forms[0].username.focus();\n"
53+ "            };\n"
54+ "            var styles = window.parent.document.styleSheets;\n"
55+ "            for(var j = 0; j < styles.length; j++) {\n"
56+ "                if(styles[j].href) {\n"
57+ "                    var stylesheet = document.createElement('link');\n"
58+ "                    stylesheet.setAttribute('rel', 'stylesheet');\n"
59+ "                    stylesheet.setAttribute('type', 'text/css');\n"
60+ "                    stylesheet.setAttribute('href', styles[j].href);\n"
61+ "                    document.getElementsByTagName('head')[0].appendChild(stylesheet);\n"
62+ "                }\n"
63+ "            }\n"
64+ "            function submitOnEnter(e) {\n"
65+ "                var keycode = e.keyCode || e.which;\n"
66+ "                if (keycode == 13) {\n"
67+ "                    document.forms[0].submit();\n"
68+ "                }\n"
69+ "            }\n"
70+ "        </script>\n"
71+ "    </head>\n"
72+ "    <body onload='setTarget();' style='margin:0;padding:0; background:transparent;' class=\"").append(ApplicationConnection.GENERATED_BODY_CLASSNAME).append("\">\n"
73+ "        <div class='v-app v-app-loginpage' style=\"background:transparent;\">\n"
74+ "            <iframe name='logintarget' style='width:0;height:0;border:0;margin:0;padding:0;'></iframe>\n"
75+ "            <form id='loginf' target='logintarget' onkeypress=\"submitOnEnter(event)\" method=\"post\">\n"
76+ "                <table align=\"center\" width=\"100%\" height=\"100%\">\n"
77+ "                    <tr>\n"
78+ "                        <td align=\"right\">").append(getUsernameCaption()).append("</td>\n"
79+ "                        <td><input class='v-textfield' style='display:block;' type='text' name='username'></td>\n"
80+ "                    </tr>\n"
81+ "                    <tr>\n"
82+ "                        <td align=\"right\">").append(getPasswordCaption()).append("</td>\n"
83+ "                        <td><input class='v-textfield' style='display:block;' type='password' name='password'></td>\n"
84+ "                    </tr>\n"
85+ "                    <tr>\n"
86+ "                        <td></td>\n"
87+ "                        <td align=\"right\" >\n"
88+ "                            <div onclick=\"document.forms[0].submit();\" tabindex=\"0\" class=\"v-button\" role=\"button\">\n"
89+ "                                <span class=\"v-button-wrap\">\n"
90+ "                                    <span class=\"v-button-caption\">").append(getLoginButtonCaption()).append("</span>\n"
91+ "                                </span>\n"
92+ "                            </div>\n"
93+ "                        </td>\n"
94+ "                    </tr>\n"
95+ "                </table>\n"
96+ "            </form>\n"
97+ "        </div>\n"
98+ "    </body>\n"
99+ "</html>\n");
100
101        String html = sb.toString();
102
103        try {
104            return html.getBytes("UTF-8");
105        }
106        catch(UnsupportedEncodingException ex) {
107            throw new RuntimeException("UTF-8 encoding not avalable", ex);
108        }
109    }
110}
Note: See TracBrowser for help on using the repository browser.