 
| Line | Hits | Source | 
|---|---|---|
| 1 | /******************************************************************************* | |
| 2 | *InternetCafe is a software solution that helps the management of Cybercafes | |
| 3 | * according with the ITALIAN DECREE LAW ON ANTI-TERROR MEASURES, 27 JULY 2005. | |
| 4 | * Copyright (C) 2006 Guido Angelo Ingenito | |
| 5 | ||
| 6 | * This program is free software; you can redistribute it and/or | |
| 7 | * modify it under the terms of the GNU General Public License | |
| 8 | * as published by the Free Software Foundation; either version 2 | |
| 9 | * of the License, or (at your option) any later version. | |
| 10 | ||
| 11 | * This program is distributed in the hope that it will be useful, | |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 14 | * GNU General Public License for more details. | |
| 15 | * | |
| 16 | * You should have received a copy of the GNU General Public License | |
| 17 | * along with this program; if not, write to the Free Software | |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
| 19 | *******************************************************************************/ | |
| 20 | ||
| 21 | package base.jdbs.ui.command; | |
| 22 | ||
| 23 | import java.security.KeyStore; | |
| 24 | import java.util.Enumeration; | |
| 25 | ||
| 26 | import org.apache.log4j.Logger; | |
| 27 | ||
| 28 | import ui.command.Command; | |
| 29 | import base.InternetCafe; | |
| 30 | import base.jdbs.Backup; | |
| 31 | import base.jdbs.BackupArtifactAssembler; | |
| 32 | import base.jdbs.ConfigurationManager; | |
| 33 | import base.jdbs.cryptography.asymmetric.AsymmetricKeyRing; | |
| 34 | import base.jdbs.cryptography.symmetric.SymmetricKey; | |
| 35 | ||
| 36 | /** | |
| 37 | * @author skunk | |
| 38 | * | |
| 39 | */ | |
| 40 | 0 | public class BuildBackupArtifactCommand extends Command { | 
| 41 | ||
| 42 | 0 | private static final transient Logger logger = Logger.getLogger(BuildBackupArtifactCommand.class.getName()); | 
| 43 | ||
| 44 | private final Backup backup; | |
| 45 | ||
| 46 | 0 | public BuildBackupArtifactCommand(Backup backup){ | 
| 47 | 0 | this.backup = backup; | 
| 48 | 0 | } | 
| 49 | ||
| 50 | /* | |
| 51 | * (non-Javadoc) | |
| 52 | * | |
| 53 | * @see ui.command.Command#prologo() | |
| 54 | */ | |
| 55 | @Override | |
| 56 | protected void prologo() { | |
| 57 | 0 | InternetCafe.setStatusBarMessage("Building a new backup..."); | 
| 58 | 0 | setStatus(EXECUTE_STATUS); | 
| 59 | 0 | } | 
| 60 | ||
| 61 | /* | |
| 62 | * (non-Javadoc) | |
| 63 | * | |
| 64 | * @see ui.command.Command#execution() | |
| 65 | */ | |
| 66 | @Override | |
| 67 | protected void execution() throws Exception { | |
| 68 | 0 | switch (getStatus()) { | 
| 69 | case ABORT_STATUS: | |
| 70 | 0 | break; | 
| 71 | case VETOED_STATUS: | |
| 72 | 0 | break; | 
| 73 | case EXECUTE_STATUS: | |
| 74 | try{ | |
| 75 | 0 | AsymmetricKeyRing asymmetricKeyRing = new AsymmetricKeyRing(ConfigurationManager.getInstance().getUser()); | 
| 76 | ||
| 77 | 0 | KeyStore keyStore = asymmetricKeyRing.retrieve(ConfigurationManager.getInstance().getKeyRingLocation(),"password"); | 
| 78 | 0 | Enumeration aliasEnumeration = keyStore.aliases(); | 
| 79 | 0 | while(aliasEnumeration.hasMoreElements()){ | 
| 80 | 0 | System.out.println(aliasEnumeration.nextElement()); | 
| 81 | 0 | } | 
| 82 | 0 | long start = System.currentTimeMillis(); | 
| 83 | 0 | BackupArtifactAssembler.buildNewBackupArtifact(ConfigurationManager.getInstance().getRepository().getLocation(),new SymmetricKey("password"),asymmetricKeyRing.getAllKeyPair()[0],backup); | 
| 84 | 0 | long end = System.currentTimeMillis(); | 
| 85 | 0 | logger.debug("The backup artifact assemblation has taken: "+(end - start)+" ms"); | 
| 86 | 0 | ConfigurationManager.getInstance().getRepository().indexRepository(); | 
| 87 | 0 | }catch(Exception ex){ | 
| 88 | 0 | ex.printStackTrace(); | 
| 89 | 0 | } | 
| 90 | ||
| 91 | 0 | setStatus(SUCCESS_STATUS); | 
| 92 | break; | |
| 93 | } | |
| 94 | 0 | } | 
| 95 | ||
| 96 | /* | |
| 97 | * (non-Javadoc) | |
| 98 | * | |
| 99 | * @see ui.command.Command#epilogue() | |
| 100 | */ | |
| 101 | @Override | |
| 102 | protected void epilogue() { | |
| 103 | 0 | switch (getStatus()) { | 
| 104 | case SUCCESS_STATUS: | |
| 105 | 0 | InternetCafe.setStatusBarMessage("Backup successfully created..."); | 
| 106 | 0 | break; | 
| 107 | case ABORT_STATUS: | |
| 108 | 0 | InternetCafe.setStatusBarMessage("Command aborted by user..."); | 
| 109 | 0 | break; | 
| 110 | case ERROR_STATUS: | |
| 111 | 0 | InternetCafe.setStatusBarMessage("Command error..."); | 
| 112 | 0 | break; | 
| 113 | case VETOED_STATUS: | |
| 114 | 0 | InternetCafe.setStatusBarMessage("Command vetoed..."); | 
| 115 | break; | |
| 116 | } | |
| 117 | 0 | } | 
| 118 | ||
| 119 | } | |
| 120 | 
| 
this report was generated by version 1.0.5 of jcoverage. | 
copyright © 2003, jcoverage ltd. all rights reserved. |