org.jasig.portal.utils.uri
Class PrefixUriScrutinizer

java.lang.Object
  extended by org.jasig.portal.utils.uri.PrefixUriScrutinizer
All Implemented Interfaces:
Serializable, IUriScrutinizer

public final class PrefixUriScrutinizer
extends Object
implements IUriScrutinizer, Serializable

UriScrutinizer implementation matching URIs against allowed prefixes and disallowed prefixes to determine whether to block the URI.

The URI will be allowed if it is prefixed by at least one of the allowed prefixes and it is not prefixed by any of the blocked prefixes.

Instances of this class are immutable once constructed.

Instances of this class are threadsafe and serializable.

Since:
uPortal 2.5.1
See Also:
Serialized Form

Constructor Summary
PrefixUriScrutinizer(String[] allowPrefixesArg, String[] denyPrefixesArg)
          Create a new PrefixUriScrutinizer instance specifying the allowed URI prefixes and the blocked URI prefixes.
 
Method Summary
 List getAllowPrefixes()
          Get an unmodifiable List of the Strings allowed as prefixes to URIs scrutinized by this PrefixUriScrutinizer.
 List getDenyPrefixes()
          Get an unmodifiable List of the Strings explicitly denied as prefixes to URIs scrutinized by this PrefixUriScrutinizer.
static PrefixUriScrutinizer instanceFromParameters(String allowPrefixesArg, String denyPrefixesArg)
           
 void scrutinize(URI uriArg)
          Scrutinize a URI to determine if access to it should be blocked for reasons of policy.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PrefixUriScrutinizer

public PrefixUriScrutinizer(String[] allowPrefixesArg,
                            String[] denyPrefixesArg)
Create a new PrefixUriScrutinizer instance specifying the allowed URI prefixes and the blocked URI prefixes. Both arguments must not be null or contain null references. This instance will block all URIs if allowPrefixesArg is empty. This constructor will copy the argument arrays, normalizing the prefix content to all-lowercase.

Parameters:
allowPrefixesArg - non-null potentially empty array of Strings
denyPrefixesArg - non-null potentially empty array of Strings
Method Detail

instanceFromParameters

public static PrefixUriScrutinizer instanceFromParameters(String allowPrefixesArg,
                                                          String denyPrefixesArg)

scrutinize

public void scrutinize(URI uriArg)
                throws BlockedUriException
Description copied from interface: IUriScrutinizer
Scrutinize a URI to determine if access to it should be blocked for reasons of policy. Throws BlockedUriException if access to the URI should be blocked, conveying the reason for blockage. Blocking a URI is an exceptional and ideally rare circumstance which will usually abort whatever operation was being undertaken, and so this method throws on that exceptional circumstance.

Specified by:
scrutinize in interface IUriScrutinizer
Parameters:
uriArg - non-null URI for examination
Throws:
BlockedUriException - if access should be blocked

getAllowPrefixes

public List getAllowPrefixes()
Get an unmodifiable List of the Strings allowed as prefixes to URIs scrutinized by this PrefixUriScrutinizer.

Returns:
an unmodifiable List of Strings

getDenyPrefixes

public List getDenyPrefixes()
Get an unmodifiable List of the Strings explicitly denied as prefixes to URIs scrutinized by this PrefixUriScrutinizer.

Returns:
an unmodifiable potentially empty list of Strings

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2010 Jasig. All Rights Reserved.