AuthenticationKeyDatabase database = new AuthenticationKeyDatabase();
List keys = PlexusJdoUtils.getAllObjectsDetached( getPersistenceManager(), JdoAuthenticationKey.class );
database.setKeys( keys );
PlexusSecurityKeyManagementJdoStaxWriter writer = new PlexusSecurityKeyManagementJdoStaxWriter();
FileWriter fileWriter = new FileWriter( new File( backupDirectory, KEYS_XML_NAME ) );
try
{
writer.write( fileWriter, database );
}
finally
{
IOUtil.close( fileWriter );
}