3.4 Resealing

This section contains the following topics:

3.4.1 Resealing Using the Sealing Server

Resealing is the process of altering the custom metadata or editing the encrypted content. Oracle IRM Desktop allows certain formats, such as Microsoft Office, to be edited in sealed form. The process of saving edits is called resealing.

The sealing server supports resealing to update the custom metadata but does not support updating the encrypted content of the sealed file. Content is uploaded to the sealing server, the custom metadata is updated, and the sealed content is returned to the caller.

3.4.1.1 Uploading Content

For JAX-WS generated web service proxies, the content is provided as a DataHandler parameter. Using a data handler allows the web service stack to stream the binary content to the server without having to load the complete file into memory.

javax.activation.DataHandler input = new javax.activation.DataHandler(new FileDataSource("example.stml"));

The data source does not have to be a file.

3.4.1.2 Calling reseal

A call to reseal requires the sealed data (in the form of a DataHandler) and the custom data for the update. The following demonstrates how to reseal a sealed file using the reseal method adding XML-based custom data to the sealed file.

The XML based custom data is provided as an XML element.

Element element = document.createElement("SampleCustomData");
element.setTextContent("Some example custom data provided as an XML element containing this text");
 
CustomData data = new CustomData();
 
// UUID identifies the custom data, this example uses a fixed example UUID value
data.setUuid("7f79d1e8-fc07-464c-8477-834951e07060");
 
// Custom data is XML document
data.setData(element);

Then the reseal operation is called to reseal the content and re-sign the metadata.

SealingServices sealingServices = new SealingServicesService().getSealingServices(new javax.xml.ws.soap.MTOMFeature());
 
DataHandler results = sealingServices.reseal(input, new CustomData[] {data});

To call the reseal operation, the authenticated user needs rights that allow the reseal feature to be performed for the classification of the sealed content.

3.4.1.3 Extracting the Content

The DataHandler class can be used to write out the resealed content to an output stream of the programmer's choice. This example shows the resealed content being written out to a file.

java.io.FileOutputStream outputStream = new java.io.FileOutputStream("example.stml");
 
results.writeTo(outputStream);
 
outputStream.close();

3.4.2 Resealing Using the IRM Java API

Resealing is the process of altering the custom metadata or editing the encrypted content. Oracle IRM Desktop allows certain formats, such as Microsoft Office, to be edited in sealed form. The IRM Java API allows the custom metadata to be altered. Custom data is provided as an XML element, this code does not show how the XML element is created, just how to use a XML element with custom data. The Java API for XML Code Samples show how to create and manipulate XML documents.

org.w3c.dom.Element element = ...

Custom data entries are identified with a UUID value.

java.util.UUID uuid = java.util.UUID.fromString("7f79d1e8-fc07-464c-8477-834951e07060");

As sealed content can contain multiple custom data entries, each one must have a unique UUID value. This value can be used when peeking the content to identify the custom data. This example uses just one custom data entry.

import static oracle.irm.engine.content.sealing.CustomDataFactory.createCustomData;
import static oracle.irm.engine.content.sealing.CustomDataCollectionFactory.createCustomData;
import oracle.irm.engine.content.sealing.CustomData;
...
// Create custom data, identified by the UUID value
CustomData data = createCustomData(uuid, element);
 
// Resealing allows multiple custom data entries, and expects a collection type
java.util.Collection<CustomData> data = createCustomData(data)

Once the custom data has been created, the reseal operation can then be called to reseal the content and re-sign the metadata.

import oracle.irm.engine.content.sealing.CustomData;
...
// Sealed file provided as a file
java.io.InputStream input = new java.io.FileInputStream("sealed.stml");
 
// Resealed file written out to a file
java.io.OutputStream output = new java.io.FileInputStream("resealed.stml");
 
// Reseal the sealed content, altering the custom data
reseal(input, output, data);

To call the reseal operation, the authenticated user needs rights that allow the reseal feature to be performed for the classification of the sealed content.