Source Code Cross Referenced for LoginPage.java in  » Issue-Tracking » jTrac » info » jtrac » wicket » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Issue Tracking » jTrac » info.jtrac.wicket 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002-2005 the original author or authors.
003:         * 
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         * 
008:         *      http://www.apache.org/licenses/LICENSE-2.0
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:
017:        package info.jtrac.wicket;
018:
019:        import info.jtrac.Jtrac;
020:        import info.jtrac.domain.User;
021:        import info.jtrac.util.WebUtils;
022:        import javax.servlet.http.Cookie;
023:        import org.apache.wicket.behavior.HeaderContributor;
024:        import org.apache.wicket.markup.html.IHeaderContributor;
025:        import org.apache.wicket.markup.html.IHeaderResponse;
026:        import org.apache.wicket.markup.html.WebMarkupContainer;
027:        import org.apache.wicket.markup.html.WebPage;
028:        import org.apache.wicket.markup.html.basic.Label;
029:        import org.apache.wicket.markup.html.form.CheckBox;
030:        import org.apache.wicket.markup.html.form.PasswordTextField;
031:        import org.apache.wicket.markup.html.form.StatelessForm;
032:        import org.apache.wicket.markup.html.form.TextField;
033:        import org.apache.wicket.markup.html.panel.FeedbackPanel;
034:        import org.apache.wicket.model.BoundCompoundPropertyModel;
035:        import org.slf4j.Logger;
036:        import org.slf4j.LoggerFactory;
037:
038:        /**
039:         * login page
040:         */
041:        public class LoginPage extends WebPage {
042:
043:            private static final Logger logger = LoggerFactory
044:                    .getLogger(LoginPage.class);
045:
046:            private Jtrac getJtrac() {
047:                return ((JtracApplication) getApplication()).getJtrac();
048:            }
049:
050:            public LoginPage() {
051:                setVersioned(false);
052:                add(new Label("title", getLocalizer().getString("login.title",
053:                        null)));
054:                add(new LoginForm("form"));
055:                String jtracVersion = ComponentUtils.getJtrac(this )
056:                        .getReleaseVersion();
057:                add(new Label("version", jtracVersion));
058:            }
059:
060:            /**
061:             * wicket form
062:             */
063:            private class LoginForm extends StatelessForm {
064:
065:                private String loginName;
066:                private String password;
067:                private boolean rememberMe;
068:
069:                public String getLoginName() {
070:                    return loginName;
071:                }
072:
073:                public void setLoginName(String loginName) {
074:                    this .loginName = loginName;
075:                }
076:
077:                public String getPassword() {
078:                    return password;
079:                }
080:
081:                public void setPassword(String password) {
082:                    this .password = password;
083:                }
084:
085:                public boolean isRememberMe() {
086:                    return rememberMe;
087:                }
088:
089:                public void setRememberMe(boolean rememberMe) {
090:                    this .rememberMe = rememberMe;
091:                }
092:
093:                public LoginForm(String id) {
094:                    super (id);
095:                    add(new WebMarkupContainer("hide") {
096:                        @Override
097:                        public boolean isVisible() {
098:                            return !LoginForm.this .hasError();
099:                        }
100:                    });
101:                    add(new FeedbackPanel("feedback"));
102:                    setModel(new BoundCompoundPropertyModel(this ));
103:                    final TextField loginNameField = new TextField("loginName");
104:                    loginNameField.setOutputMarkupId(true);
105:                    add(loginNameField);
106:                    final PasswordTextField passwordField = new PasswordTextField(
107:                            "password");
108:                    passwordField.setRequired(false);
109:                    passwordField.setOutputMarkupId(true);
110:                    add(passwordField);
111:                    // intelligently set focus on the appropriate textbox
112:                    add(new HeaderContributor(new IHeaderContributor() {
113:                        public void renderHead(IHeaderResponse response) {
114:                            String markupId;
115:                            if (loginNameField.getConvertedInput() == null) {
116:                                markupId = loginNameField.getMarkupId();
117:                            } else {
118:                                markupId = passwordField.getMarkupId();
119:                            }
120:                            response
121:                                    .renderOnLoadJavascript("document.getElementById('"
122:                                            + markupId + "').focus()");
123:                        }
124:                    }));
125:                    add(new CheckBox("rememberMe"));
126:
127:                }
128:
129:                @Override
130:                protected void onSubmit() {
131:                    if (loginName == null || password == null) {
132:                        logger
133:                                .debug("login failed - login name or password is null");
134:                        error(getLocalizer().getString("login.error", null));
135:                        return;
136:                    }
137:                    User user = ((JtracApplication) getApplication())
138:                            .authenticate(loginName, password);
139:                    if (user == null) { // login failed                
140:                        error(getLocalizer().getString("login.error", null));
141:                    } else { // login success
142:                        // remember me cookie
143:                        if (rememberMe) {
144:                            Cookie cookie = new Cookie("jtrac", loginName + ":"
145:                                    + getJtrac().encodeClearText(password));
146:                            cookie.setMaxAge(30 * 24 * 60 * 60); // 30 days in seconds 
147:                            String path = getWebRequestCycle().getWebRequest()
148:                                    .getHttpServletRequest().getContextPath();
149:                            cookie.setPath(path);
150:                            getWebRequestCycle().getWebResponse().addCookie(
151:                                    cookie);
152:                            logger
153:                                    .debug("remember me requested, cookie added, "
154:                                            + WebUtils
155:                                                    .getDebugStringForCookie(cookie));
156:                        }
157:                        // setup session with principal
158:                        ((JtracSession) getSession()).setUser(user);
159:                        // proceed to bookmarkable page or default dashboard
160:                        if (!continueToOriginalDestination()) {
161:                            setResponsePage(DashboardPage.class);
162:                        }
163:                    }
164:                }
165:
166:            }
167:
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.