diff --git a/config/alfresco/authentication-services-context.xml b/config/alfresco/authentication-services-context.xml index 00dedab58f..6a6f35832b 100644 --- a/config/alfresco/authentication-services-context.xml +++ b/config/alfresco/authentication-services-context.xml @@ -523,13 +523,13 @@ - + - PT1H + ${authentication.ticket.validDuration} - false + ${authentication.ticket.ticketsExpire} @@ -539,7 +539,7 @@ - AFTER_FIXED_TIME + ${authentication.ticket.expiryMode} diff --git a/config/alfresco/cache-context.xml b/config/alfresco/cache-context.xml index 151488b4cd..84a316b756 100644 --- a/config/alfresco/cache-context.xml +++ b/config/alfresco/cache-context.xml @@ -473,7 +473,7 @@ - + @@ -485,22 +485,7 @@ - - - - - - - - - org.alfresco.ticketsTransactionalCache - - - 10 - - - - + diff --git a/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/upgrade-from-2.1.sql b/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/upgrade-from-2.1.sql index 4847ab773a..d3500a2480 100644 --- a/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/upgrade-from-2.1.sql +++ b/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/upgrade-from-2.1.sql @@ -282,6 +282,7 @@ INSERT INTO t_summary_nstat (node_id, transaction_id) SELECT node_id, transaction_id FROM alf_node_status WHERE node_id IS NOT NULL; -- Copy data over +--BEGIN TXN LOCK TABLES t_alf_node WRITE, alf_node AS n READ, @@ -303,6 +304,7 @@ INSERT INTO t_alf_node JOIN t_summary_nstat nstat ON (nstat.node_id = n.id) JOIN t_alf_store s ON (s.protocol = n.protocol AND s.identifier = n.identifier) ; +--END TXN UNLOCK TABLES; DROP TABLE t_summary_nstat; @@ -371,6 +373,7 @@ CREATE TABLE t_alf_child_assoc UNIQUE (parent_node_id, type_qname_id, child_node_name_crc, child_node_name) ) TYPE=InnoDB; +--BEGIN TXN LOCK TABLES t_alf_child_assoc WRITE, alf_child_assoc AS ca READ, @@ -400,6 +403,7 @@ INSERT INTO t_alf_child_assoc JOIN t_qnames_dyn tqndyn ON (ca.qname = tqndyn.qname) JOIN t_qnames tqn ON (ca.type_qname = tqn.qname) ; +--END TXN UNLOCK TABLES; -- Clean up @@ -428,6 +432,7 @@ CREATE TABLE t_alf_node_assoc UNIQUE (source_node_id, target_node_id, type_qname_id) ) TYPE=InnoDB; +--BEGIN TXN LOCK TABLES t_alf_node_assoc WRITE, alf_node_assoc AS na READ, @@ -447,6 +452,7 @@ INSERT INTO t_alf_node_assoc alf_node_assoc na JOIN t_qnames tqn ON (na.type_qname = tqn.qname) ; +--END TXN UNLOCK TABLES; -- Clean up @@ -501,6 +507,7 @@ CREATE TABLE t_alf_node_aspects PRIMARY KEY (node_id, qname_id) ) TYPE=InnoDB; +--BEGIN TXN LOCK TABLES t_alf_node_aspects WRITE, alf_node_aspects AS na READ, @@ -520,6 +527,7 @@ INSERT INTO t_alf_node_aspects WHERE tqn.qname != '{http://www.alfresco.org/model/system/1.0}referenceable' ; +--END TXN UNLOCK TABLES; -- Clean up @@ -761,6 +769,7 @@ CREATE TABLE t_alf_node_properties PRIMARY KEY (node_id, qname_id, list_index, locale_id) ) TYPE=InnoDB; +--BEGIN TXN -- Copy values over LOCK TABLES t_alf_node_properties WRITE, @@ -791,7 +800,9 @@ INSERT INTO t_alf_node_properties WHERE np.attribute_value IS NULL ; +--END TXN UNLOCK TABLES; + -- Update cm:auditable properties on the nodes UPDATE t_alf_node n SET audit_creator = ( diff --git a/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/upgrade-from-2.2SP1.sql b/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/upgrade-from-2.2SP1.sql index a63d66afcb..5f02e50b1e 100644 --- a/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/upgrade-from-2.2SP1.sql +++ b/config/alfresco/dbscripts/upgrade/2.2/org.hibernate.dialect.MySQLInnoDBDialect/upgrade-from-2.2SP1.sql @@ -73,6 +73,7 @@ CREATE TABLE t_summary_nstat INSERT INTO t_summary_nstat (node_id, transaction_id) SELECT node_id, transaction_id FROM alf_node_status WHERE node_id IS NOT NULL; +--BEGIN TXN -- Copy data over LOCK TABLES t_alf_node WRITE, @@ -93,6 +94,7 @@ INSERT INTO t_alf_node JOIN t_summary_nstat nstat ON (nstat.node_id = n.id) JOIN t_alf_store s ON (s.protocol = n.protocol AND s.identifier = n.identifier) ; +--END TXN UNLOCK TABLES; DROP TABLE t_summary_nstat; @@ -161,6 +163,7 @@ CREATE TABLE t_alf_child_assoc UNIQUE (parent_node_id, type_qname_id, child_node_name_crc, child_node_name) ) TYPE=InnoDB; +--BEGIN TXN LOCK TABLES t_alf_child_assoc WRITE, alf_child_assoc AS ca READ @@ -186,6 +189,7 @@ INSERT INTO t_alf_child_assoc FROM alf_child_assoc ca ; +--END TXN UNLOCK TABLES; -- Clean up @@ -213,6 +217,7 @@ CREATE TABLE t_alf_node_assoc UNIQUE (source_node_id, target_node_id, type_qname_id) ) TYPE=InnoDB; +--BEGIN TXN LOCK TABLES t_alf_node_assoc WRITE, alf_node_assoc AS na READ @@ -230,6 +235,7 @@ INSERT INTO t_alf_node_assoc FROM alf_node_assoc na ; +--END TXN UNLOCK TABLES; -- Clean up @@ -284,6 +290,7 @@ CREATE TABLE t_alf_node_aspects PRIMARY KEY (node_id, qname_id) ) TYPE=InnoDB; +--BEGIN TXN LOCK TABLES t_alf_node_aspects WRITE, alf_node_aspects AS na READ, @@ -306,6 +313,7 @@ INSERT INTO t_alf_node_aspects ns.uri != 'http://www.alfresco.org/model/system/1.0' OR qn.local_name != 'referenceable' ; +--END TXN UNLOCK TABLES; -- Clean up @@ -477,6 +485,7 @@ CREATE TABLE t_alf_node_properties PRIMARY KEY (node_id, qname_id, list_index, locale_id) ) TYPE=InnoDB; +--BEGIN TXN -- Copy values over LOCK TABLES t_alf_node_properties WRITE, @@ -501,7 +510,9 @@ INSERT INTO t_alf_node_properties WHERE np.attribute_value IS NULL ; +--END TXN UNLOCK TABLES; + -- Update cm:auditable properties on the nodes UPDATE t_alf_node n SET audit_creator = ( diff --git a/config/alfresco/repository.properties b/config/alfresco/repository.properties index 3ae1580b7b..a189ab741a 100644 --- a/config/alfresco/repository.properties +++ b/config/alfresco/repository.properties @@ -412,6 +412,20 @@ V2.1-A.fixes.to.schema=0 # The default authentication chain authentication.chain=alfrescoNtlm1:alfrescoNtlm +# Do authentication tickets expire or live for ever? +authentication.ticket.ticketsExpire=false + +# If ticketsEpire is true then how they should expire? +# Valid values are: AFTER_INACTIVITY, AFTER_FIXED_TIME, DO_NOT_EXPIRE +# The default is AFTER_FIXED_TIME +authentication.ticket.expiryMode=AFTER_FIXED_TIME + +# If authentication.ticket.ticketsExpire is true and +# authentication.ticket.expiryMode is AFTER_FIXED_TIME or AFTER_INACTIVITY, +# this controls the minimum period for which tickets are valid. +# The default is PT1H for one hour. +authentication.ticket.validDuration=PT1H + # Default NFS user mappings nfs.user.mappings=admin nfs.user.mappings.default.uid=0 diff --git a/source/java/org/alfresco/filesys/auth/cifs/AlfrescoCifsAuthenticator.java b/source/java/org/alfresco/filesys/auth/cifs/AlfrescoCifsAuthenticator.java index f6cffc57b9..4b028dc020 100644 --- a/source/java/org/alfresco/filesys/auth/cifs/AlfrescoCifsAuthenticator.java +++ b/source/java/org/alfresco/filesys/auth/cifs/AlfrescoCifsAuthenticator.java @@ -116,7 +116,7 @@ public class AlfrescoCifsAuthenticator extends CifsAuthenticatorBase { // Use the existing authentication token - getAuthenticationService().validate(alfClient.getAuthenticationTicket(), null); + getAuthenticationService().validate(alfClient.getAuthenticationTicket()); // Debug diff --git a/source/java/org/alfresco/filesys/auth/cifs/CifsAuthenticatorBase.java b/source/java/org/alfresco/filesys/auth/cifs/CifsAuthenticatorBase.java index 05c9f7d88f..8d5f3c7b59 100644 --- a/source/java/org/alfresco/filesys/auth/cifs/CifsAuthenticatorBase.java +++ b/source/java/org/alfresco/filesys/auth/cifs/CifsAuthenticatorBase.java @@ -433,7 +433,7 @@ public abstract class CifsAuthenticatorBase extends CifsAuthenticator implements { try { - getAuthenticationService().validate(alfClient.getAuthenticationTicket(), null); + getAuthenticationService().validate(alfClient.getAuthenticationTicket()); } catch (AuthenticationException e) { diff --git a/source/java/org/alfresco/filesys/auth/cifs/PassthruCifsAuthenticator.java b/source/java/org/alfresco/filesys/auth/cifs/PassthruCifsAuthenticator.java index d03d201505..84939fc8a4 100644 --- a/source/java/org/alfresco/filesys/auth/cifs/PassthruCifsAuthenticator.java +++ b/source/java/org/alfresco/filesys/auth/cifs/PassthruCifsAuthenticator.java @@ -188,7 +188,7 @@ public class PassthruCifsAuthenticator extends CifsAuthenticatorBase implements { // Use the existing authentication token - getAuthenticationService().validate(alfClient.getAuthenticationTicket(), null); + getAuthenticationService().validate(alfClient.getAuthenticationTicket()); // Debug @@ -269,41 +269,32 @@ public class PassthruCifsAuthenticator extends CifsAuthenticatorBase implements else { // Map the passthru username to an Alfresco person - + String username = client.getUserName(); - String personName = getPersonService().getUserIdentifier(username); - if (null == personName) - { - personName = username; - } - if ( personName != null) - { - // Use the person name as the current user - getAuthenticationComponent().setCurrentUser(personName); - alfClient.setAuthenticationTicket(getAuthenticationService().getCurrentTicket()); - - // DEBUG - - if ( logger.isDebugEnabled()) - logger.debug("Setting current user using person " + personName + " (username " + username + ")"); - - // Allow the user full access to the server - - authSts = ICifsAuthenticator.AUTH_ALLOW; - - // Debug - - if (logger.isDebugEnabled()) - logger.debug("Passthru authenticate user=" + client.getUserName() + ", FULL"); - } - else if ( logger.isDebugEnabled()) - logger.debug("Failed to find person matching user " + username); + // Use the person name as the current user + + getAuthenticationComponent().setCurrentUser(username); + alfClient.setAuthenticationTicket(getAuthenticationService().getCurrentTicket()); + + // DEBUG + + if ( logger.isDebugEnabled()) + logger.debug("Setting current user using person " + getAuthenticationComponent().getCurrentUserName() + " (username " + username + ")"); + + // Allow the user full access to the server + + authSts = ICifsAuthenticator.AUTH_ALLOW; + + // Debug + + if (logger.isDebugEnabled()) + logger.debug("Passthru authenticate user=" + client.getUserName() + ", FULL"); } } - catch (AuthenticationException ex) + catch (AuthenticationException e) { - logger.debug("User invalid or max tickets exceeded", ex); + throw e; } catch (Exception ex) { diff --git a/source/java/org/alfresco/filesys/auth/nfs/AlfrescoRpcAuthenticator.java b/source/java/org/alfresco/filesys/auth/nfs/AlfrescoRpcAuthenticator.java index f67f53feb6..af32f6f359 100644 --- a/source/java/org/alfresco/filesys/auth/nfs/AlfrescoRpcAuthenticator.java +++ b/source/java/org/alfresco/filesys/auth/nfs/AlfrescoRpcAuthenticator.java @@ -313,7 +313,7 @@ public class AlfrescoRpcAuthenticator implements RpcAuthenticator, InitializingB { // Set the authentication context for the request - getAuthenticationService().validate(alfClient.getAuthenticationTicket(), null); + getAuthenticationService().validate(alfClient.getAuthenticationTicket()); // DEBUG diff --git a/source/java/org/alfresco/filesys/repo/ContentIOControlHandler.java b/source/java/org/alfresco/filesys/repo/ContentIOControlHandler.java index 243f751281..2649603fc3 100644 --- a/source/java/org/alfresco/filesys/repo/ContentIOControlHandler.java +++ b/source/java/org/alfresco/filesys/repo/ContentIOControlHandler.java @@ -748,7 +748,7 @@ public class ContentIOControlHandler implements IOControlHandler { // Validate the existing ticket - getAuthenticationService().validate( cInfo.getAuthenticationTicket(), null); + getAuthenticationService().validate( cInfo.getAuthenticationTicket()); needTicket = false; } catch ( AuthenticationException ex) @@ -757,7 +757,7 @@ public class ContentIOControlHandler implements IOControlHandler try { - getAuthenticationService().invalidateTicket( cInfo.getAuthenticationTicket(), null); + getAuthenticationService().invalidateTicket( cInfo.getAuthenticationTicket()); cInfo.setAuthenticationTicket( null); } catch (Exception ex2) diff --git a/source/java/org/alfresco/jcr/session/SessionImpl.java b/source/java/org/alfresco/jcr/session/SessionImpl.java index 754786a5f8..b206aaaf4f 100644 --- a/source/java/org/alfresco/jcr/session/SessionImpl.java +++ b/source/java/org/alfresco/jcr/session/SessionImpl.java @@ -651,7 +651,7 @@ public class SessionImpl implements Session { try { - getRepositoryImpl().getServiceRegistry().getAuthenticationService().invalidateTicket(getTicket(), null); + getRepositoryImpl().getServiceRegistry().getAuthenticationService().invalidateTicket(getTicket()); } finally { diff --git a/source/java/org/alfresco/jcr/util/JCRProxyFactory.java b/source/java/org/alfresco/jcr/util/JCRProxyFactory.java index 204bf236be..0c6e6652dd 100644 --- a/source/java/org/alfresco/jcr/util/JCRProxyFactory.java +++ b/source/java/org/alfresco/jcr/util/JCRProxyFactory.java @@ -124,7 +124,7 @@ public class JCRProxyFactory { if (username == null) { - authenticationService.validate(session.getTicket(), null); + authenticationService.validate(session.getTicket()); } } diff --git a/source/java/org/alfresco/repo/action/ActionServiceTransportImpl.java b/source/java/org/alfresco/repo/action/ActionServiceTransportImpl.java index 9fe1bf8955..2e2aa57622 100644 --- a/source/java/org/alfresco/repo/action/ActionServiceTransportImpl.java +++ b/source/java/org/alfresco/repo/action/ActionServiceTransportImpl.java @@ -59,7 +59,7 @@ public class ActionServiceTransportImpl implements ActionServiceTransport */ public Action createAction(String ticket, String name) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); return fActionService.createAction(name); } @@ -69,7 +69,7 @@ public class ActionServiceTransportImpl implements ActionServiceTransport public Action createAction(String ticket, String name, Map params) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); return fActionService.createAction(name, params); } @@ -78,7 +78,7 @@ public class ActionServiceTransportImpl implements ActionServiceTransport */ public ActionCondition createActionCondition(String ticket, String name) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); return fActionService.createActionCondition(name); } @@ -88,7 +88,7 @@ public class ActionServiceTransportImpl implements ActionServiceTransport public ActionCondition createActionCondition(String ticket, String name, Map params) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); return fActionService.createActionCondition(name, params); } @@ -97,7 +97,7 @@ public class ActionServiceTransportImpl implements ActionServiceTransport */ public CompositeAction createCompositeAction(String ticket) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); return fActionService.createCompositeAction(); } @@ -107,7 +107,7 @@ public class ActionServiceTransportImpl implements ActionServiceTransport public boolean evaluateAction(String ticket, Action action, NodeRef actionedUponNodeRef) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); return fActionService.evaluateAction(action, actionedUponNodeRef); } @@ -117,7 +117,7 @@ public class ActionServiceTransportImpl implements ActionServiceTransport public boolean evaluateActionCondition(String ticket, ActionCondition condition, NodeRef actionedUponNodeRef) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); return fActionService.evaluateActionCondition(condition, actionedUponNodeRef); } @@ -127,7 +127,7 @@ public class ActionServiceTransportImpl implements ActionServiceTransport public void executeAction(String ticket, Action action, NodeRef actionedUponNodeRef) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); fActionService.executeAction(action, actionedUponNodeRef); } @@ -137,7 +137,7 @@ public class ActionServiceTransportImpl implements ActionServiceTransport public void executeAction(String ticket, Action action, NodeRef actionedUponNodeRef, boolean checkConditions) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); fActionService.executeAction(action, actionedUponNodeRef, checkConditions); } @@ -148,7 +148,7 @@ public class ActionServiceTransportImpl implements ActionServiceTransport NodeRef actionedUponNodeRef, boolean checkConditions, boolean executeAsynchronously) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); fActionService.executeAction(action, actionedUponNodeRef, checkConditions, executeAsynchronously); } @@ -157,7 +157,7 @@ public class ActionServiceTransportImpl implements ActionServiceTransport */ public Action getAction(String ticket, NodeRef nodeRef, String actionId) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); return fActionService.getAction(nodeRef, actionId); } @@ -167,7 +167,7 @@ public class ActionServiceTransportImpl implements ActionServiceTransport public ActionConditionDefinition getActionConditionDefinition( String ticket, String name) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); return fActionService.getActionConditionDefinition(name); } @@ -177,7 +177,7 @@ public class ActionServiceTransportImpl implements ActionServiceTransport public List getActionConditionDefinitions( String ticket) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); return fActionService.getActionConditionDefinitions(); } @@ -186,7 +186,7 @@ public class ActionServiceTransportImpl implements ActionServiceTransport */ public ActionDefinition getActionDefinition(String ticket, String name) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); return fActionService.getActionDefinition(name); } @@ -195,7 +195,7 @@ public class ActionServiceTransportImpl implements ActionServiceTransport */ public List getActionDefinitions(String ticket) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); return fActionService.getActionDefinitions(); } @@ -205,7 +205,7 @@ public class ActionServiceTransportImpl implements ActionServiceTransport public List getActionDefinitions(String ticket, NodeRef nodeRef) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); return fActionService.getActionDefinitions(nodeRef); } @@ -214,7 +214,7 @@ public class ActionServiceTransportImpl implements ActionServiceTransport */ public ParameterConstraint getParameterConstraint(String ticket, String name) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); return fActionService.getParameterConstraint(name); } @@ -223,7 +223,7 @@ public class ActionServiceTransportImpl implements ActionServiceTransport */ public List getParameterConstraints(String ticket) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); return fActionService.getParameterConstraints(); } @@ -232,7 +232,7 @@ public class ActionServiceTransportImpl implements ActionServiceTransport */ public List getActions(String ticket, NodeRef nodeRef) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); return fActionService.getActions(nodeRef); } @@ -241,7 +241,7 @@ public class ActionServiceTransportImpl implements ActionServiceTransport */ public void removeAction(String ticket, NodeRef nodeRef, Action action) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); fActionService.removeAction(nodeRef, action); } @@ -250,7 +250,7 @@ public class ActionServiceTransportImpl implements ActionServiceTransport */ public void removeAllActions(String ticket, NodeRef nodeRef) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); fActionService.removeAllActions(nodeRef); } @@ -259,7 +259,7 @@ public class ActionServiceTransportImpl implements ActionServiceTransport */ public void saveAction(String ticket, NodeRef nodeRef, Action action) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); fActionService.saveAction(nodeRef, action); } } diff --git a/source/java/org/alfresco/repo/avm/AVMRemoteTransportService.java b/source/java/org/alfresco/repo/avm/AVMRemoteTransportService.java index 9933b9fe5b..b7c58a5a81 100644 --- a/source/java/org/alfresco/repo/avm/AVMRemoteTransportService.java +++ b/source/java/org/alfresco/repo/avm/AVMRemoteTransportService.java @@ -257,7 +257,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public String getInputHandle(String ticket, int version, String path) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); InputStream in = fAVMService.getFileInputStream(version, path); String handle = GUID.generate(); synchronized (this) @@ -274,7 +274,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public String getInputHandle(String ticket, AVMNodeDescriptor desc) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); InputStream in = fAVMService.getFileInputStream(desc); String handle = GUID.generate(); synchronized (this) @@ -294,7 +294,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public byte [] readInput(String ticket, String handle, int count) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); InputStream in = null; synchronized (this) { @@ -347,7 +347,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public synchronized void closeInputHandle(String ticket, String handle) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); InputStream in = fInputStreams.get(handle); if (in != null) { @@ -372,7 +372,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public String getOutputHandle(String ticket, String path) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); OutputStream out = fAVMService.getFileOutputStream(path); String handle = GUID.generate(); synchronized (this) @@ -394,7 +394,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void writeOutput(String ticket, String handle, byte [] buff, int count) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); OutputStream out = null; synchronized (this) { @@ -429,7 +429,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public synchronized void closeOutputHandle(String ticket, String handle) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); OutputStream out = fOutputStreams.get(handle); if (out != null) { @@ -456,7 +456,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable public SortedMap getDirectoryListingDirect(String ticket, int version, String path) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.getDirectoryListingDirect(version, path); } @@ -469,7 +469,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable public SortedMap getDirectoryListing(String ticket, int version, String path) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.getDirectoryListing(version, path); } @@ -481,7 +481,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable public SortedMap getDirectoryListing(String ticket, AVMNodeDescriptor dir) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.getDirectoryListing(dir); } @@ -493,7 +493,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public List getDeleted(String ticket, int version, String path) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.getDeleted(version, path); } @@ -505,7 +505,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public String createFile(String ticket, String path, String name) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); OutputStream out = fAVMService.createFile(path, name); String handle = GUID.generate(); synchronized (this) @@ -524,7 +524,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void createDirectory(String ticket, String path, String name) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.createDirectory(path, name); } @@ -536,7 +536,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void createLayeredFile(String ticket, String targetPath, String parent, String name) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.createLayeredFile(targetPath, parent, name); } @@ -548,7 +548,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void createLayeredDirectory(String ticket, String targetPath, String parent, String name) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.createLayeredDirectory(targetPath, parent, name); } @@ -559,7 +559,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void retargetLayeredDirectory(String ticket, String path, String target) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.retargetLayeredDirectory(path, target); } @@ -569,7 +569,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void createStore(String ticket, String name) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.createStore(name); } @@ -582,7 +582,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void createBranch(String ticket, int version, String srcPath, String dstPath, String name) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.createBranch(version, srcPath, dstPath, name); } @@ -593,7 +593,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void removeNode(String ticket, String parent, String name) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.removeNode(parent, name); } @@ -606,7 +606,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void rename(String ticket, String srcParent, String srcName, String dstParent, String dstName) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.rename(srcParent, srcName, dstParent, dstName); } @@ -617,7 +617,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void uncover(String ticket, String dirPath, String name) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.uncover(dirPath, name); } @@ -628,7 +628,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public int getNextVersionID(String ticket, String storeName) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.getNextVersionID(storeName); } @@ -649,7 +649,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public Map createSnapshot(String ticket, String store, String label, String comment) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.createSnapshot(store, label, comment); } @@ -660,7 +660,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public List getStoreVersions(String ticket, String name) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.getStoreVersions(name); } @@ -673,7 +673,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public List getStoreVersions(String ticket, String name, Date from, Date to) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.getStoreVersions(name, from, to); } @@ -683,7 +683,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public List getStores(String ticket) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.getStores(); } @@ -694,7 +694,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public AVMStoreDescriptor getStore(String ticket, String name) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.getStore(name); } @@ -706,7 +706,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public AVMNodeDescriptor getStoreRoot(String ticket, int version, String name) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.getStoreRoot(version, name); } @@ -718,7 +718,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public AVMNodeDescriptor lookup(String ticket, int version, String path) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.lookup(version, path); } @@ -734,7 +734,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public AVMNodeDescriptor lookup(String ticket, int version, String path, boolean includeDeleted) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.lookup(version, path, includeDeleted); } @@ -747,7 +747,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public AVMNodeDescriptor lookup(String ticket, AVMNodeDescriptor dir, String name) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.lookup(dir, name); } @@ -765,7 +765,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public AVMNodeDescriptor lookup(String ticket, AVMNodeDescriptor dir, String name, boolean includeDeleted) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.lookup(dir, name, includeDeleted); } @@ -778,7 +778,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public String getIndirectionPath(String ticket, int version, String path) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.getIndirectionPath(version, path); } @@ -788,7 +788,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void purgeStore(String ticket, String name) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.purgeStore(name); } @@ -799,7 +799,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void purgeVersion(String ticket, int version, String name) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.purgeVersion(version, name); } @@ -809,7 +809,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void makePrimary(String ticket, String path) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.makePrimary(path); } @@ -821,7 +821,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public List getHistory(String ticket, AVMNodeDescriptor desc, int count) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.getHistory(desc, count); } @@ -832,7 +832,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void setOpacity(String ticket, String path, boolean opacity) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.setOpacity(path, opacity); } @@ -844,7 +844,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public AVMNodeDescriptor getCommonAncestor(String ticket, AVMNodeDescriptor left, AVMNodeDescriptor right) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.getCommonAncestor(left, right); } @@ -856,7 +856,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public LayeringDescriptor getLayeringInfo(String ticket, int version, String path) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.getLayeringInfo(version, path); } @@ -868,7 +868,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void setNodeProperty(String ticket, String path, QName name, PropertyValue value) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.setNodeProperty(path, name, value); } @@ -879,7 +879,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void setNodeProperties(String ticket, String path, Map properties) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.setNodeProperties(path, properties); } @@ -892,7 +892,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public PropertyValue getNodeProperty(String ticket, int version, String path, QName name) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.getNodeProperty(version, path, name); } @@ -904,7 +904,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public Map getNodeProperties(String ticket, int version, String path) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.getNodeProperties(version, path); } @@ -915,7 +915,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void deleteNodeProperty(String ticket, String path, QName name) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.deleteNodeProperty(path, name); } @@ -925,7 +925,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void deleteNodeProperties(String ticket, String path) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.deleteNodeProperties(path); } @@ -937,7 +937,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void setStoreProperty(String ticket, String store, QName name, PropertyValue value) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.setStoreProperty(store, name, value); } @@ -948,7 +948,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void setStoreProperties(String ticket, String store, Map props) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.setStoreProperties(store, props); } @@ -960,7 +960,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public PropertyValue getStoreProperty(String ticket, String store, QName name) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.getStoreProperty(store, name); } @@ -972,7 +972,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public Map queryStorePropertyKey(String ticket, String store, QName keyPattern) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.queryStorePropertyKey(store, keyPattern); } @@ -983,7 +983,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public Map> queryStoresPropertyKey(String ticket, QName keyPattern) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.queryStoresPropertyKeys(keyPattern); } @@ -994,7 +994,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public Map getStoreProperties(String ticket, String store) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.getStoreProperties(store); } @@ -1005,7 +1005,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void deleteStoreProperty(String ticket, String store, QName name) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.deleteStoreProperty(store, name); } @@ -1014,7 +1014,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void renameStore(String ticket, String sourceName, String destName) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.renameStore(sourceName, destName); } @@ -1023,7 +1023,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void addAspect(String ticket, String path, QName aspectName) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.addAspect(path, aspectName); } @@ -1032,7 +1032,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public Set getAspects(String ticket, int version, String path) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.getAspects(version, path); } @@ -1041,7 +1041,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public boolean hasAspect(String ticket, int version, String path, QName aspectName) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.hasAspect(version, path, aspectName); } @@ -1050,7 +1050,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void removeAspect(String ticket, String path, QName aspectName) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.removeAspect(path, aspectName); } @@ -1059,7 +1059,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void revert(String ticket, String path, AVMNodeDescriptor toRevertTo) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.revert(path, toRevertTo); } @@ -1068,7 +1068,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public Pair getAPath(String ticket, AVMNodeDescriptor desc) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fAVMService.getAPath(desc); } @@ -1077,7 +1077,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void setGuid(String ticket, String path, String guid) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.setGuid(path, guid); } @@ -1086,7 +1086,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void setEncoding(String ticket, String path, String encoding) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.setEncoding(path, encoding); } @@ -1095,7 +1095,7 @@ public class AVMRemoteTransportService implements AVMRemoteTransport, Runnable */ public void setMimeType(String ticket, String path, String mimeType) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fAVMService.setMimeType(path, mimeType); } } diff --git a/source/java/org/alfresco/repo/avm/AVMSyncServiceTransportImpl.java b/source/java/org/alfresco/repo/avm/AVMSyncServiceTransportImpl.java index 887de4cc86..97fac7e97f 100644 --- a/source/java/org/alfresco/repo/avm/AVMSyncServiceTransportImpl.java +++ b/source/java/org/alfresco/repo/avm/AVMSyncServiceTransportImpl.java @@ -65,7 +65,7 @@ public class AVMSyncServiceTransportImpl implements AVMSyncServiceTransport public List compare(String ticket, int srcVersion, String srcPath, int dstVersion, String dstPath, NameMatcher excluder) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); return fSyncService.compare(srcVersion, srcPath, dstVersion, dstPath, excluder); } @@ -74,7 +74,7 @@ public class AVMSyncServiceTransportImpl implements AVMSyncServiceTransport */ public void flatten(String ticket, String layerPath, String underlyingPath) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); fSyncService.flatten(layerPath, underlyingPath); } @@ -83,7 +83,7 @@ public class AVMSyncServiceTransportImpl implements AVMSyncServiceTransport */ public void resetLayer(String ticket, String layerPath) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); fSyncService.resetLayer(layerPath); } @@ -95,7 +95,7 @@ public class AVMSyncServiceTransportImpl implements AVMSyncServiceTransport boolean overrideConflicts, boolean overrideOlder, String tag, String description) { - fAuthenticationService.validate(ticket, null); + fAuthenticationService.validate(ticket); fSyncService.update(diffList, excluder, ignoreConflicts, ignoreOlder, overrideConflicts, overrideOlder, tag, description); } } diff --git a/source/java/org/alfresco/repo/avm/AVMTestSuite.java b/source/java/org/alfresco/repo/avm/AVMTestSuite.java index 41f8f0c23a..cdd24092de 100644 --- a/source/java/org/alfresco/repo/avm/AVMTestSuite.java +++ b/source/java/org/alfresco/repo/avm/AVMTestSuite.java @@ -70,6 +70,9 @@ public class AVMTestSuite extends TestSuite suite.addTestSuite(AVMServiceTestBase.class); suite.addTestSuite(AVMServiceTest.class); + + suite.addTestSuite(PurgeTestP.class); + suite.addTestSuite(AVMServiceLocalTest.class); suite.addTestSuite(AVMLockingServiceTest.class); diff --git a/source/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java b/source/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java index 052380b483..e330a1a37b 100644 --- a/source/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java +++ b/source/java/org/alfresco/repo/domain/schema/SchemaBootstrap.java @@ -1018,6 +1018,17 @@ public class SchemaBootstrap extends AbstractLifecycleBean fetchColumnName = assigns[1]; continue; } + // Allow transaction delineation + else if (sql.startsWith("--BEGIN TXN")) + { + connection.setAutoCommit(false); + } + else if (sql.startsWith("--END TXN")) + { + connection.commit(); + connection.setAutoCommit(true); + } + // Check for comments if (sql.length() == 0 || sql.startsWith( "--" ) || diff --git a/source/java/org/alfresco/repo/imap/ImapServiceImplTest.java b/source/java/org/alfresco/repo/imap/ImapServiceImplTest.java index 6f7d4b3eb3..553248068c 100644 --- a/source/java/org/alfresco/repo/imap/ImapServiceImplTest.java +++ b/source/java/org/alfresco/repo/imap/ImapServiceImplTest.java @@ -248,7 +248,7 @@ public class ImapServiceImplTest extends TestCase private void reauthenticate(String name, String password) { - authenticationService.invalidateTicket(authenticationService.getCurrentTicket(), null); + authenticationService.invalidateTicket(authenticationService.getCurrentTicket()); authenticationService.clearCurrentSecurityContext(); authenticationService.authenticate(name, password.toCharArray()); } diff --git a/source/java/org/alfresco/repo/imap/LoadTester.java b/source/java/org/alfresco/repo/imap/LoadTester.java index 44fbd0b395..75e295b0c2 100644 --- a/source/java/org/alfresco/repo/imap/LoadTester.java +++ b/source/java/org/alfresco/repo/imap/LoadTester.java @@ -211,7 +211,7 @@ public class LoadTester extends TestCase private void reauthenticate(String name, String password) { - authenticationService.invalidateTicket(authenticationService.getCurrentTicket(), null); + authenticationService.invalidateTicket(authenticationService.getCurrentTicket()); authenticationService.clearCurrentSecurityContext(); authenticationService.authenticate(name, password.toCharArray()); } diff --git a/source/java/org/alfresco/repo/model/ml/MultilingualContentServiceImpl.java b/source/java/org/alfresco/repo/model/ml/MultilingualContentServiceImpl.java index a51a219e92..6adc5c1b3e 100644 --- a/source/java/org/alfresco/repo/model/ml/MultilingualContentServiceImpl.java +++ b/source/java/org/alfresco/repo/model/ml/MultilingualContentServiceImpl.java @@ -291,10 +291,21 @@ public class MultilingualContentServiceImpl implements MultilingualContentServic // set the pivot language and the functional name nodeService.setProperty(mlContainerNodeRef, ContentModel.PROP_LOCALE, locale); nodeService.setProperty(mlContainerNodeRef, ContentModel.PROP_NAME, containerFunctionalName); - } else { + // ALF-2200: Create the translation as the same type as the pivot + NodeRef pivotNodeRef = this.getPivotTranslation(mlContainerNodeRef); + if (pivotNodeRef != null && !pivotNodeRef.equals(contentNodeRef)) + { + QName pivotNodeType = nodeService.getType(pivotNodeRef); + QName contentNodeType = nodeService.getType(contentNodeRef); + if (!pivotNodeType.equals(contentNodeType)) + { + nodeService.setType(contentNodeRef, pivotNodeType); + } + } + // Check that the language is not duplicated Map existingLanguages = this.getTranslations(mlContainerNodeRef); if (existingLanguages.containsKey(locale)) @@ -379,7 +390,7 @@ public class MultilingualContentServiceImpl implements MultilingualContentServic /** @inheritDoc */ public void deleteTranslationContainer(NodeRef mlContainerNodeRef) { - if(!ContentModel.TYPE_MULTILINGUAL_CONTAINER.equals(nodeService.getType(mlContainerNodeRef))) + if (!ContentModel.TYPE_MULTILINGUAL_CONTAINER.equals(nodeService.getType(mlContainerNodeRef))) { throw new IllegalArgumentException( "Node type must be " + ContentModel.TYPE_MULTILINGUAL_CONTAINER); @@ -394,30 +405,17 @@ public class MultilingualContentServiceImpl implements MultilingualContentServic // remove the translations for(NodeRef translationToRemove : translations.values()) { - if(nodeService.exists(translationToRemove)) + // unmake the translation, ignore any parent-child logic + this.unmakeTranslationSimple(translationToRemove); + // remove it, if necessary + if (nodeService.exists(translationToRemove)) { - // unmake the translation - this.unmakeTranslation(translationToRemove); - - // remove it - if(nodeService.exists(translationToRemove)) - { - nodeService.deleteNode(translationToRemove); - } + nodeService.deleteNode(translationToRemove); } } - // if the mlContainer is not removed with the pivot, - if(nodeService.exists(mlContainerNodeRef)) - { - // force its deletion - nodeService.deleteNode(mlContainerNodeRef); - - if (logger.isWarnEnabled()) - { - logger.warn("The ML container " + mlContainerNodeRef + " was not removed with it's pivot translation in the unmakeTranslation process."); - } - } + // force its deletion + nodeService.deleteNode(mlContainerNodeRef); // done if (logger.isDebugEnabled()) @@ -427,26 +425,37 @@ public class MultilingualContentServiceImpl implements MultilingualContentServic " Number of translations: " + translationCount); } } + + /** + * Does the work of making the translation a simple node again. No parent-child relationships + * are modified and the pivot-container logic is not done here. + * + * @param translationNodeRef a translation + */ + private void unmakeTranslationSimple(NodeRef translationNodeRef) + { + if (nodeService.hasAspect(translationNodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION)) + { + nodeService.removeAspect(translationNodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION); + nodeService.addAspect(translationNodeRef, ContentModel.ASPECT_TEMPORARY, null); + } + else + { + nodeService.removeAspect(translationNodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT); + } + } /** @inheritDoc */ public void unmakeTranslation(NodeRef translationNodeRef) { - // Get the container NodeRef containerNodeRef = getMLContainer(translationNodeRef, true); if (containerNodeRef == null) { - if (nodeService.hasAspect(translationNodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION)) - { - nodeService.deleteNode(translationNodeRef); - } - else - { - nodeService.removeAspect(translationNodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT); - } + unmakeTranslationSimple(translationNodeRef); } else if (isPivotTranslation(translationNodeRef)) { - // Get all translation child associations + // Pivot nodes are handled by unmaking all translations and removing the container List mlChildAssocs = nodeService.getChildAssocs( containerNodeRef, ContentModel.ASSOC_MULTILINGUAL_CHILD, @@ -455,30 +464,15 @@ public class MultilingualContentServiceImpl implements MultilingualContentServic { NodeRef mlChildNodeRef = mlChildAssoc.getChildRef(); // Delete empty translations - if (nodeService.hasAspect(mlChildNodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION)) - { - nodeService.deleteNode(mlChildNodeRef); - } - else - { - nodeService.removeAspect(mlChildNodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT); - } + unmakeTranslationSimple(mlChildNodeRef); } // Now delete the container nodeService.deleteNode(containerNodeRef); } else { - if (nodeService.hasAspect(translationNodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION)) - { - nodeService.deleteNode(translationNodeRef); - } - else - { - // Get the container and break the association to it - nodeService.removeChild(containerNodeRef, translationNodeRef); - nodeService.removeAspect(translationNodeRef, ContentModel.ASPECT_MULTILINGUAL_DOCUMENT); - } + nodeService.removeChild(containerNodeRef, translationNodeRef); + unmakeTranslationSimple(translationNodeRef); } } @@ -739,11 +733,13 @@ public class MultilingualContentServiceImpl implements MultilingualContentServic // Create the document in the space of the node of reference NodeRef parentNodeRef = nodeService.getPrimaryParent(translationOfNodeRef).getParentRef(); - // Create the empty translation + // Create the empty translation. + // ALF-2200: Create the translation as the same type as the pivot + QName newTranslationType = nodeService.getType(translationOfNodeRef); NodeRef newTranslationNodeRef = fileFolderService.create( parentNodeRef, name, - ContentModel.TYPE_CONTENT).getNodeRef(); + newTranslationType).getNodeRef(); // add the translation to the container addTranslation(newTranslationNodeRef, translationOfNodeRef, locale); diff --git a/source/java/org/alfresco/repo/model/ml/MultilingualDocumentAspect.java b/source/java/org/alfresco/repo/model/ml/MultilingualDocumentAspect.java index 0973e4b656..9dfddd883d 100644 --- a/source/java/org/alfresco/repo/model/ml/MultilingualDocumentAspect.java +++ b/source/java/org/alfresco/repo/model/ml/MultilingualDocumentAspect.java @@ -122,15 +122,8 @@ public class MultilingualDocumentAspect implements */ public void beforeDeleteNode(NodeRef nodeRef) { - if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_MULTILINGUAL_EMPTY_TRANSLATION)) - { - // We just let it get deleted - } - else - { - // First unhook it - multilingualContentService.unmakeTranslation(nodeRef); - } + // First unhook it + multilingualContentService.unmakeTranslation(nodeRef); } /** diff --git a/source/java/org/alfresco/repo/node/AbstractNodeServiceImpl.java b/source/java/org/alfresco/repo/node/AbstractNodeServiceImpl.java index 31ef41b0e9..c6a5fc9890 100644 --- a/source/java/org/alfresco/repo/node/AbstractNodeServiceImpl.java +++ b/source/java/org/alfresco/repo/node/AbstractNodeServiceImpl.java @@ -436,8 +436,11 @@ public abstract class AbstractNodeServiceImpl implements NodeService if (ignorePolicy(childNodeRef)) { // special case - qnames = new HashSet(1); - qnames.add(ContentModel.ASPECT_VERSIONABLE); + if (childAspectQnames.contains(ContentModel.ASPECT_VERSIONABLE) || childNodeTypeQName.equals(ContentModel.ASPECT_VERSIONABLE)) + { + qnames = new HashSet(1); + qnames.add(ContentModel.ASPECT_VERSIONABLE); + } } else { diff --git a/source/java/org/alfresco/repo/remote/FileFolderRemoteServer.java b/source/java/org/alfresco/repo/remote/FileFolderRemoteServer.java index 5a3211d712..8142fc0c5a 100644 --- a/source/java/org/alfresco/repo/remote/FileFolderRemoteServer.java +++ b/source/java/org/alfresco/repo/remote/FileFolderRemoteServer.java @@ -97,7 +97,7 @@ public class FileFolderRemoteServer implements FileFolderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); // Make the call RetryingTransactionCallback> callback = new RetryingTransactionCallback>() { @@ -122,7 +122,7 @@ public class FileFolderRemoteServer implements FileFolderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); // Make the call RetryingTransactionCallback> callback = new RetryingTransactionCallback>() { @@ -147,7 +147,7 @@ public class FileFolderRemoteServer implements FileFolderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); // Make the call RetryingTransactionCallback> callback = new RetryingTransactionCallback>() { @@ -172,7 +172,7 @@ public class FileFolderRemoteServer implements FileFolderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); // Make the call RetryingTransactionCallback callback = new RetryingTransactionCallback() { @@ -201,7 +201,7 @@ public class FileFolderRemoteServer implements FileFolderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); // Make the call RetryingTransactionCallback> callback = new RetryingTransactionCallback>() { @@ -232,7 +232,7 @@ public class FileFolderRemoteServer implements FileFolderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); // Make the call RetryingTransactionCallback> callback = new RetryingTransactionCallback>() { @@ -257,7 +257,7 @@ public class FileFolderRemoteServer implements FileFolderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); // Make the call RetryingTransactionCallback callback = new RetryingTransactionCallback() { @@ -283,7 +283,7 @@ public class FileFolderRemoteServer implements FileFolderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); // Make the call RetryingTransactionCallback callback = new RetryingTransactionCallback() { @@ -309,7 +309,7 @@ public class FileFolderRemoteServer implements FileFolderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); // Make the call RetryingTransactionCallback callback = new RetryingTransactionCallback() { @@ -334,7 +334,7 @@ public class FileFolderRemoteServer implements FileFolderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); // Make the call RetryingTransactionCallback callback = new RetryingTransactionCallback() { @@ -359,7 +359,7 @@ public class FileFolderRemoteServer implements FileFolderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); // Make the call RetryingTransactionCallback callback = new RetryingTransactionCallback() { @@ -389,7 +389,7 @@ public class FileFolderRemoteServer implements FileFolderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); // Make the call RetryingTransactionCallback callback = new RetryingTransactionCallback() { @@ -415,7 +415,7 @@ public class FileFolderRemoteServer implements FileFolderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); // Make the call RetryingTransactionCallback callback = new RetryingTransactionCallback() { @@ -442,7 +442,7 @@ public class FileFolderRemoteServer implements FileFolderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); // Make the call RetryingTransactionCallback callback = new RetryingTransactionCallback() { @@ -467,7 +467,7 @@ public class FileFolderRemoteServer implements FileFolderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); // Make the call RetryingTransactionCallback> callback = new RetryingTransactionCallback>() { @@ -492,7 +492,7 @@ public class FileFolderRemoteServer implements FileFolderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); // Make the call RetryingTransactionCallback callback = new RetryingTransactionCallback() { @@ -517,7 +517,7 @@ public class FileFolderRemoteServer implements FileFolderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); // Make the call RetryingTransactionCallback callback = new RetryingTransactionCallback() { @@ -546,7 +546,7 @@ public class FileFolderRemoteServer implements FileFolderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); // Make the call RetryingTransactionCallback callback = new RetryingTransactionCallback() { @@ -595,7 +595,7 @@ public class FileFolderRemoteServer implements FileFolderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); // Make the call RetryingTransactionCallback callback = new RetryingTransactionCallback() { @@ -647,7 +647,7 @@ public class FileFolderRemoteServer implements FileFolderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); // Make the call RetryingTransactionCallback callback = new RetryingTransactionCallback() { diff --git a/source/java/org/alfresco/repo/remote/LoaderRemoteServer.java b/source/java/org/alfresco/repo/remote/LoaderRemoteServer.java index 87b777f1d9..33ecc5c80e 100644 --- a/source/java/org/alfresco/repo/remote/LoaderRemoteServer.java +++ b/source/java/org/alfresco/repo/remote/LoaderRemoteServer.java @@ -156,7 +156,7 @@ public class LoaderRemoteServer implements LoaderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); // Make the call RetryingTransactionCallback callback = new RetryingTransactionCallback() { @@ -241,7 +241,7 @@ public class LoaderRemoteServer implements LoaderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); // Make the call RetryingTransactionCallback callback = new RetryingTransactionCallback() @@ -322,7 +322,7 @@ public class LoaderRemoteServer implements LoaderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); RetryingTransactionCallback callback = new RetryingTransactionCallback() { public NodeRef execute() throws Throwable @@ -349,7 +349,7 @@ public class LoaderRemoteServer implements LoaderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); RetryingTransactionCallback callback = new RetryingTransactionCallback() { public FileInfo[] execute() throws Throwable @@ -385,7 +385,7 @@ public class LoaderRemoteServer implements LoaderRemote AuthenticationUtil.pushAuthentication(); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); RetryingTransactionCallback callback = new RetryingTransactionCallback() { public NodeRef execute() throws Throwable @@ -412,7 +412,7 @@ public class LoaderRemoteServer implements LoaderRemote try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); RetryingTransactionCallback callback = new RetryingTransactionCallback() { public NodeRef [] execute() throws Throwable diff --git a/source/java/org/alfresco/repo/remote/RepoRemoteTransportService.java b/source/java/org/alfresco/repo/remote/RepoRemoteTransportService.java index 7da1ff6c08..b6418765b2 100644 --- a/source/java/org/alfresco/repo/remote/RepoRemoteTransportService.java +++ b/source/java/org/alfresco/repo/remote/RepoRemoteTransportService.java @@ -244,7 +244,7 @@ public class RepoRemoteTransportService implements RepoRemoteTransport, */ public synchronized void closeInputHandle(String ticket, String handle) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); InputStream in = fInputStreams.get(handle); if (in != null) { @@ -267,7 +267,7 @@ public class RepoRemoteTransportService implements RepoRemoteTransport, */ public synchronized void closeOutputHandle(String ticket, String handle) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); OutputStream out = fOutputStreams.get(handle); if (out != null) { @@ -290,7 +290,7 @@ public class RepoRemoteTransportService implements RepoRemoteTransport, */ public NodeRef createDirectory(String ticket, NodeRef base, String path) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fRepoRemote.createDirectory(base, path); } @@ -299,7 +299,7 @@ public class RepoRemoteTransportService implements RepoRemoteTransport, */ public String createFile(String ticket, NodeRef base, String path) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); OutputStream out = fRepoRemote.createFile(base, path); return getOutputHandle(out); } @@ -309,7 +309,7 @@ public class RepoRemoteTransportService implements RepoRemoteTransport, */ public Map> getListing(String ticket, NodeRef dir) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fRepoRemote.getListing(dir); } @@ -318,7 +318,7 @@ public class RepoRemoteTransportService implements RepoRemoteTransport, */ public NodeRef getRoot(String ticket) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fRepoRemote.getRoot(); } @@ -327,7 +327,7 @@ public class RepoRemoteTransportService implements RepoRemoteTransport, */ public Pair lookup(String ticket, NodeRef base, String path) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); return fRepoRemote.lookup(base, path); } @@ -336,7 +336,7 @@ public class RepoRemoteTransportService implements RepoRemoteTransport, */ public String readFile(String ticket, NodeRef base, String path) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); InputStream in = fRepoRemote.readFile(base, path); return getInputHandle(in); } @@ -346,7 +346,7 @@ public class RepoRemoteTransportService implements RepoRemoteTransport, */ public String readFile(String ticket, NodeRef fileRef) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); InputStream in = fRepoRemote.readFile(fileRef); return getInputHandle(in); } @@ -356,7 +356,7 @@ public class RepoRemoteTransportService implements RepoRemoteTransport, */ public byte[] readInput(String ticket, String handle, int count) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); InputStream in = null; synchronized (this) { @@ -405,7 +405,7 @@ public class RepoRemoteTransportService implements RepoRemoteTransport, */ public void removeNode(String ticket, NodeRef base, String path) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fRepoRemote.removeNode(base, path); } @@ -414,7 +414,7 @@ public class RepoRemoteTransportService implements RepoRemoteTransport, */ public void removeNode(String ticket, NodeRef toRemove) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fRepoRemote.removeNode(toRemove); } @@ -423,7 +423,7 @@ public class RepoRemoteTransportService implements RepoRemoteTransport, */ public void rename(String ticket, NodeRef base, String src, String dst) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); fRepoRemote.rename(base, src, dst); } @@ -432,7 +432,7 @@ public class RepoRemoteTransportService implements RepoRemoteTransport, */ public String writeFile(String ticket, NodeRef base, String path) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); OutputStream out = fRepoRemote.writeFile(base, path); return getOutputHandle(out); } @@ -442,7 +442,7 @@ public class RepoRemoteTransportService implements RepoRemoteTransport, */ public void writeOutput(String ticket, String handle, byte[] buff, int count) { - fAuthService.validate(ticket, null); + fAuthService.validate(ticket); OutputStream out = null; synchronized (this) { diff --git a/source/java/org/alfresco/repo/security/authentication/AbstractAuthenticationService.java b/source/java/org/alfresco/repo/security/authentication/AbstractAuthenticationService.java index 646f4c0f5c..60733c43e9 100644 --- a/source/java/org/alfresco/repo/security/authentication/AbstractAuthenticationService.java +++ b/source/java/org/alfresco/repo/security/authentication/AbstractAuthenticationService.java @@ -67,11 +67,6 @@ public abstract class AbstractAuthenticationService implements AuthenticationSer { return sysAdminParams.getMaxUsers(); } - - public String getCurrentTicket() - { - return getCurrentTicket(null); - } public abstract Set getUsersWithTickets(boolean nonExpiredOnly); diff --git a/source/java/org/alfresco/repo/security/authentication/AbstractChainingAuthenticationService.java b/source/java/org/alfresco/repo/security/authentication/AbstractChainingAuthenticationService.java index 20add41e76..d8adab5744 100644 --- a/source/java/org/alfresco/repo/security/authentication/AbstractChainingAuthenticationService.java +++ b/source/java/org/alfresco/repo/security/authentication/AbstractChainingAuthenticationService.java @@ -32,8 +32,7 @@ import org.alfresco.service.cmr.security.MutableAuthenticationService; * * @author dward */ -public abstract class AbstractChainingAuthenticationService extends AbstractAuthenticationService implements - MutableAuthenticationService +public abstract class AbstractChainingAuthenticationService extends AbstractAuthenticationService implements MutableAuthenticationService { /** * Instantiates a new abstract chaining authentication service. @@ -57,8 +56,7 @@ public abstract class AbstractChainingAuthenticationService extends AbstractAuth */ protected abstract List getUsableAuthenticationServices(); - /* - * (non-Javadoc) + /* (non-Javadoc) * @see org.alfresco.service.cmr.security.AuthenticationService#createAuthentication(java.lang.String, char[]) */ public void createAuthentication(String userName, char[] password) throws AuthenticationException @@ -71,10 +69,8 @@ public abstract class AbstractChainingAuthenticationService extends AbstractAuth getMutableAuthenticationService().createAuthentication(userName, password); } - /* - * (non-Javadoc) - * @see org.alfresco.service.cmr.security.AuthenticationService#updateAuthentication(java.lang.String, char[], - * char[]) + /* (non-Javadoc) + * @see org.alfresco.service.cmr.security.AuthenticationService#updateAuthentication(java.lang.String, char[], char[]) */ public void updateAuthentication(String userName, char[] oldPassword, char[] newPassword) throws AuthenticationException @@ -249,7 +245,7 @@ public abstract class AbstractChainingAuthenticationService extends AbstractAuth // it doesn't exist in any of the authentication components return false; } - + /** * {@inheritDoc} */ @@ -293,13 +289,13 @@ public abstract class AbstractChainingAuthenticationService extends AbstractAuth /** * {@inheritDoc} */ - public void invalidateTicket(String ticket, String sessionId) throws AuthenticationException + public void invalidateTicket(String ticket) throws AuthenticationException { for (AuthenticationService authService : getUsableAuthenticationServices()) { try { - authService.invalidateTicket(ticket, sessionId); + authService.invalidateTicket(ticket); return; } catch (AuthenticationException e) @@ -314,13 +310,13 @@ public abstract class AbstractChainingAuthenticationService extends AbstractAuth /** * {@inheritDoc} */ - public void validate(String ticket, String sessionId) throws AuthenticationException + public void validate(String ticket) throws AuthenticationException { for (AuthenticationService authService : getUsableAuthenticationServices()) { try { - authService.validate(ticket, sessionId); + authService.validate(ticket); return; } catch (AuthenticationException e) @@ -335,13 +331,13 @@ public abstract class AbstractChainingAuthenticationService extends AbstractAuth /** * {@inheritDoc} */ - public String getCurrentTicket(String sessionId) + public String getCurrentTicket() { for (AuthenticationService authService : getUsableAuthenticationServices()) { try { - return authService.getCurrentTicket(sessionId); + return authService.getCurrentTicket(); } catch (AuthenticationException e) { @@ -354,13 +350,13 @@ public abstract class AbstractChainingAuthenticationService extends AbstractAuth /** * {@inheritDoc} */ - public String getNewTicket(String sessionId) + public String getNewTicket() { for (AuthenticationService authService : getUsableAuthenticationServices()) { try { - return authService.getNewTicket(sessionId); + return authService.getNewTicket(); } catch (AuthenticationException e) { @@ -552,5 +548,7 @@ public abstract class AbstractChainingAuthenticationService extends AbstractAuth } return defaultGuestUserNames; } + + } \ No newline at end of file diff --git a/source/java/org/alfresco/repo/security/authentication/AuthenticationServiceImpl.java b/source/java/org/alfresco/repo/security/authentication/AuthenticationServiceImpl.java index 5a4b33e1dd..df5f180ac7 100644 --- a/source/java/org/alfresco/repo/security/authentication/AuthenticationServiceImpl.java +++ b/source/java/org/alfresco/repo/security/authentication/AuthenticationServiceImpl.java @@ -70,7 +70,7 @@ public class AuthenticationServiceImpl extends AbstractAuthenticationService imp throw ae; } ticketComponent.clearCurrentTicket(); - getCurrentTicket(null); + getCurrentTicket(); } public String getCurrentUserName() throws AuthenticationException @@ -88,9 +88,9 @@ public class AuthenticationServiceImpl extends AbstractAuthenticationService imp return ticketComponent.getUsersWithTickets(nonExpiredOnly); } - public void invalidateTicket(String ticket, String sessionId) throws AuthenticationException + public void invalidateTicket(String ticket) throws AuthenticationException { - ticketComponent.invalidateTicketById(ticket, sessionId); + ticketComponent.invalidateTicketById(ticket); } public int countTickets(boolean nonExpiredOnly) @@ -104,7 +104,7 @@ public class AuthenticationServiceImpl extends AbstractAuthenticationService imp } - public void validate(String ticket, String sessionId) throws AuthenticationException + public void validate(String ticket) throws AuthenticationException { String currentUser = null; try @@ -112,7 +112,7 @@ public class AuthenticationServiceImpl extends AbstractAuthenticationService imp // clear context - to avoid MT concurrency issue (causing domain mismatch) - see also 'authenticate' above clearCurrentSecurityContext(); - currentUser = ticketComponent.validateTicket(ticket, sessionId); + currentUser = ticketComponent.validateTicket(ticket); authenticationComponent.setCurrentUser(currentUser, UserNameValidationMode.CHECK); } catch (AuthenticationException ae) @@ -122,22 +122,22 @@ public class AuthenticationServiceImpl extends AbstractAuthenticationService imp } } - public String getCurrentTicket(String sessionId) throws AuthenticationException + public String getCurrentTicket() throws AuthenticationException { String userName = getCurrentUserName(); // So that preAuthenticationCheck can constrain the creation of new tickets, we first ask for the current ticket // without auto-creation - String ticket = ticketComponent.getCurrentTicket(userName, sessionId, false); + String ticket = ticketComponent.getCurrentTicket(userName, false); if (ticket == null) { // If we get through the authentication check then it's safe to issue a new ticket (e.g. for // SSO/external-based login) - return getNewTicket(sessionId); + return getNewTicket(); } return ticket; } - public String getNewTicket(String sessionId) + public String getNewTicket() { String userName = getCurrentUserName(); try @@ -149,7 +149,7 @@ public class AuthenticationServiceImpl extends AbstractAuthenticationService imp clearCurrentSecurityContext(); throw e; } - return ticketComponent.getNewTicket(userName, sessionId); + return ticketComponent.getNewTicket(userName); } public void clearCurrentSecurityContext() @@ -174,7 +174,7 @@ public class AuthenticationServiceImpl extends AbstractAuthenticationService imp authenticationComponent.setGuestUserAsCurrentUser(); String guestUser = authenticationComponent.getCurrentUserName(); ticketComponent.clearCurrentTicket(); - ticketComponent.getCurrentTicket(guestUser, null, true); // to ensure new ticket is created (even if client does not explicitly call getCurrentTicket) + ticketComponent.getCurrentTicket(guestUser, true); // to ensure new ticket is created (even if client does not explicitly call getCurrentTicket) } public boolean guestUserAuthenticationAllowed() diff --git a/source/java/org/alfresco/repo/security/authentication/AuthenticationTest.java b/source/java/org/alfresco/repo/security/authentication/AuthenticationTest.java index d206a42bb1..e22d65f46d 100644 --- a/source/java/org/alfresco/repo/security/authentication/AuthenticationTest.java +++ b/source/java/org/alfresco/repo/security/authentication/AuthenticationTest.java @@ -278,11 +278,11 @@ public class AuthenticationTest extends TestCase //userTransaction = transactionService.getUserTransaction(); //userTransaction.begin(); - pubAuthenticationService.validate(ticket, null); + pubAuthenticationService.validate(ticket); userName = pubAuthenticationService.getCurrentUserName(); assertEquals("andy", userName); - pubAuthenticationService.validate(newticket, null); + pubAuthenticationService.validate(newticket); userName = pubAuthenticationService.getCurrentUserName(); assertEquals("andy", userName); @@ -641,14 +641,14 @@ public class AuthenticationTest extends TestCase Authentication result = authenticationManager.authenticate(token); result.setAuthenticated(true); - String ticket = ticketComponent.getNewTicket(getUserName(result), null); - String user = ticketComponent.validateTicket(ticket, null); - assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket); + String ticket = ticketComponent.getNewTicket(getUserName(result)); + String user = ticketComponent.validateTicket(ticket); + assertEquals(ticketComponent.getCurrentTicket("Andy", true), ticket); user = null; try { - user = ticketComponent.validateTicket("INVALID", null); + user = ticketComponent.validateTicket("INVALID"); assertNotNull(null); } catch (AuthenticationException e) @@ -656,11 +656,11 @@ public class AuthenticationTest extends TestCase assertNull(user); } - ticketComponent.invalidateTicketById(ticket, null); + ticketComponent.invalidateTicketById(ticket); try { - user = ticketComponent.validateTicket(ticket, null); - assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket); + user = ticketComponent.validateTicket(ticket); + assertEquals(ticketComponent.getCurrentTicket("Andy", true), ticket); assertNotNull(null); } catch (AuthenticationException e) @@ -689,11 +689,11 @@ public class AuthenticationTest extends TestCase Authentication result = authenticationManager.authenticate(token); result.setAuthenticated(true); - String ticket = tc.getNewTicket(getUserName(result), null); - tc.validateTicket(ticket, null); - assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket); - tc.validateTicket(ticket, null); - assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket); + String ticket = tc.getNewTicket(getUserName(result)); + tc.validateTicket(ticket); + assertEquals(ticketComponent.getCurrentTicket("Andy", true), ticket); + tc.validateTicket(ticket); + assertEquals(ticketComponent.getCurrentTicket("Andy", true), ticket); dao.deleteUser("Andy"); // assertNull(dao.getUserOrNull("Andy")); @@ -715,12 +715,12 @@ public class AuthenticationTest extends TestCase Authentication result = authenticationManager.authenticate(token); result.setAuthenticated(true); - String ticket = tc.getNewTicket(getUserName(result), null); - tc.validateTicket(ticket, null); - assertTrue(!ticketComponent.getCurrentTicket("Andy", null, true).equals(ticket)); + String ticket = tc.getNewTicket(getUserName(result)); + tc.validateTicket(ticket); + assertTrue(!ticketComponent.getCurrentTicket("Andy", true).equals(ticket)); try { - tc.validateTicket(ticket, null); + tc.validateTicket(ticket); assertNotNull(null); } catch (AuthenticationException e) @@ -749,13 +749,13 @@ public class AuthenticationTest extends TestCase Authentication result = authenticationManager.authenticate(token); result.setAuthenticated(true); - String ticket = tc.getNewTicket(getUserName(result), null); - tc.validateTicket(ticket, null); - assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket); - tc.validateTicket(ticket, null); - assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket); - tc.validateTicket(ticket, null); - assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket); + String ticket = tc.getNewTicket(getUserName(result)); + tc.validateTicket(ticket); + assertEquals(ticketComponent.getCurrentTicket("Andy", true), ticket); + tc.validateTicket(ticket); + assertEquals(ticketComponent.getCurrentTicket("Andy", true), ticket); + tc.validateTicket(ticket); + assertEquals(ticketComponent.getCurrentTicket("Andy", true), ticket); synchronized (this) { @@ -771,7 +771,7 @@ public class AuthenticationTest extends TestCase } try { - tc.validateTicket(ticket, null); + tc.validateTicket(ticket); assertNotNull(null); } catch (AuthenticationException e) @@ -781,7 +781,7 @@ public class AuthenticationTest extends TestCase try { - tc.validateTicket(ticket, null); + tc.validateTicket(ticket); assertNotNull(null); } catch (AuthenticationException e) @@ -791,7 +791,7 @@ public class AuthenticationTest extends TestCase try { - tc.validateTicket(ticket, null); + tc.validateTicket(ticket); assertNotNull(null); } catch (AuthenticationException e) @@ -814,7 +814,7 @@ public class AuthenticationTest extends TestCase try { - tc.validateTicket(ticket, null); + tc.validateTicket(ticket); assertNotNull(null); } catch (AuthenticationException e) @@ -823,7 +823,7 @@ public class AuthenticationTest extends TestCase } tc.setExpiryMode(ExpiryMode.AFTER_INACTIVITY.toString()); - ticket = tc.getNewTicket(getUserName(result), null); + ticket = tc.getNewTicket(getUserName(result)); for (int i = 0; i < 50; i++) { @@ -840,7 +840,7 @@ public class AuthenticationTest extends TestCase e.printStackTrace(); } - tc.validateTicket(ticket, null); + tc.validateTicket(ticket); } } @@ -860,7 +860,7 @@ public class AuthenticationTest extends TestCase try { - tc.validateTicket(ticket, null); + tc.validateTicket(ticket); assertNotNull(null); } catch (AuthenticationException e) @@ -889,13 +889,13 @@ public class AuthenticationTest extends TestCase Authentication result = authenticationManager.authenticate(token); result.setAuthenticated(true); - String ticket = tc.getNewTicket(getUserName(result), null); - tc.validateTicket(ticket, null); - assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket); - tc.validateTicket(ticket, null); - assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket); - tc.validateTicket(ticket, null); - assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket); + String ticket = tc.getNewTicket(getUserName(result)); + tc.validateTicket(ticket); + assertEquals(ticketComponent.getCurrentTicket("Andy", true), ticket); + tc.validateTicket(ticket); + assertEquals(ticketComponent.getCurrentTicket("Andy", true), ticket); + tc.validateTicket(ticket); + assertEquals(ticketComponent.getCurrentTicket("Andy", true), ticket); synchronized (this) { @@ -911,7 +911,7 @@ public class AuthenticationTest extends TestCase } try { - tc.validateTicket(ticket, null); + tc.validateTicket(ticket); assertNotNull(null); } catch (AuthenticationException e) @@ -921,7 +921,7 @@ public class AuthenticationTest extends TestCase try { - tc.validateTicket(ticket, null); + tc.validateTicket(ticket); assertNotNull(null); } catch (AuthenticationException e) @@ -931,7 +931,7 @@ public class AuthenticationTest extends TestCase try { - tc.validateTicket(ticket, null); + tc.validateTicket(ticket); assertNotNull(null); } catch (AuthenticationException e) @@ -954,7 +954,7 @@ public class AuthenticationTest extends TestCase try { - tc.validateTicket(ticket, null); + tc.validateTicket(ticket); assertNotNull(null); } catch (AuthenticationException e) @@ -982,13 +982,13 @@ public class AuthenticationTest extends TestCase Authentication result = authenticationManager.authenticate(token); result.setAuthenticated(true); - String ticket = tc.getNewTicket(getUserName(result), null); - tc.validateTicket(ticket, null); - assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket); - tc.validateTicket(ticket, null); - assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket); - tc.validateTicket(ticket, null); - assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket); + String ticket = tc.getNewTicket(getUserName(result)); + tc.validateTicket(ticket); + assertEquals(ticketComponent.getCurrentTicket("Andy", true), ticket); + tc.validateTicket(ticket); + assertEquals(ticketComponent.getCurrentTicket("Andy", true), ticket); + tc.validateTicket(ticket); + assertEquals(ticketComponent.getCurrentTicket("Andy", true), ticket); synchronized (this) { try @@ -1002,8 +1002,8 @@ public class AuthenticationTest extends TestCase } } - tc.validateTicket(ticket, null); - assertEquals(ticketComponent.getCurrentTicket("Andy", null, true), ticket); + tc.validateTicket(ticket); + assertEquals(ticketComponent.getCurrentTicket("Andy", true), ticket); dao.deleteUser("Andy"); // assertNull(dao.getUserOrNull("Andy")); @@ -1138,14 +1138,14 @@ public class AuthenticationTest extends TestCase // instance String ticket = authenticationService.getCurrentTicket(); // validate our ticket is still valid - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); assertEquals(ticket, authenticationService.getCurrentTicket()); // destroy the ticket instance - authenticationService.invalidateTicket(ticket, null); + authenticationService.invalidateTicket(ticket); try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); fail("Invalid taicket should have been rejected"); } catch (AuthenticationException e) @@ -1187,11 +1187,11 @@ public class AuthenticationTest extends TestCase // validate our ticket is still valid authenticationService.clearCurrentSecurityContext(); - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); assertEquals(ticket, authenticationService.getCurrentTicket()); // destroy the ticket instance - authenticationService.invalidateTicket(ticket, null); + authenticationService.invalidateTicket(ticket); Authentication current = authenticationComponent.getCurrentAuthentication(); if (current != null) @@ -1202,7 +1202,7 @@ public class AuthenticationTest extends TestCase try { - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); fail("Invalid ticket should have been rejected"); } catch (AuthenticationException e) @@ -1246,11 +1246,11 @@ public class AuthenticationTest extends TestCase // instance String ticket = authenticationService.getCurrentTicket(); // validate our ticket is still valid - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); assertEquals(ticket, authenticationService.getCurrentTicket()); // destroy the ticket instance - authenticationService.invalidateTicket(ticket, null); + authenticationService.invalidateTicket(ticket); Authentication current = authenticationComponent.getCurrentAuthentication(); if (current != null) @@ -1306,11 +1306,11 @@ public class AuthenticationTest extends TestCase // instance String ticket = authenticationService.getCurrentTicket(); // validate our ticket is still valid - authenticationService.validate(ticket, null); + authenticationService.validate(ticket); assertEquals(ticket, authenticationService.getCurrentTicket()); // destroy the ticket instance - authenticationService.invalidateTicket(ticket, null); + authenticationService.invalidateTicket(ticket); Authentication current = authenticationComponent.getCurrentAuthentication(); if (current != null) @@ -1328,48 +1328,6 @@ public class AuthenticationTest extends TestCase // assertNull(dao.getUserOrNull("Andy")); } - public void testAuthenticationServiceSessionIds() - { - // create an authentication object e.g. the user - authenticationService.createAuthentication("Andy", "auth1".toCharArray()); - - // authenticate with this user details - authenticationService.authenticate("Andy", "auth1".toCharArray()); - - // assert the user is authenticated - assertEquals("Andy", authenticationService.getCurrentUserName()); - - // Get the user's ticket and associate it with "AndySessionId" - String andyTicket = authenticationService.getCurrentTicket("AndySessionId"); - - // Now validate the ticket in another session - authenticationService.validate(andyTicket, "DaveSessionId"); - - assertEquals(andyTicket, authenticationService.getCurrentTicket()); - - // Invalidate it in that session - authenticationService.invalidateTicket(andyTicket, "DaveSessionId"); - - // Make sure we don't get that ticket again in the same session - assertNotSame(andyTicket, authenticationService.getCurrentTicket("DaveSessionId")); - - // The ticket should still validate in the other session - authenticationService.validate(andyTicket, "AndySessionId"); - - // When we invalidate it in the other session, the ticket should be invalidated globally - authenticationService.invalidateTicket(andyTicket, "AndySessionId"); - - try - { - authenticationService.validate(andyTicket, null); - fail("Invalid ticket should have been rejected"); - } - catch (AuthenticationException e) - { - // Expected - } - } - public void testPubAuthenticationService1() { authenticationComponent.setSystemUserAsCurrentUser(); @@ -1510,14 +1468,14 @@ public class AuthenticationTest extends TestCase assertNull(authenticationComponent.getCurrentAuthentication()); // validate our ticket is still valid - pubAuthenticationService.validate(ticket, null); + pubAuthenticationService.validate(ticket); assertEquals(ticket, authenticationService.getCurrentTicket()); // destroy the ticket instance - pubAuthenticationService.invalidateTicket(ticket, null); + pubAuthenticationService.invalidateTicket(ticket); try { - pubAuthenticationService.validate(ticket, null); + pubAuthenticationService.validate(ticket); fail("Ticket should not validate"); } catch (AuthenticationException e) @@ -1579,11 +1537,11 @@ public class AuthenticationTest extends TestCase // instance String ticket = pubAuthenticationService.getCurrentTicket(); // validate our ticket is still valid - pubAuthenticationService.validate(ticket, null); + pubAuthenticationService.validate(ticket); assertEquals(ticket, authenticationService.getCurrentTicket()); // destroy the ticket instance - pubAuthenticationService.invalidateTicket(ticket, null); + pubAuthenticationService.invalidateTicket(ticket); } @@ -1640,11 +1598,11 @@ public class AuthenticationTest extends TestCase // instance String ticket = pubAuthenticationService.getCurrentTicket(); // validate our ticket is still valid - pubAuthenticationService.validate(ticket, null); + pubAuthenticationService.validate(ticket); assertEquals(ticket, authenticationService.getCurrentTicket()); // destroy the ticket instance - pubAuthenticationService.invalidateTicket(ticket, null); + pubAuthenticationService.invalidateTicket(ticket); authenticationComponent.clearCurrentSecurityContext(); diff --git a/source/java/org/alfresco/repo/security/authentication/ChainingAuthenticationServiceTest.java b/source/java/org/alfresco/repo/security/authentication/ChainingAuthenticationServiceTest.java index 936041c0e3..4ba9729f54 100644 --- a/source/java/org/alfresco/repo/security/authentication/ChainingAuthenticationServiceTest.java +++ b/source/java/org/alfresco/repo/security/authentication/ChainingAuthenticationServiceTest.java @@ -299,11 +299,11 @@ public class ChainingAuthenticationServiceTest extends TestCase String ticket = as.getCurrentTicket(); assertTrue(ticket == as.getCurrentTicket()); - as.validate(ticket, null); - as.invalidateTicket(ticket, null); + as.validate(ticket); + as.invalidateTicket(ticket); try { - as.validate(ticket, null); + as.validate(ticket); fail(); } catch (AuthenticationException e) @@ -312,11 +312,11 @@ public class ChainingAuthenticationServiceTest extends TestCase } ticket = as.getCurrentTicket(); - as.validate(ticket, null); + as.validate(ticket); as.invalidateUserSession("andy"); try { - as.validate(ticket, null); + as.validate(ticket); fail(); } catch (AuthenticationException e) @@ -664,11 +664,11 @@ public class ChainingAuthenticationServiceTest extends TestCase String ticket = as.getCurrentTicket(); assertTrue(ticket == as.getCurrentTicket()); - as.validate(ticket, null); - as.invalidateTicket(ticket, null); + as.validate(ticket); + as.invalidateTicket(ticket); try { - as.validate(ticket, null); + as.validate(ticket); fail(); } catch (AuthenticationException e) @@ -677,11 +677,11 @@ public class ChainingAuthenticationServiceTest extends TestCase } ticket = as.getCurrentTicket(); - as.validate(ticket, null); + as.validate(ticket); as.invalidateUserSession("andy"); try { - as.validate(ticket, null); + as.validate(ticket); fail(); } catch (AuthenticationException e) diff --git a/source/java/org/alfresco/repo/security/authentication/TestAuthenticationServiceImpl.java b/source/java/org/alfresco/repo/security/authentication/TestAuthenticationServiceImpl.java index 076ed97112..6088017517 100644 --- a/source/java/org/alfresco/repo/security/authentication/TestAuthenticationServiceImpl.java +++ b/source/java/org/alfresco/repo/security/authentication/TestAuthenticationServiceImpl.java @@ -278,7 +278,7 @@ public class TestAuthenticationServiceImpl implements MutableAuthenticationServi userToTicket.remove(userName); } - public void invalidateTicket(String ticket, String sessionId) throws AuthenticationException + public void invalidateTicket(String ticket) throws AuthenticationException { String userToRemove = null; for (String user : userToTicket.keySet()) @@ -296,7 +296,7 @@ public class TestAuthenticationServiceImpl implements MutableAuthenticationServi } - public void validate(String ticket, String sessionId) throws AuthenticationException + public void validate(String ticket) throws AuthenticationException { String userToSet = null; for (String user : userToTicket.keySet()) @@ -319,12 +319,6 @@ public class TestAuthenticationServiceImpl implements MutableAuthenticationServi } public String getCurrentTicket() - { - return getCurrentTicket(null); - } - - // TODO: Fix this up - public String getCurrentTicket(String sessionId) { String currentUser = getCurrentUserName(); String ticket = userToTicket.get(currentUser); @@ -336,7 +330,7 @@ public class TestAuthenticationServiceImpl implements MutableAuthenticationServi return ticket; } - public String getNewTicket(String sessionId) + public String getNewTicket() { String currentUser = getCurrentUserName(); String ticket = userToTicket.get(currentUser); diff --git a/source/java/org/alfresco/service/cmr/security/AuthenticationService.java b/source/java/org/alfresco/service/cmr/security/AuthenticationService.java index 7b3477d244..e7d17f8406 100644 --- a/source/java/org/alfresco/service/cmr/security/AuthenticationService.java +++ b/source/java/org/alfresco/service/cmr/security/AuthenticationService.java @@ -90,56 +90,37 @@ public interface AuthenticationService @Auditable(parameters = {"userName"}) public void invalidateUserSession(String userName) throws AuthenticationException; - /** - * Invalidate a single ticket by ID or remove its association with a given session ID. - * - * @param sessionId - * the app server session ID (e.g. HttpSession ID) or null if not applicable. - * @throws AuthenticationException - */ - @Auditable(parameters = {"ticket", "sessionId"}, recordable = {false, false}) - public void invalidateTicket(String ticket, String sessionId) throws AuthenticationException; + /** + * Invalidate a single ticket by ID + * + * @param ticket + * @throws AuthenticationException + */ + @Auditable(parameters = {"ticket"}, recordable = {false}) + public void invalidateTicket(String ticket) throws AuthenticationException; + + /** + * Validate a ticket. Set the current user name accordingly. + * + * @param ticket + * @throws AuthenticationException + */ + @Auditable(parameters = {"ticket"}, recordable = {false}) + public void validate(String ticket) throws AuthenticationException; /** - * Validate a ticket and associate it with a given app server session ID. Set the current user name accordingly. - * - * @param ticket - * @param sessionId - * the app server session ID (e.g. HttpSession ID) or null if not applicable. - * @throws AuthenticationException - */ - @Auditable(parameters = {"ticket", "sessionId"}, recordable = {false, false}) - public void validate(String ticket, String sessionId) throws AuthenticationException; - - /** - * Gets the current ticket as a string. If there isn't an appropriate current ticket, a new ticket will be made the - * current ticket. - * - * @param sessionId - * the app server session ID (e.g. HttpSession ID) or null if not applicable. If non-null, - * the ticket returned is either a new one or one previously associated with the same sessionId by - * {@link #validate(String, String)} or {@link #getCurrentTicket(String)}. - * @return the current ticket as a string - */ - @Auditable(parameters = {"sessionId"}, recordable = {false}) - public String getCurrentTicket(String sessionId); - - /** - * Gets the current ticket as a string. If there isn't an appropriate current ticket, a new ticket will be made the - * current ticket. - * - * @return the current ticket as a string + * Get the current ticket as a string + * @return */ @Auditable public String getCurrentTicket(); - + /** * Get a new ticket as a string - * @param sessionId - * the app server session ID (e.g. HttpSession ID) or null if not applicable. + * @return */ - @Auditable(parameters = {"sessionId"}, recordable = {false}) - public String getNewTicket(String sessionId); + @Auditable + public String getNewTicket(); /** * Remove the current security information