19 package org.turro.signin;
22 import java.io.IOException;
23 import java.util.logging.Level;
24 import java.util.logging.Logger;
25 import org.turro.string.Strings;
26 import org.turro.action.Actions;
27 import org.turro.auth.Authentication;
28 import org.turro.collections.KeyValueMap;
29 import org.turro.command.Command;
30 import org.turro.elephant.TemplateControl;
31 import org.turro.elephant.context.Application;
32 import org.turro.elephant.context.ElephantContext;
33 import org.turro.elephant.context.IConstructor;
34 import org.turro.elephant.security.IUser;
35 import org.turro.elephant.web.ElContext;
36 import org.turro.elephant.zkoss.Modal;
37 import org.turro.elephant.zkoss.ZkossElephant;
38 import org.turro.i18n.I_;
39 import org.turro.log.SystemLogType;
40 import org.turro.log.SystemLogger;
41 import org.zkoss.zk.ui.Executions;
42 import org.zkoss.zk.ui.event.Event;
43 import org.zkoss.zk.ui.event.InputEvent;
44 import org.zkoss.zk.ui.select.annotation.Listen;
45 import org.zkoss.zk.ui.select.annotation.Wire;
46 import org.zkoss.zk.ui.util.Clients;
47 import org.zkoss.zul.A;
48 import org.zkoss.zul.Checkbox;
49 import org.zkoss.zul.Div;
50 import org.zkoss.zul.Listbox;
51 import org.zkoss.zul.Listitem;
52 import org.zkoss.zul.Textbox;
64 private Div siginform;
70 private Textbox password;
73 private Checkbox storepass;
76 private Div sigoutform;
79 private Checkbox wadmin;
102 @Listen(
"onChanging = #user")
107 @Listen(
"onCheck = #wadmin")
109 org.turro.elephant.zkoss.ZkossElephant.doWebAdmin(wadmin.isChecked(), redir);
112 @Listen(
"onOK = #signinform; onClick = #signin")
114 if(storepass.isChecked()) {
127 }
catch (IOException ex) {
132 @Listen(
"onClick = #remind")
133 public
void onRemind(Event event) throws IOException {
134 Clients.clearWrongValue(user);
135 if(org.turro.elephant.zkoss.ZkossElephant.doSendReminder(user.getText())) {
136 Clients.showNotification(
I_.
get(
"A reminder has been sent"));
138 Clients.wrongValue(user,
I_.
get(
"Missing") +
": " +
I_.
get(
"User/Email"));
142 @Listen(
"onClick = #signout")
146 }
catch (IOException ex) {
151 @Listen(
"onClick = #profile")
152 public
void onProfile(Event event) throws IOException, InterruptedException {
154 Modal.
doModal(
"/WEB-INF/_zul/www/profile.zul", (Command)
null);
157 @Listen(
"onSelect = #lang")
159 String sel = lang.getSelectedItem().getValue();
165 Executions.getCurrent().sendRedirect(
"");
171 redir = Executions.getCurrent().getParameter(
"redir");
172 if(Strings.isBlank(redir)) {
176 siginform.setVisible(
true);
178 storepass.setChecked(
true);
180 if(!Strings.isBlank(xppass)) {
181 password.setValue(xppass);
184 if(map !=
null && map.containsKey(
"email")) {
185 user.setValue(map.get(
"email"));
192 sigoutform.setVisible(
true);
193 langs.setVisible(
false);
196 if(isInternalSignIn !=
null && isInternalSignIn) {
199 profile.setVisible(
false);
200 signout.setVisible(
false);
203 wadmin.setVisible(
true);
206 wadmin.setVisible(
false);
210 String currentLang = org.turro.elephant.zkoss.ZkossElephant.getCookieValue(
"lang");
211 lang.appendItem(
I_.
get(
"Browser's default"),
null);
212 for(String l : langs) {
213 Listitem li = lang.appendItem(
I_.
byKey(l), l);
214 if(l.equals(currentLang)) {
215 li.setSelected(
true);
static KeyValueMap getRightNowAction(IConstructor constructor)
static void doLogout(String redir)
static void doLogin(String login, String pass, String redir, Object extra)
static String decryptCookieValue(String name)
IConstructor getConstructor()
static String getCookieValue(String name)
static void encryptCookie(String name, String value, String path, int age)
static IContact getUser()
static Application getApplication()
static void deleteCookie(String name, String path)
static void setCookie(String name, String value, String path, int age)
abstract HttpServletRequest getHttpServletRequest()
static String getRealPath(String path)
static String logMsg(String msg)
static String getSiteLocales()
static String extractPath(String path)
static int doModal(String file)
static Application getCurrent()
static String byKey(String key)
static String get(String msg)
static ISystemLogger getInstance()
void onChangingUser(InputEvent evt)
void onProfile(Event event)
void onRemind(Event event)
boolean isWebAdministering()
Object getSessionAttribute(String key)
boolean canWebAdminister()
static final String INTERNAL_SIGNIN
void doLog(SystemLogType type, Object entity, String comment, Serializable data)