6.2 Using JDeveloper Generated Web Services Proxies

This section contains the following topics:

6.2.1 Introduction

The following section provides sample code that can be used with JAX-WS web service proxies generated using JDeveloper 11g.

6.2.2 Using the Samples

The JDeveloper 11g sample code comes packaged with a pre-generated set of web service proxy code so there is no need to generate the web service proxy code. The code samples in this document do not show this generated code, but assume this code is present in a package called generated. The easiest way to use the samples is to import them directly into a new or existing JDeveloper 11g project using the File > Import > Java Source menu.

Note:

Before running each sample, check the code to see what command line arguments the sample requires.

6.2.3 Generating a Web Service Proxy

If the web service proxy code needs to be generated by hand, these are the steps to follow within JDeveloper 11g:

  1. From the File menu, select New, then Business Tier, then Web Services, then Web Service Proxy.

  2. Select a JAX-WS Style client and press Next.

  3. Enter the required WSDL document URL as listed in the Web Services section of this document.

    For example, http://irm.example.com/irm_sealing/sealing_services?wsdl

    There is no need to copy the WSDL into the project.

  4. Press Next.

  5. Select Run against a service deployed to an external server.

  6. Press Finish.

6.2.4 Creating a Domain

The following code demonstrates how to create a domain. The sample code uses a fixed domain UUID so that all sample code can work against a known domain. A new domain would typically be given a new random UUID value. The authenticated user becomes the domain administrator. When a domain is created, a set of human-readable labels can be given to the domain for the target language audience.

Example 6-1

import static oracle.irm.j2ee.jws.rights.context.DomainOperations.getDomainOperationsEndpoint;
 
 import java.net.Authenticator;
 import java.net.PasswordAuthentication;
 import java.util.Locale;
 import java.util.UUID;
 
 import oracle.irm.engine.types.core.general.Label;
 import oracle.irm.engine.types.rights.context.Domain;
 import oracle.irm.j2ee.jws.rights.context.DomainOperationsEndpoint;
 
 public class SaveNewDomainWS {
 
     public static void main(String[] args) throws Exception {
 
         final String hostPort = args[0];
         final String username = args[1];
         final String password = args[2];
         
         // Configure an authenticator to provide the credentials
         // for the web service
         Authenticator.setDefault(new Authenticator() {
             @Override
             protected PasswordAuthentication getPasswordAuthentication() {
                 return new PasswordAuthentication(username, password.toCharArray());
             }
         });
         
         // Get the domain operations web service
         DomainOperationsEndpoint domainOperations = getDomainOperationsEndpoint(hostPort);
 
         // Domain has one English label
         Label label = new Label(Locale.ENGLISH, "Sample Domain", "This is a domain created from sample code.");
 
         // Domain UUID is fixed for sample code
         UUID domainUUID = UUID.fromString("6fab93fd-2858-461a-a0b3-34e261dbf8fd");
 
         Domain domain = new Domain(domainUUID,new Label[] { label });
         
         // Save the new domain
         domainOperations.saveNewDomain(domain);
     }
 }

6.2.5 Creating a Role

The following code demonstrates how to create a role. The sample code uses a fixed role UUID so that all sample code can work with a known role. A new role would typically be given a new random UUID value. The sample role is set up to allow all the content operations required by the sample code. When assigned to a user, this role allows sealing, unsealing, resealing and (validated) peeking. This is done by a providing an appropriate set of features and export constraints.

Example 6-2

import static oracle.irm.engine.core.feature.FeatureConstants.OPEN_FEATURE_ID;
 import static oracle.irm.engine.core.feature.FeatureConstants.RESEAL_FEATURE_ID;
 import static oracle.irm.engine.core.feature.FeatureConstants.SEAL_FEATURE_ID;
 import static oracle.irm.j2ee.jws.rights.context.DocumentRoleOperations.getDocumentRoleOperationsEndpoint;
 
 import java.net.Authenticator;
 import java.net.PasswordAuthentication;
 import java.util.Locale;
 import java.util.UUID;
 
 import oracle.irm.engine.types.classifications.item.ItemConstraints;
 import oracle.irm.engine.types.core.feature.Feature;
 import oracle.irm.engine.types.core.general.Label;
 import oracle.irm.engine.types.core.license.LicenseCriteria;
 import oracle.irm.engine.types.core.time.TimePeriod;
 import oracle.irm.engine.types.rights.context.DocumentRole;
 import oracle.irm.engine.types.rights.context.DomainRef;
 import oracle.irm.j2ee.jws.rights.context.DocumentRoleOperationsEndpoint;
 
 public class SaveNewRoleWS {
 
     public static void main(String[] args) throws Exception {
 
         final String hostPort = args[0];
         final String username = args[1];
         final String password = args[2];
         
         // Configure an authenticator to provide the credentials
         // for the web service
         Authenticator.setDefault(new Authenticator() {
             @Override
             protected PasswordAuthentication getPasswordAuthentication() {
                 return new PasswordAuthentication(username, password.toCharArray());
             }
         });
         
         // Document Role UUID is fixed for sample code
         UUID documentRoleUUID = UUID.fromString("ee82c3f9-152b-440d-afd7-dbf36b0c8188");
 
         DocumentRole role = new DocumentRole();
         
         // The UUID value that identifies this role within the domain
         role.setUuid(documentRoleUUID);
 
         // Role has one English label
         Label label = new Label(Locale.ENGLISH, "Sample Role", "This is a role created from sample code.");
 
         // The human readable labels
         role.setLabels( new Label[] { label } );
 
         // This role allows the user to access content while offline by persisting licenses on the desktop
         role.setStorage(LicenseCriteria.Storage.PERSISTENT);
 
         // This role allows content to be saved in the clear (unsealing and copying)
         role.setExportConstraints(DocumentRole.ExportConstraints.NONE);
         
         // This role allows opening, sealing, resealing
         Feature open = new Feature(OPEN_FEATURE_ID, Feature.Use.IMMEDIATE, true);
         Feature seal = new Feature(SEAL_FEATURE_ID, Feature.Use.IMMEDIATE, true);
         Feature reseal = new Feature(RESEAL_FEATURE_ID, Feature.Use.IMMEDIATE, false);
         
         role.setFeatures( new Feature[] { open, seal, reseal });
         
         // Role allows document exclusions to be listed, by default all items are allowed
         role.setItemConstraints(ItemConstraints.Type.EXCLUSIONS);
         
         // This role allows content to be opened for one hour before refreshing the rights from the server
         TimePeriod value = new TimePeriod(1, TimePeriod.Units.HOURS);
         
         role.setRefreshPeriod(value);
         
         // This role has no additional time constraints
         role.setTimeSpans(null);
         
         // Get the document role operations web service
         DocumentRoleOperationsEndpoint roleOperations = getDocumentRoleOperationsEndpoint(hostPort);
 
         // Domain UUID is fixed for sample code
         UUID domainUUID = UUID.fromString("6fab93fd-2858-461a-a0b3-34e261dbf8fd");
 
         DomainRef domain = new DomainRef(domainUUID);
 
         // Save the new role
         roleOperations.saveNewRole(domain, role);
     }
 }

