Big honkin' merge from head. Sheesh!

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3617 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Britt Park
2006-08-27 01:01:30 +00:00
parent e2c66899cc
commit 8031cc6574
322 changed files with 20776 additions and 6550 deletions

View File

@@ -19,7 +19,9 @@ package org.alfresco.filesys.server.config;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.NetworkInterface;
import java.net.Socket;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.security.Provider;
import java.security.Security;
@@ -62,11 +64,15 @@ import org.alfresco.filesys.server.core.ShareType;
import org.alfresco.filesys.server.core.SharedDevice;
import org.alfresco.filesys.server.core.SharedDeviceList;
import org.alfresco.filesys.server.filesys.DefaultShareMapper;
import org.alfresco.filesys.server.filesys.DiskDeviceContext;
import org.alfresco.filesys.server.filesys.DiskInterface;
import org.alfresco.filesys.server.filesys.DiskSharedDevice;
import org.alfresco.filesys.server.filesys.HomeShareMapper;
import org.alfresco.filesys.smb.ServerType;
import org.alfresco.filesys.smb.TcpipSMB;
import org.alfresco.filesys.smb.server.repo.ContentContext;
import org.alfresco.filesys.smb.server.repo.DesktopAction;
import org.alfresco.filesys.smb.server.repo.DesktopActionException;
import org.alfresco.filesys.smb.server.repo.DesktopActionTable;
import org.alfresco.filesys.util.IPAddress;
import org.alfresco.filesys.util.X64;
import org.alfresco.repo.security.authentication.AuthenticationComponent;
@@ -182,6 +188,16 @@ public class ServerConfiguration implements ApplicationListener
private String m_broadcast;
// NetBIOS ports
private int m_nbNamePort = RFCNetBIOSProtocol.NAME_PORT;
private int m_nbSessPort = RFCNetBIOSProtocol.PORT;
private int m_nbDatagramPort = RFCNetBIOSProtocol.DATAGRAM;
// Native SMB port
private int m_tcpSMBPort = TcpipSMB.PORT;
// Announce the server to network neighborhood, announcement interval in
// minutes
@@ -586,7 +602,7 @@ public class ServerConfiguration implements ApplicationListener
m_platform = PlatformType.LINUX;
else if (osName.startsWith("Mac OS X"))
m_platform = PlatformType.MACOSX;
else if (osName.startsWith("Solaris"))
else if (osName.startsWith("Solaris") || osName.startsWith("SunOS"))
m_platform = PlatformType.SOLARIS;
}
@@ -800,103 +816,198 @@ public class ServerConfiguration implements ApplicationListener
platformOK = true;
}
// Check if the broadcast mask has been specified
if (getBroadcastMask() == null)
throw new AlfrescoRuntimeException("Network broadcast mask not specified");
// Enable the NetBIOS SMB support, if enabled for this platform
setNetBIOSSMB(platformOK);
// Check for a bind address
String bindto = elem.getAttribute("bindto");
if (bindto != null && bindto.length() > 0)
// Parse/check NetBIOS settings, if enabled
if ( hasNetBIOSSMB())
{
// Validate the bind address
try
{
// Check the bind address
InetAddress bindAddr = InetAddress.getByName(bindto);
// Set the bind address for the NetBIOS name server
setNetBIOSBindAddress(bindAddr);
}
catch (UnknownHostException ex)
{
throw new AlfrescoRuntimeException("Invalid NetBIOS bind address");
}
}
else if (hasSMBBindAddress())
{
// Use the SMB bind address for the NetBIOS name server
setNetBIOSBindAddress(getSMBBindAddress());
}
else
{
// Get a list of all the local addresses
InetAddress[] addrs = null;
try
{
// Get the local server IP address list
addrs = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName());
}
catch (UnknownHostException ex)
{
logger.error("Failed to get local address list", ex);
}
// Check the address list for one or more valid local addresses filtering out the loopback address
int addrCnt = 0;
if ( addrs != null)
{
for (int i = 0; i < addrs.length; i++)
{
// Check for a valid address, filter out '127.0.0.1' and '0.0.0.0' addresses
if (addrs[i].getHostAddress().equals("127.0.0.1") == false
&& addrs[i].getHostAddress().equals("0.0.0.0") == false)
addrCnt++;
}
}
// Check if any addresses were found
if ( addrCnt == 0)
{
// Log the available IP addresses
if ( logger.isDebugEnabled())
{
logger.debug("Local address list dump :-");
if ( addrs != null)
{
for ( int i = 0; i < addrs.length; i++)
logger.debug( " Address: " + addrs[i]);
}
else
logger.debug(" No addresses");
}
// Throw an exception to stop the CIFS/NetBIOS name server from starting
throw new AlfrescoRuntimeException( "Failed to get IP address(es) for the local server, check hosts file and/or DNS setup");
}
// Check if the broadcast mask has been specified
if (getBroadcastMask() == null)
throw new AlfrescoRuntimeException("Network broadcast mask not specified");
// Check for a bind address
String bindto = elem.getAttribute("bindto");
if (bindto != null && bindto.length() > 0)
{
// Validate the bind address
try
{
// Check the bind address
InetAddress bindAddr = InetAddress.getByName(bindto);
// Set the bind address for the NetBIOS name server
setNetBIOSBindAddress(bindAddr);
}
catch (UnknownHostException ex)
{
throw new AlfrescoRuntimeException("Invalid NetBIOS bind address");
}
}
else if (hasSMBBindAddress())
{
// Use the SMB bind address for the NetBIOS name server
setNetBIOSBindAddress(getSMBBindAddress());
}
else
{
// Get a list of all the local addresses
InetAddress[] addrs = null;
try
{
// Get the local server IP address list
addrs = InetAddress.getAllByName(InetAddress.getLocalHost().getHostName());
}
catch (UnknownHostException ex)
{
logger.error("Failed to get local address list", ex);
}
// Check the address list for one or more valid local addresses filtering out the loopback address
int addrCnt = 0;
if ( addrs != null)
{
for (int i = 0; i < addrs.length; i++)
{
// Check for a valid address, filter out '127.0.0.1' and '0.0.0.0' addresses
if (addrs[i].getHostAddress().equals("127.0.0.1") == false
&& addrs[i].getHostAddress().equals("0.0.0.0") == false)
addrCnt++;
}
}
// Check if any addresses were found
if ( addrCnt == 0)
{
// Enumerate the network adapter list
Enumeration<NetworkInterface> niEnum = null;
try
{
niEnum = NetworkInterface.getNetworkInterfaces();
}
catch (SocketException ex)
{
}
if ( niEnum != null)
{
while ( niEnum.hasMoreElements())
{
// Get the current network interface
NetworkInterface ni = niEnum.nextElement();
// Enumerate the addresses for the network adapter
Enumeration<InetAddress> niAddrs = ni.getInetAddresses();
if ( niAddrs != null)
{
// Check for any valid addresses
while ( niAddrs.hasMoreElements())
{
InetAddress curAddr = niAddrs.nextElement();
if ( curAddr.getHostAddress().equals("127.0.0.1") == false &&
curAddr.getHostAddress().equals("0.0.0.0") == false)
addrCnt++;
}
}
}
// DEBUG
if ( addrCnt > 0 && logger.isDebugEnabled())
logger.debug("Found valid IP address from interface list");
}
// Check if we found any valid network addresses
if ( addrCnt == 0)
{
// Log the available IP addresses
if ( logger.isDebugEnabled())
{
logger.debug("Local address list dump :-");
if ( addrs != null)
{
for ( int i = 0; i < addrs.length; i++)
logger.debug( " Address: " + addrs[i]);
}
else
logger.debug(" No addresses");
}
// Throw an exception to stop the CIFS/NetBIOS name server from starting
throw new AlfrescoRuntimeException( "Failed to get IP address(es) for the local server, check hosts file and/or DNS setup");
}
}
}
// Check if the session port has been specified
String portNum = elem.getAttribute("sessionPort");
if ( portNum != null && portNum.length() > 0) {
try {
setNetBIOSSessionPort(Integer.parseInt(portNum));
if ( getNetBIOSSessionPort() <= 0 || getNetBIOSSessionPort() >= 65535)
throw new AlfrescoRuntimeException("NetBIOS session port out of valid range");
}
catch (NumberFormatException ex) {
throw new AlfrescoRuntimeException("Invalid NetBIOS session port");
}
}
// Check if the name port has been specified
portNum = elem.getAttribute("namePort");
if ( portNum != null && portNum.length() > 0) {
try {
setNetBIOSNamePort(Integer.parseInt(portNum));
if ( getNetBIOSNamePort() <= 0 || getNetBIOSNamePort() >= 65535)
throw new AlfrescoRuntimeException("NetBIOS name port out of valid range");
}
catch (NumberFormatException ex) {
throw new AlfrescoRuntimeException("Invalid NetBIOS name port");
}
}
// Check if the datagram port has been specified
portNum = elem.getAttribute("datagramPort");
if ( portNum != null && portNum.length() > 0) {
try {
setNetBIOSDatagramPort(Integer.parseInt(portNum));
if ( getNetBIOSDatagramPort() <= 0 || getNetBIOSDatagramPort() >= 65535)
throw new AlfrescoRuntimeException("NetBIOS datagram port out of valid range");
}
catch (NumberFormatException ex) {
throw new AlfrescoRuntimeException("Invalid NetBIOS datagram port");
}
}
}
}
else
@@ -937,6 +1048,20 @@ public class ServerConfiguration implements ApplicationListener
// Enable the TCP/IP SMB support, if enabled for this platform
setTcpipSMB(platformOK);
// Check if the port has been specified
String portNum = elem.getAttribute("port");
if ( portNum != null && portNum.length() > 0) {
try {
setTcpipSMBPort(Integer.parseInt(portNum));
if ( getTcpipSMBPort() <= 0 || getTcpipSMBPort() >= 65535)
throw new AlfrescoRuntimeException("TCP/IP SMB port out of valid range");
}
catch (NumberFormatException ex) {
throw new AlfrescoRuntimeException("Invalid TCP/IP SMB port");
}
}
}
else
{
@@ -1460,7 +1585,7 @@ public class ServerConfiguration implements ApplicationListener
}
}
// Get the top level filesystems confgiruation element
// Get the top level filesystems configuration element
ConfigElement filesystems = config.getConfigElement("filesystems");
@@ -1511,8 +1636,9 @@ public class ServerConfiguration implements ApplicationListener
{
// Create a new filesystem driver instance and create a context for
// the new filesystem
DiskInterface filesysDriver = this.diskInterface;
DiskDeviceContext filesysContext = (DiskDeviceContext) filesysDriver.createContext(elem);
ContentContext filesysContext = (ContentContext) filesysDriver.createContext(elem);
// Check if an access control list has been specified
@@ -1542,6 +1668,18 @@ public class ServerConfiguration implements ApplicationListener
DiskSharedDevice filesys = new DiskSharedDevice(filesysName, filesysDriver, filesysContext);
// Attach desktop actions to the filesystem
ConfigElement deskActionsElem = elem.getChild("desktopActions");
if ( deskActionsElem != null)
{
// Get the desktop actions list
DesktopActionTable desktopActions = processDesktopActions(deskActionsElem, filesys);
if ( desktopActions != null)
filesysContext.setDesktopActions( desktopActions, filesysDriver);
}
// Add any access controls to the share
filesys.setAccessControlList(acls);
@@ -1682,6 +1820,8 @@ public class ServerConfiguration implements ApplicationListener
setAuthenticator(auth, authElem, allowGuest);
auth.setMapToGuest( mapGuest);
}
else
throw new AlfrescoRuntimeException("Authenticator not specified");
}
/**
@@ -1775,6 +1915,99 @@ public class ServerConfiguration implements ApplicationListener
return acls;
}
/**
* Process a desktop actions sub-section and return the desktop action table
*
* @param deskActionElem ConfigElement
* @param fileSys DiskSharedDevice
*/
private final DesktopActionTable processDesktopActions(ConfigElement deskActionElem, DiskSharedDevice fileSys)
{
// Get the desktop action configuration elements
DesktopActionTable desktopActions = null;
List<ConfigElement> actionElems = deskActionElem.getChildren();
if ( actionElems != null)
{
// Check for the global configuration section
ConfigElement globalConfig = deskActionElem.getChild("global");
// Allocate the actions table
desktopActions = new DesktopActionTable();
// Process the desktop actions list
for ( ConfigElement actionElem : actionElems)
{
if ( actionElem.getName().equals("action"))
{
// Get the desktop action class name or bean id
ConfigElement className = actionElem.getChild("class");
if ( className != null)
{
// Load the desktop action class, create a new instance
Object actionObj = null;
try
{
// Create a new desktop action instance
actionObj = Class.forName(className.getValue()).newInstance();
// Make sure the object is a desktop action
if ( actionObj instanceof DesktopAction)
{
// Initialize the desktop action
DesktopAction deskAction = (DesktopAction) actionObj;
deskAction.initializeAction(globalConfig, actionElem, fileSys);
// Add the action to the list of desktop actions
desktopActions.addAction(deskAction);
// DEBUG
if ( logger.isDebugEnabled())
logger.debug("Added desktop action " + deskAction.getName());
}
else
throw new AlfrescoRuntimeException("Desktop action does not extend DesktopAction class, " + className.getValue());
}
catch ( ClassNotFoundException ex)
{
throw new AlfrescoRuntimeException("Desktop action class not found, " + className.getValue());
}
catch (IllegalAccessException ex)
{
throw new AlfrescoRuntimeException("Failed to create desktop action instance, " + className.getValue(), ex);
}
catch ( InstantiationException ex)
{
throw new AlfrescoRuntimeException("Failed to create desktop action instance, " + className.getValue(), ex);
}
catch (DesktopActionException ex)
{
throw new AlfrescoRuntimeException("Failed to initialize desktop action", ex);
}
}
}
else if ( actionElem.getName().equals("global") == false)
throw new AlfrescoRuntimeException("Invalid configuration element in desktopActions section, " + actionElem.getName());
}
}
// Return the desktop actions list
return desktopActions;
}
/**
* Parse the platforms attribute returning the set of platform ids
*
@@ -2013,6 +2246,36 @@ public class ServerConfiguration implements ApplicationListener
return m_nbBindAddress;
}
/**
* Return the NetBIOS name server port
*
* @return int
*/
public final int getNetBIOSNamePort()
{
return m_nbNamePort;
}
/**
* Return the NetBIOS session port
*
* @return int
*/
public final int getNetBIOSSessionPort()
{
return m_nbSessPort;
}
/**
* Return the NetBIOS datagram port
*
* @return int
*/
public final int getNetBIOSDatagramPort()
{
return m_nbDatagramPort;
}
/**
* Return the network broadcast mask to be used for broadcast datagrams.
*
@@ -2154,6 +2417,16 @@ public class ServerConfiguration implements ApplicationListener
return m_win32NBUseWinsock;
}
/**
* Return the native SMB port
*
* @return int
*/
public final int getTcpipSMBPort()
{
return m_tcpSMBPort;
}
/**
* Return the timezone name
*
@@ -2716,6 +2989,36 @@ public class ServerConfiguration implements ApplicationListener
m_netBIOSEnable = ena;
}
/**
* Set the NetBIOS name server port
*
* @param port int
*/
public final void setNetBIOSNamePort(int port)
{
m_nbNamePort = port;
}
/**
* Set the NetBIOS session port
*
* @param port int
*/
public final void setNetBIOSSessionPort(int port)
{
m_nbSessPort = port;
}
/**
* Set the NetBIOS datagram port
*
* @param port int
*/
public final void setNetBIOSDatagramPort(int port)
{
m_nbDatagramPort = port;
}
/**
* Enable/disable the TCP/IP SMB support
*
@@ -2726,6 +3029,16 @@ public class ServerConfiguration implements ApplicationListener
m_tcpSMBEnable = ena;
}
/**
* Set the TCP/IP SMB port
*
* @param port int
*/
public final void setTcpipSMBPort( int port)
{
m_tcpSMBPort = port;
}
/**
* Enable/disable the Win32 NetBIOS SMB support
*