author | mchung |
Wed, 14 Dec 2016 10:51:13 -0800 | |
changeset 42693 | 6645de32a866 |
parent 25859 | jdk/src/jdk.crypto.pkcs11/share/classes/sun/security/pkcs11/wrapper/CK_INFO.java@3317bb8137f4 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
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 |
||
48 |
package sun.security.pkcs11.wrapper; |
|
49 |
||
50 |
||
51 |
||
52 |
/** |
|
53 |
* class CK_INFO provides general information about Cryptoki.<p> |
|
54 |
* <B>PKCS#11 structure:</B> |
|
55 |
* <PRE> |
|
56 |
* typedef struct CK_INFO { |
|
57 |
* CK_VERSION cryptokiVersion; |
|
58 |
* CK_UTF8CHAR manufacturerID[32]; |
|
59 |
* CK_FLAGS flags; |
|
60 |
* CK_UTF8CHAR libraryDescription[32]; |
|
61 |
* CK_VERSION libraryVersion; |
|
62 |
* } CK_INFO; |
|
63 |
* </PRE> |
|
64 |
* |
|
65 |
* @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at> |
|
66 |
* @author Martin Schlaeffer <schlaeff@sbox.tugraz.at> |
|
67 |
*/ |
|
68 |
public class CK_INFO { |
|
69 |
||
70 |
/** |
|
71 |
* Cryptoki interface version number<p> |
|
72 |
* <B>PKCS#11:</B> |
|
73 |
* <PRE> |
|
74 |
* CK_VERSION cryptokiVersion; |
|
75 |
* </PRE> |
|
76 |
*/ |
|
77 |
public CK_VERSION cryptokiVersion; |
|
78 |
||
79 |
/** |
|
80 |
* ID of the Cryptoki library manufacturer. must be blank |
|
81 |
* padded - only the first 32 chars will be used<p> |
|
82 |
* <B>PKCS#11:</B> |
|
83 |
* <PRE> |
|
84 |
* CK_UTF8CHAR manufacturerID[32]; |
|
85 |
* </PRE> |
|
86 |
*/ |
|
87 |
public char[] manufacturerID; |
|
88 |
||
89 |
/** |
|
90 |
* bit flags reserved for future versions. must be zero<p> |
|
91 |
* <B>PKCS#11:</B> |
|
92 |
* <PRE> |
|
93 |
* CK_FLAGS flags; |
|
94 |
* </PRE> |
|
95 |
*/ |
|
96 |
public long flags; |
|
97 |
||
98 |
||
99 |
/* libraryDescription and libraryVersion are new for v2.0 */ |
|
100 |
||
101 |
/** |
|
102 |
* must be blank padded - only the first 32 chars will be used<p> |
|
103 |
* <B>PKCS#11:</B> |
|
104 |
* <PRE> |
|
105 |
* CK_UTF8CHAR libraryDescription[32]; |
|
106 |
* </PRE> |
|
107 |
*/ |
|
108 |
public char[] libraryDescription; |
|
109 |
||
110 |
/** |
|
111 |
* Cryptoki library version number<p> |
|
112 |
* <B>PKCS#11:</B> |
|
113 |
* <PRE> |
|
114 |
* CK_VERSION libraryVersion; |
|
115 |
* </PRE> |
|
116 |
*/ |
|
117 |
public CK_VERSION libraryVersion; |
|
118 |
||
119 |
public CK_INFO(CK_VERSION cryptoVer, char[] vendor, long flags, |
|
120 |
char[] libDesc, CK_VERSION libVer) { |
|
121 |
this.cryptokiVersion = cryptoVer; |
|
122 |
this.manufacturerID = vendor; |
|
123 |
this.flags = flags; |
|
124 |
this.libraryDescription = libDesc; |
|
125 |
this.libraryVersion = libVer; |
|
126 |
} |
|
127 |
||
128 |
/** |
|
129 |
* Returns the string representation of CK_INFO. |
|
130 |
* |
|
131 |
* @return the string representation of CK_INFO |
|
132 |
*/ |
|
133 |
public String toString() { |
|
24969
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
2
diff
changeset
|
134 |
StringBuilder sb = new StringBuilder(); |
2 | 135 |
|
24969
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
2
diff
changeset
|
136 |
sb.append(Constants.INDENT); |
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
2
diff
changeset
|
137 |
sb.append("cryptokiVersion: "); |
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
2
diff
changeset
|
138 |
sb.append(cryptokiVersion.toString()); |
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
2
diff
changeset
|
139 |
sb.append(Constants.NEWLINE); |
2 | 140 |
|
24969
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
2
diff
changeset
|
141 |
sb.append(Constants.INDENT); |
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
2
diff
changeset
|
142 |
sb.append("manufacturerID: "); |
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
2
diff
changeset
|
143 |
sb.append(new String(manufacturerID)); |
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
2
diff
changeset
|
144 |
sb.append(Constants.NEWLINE); |
2 | 145 |
|
24969
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
2
diff
changeset
|
146 |
sb.append(Constants.INDENT); |
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
2
diff
changeset
|
147 |
sb.append("flags: "); |
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
2
diff
changeset
|
148 |
sb.append(Functions.toBinaryString(flags)); |
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
2
diff
changeset
|
149 |
sb.append(Constants.NEWLINE); |
2 | 150 |
|
24969
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
2
diff
changeset
|
151 |
sb.append(Constants.INDENT); |
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
2
diff
changeset
|
152 |
sb.append("libraryDescription: "); |
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
2
diff
changeset
|
153 |
sb.append(new String(libraryDescription)); |
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
2
diff
changeset
|
154 |
sb.append(Constants.NEWLINE); |
2 | 155 |
|
24969
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
2
diff
changeset
|
156 |
sb.append(Constants.INDENT); |
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
2
diff
changeset
|
157 |
sb.append("libraryVersion: "); |
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
2
diff
changeset
|
158 |
sb.append(libraryVersion.toString()); |
2 | 159 |
//buffer.append(Constants.NEWLINE); |
160 |
||
24969
afa6934dd8e8
8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents:
2
diff
changeset
|
161 |
return sb.toString() ; |
2 | 162 |
} |
163 |
||
164 |
} |