Package com.tccc.kos.commons.kab
Class KabOutputStreamBuilder
java.lang.Object
com.tccc.kos.commons.kab.KabOutputStreamBuilder
Builder to make it easier to create a
KabOutputStream
. Since
KabOutputStream
requires a large number of constructor parameters,
this builder provides a simple way to add only those parameters that are
needed using a fluent api, and the builder will fill in everything else
automatically.- Version:
- Jul-2-22
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
getName()
getTag()
getType()
setAccessProvider
(KabAccessProvider accessProvider) When building a KAB, each entry can be created using ownership and permission information.Set theKeySet
to use when signing the KAB.Set the name header property of the KAB.setOutputFile
(File outputFile) The underlying output stream for the KAB to be written to can be set either by specifying theOutputStream
or by specifying aFile
.setOutputStream
(OutputStream outputStream) The underlying output stream for the KAB to be written to can be set either by specifying theOutputStream
or by specifying aFile
.setPrivateKey
(PrivateKey privateKey) If any content in the KAB require encryption, a private key must be specified to enable encryption.Set the tag header property of the KAB.Set the type of the KAB.setVersion
(String version) Set the version header property of the KAB.
-
Constructor Details
-
KabOutputStreamBuilder
public KabOutputStreamBuilder()
-
-
Method Details
-
build
- Throws:
IOException
-
setOutputStream
The underlying output stream for the KAB to be written to can be set either by specifying theOutputStream
or by specifying aFile
. This method allows the underlyingOutputStream
to be specified.- Parameters:
outputStream
- the underlying stream to write to
-
setOutputFile
The underlying output stream for the KAB to be written to can be set either by specifying theOutputStream
or by specifying aFile
. This method allows the underlyingFile
to be specified.- Parameters:
outputFile
- the underlying file to write to
-
setType
Set the type of the KAB. The type of the KAB is typically used to determine what the KAB contains and how to use it. All core kOS types start with akos.*
prefix. Developers are free to define new types but may consider using an organization prefix to ensure KABs from other organizations, particularly those from the kOS Studio market, don't collide.- Parameters:
type
- the type of the resulting KAB
-
setTag
Set the tag header property of the KAB. This is developer defined and is typically used to add additional meta data to a KAB of a given type to help distinguish it from other KABs of the same type. In general, kOS internals don't use tag values so developers are free to use tags to implement policy.When publishing KABs to the kOS Studio market, it is common convention to record the qualifier of the artifact instance in the tag of the KAB. This allows developers to examine a particular KAB and identify which variant this KAB represents.
- Parameters:
tag
- the tag header value for the resulting KAB
-
setName
Set the name header property of the KAB. This is developer defined and is commonly used to record the source of the KAB or some other identifying information. kOS internals don't use name values so developers are free to use name values as needed.- Parameters:
name
- the name header value for the resulting KAB
-
setVersion
Set the version header property of the KAB. If not specified, the version will be "0.0.0". Versions should adhere to semantic version policies which dictate a maximum of three numbers and an optional label. However, it is possible to use any string as the version.When publishing a KAB using kOS Studio, several features of kOS Studio will not be available if the version does not adhere to semantic version format. Published artifacts derive the version from the version stored in the KAB being published.
The kOS publish tool will extract the version from this header by default. It is strongly recommended to populate this header with the correct version information when publishing.
- Parameters:
version
- the version header value for the resulting KAB
-
setKeySet
Set theKeySet
to use when signing the KAB.- Parameters:
keySet
- theKeySet
used to sign the resulting KAB
-
setAccessProvider
When building a KAB, each entry can be created using ownership and permission information. If this information is not readily available at the the entry is added, or the KAB is constructed by some other code where it's not possible to influence the entry creation parameters, aKabAccessProvider
can be provided to overlay ownership and permission information. If provided, when theKabOutputStream
is closed, every entry in the directory will be passed to the provider and the provider has the opportunity to set the ownership and permission information.- Parameters:
accessProvider
- optional provider to override ownership and permissions
-
setPrivateKey
If any content in the KAB require encryption, a private key must be specified to enable encryption. The encrypted content in the resulting KAB can only be accessed using the matching public key.- Parameters:
privateKey
- the private key to use for any encrypted KAB content
-
getOutputStream
-
getOutputFile
-
getType
-
getTag
-
getName
-
getVersion
-
getKeySet
-
getAccessProvider
-
getPrivateKey
-