Skip to content

Commit

Permalink
allowing to start server without password if sftp only and pub key au…
Browse files Browse the repository at this point in the history
…th is enabled, see GH issue #38
  • Loading branch information
wolpi committed Dec 17, 2015
1 parent a364dff commit 5b760ca
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
11 changes: 10 additions & 1 deletion primitiveFTPd/src/org/primftpd/PrimitiveFtpdActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ protected void handleStart() {
handleStart(null, null);
}
protected void handleStart(MenuItem startIcon, MenuItem stopIcon) {
if (StringUtils.isBlank(prefsBean.getPassword()))
if (!isPasswordOk())
{
Toast.makeText(
getApplicationContext(),
Expand Down Expand Up @@ -691,6 +691,15 @@ protected void handlePrefs() {
startActivity(intent);
}

protected boolean isPasswordOk() {
if (!prefsBean.getServerToStart().isPasswordMandatory()
&& prefsBean.isPubKeyAuth())
{
return true;
}
return !StringUtils.isBlank(prefsBean.getPassword());
}

/**
* @return Intent to start/stop {@link FtpServerService}.
*/
Expand Down
7 changes: 7 additions & 0 deletions primitiveFTPd/src/org/primftpd/prefs/ServerToStart.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public boolean startFtp() {
public boolean startSftp() {
return true;
}
@Override
public boolean isPasswordMandatory() {
return false;
}
},
ALL("0") {
@Override
Expand Down Expand Up @@ -60,4 +64,7 @@ public static ServerToStart byXmlVal(String xmlVal) {

public abstract boolean startFtp();
public abstract boolean startSftp();
public boolean isPasswordMandatory() {
return true;
}
}

0 comments on commit 5b760ca

Please sign in to comment.