[opencms-dev] login on published pages of non-editors

Alexander Wallace aw at avatartechnology.com
Fri Jun 10 15:57:34 CEST 2005


there are multiple ways of doing it... What the book sugests is correct, but 
the package names have changed...  

Something like this can be used to create the users:

<%@ page import="org.opencms.jsp.CmsJspLoginBean" %>
<%@ page import="org.opencms.file.CmsUser" %>
<%@ page import="java.util.Hashtable" %>
(may need to add more here)
<%
CmsJspLoginBean cmsLogin = new CmsJspLoginBean(pageContext, request, 
response);

Hashtable params = new Hashtable();
params.put("whatever", "someValueOrObject");
try {
 user = cmsLogin.getCmsObject().addWebUser(username, password, "Guests",     
"some description", params);
user.setFirstname("name1");
user.setLastname("name2");
cmsLogin.getCmsObject().writeWebUser(user);
} catch (Exception e) {
 //FIXME: do something appropiate...
}
%>
Something like this can log you in:

cmsLogin.login(username, password);

And you can use cmsLogin.isLoggedIn() combined with any other checking you may 
want to do to decide if you let someone see a page by putting this in a 
template... There are other ways to do this too...

Hope this helps


On Friday 10 June 2005 01:38 am, bub habub wrote:
> hi,
> 
> i want to implement a login for some restricted aread
> of my homepage. how can i do that?
> i read in the open cms book that there are two ways to
> do it?
> i would like to do it with the built in webuser flag
> concept. but i couldn't find as this concept works.
> 
> the other method would be an authentication an
> webserver level but for that i understood that i have
> to configure tomcat. this would be very unhandy not
> having the user configuration in the workplace.
> 
> also i would like to have two groups of users one with
> download permission, one just with view permission.
> how can i do that?
> 
> thanks a lot
> 
> jap 
> 
> 
> 		
> __________________________________ 
> Discover Yahoo! 
> Get on-the-go sports scores, stock quotes, news and more. Check it out! 
> http://discover.yahoo.com/mobile.html
> 
> 
> _______________________________________________
> This mail is send to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://mail.opencms.org/mailman/listinfo/opencms-dev
> 



More information about the opencms-dev mailing list