6.2.6 Creating a Context Template

The following code demonstrates how to create a context template. The sample code uses a fixed template UUID so that all sample code can work with a known template. A new template would typically be given a new random UUID value. The sample template has one role and is active. This template is used to create contexts in the create context code sample.

Example 6-3

import static oracle.irm.j2ee.jws.rights.context.ContextTemplateOperations.getContextTemplateOperationsEndpoint;
 
 import java.net.Authenticator;
 import java.net.PasswordAuthentication;
 import java.util.Locale;
 import java.util.UUID;
 
 import oracle.irm.engine.types.core.general.Label;
 import oracle.irm.engine.types.rights.context.ContextTemplate;
 import oracle.irm.engine.types.rights.context.DocumentRoleRef;
 import oracle.irm.engine.types.rights.context.DomainRef;
 import oracle.irm.j2ee.jws.rights.context.ContextTemplateOperationsEndpoint;
 
 public class SaveNewContextTemplateWS {
 
     public static void main(String[] args) throws Exception {
 
         final String hostPort = args[0];
         final String username = args[1];
         final String password = args[2];
         
         // Configure an authenticator to provide the credentials
         // for the web service
         Authenticator.setDefault(new Authenticator() {
             @Override
             protected PasswordAuthentication getPasswordAuthentication() {
                 return new PasswordAuthentication(username, password.toCharArray());
             }
         });
         
         // Context Template UUID is fixed for sample code
         UUID contextTemplateUUID = UUID.fromString("930876e6-a505-4a10-8d93-bc43d9a37c23");
 
         ContextTemplate template = new ContextTemplate();
         
         // The UUID value that identifies this role within the domain
         template.setUuid(contextTemplateUUID);
 
         // Context Template has one English label
         Label label = new Label(Locale.ENGLISH, "Sample Template", "This is a template created from sample code.");
 
         // The human readable labels
         template.setLabels( new Label[] { label } );
 
         // The template is active
         template.setStatus(ContextTemplate.Status.ACTIVE);
         
         // Domain UUID is fixed for sample code
         UUID domainUUID = UUID.fromString("6fab93fd-2858-461a-a0b3-34e261dbf8fd");
 
         DomainRef domain = new DomainRef(domainUUID);
 
         // Document Role UUID is fixed for sample code
         UUID documentRoleUUID = UUID.fromString("ee82c3f9-152b-440d-afd7-dbf36b0c8188");
 
         DocumentRoleRef documentRole = new DocumentRoleRef(documentRoleUUID, domain);
         
         // Template has one role
         template.setRoles( new DocumentRoleRef[] { documentRole });
         
         // Get the context template operations web service
         ContextTemplateOperationsEndpoint templateOperations = getContextTemplateOperationsEndpoint(hostPort);
 
         // Save the new template
         templateOperations.saveNewContextTemplate(domain, template);
     }
 }

6.2.7 Creating a Context

The following code demonstrates how to create a context from a context template. The sample code uses a fixed context template reference (information that identifies the template) and provides a fixed UUID value for the new context. The authenticated user becomes the context manager. The context is created with two labels, English and German. This context is used in the sample code that assigns a role, as well as the sealing, unsealing, resealing, reclassification and peeking code samples.

Example 6-4

import generated.ContextInstanceVisibility;
import generated.ContextOperations;
import generated.ContextOperationsService;
import generated.ContextTemplateRef;
import generated.DomainRef;
import generated.Label;
 
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
 
import javax.xml.ws.BindingProvider;
 
public class CreateContextFromTemplate {
 
    public static void main(String[] args) throws Exception {
 
        final String endpointAddress = args[0];
        final String username = args[1];
        final String password = args[2];
        
        // Configure an authenticator to provide the credentials
        // for the web service
        Authenticator.setDefault(new Authenticator() {
            @Override
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(username, password.toCharArray());
            }
        });
        
        // Get the content operations endpoint
        ContextOperationsService service = new ContextOperationsService();
        
        ContextOperations contextOperations = service.getContextOperations();
        
        // Set the end point address
        Map<String, Object> requestContext = ((BindingProvider)contextOperations).getRequestContext();
        
        requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddress);
        
        // Domain UUID is fixed for sample code
        DomainRef domain = new DomainRef();
        
        domain.setUuid("6fab93fd-2858-461a-a0b3-34e261dbf8fd");
        
        // Create the context template reference
        ContextTemplateRef templateRef = new ContextTemplateRef();
        
        templateRef.setDomain(domain);
        
        // Context Template UUID is for the "standard" template automatically installed with a domain
        templateRef.setUuid("930876e6-a505-4a10-8d93-bc43d9a37c23");
        
        templateRef.setDomain(domain);
        
        // Context UUID is fixed for sample code
        String contextUUID = "46f910d9-dd30-476e-b060-4d01f88f8b05";
 
        // Context has two labels, English and German
        Label english = new Label();
        
        english.setLocale(Locale.ENGLISH.toString());
        english.setName("Sample Classification");
        english.setDescription("Created from sample code.");
 
        Label german = new Label();
        
        german.setLocale(Locale.GERMAN.toString());
        german.setName("Beispielklassifikation");
        german.setDescription("Verursacht vom Beispielcode.");
        
        List<Label> labels = new ArrayList<Label>();
        
        labels.add(english);
        labels.add(german);
        
        // Create a context based on that template
        contextOperations.createContextFromTemplate(
            contextUUID, // context UUID value 
            templateRef, // context template
            labels, // labels
            ContextInstanceVisibility.DOMAIN, // visibility 
            null); // additional context managers
    }
}

