mirror of http://galexander.org/git/simplesshd.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.1 KiB
59 lines
1.1 KiB
package org.galexander.sshd;
|
|
|
|
import android.app.Activity;
|
|
import android.os.AsyncTask;
|
|
import android.widget.Toast;
|
|
import java.io.File;
|
|
import java.io.FileInputStream;
|
|
|
|
|
|
public class AuthKeysLoad extends AsyncTask<Void,Void,Void> {
|
|
private AuthKeys act = null;
|
|
private String result = null;
|
|
private String error = null;
|
|
|
|
public static void go(AuthKeys act_) {
|
|
(new AuthKeysLoad(act_)).execute();
|
|
}
|
|
|
|
AuthKeysLoad(AuthKeys act_) {
|
|
super();
|
|
act = act_;
|
|
}
|
|
|
|
protected Void doInBackground(Void... v) {
|
|
try {
|
|
File f = new File(Prefs.get_path(), "authorized_keys");
|
|
FileInputStream fis = new FileInputStream(f);
|
|
|
|
byte b[] = new byte[1024];
|
|
|
|
result = "";
|
|
try {
|
|
while (true) {
|
|
int r = fis.read(b);
|
|
if (r <= 0) {
|
|
break;
|
|
}
|
|
result += new String(b, 0, r);
|
|
}
|
|
} finally {
|
|
fis.close();
|
|
}
|
|
} catch (Exception e) {
|
|
error = e.getMessage();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
protected void onPostExecute(Void v) {
|
|
if (result != null) {
|
|
act.set_authtext(result);
|
|
} else if (error != null) {
|
|
Toast.makeText(act,
|
|
"failed to load authorized_keys: " + error,
|
|
Toast.LENGTH_LONG).show();
|
|
}
|
|
}
|
|
}
|