-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi guys and spring specialists,
Last week I secured my webapp with the spring framework. Everything works fine. The article found here works fine as well. But here is my big unsolved problem.
In the WEB-INF/applicationContext-security.xml I create a tag for my own login page like :
<http auto-config="true"> <intercept-url pattern="/secure/extreme/**" access="ROLE_SUPERVISOR"/> <intercept-url pattern="/secure/**" access="IS_AUTHENTICATED_REMEMBERED" /> <intercept-url pattern="/**" access="IS_AUTHENTICATED_ANONYMOUSLY" /> <!-- use own login page rather than the default one --> <form-login login-page="/login.zul"/> </http>
<zksp:zk-event login-template-close-delay="5"> <zksp:intercept-event event="onClick" path="//**/btn_*" access="ROLE_TELLER"/> <zksp:intercept-event path="/**" access="IS_AUTHENTICATED_ANONYMOUSLY"/> </zksp:zk-event>
hohoho, Maik, i'm not sure if i can help you :-)
I done all security intercepts in the java code.
Here is a rest of my xml code but it doesn't use it:
<zksp:zk-event login-template-close-delay="5">
<zksp:intercept-event event="onClick" path="//**/btn_*" access="IS_AUTHENTICATED_REMEBERED"/>
<zksp:intercept-event path="/**" access="IS_AUTHENTICATED_ANONYMOUSLY"/>
</zksp:zk-event>
regards
Stephan
I'm not at place, so i can only in the evening post here the the zul- and java code for the LoginDialog. And yes you are right, it's a mix from html and zul. This is copied by a friend of mine from a jsp project.
Hope in 1-2 weeks i check out fully sourced sample in ZK Forge.
Attached my used code, But it works not alone.
Stephan
Maik beschreib mir das doch mal auf deutsch. das ist für mich einfacher zu verstehen.
sge(at)forsthaus(dot)de
ZKLoginDialog.zul
<?page id="loginZul" title="LOGIN"?> <?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?> <zk xmlns="http://www.zkoss.org/2005/zul" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd"> <window id="loginwin" border="none" width="350px" use="org.myfirm.ZkLoginDialogCtrl"> <div style="background-color:#4944F9"> <hbox width="100%"> <h:div id="divNo" align="left"> <image src="/images/zkoss3.gif" /> </h:div> <h:div id="divNorthEast" align="right"> <button id="button_ZKLoginDialog_Close" image="/images/icons/stop.gif" tooltiptext="${c:l('button_ZKLoginDialog_Close.tooltiptext')}" /> </h:div> </hbox> <separator bar="true" style="background-color:silver" /> </div> <groupbox if="${not empty param.login_error}"> <label style="color:red" value="Login failed. Please try again." /> <h:br /> <label style="color:red" value="Reason: ${sessionScope.SPRING_SECURITY_LAST_EXCEPTION.message}" /> <h:br /> </groupbox> <groupbox> <caption>Login</caption> <div align="right" style="padding: 5px"> <hbox align="end"> <label id="lbl_ServerTime" /> <button id="button_ZKLoginDialog_ServerTime" image="/images/icons/date.gif" tooltiptext="${c:l('button_ZKLoginDialog_ServerTime.tooltiptext')}" /> </hbox> <separator bar="true" /> </div> <div> <h:form id="f" name="f" action="j_spring_security_check" method="POST"> <grid fixedLayout="true" style="border:0px"> <columns> <column width="40%" /> <column width="60%" /> </columns> <rows> <row> <label id="label_ZKLoginDialog_user" value="${c:l('label_ZKLoginDialog_user.value')}" /> <textbox id="u" name="j_username" width="99%" /> </row> <row> <label id="label_ZKLoginDialog_pwd" value="${c:l('label_ZKLoginDialog_pwd.value')}" /> <textbox id="p" type="password" name="j_password" width="99%" /> </row> <row spans="2"> <hbox> <h:input type="submit" value="Login" /> <h:input type="reset" value="Reset" /> </hbox> </row> </rows> </grid> </h:form> </div> </groupbox> </window> </zk>[ /code] <u > ZkLoginDialogCtr</u>l
import org.apache.log4j.Logger;
import org.myfirm.webui.util.BaseCtrl;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zul.Label;
import org.zkoss.zul.Window;
public class ZkLoginDialogCtrl extends BaseCtrl implements Serializable {
private transient final static Logger logger = Logger.getLogger(ZkLoginDialogCtrl.class);
private static final long serialVersionUID = -71422545405325060L;
/*
* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Components from the zul-file that are autowired through extending this
* class from BaseCtrl.java
* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
*/
protected Window loginwin; // autowired
protected Label lbl_ServerTime; // autowired
/**
* constructor. <br>
*/
public ZkLoginDialogCtrl() {
super();
if (logger.isDebugEnabled()) {
logger.debug("--> super() ");
}
}
public void onCreate$loginwin(Event event) throws Exception {
if (logger.isDebugEnabled()) {
logger.debug("--> " + event.toString());
}
doOnCreateCommon(loginwin); // do the autowire
loginwin.doModal();
}
/**
* when the "close" button is clicked. <br>
*
* @throws IOException
*/
public void onClick$button_ZKLoginDialog_Close() throws IOException {
if (logger.isDebugEnabled()) {
logger.debug("-->");
}
Executions.sendRedirect("/j_spring_logout");
}
/**
* when the "getServerTime" button is clicked. <br>
*
* @throws IOException
*/
public void onClick$button_ZKLoginDialog_ServerTime() throws IOException {
if (logger.isDebugEnabled()) {
logger.debug("--> get the server date/time");
}
lbl_ServerTime.setValue("time on server: " + getDateTime());
}
/**
* Get the actual date/time on server. <br>
*
* @return String of date/time
*/
private String getDateTime() {
DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
Date date = new Date();
return dateFormat.format(date);
}
}
Asked: 2009-07-22 10:03:44 +0800
Seen: 429 times
Last updated: Jul 22 '09