Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| IAIK PKCS#11 Wrapper Demo version 1.2.16
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## demo.pkcs.pkcs11
Class Util

    java.lang.Object
      demo.pkcs.pkcs11.Util

public class Util
extends Object

This class contains only static methods. It is the place for all functions that are used by several classes in this package.

Field Summary
`protected static Hashtable` | `mechansimCodes_` Maps mechanism strings to their codes as Long.

Constructor Summary
`Util()`

Method Summary
`static Long` | `mechanismCodeToString(String mechansimName)` Converts the names of mechanisms to their long value code.
`static Session` | `openAuthorizedSession(Token token, boolean rwSession, PrintWriter output, BufferedReader input)` Opens an authorized session for the given token.
`static KeyAndCertificate` | `selectKeyAndCertificate(Session session, Key keyTemplate, PrintWriter output, BufferedReader input)` Lists all keys that match the given key template and lets the user choose one, if there is more than one.
`static Token` | `selectToken(Module pkcs11Module, PrintWriter output, BufferedReader input)` Lists all available tokens of the given module and lets the user select one, if there is more than one available.
`static String` | `toString(X509PublicKeyCertificate certificate)` Gets a string representation of the given PKCS#11 certificate.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### mechansimCodes_

    protected static Hashtable mechansimCodes_

  Maps mechanism strings to their codes as Long.

Constructor Detail

### Util

    public Util()

Method Detail

### mechanismCodeToString

    public static Long mechanismCodeToString(String mechansimName)

  Converts the names of mechanisms to their long value code.

  Parameters:
    `mechansimName` - The name of the mechanism to get the code; e.g. "CKM_RSA_PKCS".
  Returns:
    The code of the mechanism or null, if this name is unknown.
  Preconditions
    (mechansimName <> null)
  Postconditions

### selectToken

    public static Token selectToken(Module pkcs11Module,
                                    PrintWriter output,
                                    BufferedReader input)
                             throws TokenException,
                                    IOException

  Lists all available tokens of the given module and lets the user select one, if there is more than one available.

  Parameters:
    `pkcs11Module` - The PKCS#11 module to use.
    `output` - The output stream to write the user prompts to.
    `input` - The input stream where to read user input from.
  Returns:
    The selected token or null, if no token is available or the user canceled the action.
  Throws:
    `TokenException` - If listing the tokens failed.
    `IOException` - If writing a user prompt faild or if reading user input failed.
  Preconditions
    (pkcs11Module <> null) and (output <> null) and (input <> null)
  Postconditions

### openAuthorizedSession

    public static Session openAuthorizedSession(Token token,
                                                boolean rwSession,
                                                PrintWriter output,
                                                BufferedReader input)
                                         throws TokenException,
                                                IOException

  Opens an authorized session for the given token. If the token requires the user to login for private operations, the method loggs in the user.

  Parameters:
    `token` - The token to open a session for.
    `rwSession` - If the session should be a read-write session. This may be Token.SessionReadWriteBehavior.RO_SESSION or Token.SessionReadWriteBehavior.RW_SESSION.
    `output` - The output stream to write the user prompts to.
    `input` - The input stream where to read user input from.
  Returns:
    The selected token or null, if no token is available or the user canceled the action.
  Throws:
    `TokenException` - If listing the tokens failed.
    `IOException` - If writing a user prompt faild or if reading user input failed.
  Preconditions
    (token <> null) and (output <> null) and (input <> null)
  Postconditions
    (result <> null)

### selectKeyAndCertificate

    public static KeyAndCertificate selectKeyAndCertificate(Session session,
                                                            Key keyTemplate,
                                                            PrintWriter output,
                                                            BufferedReader input)
                                                     throws TokenException,
                                                            IOException

  Lists all keys that match the given key template and lets the user choose one, if there is more than one. If there is a corresponding certificate for a key, this method displays the certificate for this key.

  Parameters:
    `session` - The session to use for key and certificate searching.
    `keyTemplate` - The template for searching for keys.
    `output` - The output stream to write the user prompts to.
    `input` - The input stream where to read user input from.
  Returns:
    The selected key or null, if there is no matching key or the user canceled the operation. The return object also contains a corresponding certificate, if there is one for the selected key.
  Throws:
    `TokenException` - If searching for keys or certificates failed.
    `IOException` - If writing a user prompt faild or if reading user input failed.
  Preconditions
    (session <> null) and (keyTemplate <> keyTemplate) and (output <> null) and (input <> null)
  Postconditions
    (result <> null)

### toString

    public static String toString(X509PublicKeyCertificate certificate)

  Gets a string representation of the given PKCS#11 certificate.

  Parameters:
    `certificate` - The PKCS#11 certificate.
  Returns:
    The string representing the certificate.
  Preconditions
  Postconditions

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| IAIK PKCS#11 Wrapper Demo version 1.2.16
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

IAIK JavaSecurity Website http://jce.iaik.tugraz.at/
IAIK at Graz University of Technology, Austria, Europe
Copyright 2001-2002, IAIK, Graz University of Technology, Inffeldgasse 16a, 8010 Graz, Austria. All Rights Reserved.