mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Changed filesystem initialization code to use the system user as the security
context to allow calls to normal services. Added <relativePath> filesystem configuration to allow root of filesystem to be a folder node within the hierarchy. Changed drag and drop <path> setting to search the classpath for the file. Added checks to validate that the file exists and is on the local filesystem. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2134 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -55,12 +55,12 @@
|
|||||||
</constructor-arg>
|
</constructor-arg>
|
||||||
<property name="transactionService"><ref bean="transactionComponent" /></property>
|
<property name="transactionService"><ref bean="transactionComponent" /></property>
|
||||||
<property name="nodeService"><ref bean="NodeService" /></property>
|
<property name="nodeService"><ref bean="NodeService" /></property>
|
||||||
<property name="unprotectedNodeService"><ref bean="nodeService" /></property>
|
<property name="searchService"><ref bean="SearchService" /></property>
|
||||||
<property name="unprotectedSearchService"><ref bean="searchService" /></property>
|
|
||||||
<property name="namespaceService"><ref bean="namespaceService" /></property>
|
<property name="namespaceService"><ref bean="namespaceService" /></property>
|
||||||
<property name="contentService"><ref bean="ContentService" /></property>
|
<property name="contentService"><ref bean="ContentService" /></property>
|
||||||
<property name="permissionService"><ref bean="permissionService"/></property>
|
<property name="permissionService"><ref bean="permissionService"/></property>
|
||||||
<property name="checkInOutService"><ref bean="checkOutCheckInService"/></property>
|
<property name="checkInOutService"><ref bean="checkOutCheckInService"/></property>
|
||||||
|
<property name="authenticationComponent"><ref bean="authenticationComponent"/></property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="cifsHelper" class="org.alfresco.filesys.smb.server.repo.CifsHelper">
|
<bean id="cifsHelper" class="org.alfresco.filesys.smb.server.repo.CifsHelper">
|
||||||
|
@@ -16,8 +16,10 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.filesys.smb.server.repo;
|
package org.alfresco.filesys.smb.server.repo;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.transaction.UserTransaction;
|
import javax.transaction.UserTransaction;
|
||||||
@@ -52,6 +54,7 @@ import org.alfresco.filesys.smb.server.repo.pseudo.PseudoFileInterface;
|
|||||||
import org.alfresco.filesys.smb.server.repo.pseudo.PseudoNetworkFile;
|
import org.alfresco.filesys.smb.server.repo.pseudo.PseudoNetworkFile;
|
||||||
import org.alfresco.filesys.util.DataBuffer;
|
import org.alfresco.filesys.util.DataBuffer;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
|
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
|
||||||
import org.alfresco.service.cmr.lock.NodeLockedException;
|
import org.alfresco.service.cmr.lock.NodeLockedException;
|
||||||
import org.alfresco.service.cmr.repository.ContentService;
|
import org.alfresco.service.cmr.repository.ContentService;
|
||||||
@@ -91,12 +94,13 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface
|
|||||||
private TransactionService transactionService;
|
private TransactionService transactionService;
|
||||||
private NamespaceService namespaceService;
|
private NamespaceService namespaceService;
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
private NodeService unprotectedNodeService;
|
private SearchService searchService;
|
||||||
private SearchService unprotectedSearchService;
|
|
||||||
private ContentService contentService;
|
private ContentService contentService;
|
||||||
private PermissionService permissionService;
|
private PermissionService permissionService;
|
||||||
private CheckOutCheckInService checkInOutService;
|
private CheckOutCheckInService checkInOutService;
|
||||||
|
|
||||||
|
private AuthenticationComponent authComponent;
|
||||||
|
|
||||||
// I/O control handler
|
// I/O control handler
|
||||||
|
|
||||||
private IOControlHandler m_ioHandler;
|
private IOControlHandler m_ioHandler;
|
||||||
@@ -139,20 +143,12 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface
|
|||||||
this.nodeService = nodeService;
|
this.nodeService = nodeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param nodeService the node service
|
|
||||||
*/
|
|
||||||
public void setUnprotectedNodeService(NodeService nodeService)
|
|
||||||
{
|
|
||||||
this.unprotectedNodeService = nodeService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param searchService the search service
|
* @param searchService the search service
|
||||||
*/
|
*/
|
||||||
public void setUnprotectedSearchService(SearchService searchService)
|
public void setSearchService(SearchService searchService)
|
||||||
{
|
{
|
||||||
this.unprotectedSearchService = searchService;
|
this.searchService = searchService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -184,6 +180,16 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface
|
|||||||
this.checkInOutService = checkInOutService;
|
this.checkInOutService = checkInOutService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the authentication component
|
||||||
|
*
|
||||||
|
* @param authComponent AuthenticationComponent
|
||||||
|
*/
|
||||||
|
public void setAuthenticationComponent(AuthenticationComponent authComponent)
|
||||||
|
{
|
||||||
|
this.authComponent = authComponent;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse and validate the parameter string and create a device context object for this instance
|
* Parse and validate the parameter string and create a device context object for this instance
|
||||||
* of the shared device. The same DeviceInterface implementation may be used for multiple
|
* of the shared device. The same DeviceInterface implementation may be used for multiple
|
||||||
@@ -195,6 +201,10 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface
|
|||||||
*/
|
*/
|
||||||
public DeviceContext createContext(ConfigElement cfg) throws DeviceContextException
|
public DeviceContext createContext(ConfigElement cfg) throws DeviceContextException
|
||||||
{
|
{
|
||||||
|
// Use the system user as the authenticated context for the filesystem initialization
|
||||||
|
|
||||||
|
authComponent.setCurrentUser( authComponent.getSystemUserName());
|
||||||
|
|
||||||
// Wrap the initialization in a transaction
|
// Wrap the initialization in a transaction
|
||||||
|
|
||||||
UserTransaction tx = transactionService.getUserTransaction(true);
|
UserTransaction tx = transactionService.getUserTransaction(true);
|
||||||
@@ -220,11 +230,11 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface
|
|||||||
|
|
||||||
// Connect to the repo and ensure that the store exists
|
// Connect to the repo and ensure that the store exists
|
||||||
|
|
||||||
if (!unprotectedNodeService.exists(storeRef))
|
if (! nodeService.exists(storeRef))
|
||||||
{
|
{
|
||||||
throw new DeviceContextException("Store not created prior to application startup: " + storeRef);
|
throw new DeviceContextException("Store not created prior to application startup: " + storeRef);
|
||||||
}
|
}
|
||||||
NodeRef storeRootNodeRef = unprotectedNodeService.getRootNode(storeRef);
|
NodeRef storeRootNodeRef = nodeService.getRootNode(storeRef);
|
||||||
|
|
||||||
// Get the root path
|
// Get the root path
|
||||||
|
|
||||||
@@ -237,8 +247,7 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface
|
|||||||
|
|
||||||
// Find the root node for this device
|
// Find the root node for this device
|
||||||
|
|
||||||
List<NodeRef> nodeRefs = unprotectedSearchService.selectNodes(
|
List<NodeRef> nodeRefs = searchService.selectNodes(storeRootNodeRef, rootPath, null, namespaceService, false);
|
||||||
storeRootNodeRef, rootPath, null, namespaceService, false);
|
|
||||||
|
|
||||||
NodeRef rootNodeRef = null;
|
NodeRef rootNodeRef = null;
|
||||||
|
|
||||||
@@ -260,6 +269,27 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface
|
|||||||
rootNodeRef = nodeRefs.get(0);
|
rootNodeRef = nodeRefs.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if a relative path has been specified
|
||||||
|
|
||||||
|
ConfigElement relativePathElement = cfg.getChild(KEY_RELATIVE_PATH);
|
||||||
|
|
||||||
|
if ( relativePathElement != null)
|
||||||
|
{
|
||||||
|
// Make sure the path is in CIFS format
|
||||||
|
|
||||||
|
String relPath = relativePathElement.getValue().replace( '/', FileName.DOS_SEPERATOR);
|
||||||
|
|
||||||
|
// Find the node and validate that the relative path is to a folder
|
||||||
|
|
||||||
|
NodeRef relPathNode = cifsHelper.getNodeRef( rootNodeRef, relPath);
|
||||||
|
if ( cifsHelper.isDirectory( relPathNode) == false)
|
||||||
|
throw new DeviceContextException("Relative path is not a folder, " + relativePathElement.getValue());
|
||||||
|
|
||||||
|
// Use the relative path node as the root of the filesystem
|
||||||
|
|
||||||
|
rootNodeRef = relPathNode;
|
||||||
|
}
|
||||||
|
|
||||||
// Commit the transaction
|
// Commit the transaction
|
||||||
|
|
||||||
tx.commit();
|
tx.commit();
|
||||||
@@ -330,9 +360,18 @@ public class ContentDiskDriver implements DiskInterface, IOCtlInterface
|
|||||||
|
|
||||||
if ( pseudoName != null && appPath != null)
|
if ( pseudoName != null && appPath != null)
|
||||||
{
|
{
|
||||||
|
// Check that the application exists on the local filesystem
|
||||||
|
|
||||||
|
URL appURL = this.getClass().getClassLoader().getResource(appPath.getValue());
|
||||||
|
if ( appURL == null)
|
||||||
|
throw new DeviceContextException("Failed to find drag and drop application, " + appPath.getValue());
|
||||||
|
File appFile = new File(appURL.getFile());
|
||||||
|
if ( appFile.exists() == false)
|
||||||
|
throw new DeviceContextException("Drag and drop application not found, " + appPath.getValue());
|
||||||
|
|
||||||
// Create the pseudo file for the drag and drop application
|
// Create the pseudo file for the drag and drop application
|
||||||
|
|
||||||
PseudoFile dragDropPseudo = new PseudoFile( pseudoName.getValue(), appPath.getValue());
|
PseudoFile dragDropPseudo = new PseudoFile( pseudoName.getValue(), appFile.getAbsolutePath());
|
||||||
context.setDragAndDropApp( dragDropPseudo);
|
context.setDragAndDropApp( dragDropPseudo);
|
||||||
|
|
||||||
// Enable pseudo file support
|
// Enable pseudo file support
|
||||||
|
Reference in New Issue
Block a user