[opencms-dev] Problems with form-based login

JasDA at web.de JasDA at web.de
Mon Dec 10 15:49:41 CET 2007


I want to switch the authentication method of my OpenCMS installation to a form based login. Within the CMS  one default site is created. 

The admin area is called with:

The default site with:

To switch to a form based login I changed the opencms-system.xml to:

This index.html looks like:
page session="true"
import="org.opencms.main.*, org.opencms.jsp.*,org.opencms.file.*, java.lang.String"
CmsJspActionElement cms = new CmsJspActionElement(pageContext,request,response);
String user = request.getParameter("user");
String password = request.getParameter("password");
String url = request.getParameter("url");
if(url==null || url.length()==0 || url.equalsIgnoreCase("null")) url = "";
boolean loginFailed = false;
//form was submitted => try to log in and redirect to given URl
if((user != null) && (user.length() != 0)) {
		CmsObject cmsObject = cms.getCmsObject();
		cmsObject.loginUser(user, password);
		CmsProject cmsproject = cmsObject.readProject("Offline");
		//login successful - redirect to given URL
	} catch ( CmsException e ) {
		loginFailed = true;
//no user submitted or login failed => show login form
if(user==null || user.length()==0 || loginFailed) {
	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
		<title>Frontend login</title>
	<body onload="document.forms[0].elements[0].focus()">
	if (loginFailed) {
		<em>Login failed!</em>
	<h1>please login:</h1>
	<form method="post" action="<%=cms.info("opencms.url")%>">
		<input type="hidden" name="url" value="<%=url%>" />
		<p>username: <input name="user" /></p>
		<p>password: <input name="password" type="password" /></p>
		<p><input type="submit" /></p>

If I try this version I get an browser error, that the request could not be finished. Can anyone please help me?

Jetzt neu! Schützen Sie Ihren PC mit McAfee und WEB.DE. 3 Monate
kostenlos testen. http://www.pc-sicherheit.web.de/startseite/?mc=022220

More information about the opencms-dev mailing list