Package com.tccc.kos.commons.kab
Class KabOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
com.tccc.kos.commons.kab.KabOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
Output stream for creating an archive.
- Version:
- Jun-18-22
-
Constructor Summary
ConstructorsConstructorDescriptionKabOutputStream
(File file, String identifier, String type, String qualifier, String name, String version, KeySet keySet, KabAccessProvider accessProvider) Output a kab to the specified file.KabOutputStream
(OutputStream os, String identifier, String type, String qualifier, String name, String version, KeySet keySet, KabAccessProvider accessProvider) Create an output stream that writes a kab file. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Create a new dir entry.void
Create a new file entry.void
close()
void
copy
(InputStream is) Copy the specified input stream to the output stream.void
removeEntry
(String path) Remove an existing entry.void
write
(byte[] b, int off, int len) void
write
(int b) Methods inherited from class java.io.FilterOutputStream
flush, write
Methods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
KabOutputStream
public KabOutputStream(OutputStream os, String identifier, String type, String qualifier, String name, String version, KeySet keySet, KabAccessProvider accessProvider) throws IOException Create an output stream that writes a kab file. The certPath and key parameters much match in that key must be the private key for the first cert in certPath as the private key is used to generate the signature and the certPath is used to verify it.- Parameters:
os
- the underlying output stream to write toidentifier
- unique kab identifier (typically uuid or hash)type
- kab typequalifier
- user specified qualifiername
- display nameversion
- version of kab contentskeySet
- used to sign the kabaccessProvider
- provide access control data to entries (optional)- Throws:
IOException
- if there is an underlying stream error
-
KabOutputStream
public KabOutputStream(File file, String identifier, String type, String qualifier, String name, String version, KeySet keySet, KabAccessProvider accessProvider) throws IOException Output a kab to the specified file.- Parameters:
file
- the file to write toidentifier
- unique kab identifier (typically uuid or hash)type
- kab typequalifier
- user specified qualifiername
- display nameversion
- version of kab contentskeySet
- used to sign the kabaccessProvider
- provide access control data to entries (optional)- Throws:
IOException
- if there is an underlying stream error
-
-
Method Details
-
addFile
Create a new file entry. If the path is the same as a previous entry, it will replace it but won't delete the content from the output stream.- Parameters:
path
- the path of the file
-
addDir
Create a new dir entry.- Parameters:
path
- the path of the directory
-
removeEntry
Remove an existing entry. This simply removes the entry from the master archive directory but leaves the bytes in the file which makes them unaccessible.- Parameters:
path
- the path of the entry to remove
-
copy
Copy the specified input stream to the output stream. This is an easy way to create an entry and then copy a file to the kab. This does not close the input stream when done.- Parameters:
is
- the input stream to copy to the kab- Throws:
IOException
-
write
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterOutputStream
- Throws:
IOException
-