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

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

Go to previous page
Go to current chapter
Go to next page
PDF · Mobi · ePub

7.7 Unsealing a File

The following code demonstrates how to unseal a sealed file using the unseal method. The content to unseal can be provided as any type of; this example uses a file input stream. The sample code writes the resulting stream out to a file.

Example 7-6

import static oracle.irm.engine.content.sealing.SealingOperationsInstance.unseal;
 public class UnsealFile {
     public static void main(String[] args) throws Exception {
         // The user name and password are provided on the command line. In a production
         // system these details should be provided in a more secure manner, such
         // as prompting from the console, or reading from a secure source.
         final String username = args[0];
         final String password = args[1];
         // Configure an authenticator to provide the credentials for any network access
         Authenticator.setDefault(new Authenticator() {
             protected PasswordAuthentication getPasswordAuthentication() {
                 return new PasswordAuthentication(username, password.toCharArray());
         // The file to unseal
         String sealedFilename = args[2];
         // The unsealed file name
         String unsealedFilename = args[3];
         // Sealed file input stream
         FileInputStream inputStream = new FileInputStream(sealedFilename);
         // Unsealed file output stream        
         FileOutputStream outputStream = new FileOutputStream(unsealedFilename);
         // Unseal the sealed file
         unseal(inputStream, outputStream);
         // Close the file streams