jdk/src/jdk.crypto.token/share/classes/sun/security/pkcs11/wrapper/CK_INFO.java
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--
8171201: Drop java.compact$N aggregator modules 8171202: Rename jdk.crypto.pkcs11 and jdk.pack200 to end with Java letters Reviewed-by: alanb, erikj
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * reserved comment block
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT REMOVE OR ALTER!
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
/* Copyright  (c) 2002 Graz University of Technology. All rights reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * Redistribution and use in  source and binary forms, with or without
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * modification, are permitted  provided that the following conditions are met:
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * 1. Redistributions of  source code must retain the above copyright notice,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 *    this list of conditions and the following disclaimer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * 2. Redistributions in  binary form must reproduce the above copyright notice,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *    this list of conditions and the following disclaimer in the documentation
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 *    and/or other materials provided with the distribution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * 3. The end-user documentation included with the redistribution, if any, must
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *    include the following acknowledgment:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *    "This product includes software developed by IAIK of Graz University of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 *     Technology."
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 *    Alternately, this acknowledgment may appear in the software itself, if
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 *    and wherever such third-party acknowledgments normally appear.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * 4. The names "Graz University of Technology" and "IAIK of Graz University of
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 *    Technology" must not be used to endorse or promote products derived from
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 *    this software without prior written permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * 5. Products derived from this software may not be called
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 *    "IAIK PKCS Wrapper", nor may "IAIK" appear in their name, without prior
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 *    written permission of Graz University of Technology.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 *  THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE LICENSOR BE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *  OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 *  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 *  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 *  OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *  POSSIBILITY  OF SUCH DAMAGE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
package sun.security.pkcs11.wrapper;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * class  CK_INFO provides general information about Cryptoki.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * <B>PKCS#11 structure:</B>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 *  typedef struct CK_INFO {&nbsp;&nbsp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *    CK_VERSION cryptokiVersion;&nbsp;&nbsp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *    CK_UTF8CHAR manufacturerID[32];&nbsp;&nbsp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *    CK_FLAGS flags;&nbsp;&nbsp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 *    CK_UTF8CHAR libraryDescription[32];&nbsp;&nbsp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *    CK_VERSION libraryVersion;&nbsp;&nbsp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *  } CK_INFO;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * @author Karl Scheibelhofer <Karl.Scheibelhofer@iaik.at>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * @author Martin Schlaeffer <schlaeff@sbox.tugraz.at>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
public class CK_INFO {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     * Cryptoki interface version number<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
     * <B>PKCS#11:</B>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     *   CK_VERSION cryptokiVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    public CK_VERSION cryptokiVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * ID of the Cryptoki library manufacturer. must be blank
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     * padded - only the first 32 chars will be used<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * <B>PKCS#11:</B>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
     *   CK_UTF8CHAR manufacturerID[32];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    public char[] manufacturerID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     * bit flags reserved for future versions. must be zero<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     * <B>PKCS#11:</B>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     *   CK_FLAGS flags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    public long flags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
/* libraryDescription and libraryVersion are new for v2.0 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * must be blank padded - only the first 32 chars will be used<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * <B>PKCS#11:</B>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     *   CK_UTF8CHAR libraryDescription[32];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    public char[] libraryDescription;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * Cryptoki library version number<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * <B>PKCS#11:</B>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * <PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     *   CK_VERSION libraryVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * </PRE>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    public CK_VERSION libraryVersion;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    public CK_INFO(CK_VERSION cryptoVer, char[] vendor, long flags,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                   char[] libDesc, CK_VERSION libVer) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        this.cryptokiVersion = cryptoVer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        this.manufacturerID = vendor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        this.flags = flags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        this.libraryDescription = libDesc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        this.libraryVersion = libVer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * Returns the string representation of CK_INFO.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * @return the string representation of CK_INFO
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        //buffer.append(Constants.NEWLINE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
24969
afa6934dd8e8 8041679: Replace uses of StringBuffer with StringBuilder within core library classes
psandoz
parents: 2
diff changeset
   161
        return sb.toString() ;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
}