Top Description Inners Fields Constructors Methods
io.undertow.server.handlers

public Class AccessControlListHandler

extends Object
implements HttpHandler
Class Inheritance
All Implemented Interfaces
io.undertow.server.HttpHandler
Imports
io.undertow.UndertowMessages, io.undertow.attribute.ExchangeAttribute, io.undertow.server.HandlerWrapper, .HttpHandler, .HttpServerExchange, io.undertow.server.handlers.builder.HandlerBuilder, io.undertow.util.StatusCodes, java.util.ArrayList, .HashMap, .HashSet, .List, .Map, .Set, java.util.concurrent.CopyOnWriteArrayList, java.util.regex.Pattern, .PatternSyntaxException

Handler that can accept or reject a request based on an attribute of the remote peer

Todo

should we support non-regex values for performance reasons?

Authors
Stuart Douglas, Andre Dietisheim

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
public static class
private static class

Field Summary

Modifier and TypeField and Description
private final List<AccessControlListHandler.AclMatch>
private final ExchangeAttribute
private volatile boolean
private volatile HttpHandler

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
public AccessControlListHandler
addAllow(final String
The pattern to add to the ACL
pattern
)

Adds an allowed user agent peer to the ACL list

User agent may be given as regex

public AccessControlListHandler
addDeny(final String
The user agent to add to the ACL
pattern
)

Adds an denied user agent to the ACL list

User agent may be given as regex

private AccessControlListHandler
addRule(final String userAgent, final boolean deny)

public AccessControlListHandler
public HttpHandler
public void
handleRequest(final HttpServerExchange
the HTTP request/response exchange
exchange
)

Implements io.undertow.server.HttpHandler.handleRequest.

Handle the request.

pack-priv boolean
isAllowed(String attribute)

public boolean
public AccessControlListHandler
setDefaultAllow(final boolean defaultAllow)

public AccessControlListHandler
setNext(final HttpHandler next)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

aclback to summary
private final List<AccessControlListHandler.AclMatch> acl
attributeback to summary
private final ExchangeAttribute attribute
defaultAllowback to summary
private volatile boolean defaultAllow
nextback to summary
private volatile HttpHandler next

Constructor Detail

AccessControlListHandlerback to summary
public AccessControlListHandler(final HttpHandler next, ExchangeAttribute attribute)
AccessControlListHandlerback to summary
public AccessControlListHandler(ExchangeAttribute attribute)

Method Detail

addAllowback to summary
public AccessControlListHandler addAllow(final String pattern)

Adds an allowed user agent peer to the ACL list

User agent may be given as regex

Parameters
pattern:String

The pattern to add to the ACL

addDenyback to summary
public AccessControlListHandler addDeny(final String pattern)

Adds an denied user agent to the ACL list

User agent may be given as regex

Parameters
pattern:String

The user agent to add to the ACL

addRuleback to summary
private AccessControlListHandler addRule(final String userAgent, final boolean deny)
clearRulesback to summary
public AccessControlListHandler clearRules()
getNextback to summary
public HttpHandler getNext()
handleRequestback to summary
public void handleRequest(final HttpServerExchange exchange) throws Exception

Implements io.undertow.server.HttpHandler.handleRequest.

Doc from io.undertow.server.HttpHandler.handleRequest.

Handle the request.

Parameters
exchange:HttpServerExchange

the HTTP request/response exchange

Annotations
@Override
isAllowedback to summary
pack-priv boolean isAllowed(String attribute)
isDefaultAllowback to summary
public boolean isDefaultAllow()
setDefaultAllowback to summary
public AccessControlListHandler setDefaultAllow(final boolean defaultAllow)
setNextback to summary
public AccessControlListHandler setNext(final HttpHandler next)
io.undertow.server.handlers back to summary

pack-priv Class AccessControlListHandler.AclMatch

extends Object
Class Inheritance
  • java.lang.Object
  • io.undertow.server.handlers.AccessControlListHandler.AclMatch

Field Summary

Modifier and TypeField and Description
private final boolean
private final Pattern

Constructor Summary

