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.auth.Authentication;
27 import org.turro.command.Command;
28 import org.turro.elephant.context.Application;
29 import org.turro.elephant.context.ElephantContext;
30 import org.turro.elephant.context.IConstructor;
31 import org.turro.elephant.security.IUser;
32 import org.turro.elephant.zkoss.Modal;
33 import org.turro.elephant.zkoss.ZkossElephant;
34 import org.turro.i18n.I_;
35 import org.turro.log.SystemLogType;
36 import org.turro.log.SystemLogger;
37 import org.zkoss.zk.ui.Component;
38 import org.zkoss.zk.ui.Executions;
39 import org.zkoss.zk.ui.event.Event;
40 import org.zkoss.zk.ui.event.InputEvent;
41 import org.zkoss.zk.ui.select.SelectorComposer;
42 import org.zkoss.zk.ui.select.annotation.Listen;
43 import org.zkoss.zk.ui.select.annotation.Wire;
44 import org.zkoss.zk.ui.util.Clients;
45 import org.zkoss.zul.A;
46 import org.zkoss.zul.Checkbox;
47 import org.zkoss.zul.Div;
48 import org.zkoss.zul.Listbox;
49 import org.zkoss.zul.Listitem;
50 import org.zkoss.zul.Textbox;
62 private Div siginform;
68 private Textbox password;
71 private Checkbox storepass;
74 private Div sigoutform;
77 private Checkbox wadmin;
83 private Div personain;
86 private Div personaout;
97 @Listen(
"onChanging = #user")
99 personain.setVisible(Strings.isBlank(evt.getValue()));
102 @Listen(
"onCheck = #wadmin")
104 org.turro.elephant.zkoss.ZkossElephant.doWebAdmin(wadmin.isChecked(), redir);
107 @Listen(
"onOK = #signinform; onClick = #signin")
109 if(storepass.isChecked()) {
123 }
catch (IOException ex) {
128 @Listen(
"onClick = #remind")
129 public
void onRemind(Event event) throws IOException {
130 if(org.turro.elephant.zkoss.ZkossElephant.doSendReminder(user.getText())) {
131 Clients.showNotification(
I_.
get(
"A reminder has been sent"));
135 @Listen(
"onClick = #signout")
140 }
catch (IOException ex) {
145 @Listen(
"onClick = #profile")
146 public
void onProfile(Event event) throws IOException, InterruptedException {
148 Modal.
doModal(
"/WEB-INF/_zul/www/profile.zul", (Command)
null);
151 @Listen(
"onSelect = #lang")
153 String sel = lang.getSelectedItem().getValue();
159 Executions.getCurrent().sendRedirect(
"");
166 redir = Executions.getCurrent().getParameter(
"redir");
168 siginform.setVisible(
true);
170 storepass.setChecked(
true);
172 if(!Strings.isBlank(xppass)) {
173 password.setValue(xppass);
176 personain.setVisible(Strings.isBlank(user.getValue()));
179 sigoutform.setVisible(
true);
182 if(isInternalSignIn !=
null && isInternalSignIn) {
183 personaout.setVisible(
false);
185 profile.setVisible(
false);
186 signout.setVisible(
false);
189 wadmin.setVisible(
true);
192 wadmin.setVisible(
false);
196 String currentLang = org.turro.elephant.zkoss.ZkossElephant.getCookieValue(
"lang");
197 lang.appendItem(
I_.
get(
"Browser's default"),
null);
198 for(String l : langs) {
199 Listitem li = lang.appendItem(
I_.
byKey(l), l);
200 if(l.equals(currentLang)) {
201 li.setSelected(
true);
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)
static String getRealPath(String path)
static String logMsg(String msg)
static String getSiteLocales()
static int doModal(String file)
static String byKey(String key)
static String get(String msg)
static ISystemLogger getInstance()
void onRemind(Event event)
void onChangingUser(InputEvent evt)
void onProfile(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)