jdk/src/jdk.crypto.token/share/classes/sun/security/pkcs11/wrapper/CK_INFO.java
changeset 42693 6645de32a866
parent 25859 3317bb8137f4
equal deleted inserted replaced
42692:97247477b481 42693:6645de32a866
       
     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 {&nbsp;&nbsp;
       
    57  *    CK_VERSION cryptokiVersion;&nbsp;&nbsp;
       
    58  *    CK_UTF8CHAR manufacturerID[32];&nbsp;&nbsp;
       
    59  *    CK_FLAGS flags;&nbsp;&nbsp;
       
    60  *    CK_UTF8CHAR libraryDescription[32];&nbsp;&nbsp;
       
    61  *    CK_VERSION libraryVersion;&nbsp;&nbsp;
       
    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() {
       
   134         StringBuilder sb = new StringBuilder();
       
   135 
       
   136         sb.append(Constants.INDENT);
       
   137         sb.append("cryptokiVersion: ");
       
   138         sb.append(cryptokiVersion.toString());
       
   139         sb.append(Constants.NEWLINE);
       
   140 
       
   141         sb.append(Constants.INDENT);
       
   142         sb.append("manufacturerID: ");
       
   143         sb.append(new String(manufacturerID));
       
   144         sb.append(Constants.NEWLINE);
       
   145 
       
   146         sb.append(Constants.INDENT);
       
   147         sb.append("flags: ");
       
   148         sb.append(Functions.toBinaryString(flags));
       
   149         sb.append(Constants.NEWLINE);
       
   150 
       
   151         sb.append(Constants.INDENT);
       
   152         sb.append("libraryDescription: ");
       
   153         sb.append(new String(libraryDescription));
       
   154         sb.append(Constants.NEWLINE);
       
   155 
       
   156         sb.append(Constants.INDENT);
       
   157         sb.append("libraryVersion: ");
       
   158         sb.append(libraryVersion.toString());
       
   159         //buffer.append(Constants.NEWLINE);
       
   160 
       
   161         return sb.toString() ;
       
   162     }
       
   163 
       
   164 }