apache的简单校验分为两种,一直是前面提到的properties的校验,具体参考:apache ftp server的简单入门(properties验证)

今天来说一种数据库的校验,这种方式在项目中更加常用:

具体步骤如下:

  第一步:下载解压(我在window上演示,linux上就启动命令由bat的命令换成sh命令即可,不会的自己百度,网上有很多资料)

  

  第二步:进入%ftp-server%/res中修改一下数据库文件,并在数据库中创建对于的表    ftpd-db.sql

  

  到这儿还没结束:

  我是mysql演示,就在mysql中说: 在mysql中创建一个数据库,暂定为ftpserver   并在库中创建上面那个权限认证表(我认为的),成功如下:

  

  往表中添加允许登录ftp的用户,

  

INSERT INTO `ftpserver`.`ftp_user` (`userid`, `userpassword`, `homedirectory`, `enableflag`, `writepermission`, `idletime`, `uploadrate`, `downloadrate`, `maxloginnumber`, `maxloginperip`) VALUES ('admin', 'admin', 'D:/', '', '', '', '', '', '', '');
INSERT INTO `ftpserver`.`ftp_user` (`userid`, `userpassword`, `homedirectory`, `enableflag`, `writepermission`, `idletime`, `uploadrate`, `downloadrate`, `maxloginnumber`, `maxloginperip`) VALUES ('huhy', '', './res/home', '', '', '', '', '', '', '');

  第三步,配置数据库文件,ftpd-mysql.xml   -----------这是从ftpd-typical.xml  cp  过来的,,为了不破坏原来的文件结构,即出错,只需要删除我自己创建的一个文件即可

  

  ftpd-mysql.xml的文本信息 (把数据库连接信息改了就可以直接用) 

<?xml version="1.0" encoding="UTF-8"?>
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for additional
information regarding copyright ownership. The ASF licenses this file to
you under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of
the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
by applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, either express or implied. See the License for the specific
language governing permissions and limitations under the License. -->
<server xmlns="http://mina.apache.org/ftpserver/spring/v1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://mina.apache.org/ftpserver/spring/v1
http://mina.apache.org/ftpserver/ftpserver-1.0.xsd
"
id="myServer">
<listeners>
<nio-listener name="default" port="">
<ssl>
<keystore file="./res/ftpserver.jks" password="password" />
</ssl>
</nio-listener>
</listeners>
<!-- 将文件方式注释掉 -->
<!-- <file-user-manager file="./res/conf/users.properties" /> -->
<db-user-manager encrypt-passwords="clear">
<!-- 数据源信息,ftpserver为MySQL数据库名称,root/,为用户名以及密码 -->
<data-source>
<beans:bean class="org.apache.commons.dbcp.BasicDataSource">
<beans:property name="driverClassName" value="com.mysql.jdbc.Driver" />
<beans:property name="url" value="jdbc:mysql://localhost/ftpserver" />
<beans:property name="username" value="root" />
<beans:property name="password" value="" />
</beans:bean>
</data-source>
<insert-user>INSERT INTO FTP_USER (userid, userpassword,
homedirectory, enableflag, writepermission, idletime, uploadrate,
downloadrate) VALUES ('{userid}', '{userpassword}',
'{homedirectory}',
{enableflag}, {writepermission}, {idletime},
{uploadrate},
{downloadrate})
</insert-user>
<update-user>UPDATE FTP_USER SET
userpassword='{userpassword}',homedirectory='{homedirectory}',enableflag={enableflag},writepermission={writepermission},idletime={idletime},uploadrate={uploadrate},downloadrate={downloadrate}
WHERE userid='{userid}'
</update-user>
<delete-user>DELETE FROM FTP_USER WHERE userid = '{userid}'
</delete-user>
<select-user>SELECT userid, userpassword, homedirectory,
enableflag, writepermission, idletime, uploadrate, downloadrate,
maxloginnumber, maxloginperip FROM
FTP_USER WHERE userid = '{userid}'
</select-user>
<select-all-users>
SELECT userid FROM FTP_USER ORDER BY userid
</select-all-users>
<is-admin>SELECT userid FROM FTP_USER WHERE userid='{userid}'
AND
userid='admin'
</is-admin>
<authenticate>SELECT userpassword from FTP_USER WHERE
userid='{userid}'
</authenticate>
</db-user-manager>
</server>

第四步: 获取指定jar包放到common/lib下

  主要需要   common-jdbc    common-pools      mysql的连接jar包

  

  第五步:

    进入bin下,启动ftp服务:

    service  install

    ftpd.bat  res/conf/ftpd-mysql..xml

    

  第六步,验证:

    

    注意,这里的用户名密码是指的你数据库表中的用户名和密码,验证成功打开的是你数据库表中homedirectory字段对应 的家目录

  成功对比分析:

  