6.2.8 Assigning a Role to a User

The following code demonstrates how to assign a role to a user. To assign a role, the role, context and user or group must be specified. If the role is restricted to individual items then items can also be specified as in the assign role method.

Example 6-5

import static oracle.irm.j2ee.jws.rights.context.DocumentRightOperations.getDocumentRightOperationsEndpoint;
 
 import java.net.Authenticator;
 import java.net.PasswordAuthentication;
 import java.net.URLEncoder;
 import java.util.UUID;
 
 import oracle.irm.engine.types.core.account.AccountRef;
 import oracle.irm.engine.types.rights.context.ContextInstanceRef;
 import oracle.irm.engine.types.rights.context.DocumentRoleRef;
 import oracle.irm.engine.types.rights.context.DomainRef;
 import oracle.irm.j2ee.jws.rights.context.DocumentRightOperationsEndpoint;
 
 public class AssignRoleWS {
 
     public static void main(String[] args) throws Exception {
 
         final String hostPort = args[0];
         final String username = args[1];
         final String password = args[2];
         
         // Configure an authenticator to provide the credentials
         // for the web service
         Authenticator.setDefault(new Authenticator() {
             @Override
             protected PasswordAuthentication getPasswordAuthentication() {
                 return new PasswordAuthentication(username, password.toCharArray());
             }
         });
 
         // Domain UUID is fixed for sample code
         UUID domainUUID = UUID.fromString("6fab93fd-2858-461a-a0b3-34e261dbf8fd");
         
         DomainRef domainRef = new DomainRef(domainUUID);
 
         // Document Role UUID is for the "Sample Role" role
         UUID documentRoleUUID = UUID.fromString("ee82c3f9-152b-440d-afd7-dbf36b0c8188");
         
         DocumentRoleRef roleRef = new DocumentRoleRef(documentRoleUUID, domainRef);
 
         // Context UUID is fixed for sample code
         UUID contextUUID = UUID.fromString("46f910d9-dd30-476e-b060-4d01f88f8b05");
 
         ContextInstanceRef contextInstanceRef = new ContextInstanceRef(contextUUID);
         
         // Get the document right operations endpoint
         DocumentRightOperationsEndpoint rightOperations = getDocumentRightOperationsEndpoint(hostPort);
 
         // Reference the account by user name
         AccountRef accountRef = new AccountRef("urn:user:" + URLEncoder.encode(username, "utf-8"));
 
         // Assign the role to the account
         rightOperations.assignRole(
             contextInstanceRef, 
             roleRef, 
             new AccountRef[] { accountRef }, 
             null); // no item constraints
     }
 }

6.2.9 Listing Rights Assigned to a User or Group

The following code demonstrates how to list the rights that have been assigned to a user or group. The code displays the role label and the context UUID from each right.

Example 6-6

import static oracle.irm.j2ee.jws.rights.context.DocumentRightOperations.getDocumentRightOperationsEndpoint;
 
 import java.net.Authenticator;
 import java.net.PasswordAuthentication;
 import java.net.URLEncoder;
 
 import oracle.irm.engine.types.classifications.item.ItemCode;
 import oracle.irm.engine.types.core.account.AccountRef;
 import oracle.irm.engine.types.rights.context.DocumentRight;
 import oracle.irm.j2ee.jws.rights.context.DocumentRightOperationsEndpoint;
 
 public class ListRightsByAccountWS {
 
     public static void main(String[] args) throws Exception {
 
         final String hostPort = args[0];
         final String username = args[1];
         final String password = args[2];
         
         // Configure an authenticator to provide the credentials
         // for the web service
         Authenticator.setDefault(new Authenticator() {
             @Override
             protected PasswordAuthentication getPasswordAuthentication() {
                 return new PasswordAuthentication(username, password.toCharArray());
             }
         });
 
         // Get the document right operations web service
         DocumentRightOperationsEndpoint rightOperations = getDocumentRightOperationsEndpoint(hostPort);
 
         // Reference the account by user name, allowed formats are
         //  urn:user:xxxx
         //  urn:group:xxxx
         //  00000000-0000-0000-0000-000000000000
         AccountRef accountRef = new AccountRef("urn:user:" + URLEncoder.encode(username, "utf-8"));
         
         // Get all of the rights assigned to the account
         DocumentRight[] rights = rightOperations.listRightsByAccount(accountRef);
 
         // Display a summary of each right
         for (DocumentRight right : rights) {
             System.out.println("Account: " + right.getAccount().getUuid());
             System.out.println(" Context: " + right.getContext().getUuid());
             System.out.println(" Role: " + right.getRole().getUuid());
 
             // Show items
             ItemCode[] itemCodes = right.getItemCodes();
             
             if (itemCodes != null) {
                 for (ItemCode itemCode : itemCodes) {
                     System.out.println(" ItemCode: " + itemCode.getValue());
                 }
             }
         }
     }
 }

6.2.10 Altering the Role Assigned to a User or Group

The following code demonstrates how to alter a role assignment using the reassignRole method over web services. The sample code adds an item code exclusion to a role assignment. Typically this method is used to alter the role, but as the sample code only has one demonstration role it shows how to alter the item restrictions.

Example 6-7

