1 13 14 package org.ejbca.core.model.hardtoken.profiles; 15 16 17 import java.awt.print.Printable ; 18 import java.awt.print.PrinterException ; 19 import java.io.IOException ; 20 import java.io.StringReader ; 21 22 import org.ejbca.core.model.ra.UserDataVO; 23 24 25 26 27 28 34 public abstract class HardTokenProfileWithPINEnvelope extends HardTokenProfile implements IPINEnvelopeSettings{ 35 36 37 protected static final String PINENVELOPETYPE = "pinenvelopetype"; 39 protected static final String PINENVELOPEFILENAME = "pinenvelopefilename"; 40 protected static final String PINENVELOPEDATA = "pinenvelopetdata"; 41 protected static final String PINENVELOPECOPIES = "pinenvelopetcopies"; 42 protected static final String VISUALVALIDITY = "visualvalidity"; 43 44 private SVGImageManipulator envelopesvgimagemanipulator = null; 45 46 public HardTokenProfileWithPINEnvelope() { 48 super(); 49 50 setPINEnvelopeType(IPINEnvelopeSettings.PINENVELOPETYPE_GENERALENVELOBE); 51 setPINEnvelopeTemplateFilename(""); 52 setNumberOfPINEnvelopeCopies(1); 53 setVisualValidity(356); 54 55 } 56 57 59 60 public void upgrade(){ 61 super.upgrade(); 63 } 64 65 66 67 70 public int getPINEnvelopeType() { 71 return ((Integer ) data.get(PINENVELOPETYPE)).intValue(); 72 } 73 74 77 public void setPINEnvelopeType(int type) { 78 data.put(PINENVELOPETYPE, new Integer (type)); 79 } 80 81 84 public String getPINEnvelopeTemplateFilename() { 85 return (String ) data.get(PINENVELOPEFILENAME); 86 } 87 88 91 public void setPINEnvelopeTemplateFilename(String filename) { 92 data.put(PINENVELOPEFILENAME, filename); 93 } 94 95 98 public String getPINEnvelopeData() { 99 return (String ) data.get(PINENVELOPEDATA); 100 } 101 102 105 public void setPINEnvelopeData(String templatedata) { 106 data.put(PINENVELOPEDATA, templatedata); 107 } 108 109 112 public int getNumberOfPINEnvelopeCopies() { 113 return ((Integer ) data.get(PINENVELOPECOPIES)).intValue(); 114 } 115 116 119 public void setNumberOfPINEnvelopeCopies(int copies) { 120 data.put(PINENVELOPECOPIES, new Integer (copies)); 121 } 122 123 126 public int getVisualValidity(){ 127 return ((Integer ) data.get(VISUALVALIDITY)).intValue(); 128 } 129 130 133 public void setVisualValidity(int validity){ 134 data.put(VISUALVALIDITY, new Integer (validity)); 135 } 136 137 138 141 public Printable printPINEnvelope(UserDataVO userdata, String [] pincodes, String [] pukcodes, String hardtokensn, String copyoftokensn) throws IOException , PrinterException { 142 Printable returnval = null; 143 144 if(getPINEnvelopeData() != null){ 145 if(envelopesvgimagemanipulator == null) 146 envelopesvgimagemanipulator = new SVGImageManipulator(new StringReader (getPINEnvelopeData()), 147 getVisualValidity(), 148 getHardTokenSNPrefix()); 149 150 returnval = envelopesvgimagemanipulator.print(userdata, pincodes, pukcodes, hardtokensn, copyoftokensn); 151 } 152 153 154 return returnval; 155 } 156 157 158 159 } 160 | Popular Tags |