SlideShare uma empresa Scribd logo
1 de 18
Baixar para ler offline
MONTREAL JUNE 30, JULY 1ST AND 2ND 2012




Apache FTP Server integration
Yoann Canal - twitter.com/y_canal
Sophiacom
Agenda

•   Apache FTP Server overview

•   First step: integration in your project

•   Authentication through WebObjects

•   FTPLet: what’s that?

•   Q&A
Preamble

•   The Apache project is not well documented :-(

•   You get almost nothing when you google “Apache FTP Server
    WebObjects”

•   FTP Server has been designed with Spring in mind


➡ This session will not show you a reusable framework but the
     goal is to give you our feedback with some piece of code
Apache FTP Server overview
FTP Server Overview

Except from project web page:

The Apache FtpServer is a 100% pure Java FTP server. It's designed to be a complete and
portable FTP server engine solution based on currently available open protocols. FtpServer
can be run standalone as a Windows service or Unix/Linux daemon, or embedded into a
Java application.We also provide support for integration within Spring applications and
provide our releases as OSGi bundles.
Documentation and download: http://mina.apache.org/ftpserver/
FTP Server Overview

•   Current release is 1.06 (posted on Jul 16, 2011)

•   Url to download:
    http://mina.apache.org/ftpserver/apache-ftpserver-106-
    release.html

•   No dependancies with other libraries
Basic Integration
Project Setup

•   Add the following libraries:
    • ftplet-api-1.0.6.jar
    • ftpserver-core-1.0.6.jar
    • mina-core-2.0.4.jar
•   Initialize an Apache FtpServer
    object in your application or a
    Framework Principal object
FTP Server Initialization

	   FtpServerFactory serverFactory = new FtpServerFactory();

	   // listen to a port > 1024
	   // This port is used when connecting to the FTP Server
	   // ex: ftp ftp://userName@localhost:1250
	   ListenerFactory listenerFactory = new ListenerFactory();
	   listenerFactory.setPort(1250);
	   Listener listener = listenerFactory.createListener();
	   serverFactory.addListener("default", listener);

	   FtpServer server = serverFactory.createServer();
	   try {
	        server.start();
	   } catch (FtpException e) {
	        e.printStackTrace();
	   }
Authentication through
    WebObjects
Authentication

•   You have 2 classes to create

    •   One implements User
        •At least must return the name and the home directory

    •   The other implements UserManager
        • check if the user is allowed to connect
        • create an authenticated User
Authentication

    public class FTPUser implements User {
	   private final String login;

	   public FTPUser(final String login) {
	   	    this.login = login;
	   }

	   @Override
	   public AuthorizationRequest authorize(final AuthorizationRequest authRequest) {
	   	    return authRequest;
	   }

	   @Override
	   public boolean getEnabled() {
	   	    return true;
	   }

	   @Override
	   public String getHomeDirectory() {
	   	    return "/tmp/FTP/" + login;
	   }

	   @Override
	   public int getMaxIdleTime() {
	   	    return 0;
	   }

	   @Override
	   public String getName() {
	   	    return this.login;
	   }
}
Authentication

    	
	   public class FTPUserManager implements UserManager {

	   	   @Override
	   	   public User authenticate(final Authentication inAuth) throws AuthenticationFailedException {
	   	   	 // inAuth is always an UsernamePasswordAuthentication
	   	   	 UsernamePasswordAuthentication upa = (UsernamePasswordAuthentication)inAuth;
	   	   	 String login = upa.getUsername();
	   	   	 String password = upa.getPassword();

	   	   	   // check user existence and credentials in database
	   	   	   if(!EOUser.authenticate(login, password))
	   	   	   	 throw new AuthenticationFailedException();

	   	   	   return new FTPUser(login);
	   	   }

	   	   @Override
	   	   public User getUserByName(final String login) throws FtpException {
	   	   	 return new FTPUser(login);
	   	   }
	   }
Authentication


    	
	   FtpServerFactory serverFactory = new FtpServerFactory();

	   // listen to a port > 1024
	   ListenerFactory listenerFactory = new ListenerFactory();
	   listenerFactory.setPort(1252);
	   Listener listener = listenerFactory.createListener();
	   serverFactory.addListener("default", listener);

	   // set the user manager
	   serverFactory.setUserManager(new FTPUserManager());

	   FtpServer server = serverFactory.createServer();
FTPLet
FTPLet

•   Give an opportunity to override the default behavior of a FTP
    Server

•   You can redefine all commands like ls, get, put, delete, mkdir…

•   Example: insert data automatically from an uploaded file
FTPLet example

	   public class MyFTPLet extends DefaultFtplet {

	   	    @Override
	   	    public FtpletResult onLogin(final FtpSession session, final FtpRequest request) throws FtpException, IOException {
	   	    	   File userRoot = new File(session.getUser().getHomeDirectory());
	   	    	   userRoot.mkdirs();

	   	    	    return super.onLogin(session, request);
	         }

	         @Override
	   	    public FtpletResult onMkdirStart(final FtpSession session, final FtpRequest request) throws FtpException, IOException {
	   	    	    session.write(new DefaultFtpReply(FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "You can't create directories on this server."));
	   	    	    return FtpletResult.SKIP;
	   	    }

	   	    @Override
	   	    public FtpletResult onUploadEnd(final FtpSession session, final FtpRequest request) throws FtpException, IOException {
	    	        String userRoot = session.getUser().getHomeDirectory();
	   	    	   String currDir = session.getFileSystemView().getWorkingDirectory().getAbsolutePath();
	   	    	   String fileName = request.getArgument();

	    	        File f = new File(userRoot + currDir + fileName);
	   	    	    // do something fun with this file
	   	    }
	   }
MONTREAL JUNE 30, JULY 1ST AND 2ND 2012




Q&A

Mais conteúdo relacionado

Mais procurados

Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with PythonLarry Cai
 
Python Google Cloud Function with CORS
Python Google Cloud Function with CORSPython Google Cloud Function with CORS
Python Google Cloud Function with CORSRapidValue
 
Infinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
Infinum Android Talks #16 - Retrofit 2 by Kristijan JurkovicInfinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
Infinum Android Talks #16 - Retrofit 2 by Kristijan JurkovicInfinum
 
CCI2019 - I've got the Power! I've got the Shell!
CCI2019 - I've got the Power! I've got the Shell!CCI2019 - I've got the Power! I've got the Shell!
CCI2019 - I've got the Power! I've got the Shell!walk2talk srl
 
Input and output flow using http and java component
Input and output flow using http and java componentInput and output flow using http and java component
Input and output flow using http and java componentSon Nguyen
 
Java 7 Features and Enhancements
Java 7 Features and EnhancementsJava 7 Features and Enhancements
Java 7 Features and EnhancementsGagan Agrawal
 
Sunil phani's take on windows powershell
Sunil phani's take on windows powershellSunil phani's take on windows powershell
Sunil phani's take on windows powershellSunil Phani
 
Write book in markdown
Write book in markdownWrite book in markdown
Write book in markdownLarry Cai
 
InfiniFlux collector
InfiniFlux collectorInfiniFlux collector
InfiniFlux collectorInfiniFlux
 
PyCon 2005 PyBlosxom
PyCon 2005 PyBlosxomPyCon 2005 PyBlosxom
PyCon 2005 PyBlosxomTed Leung
 
Groovy example in mule
Groovy example in muleGroovy example in mule
Groovy example in muleMohammed246
 
MuleSoft ESB scatter-gather and base64
MuleSoft ESB scatter-gather and base64MuleSoft ESB scatter-gather and base64
MuleSoft ESB scatter-gather and base64akashdprajapati
 

Mais procurados (19)

Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with Python
 
Authoring CPAN modules
Authoring CPAN modulesAuthoring CPAN modules
Authoring CPAN modules
 
Python Google Cloud Function with CORS
Python Google Cloud Function with CORSPython Google Cloud Function with CORS
Python Google Cloud Function with CORS
 
Infinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
Infinum Android Talks #16 - Retrofit 2 by Kristijan JurkovicInfinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
Infinum Android Talks #16 - Retrofit 2 by Kristijan Jurkovic
 
Powershell alias
Powershell aliasPowershell alias
Powershell alias
 
CCI2019 - I've got the Power! I've got the Shell!
CCI2019 - I've got the Power! I've got the Shell!CCI2019 - I've got the Power! I've got the Shell!
CCI2019 - I've got the Power! I've got the Shell!
 
Input and output flow using http and java component
Input and output flow using http and java componentInput and output flow using http and java component
Input and output flow using http and java component
 
Mule esb :Data Weave
Mule esb :Data WeaveMule esb :Data Weave
Mule esb :Data Weave
 
Java 7 Features and Enhancements
Java 7 Features and EnhancementsJava 7 Features and Enhancements
Java 7 Features and Enhancements
 
Sunil phani's take on windows powershell
Sunil phani's take on windows powershellSunil phani's take on windows powershell
Sunil phani's take on windows powershell
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
 
Python at Facebook
Python at FacebookPython at Facebook
Python at Facebook
 
Easy install
Easy installEasy install
Easy install
 
Write book in markdown
Write book in markdownWrite book in markdown
Write book in markdown
 
InfiniFlux collector
InfiniFlux collectorInfiniFlux collector
InfiniFlux collector
 
PyCon 2005 PyBlosxom
PyCon 2005 PyBlosxomPyCon 2005 PyBlosxom
PyCon 2005 PyBlosxom
 
Groovy example in mule
Groovy example in muleGroovy example in mule
Groovy example in mule
 
MuleSoft ESB scatter-gather and base64
MuleSoft ESB scatter-gather and base64MuleSoft ESB scatter-gather and base64
MuleSoft ESB scatter-gather and base64
 
Server Side? Swift
Server Side? SwiftServer Side? Swift
Server Side? Swift
 

Semelhante a Apache FTP Server Integration

What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5Darren Craig
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsMichael Peacock
 
file-transfer-using-tcp.pdf
file-transfer-using-tcp.pdffile-transfer-using-tcp.pdf
file-transfer-using-tcp.pdfJayaprasanna4
 
Monitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleMonitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleCarsten Ziegeler
 
Monitoring OSGi Applications with the Web Console - Carsten Ziegeler
Monitoring OSGi Applications with the Web Console - Carsten ZiegelerMonitoring OSGi Applications with the Web Console - Carsten Ziegeler
Monitoring OSGi Applications with the Web Console - Carsten Ziegelermfrancis
 
Monitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleMonitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleAdobe
 
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiGrâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiJérémy Derussé
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterHaehnchen
 
Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer ...
Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer ...Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer ...
Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer ...Yoshifumi Kawai
 
A Presentation about Puppet that I've made at the OSSPAC conference
A Presentation about Puppet that I've made at the OSSPAC conferenceA Presentation about Puppet that I've made at the OSSPAC conference
A Presentation about Puppet that I've made at the OSSPAC conferenceohadlevy
 
Performance #4 network
Performance #4  networkPerformance #4  network
Performance #4 networkVitali Pekelis
 
Everything you wanted to know about writing async, concurrent http apps in java
Everything you wanted to know about writing async, concurrent http apps in java Everything you wanted to know about writing async, concurrent http apps in java
Everything you wanted to know about writing async, concurrent http apps in java Baruch Sadogursky
 
WebTalk - Implementing Web Services with a dedicated Java daemon
WebTalk - Implementing Web Services with a dedicated Java daemonWebTalk - Implementing Web Services with a dedicated Java daemon
WebTalk - Implementing Web Services with a dedicated Java daemonGeert Van Pamel
 
Laravel for Web Artisans
Laravel for Web ArtisansLaravel for Web Artisans
Laravel for Web ArtisansRaf Kewl
 

Semelhante a Apache FTP Server Integration (20)

Wordcamp Plugins
Wordcamp PluginsWordcamp Plugins
Wordcamp Plugins
 
What's New In Laravel 5
What's New In Laravel 5What's New In Laravel 5
What's New In Laravel 5
 
Phpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friendsPhpne august-2012-symfony-components-friends
Phpne august-2012-symfony-components-friends
 
file-transfer-using-tcp.pdf
file-transfer-using-tcp.pdffile-transfer-using-tcp.pdf
file-transfer-using-tcp.pdf
 
Monitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleMonitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web Console
 
Monitoring OSGi Applications with the Web Console - Carsten Ziegeler
Monitoring OSGi Applications with the Web Console - Carsten ZiegelerMonitoring OSGi Applications with the Web Console - Carsten Ziegeler
Monitoring OSGi Applications with the Web Console - Carsten Ziegeler
 
Monitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web ConsoleMonitoring OSGi Applications with the Web Console
Monitoring OSGi Applications with the Web Console
 
Apache
ApacheApache
Apache
 
Apache
ApacheApache
Apache
 
Apache
ApacheApache
Apache
 
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiGrâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
 
Unit testing
Unit testingUnit testing
Unit testing
 
Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer ...
Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer ...Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer ...
Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer ...
 
Php
PhpPhp
Php
 
A Presentation about Puppet that I've made at the OSSPAC conference
A Presentation about Puppet that I've made at the OSSPAC conferenceA Presentation about Puppet that I've made at the OSSPAC conference
A Presentation about Puppet that I've made at the OSSPAC conference
 
Performance #4 network
Performance #4  networkPerformance #4  network
Performance #4 network
 
Everything you wanted to know about writing async, concurrent http apps in java
Everything you wanted to know about writing async, concurrent http apps in java Everything you wanted to know about writing async, concurrent http apps in java
Everything you wanted to know about writing async, concurrent http apps in java
 
WebTalk - Implementing Web Services with a dedicated Java daemon
WebTalk - Implementing Web Services with a dedicated Java daemonWebTalk - Implementing Web Services with a dedicated Java daemon
WebTalk - Implementing Web Services with a dedicated Java daemon
 
Laravel for Web Artisans
Laravel for Web ArtisansLaravel for Web Artisans
Laravel for Web Artisans
 

Mais de WO Community

In memory OLAP engine
In memory OLAP engineIn memory OLAP engine
In memory OLAP engineWO Community
 
Using Nagios to monitor your WO systems
Using Nagios to monitor your WO systemsUsing Nagios to monitor your WO systems
Using Nagios to monitor your WO systemsWO Community
 
Build and deployment
Build and deploymentBuild and deployment
Build and deploymentWO Community
 
Reenabling SOAP using ERJaxWS
Reenabling SOAP using ERJaxWSReenabling SOAP using ERJaxWS
Reenabling SOAP using ERJaxWSWO Community
 
Chaining the Beast - Testing Wonder Applications in the Real World
Chaining the Beast - Testing Wonder Applications in the Real WorldChaining the Beast - Testing Wonder Applications in the Real World
Chaining the Beast - Testing Wonder Applications in the Real WorldWO Community
 
D2W Stateful Controllers
D2W Stateful ControllersD2W Stateful Controllers
D2W Stateful ControllersWO Community
 
Deploying WO on Windows
Deploying WO on WindowsDeploying WO on Windows
Deploying WO on WindowsWO Community
 
Unit Testing with WOUnit
Unit Testing with WOUnitUnit Testing with WOUnit
Unit Testing with WOUnitWO Community
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO DevsWO Community
 
Advanced Apache Cayenne
Advanced Apache CayenneAdvanced Apache Cayenne
Advanced Apache CayenneWO Community
 
Migrating existing Projects to Wonder
Migrating existing Projects to WonderMigrating existing Projects to Wonder
Migrating existing Projects to WonderWO Community
 
iOS for ERREST - alternative version
iOS for ERREST - alternative versioniOS for ERREST - alternative version
iOS for ERREST - alternative versionWO Community
 
"Framework Principal" pattern
"Framework Principal" pattern"Framework Principal" pattern
"Framework Principal" patternWO Community
 
Filtering data with D2W
Filtering data with D2W Filtering data with D2W
Filtering data with D2W WO Community
 
Localizing your apps for multibyte languages
Localizing your apps for multibyte languagesLocalizing your apps for multibyte languages
Localizing your apps for multibyte languagesWO Community
 

Mais de WO Community (20)

KAAccessControl
KAAccessControlKAAccessControl
KAAccessControl
 
In memory OLAP engine
In memory OLAP engineIn memory OLAP engine
In memory OLAP engine
 
Using Nagios to monitor your WO systems
Using Nagios to monitor your WO systemsUsing Nagios to monitor your WO systems
Using Nagios to monitor your WO systems
 
Build and deployment
Build and deploymentBuild and deployment
Build and deployment
 
High availability
High availabilityHigh availability
High availability
 
Reenabling SOAP using ERJaxWS
Reenabling SOAP using ERJaxWSReenabling SOAP using ERJaxWS
Reenabling SOAP using ERJaxWS
 
Chaining the Beast - Testing Wonder Applications in the Real World
Chaining the Beast - Testing Wonder Applications in the Real WorldChaining the Beast - Testing Wonder Applications in the Real World
Chaining the Beast - Testing Wonder Applications in the Real World
 
D2W Stateful Controllers
D2W Stateful ControllersD2W Stateful Controllers
D2W Stateful Controllers
 
Deploying WO on Windows
Deploying WO on WindowsDeploying WO on Windows
Deploying WO on Windows
 
Unit Testing with WOUnit
Unit Testing with WOUnitUnit Testing with WOUnit
Unit Testing with WOUnit
 
Life outside WO
Life outside WOLife outside WO
Life outside WO
 
Apache Cayenne for WO Devs
Apache Cayenne for WO DevsApache Cayenne for WO Devs
Apache Cayenne for WO Devs
 
Advanced Apache Cayenne
Advanced Apache CayenneAdvanced Apache Cayenne
Advanced Apache Cayenne
 
Migrating existing Projects to Wonder
Migrating existing Projects to WonderMigrating existing Projects to Wonder
Migrating existing Projects to Wonder
 
iOS for ERREST - alternative version
iOS for ERREST - alternative versioniOS for ERREST - alternative version
iOS for ERREST - alternative version
 
iOS for ERREST
iOS for ERRESTiOS for ERREST
iOS for ERREST
 
"Framework Principal" pattern
"Framework Principal" pattern"Framework Principal" pattern
"Framework Principal" pattern
 
Filtering data with D2W
Filtering data with D2W Filtering data with D2W
Filtering data with D2W
 
WOver
WOverWOver
WOver
 
Localizing your apps for multibyte languages
Localizing your apps for multibyte languagesLocalizing your apps for multibyte languages
Localizing your apps for multibyte languages
 

Último

SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 

Último (20)

SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 

Apache FTP Server Integration

  • 1. MONTREAL JUNE 30, JULY 1ST AND 2ND 2012 Apache FTP Server integration Yoann Canal - twitter.com/y_canal Sophiacom
  • 2. Agenda • Apache FTP Server overview • First step: integration in your project • Authentication through WebObjects • FTPLet: what’s that? • Q&A
  • 3. Preamble • The Apache project is not well documented :-( • You get almost nothing when you google “Apache FTP Server WebObjects” • FTP Server has been designed with Spring in mind ➡ This session will not show you a reusable framework but the goal is to give you our feedback with some piece of code
  • 4. Apache FTP Server overview
  • 5. FTP Server Overview Except from project web page: The Apache FtpServer is a 100% pure Java FTP server. It's designed to be a complete and portable FTP server engine solution based on currently available open protocols. FtpServer can be run standalone as a Windows service or Unix/Linux daemon, or embedded into a Java application.We also provide support for integration within Spring applications and provide our releases as OSGi bundles. Documentation and download: http://mina.apache.org/ftpserver/
  • 6. FTP Server Overview • Current release is 1.06 (posted on Jul 16, 2011) • Url to download: http://mina.apache.org/ftpserver/apache-ftpserver-106- release.html • No dependancies with other libraries
  • 8. Project Setup • Add the following libraries: • ftplet-api-1.0.6.jar • ftpserver-core-1.0.6.jar • mina-core-2.0.4.jar • Initialize an Apache FtpServer object in your application or a Framework Principal object
  • 9. FTP Server Initialization FtpServerFactory serverFactory = new FtpServerFactory(); // listen to a port > 1024 // This port is used when connecting to the FTP Server // ex: ftp ftp://userName@localhost:1250 ListenerFactory listenerFactory = new ListenerFactory(); listenerFactory.setPort(1250); Listener listener = listenerFactory.createListener(); serverFactory.addListener("default", listener); FtpServer server = serverFactory.createServer(); try { server.start(); } catch (FtpException e) { e.printStackTrace(); }
  • 11. Authentication • You have 2 classes to create • One implements User •At least must return the name and the home directory • The other implements UserManager • check if the user is allowed to connect • create an authenticated User
  • 12. Authentication public class FTPUser implements User { private final String login; public FTPUser(final String login) { this.login = login; } @Override public AuthorizationRequest authorize(final AuthorizationRequest authRequest) { return authRequest; } @Override public boolean getEnabled() { return true; } @Override public String getHomeDirectory() { return "/tmp/FTP/" + login; } @Override public int getMaxIdleTime() { return 0; } @Override public String getName() { return this.login; } }
  • 13. Authentication public class FTPUserManager implements UserManager { @Override public User authenticate(final Authentication inAuth) throws AuthenticationFailedException { // inAuth is always an UsernamePasswordAuthentication UsernamePasswordAuthentication upa = (UsernamePasswordAuthentication)inAuth; String login = upa.getUsername(); String password = upa.getPassword(); // check user existence and credentials in database if(!EOUser.authenticate(login, password)) throw new AuthenticationFailedException(); return new FTPUser(login); } @Override public User getUserByName(final String login) throws FtpException { return new FTPUser(login); } }
  • 14. Authentication FtpServerFactory serverFactory = new FtpServerFactory(); // listen to a port > 1024 ListenerFactory listenerFactory = new ListenerFactory(); listenerFactory.setPort(1252); Listener listener = listenerFactory.createListener(); serverFactory.addListener("default", listener); // set the user manager serverFactory.setUserManager(new FTPUserManager()); FtpServer server = serverFactory.createServer();
  • 16. FTPLet • Give an opportunity to override the default behavior of a FTP Server • You can redefine all commands like ls, get, put, delete, mkdir… • Example: insert data automatically from an uploaded file
  • 17. FTPLet example public class MyFTPLet extends DefaultFtplet { @Override public FtpletResult onLogin(final FtpSession session, final FtpRequest request) throws FtpException, IOException { File userRoot = new File(session.getUser().getHomeDirectory()); userRoot.mkdirs(); return super.onLogin(session, request); } @Override public FtpletResult onMkdirStart(final FtpSession session, final FtpRequest request) throws FtpException, IOException { session.write(new DefaultFtpReply(FtpReply.REPLY_550_REQUESTED_ACTION_NOT_TAKEN, "You can't create directories on this server.")); return FtpletResult.SKIP; } @Override public FtpletResult onUploadEnd(final FtpSession session, final FtpRequest request) throws FtpException, IOException { String userRoot = session.getUser().getHomeDirectory(); String currDir = session.getFileSystemView().getWorkingDirectory().getAbsolutePath(); String fileName = request.getArgument(); File f = new File(userRoot + currDir + fileName); // do something fun with this file } }
  • 18. MONTREAL JUNE 30, JULY 1ST AND 2ND 2012 Q&A