From 05927316da6f4a7d39b1f1719b29e17c948981c6 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Thu, 8 Feb 2007 11:05:21 +0000 Subject: [PATCH] Added session id to the result of authentication call. Updated Java web service client to pass session id on cookieif present in authentication details. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5075 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../authentication/AuthenticationResult.java | 40 ++++++++++++++++++- .../org/alfresco/repo/webservice/Utils.java | 24 ++++++++++- .../AuthenticationWebService.java | 5 ++- .../axis/TicketCallbackSpringHandler.java | 3 +- source/wsdl/authentication-service.wsdl | 1 + 5 files changed, 67 insertions(+), 6 deletions(-) diff --git a/source/generated/org/alfresco/repo/webservice/authentication/AuthenticationResult.java b/source/generated/org/alfresco/repo/webservice/authentication/AuthenticationResult.java index 1165518e0c..4cf80ebe16 100644 --- a/source/generated/org/alfresco/repo/webservice/authentication/AuthenticationResult.java +++ b/source/generated/org/alfresco/repo/webservice/authentication/AuthenticationResult.java @@ -12,14 +12,18 @@ public class AuthenticationResult implements java.io.Serializable { private java.lang.String ticket; + private java.lang.String sessionid; + public AuthenticationResult() { } public AuthenticationResult( java.lang.String username, - java.lang.String ticket) { + java.lang.String ticket, + java.lang.String sessionid) { this.username = username; this.ticket = ticket; + this.sessionid = sessionid; } @@ -62,6 +66,26 @@ public class AuthenticationResult implements java.io.Serializable { this.ticket = ticket; } + + /** + * Gets the sessionid value for this AuthenticationResult. + * + * @return sessionid + */ + public java.lang.String getSessionid() { + return sessionid; + } + + + /** + * Sets the sessionid value for this AuthenticationResult. + * + * @param sessionid + */ + public void setSessionid(java.lang.String sessionid) { + this.sessionid = sessionid; + } + private java.lang.Object __equalsCalc = null; public synchronized boolean equals(java.lang.Object obj) { if (!(obj instanceof AuthenticationResult)) return false; @@ -79,7 +103,10 @@ public class AuthenticationResult implements java.io.Serializable { this.username.equals(other.getUsername()))) && ((this.ticket==null && other.getTicket()==null) || (this.ticket!=null && - this.ticket.equals(other.getTicket()))); + this.ticket.equals(other.getTicket()))) && + ((this.sessionid==null && other.getSessionid()==null) || + (this.sessionid!=null && + this.sessionid.equals(other.getSessionid()))); __equalsCalc = null; return _equals; } @@ -97,6 +124,9 @@ public class AuthenticationResult implements java.io.Serializable { if (getTicket() != null) { _hashCode += getTicket().hashCode(); } + if (getSessionid() != null) { + _hashCode += getSessionid().hashCode(); + } __hashCodeCalc = false; return _hashCode; } @@ -119,6 +149,12 @@ public class AuthenticationResult implements java.io.Serializable { elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); elemField.setNillable(false); typeDesc.addFieldDesc(elemField); + elemField = new org.apache.axis.description.ElementDesc(); + elemField.setFieldName("sessionid"); + elemField.setXmlName(new javax.xml.namespace.QName("http://www.alfresco.org/ws/service/authentication/1.0", "sessionid")); + elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string")); + elemField.setNillable(true); + typeDesc.addFieldDesc(elemField); } /** diff --git a/source/java/org/alfresco/repo/webservice/Utils.java b/source/java/org/alfresco/repo/webservice/Utils.java index a798a370b3..8cd441714a 100644 --- a/source/java/org/alfresco/repo/webservice/Utils.java +++ b/source/java/org/alfresco/repo/webservice/Utils.java @@ -26,7 +26,9 @@ import java.util.Map; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; import javax.transaction.UserTransaction; +import javax.xml.rpc.server.ServletEndpointContext; import org.alfresco.repo.webservice.axis.QueryConfigHandler; import org.alfresco.repo.webservice.types.AssociationDefinition; @@ -520,7 +522,7 @@ public class Utils * @return a UserTransaction */ public static UserTransaction getUserTransaction(MessageContext msgContext) - { + { // get the service regsistry ServiceRegistry svcReg = (ServiceRegistry) getSpringContext(msgContext) .getBean(ServiceRegistry.SERVICE_REGISTRY); @@ -528,6 +530,26 @@ public class Utils TransactionService transactionService = svcReg.getTransactionService(); return transactionService.getUserTransaction(); } + + /** + * Gets the current http session id + * + * @return the current http session id, null if none found + */ + public static String getSessionId() + { + String result = null; + ServletEndpointContext endpointContext = (ServletEndpointContext)MessageContext.getCurrentContext().getProperty("servletEndpointContext"); + if (endpointContext != null) + { + HttpSession session = endpointContext.getHttpSession(); + if (session != null) + { + result = session.getId(); + } + } + return result; + } /** * Returns the value of the fetchSize from the diff --git a/source/java/org/alfresco/repo/webservice/authentication/AuthenticationWebService.java b/source/java/org/alfresco/repo/webservice/authentication/AuthenticationWebService.java index 4a7b20eaad..d601a3350d 100644 --- a/source/java/org/alfresco/repo/webservice/authentication/AuthenticationWebService.java +++ b/source/java/org/alfresco/repo/webservice/authentication/AuthenticationWebService.java @@ -19,6 +19,7 @@ package org.alfresco.repo.webservice.authentication; import java.rmi.RemoteException; import org.alfresco.repo.security.authentication.AuthenticationException; +import org.alfresco.repo.webservice.Utils; import org.alfresco.service.cmr.security.AuthenticationService; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -63,8 +64,8 @@ public class AuthenticationWebService implements AuthenticationServiceSoapPort { logger.debug("Issued ticket '" + ticket + "' for '" + username + "'"); } - - return new AuthenticationResult(username, ticket); + + return new AuthenticationResult(username, ticket, Utils.getSessionId()); } catch (AuthenticationException ae) { diff --git a/source/java/org/alfresco/repo/webservice/axis/TicketCallbackSpringHandler.java b/source/java/org/alfresco/repo/webservice/axis/TicketCallbackSpringHandler.java index 08ebc7ab13..e2b56166c1 100644 --- a/source/java/org/alfresco/repo/webservice/axis/TicketCallbackSpringHandler.java +++ b/source/java/org/alfresco/repo/webservice/axis/TicketCallbackSpringHandler.java @@ -41,7 +41,8 @@ import org.springframework.web.context.support.WebApplicationContextUtils; */ public class TicketCallbackSpringHandler extends BasicHandler { - private static final Log logger = LogFactory.getLog(TicketCallbackSpringHandler.class); + @SuppressWarnings("unused") +private static final Log logger = LogFactory.getLog(TicketCallbackSpringHandler.class); private static final String BEAN_NAME = "ticketCallbackHandler"; private static final long serialVersionUID = -135125831180499667L; diff --git a/source/wsdl/authentication-service.wsdl b/source/wsdl/authentication-service.wsdl index db339007c7..b27b097c80 100644 --- a/source/wsdl/authentication-service.wsdl +++ b/source/wsdl/authentication-service.wsdl @@ -47,6 +47,7 @@ +