import static oracle.irm.j2ee.jws.rights.context.DocumentRightOperations.getDocumentRightOperationsEndpoint;
 
 import java.net.Authenticator;
 import java.net.PasswordAuthentication;
 import java.net.URLEncoder;
 
 import oracle.irm.engine.types.classifications.item.ItemCode;
 import oracle.irm.engine.types.core.account.AccountRef;
 import oracle.irm.engine.types.rights.context.DocumentRight;
 import oracle.irm.engine.types.rights.context.DocumentRightRef;
 import oracle.irm.engine.types.rights.context.DocumentRoleRef;
 import oracle.irm.engine.types.rights.context.DomainRef;
 import oracle.irm.j2ee.jws.rights.context.DocumentRightOperationsEndpoint;
 
 public class ReassignRoleWS {
 
     public static void main(String[] args) throws Exception {
 
         final String hostPort = args[0];
         final String username = args[1];
         final String password = args[2];
         
         // Configure an authenticator to provide the credentials
         // for the web service
         Authenticator.setDefault(new Authenticator() {
             @Override
             protected PasswordAuthentication getPasswordAuthentication() {
                 return new PasswordAuthentication(username, password.toCharArray());
             }
         });
 
         // Get the document right operations web service
         DocumentRightOperationsEndpoint rightOperations = getDocumentRightOperationsEndpoint(hostPort);
 
         // Reference the account by user name
         AccountRef accountRef = new AccountRef("urn:user:" + URLEncoder.encode(username, "utf-8"));
         
         // Get all rights assigned to the account
         DocumentRight[] rights = rightOperations.listRightsByAccount(accountRef);
 
         // Take the first one on the list
         DocumentRight right = rights[0];
 
         DocumentRightRef rightRef = new DocumentRightRef(right.getUuid());
 
         // Get a reference to the role to be reassigned
         DomainRef domainRef = right.getRole().getDomain();
 
         DocumentRoleRef roleRef = new DocumentRoleRef(right.getRole().getUuid(), domainRef);
 
         // Change the item exclusion list to contain one sample item
         ItemCode itemCode = new ItemCode();
         itemCode.setValue("sample-item-code");
 
         // Reassign the role to the account
         rightOperations.reassignRole(new DocumentRightRef[] { rightRef }, roleRef, new ItemCode[] { itemCode });
     }
 }

6.2.11 Sealing a File

The following code demonstrates how to seal a file. The content to seal can be provided as any type of InputStream; this example uses a file input stream. The sample writes the resulting stream out as a file with a sealed file name inferred from the unsealed file name. The file is sealed using the context classification system, specifying a context with a known UUID value and an item code.

Example 6-8

import static oracle.irm.engine.classifications.context.ContextConstants.CONTEXT_CLASSIFICATION_SYSTEM_UUID;
 import static oracle.irm.engine.content.type.ContentTypeOperationsInstance.getContentTypeFromPath;
 import static oracle.irm.engine.content.type.ContentTypeOperationsInstance.getSealedFileName;
 import static oracle.irm.j2ee.jws.content.sealing.SealingServices.getSealingServicesEndpoint;
 
 import java.io.File;
 import java.net.URI;
 import java.util.Date;
 import java.util.Map;
 import java.util.UUID;
 
 import javax.activation.DataHandler;
 import javax.activation.FileDataSource;
 import javax.xml.ws.BindingProvider;
 
 import oracle.irm.engine.content.type.ContentType;
 import oracle.irm.engine.types.classifications.context.ContextCookie;
 import oracle.irm.engine.types.classifications.context.ContextRef;
 import oracle.irm.engine.types.classifications.item.ItemCode;
 import oracle.irm.engine.types.content.sealing.SealingOptions;
 import oracle.irm.engine.types.core.classification.Classification;
 import oracle.irm.engine.types.core.classification.ClassificationSystemRef;
 import oracle.irm.j2ee.jws.content.sealing.SealingServicesEndpoint;
 
 import com.sun.xml.ws.developer.JAXWSProperties;
 import com.sun.xml.ws.developer.StreamingDataHandler;
 
 public class SealFile {
 
     public static void main(String[] args) throws Exception {
 
         String hostPort = args[0];
         String username = args[1];
         String password = args[2];
 
         // The server URI. e.g. https://irm.example.com/irm_desktop
         URI serverURI = URI.create(args[3]);
 
         // The filename to seal
         String filename = args[4];
 
         // Context UUID is fixed for sample code
         ContextRef context = new ContextRef(UUID.fromString("46f910d9-dd30-476e-b060-4d01f88f8b05"));
 
         // Provide an explicit item code value and time
         ItemCode itemCode = new ItemCode();
         itemCode.setValue(new File(filename).getName());
         itemCode.setTime(new Date());
 
         // Create a context cookie for the classification - this specifies which context to use as
         // well as the item code for the content.
         ContextCookie cookie = new ContextCookie();
         cookie.setContext(context);
         cookie.setItemCode(itemCode);
 
         // Create the classification details used in the sealing options
         Classification classification = new Classification();
 
         // For the context classification system the classification Id is the context UUID value.
         classification.setId("46f910d9-dd30-476e-b060-4d01f88f8b05");
 
         // Context classification system
         classification.setSystem(new ClassificationSystemRef(CONTEXT_CLASSIFICATION_SYSTEM_UUID));
 
         // As the key set is not known get the sealing process to automatically fill this in
         classification.setKeySet(null);
 
         // URL sealed into content that tells the desktop where to go to get licenses
         classification.setUri(serverURI);
 
         // Classification time set explicitly to the current time
         classification.setClassificationTime(new Date());
 
         // As the labels are not known get the sealing process to automatically fill these in
         classification.setLabels(null);
 
         // Set the context and item code details
         classification.setCookie(cookie);
 
         // The classification is the only mandatory property for sealing options
         SealingOptions sealingOptions = new SealingOptions();
 
         sealingOptions.setClassification(classification);
 
         // Get the MIME type of the file to seal, this is inferred from the unsealed file name
         ContentType contentType = getContentTypeFromPath(filename);
 
         String mimeType = contentType.getMimeTypes()[0];
 
         // Get the sealing services web service proxy
         SealingServicesEndpoint sealingServices = getSealingServicesEndpoint(hostPort);
 
         // Set the user name and password
         Map requestContext = ((BindingProvider)sealingServices).getRequestContext();
 
         requestContext.put(BindingProvider.USERNAME_PROPERTY, username);
         requestContext.put(BindingProvider.PASSWORD_PROPERTY, password);
 
         // Without this setting the client may get an java.lang.OutOfMemoryException
         // when large files are buffered into memory by the HTTP stack.
         //
         // For more information see:
         //  https://jax-ws.dev.java.net/guide/HTTP_client_streaming_support.html
         //  https://jax-ws.dev.java.net/guide/Large_Attachments.html
         requestContext.put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 4096);
 
         // Send the file contents to the server for sealing
         DataHandler input = new DataHandler(new FileDataSource(filename));
 
         StreamingDataHandler results = (StreamingDataHandler)sealingServices.seal(input, mimeType, sealingOptions);
 
         // Get the sealed equivalent of the unsealed filename
         String sealedFilename = getSealedFileName(filename);
 
         // Copy the downloaded file to the relevant location
         results.moveTo(new File(sealedFilename));
     }
 }

