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.
37 lines
790 B
37 lines
790 B
package org.galexander.sshd;
|
|
|
|
import android.app.IntentService;
|
|
import android.content.Intent;
|
|
import java.io.File;
|
|
import java.io.FileOutputStream;
|
|
|
|
public class AuthKeysSave extends IntentService {
|
|
public AuthKeysSave() {
|
|
super("SimpleSSHDAuthKeysSave");
|
|
}
|
|
protected void onHandleIntent(Intent i) {
|
|
String s = i.getStringExtra("s", null);
|
|
if (s == null) {
|
|
return;
|
|
}
|
|
try {
|
|
File p = new File(Prefs.get_path());
|
|
if (!p.exists()) {
|
|
p.mkdirs();
|
|
}
|
|
File f = new File(p, "authorized_keys");
|
|
FileOutputStream fos = new FileOutputStream(f);
|
|
int ofs = 0;
|
|
|
|
try {
|
|
fos.write(s.getBytes());
|
|
} finally {
|
|
fos.close();
|
|
}
|
|
} catch (Exception e) {
|
|
SimpleSSHD.toast(
|
|
"authorized_keys save failed: "+e.getMessage());
|
|
}
|
|
}
|
|
}
|