blob: 89cbe75200e37fe929ecc49bd5499ea0e094d386 [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_SESSION_INFO provides information about a session.<p>
54 * <B>PKCS#11 structure:</B>
55 * <PRE>
56 * typedef struct CK_SESSION_INFO {&nbsp;&nbsp;
57 * CK_SLOT_ID slotID;&nbsp;&nbsp;
58 * CK_STATE state;&nbsp;&nbsp;
59 * CK_FLAGS flags;&nbsp;&nbsp;
60 * CK_ULONG ulDeviceError;&nbsp;&nbsp;
61 * } CK_SESSION_INFO;
62 * </PRE>
63 *
64 * @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
65 * @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
66 */
67public class CK_SESSION_INFO {
68
69 /**
70 * <B>PKCS#11:</B>
71 * <PRE>
72 * CK_SLOT_ID slotID;
73 * </PRE>
74 */
75 public long slotID;
76
77 /**
78 * <B>PKCS#11:</B>
79 * <PRE>
80 * CK_STATE state;
81 * </PRE>
82 */
83 public long state;
84
85 /**
86 * <B>PKCS#11:</B>
87 * <PRE>
88 * CK_FLAGS flags;
89 * </PRE>
90 */
91 public long flags; /* see below */
92
93 /* ulDeviceError was changed from CK_USHORT to CK_ULONG for
94 * v2.0 */
95 /**
96 * <B>PKCS#11:</B>
97 * <PRE>
98 * CK_ULONG ulDeviceError;
99 * </PRE>
100 */
101 public long ulDeviceError; /* device-dependent error code */
102
103 public CK_SESSION_INFO(long slotID, long state,
104 long flags, long ulDeviceError) {
105 this.slotID = slotID;
106 this.state = state;
107 this.flags = flags;
108 this.ulDeviceError = ulDeviceError;
109 }
110
111 /**
112 * Returns the string representation of CK_SESSION_INFO.
113 *
114 * @return the string representation of CK_SESSION_INFO
115 */
116 public String toString() {
117 StringBuffer buffer = new StringBuffer();
118
119 buffer.append(Constants.INDENT);
120 buffer.append("slotID: ");
121 buffer.append(String.valueOf(slotID));
122 buffer.append(Constants.NEWLINE);
123
124 buffer.append(Constants.INDENT);
125 buffer.append("state: ");
126 buffer.append(Functions.sessionStateToString(state));
127 buffer.append(Constants.NEWLINE);
128
129 buffer.append(Constants.INDENT);
130 buffer.append("flags: ");
131 buffer.append(Functions.sessionInfoFlagsToString(flags));
132 buffer.append(Constants.NEWLINE);
133
134 buffer.append(Constants.INDENT);
135 buffer.append("ulDeviceError: ");
136 buffer.append(Functions.toHexString(ulDeviceError));
137 //buffer.append(Constants.NEWLINE);
138
139 return buffer.toString() ;
140 }
141
142}