6.2.12 Peeking a Sealed File

The following code demonstrates how to extract the metadata from sealed content using the peek method. This method sends the sealed content to the sealing server, the server extracts the metadata and returns this information to the caller. The sealed content can be provided as any type of 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.

Example 6-9

import static oracle.irm.j2ee.jws.content.sealing.SealingServices.getSealingServicesEndpoint;
 
 import java.util.Map;
 
 import javax.activation.DataHandler;
 import javax.activation.FileDataSource;
 import javax.xml.ws.BindingProvider;
 
 import oracle.irm.engine.types.content.sealing.ContentDescription;
 import oracle.irm.engine.types.core.classification.Classification;
 import oracle.irm.engine.types.core.general.Label;
 import oracle.irm.j2ee.jws.content.sealing.SealingServicesEndpoint;
 
 import com.sun.xml.ws.developer.JAXWSProperties;
 
 public class PeekFile {
 
     public static void main(String[] args) throws Exception {
 
         String hostPort = args[0];
         String username = args[1];
         String password = args[2];
 
         // The name of the file to peek
         String filename = args[3];
 
         // Get the sealing services web service proxy
         SealingServicesEndpoint sealingServices = getSealingServicesEndpoint(hostPort);
 
         // Set the user name and password
         Map requestContext = ((BindingProvider)sealingServices).getRequestContext();
 
         requestContext.put(BindingProvider.USERNAME_PROPERTY, username);
         requestContext.put(BindingProvider.PASSWORD_PROPERTY, password);
 
         // Without this setting the client may get an java.lang.OutOfMemoryException
         // when large files are buffered into memory by the HTTP stack.
         //
         // For more information see:
         //  https://jax-ws.dev.java.net/guide/HTTP_client_streaming_support.html
         //  https://jax-ws.dev.java.net/guide/Large_Attachments.html
         requestContext.put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 4096);
 
         // Perform the peek, providing a stream to the sealed file
         DataHandler input = new DataHandler(new FileDataSource(filename));
 
         ContentDescription results = sealingServices.peek(input);
 
         // Extract the classification details from the content
         Classification classification = results.getClassification();
 
         // Show all the labels sealed into content (assumes labels are available)
         for (Label label : classification.getLabels()) {
             System.out.println(label.getLocale().getDisplayName() + " : " + label.getName());
         }
     }
 }

6.2.13 Peeking a Sealed File and Checking the Digital Signature

The following code demonstrates how to extract the metadata from sealed content using the validatedPeek method. This method sends the sealed content to the sealing server, the server extracts the metadata and returns this information to the caller. The sealed content can be provided as any type of 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.

Example 6-10

import static oracle.irm.j2ee.jws.content.sealing.SealingServices.getSealingServicesEndpoint;
 
 import java.util.Map;
 
 import javax.activation.DataHandler;
 import javax.activation.FileDataSource;
 import javax.xml.ws.BindingProvider;
 
 import com.sun.xml.ws.developer.JAXWSProperties;
 
 import oracle.irm.engine.types.content.sealing.ContentDescription;
 import oracle.irm.engine.types.core.classification.Classification;
 import oracle.irm.engine.types.core.general.Label;
 import oracle.irm.j2ee.jws.content.sealing.SealingServicesEndpoint;
 
 public class ValidatedPeekFile {
 
     public static void main(String[] args) throws Exception {
 
         String hostPort = args[0];
         String username = args[1];
         String password = args[2];
 
         // The name of the file to peek
         String filename = args[3];
 
         // Get the sealing services web service proxy
         SealingServicesEndpoint sealingServices = getSealingServicesEndpoint(hostPort);
 
         // Set the user name and password
         Map requestContext = ((BindingProvider)sealingServices).getRequestContext();
 
         requestContext.put(BindingProvider.USERNAME_PROPERTY, username);
         requestContext.put(BindingProvider.PASSWORD_PROPERTY, password);
 
         // Without this setting the client may get an java.lang.OutOfMemoryException
         // when large files are buffered into memory by the HTTP stack.
         //
         // For more information see:
         //  https://jax-ws.dev.java.net/guide/HTTP_client_streaming_support.html
         //  https://jax-ws.dev.java.net/guide/Large_Attachments.html
         requestContext.put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 4096);
 
         // Send the file contents to the server for peeking
         DataHandler input = new DataHandler(new FileDataSource(filename));
 
         ContentDescription results = sealingServices.validatedPeek(input);
 
         // Extract the classification details from the content
         Classification classification = results.getClassification();
 
         // Show all the labels sealed into content (assumes labels are available)
         for (Label label : classification.getLabels()) {
             System.out.println(label.getLocale().getDisplayName() + " : " + label.getName());
         }
     }
 }

6.2.14 Changing Item Restrictions Associated with a Right

The following code demonstrates how to alter the item locks or exclusions associated with a right. The sample code replaces one item code with two item codes.

Example 6-11