apache ftp server的简单入门(数据库验证)的更多相关文章

  1. apache ftp server的简单入门(properties验证)

    Apache FTPServer:(开源) Apache FTPServer是一个100%纯Java的FTP服务器. 它的设计是基于现有的开放式协议的完整和便携式FTP服务器引擎解决方案.FTPSer ...

  2. apache ftp server的简单入门(java应用内嵌ftp server)

    Apache Ftp Server:(强调) Apache Ftp Server 是100%纯Java的FTP服务器软件,它采用MINA网络框架开发具有非常好的性能.Apache FtpServer ...

  3. apache ftp server的外网访问问题

    apache ftp server的外网访问简单配置点如下:

  4. apache ftp server 设置

    <server xmlns="http://mina.apache.org/ftpserver/spring/v1" xmlns:xsi="http://www.w ...

  5. 数据库技术丛书:SQL Server 2016 从入门到实战(视频教学版) PDF

    1:书籍下载方式: SQL Server2016从入门到实战 PDF 下载  链接:https://pan.baidu.com/s/1sWZjdud4RosPyg8sUBaqsQ 密码:8z7w 学习 ...

  6. 网络编程4 网络编程之FTP上传简单示例&socketserver介绍&验证合法性连接

    今日大纲: 1.FTP上传简单示例(详细代码) 2.socketserver简单示例&源码介绍 3.验证合法性连接//[秘钥加密(urandom,sendall)(注意:中文的!不能用)] 内 ...

  7. 一篇文章带你了解NoSql数据库——Redis简单入门

    一篇文章带你了解NoSql数据库--Redis简单入门 Redis是一个基于内存的key-value结构数据库 我们会利用其内存存储速度快,读写性能高的特点去完成企业中的一些热门数据的储存信息 在本篇 ...

  8. 用http.get()简单实现网络验证防止客户不给尾款_电脑计算机编程入门教程自学

    首发于:用http.get()简单实现网络验证防止客户不给尾款_电脑计算机编程入门教程自学 http://jianma123.com/viewthread.aardio?threadid=428 给软 ...

  9. Identity Server 4 从入门到落地(六)—— 简单的单页面客户端

    前面的部分: Identity Server 4 从入门到落地(一)-- 从IdentityServer4.Admin开始 Identity Server 4 从入门到落地(二)-- 理解授权码模式 ...

随机推荐

  1. Failed to create prime the NuGet cache

    在centos 7上使用dotnet core时: dotnet core 安装环境在root下完成,并成功运行“hello world”程序.切换到其他账户使用dotnet命令时,报“Failed ...

  2. C++的开源跨平台日志库glog学习研究(三)--杂项

    在前面对glog分别做了两次学习,请看C++的开源跨平台日志库glog学习研究(一).C++的开源跨平台日志库glog学习研究(二)--宏的使用,这篇再做个扫尾工作,算是基本完成了. 编译期断言 动态 ...

  3. Pelican+Github博客搭建详细教程

    操作系统:Mac OS / Linux 工具集: 1.Pelican--基于Python的静态网页生成器 2.马克飞象--Evernote出的Markdown文本编辑器 3.GoDaddy--域名供应 ...

  4. alloca() 是什么?为什么不提倡使用它?

    在调用 alloca() 的函数返回的时候, 它分配的内存会自动释放.也就是说, 用 alloca 分配的内存在某种程度上局部于函数的 ``堆栈帧"  或上下文中. alloca() 不具可 ...

  5. HDU 1863 畅通工程(Prim算法求解MST)

    题目: 省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可).经过调查评估,得到的统计表中列出了有可能建设公路的若干条道路的成本.现 ...

  6. CocoaPods管理第三方

    之前听伟哥说用CocoaPods做第三方库的管理很方便,今天看了下自己做了下感觉确实不错.下面开始,Let's go!! 1.安装CocoaPods之前,先确保本地有Ruby环境,因为CocoaPod ...

  7. asp查找</td>标记时遇到以外的文件结尾

    正确的<td></td> 错误的<td> 没有写完整

  8. Flume - 快速入门

    关于Flume,官方定义如下: Apache Flume is a distributed, reliable, and available system for efficiently collec ...

  9. ModelState.IsValid always returning true while mocking a request

    ASB.net  MVC 视图验证里有一个IValidatableObject接口.这里面有一个验证方法.通常我们表单提交的时候dto就是用一个实现IValidatableObject这个接口的实体. ...

  10. Jprofiler注册码

    L-Larry_Lau@163.com#23874-hrwpdp1sh1wrn#0620 L-Larry_Lau@163.com#36573-fdkscp15axjj6#25257 L-Larry_L ...