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 HardTokenProfileWithAdressLabel extends HardTokenProfileWithReceipt implements IAdressLabelSettings{ 35 36 37 protected static final String ADRESSLABELTYPE = "adresslabeltype"; 39 protected static final String ADRESSLABELFILENAME = "adresslabelfilename"; 40 protected static final String ADRESSLABELDATA = "adresslabeldata"; 41 protected static final String ADRESSLABELCOPIES = "adresslabelcopies"; 42 43 44 private SVGImageManipulator adresslabelsvgimagemanipulator = null; 45 46 public HardTokenProfileWithAdressLabel() { 48 super(); 49 50 setAdressLabelType(IAdressLabelSettings.ADRESSLABELTYPE_GENERAL); 51 setAdressLabelTemplateFilename(""); 52 setNumberOfAdressLabelCopies(1); 53 54 55 } 56 57 59 60 public void upgrade(){ 61 63 if(data.get(ADRESSLABELTYPE) == null){ 64 setAdressLabelType(IAdressLabelSettings.ADRESSLABELTYPE_GENERAL); 65 } 66 if(data.get(ADRESSLABELFILENAME) == null){ 67 setAdressLabelTemplateFilename(""); 68 } 69 if(data.get(ADRESSLABELCOPIES) == null){ 70 setNumberOfAdressLabelCopies(1); 71 } 72 73 super.upgrade(); 74 } 75 76 77 78 81 public int getNumberOfAdressLabelCopies() { 82 return ((Integer ) data.get(ADRESSLABELCOPIES)).intValue(); 83 } 84 87 public String getAdressLabelData() { 88 return (String ) data.get(ADRESSLABELDATA); 89 } 90 93 public String getAdressLabelTemplateFilename() { 94 return (String ) data.get(ADRESSLABELFILENAME); 95 } 96 99 public int getAdressLabelType() { 100 return ((Integer ) data.get(ADRESSLABELTYPE)).intValue(); 101 } 102 105 public Printable printAdressLabel(UserDataVO userdata, String [] pincodes, 106 String [] pukcodes, String hardtokensn, String copyoftokensn) 107 throws IOException , PrinterException { 108 Printable returnval = null; 109 110 if(getAdressLabelData() != null){ 111 if(adresslabelsvgimagemanipulator == null) 112 adresslabelsvgimagemanipulator = new SVGImageManipulator(new StringReader (getAdressLabelData()), 113 getVisualValidity(), 114 getHardTokenSNPrefix()); 115 116 returnval = adresslabelsvgimagemanipulator.print(userdata, pincodes, pukcodes, hardtokensn, copyoftokensn); 117 } 118 119 120 return returnval; 121 } 122 125 public void setNumberOfAdressLabelCopies(int copies) { 126 data.put(ADRESSLABELCOPIES, new Integer (copies)); 127 } 128 131 public void setAdressLabelData(String templatedata) { 132 data.put(ADRESSLABELDATA, templatedata); 133 } 134 137 public void setAdressLabelTemplateFilename(String filename) { 138 data.put(ADRESSLABELFILENAME, filename); 139 } 140 143 public void setAdressLabelType(int type) { 144 data.put(ADRESSLABELTYPE, new Integer (type)); 145 } 146 } 147 | Popular Tags |