import static oracle.irm.j2ee.jws.rights.context.DocumentRightOperations.getDocumentRightOperationsEndpoint;
 
 import java.net.Authenticator;
 import java.net.PasswordAuthentication;
 import java.net.URLEncoder;
 import java.util.Date;
 
 import oracle.irm.engine.types.classifications.item.ItemCode;
 import oracle.irm.engine.types.core.account.AccountRef;
 import oracle.irm.engine.types.rights.context.DocumentRight;
 import oracle.irm.engine.types.rights.context.DocumentRightRef;
 import oracle.irm.j2ee.jws.rights.context.DocumentRightOperationsEndpoint;
 
 public class SaveChangesToItemsWS {
 
     public static void main(String[] args) throws Exception {
 
         final String hostPort = args[0];
         final String username = args[1];
         final String password = args[2];
         
         // Configure an authenticator to provide the credentials
         // for the web service
         Authenticator.setDefault(new Authenticator() {
             @Override
             protected PasswordAuthentication getPasswordAuthentication() {
                 return new PasswordAuthentication(username, password.toCharArray());
             }
         });
 
         // Get the document right operations web service
         DocumentRightOperationsEndpoint rightOperations = getDocumentRightOperationsEndpoint(hostPort);
 
         // Reference the account by user name
         AccountRef accountRef = new AccountRef("urn:user:" + URLEncoder.encode(username, "utf-8"));
         
         // Get all rights assigned to the account
         DocumentRight[] rights = rightOperations.listRightsByAccount(accountRef);
 
         // Take the first one on the list
         DocumentRight right = rights[0];
 
         DocumentRightRef rightRef = new DocumentRightRef(right.getUuid());
 
         // The save change method allows items to be added and/or removed in the same call.
         // It does this be comparing two sets of items and applying the differences.
         
         // Item codes
         ItemCode sampleItemCode = new ItemCode();
         sampleItemCode.setValue("sample-item-code");
         
         ItemCode sampleItemCodeOne = new ItemCode();
         sampleItemCodeOne.setValue("sample-item-code-one");
         sampleItemCodeOne.setTime(new Date());
         
         ItemCode sampleItemCodeTwo = new ItemCode();
         sampleItemCodeTwo.setValue("sample-item-code-two");
         sampleItemCodeTwo.setTime(new Date());
         
         // This example shows a delta where item "sample-item-code" is removed
         // and items "sample-item-code-one" and "sample-item-code-two" are added.
         ItemCode[] itemCodes = new ItemCode[] { sampleItemCode };
         ItemCode[] deltaItemCodes = new ItemCode[] { sampleItemCodeOne, sampleItemCodeTwo };
                  
         // Alter the items
         rightOperations.saveChangesToItems(new DocumentRightRef[] { rightRef },itemCodes, deltaItemCodes);
     }
 }

6.2.15 Unassigning Rights Assigned to a User

The following code demonstrates how to unassign rights that have been assigned to a user. The sample first lists all the rights directly assigned to the user and unassigns them. To unassign the right the authenticated user must be a context manager for the related context.

Example 6-12

import static oracle.irm.j2ee.jws.rights.context.DocumentRightOperations.getDocumentRightOperationsEndpoint;
 
 import java.net.Authenticator;
 import java.net.PasswordAuthentication;
 import java.net.URLEncoder;
 
 import oracle.irm.engine.types.core.account.AccountRef;
 import oracle.irm.engine.types.rights.context.DocumentRight;
 import oracle.irm.engine.types.rights.context.DocumentRightRef;
 import oracle.irm.j2ee.jws.rights.context.DocumentRightOperationsEndpoint;
 
 public class UnassignRightsWS {
 
     public static void main(String[] args) throws Exception {
 
         final String hostPort = args[0];
         final String username = args[1];
         final String password = args[2];
         
         // Configure an authenticator to provide the credentials
         // for the web service
         Authenticator.setDefault(new Authenticator() {
             @Override
             protected PasswordAuthentication getPasswordAuthentication() {
                 return new PasswordAuthentication(username, password.toCharArray());
             }
         });
 
         // Get the document right operations web service
         DocumentRightOperationsEndpoint rightOperations = getDocumentRightOperationsEndpoint(hostPort);
 
         // Reference the account by user name
         AccountRef accountRef = new AccountRef("urn:user:" + URLEncoder.encode(username, "utf-8"));
         
         // Get all rights assigned to the account
         DocumentRight[] rights = rightOperations.listRightsByAccount(accountRef);
 
         DocumentRightRef[] rightRefs = new DocumentRightRef[rights.length];
 
         for (int i = 0; i < rightRefs.length; ++i) {
             rightRefs[i] = new DocumentRightRef(rights[i].getUuid());
         }
 
         // Unassign the rights
         rightOperations.unassignRights(rightRefs);
     }
 }

6.2.16 Reclassifying a File

The following code demonstrates how to reclassify a sealed file using the reclassify method. The content to reclassify can be provided as any type of InputStream; this example uses a file input stream. The sample changes the labels of the classification and then writes the resulting stream out as a file.

Example 6-13

import static oracle.irm.j2ee.jws.content.sealing.SealingServices.getSealingServicesEndpoint;
 
 import java.io.File;
 import java.util.Locale;
 import java.util.Map;
 
 import javax.activation.DataHandler;
 import javax.activation.FileDataSource;
 import javax.xml.ws.BindingProvider;
 
 import oracle.irm.engine.types.content.sealing.ContentDescription;
 import oracle.irm.engine.types.core.classification.Classification;
 import oracle.irm.engine.types.core.general.Label;
 import oracle.irm.j2ee.jws.content.sealing.SealingServicesEndpoint;
 
 import com.sun.xml.ws.developer.JAXWSProperties;
 import com.sun.xml.ws.developer.StreamingDataHandler;
 
 public class ReclassifyFile {
 
        public static void main(String[] args) throws Exception {
 
         String hostPort = args[0];
         String username = args[1];
         String password = args[2];
 
         // Get the file to reclassify
         String filename = args[3];
 
         // Get the label to apply to the classification
         String labelName = args[4];
 
         // Get the sealing services web service proxy
         SealingServicesEndpoint sealingServices = getSealingServicesEndpoint(hostPort);
 
         // Set the user name and password
         Map requestContext = ((BindingProvider)sealingServices).getRequestContext();
 
         requestContext.put(BindingProvider.USERNAME_PROPERTY, username);
         requestContext.put(BindingProvider.PASSWORD_PROPERTY, password);
 
         // Without this setting the client may get an java.lang.OutOfMemoryException
         // when large files are buffered into memory by the HTTP stack.
         //
         // For more information see:
         //  https://jax-ws.dev.java.net/guide/HTTP_client_streaming_support.html
         //  https://jax-ws.dev.java.net/guide/Large_Attachments.html
         requestContext.put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 4096);
 
         // Peek the contents of the file to obtain the classification details
         DataHandler input = new DataHandler(new FileDataSource(filename));
 
         ContentDescription contentDescription = sealingServices.peek(input);
 
         // Extract the classification from the content description
         Classification classification = contentDescription.getClassification();
 
         // Replace the labels with one
         Label label = new Label(
             Locale.ENGLISH,
             labelName,
             null);
 
         classification.setLabels(new Label[] { label });
 
         // Reclassify the sealed file with the new classification
         StreamingDataHandler results = (StreamingDataHandler)sealingServices.reclassify(input, classification);
 
         // Copy the downloaded file to the relevant location
         results.moveTo(new File(filename));
        }
 }

