0N/A/*
2362N/A * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
0N/A */
0N/A
0N/A/* Copyright (c) 2002 Graz University of Technology. All rights reserved.
0N/A *
0N/A * Redistribution and use in source and binary forms, with or without
0N/A * modification, are permitted provided that the following conditions are met:
0N/A *
0N/A * 1. Redistributions of source code must retain the above copyright notice,
0N/A * this list of conditions and the following disclaimer.
0N/A *
0N/A * 2. Redistributions in binary form must reproduce the above copyright notice,
0N/A * this list of conditions and the following disclaimer in the documentation
0N/A * and/or other materials provided with the distribution.
0N/A *
0N/A * 3. The end-user documentation included with the redistribution, if any, must
0N/A * include the following acknowledgment:
0N/A *
0N/A * "This product includes software developed by IAIK of Graz University of
0N/A * Technology."
0N/A *
0N/A * Alternately, this acknowledgment may appear in the software itself, if
0N/A * and wherever such third-party acknowledgments normally appear.
0N/A *
0N/A * 4. The names "Graz University of Technology" and "IAIK of Graz University of
0N/A * Technology" must not be used to endorse or promote products derived from
0N/A * this software without prior written permission.
0N/A *
0N/A * 5. Products derived from this software may not be called
0N/A * "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
0N/A * written permission of Graz University of Technology.
0N/A *
0N/A * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
0N/A * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
0N/A * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
0N/A * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
0N/A * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
0N/A * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
0N/A * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
0N/A * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
0N/A * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
0N/A * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
0N/A * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0N/A * POSSIBILITY OF SUCH DAMAGE.
0N/A */
0N/A
0N/Apackage sun.security.pkcs11.wrapper;
0N/A
0N/A
0N/A
0N/A/**
0N/A * class CK_TOKEN_INFO provides information about a token.<p>
0N/A * <B>PKCS#11 structure:</B>
0N/A * <PRE>
0N/A * typedef struct CK_TOKEN_INFO {&nbsp;&nbsp;
0N/A * CK_UTF8CHAR label[32];&nbsp;&nbsp;
0N/A * CK_UTF8CHAR manufacturerID[32];&nbsp;&nbsp;
0N/A * CK_UTF8CHAR model[16];&nbsp;&nbsp;
0N/A * CK_CHAR serialNumber[16];&nbsp;&nbsp;
0N/A * CK_FLAGS flags;&nbsp;&nbsp;
0N/A * CK_ULONG ulMaxSessionCount;&nbsp;&nbsp;
0N/A * CK_ULONG ulSessionCount;&nbsp;&nbsp;
0N/A * CK_ULONG ulMaxRwSessionCount;&nbsp;&nbsp;
0N/A * CK_ULONG ulRwSessionCount;&nbsp;&nbsp;
0N/A * CK_ULONG ulMaxPinLen;&nbsp;&nbsp;
0N/A * CK_ULONG ulMinPinLen;&nbsp;&nbsp;
0N/A * CK_ULONG ulTotalPublicMemory;&nbsp;&nbsp;
0N/A * CK_ULONG ulFreePublicMemory;&nbsp;&nbsp;
0N/A * CK_ULONG ulTotalPrivateMemory;&nbsp;&nbsp;
0N/A * CK_ULONG ulFreePrivateMemory;&nbsp;&nbsp;
0N/A * CK_VERSION hardwareVersion;&nbsp;&nbsp;
0N/A * CK_VERSION firmwareVersion;&nbsp;&nbsp;
0N/A * CK_CHAR utcTime[16];&nbsp;&nbsp;
0N/A * } CK_TOKEN_INFO;
0N/A * &nbsp;&nbsp;
0N/A * </PRE>
0N/A *
0N/A * @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
0N/A * @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
0N/A */
0N/Apublic class CK_TOKEN_INFO {
0N/A
0N/A /* label, manufacturerID, and model have been changed from
0N/A * CK_CHAR to CK_UTF8CHAR for v2.11. */
0N/A /**
0N/A * must be blank padded and only the first 32 chars will be used<p>
0N/A * <B>PKCS#11:</B>
0N/A * <PRE>
0N/A * CK_UTF8CHAR label[32];
0N/A * </PRE>
0N/A */
0N/A public char[] label; /* blank padded */
0N/A
0N/A /**
0N/A * must be blank padded and only the first 32 chars will be used<p>
0N/A * <B>PKCS#11:</B>
0N/A * <PRE>
0N/A * CK_UTF8CHAR manufacturerID[32];
0N/A * </PRE>
0N/A */
0N/A public char[] manufacturerID; /* blank padded */
0N/A
0N/A /**
0N/A * must be blank padded and only the first 16 chars will be used<p>
0N/A * <B>PKCS#11:</B>
0N/A * <PRE>
0N/A * CK_UTF8CHAR model[16];
0N/A * </PRE>
0N/A */
0N/A public char[] model; /* blank padded */
0N/A
0N/A /**
0N/A * must be blank padded and only the first 16 chars will be used<p>
0N/A * <B>PKCS#11:</B>
0N/A * <PRE>
0N/A * CK_CHAR serialNumber[16];
0N/A * </PRE>
0N/A */
0N/A public char[] serialNumber; /* blank padded */
0N/A
0N/A /**
0N/A * <B>PKCS#11:</B>
0N/A * <PRE>
0N/A * CK_FLAGS flags;
0N/A * </PRE>
0N/A */
0N/A public long flags; /* see below */
0N/A
0N/A /* ulMaxSessionCount, ulSessionCount, ulMaxRwSessionCount,
0N/A * ulRwSessionCount, ulMaxPinLen, and ulMinPinLen have all been
0N/A * changed from CK_USHORT to CK_ULONG for v2.0 */
0N/A /**
0N/A * <B>PKCS#11:</B>
0N/A * <PRE>
0N/A * CK_ULONG ulMaxSessionCount;
0N/A * </PRE>
0N/A */
0N/A public long ulMaxSessionCount; /* max open sessions */
0N/A
0N/A /**
0N/A * <B>PKCS#11:</B>
0N/A * <PRE>
0N/A * CK_ULONG ulSessionCount;
0N/A * </PRE>
0N/A */
0N/A public long ulSessionCount; /* sess. now open */
0N/A
0N/A /**
0N/A * <B>PKCS#11:</B>
0N/A * <PRE>
0N/A * CK_ULONG ulMaxRwSessionCount;
0N/A * </PRE>
0N/A */
0N/A public long ulMaxRwSessionCount; /* max R/W sessions */
0N/A
0N/A /**
0N/A * <B>PKCS#11:</B>
0N/A * <PRE>
0N/A * CK_ULONG ulRwSessionCount;
0N/A * </PRE>
0N/A */
0N/A public long ulRwSessionCount; /* R/W sess. now open */
0N/A
0N/A /**
0N/A * <B>PKCS#11:</B>
0N/A * <PRE>
0N/A * CK_ULONG ulMaxPinLen;
0N/A * </PRE>
0N/A */
0N/A public long ulMaxPinLen; /* in bytes */
0N/A
0N/A /**
0N/A * <B>PKCS#11:</B>
0N/A * <PRE>
0N/A * CK_ULONG ulMinPinLen;
0N/A * </PRE>
0N/A */
0N/A public long ulMinPinLen; /* in bytes */
0N/A
0N/A /**
0N/A * <B>PKCS#11:</B>
0N/A * <PRE>
0N/A * CK_ULONG ulTotalPublicMemory;
0N/A * </PRE>
0N/A */
0N/A public long ulTotalPublicMemory; /* in bytes */
0N/A
0N/A /**
0N/A * <B>PKCS#11:</B>
0N/A * <PRE>
0N/A * CK_ULONG ulFreePublicMemory;
0N/A * </PRE>
0N/A */
0N/A public long ulFreePublicMemory; /* in bytes */
0N/A
0N/A /**
0N/A * <B>PKCS#11:</B>
0N/A * <PRE>
0N/A * CK_ULONG ulTotalPrivateMemory;
0N/A * </PRE>
0N/A */
0N/A public long ulTotalPrivateMemory; /* in bytes */
0N/A
0N/A /**
0N/A * <B>PKCS#11:</B>
0N/A * <PRE>
0N/A * CK_ULONG ulFreePrivateMemory;
0N/A * </PRE>
0N/A */
0N/A public long ulFreePrivateMemory; /* in bytes */
0N/A
0N/A /* hardwareVersion, firmwareVersion, and time are new for
0N/A * v2.0 */
0N/A /**
0N/A * <B>PKCS#11:</B>
0N/A * <PRE>
0N/A * CK_VERSION hardwareVersion;
0N/A * </PRE>
0N/A */
0N/A public CK_VERSION hardwareVersion; /* version of hardware */
0N/A
0N/A /**
0N/A * <B>PKCS#11:</B>
0N/A * <PRE>
0N/A * CK_VERSION firmwareVersion;
0N/A * </PRE>
0N/A */
0N/A public CK_VERSION firmwareVersion; /* version of firmware */
0N/A
0N/A /**
0N/A * only the first 16 chars will be used
0N/A * <B>PKCS#11:</B>
0N/A * <PRE>
0N/A * CK_CHAR utcTime[16];
0N/A * </PRE>
0N/A */
0N/A public char[] utcTime; /* time */
0N/A
0N/A public CK_TOKEN_INFO(char[] label, char[] vendor, char[] model,
0N/A char[] serialNo, long flags,
0N/A long sessionMax, long session,
0N/A long rwSessionMax, long rwSession,
0N/A long pinLenMax, long pinLenMin,
0N/A long totalPubMem, long freePubMem,
0N/A long totalPrivMem, long freePrivMem,
0N/A CK_VERSION hwVer, CK_VERSION fwVer, char[] utcTime) {
0N/A this.label = label;
0N/A this.manufacturerID = vendor;
0N/A this.model = model;
0N/A this.serialNumber = serialNo;
0N/A this.flags = flags;
0N/A this.ulMaxSessionCount = sessionMax;
0N/A this.ulSessionCount = session;
0N/A this.ulMaxRwSessionCount = rwSessionMax;
0N/A this.ulRwSessionCount = rwSession;
0N/A this.ulMaxPinLen = pinLenMax;
0N/A this.ulMinPinLen = pinLenMin;
0N/A this.ulTotalPublicMemory = totalPubMem;
0N/A this.ulFreePublicMemory = freePubMem;
0N/A this.ulTotalPrivateMemory = totalPrivMem;
0N/A this.ulFreePrivateMemory = freePrivMem;
0N/A this.hardwareVersion = hwVer;
0N/A this.firmwareVersion = fwVer;
0N/A this.utcTime = utcTime;
0N/A }
0N/A
0N/A /**
0N/A * Returns the string representation of CK_TOKEN_INFO.
0N/A *
0N/A * @return the string representation of CK_TOKEN_INFO
0N/A */
0N/A public String toString() {
0N/A StringBuffer buffer = new StringBuffer();
0N/A
0N/A buffer.append(Constants.INDENT);
0N/A buffer.append("label: ");
0N/A buffer.append(new String(label));
0N/A buffer.append(Constants.NEWLINE);
0N/A
0N/A buffer.append(Constants.INDENT);
0N/A buffer.append("manufacturerID: ");
0N/A buffer.append(new String(manufacturerID));
0N/A buffer.append(Constants.NEWLINE);
0N/A
0N/A buffer.append(Constants.INDENT);
0N/A buffer.append("model: ");
0N/A buffer.append(new String(model));
0N/A buffer.append(Constants.NEWLINE);
0N/A
0N/A buffer.append(Constants.INDENT);
0N/A buffer.append("serialNumber: ");
0N/A buffer.append(new String(serialNumber));
0N/A buffer.append(Constants.NEWLINE);
0N/A
0N/A buffer.append(Constants.INDENT);
0N/A buffer.append("flags: ");
0N/A buffer.append(Functions.tokenInfoFlagsToString(flags));
0N/A buffer.append(Constants.NEWLINE);
0N/A
0N/A buffer.append(Constants.INDENT);
0N/A buffer.append("ulMaxSessionCount: ");
0N/A buffer.append((ulMaxSessionCount == PKCS11Constants.CK_EFFECTIVELY_INFINITE)
0N/A ? "CK_EFFECTIVELY_INFINITE"
0N/A : (ulMaxSessionCount == PKCS11Constants.CK_UNAVAILABLE_INFORMATION)
0N/A ? "CK_UNAVAILABLE_INFORMATION"
0N/A : String.valueOf(ulMaxSessionCount));
0N/A buffer.append(Constants.NEWLINE);
0N/A
0N/A buffer.append(Constants.INDENT);
0N/A buffer.append("ulSessionCount: ");
0N/A buffer.append((ulSessionCount == PKCS11Constants.CK_UNAVAILABLE_INFORMATION)
0N/A ? "CK_UNAVAILABLE_INFORMATION"
0N/A : String.valueOf(ulSessionCount));
0N/A buffer.append(Constants.NEWLINE);
0N/A
0N/A buffer.append(Constants.INDENT);
0N/A buffer.append("ulMaxRwSessionCount: ");
0N/A buffer.append((ulMaxRwSessionCount == PKCS11Constants.CK_EFFECTIVELY_INFINITE)
0N/A ? "CK_EFFECTIVELY_INFINITE"
0N/A : (ulMaxRwSessionCount == PKCS11Constants.CK_UNAVAILABLE_INFORMATION)
0N/A ? "CK_UNAVAILABLE_INFORMATION"
0N/A : String.valueOf(ulMaxRwSessionCount));
0N/A buffer.append(Constants.NEWLINE);
0N/A
0N/A buffer.append(Constants.INDENT);
0N/A buffer.append("ulRwSessionCount: ");
0N/A buffer.append((ulRwSessionCount == PKCS11Constants.CK_UNAVAILABLE_INFORMATION)
0N/A ? "CK_UNAVAILABLE_INFORMATION"
0N/A : String.valueOf(ulRwSessionCount));
0N/A buffer.append(Constants.NEWLINE);
0N/A
0N/A buffer.append(Constants.INDENT);
0N/A buffer.append("ulMaxPinLen: ");
0N/A buffer.append(String.valueOf(ulMaxPinLen));
0N/A buffer.append(Constants.NEWLINE);
0N/A
0N/A buffer.append(Constants.INDENT);
0N/A buffer.append("ulMinPinLen: ");
0N/A buffer.append(String.valueOf(ulMinPinLen));
0N/A buffer.append(Constants.NEWLINE);
0N/A
0N/A buffer.append(Constants.INDENT);
0N/A buffer.append("ulTotalPublicMemory: ");
0N/A buffer.append((ulTotalPublicMemory == PKCS11Constants.CK_UNAVAILABLE_INFORMATION)
0N/A ? "CK_UNAVAILABLE_INFORMATION"
0N/A : String.valueOf(ulTotalPublicMemory));
0N/A buffer.append(Constants.NEWLINE);
0N/A
0N/A buffer.append(Constants.INDENT);
0N/A buffer.append("ulFreePublicMemory: ");
0N/A buffer.append((ulFreePublicMemory == PKCS11Constants.CK_UNAVAILABLE_INFORMATION)
0N/A ? "CK_UNAVAILABLE_INFORMATION"
0N/A : String.valueOf(ulFreePublicMemory));
0N/A buffer.append(Constants.NEWLINE);
0N/A
0N/A buffer.append(Constants.INDENT);
0N/A buffer.append("ulTotalPrivateMemory: ");
0N/A buffer.append((ulTotalPrivateMemory == PKCS11Constants.CK_UNAVAILABLE_INFORMATION)
0N/A ? "CK_UNAVAILABLE_INFORMATION"
0N/A : String.valueOf(ulTotalPrivateMemory));
0N/A buffer.append(Constants.NEWLINE);
0N/A
0N/A buffer.append(Constants.INDENT);
0N/A buffer.append("ulFreePrivateMemory: ");
0N/A buffer.append((ulFreePrivateMemory == PKCS11Constants.CK_UNAVAILABLE_INFORMATION)
0N/A ? "CK_UNAVAILABLE_INFORMATION"
0N/A : String.valueOf(ulFreePrivateMemory));
0N/A buffer.append(Constants.NEWLINE);
0N/A
0N/A buffer.append(Constants.INDENT);
0N/A buffer.append("hardwareVersion: ");
0N/A buffer.append(hardwareVersion.toString());
0N/A buffer.append(Constants.NEWLINE);
0N/A
0N/A buffer.append(Constants.INDENT);
0N/A buffer.append("firmwareVersion: ");
0N/A buffer.append(firmwareVersion.toString());
0N/A buffer.append(Constants.NEWLINE);
0N/A
0N/A buffer.append(Constants.INDENT);
0N/A buffer.append("utcTime: ");
0N/A buffer.append(new String(utcTime));
0N/A //buffer.append(Constants.NEWLINE);
0N/A
0N/A return buffer.toString() ;
0N/A }
0N/A
0N/A}