-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I have my own login form and I want to make authentication in Composer event listener. Here is application-context
<http auto-config="true" use-expressions="true">
<intercept-url pattern="/zkau/**" access="permitAll"/>
<intercept-url pattern="/public/**" access="permitAll"/>
<intercept-url pattern="/images/**" access="permitAll"/>
<intercept-url pattern="/css/**" access="permitAll"/>
<intercept-url pattern="/js/**" access="permitAll"/>
<intercept-url pattern="/help/**" access="permitAll"/>
<intercept-url pattern="/personal/**" access="isAuthenticated()"/>
<intercept-url pattern="/**" access="isAuthenticated()"/>
<form-login login-page="/public/#login"/>
<logout logout-success-url="/public" invalidate-session="true"/>
</http>
And my Java code from composer
protected String readText(Textbox textbox, String errorMessage) {
String value = textbox.getValue();
if (StringUtils.isTrimedEmpty(value)) {
throw new WrongValueException(textbox, errorMessage);
} else {
return value;
}
}
/**
* Tries to authorize user with specified login and password
*/
public void authorize() {
String login = readText(loginText, "Необходимо ввести логин");
String password = readText(passwordText, "Необходимо ввести пароль");
try {
Authentication authentication = authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(login, password));
SecurityContext context = SecurityContextHolder.getContext();
context.setAuthentication(authentication);
session.setAttribute("SPRING_SECURITY_CONTEXT", context);
sessionAuthenticationStrategy.onAuthentication(authentication, (HttpServletRequest) execution.getNativeRequest(), (HttpServletResponse) execution.getNativeResponse());
Executions.getCurrent().sendRedirect("/index.zul");
But when is redirected to index.zul current session is not authenticated and Spring redirects back to /public#login
Hello Arsen,
Please look at the following example:
http://emrpms.blogspot.in/2013/03/zk-spring-security-login-formpart-2.html
Best Regards,
Darksu
Asked: 2015-02-15 16:28:37 +0800
Seen: 37 times
Last updated: Feb 21 '15