Package com.browserup.bup.proxy
Class Whitelist
- java.lang.Object
-
- com.browserup.bup.proxy.Whitelist
-
public class Whitelist extends java.lang.ObjectA URL whitelist. This object is immutable and the list of matching patterns and the HTTP status code is unmodifiable after creation. Enabling, disabling, or modifying the whitelist can be safely and easily accomplished by updating the whitelist reference to a new whitelist.
-
-
Field Summary
Fields Modifier and Type Field Description static WhitelistWHITELIST_DISABLEDA disabled Whitelist.
-
Constructor Summary
Constructors Constructor Description Whitelist()Creates an empty, disabled Whitelist.Whitelist(int statusCode)Creates an empty, enabled whitelist with the specified response code.Whitelist(java.lang.String[] patterns, int statusCode)Deprecated.Whitelist(java.util.Collection<java.lang.String> patterns, int statusCode)Creates a whitelist for the specified patterns, returning the given statusCode when a URL does not match one of the patterns.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.util.Collection<java.util.regex.Pattern>getPatterns()intgetResponseCode()Deprecated.usegetStatusCode()intgetStatusCode()booleanisEnabled()booleanmatches(java.lang.String url)Returns true if the specified URL matches a whitelisted URL regular expression.
-
-
-
Field Detail
-
WHITELIST_DISABLED
public static final Whitelist WHITELIST_DISABLED
A disabled Whitelist.
-
-
Constructor Detail
-
Whitelist
public Whitelist()
Creates an empty, disabled Whitelist.
-
Whitelist
public Whitelist(int statusCode)
Creates an empty, enabled whitelist with the specified response code.- Parameters:
statusCode- the response code that the (enabled) Whitelist will return for all URLs.
-
Whitelist
@Deprecated public Whitelist(java.lang.String[] patterns, int statusCode)Deprecated.- Parameters:
patterns- String[] patternsstatusCode- int statusCode
-
Whitelist
public Whitelist(java.util.Collection<java.lang.String> patterns, int statusCode)Creates a whitelist for the specified patterns, returning the given statusCode when a URL does not match one of the patterns. A null or empty collection will result in an empty whitelist.- Parameters:
patterns- URL-matching regular expression patterns to whiteliststatusCode- the HTTP status code to return when a request URL matches a whitelist pattern
-
-
Method Detail
-
isEnabled
public boolean isEnabled()
- Returns:
- true if this whitelist is enabled, otherwise false
-
getPatterns
public java.util.Collection<java.util.regex.Pattern> getPatterns()
- Returns:
- regular expression patterns describing the URLs that should be whitelisted, or an empty collection if the whitelist is disabled
-
getStatusCode
public int getStatusCode()
- Returns:
- HTTP status code returned by the whitelist, or -1 if the whitelist is disabled
-
getResponseCode
@Deprecated public int getResponseCode()
Deprecated.usegetStatusCode()- Returns:
- response code
-
matches
public boolean matches(java.lang.String url)
Returns true if the specified URL matches a whitelisted URL regular expression. If the whitelist is disabled, this method always returns false.- Parameters:
url- URL to match against the whitelist- Returns:
- true if the whitelist is enabled and the URL matched an entry in the whitelist, otherwise false
-
-