Skip to main content

SecurityLimitAction Enum

Lists values that specify the action that the API takes when it detects a security loading limit violation.

Declaration

public enum SecurityLimitAction extends Enum<SecurityLimitAction> implements IIntEnum

Members

Name Description
CONTINUE

Continues loading the document.

THROW

Stops loading the document and throws an exception.

fromValue(int value)

Returns the SecurityLimitAction enumeration value that corresponds to the specified integer value.

getName()

Returns the name of the enumeration constant.

getValue()

Returns the integer value associated with the enumeration constant.

toString()

Returns the string representation of the enumeration constant.

valueOf(String name)

Returns the enum constant with the specified name.

values()

Returns available constants.

Remarks

Refer to the following help topic for additional information: Secure Presentation Processing.

The following code snippet configures loading options, handles security violations, and loads a presentation with the specified security settings. The example throws an exception if the presentation exceeds a configured limit or contains restricted content, and logs the violation to the console:

package presentation;

import com.devexpress.docs.office.*;
import com.devexpress.docs.presentation.*;

import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {

        // Create load options.
        LoadOptions loadOptions = new LoadOptions();

        // Configure security loading limits.
        PresentationSecurityLoadingLimits limits = new PresentationSecurityLoadingLimits();
        limits.setMaxFileSize(50L * 1024 * 1024);
        limits.setMaxSlideCount(100);
        limits.setMaxShapeCountPerSlide(500);

        loadOptions.setSecurityLoadingLimits(limits);

        // Configure security loading options.
        PresentationSecurityLoadingOptions securityLoadingOptionsOptions = new PresentationSecurityLoadingOptions();
        securityLoadingOptionsOptions.setRemoveMacros(true);
        securityLoadingOptionsOptions.setRemoveOleObjects(true);
        securityLoadingOptionsOptions.setRemoveActiveXContent(true);
        securityLoadingOptionsOptions.setRemoveCustomXMLParts(true);

        loadOptions.setSecurityLoadingOptions(securityLoadingOptionsOptions);

        // Handle security loading violations.
        loadOptions.setSecurityLoadingHandler(new ISecurityLoadingHandler() {
            @Override
            public SecurityLimitAction handleLimitExceeded(
                    SecurityLimitExceededParams parameters) {

                System.out.println("Security limit exceeded: " + parameters.getPropertyName());
                return SecurityLimitAction.THROW;
            }

            @Override
            public SecurityViolationAction handleOptionsViolation(
                    SecurityOptionsViolationParams parameters) {

                System.out.println("Security option violated: " + parameters.getPropertyName());
                return SecurityViolationAction.REMOVE;
            }
        });

        try(FileInputStream inputStream = new FileInputStream("Presentation.pptx");
            Presentation presentation = new Presentation(inputStream, loadOptions)) {

            //...
        }
    }
}

Implements

com.devexpress.java.enums.IIntEnum

Inherited Members

java.lang.Enum.<T>valueOf(java.lang.Class<T>,java.lang.String)
java.lang.Enum.clone()
java.lang.Enum.compareTo(E)
java.lang.Enum.describeConstable()
java.lang.Enum.equals(java.lang.Object)
java.lang.Enum.finalize()
java.lang.Enum.getDeclaringClass()
java.lang.Enum.hashCode()
java.lang.Enum.name()
java.lang.Enum.ordinal()
java.lang.Enum.toString()
java.lang.Object.getClass()
java.lang.Object.notify()
java.lang.Object.notifyAll()
java.lang.Object.wait()
java.lang.Object.wait(long)
java.lang.Object.wait(long,int)

Inheritance

Object
java.lang.Enum
SecurityLimitAction