6.2.17 Resealing a File with Different Custom Data

The following code demonstrates how to reseal a sealed file using the reseal method. The content to reseal can be provided as any type of InputStream; this example uses a file input stream. The sample adds XML-based custom data to the sealed file.

Example 6-14

import static oracle.irm.j2ee.jws.content.sealing.SealingServices.getSealingServicesEndpoint;
 
 import java.io.File;
 import java.util.Map;
 import java.util.UUID;
 
 import javax.activation.DataHandler;
 import javax.activation.FileDataSource;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.ws.BindingProvider;
 
 import oracle.irm.engine.types.content.sealing.CustomData;
 import oracle.irm.j2ee.jws.content.sealing.SealingServicesEndpoint;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
 import com.sun.xml.ws.developer.JAXWSProperties;
 import com.sun.xml.ws.developer.StreamingDataHandler;
 
 public class ResealFile {
 
        public static void main(String[] args) throws Exception {
 
         String hostPort = args[0];
         String username = args[1];
         String password = args[2];
 
         // Get the file to reseal
         String filename = args[3];
 
         // Get the sealing services web service proxy
         SealingServicesEndpoint sealingServices = getSealingServicesEndpoint(hostPort);
 
         // Set the user name and password
         Map requestContext = ((BindingProvider)sealingServices).getRequestContext();
 
         requestContext.put(BindingProvider.USERNAME_PROPERTY, username);
         requestContext.put(BindingProvider.PASSWORD_PROPERTY, password);
 
            // Without this setting the client may get an java.lang.OutOfMemoryException
            // when large files are buffered into memory by the HTTP stack.
            //
            // For more information see:
            //  https://jax-ws.dev.java.net/guide/HTTP_client_streaming_support.html
         //  https://jax-ws.dev.java.net/guide/Large_Attachments.html
            requestContext.put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 4096);
 
         // Custom data is provided as XML
         DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
         DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
         Document document = documentBuilder.newDocument();
 
         Element element = document.createElement("SampleCustomData");
         element.setTextContent("Some example custom data provided as an XML text element");
 
         CustomData data = new CustomData();
 
         // UUID identifies the custom data, in this example just use a random UUID value
         data.setUuid(UUID.randomUUID());
 
         // Custom data is XML document
         data.setData(element);
 
         // Send the sealed file contents to the server for resealing
         DataHandler input = new DataHandler(new FileDataSource(filename));
 
         StreamingDataHandler results = (StreamingDataHandler)sealingServices.reseal(input, new CustomData[] {data});
 
         // Copy the downloaded file to the relevant location
         results.moveTo(new File(filename));
        }
 }

6.2.18 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 InputStream; this example uses a file input stream. The sample writes the resulting unsealed stream out to a file.

Example 6-15

import static oracle.irm.j2ee.jws.content.sealing.SealingServices.getSealingServicesEndpoint;
 
 import java.io.File;
 import java.util.Map;
 
 import javax.activation.DataHandler;
 import javax.activation.FileDataSource;
 import javax.xml.ws.BindingProvider;
 
 import oracle.irm.j2ee.jws.content.sealing.SealingServicesEndpoint;
 
 import com.sun.xml.ws.developer.JAXWSProperties;
 import com.sun.xml.ws.developer.StreamingDataHandler;
 
 public class UnsealFile {
 
     public static void main(String[] args) throws Exception {
 
         String hostPort = args[0];
         String username = args[1];
         String password = args[2];
 
         // The file to unseal
         String sealedFilename = args[3];
 
         // The unsealed file name
         String unsealedFilename = args[4];
 
         // Get the sealing services web service proxy
         SealingServicesEndpoint sealingServices = getSealingServicesEndpoint(hostPort);
 
         // Set the user name and password
         Map requestContext = ((BindingProvider)sealingServices).getRequestContext();
 
         requestContext.put(BindingProvider.USERNAME_PROPERTY, username);
         requestContext.put(BindingProvider.PASSWORD_PROPERTY, password);
 
         // Without this setting the client may get an java.lang.OutOfMemoryException
         // when large files are buffered into memory by the HTTP stack.
         //
         // For more information see:
         //  https://jax-ws.dev.java.net/guide/HTTP_client_streaming_support.html
         //  https://jax-ws.dev.java.net/guide/Large_Attachments.html
         requestContext.put(JAXWSProperties.HTTP_CLIENT_STREAMING_CHUNK_SIZE, 4096);
 
         // Send the file contents to the server for unsealing
         DataHandler input = new DataHandler(new FileDataSource(sealedFilename));
 
         StreamingDataHandler results = (StreamingDataHandler)sealingServices.unseal(input);
 
         // Copy the downloaded file to the relevant location
         results.moveTo(new File(unsealedFilename));
     }
 }

6.2.19 Listing Classifications

The following code demonstrates how to list classification details from a sealing server using the listClassifications method. The sample code displays the list of Classifications details available to the authenticated user.

Example 6-16

