KickJava   Java API By Example, From Geeks To Geeks.

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


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  * HardTokenProfileWithPINEnvelope is a basic class that should be inherited by all types
30  * of hardtokenprofiles that should have PIN envelope functionality.
31  *
32  * @version $Id: HardTokenProfileWithPINEnvelope.java,v 1.2 2006/01/26 14:17:58 anatom Exp $
33  */

34 public abstract class HardTokenProfileWithPINEnvelope extends HardTokenProfile implements IPINEnvelopeSettings{
35         
36     
37     // Protected Constants
38
protected static final String JavaDoc PINENVELOPETYPE = "pinenvelopetype";
39     protected static final String JavaDoc PINENVELOPEFILENAME = "pinenvelopefilename";
40     protected static final String JavaDoc PINENVELOPEDATA = "pinenvelopetdata";
41     protected static final String JavaDoc PINENVELOPECOPIES = "pinenvelopetcopies";
42     protected static final String JavaDoc VISUALVALIDITY = "visualvalidity";
43
44     private SVGImageManipulator envelopesvgimagemanipulator = null;
45             
46     // Default Values
47
public HardTokenProfileWithPINEnvelope() {
48       super();
49       
50       setPINEnvelopeType(IPINEnvelopeSettings.PINENVELOPETYPE_GENERALENVELOBE);
51       setPINEnvelopeTemplateFilename("");
52       setNumberOfPINEnvelopeCopies(1);
53       setVisualValidity(356);
54       
55     }
56
57     // Public Methods mostly used by PrimeCard
58

59     
60     public void upgrade(){
61       // Perform upgrade functionality
62
super.upgrade();
63     }
64     
65
66
67     /**
68      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IPINEnvelopeSettings#getPINEnvelopeType()
69      */

70     public int getPINEnvelopeType() {
71         return ((Integer JavaDoc) data.get(PINENVELOPETYPE)).intValue();
72     }
73
74     /**
75      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IPINEnvelopeSettings#setPINEnvelopeType(int)
76      */

77     public void setPINEnvelopeType(int type) {
78       data.put(PINENVELOPETYPE, new Integer JavaDoc(type));
79     }
80
81     /**
82      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IPINEnvelopeSettings#getPINEnvelopeTemplateFilename()
83      */

84     public String JavaDoc getPINEnvelopeTemplateFilename() {
85         return (String JavaDoc) data.get(PINENVELOPEFILENAME);
86     }
87
88     /**
89      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IPINEnvelopeSettings#setPINEnvelopeTemplateFilename(java.lang.String)
90      */

91     public void setPINEnvelopeTemplateFilename(String JavaDoc filename) {
92       data.put(PINENVELOPEFILENAME, filename);
93     }
94
95     /**
96      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IPINEnvelopeSettings#getPINEnvelopeData()
97      */

98     public String JavaDoc getPINEnvelopeData() {
99         return (String JavaDoc) data.get(PINENVELOPEDATA);
100     }
101
102     /**
103      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IPINEnvelopeSettings#setPINEnvelopeData(java.lang.String)
104      */

105     public void setPINEnvelopeData(String JavaDoc templatedata) {
106       data.put(PINENVELOPEDATA, templatedata);
107     }
108
109     /**
110      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IPINEnvelopeSettings#getNumberOfPINEnvelopeCopies()
111      */

112     public int getNumberOfPINEnvelopeCopies() {
113         return ((Integer JavaDoc) data.get(PINENVELOPECOPIES)).intValue();
114     }
115
116     /**
117      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IPINEnvelopeSettings#setNumberOfPINEnvelopeCopies(int)
118      */

119     public void setNumberOfPINEnvelopeCopies(int copies) {
120       data.put(PINENVELOPECOPIES, new Integer JavaDoc(copies));
121     }
122
123     /**
124      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IPINEnvelopeSettings#getVisualValidity()
125      */

126     public int getVisualValidity(){
127       return ((Integer JavaDoc) data.get(VISUALVALIDITY)).intValue();
128     }
129
130     /**
131      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IPINEnvelopeSettings#setVisualValidity(int)
132      */

133     public void setVisualValidity(int validity){
134       data.put(VISUALVALIDITY, new Integer JavaDoc(validity));
135     }
136
137
138     /**
139      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IPINEnvelopeSettings#printPINEnvelope(org.ejbca.core.model.ra.UserDataVO, java.lang.String[], java.lang.String[], java.lang.String, java.lang.String)
140      */

141     public Printable JavaDoc printPINEnvelope(UserDataVO userdata, String JavaDoc[] pincodes, String JavaDoc[] pukcodes, String JavaDoc hardtokensn, String JavaDoc copyoftokensn) throws IOException JavaDoc, PrinterException JavaDoc{
142         Printable JavaDoc returnval = null;
143       
144         if(getPINEnvelopeData() != null){
145             if(envelopesvgimagemanipulator == null)
146               envelopesvgimagemanipulator = new SVGImageManipulator(new StringReader JavaDoc(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