1 13 package org.ejbca.ui.cli.batch; 14 15 import java.io.File ; 16 import java.io.FileInputStream ; 17 import java.io.FileNotFoundException ; 18 import java.io.IOException ; 19 import java.util.Properties ; 20 21 import org.apache.log4j.Logger; 22 23 30 public class BatchToolProperties { 31 32 private static final String PROPERTY_KEYSPEC = "keys.spec"; 33 private static final String PROPERTY_KEYALG = "keys.alg"; 34 35 36 Properties batchToolProperties = new Properties (); 37 private static final Logger log = Logger.getLogger(BatchToolProperties.class); 38 39 BatchToolProperties(){ 40 load(); 41 } 42 43 47 public String getKeySpec(){ 48 return batchToolProperties.getProperty(PROPERTY_KEYSPEC,"1024"); 49 } 50 51 55 public String getKeyAlg(){ 56 return batchToolProperties.getProperty(PROPERTY_KEYALG,"RSA"); 57 } 58 59 60 61 62 68 private void load(){ 69 File file = new File ( System.getProperty("user.home"), 70 "batchtool.properties"); 71 try { 72 try{ 73 FileInputStream fis = new FileInputStream (file); 74 batchToolProperties.load(fis); 75 } catch (FileNotFoundException e) { 76 try{ 77 FileInputStream fis = new FileInputStream ("batchtool.properties"); 78 batchToolProperties.load(fis); 79 }catch (FileNotFoundException e1) { 80 try{ 81 FileInputStream fis = new FileInputStream ("bin/batchtool.properties"); 82 batchToolProperties.load(fis); 83 }catch (FileNotFoundException e2) { 84 log.info("Could not find any batchtool property file, default values will be used."); 85 log.debug(e); 86 } 87 } 88 } 89 } catch (IOException e) { 90 log.error("Error reading batchtool property file "); 91 log.debug(e); 92 } 93 } 94 95 96 97 } 98 | Popular Tags |