Updating a DRM policy with the Java API

Last update: 2023-10-02

To update a DRM policy with the Java API:

  1. Set up your development environment and include in your project all of the JAR files listed in Setting up the development environment.

  2. Create a DRM Policy instance and read the DRM policy from a file or database.

    Policy policy = new Policy(policyBytes);
  3. Update the DRM Policy object by setting its properties, such as its name and usage rules.

    // Change the DRM policy name.
    // Add DRM module restrictions to the play right
    for (Right r: policy.getRights()) {
        if (r instanceof PlayRight) {
            PlayRight pr = (PlayRight) r;
            // Disallow Linux versions up to and including 1.9.  Allow
            // all other OSes and Linux versions above 1.9
            VersionInfo toExclude = new VersionInfo();
            Collection<VersionInfo> exclusions = new ArrayList<VersionInfo>();
            ModuleRequirements drmRestrictions = new ModuleRequirements();
  4. Serialize the updated DRM Policy object and store it in a file or database.

    // Serialize the DRM policy.
    byte[] policyBytes = policy.getBytes();
    System.out.println("New DRM policy revision number: "
        +  policy.getRevision());
    // Write the DRM policy to a file.
    // Alternatively, the DRM policy may be stored in a database.
    FileOutputStream out = new FileOutputStream("demopolicy-updated.pol");

See com.adobe.flashaccess.samples.policy.UpdatePolicy in the Reference Implementation Command Line Tools samples directory for the source of this sample code.

On this page