Loading…

Kryptel/Java

Kryptel class

Declaration

package com.kryptel.storage;

public final class Kryptel {

  public static final class ContainerHandlers 

  public static boolean IsContainer(String path)

  public static ContainerHandlers GetContainerHandlers(String path)
}

Description

This class contains several helper functions. It also defines a large number of constants, which are of no interest for a library user and so are not discussed here.

ContainerHandlers

public static final class ContainerHandlers {
  public final int tag;
  public final UUID agent;
  public final UUID storage;

  ContainerHandlers(int tag, UUID agent, UUID storage)
}

This structure is returned by GetContainerHandlers function (see below). The tag field contains Kryptel.CONTAINER_TAG (0x07AA050B); the other fields contain component IDs of the agent and the storage handler that are needed to access the container.

IsContainer

public static boolean IsContainer(String path)

Returns true if the specified file is a Kryptel container. Note that it is not necessarily mean a file container; in order to determine the container type use GetContainerHandlers function.

GetContainerHandlers

public static ContainerHandlers GetContainerHandlers(String path)

Returns ContainerHandlers structure if the specified file is a Kryptel container, null otherwise. Use this function to open an existing container; don't assume it uses some specific handler. The example below illustrates the typical usage.

ContainerHandlers ch = GetContainerHandlers(contPath);
if (ch == null) throw new Exception("Not a valid container");
if (ch.agent == null) throw new Exception("Not a file container");

IKryptelComponent krComp = Loader.CreateComponent(ch.agent);
if (krComp == null) throw new Exception("Unknown agent or not a file container");

IEncryptedFileStorage stor = (IEncryptedFileStorage)krComp.GetInterface(IID_IEncryptedFileStorage);
if (stor == null) throw new Exception("Not a file container");
. . .

This example shows the standard sequence for accessing a file container – get the agent's component ID, instantiate it, and request its IEncryptedFileStorage interface. In order to determine the exact agent type call IKryptelComponent.ComponentType. Possible component type values are:

TYPE_STORAGE_AGENT | TYPE_FILE_AGENT
File agent, the only supported target is TARGET_DEFAULT. Does not store the original file paths so you must specify the target directory for a decryption operation.
TYPE_STORAGE_AGENT | TYPE_BACKUP_AGENT
Backup agent, supports multiple root directories (i.e. targets). Stores original paths.
TYPE_STORAGE_AGENT
Some other (non-file) agent.

Another way to determine the type of the agent is to obtain the file storage capabilities using function IEncryptedFileStorageInfo.GetFileStorageCapabilities. If the flag EFSTOR_TARGETS is set, then the agent is a backup one.