Package org.sakaiproject.unboundid
Class RegexpBlacklistEidValidator
- java.lang.Object
-
- org.sakaiproject.unboundid.RegexpBlacklistEidValidator
-
- All Implemented Interfaces:
EidValidator
public class RegexpBlacklistEidValidator extends Object implements EidValidator
ImplementsUserEID "validation" by checking for matches in a configurable blacklist, entries in which are treated as regular expressions.- Author:
- dmccallum
-
-
Constructor Summary
Constructors Constructor Description RegexpBlacklistEidValidator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<String>getEidBlacklist()Access the String representation of blacklisted User EID regexps configured on this object.intgetRegexpFlags()Access the configured set ofPatternmatching flags.protected booleanisBlackListedEid(String eid)Encapsulates the logic for actually checking a user EID against the configured blacklist.protected booleanisMinimallyValidEid(String eid)As implemented requires that the given ID be non-null and non-whitespace.booleanisSearchableEid(String eid)Requires minimally valid and non-blacklisted EIDs.voidsetEidBlacklist(Collection<String> eidBlacklist)Converts the given collection of Strings into a collection of s and caches the latter for evaluation byisSearchableEid(String).voidsetRegexpFlags(int regexpFlags)Assign a bitmask forPatternmatching behaviors.
-
-
-
Method Detail
-
isSearchableEid
public boolean isSearchableEid(String eid)
Requires minimally valid and non-blacklisted EIDs. This is tested by callingisMinimallyValidEid(String)andisBlackListedEid(String). Theoretically, then, a subclass could overrideisMinimallyValidEid(String)to, for example, allow any non-null EID but allow any EID not described by the current blacklist.- Specified by:
isSearchableEidin interfaceEidValidator
-
isMinimallyValidEid
protected boolean isMinimallyValidEid(String eid)
As implemented requires that the given ID be non-null and non-whitespace.- Parameters:
eid- and EID to test- Returns:
trueunless the given String is null or entirely whitespace
-
isBlackListedEid
protected boolean isBlackListedEid(String eid)
Encapsulates the logic for actually checking a user EID against the configured blacklist. If no blacklist is configured, will returnfalse- Returns:
trueif the eid matches a configured blacklist pattern.falseotherwise (e.g. if no configured blacklist).
-
getEidBlacklist
public Collection<String> getEidBlacklist()
Access the String representation of blacklisted User EID regexps configured on this object. The returned collection may or may not be equivalent to the collection passed tosetEidBlacklist(Collection)- Returns:
-
setEidBlacklist
public void setEidBlacklist(Collection<String> eidBlacklist)
Converts the given collection of Strings into a collection of s and caches the latter for evaluation byisSearchableEid(String). Configure {link Pattern} evaluation flags withsetRegexpFlags(int).- Parameters:
eidBlacklist- a collection of Strings to be compiled intoPatterns. May benull, which will have the same semantics as an empty collection.
-
getRegexpFlags
public int getRegexpFlags()
Access the configured set ofPatternmatching flags. Defaults to zero.- Returns:
- a bitmask of
Patternmatching flags - See Also:
Pattern.compile(String, int)
-
setRegexpFlags
public void setRegexpFlags(int regexpFlags)
Assign a bitmask forPatternmatching behaviors. Be sure to set this property prior to invokingsetEidBlacklist(Collection). The cachedPatternswillnotbe recompiled as a side-effect of invoking this method.- Parameters:
regexpFlags-
-
-