* @throws IOException
* @throws InvalidSshKeyException
*/
public byte[] format(AuthorizedKeys keys, AuthorizedKeysFileSaver saver)
throws IOException, InvalidSshKeyException {
Authorization authorization = new Authorization();
SshPublicKeyFile pubfile;
SECSHPublicKeyFormat secsh = new SECSHPublicKeyFormat();
Map.Entry entry;
for (Iterator it = keys.getAuthorizedKeys().entrySet().iterator();
(it != null) && it.hasNext();) {
entry = (Map.Entry) it.next();
// Write out the public key file
String username = (String) entry.getValue();
String filename = username + ".pub";
secsh.setComment(username);
pubfile = SshPublicKeyFile.create((SshPublicKey) entry.getKey(),
secsh);
saver.saveFile(filename, pubfile.toString().getBytes("US-ASCII"));
// Write out the key entry
authorization.addKey(filename);
}
return authorization.toString().getBytes("US-ASCII");
}