19 package org.turro.auth;
21 import java.io.IOException;
22 import java.util.logging.Level;
23 import java.util.logging.Logger;
24 import org.turro.string.Strings;
25 import org.turro.action.Actions;
26 import org.turro.collections.KeyValueMap;
27 import org.turro.elephant.TemplateControl;
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.web.ElContext;
33 import org.turro.elephant.zkoss.ZkossElephant;
34 import org.turro.external.Authentications;
35 import org.turro.i18n.I_;
36 import org.turro.sso.SSO;
37 import org.turro.zkoss.input.GenericCombobox;
38 import org.zkoss.zk.ui.Executions;
39 import org.zkoss.zk.ui.event.Event;
40 import org.zkoss.zk.ui.select.annotation.Listen;
41 import org.zkoss.zk.ui.select.annotation.Wire;
42 import org.zkoss.zk.ui.util.Clients;
43 import org.zkoss.zul.A;
44 import org.zkoss.zul.Checkbox;
45 import org.zkoss.zul.Div;
46 import org.zkoss.zul.Listbox;
47 import org.zkoss.zul.Listitem;
48 import org.zkoss.zul.Textbox;
59 private Div siginform;
62 private Div signupform;
64 @Wire(
"#procedencefield")
65 private Div procedencefield;
74 private Textbox password;
77 private Checkbox storepass;
80 private Div sigoutform;
83 private Checkbox wadmin;
97 @Listen(
"onCheck = #wadmin")
99 org.turro.elephant.zkoss.ZkossElephant.doWebAdmin(wadmin.isChecked(), redir);
102 @Listen(
"onOK = #signinform; onClick = #signin")
105 if(storepass.isChecked()) {
124 }
catch (IOException ex) {
128 Clients.showNotification(
I_.
format(
"To many attempts, wait %d minutes before trying again.", 30));
132 @Listen(
"onClick = #remind")
133 public
void onRemind(Event event) throws IOException {
137 @Listen(
"onClick = #signout")
141 }
catch (IOException ex) {
146 @Listen(
"onSelect = #lang")
148 String sel = lang.getSelectedItem().getValue();
154 Executions.getCurrent().sendRedirect(
"");
160 redir = Executions.getCurrent().getParameter(
"redir");
161 if(Strings.isBlank(redir)) {
165 storepass.setLabel(
I_.
get(
"Keep me signed"));
167 storepass.setLabel(
I_.
get(
"Remember me"));
170 siginform.setVisible(
true);
172 storepass.setChecked(
true);
178 if(!Strings.isBlank(xppass)) {
179 password.setValue(xppass);
183 if(map !=
null && map.containsKey(
"email")) {
184 user.setValue(map.get(
"email"));
192 sigoutform.setVisible(
true);
193 langs.setVisible(
false);
196 if(isInternalSignIn !=
null && isInternalSignIn) {
199 signout.setVisible(
false);
202 wadmin.setVisible(
true);
205 wadmin.setVisible(
false);
210 lang.appendItem(
I_.
get(
"Browser's default"),
null);
211 for(String l : langs) {
212 Listitem li = lang.appendItem(
I_.
byKey(l), l);
213 if(l.equals(currentLang)) {
214 li.setSelected(
true);
218 signupform.setVisible(userIn ==
null && signup.isVisible());
static KeyValueMap getRightNowAction(IConstructor constructor)
static boolean canLogin(String login, int minutes)
static void doLogout(String redir)
static void doLogin(String login, String pass, String redir, Object extra)
void onRemind(Event event)
static String decryptCookieValue(String name)
IConstructor getConstructor()
static String getCookieValue(String name)
abstract void sendRedirect(String uri)
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 boolean hasSignup()
static String getSiteName()
static String logMsg(String msg)
static String getSiteLocales()
static String extractPath(String path)
static Application getCurrent()
static boolean requiresProcedence()
static String format(String msg, Object... arguments)
static String byKey(String key)
static String get(String msg)
boolean isWebAdministering()
Object getSessionAttribute(String key)
boolean canWebAdminister()
static final String INTERNAL_SIGNIN