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