Alfresco JLAN integration updates.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@7758 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gary Spencer
2008-01-06 16:50:32 +00:00
parent f5738eee4d
commit 139726aeaa
6 changed files with 120 additions and 80 deletions

View File

@@ -19,5 +19,6 @@
<classpathentry kind="lib" path="/3rd Party/lib/chiba-1.3.0.jar"/> <classpathentry kind="lib" path="/3rd Party/lib/chiba-1.3.0.jar"/>
<classpathentry kind="lib" path="/3rd Party/lib/json.jar"/> <classpathentry kind="lib" path="/3rd Party/lib/json.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Web-Framework"/> <classpathentry combineaccessrules="false" kind="src" path="/Web-Framework"/>
<classpathentry combineaccessrules="false" kind="src" path="/Alfresco JLAN"/>
<classpathentry kind="output" path="build/classes"/> <classpathentry kind="output" path="build/classes"/>
</classpath> </classpath>

View File

@@ -54,14 +54,14 @@ import javax.servlet.http.HttpSession;
import javax.transaction.UserTransaction; import javax.transaction.UserTransaction;
import org.alfresco.config.ConfigService; import org.alfresco.config.ConfigService;
import org.alfresco.filesys.server.auth.kerberos.KerberosDetails; import org.alfresco.filesys.ServerConfigurationBean;
import org.alfresco.filesys.server.auth.kerberos.SessionSetupPrivilegedAction;
import org.alfresco.filesys.server.auth.spnego.NegTokenInit;
import org.alfresco.filesys.server.auth.spnego.NegTokenTarg;
import org.alfresco.filesys.server.auth.spnego.OID;
import org.alfresco.filesys.server.auth.spnego.SPNEGO;
import org.alfresco.filesys.server.config.ServerConfiguration;
import org.alfresco.i18n.I18NUtil; import org.alfresco.i18n.I18NUtil;
import org.alfresco.jlan.server.auth.kerberos.KerberosDetails;
import org.alfresco.jlan.server.auth.kerberos.SessionSetupPrivilegedAction;
import org.alfresco.jlan.server.auth.spnego.NegTokenInit;
import org.alfresco.jlan.server.auth.spnego.NegTokenTarg;
import org.alfresco.jlan.server.auth.spnego.OID;
import org.alfresco.jlan.server.auth.spnego.SPNEGO;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.security.authentication.AuthenticationException; import org.alfresco.repo.security.authentication.AuthenticationException;
@@ -112,7 +112,7 @@ public class KerberosAuthenticationFilter extends AbstractAuthenticationFilter i
// File server configuration // File server configuration
private ServerConfiguration m_srvConfig; private ServerConfigurationBean m_srvConfig;
// Various services required by the Kerberos authenticator // Various services required by the Kerberos authenticator
@@ -196,7 +196,7 @@ public class KerberosAuthenticationFilter extends AbstractAuthenticationFilter i
m_personService = (PersonService) ctx.getBean("personService"); m_personService = (PersonService) ctx.getBean("personService");
m_configService = (ConfigService) ctx.getBean("webClientConfigService"); m_configService = (ConfigService) ctx.getBean("webClientConfigService");
m_srvConfig = (ServerConfiguration) ctx.getBean(ServerConfiguration.SERVER_CONFIGURATION); m_srvConfig = (ServerConfigurationBean) ctx.getBean(ServerConfigurationBean.SERVER_CONFIGURATION);
// Check that the authentication component supports the required mode // Check that the authentication component supports the required mode

View File

