Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2010 Västra Götalandsregionen This library is free software; you can redistribute it and/or modify it under the terms of version 2.1 of the GNU Lesser General Public License as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 package se.vgregion.portal.cs.migration;
This is the starting point of a standalone application used for migration of cipher texts from one cipher to another or from one key to another.

Patrik Bergström
 public class PasswordEncryptionMigrator {
     private static final Logger LOGGER = Logger.getLogger(PasswordEncryptionMigrator.class.getName());
     private MigrationService migrationService;

Main method which performs a given migration of cipher texts.

args Takes exactly one argument which should equal "ecb2ctr", "ctr2ecb", "updatekey" or "undoupdatekey".
     public static void main(String[] args) {
         if (args.length != 1 || !(args[0].equalsIgnoreCase("ecb2ctr") || args[0].equalsIgnoreCase("ctr2ecb")
                 || args[0].equalsIgnoreCase("updatekey") || args[0].equalsIgnoreCase("undoupdatekey"))) {
             ..println("Add \"ecb2ctr\", \"ctr2ecb\", \"updateKey\" or \"undoUpdateKey\" as input "
                     + "parameter");
         String cmd = args[0];
         PasswordEncryptionMigrator migrator = setupApplicationContext();
         //Do it
         if (cmd.equalsIgnoreCase("ecb2ctr")) {
         } else if (cmd.equalsIgnoreCase("ctr2ecb")) {
         } else if (cmd.equalsIgnoreCase("updatekey")) {
             File newKeyFile = migrator.migrateAndUpdateKey();
             ..println("New key file: " + newKeyFile.getAbsolutePath());
         } else if (cmd.equalsIgnoreCase("undoupdatekey")) {
         } else {
             throw new IllegalArgumentException("wrong arguments");
     private static PasswordEncryptionMigrator setupApplicationContext() {
         ApplicationContext ctx = new ClassPathXmlApplicationContext(
         MigrationService service = ctx.getBean(MigrationService.class);
         PasswordEncryptionMigrator migrator = new PasswordEncryptionMigrator();
         return migrator;
     private void undoMigrateAndUpdateKey() {
     private File migrateAndUpdateKey() {
         return .migrateAndUpdateKey();
     private void migrateEcbToCtr() {
     private void migrateCtr2Ecb() {
    public void setMigrationService(MigrationService credentialService) {
        this. = credentialService;
New to GrepCode? Check out our FAQ X