Class RACFInputStream

java.lang.Object
java.io.InputStream
com.ibm.crypto.zsecurity.provider.RACFInputStream
All Implemented Interfaces:
Closeable, AutoCloseable

public class RACFInputStream extends InputStream
This class extends InputStream and is used by com.ibm.crypto.provider.JceRACFKeyStore to read certificates and private keys from RACF.
  • Constructor Summary

    Constructors
    Constructor
    Description
    RACFInputStream(String userID, String ringid, char[] passwd)
    Constructs an instance of RACFInputStream.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Return the number of bytes of data that can be read from this input stream.
    void
    Closes this input stream and releases any system resources associated with the stream.
    getEntry(Hashtable<String,RACFObject> racfs, String key, char[] passwd)
    Retrieve a RACF com.ibm.crypto.provider.HWKeyEntry object from the given racfs hash table with the specified key alias.
    void
    mark(int readlimit)
    Marks the current position in this input stream.
    boolean
    Tests if this input stream supports the mark and reset methods.
    int
    Read the next byte of data from the input stream.
    int
    read(byte[] buffer)
    Read data from RACFInputStream and store it into the specified byte array.
    int
    read(byte[] buffer, int offset, int count)
    Read up to count bytes of data from RACFInputStream and store it into the specified byte array.
    void
    Repositions this stream to the position at the time the mark method was last called on this input stream.
    x2c(byte[] data)
    Convert the given byte array into a hexadecimal string representation.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RACFInputStream

      public RACFInputStream(String userID, String ringid, char[] passwd) throws IOException
      Constructs an instance of RACFInputStream. A RACFInputStream is used to access certificates and keys from a RACF key ring.

      During the construction of this object, all key and certificate entries are read from the specified RACF key ring and stored internally in a byte array, to be consumed later.

      Parameters:
      userID - a string containing the ID of the user that owns the keyring
      ringid - a string containing the name of the RACF key ring
      passwd - a character array containing the password for the keystore
      Throws:
      IOException - if there is an error retrieving keys and certificates from the RACF key ring.
  • Method Details

    • read

      public int read(byte[] buffer) throws IOException
      Read data from RACFInputStream and store it into the specified byte array.
      Overrides:
      read in class InputStream
      Parameters:
      buffer - the buffer into which the data is read
      Returns:
      the total number of bytes read into the buffer, or -1 if there is no more data.
      Throws:
      IOException - if some I/O error occurs.
    • read

      public int read(byte[] buffer, int offset, int count) throws IOException
      Read up to count bytes of data from RACFInputStream and store it into the specified byte array.
      Overrides:
      read in class InputStream
      Parameters:
      buffer - the buffer into which the data is read
      offset - the start offset in array buffer at which the data is written
      count - the maximum number of bytes to read
      Returns:
      the total number of bytes read into the buffer, or -1 if the buffer size is smaller than count or end of the stream is reached.
      Throws:
      IOException - if some I/O error occurs.
    • read

      public int read() throws IOException
      Read the next byte of data from the input stream.
      Specified by:
      read in class InputStream
      Returns:
      the next byte of data, or -1 if the end of the stream is reached.
      Throws:
      IOException - if an I/O error occurs.
    • available

      public int available()
      Return the number of bytes of data that can be read from this input stream.
      Overrides:
      available in class InputStream
      Returns:
      the number of bytes that can be read from this input stream.
    • markSupported

      public boolean markSupported()
      Tests if this input stream supports the mark and reset methods.
      Overrides:
      markSupported in class InputStream
      Returns:
      always false.
    • close

      public void close() throws IOException
      Closes this input stream and releases any system resources associated with the stream.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class InputStream
      Throws:
      IOException - if an I/O error occurs.
    • mark

      public void mark(int readlimit)
      Marks the current position in this input stream. This method is not supported and will act as a NOOP.
      Overrides:
      mark in class InputStream
      Parameters:
      readlimit - the maximum limit of bytes that can be read before the mark position becomes invalid
    • reset

      public void reset() throws IOException
      Repositions this stream to the position at the time the mark method was last called on this input stream. This method is not supported and will always throw an IOException.
      Overrides:
      reset in class InputStream
      Throws:
      IOException - is always thrown.
    • x2c

      public String x2c(byte[] data)
      Convert the given byte array into a hexadecimal string representation. The hexadecimal string representation will contain 16 bytes of formatted HEX per line, followed by the original byte data.
      Parameters:
      data - the byte array to convert
      Returns:
      a hexadecimal string representation of the given byte array.
    • getEntry

      public Object getEntry(Hashtable<String,RACFObject> racfs, String key, char[] passwd) throws IOException
      Retrieve a RACF com.ibm.crypto.provider.HWKeyEntry object from the given racfs hash table with the specified key alias.
      Parameters:
      racfs - hash table containing RACF keys and certificates
      key - alias of the RACF entry to get
      passwd - password protecting the RACF key
      Returns:
      the constructed com.ibm.crypto.provider.HWKeyEntry object.
      Throws:
      IllegalArgumentException - if racfs is null
      IOException - if an I/O error is detected.