@@ -48,19 +48,20 @@ import javax.transaction.UserTransaction;
import net.sf.acegisecurity.BadCredentialsException; import net.sf.acegisecurity.BadCredentialsException;
import org.alfresco.config.ConfigService; import org.alfresco.config.ConfigService;
import org.alfresco.filesys.server.auth.PasswordEncryptor; import org.alfresco.filesys.ServerConfigurationBean;
import org.alfresco.filesys.server.auth.ntlm.NTLM;
import org.alfresco.filesys.server.auth.ntlm.NTLMLogonDetails;
import org.alfresco.filesys.server.auth.ntlm.NTLMMessage;
import org.alfresco.filesys.server.auth.ntlm.TargetInfo;
import org.alfresco.filesys.server.auth.ntlm.Type1NTLMMessage;
import org.alfresco.filesys.server.auth.ntlm.Type2NTLMMessage;
import org.alfresco.filesys.server.auth.ntlm.Type3NTLMMessage;
import org.alfresco.filesys.server.auth.passthru.DomainMapping;
import org.alfresco.filesys.server.config.ServerConfiguration;
import org.alfresco.filesys.util.DataPacker;
import org.alfresco.filesys.util.IPAddress;
import org.alfresco.i18n.I18NUtil; import org.alfresco.i18n.I18NUtil;
import org.alfresco.jlan.server.auth.PasswordEncryptor;
import org.alfresco.jlan.server.auth.ntlm.NTLM;
import org.alfresco.jlan.server.auth.ntlm.NTLMLogonDetails;
import org.alfresco.jlan.server.auth.ntlm.NTLMMessage;
import org.alfresco.jlan.server.auth.ntlm.TargetInfo;
import org.alfresco.jlan.server.auth.ntlm.Type1NTLMMessage;
import org.alfresco.jlan.server.auth.ntlm.Type2NTLMMessage;
import org.alfresco.jlan.server.auth.ntlm.Type3NTLMMessage;
import org.alfresco.jlan.server.auth.passthru.DomainMapping;
import org.alfresco.jlan.server.config.SecurityConfigSection;
import org.alfresco.jlan.util.DataPacker;
import org.alfresco.jlan.util.IPAddress;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.authentication.AuthenticationComponent; import org.alfresco.repo.security.authentication.AuthenticationComponent;
import org.alfresco.repo.security.authentication.AuthenticationException; import org.alfresco.repo.security.authentication.AuthenticationException;
@@ -116,7 +117,7 @@ public class NTLMAuthenticationFilter extends AbstractAuthenticationFilter imple
// File server configuration // File server configuration
private ServerConfiguration m_srvConfig; private ServerConfigurationBean m_srvConfig;
// Various services required by NTLM authenticator // Various services required by NTLM authenticator
@@ -127,6 +128,10 @@ public class NTLMAuthenticationFilter extends AbstractAuthenticationFilter imple
private TransactionService m_transactionService; private TransactionService m_transactionService;
private ConfigService m_configService; private ConfigService m_configService;
// Security configuration section, for domain mappings
private SecurityConfigSection m_secConfig;
// Password encryptor // Password encryptor
private PasswordEncryptor m_encryptor = new PasswordEncryptor(); private PasswordEncryptor m_encryptor = new PasswordEncryptor();
@@ -180,7 +185,7 @@ public class NTLMAuthenticationFilter extends AbstractAuthenticationFilter imple
m_personService = (PersonService) ctx.getBean("personService"); m_personService = (PersonService) ctx.getBean("personService");
m_configService = (ConfigService) ctx.getBean("webClientConfigService"); m_configService = (ConfigService) ctx.getBean("webClientConfigService");
m_srvConfig = (ServerConfiguration) ctx.getBean(ServerConfiguration.SERVER_CONFIGURATION); m_srvConfig = (ServerConfigurationBean) ctx.getBean(ServerConfigurationBean.SERVER_CONFIGURATION);
// Check that the authentication component supports the required mode // Check that the authentication component supports the required mode
@@ -203,6 +208,10 @@ public class NTLMAuthenticationFilter extends AbstractAuthenticationFilter imple
m_srvName = m_srvConfig.getLocalServerName(true) + "_A"; m_srvName = m_srvConfig.getLocalServerName(true) + "_A";
} }
// Find the security configuration section
m_secConfig = (SecurityConfigSection) m_srvConfig.getConfigSection( SecurityConfigSection.SectionName);
} }
else else
{ {
@@ -781,6 +790,10 @@ public class NTLMAuthenticationFilter extends AbstractAuthenticationFilter imple
NodeRef personNodeRef = m_personService.getPerson(userName); NodeRef personNodeRef = m_personService.getPerson(userName);
// Use the system user context to do the user lookup
m_authComponent.setCurrentUser( m_authComponent.getSystemUserName());
// User name should match the uid in the person entry found // User name should match the uid in the person entry found
userName = (String) m_nodeService.getProperty(personNodeRef, ContentModel.PROP_USERNAME); userName = (String) m_nodeService.getProperty(personNodeRef, ContentModel.PROP_USERNAME);
@@ -946,13 +959,13 @@ public class NTLMAuthenticationFilter extends AbstractAuthenticationFilter imple
{ {
// Check if there are any domain mappings // Check if there are any domain mappings
if ( m_srvConfig.hasDomainMappings() == false) if ( m_secConfig != null && m_secConfig.hasDomainMappings() == false)
return null; return null;
// convert the client IP address to an integer value // convert the client IP address to an integer value
int clientAddr = IPAddress.parseNumericAddress( clientIP); int clientAddr = IPAddress.parseNumericAddress( clientIP);
for ( DomainMapping domainMap : m_srvConfig.getDomainMappings()) for ( DomainMapping domainMap : m_secConfig.getDomainMappings())
{ {
if ( domainMap.isMemberOfDomain( clientAddr)) if ( domainMap.isMemberOfDomain( clientAddr))
{ {

View File

@@ -26,6 +26,7 @@ package org.alfresco.web.bean;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -34,11 +35,14 @@ import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent; import javax.faces.event.ActionEvent;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.filesys.CIFSServer; import org.alfresco.filesys.CIFSServerBean;
import org.alfresco.filesys.server.config.ServerConfiguration; import org.alfresco.filesys.ServerConfigurationBean;
import org.alfresco.filesys.server.filesys.DiskSharedDevice; import org.alfresco.filesys.repo.ContentContext;
import org.alfresco.filesys.smb.server.repo.ContentContext; import org.alfresco.filesys.repo.ContentDiskInterface;
import org.alfresco.filesys.smb.server.repo.ContentDiskInterface; import org.alfresco.jlan.server.core.SharedDevice;
import org.alfresco.jlan.server.core.SharedDeviceList;
import org.alfresco.jlan.server.filesys.DiskSharedDevice;
import org.alfresco.jlan.server.filesys.FilesystemsConfigSection;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.permissions.AccessDeniedException; import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.service.cmr.repository.FileTypeImageSize; import org.alfresco.service.cmr.repository.FileTypeImageSize;
@@ -131,7 +135,7 @@ public class NavigationBean
/** /**
* @param cifsServer The cifsServer to set. * @param cifsServer The cifsServer to set.
*/ */
public void setCifsServer(CIFSServer cifsServer) public void setCifsServer(CIFSServerBean cifsServer)
{ {
this.cifsServer = cifsServer; this.cifsServer = cifsServer;
} }
@@ -595,27 +599,33 @@ public class NavigationBean
Path path = node.getNodePath(); Path path = node.getNodePath();
// resolve CIFS network folder location for this node // resolve CIFS network folder location for this node
ServerConfiguration fileServiceConfig = (ServerConfiguration)FacesContextUtils.getRequiredWebApplicationContext( FilesystemsConfigSection filesysConfig = (FilesystemsConfigSection) cifsServer.getConfiguration().getConfigSection(FilesystemsConfigSection.SectionName);
FacesContext.getCurrentInstance()).getBean("fileServerConfiguration"); DiskSharedDevice diskShare = null;
if (fileServiceConfig.isSMBServerEnabled())
{
DiskSharedDevice diskShare = cifsServer.getConfiguration().getPrimaryFilesystem();
if (diskShare != null && diskShare.getContext() instanceof ContentContext)
{
ContentContext contentCtx = (ContentContext) diskShare.getContext();
NodeRef rootNode = contentCtx.getRootNode();
try
{
String cifsPath = Repository.getNamePath(this.nodeService, path, rootNode, "\\", "file:///" + getCIFSServerPath(diskShare));
node.getProperties().put("cifsPath", cifsPath); SharedDeviceList shares = filesysConfig.getShares();
node.getProperties().put("cifsPathLabel", cifsPath.substring(8)); // strip file:/// part Enumeration<SharedDevice> shareEnum = shares.enumerateShares();
}
catch(AccessDeniedException ade) while ( shareEnum.hasMoreElements() && diskShare == null) {
{ SharedDevice curShare = shareEnum.nextElement();
node.getProperties().put("cifsPath", ""); if ( curShare.getContext() instanceof ContentContext)
node.getProperties().put("cifsPathLabel",""); // strip file:/// part diskShare = (DiskSharedDevice) curShare;
} }
if (diskShare != null)
{
ContentContext contentCtx = (ContentContext) diskShare.getContext();
NodeRef rootNode = contentCtx.getRootNode();
try
{
String cifsPath = Repository.getNamePath(this.nodeService, path, rootNode, "\\", "file:///" + getCIFSServerPath(diskShare));
node.getProperties().put("cifsPath", cifsPath);
node.getProperties().put("cifsPathLabel", cifsPath.substring(8)); // strip file:/// part
}
catch(AccessDeniedException ade)
{
node.getProperties().put("cifsPath", "");
node.getProperties().put("cifsPathLabel",""); // strip file:/// part
} }
} }
@@ -975,7 +985,7 @@ public class NavigationBean
protected RuleService ruleService; protected RuleService ruleService;
/** CIFSServer bean reference */ /** CIFSServer bean reference */
protected CIFSServer cifsServer; protected CIFSServerBean cifsServer;
/** CIFS content disk driver bean reference */ /** CIFS content disk driver bean reference */
protected ContentDiskInterface contentDiskDriver; protected ContentDiskInterface contentDiskDriver;

View File

@@ -32,7 +32,6 @@ import java.util.StringTokenizer;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter; import javax.faces.context.ResponseWriter;
import org.alfresco.filesys.server.filesys.FileExistsException;
import org.alfresco.model.ApplicationModel; import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.MimetypeMap;

View File

@@ -32,6 +32,7 @@ import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@@ -53,9 +54,12 @@ import javax.servlet.ServletContext;
import org.alfresco.config.ConfigElement; import org.alfresco.config.ConfigElement;
import org.alfresco.error.AlfrescoRuntimeException; import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.filesys.CIFSServer; import org.alfresco.filesys.CIFSServerBean;
import org.alfresco.filesys.server.filesys.DiskSharedDevice; import org.alfresco.filesys.repo.ContentContext;
import org.alfresco.filesys.smb.server.repo.ContentContext; import org.alfresco.jlan.server.core.SharedDevice;
import org.alfresco.jlan.server.core.SharedDeviceList;
import org.alfresco.jlan.server.filesys.DiskSharedDevice;
import org.alfresco.jlan.server.filesys.FilesystemsConfigSection;
import org.alfresco.model.ApplicationModel; import org.alfresco.model.ApplicationModel;
import org.alfresco.model.ContentModel; import org.alfresco.model.ContentModel;
import org.alfresco.repo.security.permissions.AccessDeniedException; import org.alfresco.repo.security.permissions.AccessDeniedException;
@@ -767,12 +771,25 @@ public final class Utils
NodeService nodeService = Repository.getServiceRegistry(context).getNodeService(); NodeService nodeService = Repository.getServiceRegistry(context).getNodeService();
NavigationBean navBean = (NavigationBean)context.getExternalContext(). NavigationBean navBean = (NavigationBean)context.getExternalContext().
getSessionMap().get(NavigationBean.BEAN_NAME); getSessionMap().get(NavigationBean.BEAN_NAME);
CIFSServer cifsServer = (CIFSServer)FacesContextUtils.getRequiredWebApplicationContext( CIFSServerBean cifsServer = (CIFSServerBean)FacesContextUtils.getRequiredWebApplicationContext(
context).getBean("cifsServer"); context).getBean("cifsServer");
if (nodeService != null && navBean != null && cifsServer != null) if (nodeService != null && navBean != null && cifsServer != null)
{ {
DiskSharedDevice diskShare = cifsServer.getConfiguration().getPrimaryFilesystem(); // Resolve CIFS network folder location for this node
FilesystemsConfigSection filesysConfig = (FilesystemsConfigSection) cifsServer.getConfiguration().getConfigSection(FilesystemsConfigSection.SectionName);
DiskSharedDevice diskShare = null;
SharedDeviceList shares = filesysConfig.getShares();
Enumeration<SharedDevice> shareEnum = shares.enumerateShares();
while ( shareEnum.hasMoreElements() && diskShare == null) {
SharedDevice curShare = shareEnum.nextElement();
if ( curShare.getContext() instanceof ContentContext)
diskShare = (DiskSharedDevice) curShare;
}
if (diskShare != null) if (diskShare != null)
{ {