Upstream version 8.36.169.0
[platform/framework/web/crosswalk.git] / src / third_party / pyftpdlib / src / demo / tls_ftpd.py
1 #!/usr/bin/env python
2 # $Id$
3
4 #  pyftpdlib is released under the MIT license, reproduced below:
5 #  ======================================================================
6 #  Copyright (C) 2007-2012 Giampaolo Rodola' <g.rodola@gmail.com>
7 #
8 #                         All Rights Reserved
9 #
10 # Permission is hereby granted, free of charge, to any person
11 # obtaining a copy of this software and associated documentation
12 # files (the "Software"), to deal in the Software without
13 # restriction, including without limitation the rights to use,
14 # copy, modify, merge, publish, distribute, sublicense, and/or sell
15 # copies of the Software, and to permit persons to whom the
16 # Software is furnished to do so, subject to the following
17 # conditions:
18 #
19 # The above copyright notice and this permission notice shall be
20 # included in all copies or substantial portions of the Software.
21 #
22 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
24 # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
27 # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
29 # OTHER DEALINGS IN THE SOFTWARE.
30 #
31 #  ======================================================================
32
33 """An RFC-4217 asynchronous FTPS server supporting both SSL and TLS.
34
35 Requires PyOpenSSL module (http://pypi.python.org/pypi/pyOpenSSL).
36 """
37
38 import os
39
40 from pyftpdlib import ftpserver
41 from pyftpdlib.contrib.handlers import TLS_FTPHandler
42
43 CERTFILE = os.path.abspath(os.path.join(os.path.dirname(__file__),
44                                         "keycert.pem"))
45
46 def main():
47     authorizer = ftpserver.DummyAuthorizer()
48     authorizer.add_user('user', '12345', '.', perm='elradfmw')
49     authorizer.add_anonymous('.')
50     ftp_handler = TLS_FTPHandler
51     ftp_handler.certfile = CERTFILE
52     ftp_handler.authorizer = authorizer
53     # requires SSL for both control and data channel
54     #ftp_handler.tls_control_required = True
55     #ftp_handler.tls_data_required = True
56     ftpd = ftpserver.FTPServer(('', 8021), ftp_handler)
57     ftpd.serve_forever()
58
59 if __name__ == '__main__':
60     main()