com.docmosis.document
Class ExternalResourcePermissions

java.lang.Object
  extended by com.docmosis.document.ExternalResourcePermissions
All Implemented Interfaces:
Serializable

public class ExternalResourcePermissions
extends Object
implements Serializable

Specification of allowed external resources in the form of a white list of urls or url-prefixes. These permissions are applied against templates and converted documents to control whether external resources (such as embedded OLE objects) can reference external objects (like urls or file references). The permission is simply a true/false test and typically is applied to reading a url but could apply to any operation with a url.

Matching is done with the white list items as a prefix, so:
prefix="http://"
matches any url starting with "http://"

The * symbol allows an infix wildcard to be used also, so:
prefix = "https://*.docmosis.com/"
matches any sub domain of docmosis.com over https (but not https://docmosis.com because of the . after the *). To match a site and all its subdomains over https, two prefixes are required:
https://domain.com/ and https://*.domain.com/

Note the trailing slash is important because without it, "domain.com" would be equivalent to "domain.com.au"

See Also:
Serialized Form

Field Summary
static ExternalResourcePermissions ALL
          All permission granted
static ExternalResourcePermissions NONE
          No permission granted
 
Method Summary
 com.docmosis.document.ExternalResourcePermissionsCheckResult permitted(ExternalResourceCollection resources, boolean compareCaseInsensitive, boolean compareDecodeUrls)
          Determine whether the given resource urls are permitted based on this instances prefixes.
static com.docmosis.document.ExternalResourcePermissionsCheckResult permitted(ExternalResourcePermissions permission, ExternalResourceCollection resources, boolean compareCaseInsensitive, boolean compareDecodeUrls)
          Check whether permission is granted for all given resources.
 boolean permitted(String url, boolean compareCaseInsensitive, boolean compareDecodeUrls)
          Determine whether the given url is permitted based on this instances prefixes.
static ExternalResourcePermissions whitelist(String[] prefixes)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ALL

public static final ExternalResourcePermissions ALL
All permission granted


NONE

public static final ExternalResourcePermissions NONE
No permission granted

Method Detail

whitelist

public static ExternalResourcePermissions whitelist(String[] prefixes)

permitted

public static com.docmosis.document.ExternalResourcePermissionsCheckResult permitted(ExternalResourcePermissions permission,
                                                                                     ExternalResourceCollection resources,
                                                                                     boolean compareCaseInsensitive,
                                                                                     boolean compareDecodeUrls)
Check whether permission is granted for all given resources. If no permissions are given (eg null) then true will be returned if no resources are given.

Parameters:
permission -
resources -
compareCaseInsensitive -
compareDecodeUrls -
Returns:
permission result indicating whether all resources are permitted by the given permission

permitted

public com.docmosis.document.ExternalResourcePermissionsCheckResult permitted(ExternalResourceCollection resources,
                                                                              boolean compareCaseInsensitive,
                                                                              boolean compareDecodeUrls)
Determine whether the given resource urls are permitted based on this instances prefixes. Any non-permitted url results in a false response.

Parameters:
resources - the resources to test
compareCaseInsensitive - whether to ignore differences in character-case (true is more forgiving).
compareDecodeUrls - whether to apply decoding (eg %20 == space) when comparing (true is more forgiving).
Returns:
permission result indicating whether all resources are permitted by the given permission

permitted

public boolean permitted(String url,
                         boolean compareCaseInsensitive,
                         boolean compareDecodeUrls)
Determine whether the given url is permitted based on this instances prefixes. Any matching entry grants permission.

Parameters:
url - the url to test
compareCaseInsensitive - whether to ignore differences in character-case (true is more forgiving).
compareDecodeUrls - whether to apply decoding (eg %20 == space) when comparing (true is more forgiving).
Returns:
true if so


Copyright © 2014–2023 Docmosis Pty Ltd. All rights reserved.