blob: cd6ad512138b77c8366b2d5f3e1bb6a28391d918 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * reserved comment block
3 * DO NOT REMOVE OR ALTER!
4 */
5/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright notice,
14 * this list of conditions and the following disclaimer in the documentation
15 * and/or other materials provided with the distribution.
16 *
17 * 3. The end-user documentation included with the redistribution, if any, must
18 * include the following acknowledgment:
19 *
20 * "This product includes software developed by IAIK of Graz University of
21 * Technology."
22 *
23 * Alternately, this acknowledgment may appear in the software itself, if
24 * and wherever such third-party acknowledgments normally appear.
25 *
26 * 4. The names "Graz University of Technology" and "IAIK of Graz University of
27 * Technology" must not be used to endorse or promote products derived from
28 * this software without prior written permission.
29 *
30 * 5. Products derived from this software may not be called
31 * "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
32 * written permission of Graz University of Technology.
33 *
34 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
35 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
36 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
37 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
38 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
39 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
40 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
41 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
42 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
43 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
44 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
45 * POSSIBILITY OF SUCH DAMAGE.
46 */
47
48package sun.security.pkcs11.wrapper;
49
50
51
52/**
53 * class CK_SLOT_INFO provides information about a slot.<p>
54 * <B>PKCS#11 structure:</B>
55 * <PRE>
56 * typedef struct CK_SLOT_INFO {&nbsp;&nbsp;
57 * CK_UTF8CHAR slotDescription[64];&nbsp;&nbsp;
58 * CK_UTF8CHAR manufacturerID[32];&nbsp;&nbsp;
59 * CK_FLAGS flags;&nbsp;&nbsp;
60 * CK_VERSION hardwareVersion;&nbsp;&nbsp;
61 * CK_VERSION firmwareVersion;&nbsp;&nbsp;
62 * } CK_SLOT_INFO;
63 * </PRE>
64 *
65 * @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
66 * @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
67 */
68public class CK_SLOT_INFO {
69
70 /* slotDescription and manufacturerID have been changed from
71 * CK_CHAR to CK_UTF8CHAR for v2.11. */
72
73 /**
74 * must be blank padded and only the first 64 chars will be used<p>
75 * <B>PKCS#11:</B>
76 * <PRE>
77 * CK_UTF8CHAR slotDescription[64];
78 * </PRE>
79 */
80 public char[] slotDescription;
81
82 /**
83 * must be blank padded and only the first 32 chars will be used<p>
84 * <B>PKCS#11:</B>
85 * <PRE>
86 * CK_UTF8CHAR manufacturerID[32];
87 * </PRE>
88 */
89 public char[] manufacturerID;
90
91 /**
92 * <B>PKCS#11:</B>
93 * <PRE>
94 * CK_FLAGS flags;
95 * </PRE>
96 */
97 public long flags;
98
99 /* hardwareVersion and firmwareVersion are new for v2.0 */
100 /**
101 * version of hardware<p>
102 * <B>PKCS#11:</B>
103 * <PRE>
104 * CK_VERSION hardwareVersion;
105 * </PRE>
106 */
107 public CK_VERSION hardwareVersion;
108
109 /**
110 * version of firmware<p>
111 * <B>PKCS#11:</B>
112 * <PRE>
113 * CK_VERSION firmwareVersion;
114 * </PRE>
115 */
116 public CK_VERSION firmwareVersion;
117
118 public CK_SLOT_INFO(char[] slotDesc, char[] vendor,
119 long flags, CK_VERSION hwVer, CK_VERSION fwVer) {
120 this.slotDescription = slotDesc;
121 this.manufacturerID = vendor;
122 this.flags = flags;
123 this.hardwareVersion = hwVer;
124 this.firmwareVersion = fwVer;
125 }
126
127 /**
128 * Returns the string representation of CK_SLOT_INFO.
129 *
130 * @return the string representation of CK_SLOT_INFO
131 */
132 public String toString() {
133 StringBuffer buffer = new StringBuffer();
134
135 buffer.append(Constants.INDENT);
136 buffer.append("slotDescription: ");
137 buffer.append(new String(slotDescription));
138 buffer.append(Constants.NEWLINE);
139
140 buffer.append(Constants.INDENT);
141 buffer.append("manufacturerID: ");
142 buffer.append(new String(manufacturerID));
143 buffer.append(Constants.NEWLINE);
144
145 buffer.append(Constants.INDENT);
146 buffer.append("flags: ");
147 buffer.append(Functions.slotInfoFlagsToString(flags));
148 buffer.append(Constants.NEWLINE);
149
150 buffer.append(Constants.INDENT);
151 buffer.append("hardwareVersion: ");
152 buffer.append(hardwareVersion.toString());
153 buffer.append(Constants.NEWLINE);
154
155 buffer.append(Constants.INDENT);
156 buffer.append("firmwareVersion: ");
157 buffer.append(firmwareVersion.toString());
158 //buffer.append(Constants.NEWLINE);
159
160 return buffer.toString() ;
161 }
162
163}