KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > core > model > hardtoken > profiles > HardTokenProfileWithAdressLabel


1 /*************************************************************************
2  * *
3  * EJBCA: The OpenSource Certificate Authority *
4  * *
5  * This software is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or any later version. *
9  * *
10  * See terms of license at gnu.org. *
11  * *
12  *************************************************************************/

13  
14 package org.ejbca.core.model.hardtoken.profiles;
15
16
17 import java.awt.print.Printable JavaDoc;
18 import java.awt.print.PrinterException JavaDoc;
19 import java.io.IOException JavaDoc;
20 import java.io.StringReader JavaDoc;
21
22 import org.ejbca.core.model.ra.UserDataVO;
23
24
25
26
27
28 /**
29  * HardTokenProfileWithAdressLabel is a basic class that should be inherited by all types
30  * of hardtokenprofiles that should have adress label functionality.
31  *
32  * @version $Id: HardTokenProfileWithAdressLabel.java,v 1.2 2006/01/26 14:17:58 anatom Exp $
33  */

34 public abstract class HardTokenProfileWithAdressLabel extends HardTokenProfileWithReceipt implements IAdressLabelSettings{
35         
36     
37     // Protected Constants
38
protected static final String JavaDoc ADRESSLABELTYPE = "adresslabeltype";
39     protected static final String JavaDoc ADRESSLABELFILENAME = "adresslabelfilename";
40     protected static final String JavaDoc ADRESSLABELDATA = "adresslabeldata";
41     protected static final String JavaDoc ADRESSLABELCOPIES = "adresslabelcopies";
42     
43
44     private SVGImageManipulator adresslabelsvgimagemanipulator = null;
45             
46     // Default Values
47
public HardTokenProfileWithAdressLabel() {
48       super();
49       
50       setAdressLabelType(IAdressLabelSettings.ADRESSLABELTYPE_GENERAL);
51       setAdressLabelTemplateFilename("");
52       setNumberOfAdressLabelCopies(1);
53          
54       
55     }
56
57     // Public Methods mostly used by PrimeCard
58

59     
60     public void upgrade(){
61       // Perform upgrade functionality
62

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     /* (non-Javadoc)
79      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IAdressLabelSettings#getNumberOfAdressLabelCopies()
80      */

81     public int getNumberOfAdressLabelCopies() {
82         return ((Integer JavaDoc) data.get(ADRESSLABELCOPIES)).intValue();
83     }
84     /* (non-Javadoc)
85      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IAdressLabelSettings#getAdressLabelData()
86      */

87     public String JavaDoc getAdressLabelData() {
88         return (String JavaDoc) data.get(ADRESSLABELDATA);
89     }
90     /* (non-Javadoc)
91      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IAdressLabelSettings#getAdressLabelTemplateFilename()
92      */

93     public String JavaDoc getAdressLabelTemplateFilename() {
94         return (String JavaDoc) data.get(ADRESSLABELFILENAME);
95     }
96     /* (non-Javadoc)
97      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IAdressLabelSettings#getAdressLabeltype()
98      */

99     public int getAdressLabelType() {
100         return ((Integer JavaDoc) data.get(ADRESSLABELTYPE)).intValue();
101     }
102     /* (non-Javadoc)
103      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IAdressLabelSettings#printAdressLabel(org.ejbca.core.model.ra.UserDataVO, java.lang.String[], java.lang.String[], java.lang.String, java.lang.String)
104      */

105     public Printable JavaDoc printAdressLabel(UserDataVO userdata, String JavaDoc[] pincodes,
106             String JavaDoc[] pukcodes, String JavaDoc hardtokensn, String JavaDoc copyoftokensn)
107             throws IOException JavaDoc, PrinterException JavaDoc {
108         Printable JavaDoc returnval = null;
109           
110             if(getAdressLabelData() != null){
111                 if(adresslabelsvgimagemanipulator == null)
112                     adresslabelsvgimagemanipulator = new SVGImageManipulator(new StringReader JavaDoc(getAdressLabelData()),
113                                                               getVisualValidity(),
114                                                               getHardTokenSNPrefix());
115                                                             
116               returnval = adresslabelsvgimagemanipulator.print(userdata, pincodes, pukcodes, hardtokensn, copyoftokensn);
117             }
118           
119           
120             return returnval;
121     }
122     /* (non-Javadoc)
123      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IAdressLabelSettings#setNumberOfAdressLabelCopies(int)
124      */

125     public void setNumberOfAdressLabelCopies(int copies) {
126           data.put(ADRESSLABELCOPIES, new Integer JavaDoc(copies));
127     }
128     /* (non-Javadoc)
129      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IAdressLabelSettings#setAdressLabelData(java.lang.String)
130      */

131     public void setAdressLabelData(String JavaDoc templatedata) {
132         data.put(ADRESSLABELDATA, templatedata);
133     }
134     /* (non-Javadoc)
135      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IAdressLabelSettings#setAdressLabelTemplateFilename(java.lang.String)
136      */

137     public void setAdressLabelTemplateFilename(String JavaDoc filename) {
138           data.put(ADRESSLABELFILENAME, filename);
139     }
140     /* (non-Javadoc)
141      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IAdressLabelSettings#setAdressLabeltype(int)
142      */

143     public void setAdressLabelType(int type) {
144         data.put(ADRESSLABELTYPE, new Integer JavaDoc(type));
145     }
146 }
147
Popular Tags