Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
gradle/wrapper
src
.travis.yml
README.md GH-208: Allow setting of SMB min/max versions Apr 15, 2019
build.gradle Upgrade dependencies Apr 12, 2019
gradle.properties [artifactory-release] Next development version Apr 10, 2019
gradlew Upgrade to Gradle 4.7 and Log4J 2 Apr 26, 2018
gradlew.bat GH-168: Upgrade to SI-4.3.6 and others Jan 16, 2017
publish-maven.gradle URL Cleanup Mar 6, 2019
settings.gradle GH-168: Upgrade to SI-4.3.6 and others Jan 16, 2017

README.md

Spring Integration SMB Support

Introduction

This module adds Spring Integration support for Server Message Block (SMB).

Version

Versions in Maven Repository

Using Maven

Put the following block into pom.xml if using Maven:

<dependency>
    <groupId>org.springframework.integration</groupId>
    <artifactId>spring-integration-smb</artifactId>
    <version>1.0.0.RELEASE</version>
</dependency>

Changes

Version 1.1
  • Updated to use the latest version of the JCIFS library
  • SMB2 (2.02 protocol level) support, some SMB3 support
Version 1.2
  • Ability to set the SMB min/max versions in the SmbSessionFactory via configuration in the JCIFS library

Overview

The Java CIFS Client Library has been chosen as a Java implementation for the CIFS/SMB networking protocol. Its SmbFile abstraction is simply wrapped to the Spring Integration "Remote File" foundations like SmbSession, SmbRemoteFileTemplate, etc.

The SMB Channel Adapters and support classes implementations are fully similar to existing components for (S)FTP or AWS S3 protocols. So, if you familiar with those components, it is pretty straightforward to use this extension. But any way here are several words about existing components:

SMB Inbound Channel Adapter

To download SMB files locally the SmbInboundFileSynchronizingMessageSource is provided. It is simple extension of the AbstractInboundFileSynchronizingMessageSource which requires SmbInboundFileSynchronizer injection. For filtering remote files you still can use any existing FileListFilter implementations, but particular SmbRegexPatternFileListFilter and SmbSimplePatternFileListFilter are provided. For XML configuration the <int-smb:inbound-channel-adapter> component is provided.

SMB Outbound Channel Adapter

There is no (yet) some SMB specific requirements for files transferring to SMB, so for XML <int-smb:outbound-channel-adapter> component we simply reuse an existing FileTransferringMessageHandler. In case of Java configuration that FileTransferringMessageHandler should be supplied with the SmbSessionFactory (or SmbRemoteFileTemplate).

@ServiceActivator(inputChannel = "storeToSmb")
@Bean
public MessageHandler smbMessageHandler(SmbSessionFactory smbSessionFactory) {
    FileTransferringMessageHandler<SmbFile> handler =
                new FileTransferringMessageHandler<>(smbSessionFactory);
    handler.setRemoteDirectoryExpression(
                new LiteralExpression("remote-target-dir"));
    handler.setFileNameGenerator(m ->
                m.getHeaders().get(FileHeaders.FILENAME, String.class) + ".test");
    handler.setAutoCreateDirectory(true);
    return handler;
}

Setting SMB Protocol Min/Max Versions

Example: To set a minimum version of SMB 2.1 and a maximum version of SMB 3.1.1

@Bean
public SmbSessionFactory smbSessionFactory() {
    SmbSessionFactory smbSession = new SmbSessionFactory();
    smbSession.setHost("myHost");
    smbSession.setPort(445);
    smbSession.setDomain("myDomain");
    smbSession.setUsername("myUser");
    smbSession.setPassword("myPassword");
    smbSession.setShareAndDir("myShareAndDir");
    smbSession.setSmbMinVersion(DialectVersion.SMB210);
    smbSession.setSmbMaxVersion(DialectVersion.SMB311);
    return smbSession;
}
You can’t perform that action at this time.