How to make auto login be available
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2005 11:30 AM
When I use hard code to set the username and password in login.jsp ,then make the form submit by itself ,this does not work.
How can I do it? plz help me
thx.
Leon
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-12-2006 09:11 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2006 05:23 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2006 11:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2006 11:57 AM
Thanks,
Kevin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2006 02:55 PM
I use http://usoakapp06:8082/alfresco/auto.jsp?username=username&password=password&id=e67af88f-27ee-11db-a... for auto login.
It works well for first time.
when i tried to login second time it is giving this excpetion
javax.faces.FacesException: Error calling action method of component with id loginForm:submit
caused by:
javax.faces.el.EvaluationException: Exception while invoking expression #{LoginBean.login}
caused by:
org.springframework.transaction.UnexpectedRollbackException: Transaction has been rolled back because it has been marked as rollback-only.
When i get this excpetion i can no longer login to alfresco with any user name and i have to restart the server to login again.
Can some one help to tell whats the problem in my jsp code.
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="org.alfresco.service.cmr.security.AuthenticationService"%>
<%@ page import="org.alfresco.web.bean.repository.*"%>
<%@ page import="org.alfresco.service.cmr.repository.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*"%>
<%@ page import="org.alfresco.web.bean.*"%>
<%@ page import="org.springframework.context.ApplicationContext"%>
<%@ page import="org.alfresco.util.ApplicationContextHelper"%>
<%@ page import="org.alfresco.service.ServiceRegistry"%>
<%@ page import="org.alfresco.web.app.servlet.AuthenticationHelper"%>
<%@ page import="org.alfresco.web.app.servlet.AuthenticationFilter"%>
<%@ page import="org.alfresco.model.ContentModel"%>
<%@ page import="org.springframework.web.jsf.FacesContextUtils"%>
<%@ page import="javax.faces.context.FacesContext"%>
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@ page import="org.springframework.web.context.WebApplicationContext"%>
<%@ page import="org.alfresco.service.cmr.security.PersonService"%>
<%@ page import="org.alfresco.web.bean.*"%>
<%@ page import="javax.transaction.UserTransaction"%>
<%
String username ="admin";
String password ="admin";
username = request.getParameter("username");
password = request.getParameter("password");
UserTransaction tx ;
AuthenticationService authenticationService = null;
/** NodeService bean reference */
NodeService nodeService = null;
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(application);
ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
tx = serviceRegistry.getTransactionService().getUserTransaction();
tx.begin();
// get individual, required services
nodeService = (NodeService)serviceRegistry.getNodeService();
authenticationService=(AuthenticationService)ctx.getBean("authenticationService");
PersonService personService = (PersonService)ctx.getBean("personService");
try {
//logout first
// invalidate User ticket
User user = (User)session.getValue(AuthenticationHelper.AUTHENTICATION_USER);
if (user != null)
{
authenticationService.invalidateTicket(user.getTicket());
Enumeration em= session.getAttributeNames();
while(em.hasMoreElements()) {
String name=(String)em.nextElement();
session.removeAttribute(name);
}
}
authenticationService.authenticate(username, password.toCharArray());
// setup User object and Home space ID
user = new User(authenticationService.getCurrentUserName(), authenticationService.getCurrentTicket(),personService.getPerson(username));
//user = (User)session.getAttribute(AUTHENTICATION_USER);
String homeSpaceId = null;
//nothing but workspace guid ,person or
//GUID for workspace from node_properties from the database
homeSpaceId = (String) request.getParameter("id");
// set the current user workspace
user.setHomeSpaceId(homeSpaceId);
tx.commit();
tx = null;
//inintialize the authentication session
session.putValue(AuthenticationHelper.AUTHENTICATION_USER, user);
out.println("user");
//get the noderep object form Noderef bean
NodeRef homeSpaceRef = new NodeRef(Repository.getStoreRef(), homeSpaceId);
out.println("Homespace ref" + homeSpaceRef);
out.println("user");
String homeSpaceName = Repository.getNameForNode((NodeService)serviceRegistry.getNodeService(), homeSpaceRef);
// move to actuale working service area
response.sendRedirect(request.getContextPath() + "/faces/jsp/browse/browse.jsp");
} catch (Exception ex) {
out.println("something is error." + ex.getMessage());
}
%>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2006 10:25 AM
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="org.alfresco.service.cmr.security.AuthenticationService"%>
<%@ page import="org.alfresco.web.bean.repository.*"%>
<%@ page import="org.alfresco.service.cmr.repository.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.io.*"%>
<%@ page import="org.alfresco.web.bean.*"%>
<%@ page import="org.springframework.context.ApplicationContext"%>
<%@ page import="org.alfresco.util.ApplicationContextHelper"%>
<%@ page import="org.alfresco.service.ServiceRegistry"%>
<%@ page import="org.alfresco.web.app.servlet.AuthenticationHelper"%>
<%@ page import="org.alfresco.web.app.servlet.AuthenticationFilter"%>
<%@ page import="org.alfresco.model.ContentModel"%>
<%@ page import="org.springframework.web.jsf.FacesContextUtils"%>
<%@ page import="javax.faces.context.FacesContext"%>
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@ page import="org.springframework.web.context.WebApplicationContext"%>
<%@ page import="org.alfresco.service.cmr.security.PersonService"%>
<%@ page import="org.alfresco.web.bean.*"%>
<%@ page import="javax.transaction.UserTransaction"%>
<%
User user = null;
String username ="joeb";
String password ="joeb";
UserTransaction tx ;
AuthenticationService authenticationService = null;
/** NodeService bean reference */
NodeService nodeService = null;
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext(application);
ServiceRegistry serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY);
tx = serviceRegistry.getTransactionService().getUserTransaction();
tx.begin();
// get individual, required services
nodeService = (NodeService)serviceRegistry.getNodeService();
authenticationService=(AuthenticationService)ctx.getBean("authenticationService");
PersonService personService = (PersonService)ctx.getBean("personService");
//logout first
// invalidate User ticket
try
{
try
{
user = (User)session.getValue(AuthenticationHelper.AUTHENTICATION_USER);
out.println("User is : " + user.toString());
if (user != null)
{
out.println("user was not null");
authenticationService.invalidateTicket(user.getTicket());
Enumeration em= session.getAttributeNames();
while(em.hasMoreElements())
{
String name=(String)em.nextElement();
session.removeAttribute(name);
}
}
}
catch (NullPointerException e)
{
out.println("User was null!");
authenticationService.authenticate(username, password.toCharArray());
// setup User object and Home space ID
user = new User(authenticationService.getCurrentUserName(), authenticationService.getCurrentTicket(),personService.getPerson(username));
out.println("New user is " + user);
NodeRef homeSpaceRef = (NodeRef) nodeService.getProperty(personService.getPerson(username), ContentModel.PROP_HOMEFOLDER);
// check that the home space node exists - else user cannot login
if (nodeService.exists(homeSpaceRef) == false)
{
throw new InvalidNodeRefException(homeSpaceRef);
}
user.setHomeSpaceId(homeSpaceRef.getId());
tx.commit();
tx = null;
//inintialize the authentication session
session.putValue(AuthenticationHelper.AUTHENTICATION_USER, user);
String homeSpaceName = Repository.getNameForNode((NodeService)serviceRegistry.getNodeService(), homeSpaceRef);
// move to actuale working service area
response.sendRedirect(request.getContextPath() + "/faces/jsp/browse/browse.jsp");
}
}
catch (Exception ex)
{
out.println("something is wrong." + ex.getMessage());
}
%>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2006 11:16 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-05-2006 03:55 AM
Have anyone upload the auto login servlet or jsp into the source forge?
If not can anyone send one copy to me?
why1525@gmail.com
Thanks you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2007 04:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-26-2007 10:16 AM