Package org.wildfly.security.auth.client
Class MatchRule
- java.lang.Object
-
- org.wildfly.security.auth.client.MatchRule
-
- Direct Known Subclasses:
MatchAbstractTypeAuthorityRule,MatchAbstractTypeRule,MatchHostRule,MatchNetworkRule,MatchNoUserRule,MatchPathRule,MatchPortRule,MatchSchemeRule,MatchSchemeSpecificPartRule,MatchUserRule
public abstract class MatchRule extends Object
A rule used for deciding which authentication configuration to use.- Author:
- David M. Lloyd
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) abstract StringBuilderasString(StringBuilder b)booleanequals(Object other)Determine whether this rule is equal to another object.booleanequals(MatchRule other)Determine whether this rule is equal to another.StringgetMatchAbstractType()Get the abstract type that this rule matches, ornullif this rule does not match by abstract type.StringgetMatchAbstractTypeAuthority()Get the abstract type authority that this rule matches, ornullif this rule does not match by abstract type authority.StringgetMatchHost()Get the host name that this rule matches, ornullif this rule does not match by host.org.wildfly.common.net.CidrAddressgetMatchNetwork()Get the network that this rule matches, ornullif this rule does not match by network.StringgetMatchPath()Get the path name that this rule matches, ornullif this rule does not match by path.intgetMatchPort()Get the port number that this rule matches, or 0 if this rule does not match by port.StringgetMatchProtocol()Get the protocol (scheme) that this rule matches, ornullif this rule does not match by protocol.StringgetMatchUrnName()Get the URN name that this rule matches, ornullif this rule does not match by URN.StringgetMatchUser()Get the URI user info that this rule matches, ornullif this rule only matches empty URI user info.(package private) abstract booleanhalfEqual(MatchRule other)abstract inthashCode()Get the hash code of this rule.booleanisHostMatched()Determine whether this rule matches based on host name.booleanisNetworkMatched()Determine whether this rule matches based on network.booleanisPathMatched()Determine whether this rule matches based on path name.booleanisPortMatched()Determine whether this rule matches based on port.booleanisProtocolMatched()Determine whether this rule matches based on URI protocol (scheme).booleanisTypeAuthorityMatched()Determine whether this rule matches based on abstract type.booleanisTypeMatched()Determine whether this rule matches based on abstract type.booleanisUrnNameMatched()Determine whether this rule matches based on URN name.booleanisUserMatched()Determine whether this rule matches based on non-empty URI user info.MatchRulematchAbstractType(String typeName, String authorityName)Create a new rule which is the same as this rule, but also matches the given abstract type and type authority.MatchRulematchAddress(InetAddress inetAddress)Create a new rule which is the same as this rule, but also matches the given Internet address.MatchRulematchAnyUser()Create a new rule which is the same as this rule, but matches URIs with or without user info.booleanmatches(URI uri)Determine if this rule matches the given URI.booleanmatches(URI uri, String abstractType, String abstractTypeAuthority)Determine if this rule matches the given URI, and type.MatchRulematchHost(String hostSpec)Create a new rule which is the same as this rule, but also matches the given host name.MatchRulematchLocalSecurityDomain(String name)Create a new rule which is the same as this rule, but also matches the given security domain.MatchRulematchNetwork(org.wildfly.common.net.CidrAddress cidrAddress)Create a new rule which is the same as this rule, but also matches the given Internet network address.MatchRulematchNoUser()Create a new rule which is the same as this rule, but only matches URIs with no user info.MatchRulematchPath(String pathSpec)Create a new rule which is the same as this rule, but also matches the given path name.MatchRulematchPort(int port)Create a new rule which is the same as this rule, but also matches the given port number.MatchRulematchProtocol(String protoName)Create a new rule which is the same as this rule, but also matches the given protocol (scheme) name.MatchRulematchUrnName(String name)Create a new rule which is the same as this rule, but also matches the given URN name.MatchRulematchUser(String userSpec)Create a new rule which is the same as this rule, but also matches the given URI user info.(package private) StringBuilderparentAsString(StringBuilder b)(package private) booleanparentHalfEqual(MatchRule other)(package private) intparentHashCode()(package private) abstract MatchRulereparent(MatchRule newParent)StringtoString()Get the string representation of this rule.(package private) MatchRulewithout(Class<? extends MatchRule> clazz)
-
-
-
Constructor Detail
-
MatchRule
MatchRule(MatchRule parent)
-
-
Method Detail
-
equals
public final boolean equals(Object other)
Determine whether this rule is equal to another object. Two rules are equal if they match the same conditions.
-
equals
public final boolean equals(MatchRule other)
Determine whether this rule is equal to another. Two rules are equal if they match the same conditions.- Parameters:
other- the other object- Returns:
trueif they are equal,falseotherwise
-
halfEqual
abstract boolean halfEqual(MatchRule other)
-
parentHalfEqual
final boolean parentHalfEqual(MatchRule other)
-
hashCode
public abstract int hashCode()
Get the hash code of this rule.
-
parentHashCode
final int parentHashCode()
-
matches
public final boolean matches(URI uri)
Determine if this rule matches the given URI.- Parameters:
uri- the URI to test- Returns:
trueif the rule matches,falseotherwise
-
matches
public boolean matches(URI uri, String abstractType, String abstractTypeAuthority)
Determine if this rule matches the given URI, and type.- Parameters:
uri- the URI to testabstractType- the abstract type of the connection (may benull)abstractTypeAuthority- the authority name of the abstract type (may benull)- Returns:
trueif the rule matches,falseotherwise
-
isProtocolMatched
public boolean isProtocolMatched()
Determine whether this rule matches based on URI protocol (scheme).- Returns:
trueif the rule matches based on URI protocol,falseotherwise
-
getMatchProtocol
public String getMatchProtocol()
Get the protocol (scheme) that this rule matches, ornullif this rule does not match by protocol.- Returns:
- the protocol, or
nullif there is none
-
isTypeMatched
public boolean isTypeMatched()
Determine whether this rule matches based on abstract type.- Returns:
trueif the rule matches based on type,falseotherwise
-
isTypeAuthorityMatched
public boolean isTypeAuthorityMatched()
Determine whether this rule matches based on abstract type.- Returns:
trueif the rule matches based on type,falseotherwise
-
getMatchAbstractType
public String getMatchAbstractType()
Get the abstract type that this rule matches, ornullif this rule does not match by abstract type.- Returns:
- the abstract type, or
nullif there is none
-
getMatchAbstractTypeAuthority
public String getMatchAbstractTypeAuthority()
Get the abstract type authority that this rule matches, ornullif this rule does not match by abstract type authority.- Returns:
- the abstract type, or
nullif there is none
-
matchProtocol
public final MatchRule matchProtocol(String protoName)
Create a new rule which is the same as this rule, but also matches the given protocol (scheme) name.- Parameters:
protoName- the protocol name to match- Returns:
- the new rule
-
matchAbstractType
public final MatchRule matchAbstractType(String typeName, String authorityName)
Create a new rule which is the same as this rule, but also matches the given abstract type and type authority.- Parameters:
typeName- the type to matchauthorityName- the type authority name to match- Returns:
- the new rule
-
isHostMatched
public boolean isHostMatched()
Determine whether this rule matches based on host name.- Returns:
trueif the rule matches based on host name,falseotherwise
-
getMatchHost
public String getMatchHost()
Get the host name that this rule matches, ornullif this rule does not match by host.- Returns:
- the host name, or
nullif there is none
-
isNetworkMatched
public boolean isNetworkMatched()
Determine whether this rule matches based on network.- Returns:
trueif the rule matches based on network,falseotherwise
-
getMatchNetwork
public org.wildfly.common.net.CidrAddress getMatchNetwork()
Get the network that this rule matches, ornullif this rule does not match by network.- Returns:
- the network that this rule matches, or
nullif there is none
-
matchHost
public final MatchRule matchHost(String hostSpec)
Create a new rule which is the same as this rule, but also matches the given host name. If the given string appears to be an IP address or a CIDR network specification, then it is treated as such.- Parameters:
hostSpec- the host name to match- Returns:
- the new rule
-
matchAddress
public final MatchRule matchAddress(InetAddress inetAddress)
Create a new rule which is the same as this rule, but also matches the given Internet address.- Parameters:
inetAddress- the address to match- Returns:
- the new rule
-
matchNetwork
public final MatchRule matchNetwork(org.wildfly.common.net.CidrAddress cidrAddress)
Create a new rule which is the same as this rule, but also matches the given Internet network address.- Parameters:
cidrAddress- the network to match- Returns:
- the new rule
-
isPathMatched
public boolean isPathMatched()
Determine whether this rule matches based on path name.- Returns:
trueif the rule matches based on path name,falseotherwise
-
getMatchPath
public String getMatchPath()
Get the path name that this rule matches, ornullif this rule does not match by path.- Returns:
- the path name, or
nullif there is none
-
matchPath
public final MatchRule matchPath(String pathSpec)
Create a new rule which is the same as this rule, but also matches the given path name.- Parameters:
pathSpec- the path name to match- Returns:
- the new rule
-
isPortMatched
public boolean isPortMatched()
Determine whether this rule matches based on port.- Returns:
trueif the rule matches based on port,falseotherwise
-
getMatchPort
public int getMatchPort()
Get the port number that this rule matches, or 0 if this rule does not match by port.- Returns:
- the port number, or 0 if there is none
-
matchPort
public final MatchRule matchPort(int port)
Create a new rule which is the same as this rule, but also matches the given port number. The port number must be between 1 and 65535 (inclusive).- Parameters:
port- the port to match- Returns:
- the new rule
-
isUserMatched
public boolean isUserMatched()
Determine whether this rule matches based on non-empty URI user info.- Returns:
trueif the rule matches based on non-empty user info,falseotherwise
-
getMatchUser
public String getMatchUser()
Get the URI user info that this rule matches, ornullif this rule only matches empty URI user info.- Returns:
- the user info, or
nullif there is none
-
matchUser
public final MatchRule matchUser(String userSpec)
Create a new rule which is the same as this rule, but also matches the given URI user info.- Parameters:
userSpec- the user info to match- Returns:
- the new rule
-
matchNoUser
public final MatchRule matchNoUser()
Create a new rule which is the same as this rule, but only matches URIs with no user info.- Returns:
- the new rule
-
matchAnyUser
public final MatchRule matchAnyUser()
Create a new rule which is the same as this rule, but matches URIs with or without user info.- Returns:
- the new rule
-
isUrnNameMatched
public boolean isUrnNameMatched()
Determine whether this rule matches based on URN name.- Returns:
trueif the rule matches based on URN name,falseotherwise
-
getMatchUrnName
public String getMatchUrnName()
Get the URN name that this rule matches, ornullif this rule does not match by URN.- Returns:
- the URN name, or
nullif there is none
-
matchUrnName
public final MatchRule matchUrnName(String name)
Create a new rule which is the same as this rule, but also matches the given URN name.- Parameters:
name- the URN name to match- Returns:
- the new rule
-
matchLocalSecurityDomain
public final MatchRule matchLocalSecurityDomain(String name)
Create a new rule which is the same as this rule, but also matches the given security domain.- Parameters:
name- the security domain name to match- Returns:
- the new rule
-
toString
public final String toString()
Get the string representation of this rule.
-
parentAsString
final StringBuilder parentAsString(StringBuilder b)
-
asString
abstract StringBuilder asString(StringBuilder b)
-
-