- java.lang.Object
-
- java.io.InputStream
-
- com.ibm.crypto.zsecurity.provider.RACFInputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
public class RACFInputStream extends java.io.InputStream
This class extendsInputStream
and is used bycom.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 ofRACFInputStream
.
-
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 RACFcom.ibm.crypto.provider.HWKeyEntry
object from the givenracfs
hash table with the specifiedkey
alias.void
mark(int readlimit)
Marks the current position in this input stream.boolean
markSupported()
Tests if this input stream supports themark
andreset
methods.int
read()
Read the next byte of data from the input stream.int
read(byte[] buffer)
Read data fromRACFInputStream
and store it into the specified byte array.int
read(byte[] buffer, int offset, int count)
Read up tocount
bytes of data fromRACFInputStream
and store it into the specified byte array.void
reset()
Repositions this stream to the position at the time themark
method was last called on this input stream.java.lang.String
x2c(byte[] data)
Convert the given byte array into a hexadecimal string representation.
-
-
-
Constructor Detail
-
RACFInputStream
public RACFInputStream(java.lang.String userID, java.lang.String ringid, char[] passwd) throws java.io.IOException
Constructs an instance ofRACFInputStream
. ARACFInputStream
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 keyringringid
- a string containing the name of the RACF key ringpasswd
- 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 fromRACFInputStream
and store it into the specified byte array.- Overrides:
read
in classjava.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 tocount
bytes of data fromRACFInputStream
and store it into the specified byte array.- Overrides:
read
in classjava.io.InputStream
- Parameters:
buffer
- the buffer into which the data is readoffset
- the start offset in arraybuffer
at which the data is writtencount
- 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 thancount
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 classjava.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 classjava.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 themark
andreset
methods.- Overrides:
markSupported
in classjava.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 interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.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 classjava.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 themark
method was last called on this input stream. This method is not supported and will always throw anIOException
.- Overrides:
reset
in classjava.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 RACFcom.ibm.crypto.provider.HWKeyEntry
object from the givenracfs
hash table with the specifiedkey
alias.- Parameters:
racfs
- hash table containing RACF keys and certificateskey
- alias of the RACF entry to getpasswd
- password protecting the RACF key- Returns:
- the constructed
com.ibm.crypto.provider.HWKeyEntry
object. - Throws:
java.lang.IllegalArgumentException
- if racfs is nulljava.io.IOException
- if an I/O error is detected.
-
-