throws IOException, InvalidSshKeyException {
AuthorizedKeys keys = new AuthorizedKeys();
BufferedReader reader = new BufferedReader(new InputStreamReader(
new ByteArrayInputStream(formatted)));
String line;
SshPublicKeyFile pubfile;
String filename;
String username;
while ((line = reader.readLine()) != null) {
if (line.trim().startsWith("key")) {
// Get the filename and load
filename = line.substring(line.trim().lastIndexOf(" ") + 1)
.trim();
pubfile = SshPublicKeyFile.parse(loader.loadFile(filename));
// Get the username from the filename - .pub
username = filename.substring(0, filename.length() - 4);
keys.addKey(username, pubfile.toPublicKey());
}
}
return keys;
}