AccessConstructor and Description
protected
AclMatch(final boolean deny, final String pattern)

Method Summary

Modifier and TypeMethod and Description
private Pattern
createPattern(final String pattern)

pack-priv boolean
pack-priv boolean
matches(final String attribute)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

denyback to summary
private final boolean deny
patternback to summary
private final Pattern pattern

Constructor Detail

AclMatchback to summary
protected AclMatch(final boolean deny, final String pattern)

Method Detail

createPatternback to summary
private Pattern createPattern(final String pattern)
isDenyback to summary
pack-priv boolean isDeny()
matchesback to summary
pack-priv boolean matches(final String attribute)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
io.undertow.server.handlers back to summary

public Class AccessControlListHandler.Builder

extends Object
implements HandlerBuilder
Class Inheritance
All Implemented Interfaces
io.undertow.server.handlers.builder.HandlerBuilder

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public HandlerWrapper
build(Map<String, Object>
The handler config
config
)

Implements io.undertow.server.handlers.builder.HandlerBuilder.build.

Creates the handler

public String
public String
name()

Implements io.undertow.server.handlers.builder.HandlerBuilder.name.

The string representation of the handler name.

public Map<String, Class<?>>
parameters()

Implements io.undertow.server.handlers.builder.HandlerBuilder.parameters.

Returns a map of parameters and their types.

public Set<String>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Builderback to summary
public Builder()

Method Detail

buildback to summary
public HandlerWrapper build(Map<String, Object> config)

Implements io.undertow.server.handlers.builder.HandlerBuilder.build.

Doc from io.undertow.server.handlers.builder.HandlerBuilder.build.

Creates the handler

Parameters
config:Map<String, Object>

The handler config

Returns:HandlerWrapper

The new predicate

Annotations
@Override
defaultParameterback to summary
public String defaultParameter()

Implements io.undertow.server.handlers.builder.HandlerBuilder.defaultParameter.

Returns:String

Doc from io.undertow.server.handlers.builder.HandlerBuilder.defaultParameter.

The default parameter name, or null if it does not have a default parameter

Annotations
@Override
nameback to summary
public String name()

Implements io.undertow.server.handlers.builder.HandlerBuilder.name.

Doc from io.undertow.server.handlers.builder.HandlerBuilder.name.

The string representation of the handler name.

Returns:String

The handler name

Annotations
@Override
parametersback to summary
public Map<String, Class<?>> parameters()

Implements io.undertow.server.handlers.builder.HandlerBuilder.parameters.

Doc from io.undertow.server.handlers.builder.HandlerBuilder.parameters.

Returns a map of parameters and their types.

Annotations
@Override
requiredParametersback to summary
public Set<String> requiredParameters()

Implements io.undertow.server.handlers.builder.HandlerBuilder.requiredParameters.

Returns:Set<String>

Doc from io.undertow.server.handlers.builder.HandlerBuilder.requiredParameters.

The required parameters

Annotations
@Override
io.undertow.server.handlers back to summary

private Class AccessControlListHandler.Wrapper

extends Object
implements HandlerWrapper
Class Inheritance
All Implemented Interfaces
io.undertow.server.HandlerWrapper

Field Summary

Modifier and TypeField and Description
private final ExchangeAttribute
private final boolean
private final List<AccessControlListHandler.AclMatch>

Constructor Summary

AccessConstructor and Description
private
Wrapper(List<AccessControlListHandler.AclMatch> peerMatches, boolean defaultAllow, ExchangeAttribute attribute)

Method Summary

Modifier and TypeMethod and Description
public HttpHandler
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributeback to summary
private final ExchangeAttribute attribute
defaultAllowback to summary
private final boolean defaultAllow
peerMatchesback to summary
private final List<AccessControlListHandler.AclMatch> peerMatches

Constructor Detail

Wrapperback to summary
private Wrapper(List<AccessControlListHandler.AclMatch> peerMatches, boolean defaultAllow, ExchangeAttribute attribute)

Method Detail

wrapback to summary
public HttpHandler wrap(HttpHandler handler)

Implements io.undertow.server.HandlerWrapper.wrap.

Annotations
@Override