【问题标题】:How to setup alfresco jlan file server as a standalone java package?如何将 alfresco jlan 文件服务器设置为独立的 java 包?
【发布时间】:2019-03-29 14:37:24
【问题描述】:

我是文件服务器实现的新手。 Alfresco jlan 似乎是一个好的开始,因为它是大多数服务器协议(CIFS、NFS 和 FTP)的纯 Java 实现。有很多专门用于 alfresco 的线程,但不是专门针对 jlan 的。如何在 NetBeans 中将 jlan 设置为独立的 java 包?

提前致谢。

【问题讨论】:

  • 我认为在这种情况下,您需要单独使用 JLan,而不是完整的 Alfresco 存储库(不仅仅是 jlan)。您是否尝试过 downloading the JLan source 并将其添加到您的项目中?
  • @Gagravarr 12 谢谢。是的,我已经尝试过了,但是我收到了找不到文件的错误 - 缺少 jlanserver.xml
  • 我认为您需要提供其中一个提供端口、绑定等。应该是源包中的.xml.sample 或类似名称,有没有运气找到并填写它?

标签: java alfresco fileserver


【解决方案1】:

看看https://web.archive.org/web/20110925093759/https://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/alfresco-jlan/

在这里,您将找到一个 runsrv.bat(和 runsrv.sh)脚本,用于使用提供的 XML 配置引导 JLANServer:jlanConfig.xml

由于提供的文件(jlanConfig.xml 和 JLANServer)不是提供的二进制文件的一部分(例如,不是 alfresco-jlan-embed v5.0.b 的一部分),您需要自己提供类似的设置。

例如:

    ServerConfiguration cfg = new JLANFileServerConfiguration();

    NetBIOSNameServer netBIOSNameServer = new NetBIOSNameServer(cfg);
    cfg.addServer(netBIOSNameServer);
    SMBServer smbServer = new SMBServer(cfg);
    cfg.addServer(smbServer);

    // start servers
    for (int i = 0; i < cfg.numberOfServers(); i++) {
        NetworkServer server = cfg.getServer(i);
        server.startServer();
    }

ServerConfiguration 可以从 XML 文件中读取,或者使用 Java 代码构建:

private static final String HOSTNAME = "JLANHOST";

private static final int DefaultThreadPoolInit  = 25;
private static final int DefaultThreadPoolMax   = 50;

private static final int[] DefaultMemoryPoolBufSizes  = { 256, 4096, 16384, 66000 };
private static final int[] DefaultMemoryPoolInitAlloc = {  20,   20,     5,     5 };
private static final int[] DefaultMemoryPoolMaxAlloc  = { 100,   50,    50,    50 };

public JLANFileServerConfiguration() throws InvalidConfigurationException, DeviceContextException {
    super(HOSTNAME);
    setServerName(HOSTNAME);

    // DEBUG
    DebugConfigSection debugConfig = new DebugConfigSection(this);
    final GenericConfigElement debugConfigElement = new GenericConfigElement("output");
    final GenericConfigElement logLevelConfigElement = new GenericConfigElement("logLevel");
    logLevelConfigElement.setValue("Debug");
    debugConfig.setDebug("org.alfresco.jlan.debug.ConsoleDebug", debugConfigElement);

    // CORE
    CoreServerConfigSection coreConfig = new CoreServerConfigSection(this);
    coreConfig.setMemoryPool( DefaultMemoryPoolBufSizes, DefaultMemoryPoolInitAlloc, DefaultMemoryPoolMaxAlloc);
    coreConfig.setThreadPool(DefaultThreadPoolInit, DefaultThreadPoolMax);
    coreConfig.getThreadPool().setDebug(true);

    // GLOBAL
    GlobalConfigSection globalConfig = new GlobalConfigSection(this);

    // SECURITY
    SecurityConfigSection secConfig = new SecurityConfigSection(this);
    DefaultAccessControlManager accessControlManager = new DefaultAccessControlManager();
    accessControlManager.setDebug(true);
    accessControlManager.initialize(this, new GenericConfigElement("aclManager"));
    secConfig.setAccessControlManager(accessControlManager);
    secConfig.setJCEProvider("cryptix.jce.provider.CryptixCrypto");
    final UserAccountList userAccounts = new UserAccountList();
    secConfig.setUserAccounts(userAccounts);

    // SHARES
    FilesystemsConfigSection filesysConfig = new FilesystemsConfigSection(this);
    DiskInterface diskInterface = new org.alfresco.jlan.smb.server.disk.JavaFileDiskDriver();
    final GenericConfigElement driverConfig = new GenericConfigElement("driver");
    final GenericConfigElement localPathConfig = new GenericConfigElement("LocalPath");
    localPathConfig.setValue(".");
    driverConfig.addChild(localPathConfig);
    DiskDeviceContext diskDeviceContext = (DiskDeviceContext) diskInterface.createContext("JLANSHARE", driverConfig);
    diskDeviceContext.setShareName("JLANSHARE");
    diskDeviceContext.setConfigurationParameters(driverConfig);
    diskDeviceContext.enableChangeHandler(false);
    diskDeviceContext.setDiskInformation(new SrvDiskInfo(2560000, 64, 512, 2304000));// Default to a 80Gb sized disk with 90% free space
    DiskSharedDevice diskDev = new DiskSharedDevice("JLANSHARE", diskInterface, diskDeviceContext);
    diskDev.setConfiguration(this);
    diskDev.setAccessControlList(secConfig.getGlobalAccessControls());
    diskDeviceContext.startFilesystem(diskDev);
    filesysConfig.addShare(diskDev);

    // SMB
    CIFSConfigSection cifsConfig = new CIFSConfigSection(this);
    cifsConfig.setServerName(HOSTNAME);
    cifsConfig.setDomainName("MYDOMAIN");
    cifsConfig.setHostAnnounceInterval(5);
    cifsConfig.setHostAnnouncer(true);
    final CifsAuthenticator authenticator = new LocalAuthenticator() {
        @Override
        public int authenticateUser(ClientInfo client, SrvSession sess, int alg) {
            return AUTH_ALLOW;
        }
    };
    authenticator.setDebug(true);
    authenticator.setAllowGuest(true);
    authenticator.setAccessMode(CifsAuthenticator.USER_MODE);
    final GenericConfigElement authenticatorConfigElement = new GenericConfigElement("authenticator");
    authenticator.initialize(this, authenticatorConfigElement);
    cifsConfig.setAuthenticator(authenticator);
    cifsConfig.setHostAnnounceDebug(true);
    cifsConfig.setNetBIOSDebug(true);
    cifsConfig.setSessionDebugFlags(-1);
    cifsConfig.setTcpipSMB(true);
}

请注意,要在 Windows 机器上使用 JLAN,您需要禁用端口 445 上的内置文件共享。

【讨论】:

  • 嗨,我想试试你的代码,但 CifsAuthenticator 附近似乎有错误。您可以发布更新版本或只是解释该怎么做吗?谢谢。
  • 抱歉,我删除了重复的身份验证器(上面的示例授予任何用户访问权限)。已更新。
  • 感谢您的更新。现在authenticatorConfigElement 不见了:-)
  • 再次道歉,我不得不在身份验证部分删除我们特定的服务器配置,这就是上面的 sn-p 被破坏的原因。我添加了这个缺少的配置元素行,现在应该可以工作了。
猜你喜欢
  • 2015-11-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-08-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多