Skip Headers
Oracle® Fusion Middleware Developer's Guide for Oracle IRM Server
11g Release 1 (11.1.1)

Part Number E12326-02
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to current chapter
Up
Go to next page
Next
View PDF

7.3 Peeking a Sealed File

The following code demonstrates how to extract the metadata from sealed content using the peek method. The sealed content can be provided as any type of java.io.InputStream; this example uses a file input stream. Once peeked, the file metadata, which includes the Classification details, can be examined. The sample code prints out the human-readable classification details (the labels) that were sealed into the content.

Th peek method does not attempt to check the public header against its declared signature. If the metadata has been altered post-sealing, this method will not throw an exception.

Example 7-2

import static oracle.irm.engine.content.sealing.SealingOperationsInstance.peek;
 
 import java.io.FileInputStream;
 import java.io.IOException;
 
 import oracle.irm.engine.content.sealing.ContentDescription;
 import oracle.irm.engine.core.classification.Classification;
 import oracle.irm.engine.core.general.Label;
 
 public class PeekFile {
 
     public static void main(String[] args) throws IOException {
 
         // The name of the file to peek is the first
         // command line argument
         FileInputStream stream = new FileInputStream(args[0]);
 
         // Perform the peek, providing a stream to the sealed file
         ContentDescription contentDescription = peek(stream);
 
         // Close the file stream
         stream.close();
 
         // Extract the classification details from the content
         Classification classification = contentDescription.getClassification();
 
         // Show all the labels sealed into content
         for (Label label : classification.getLabels()) {
             System.out.println(label.getLocale().getDisplayName() + " : " + label.getName());
         }
     }
 }