public byte[] format(AuthorizedKeys keys, AuthorizedKeysFileSaver saver)
throws IOException, InvalidSshKeyException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
out.write(header.getBytes("US-ASCII"));
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
out.write(key.getBytes("US-ASCII"));
out.write(filename.getBytes("US-ASCII"));
out.write('\n');