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 StringBuilder
asString(StringBuilder b)
boolean
equals(Object other)
Determine whether this rule is equal to another object.boolean
equals(MatchRule other)
Determine whether this rule is equal to another.String
getMatchAbstractType()
Get the abstract type that this rule matches, ornull
if this rule does not match by abstract type.String
getMatchAbstractTypeAuthority()
Get the abstract type authority that this rule matches, ornull
if this rule does not match by abstract type authority.String
getMatchHost()
Get the host name that this rule matches, ornull
if this rule does not match by host.org.wildfly.common.net.CidrAddress
getMatchNetwork()
Get the network that this rule matches, ornull
if this rule does not match by network.String
getMatchPath()
Get the path name that this rule matches, ornull
if this rule does not match by path.int
getMatchPort()
Get the port number that this rule matches, or 0 if this rule does not match by port.String
getMatchProtocol()
Get the protocol (scheme) that this rule matches, ornull
if this rule does not match by protocol.String
getMatchUrnName()
Get the URN name that this rule matches, ornull
if this rule does not match by URN.String
getMatchUser()
Get the URI user info that this rule matches, ornull
if this rule only matches empty URI user info.(package private) abstract boolean
halfEqual(MatchRule other)
abstract int
hashCode()
Get the hash code of this rule.boolean
isHostMatched()
Determine whether this rule matches based on host name.boolean
isNetworkMatched()
Determine whether this rule matches based on network.boolean
isPathMatched()
Determine whether this rule matches based on path name.boolean
isPortMatched()
Determine whether this rule matches based on port.boolean
isProtocolMatched()
Determine whether this rule matches based on URI protocol (scheme).boolean
isTypeAuthorityMatched()
Determine whether this rule matches based on abstract type.boolean
isTypeMatched()
Determine whether this rule matches based on abstract type.boolean
isUrnNameMatched()
Determine whether this rule matches based on URN name.boolean
isUserMatched()
Determine whether this rule matches based on non-empty URI user info.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.MatchRule
matchAddress(InetAddress inetAddress)
Create a new rule which is the same as this rule, but also matches the given Internet address.MatchRule
matchAnyUser()
Create a new rule which is the same as this rule, but matches URIs with or without user info.boolean
matches(URI uri)
Determine if this rule matches the given URI.boolean
matches(URI uri, String abstractType, String abstractTypeAuthority)
Determine if this rule matches the given URI, and type.MatchRule
matchHost(String hostSpec)
Create a new rule which is the same as this rule, but also matches the given host name.MatchRule
matchLocalSecurityDomain(String name)
Create a new rule which is the same as this rule, but also matches the given security domain.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.MatchRule
matchNoUser()
Create a new rule which is the same as this rule, but only matches URIs with no user info.MatchRule
matchPath(String pathSpec)
Create a new rule which is the same as this rule, but also matches the given path name.MatchRule
matchPort(int port)
Create a new rule which is the same as this rule, but also matches the given port number.MatchRule
matchProtocol(String protoName)
Create a new rule which is the same as this rule, but also matches the given protocol (scheme) name.MatchRule
matchUrnName(String name)
Create a new rule which is the same as this rule, but also matches the given URN name.MatchRule
matchUser(String userSpec)
Create a new rule which is the same as this rule, but also matches the given URI user info.(package private) StringBuilder
parentAsString(StringBuilder b)
(package private) boolean
parentHalfEqual(MatchRule other)
(package private) int
parentHashCode()
(package private) abstract MatchRule
reparent(MatchRule newParent)
String
toString()
Get the string representation of this rule.(package private) MatchRule
without(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:
true
if they are equal,false
otherwise
-
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:
true
if the rule matches,false
otherwise
-
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:
true
if the rule matches,false
otherwise
-
isProtocolMatched
public boolean isProtocolMatched()
Determine whether this rule matches based on URI protocol (scheme).- Returns:
true
if the rule matches based on URI protocol,false
otherwise
-
getMatchProtocol
public String getMatchProtocol()
Get the protocol (scheme) that this rule matches, ornull
if this rule does not match by protocol.- Returns:
- the protocol, or
null
if there is none
-
isTypeMatched
public boolean isTypeMatched()
Determine whether this rule matches based on abstract type.- Returns:
true
if the rule matches based on type,false
otherwise
-
isTypeAuthorityMatched
public boolean isTypeAuthorityMatched()
Determine whether this rule matches based on abstract type.- Returns:
true
if the rule matches based on type,false
otherwise
-
getMatchAbstractType
public String getMatchAbstractType()
Get the abstract type that this rule matches, ornull
if this rule does not match by abstract type.- Returns:
- the abstract type, or
null
if there is none
-
getMatchAbstractTypeAuthority
public String getMatchAbstractTypeAuthority()
Get the abstract type authority that this rule matches, ornull
if this rule does not match by abstract type authority.- Returns:
- the abstract type, or
null
if 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:
true
if the rule matches based on host name,false
otherwise
-
getMatchHost
public String getMatchHost()
Get the host name that this rule matches, ornull
if this rule does not match by host.- Returns:
- the host name, or
null
if there is none
-
isNetworkMatched
public boolean isNetworkMatched()
Determine whether this rule matches based on network.- Returns:
true
if the rule matches based on network,false
otherwise
-
getMatchNetwork
public org.wildfly.common.net.CidrAddress getMatchNetwork()
Get the network that this rule matches, ornull
if this rule does not match by network.- Returns:
- the network that this rule matches, or
null
if 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:
true
if the rule matches based on path name,false
otherwise
-
getMatchPath
public String getMatchPath()
Get the path name that this rule matches, ornull
if this rule does not match by path.- Returns:
- the path name, or
null
if 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:
true
if the rule matches based on port,false
otherwise
-
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:
true
if the rule matches based on non-empty user info,false
otherwise
-
getMatchUser
public String getMatchUser()
Get the URI user info that this rule matches, ornull
if this rule only matches empty URI user info.- Returns:
- the user info, or
null
if 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:
true
if the rule matches based on URN name,false
otherwise
-
getMatchUrnName
public String getMatchUrnName()
Get the URN name that this rule matches, ornull
if this rule does not match by URN.- Returns:
- the URN name, or
null
if 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)
-
-