Class KabOutputStreamBuilder

java.lang.Object
com.tccc.kos.commons.kab.KabOutputStreamBuilder

public class KabOutputStreamBuilder extends Object
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 Details

    • KabOutputStreamBuilder

      public KabOutputStreamBuilder()
  • Method Details

    • build

      public KabOutputStream build() throws IOException
      Throws:
      IOException
    • setOutputStream

      public KabOutputStreamBuilder setOutputStream(OutputStream outputStream)
      The underlying output stream for the KAB to be written to can be set either by specifying the OutputStream or by specifying a File . This method allows the underlying OutputStream to be specified.
      Parameters:
      outputStream - the underlying stream to write to
    • setOutputFile

      public KabOutputStreamBuilder setOutputFile(File outputFile)
      The underlying output stream for the KAB to be written to can be set either by specifying the OutputStream or by specifying a File . This method allows the underlying File to be specified.
      Parameters:
      outputFile - the underlying file to write to
    • setType

      public KabOutputStreamBuilder setType(String type)
      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 a kos.* 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

      public KabOutputStreamBuilder setTag(String tag)
      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

      public KabOutputStreamBuilder setName(String name)
      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

      public KabOutputStreamBuilder setVersion(String version)
      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

      public KabOutputStreamBuilder setKeySet(KeySet keySet)
      Set the KeySet to use when signing the KAB.
      Parameters:
      keySet - the KeySet used to sign the resulting KAB
    • setAccessProvider

      public KabOutputStreamBuilder setAccessProvider(KabAccessProvider accessProvider)
      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, a KabAccessProvider can be provided to overlay ownership and permission information. If provided, when the KabOutputStream 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

      public KabOutputStreamBuilder setPrivateKey(PrivateKey privateKey)
      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

      public OutputStream getOutputStream()
    • getOutputFile

      public File getOutputFile()
    • getType

      public String getType()
    • getTag

      public String getTag()
    • getName

      public String getName()
    • getVersion

      public String getVersion()
    • getKeySet

      public KeySet getKeySet()
    • getAccessProvider

      public KabAccessProvider getAccessProvider()
    • getPrivateKey

      public PrivateKey getPrivateKey()