import static oracle.irm.j2ee.jws.core.storage.DesktopServices.getDesktopServicesEndpoint;
 
 import java.net.Authenticator;
 import java.net.PasswordAuthentication;
 import java.net.URI;
 
 import oracle.irm.engine.types.core.classification.Classification;
 import oracle.irm.engine.types.core.general.Label;
 import oracle.irm.j2ee.jws.core.storage.DesktopServicesEndpoint;
 
 public class ListClassificationsWS {
 
     public static void main(String[] args) throws Exception {
 
         final String hostPort = args[0];
         final String username = args[1];
         final String password = args[2];
         
         // Configure an authenticator to provide the credentials
         // for the web service
         Authenticator.setDefault(new Authenticator() {
             @Override
             protected PasswordAuthentication getPasswordAuthentication() {
                 return new PasswordAuthentication(username, password.toCharArray());
             }
         });
 
         // The server URI. e.g. https://irm.example.com/irm_desktop
         URI serverURI = URI.create(args[3]);
 
         // Get the desktop services web service
         DesktopServicesEndpoint desktopServices = getDesktopServicesEndpoint(hostPort);
 
         // Synchronize with the specified server
         Classification[] classifications = desktopServices.listClassifications(serverURI);
 
         // Display the labels of the classifications
         for (Classification classification : classifications) {
 
             for (Label label : classification.getLabels()) {
                 System.out.println(label.getLocale().getDisplayName() + " : " + label.getName());
             }
         }
     }
 }

6.2.20 Searching the Context Journal Using Web Services

The following code demonstrates how to search the content usage for context classified content. The sample code searches for all entries for the last twenty-four hours and displays a short summary for the first one hundred entries.

Example 6-17

import generated.ContextJournalEntry;
import generated.ContextOperations;
import generated.ContextOperationsService;
import generated.PageRange;
import generated.TimeRange;
 
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Map;
 
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.ws.BindingProvider;
 
public class SearchJournal {
 
    public static void main(String[] args) throws Exception {
 
        // The server address. e.g. https://irm.example.com
        final String endpointAddress = args[0];
        final String username = args[1];
        final String password = args[2];
        
        // Configure an authenticator to provide the credentials
        // for the web service
        Authenticator.setDefault(new Authenticator() {
            @Override
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(username, password.toCharArray());
            }
        });
        
        // Get the content operations endpoint
        ContextOperationsService service = new ContextOperationsService();
        
        ContextOperations contextOperations = service.getContextOperations();
        
        // Set the end point address
        Map<String, Object> requestContext = ((BindingProvider)contextOperations).getRequestContext();
        
        requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddress);
 
        // Use a calendar to work out the time range
        GregorianCalendar calendar = new GregorianCalendar();
        
        DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
 
        // Search for all records from the last 24 hours
        XMLGregorianCalendar end = datatypeFactory.newXMLGregorianCalendar(calendar);
 
        calendar.add(Calendar.DAY_OF_MONTH, -1);
        
        XMLGregorianCalendar begin = datatypeFactory.newXMLGregorianCalendar(calendar);
        
        TimeRange timeRange = new TimeRange();
        
        timeRange.setBegin(begin);
        timeRange.setEnd(end);
 
        // Search the context journal
        PageRange pageRange = new PageRange();
        
        pageRange.setFirst(1);
        pageRange.setLast(100);
        
        List<ContextJournalEntry> journalResults = contextOperations.searchJournal(
            null, // no accounts filter
            null, // no item codes filter
            timeRange, 
            pageRange, 
            null); // no sorting details
 
        if (journalResults.size() == 0)
            return;
 
        // Display the timestamp, URI and and feature for each entry
        for (ContextJournalEntry entry : journalResults) {
            
            System.out.print("Timestamp : " + entry.getTime());
            System.out.print(" Account   : " + entry.getAccount().getName());
            System.out.print(" Content   : " + (entry.getUri() != null ? entry.getUri() : ""));
            System.out.print(" Feature   : " + entry.getFeature().getId());
        }
    }
}

6.2.21 Checking in Licenses

The following code demonstrates how to check in licenses currently checked out to a sealing server. When the sealing server processes content it will usually check out licenses for the authenticated user. These licenses can no longer be used from other locations (for example, the Oracle IRM Desktop) until they expire or are manually checked in.

Example 6-18

import static oracle.irm.j2ee.jws.core.storage.DesktopServices.getDesktopServicesEndpoint;
 
 import java.net.Authenticator;
 import java.net.PasswordAuthentication;
 import java.net.URI;
 
 import oracle.irm.j2ee.jws.core.storage.DesktopServicesEndpoint;
 
 public class CheckInWS {
 
     public static void main(String[] args) {
 
         final String hostPort = args[0];
         final String username = args[1];
         final String password = args[2];
         
         // Configure an authenticator to provide the credentials
         // for the web service
         Authenticator.setDefault(new Authenticator() {
             @Override
             protected PasswordAuthentication getPasswordAuthentication() {
                 return new PasswordAuthentication(username, password.toCharArray());
             }
         });
         
         // Get the desktop services web service
         DesktopServicesEndpoint desktopServices = getDesktopServicesEndpoint(hostPort);
 
         // The server URI. e.g. https://irm.example.com/irm_desktop
         URI serverURI = URI.create(args[3]);
 
         // Check in all the licenses currently within the
         // desktop store for the given server
         desktopServices.checkIn(serverURI);
     }

6.2.22 Deleting a Domain

The following code demonstrates how to delete a domain. The sample code uses a fixed domain UUID for the new domain so that all sample code can work with a known domain. A new domain would typically be given a new random UUID value. The authenticated user must be a domain administrator. When a domain is deleted all the associated roles, templates and contexts are also deleted.

Example 6-19

import generated.DomainOperations;
import generated.DomainOperationsService;
import generated.DomainRef;
 
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.util.Map;
 
import javax.xml.ws.BindingProvider;
 
public class DeleteDomain {
 
    public static void main(String[] args) throws Exception {
 
        final String endpointAddress = args[0];
        final String username = args[1];
        final String password = args[2];
        
        // Configure an authenticator to provide the credentials
        // for the web service
        Authenticator.setDefault(new Authenticator() {
            @Override
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(username, password.toCharArray());
            }
        });
        
        // Get the domain operations web service
        DomainOperationsService service = new DomainOperationsService();
        
        DomainOperations domainOperations = service.getDomainOperations();
        
        // Set the end point address
        Map<String, Object> requestContext = ((BindingProvider)domainOperations).getRequestContext();
        
        requestContext.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointAddress);
        
        // Domain UUID is fixed for sample code
        DomainRef domain = new DomainRef();
        
        domain.setUuid("6fab93fd-2858-461a-a0b3-34e261dbf8fd");
        
        // Delete the domain using the domain reference
        domainOperations.deleteDomain(domain);
    }
}