mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
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
This commit is contained in:
@@ -12,14 +12,18 @@ public class AuthenticationResult implements java.io.Serializable {
|
|||||||
|
|
||||||
private java.lang.String ticket;
|
private java.lang.String ticket;
|
||||||
|
|
||||||
|
private java.lang.String sessionid;
|
||||||
|
|
||||||
public AuthenticationResult() {
|
public AuthenticationResult() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthenticationResult(
|
public AuthenticationResult(
|
||||||
java.lang.String username,
|
java.lang.String username,
|
||||||
java.lang.String ticket) {
|
java.lang.String ticket,
|
||||||
|
java.lang.String sessionid) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.ticket = ticket;
|
this.ticket = ticket;
|
||||||
|
this.sessionid = sessionid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -62,6 +66,26 @@ public class AuthenticationResult implements java.io.Serializable {
|
|||||||
this.ticket = ticket;
|
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;
|
private java.lang.Object __equalsCalc = null;
|
||||||
public synchronized boolean equals(java.lang.Object obj) {
|
public synchronized boolean equals(java.lang.Object obj) {
|
||||||
if (!(obj instanceof AuthenticationResult)) return false;
|
if (!(obj instanceof AuthenticationResult)) return false;
|
||||||
@@ -79,7 +103,10 @@ public class AuthenticationResult implements java.io.Serializable {
|
|||||||
this.username.equals(other.getUsername()))) &&
|
this.username.equals(other.getUsername()))) &&
|
||||||
((this.ticket==null && other.getTicket()==null) ||
|
((this.ticket==null && other.getTicket()==null) ||
|
||||||
(this.ticket!=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;
|
__equalsCalc = null;
|
||||||
return _equals;
|
return _equals;
|
||||||
}
|
}
|
||||||
@@ -97,6 +124,9 @@ public class AuthenticationResult implements java.io.Serializable {
|
|||||||
if (getTicket() != null) {
|
if (getTicket() != null) {
|
||||||
_hashCode += getTicket().hashCode();
|
_hashCode += getTicket().hashCode();
|
||||||
}
|
}
|
||||||
|
if (getSessionid() != null) {
|
||||||
|
_hashCode += getSessionid().hashCode();
|
||||||
|
}
|
||||||
__hashCodeCalc = false;
|
__hashCodeCalc = false;
|
||||||
return _hashCode;
|
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.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
|
||||||
elemField.setNillable(false);
|
elemField.setNillable(false);
|
||||||
typeDesc.addFieldDesc(elemField);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -26,7 +26,9 @@ import java.util.Map;
|
|||||||
|
|
||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
import javax.transaction.UserTransaction;
|
import javax.transaction.UserTransaction;
|
||||||
|
import javax.xml.rpc.server.ServletEndpointContext;
|
||||||
|
|
||||||
import org.alfresco.repo.webservice.axis.QueryConfigHandler;
|
import org.alfresco.repo.webservice.axis.QueryConfigHandler;
|
||||||
import org.alfresco.repo.webservice.types.AssociationDefinition;
|
import org.alfresco.repo.webservice.types.AssociationDefinition;
|
||||||
@@ -520,7 +522,7 @@ public class Utils
|
|||||||
* @return a UserTransaction
|
* @return a UserTransaction
|
||||||
*/
|
*/
|
||||||
public static UserTransaction getUserTransaction(MessageContext msgContext)
|
public static UserTransaction getUserTransaction(MessageContext msgContext)
|
||||||
{
|
{
|
||||||
// get the service regsistry
|
// get the service regsistry
|
||||||
ServiceRegistry svcReg = (ServiceRegistry) getSpringContext(msgContext)
|
ServiceRegistry svcReg = (ServiceRegistry) getSpringContext(msgContext)
|
||||||
.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
.getBean(ServiceRegistry.SERVICE_REGISTRY);
|
||||||
@@ -528,6 +530,26 @@ public class Utils
|
|||||||
TransactionService transactionService = svcReg.getTransactionService();
|
TransactionService transactionService = svcReg.getTransactionService();
|
||||||
return transactionService.getUserTransaction();
|
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 <code>fetchSize</code> from the
|
* Returns the value of the <code>fetchSize</code> from the
|
||||||
|
@@ -19,6 +19,7 @@ package org.alfresco.repo.webservice.authentication;
|
|||||||
import java.rmi.RemoteException;
|
import java.rmi.RemoteException;
|
||||||
|
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationException;
|
import org.alfresco.repo.security.authentication.AuthenticationException;
|
||||||
|
import org.alfresco.repo.webservice.Utils;
|
||||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
@@ -63,8 +64,8 @@ public class AuthenticationWebService implements AuthenticationServiceSoapPort
|
|||||||
{
|
{
|
||||||
logger.debug("Issued ticket '" + ticket + "' for '" + username + "'");
|
logger.debug("Issued ticket '" + ticket + "' for '" + username + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new AuthenticationResult(username, ticket);
|
return new AuthenticationResult(username, ticket, Utils.getSessionId());
|
||||||
}
|
}
|
||||||
catch (AuthenticationException ae)
|
catch (AuthenticationException ae)
|
||||||
{
|
{
|
||||||
|
@@ -41,7 +41,8 @@ import org.springframework.web.context.support.WebApplicationContextUtils;
|
|||||||
*/
|
*/
|
||||||
public class TicketCallbackSpringHandler extends BasicHandler
|
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 String BEAN_NAME = "ticketCallbackHandler";
|
||||||
private static final long serialVersionUID = -135125831180499667L;
|
private static final long serialVersionUID = -135125831180499667L;
|
||||||
|
|
||||||
|
@@ -47,6 +47,7 @@
|
|||||||
<sequence>
|
<sequence>
|
||||||
<element name="username" nillable="false" type="xsd:string"/>
|
<element name="username" nillable="false" type="xsd:string"/>
|
||||||
<element name="ticket" nillable="false" type="xsd:string"/>
|
<element name="ticket" nillable="false" type="xsd:string"/>
|
||||||
|
<element name="sessionid" nillable="true" type="xsd:string"/>
|
||||||
</sequence>
|
</sequence>
|
||||||
</complexType>
|
</complexType>
|
||||||
<element name="AuthenticationResult" type="auth:AuthenticationResult"/>
|
<element name="AuthenticationResult" type="auth:AuthenticationResult"/>
|
||||||
|
Reference in New Issue
Block a user