KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.awt.print.Printable JavaDoc;
17 import java.awt.print.PrinterException JavaDoc;
18 import java.io.IOException JavaDoc;
19 import java.io.StringReader JavaDoc;
20
21 import org.ejbca.core.model.ra.UserDataVO;
22
23
24
25
26 /**
27  * HardTokenProfileWithVisualLayout is a basic class that should be inherited by all types
28  * of hardtokenprofiles in the system that need PIN envelope and visual layout printing funtionality.
29  *
30  * It used to customize the information generated on hard tokens when they are
31  * processed. This information could be PIN-type number of certificates,
32  * certificate profiles and so on.
33  *
34  * @version $Id: HardTokenProfileWithVisualLayout.java,v 1.2 2006/01/26 14:17:58 anatom Exp $
35  */

36 public abstract class HardTokenProfileWithVisualLayout extends HardTokenProfileWithPINEnvelope implements IVisualLayoutSettings{
37         
38     // Protected Constants
39

40     protected static final String JavaDoc VISUALLAYOUTTYPE = "visuallayouttype";
41     protected static final String JavaDoc VISUALLAYOUTFILENAME = "visuallayoutfilename";
42     protected static final String JavaDoc VISUALLAYOUTDATA = "visuallayoutdata";
43
44
45     private SVGImageManipulator visualsvgimagemanipulator = null;
46             
47     // Default Values
48
public HardTokenProfileWithVisualLayout() {
49       super();
50       
51       setVisualLayoutType(IVisualLayoutSettings.VISUALLAYOUTTYPE_GENERALLABEL);
52       setVisualLayoutTemplateFilename("");
53     }
54
55     // Public Methods mostly used by PrimeCard
56

57     /**
58      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IVisualLayoutSettings#getVisualLayoutType()
59      */

60     public int getVisualLayoutType() {
61       return ((Integer JavaDoc) data.get(VISUALLAYOUTTYPE)).intValue();
62     }
63
64     /**
65      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IVisualLayoutSettings#setVisualLayoutType(int)
66      */

67     public void setVisualLayoutType(int type) {
68       data.put(VISUALLAYOUTTYPE, new Integer JavaDoc(type));
69     }
70
71     /**
72      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IVisualLayoutSettings#getVisualLayoutTemplateFilename()
73      */

74     public String JavaDoc getVisualLayoutTemplateFilename() {
75         return (String JavaDoc) data.get(VISUALLAYOUTFILENAME);
76     }
77
78     /**
79      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IVisualLayoutSettings#setVisualLayoutTemplateFilename(java.lang.String)
80      */

81     public void setVisualLayoutTemplateFilename(String JavaDoc filename) {
82       data.put(VISUALLAYOUTFILENAME, filename);
83     }
84
85     /**
86      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IVisualLayoutSettings#getVisualLayoutData()
87      */

88     public String JavaDoc getVisualLayoutData() {
89       return (String JavaDoc) data.get(VISUALLAYOUTDATA);
90     }
91
92     /**
93      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IVisualLayoutSettings#setVisualLayoutData(java.lang.String)
94      */

95     public void setVisualLayoutData(String JavaDoc templatedata) {
96       data.put(VISUALLAYOUTDATA, templatedata);
97     }
98
99     /**
100      * @see org.ejbca.core.model.hardtoken.hardtokenprofiles.IVisualLayoutSettings#printVisualValidity(org.ejbca.core.model.ra.UserDataVO, java.lang.String[], java.lang.String[], java.lang.String, java.lang.String)
101      */

102     public Printable JavaDoc printVisualValidity(UserDataVO userdata, String JavaDoc[] pincodes, String JavaDoc[] pukcodes, String JavaDoc hardtokensn, String JavaDoc copyoftokensn) throws IOException JavaDoc, PrinterException JavaDoc{
103         Printable JavaDoc returnval = null;
104       
105       if(getVisualLayoutData() != null){
106           if(visualsvgimagemanipulator == null)
107             visualsvgimagemanipulator = new SVGImageManipulator(new StringReader JavaDoc(getVisualLayoutData()),
108                                                         getVisualValidity(),
109                                                         getHardTokenSNPrefix());
110                                                         
111         returnval = visualsvgimagemanipulator.print(userdata, pincodes, pukcodes, hardtokensn, copyoftokensn);
112       }
113       
114       
115       return returnval;
116     }
117     
118
119 }
120
Popular Tags