public class PortConstraintSecurityHandler
extends ConstraintSecurityHandler
ConstraintSecurityHandler
that allows unauthenticated communication on a
configurable port. The use case for this is to configure SMILA with two HTTP ports: one allows unauthenticated access
and is used for internal communication by other services in the SMILA cluster, but is not accessible by external
client (e.g. blocked by a firewall). External clients can connect only to the second port which requires
authentication (and maybe the HTTPS protocol).
Example for usage in jetty.xml: Talking to port 8080 does not require authentication, on all other ports
<Set name="handler"> <New id="security" class="org.eclipse.smila.http.server.jetty.PortConstraintSecurityHandler"> <Set name="NoAuthenticationPort">8080</Set> <Set name="Strict">false</Set> <Set name="Authenticator"> <New class="org.eclipse.jetty.security.authentication.BasicAuthenticator" /> </Set> <Set name="ConstraintMappings"> <Array type="org.eclipse.jetty.security.ConstraintMapping"> <Item> <New class="org.eclipse.jetty.security.ConstraintMapping"> <Set name="PathSpec">/*</Set> <Set name="Constraint"> <New class="org.eclipse.jetty.util.security.Constraint"> <Set name="Authenticate">true</Set> <Set name="Roles"> <Array type="java.lang.String"> <Item>*</Item> </Array> </Set> </New> </Set> </New> </Item> </Array> </Set> <Set name="handler"> <New id="Contexts" class="org.eclipse.jetty.server.handler.HandlerCollection" /> </Set> </New> </Set>
Constructor and Description |
---|
PortConstraintSecurityHandler() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkSecurity(Request request) |
int |
getNoAuthenticationPort() |
void |
handle(java.lang.String pathInContext,
Request baseRequest,
HttpServletRequest request,
HttpServletResponse response) |
void |
setNoAuthenticationPort(int noAuthenticationPort)
Sets port that allows unauthenticated access.
|
public void setNoAuthenticationPort(int noAuthenticationPort)
ConstraintSecurityHandler
and all ports require authentication.public int getNoAuthenticationPort()
protected boolean checkSecurity(Request request)
public void handle(java.lang.String pathInContext, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException
java.io.IOException
ServletException