KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > ui > web > admin > hardtokeninterface > HardTokenView


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.ui.web.admin.hardtokeninterface;
15
16 import java.util.Collection JavaDoc;
17 import java.util.Date JavaDoc;
18
19 import org.ejbca.core.model.hardtoken.*;
20 import org.ejbca.core.model.hardtoken.types.*;
21 import org.ejbca.util.StringTools;
22
23
24
25 /**
26  * A class representing a web interface view of a hard token in the ra database.
27  *
28  * @version $Id: HardTokenView.java,v 1.1 2006/01/17 20:26:30 anatom Exp $
29  */

30 public class HardTokenView implements java.io.Serializable JavaDoc, Cloneable JavaDoc {
31     // Public constants.
32
public HardTokenView() {
33         this.tokendata = new HardTokenData();
34     }
35
36     public HardTokenView(HardTokenData newtokendata) {
37         tokendata = newtokendata;
38     }
39
40     public void setUsername(String JavaDoc user) {
41         tokendata.setUsername(StringTools.strip(user));
42     }
43
44     public String JavaDoc getUsername() {
45         return tokendata.getUsername();
46     }
47
48
49     public void setTokenSN(String JavaDoc tokensn) {
50         tokendata.setTokenSN(tokensn);
51     }
52
53
54     public String JavaDoc getTokenSN() {
55         return tokendata.getTokenSN();
56     }
57
58     public void setCreateTime(Date JavaDoc createtime) {
59         tokendata.setCreateTime(createtime);
60     }
61
62     public Date JavaDoc getCreateTime() {
63         return tokendata.getCreateTime();
64     }
65
66     public void setModifyTime(Date JavaDoc modifytime) {
67         tokendata.setModifyTime(modifytime);
68     }
69
70     public Date JavaDoc getModifyTime() {
71         return tokendata.getModifyTime();
72     }
73
74     public int getNumberOfFields() {
75         return tokendata.getHardToken().getNumberOfFields();
76     }
77
78     public String JavaDoc getTextOfField(int index) {
79         if (tokendata.getHardToken().getFieldText(index).equals(HardToken.EMPTYROW_FIELD)) {
80             return "";
81         }
82         return tokendata.getHardToken().getFieldText(index);
83     }
84     
85     public boolean isOriginal(){
86       return tokendata.isOriginal();
87     }
88     
89     public String JavaDoc getCopyOf(){
90       return tokendata.getCopyOf();
91     }
92     
93     public Collection JavaDoc getCopies(){
94       return tokendata.getCopies();
95     }
96     
97     public Integer JavaDoc getHardTokenProfileId(){
98           return new Integer JavaDoc(tokendata.getHardToken().getTokenProfileId());
99     }
100
101     public Object JavaDoc getField(int index) {
102         HardToken token = tokendata.getHardToken();
103
104         if (token.getFieldPointer(index).equals(HardToken.EMPTYROW_FIELD)) {
105             return "";
106         }
107         return token.getField(token.getFieldPointer(index));
108     }
109
110     // Private constants.
111
// Private methods.
112
private HardTokenData tokendata;
113 }
114
Popular Tags