Class RACFInputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable

    public class RACFInputStream
    extends java.io.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​(java.lang.String userID, java.lang.String ringid, char[] passwd)
      Constructs an instance of RACFInputStream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int available()
      Return the number of bytes of data that can be read from this input stream.
      void close()
      Closes this input stream and releases any system resources associated with the stream.
      java.lang.Object getEntry​(java.util.Hashtable racfs, java.lang.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 markSupported()
      Tests if this input stream supports the mark and reset methods.
      int read()
      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 reset()
      Repositions this stream to the position at the time the mark method was last called on this input stream.
      java.lang.String x2c​(byte[] data)
      Convert the given byte array into a hexadecimal string representation.
      • Methods inherited from class java.io.InputStream

        nullInputStream, readAllBytes, readNBytes, readNBytes, skip, transferTo
      • Methods inherited from class java.lang.Object

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

      • RACFInputStream

        public RACFInputStream​(java.lang.String userID,
                               java.lang.String ringid,
                               char[] passwd)
                        throws java.io.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:
        java.io.IOException - if there is an error retrieving keys and certificates from the RACF key ring.
    • Method Detail

      • read

        public int read​(byte[] buffer)
                 throws java.io.IOException
        Read data from RACFInputStream and store it into the specified byte array.
        Overrides:
        read in class java.io.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:
        java.io.IOException - if some I/O error occurs.
      • read

        public int read​(byte[] buffer,
                        int offset,
                        int count)
                 throws java.io.IOException
        Read up to count bytes of data from RACFInputStream and store it into the specified byte array.
        Overrides:
        read in class java.io.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:
        java.io.IOException - if some I/O error occurs.
      • read

        public int read()
                 throws java.io.IOException
        Read the next byte of data from the input stream.
        Specified by:
        read in class java.io.InputStream
        Returns:
        the next byte of data, or -1 if the end of the stream is reached.
        Throws:
        java.io.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 java.io.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 java.io.InputStream
        Returns:
        always false.
      • close

        public void close()
                   throws java.io.IOException
        Closes this input stream and releases any system resources associated with the stream.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.InputStream
        Throws:
        java.io.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 java.io.InputStream
        Parameters:
        readlimit - the maximum limit of bytes that can be read before the mark position becomes invalid
      • reset

        public void reset()
                   throws java.io.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 java.io.InputStream
        Throws:
        java.io.IOException - is always thrown.
      • x2c

        public java.lang.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 java.lang.Object getEntry​(java.util.Hashtable racfs,
                                         java.lang.String key,
                                         char[] passwd)
                                  throws java.io.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:
        java.lang.IllegalArgumentException - if racfs is null
        java.io.IOException - if an I/O error is detected.