public class IPConstraint extends AbstractConstraint
<security-constraint> <ip-constraint> <allow>192.168.17.0/24</allow> </ip-constraint> <web-resource-collection> <url-pattern>/admin/*</url-pattern> </web-resource-collection> </security-constraint>
<security-constraint> <ip-constraint> <deny>205.11.12.3</deny> <deny>213.43.62.45</deny> <deny>123.4.45.6</deny> <deny>233.15.25.35</deny> <deny>233.14.87.12</deny> </ip-constraint> <web-resource-collection> <url-pattern>/*</url-pattern> </web-resource-collection> </security-constraint>
Constructor and Description |
---|
IPConstraint() |
Modifier and Type | Method and Description |
---|---|
void |
addAllow(java.lang.String network)
Add an ip network to allow.
|
void |
addDeny(java.lang.String network)
Add an ip network to deny.
|
void |
addText(java.lang.String network)
backwards compatibility, same as addAllow()
|
int |
getCacheSize()
Size of the cache used to hold whether or not to allow a certain IP
address.
|
int |
getErrorCode()
The error code to send with response.sendError, default is 403.
|
java.lang.String |
getErrorMessage()
The error message to send with response.sendError, default is
"Forbidden IP Address"
|
void |
init() |
AuthorizationResult |
isAuthorized(HttpServletRequest request,
HttpServletResponse response,
ServletContext application)
Returns true if the user is authorized for the resource.
|
void |
setCacheSize(int cacheSize)
Size of the cache used to hold whether or not to allow a certain IP
address, default is 256.
|
void |
setErrorCode(int errorCode)
The error code to send with response.sendError, default is 403.
|
void |
setErrorMessage(java.lang.String errorMessage)
The error message to send with response.sendError, default is
"Forbidden IP Address"
|
isPrivateCache, needsAuthentication, toArray
public void setErrorCode(int errorCode)
public int getErrorCode()
public void setErrorMessage(java.lang.String errorMessage)
public java.lang.String getErrorMessage()
public void setCacheSize(int cacheSize)
public int getCacheSize()
public void addAllow(java.lang.String network) throws java.net.UnknownHostException
java.net.UnknownHostException
public void addDeny(java.lang.String network) throws java.net.UnknownHostException
java.net.UnknownHostException
public void addText(java.lang.String network) throws java.net.UnknownHostException
java.net.UnknownHostException
@PostConstruct public void init() throws ConfigException
ConfigException
public AuthorizationResult isAuthorized(HttpServletRequest request, HttpServletResponse response, ServletContext application) throws ServletException, java.io.IOException
isAuthorized
in class AbstractConstraint
request
- the servlet requestresponse
- the servlet responseServletException
java.io.IOException