Android FTP server authenticates once -
i trying implement ftp server in application using apache ftp server library
.
the server , running , working fine, once.
note: using hardcoded user now. username: test
, password: test
so in order:
app launched, server started, lets ftp clients login.
app killed user.
app started user , server started. replies
530 authentication failed
user logging inusername: test
,password: test
after responds 530 authentication failed
my code below making server:
public void makepropertiesfile(){ file file = new file(environment.getexternalstoragedirectory().getabsolutepath()+"/download/user.properties"); if(file.exists() == false){ try { file.createnewfile(); logmessage("user.properties file did not exist, made one"); properties = file; this.addusers(); } catch (ioexception e) { e.printstacktrace(); } } else { logmessage("file exists, no need recreate"); usermanagerfactory = new propertiesusermanagerfactory(); usermanagerfactory.setfile(properties); usermanagerfactory.setpasswordencryptor(new saltedpasswordencryptor()); org.apache.ftpserver.ftplet.usermanager usermanager = usermanagerfactory.createusermanager(); serverfactory.setusermanager(usermanager); } } public void addusers(){ usermanagerfactory = new propertiesusermanagerfactory(); usermanagerfactory.setfile(properties); usermanagerfactory.setpasswordencryptor(new saltedpasswordencryptor()); baseuser = new baseuser(); baseuser.setname("test"); baseuser.setpassword("test"); baseuser.sethomedirectory(environment.getexternalstoragedirectory().getabsolutepath()); baseuser.setenabled(true); list<authority> authorities = new arraylist<authority>(); authorities.add(new writepermission()); baseuser.setauthorities(authorities); org.apache.ftpserver.ftplet.usermanager usermanager = usermanagerfactory.createusermanager(); try { usermanager.save(baseuser); } catch (ftpexception e) { e.printstacktrace(); logmessage("could not save user"); } serverfactory.setusermanager(usermanager); } public void start(){ serverfactory = new ftpserverfactory(); listenerfactory = new listenerfactory(); listenerfactory.setport(port); serverfactory.addlistener("default",listenerfactory.createlistener()); ftpserver = serverfactory.createserver(); this.makepropertiesfile(); try { ftpserver.start(); logmessage("started ftp server on port: " + port); } catch (ftpexception e) { e.printstacktrace(); logmessage("failed start ftp server on port: " + port); } }
has working project ftp android app
Comments
Post a Comment