Package org.wildfly.security.auth.server
Interface NameRewriter
-
- All Known Implementing Classes:
CaseNameRewriter,MutableNameRewriter,RegexNameRewriter,RegexNameValidatingRewriter
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface NameRewriter
A name rewriter. Name rewriters transform names from one form to another for various purposes, including (but not limited to):- Normalizing case
- Trimming extra whitespace
- Mapping one naming scheme to another (e.g. "user@realm" to/from "realm/user" or similar)
- Removing a realm component (e.g. "user@realm" to "user")
null, the name is not valid according to the rules of the rewriter.- Author:
- David M. Lloyd
-
-
Field Summary
Fields Modifier and Type Field Description static NameRewriterIDENTITY_REWRITERThe simple identity name rewriter, which does no rewriting.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static NameRewriteraggregate(NameRewriter... nameRewriters)Create a name rewriter which aggregates the given name rewriters; the first rewriter which successfully rewrites the name is used.static NameRewriteraggregate(NameRewriter rewriter1, NameRewriter rewriter2)Create a name rewriter which aggregates the given name rewriters; the first rewriter which successfully rewrites the name is used.default UnaryOperator<Principal>asPrincipalRewriter()Get this name rewriter as a principal rewriter that applies only toNamePrincipalinstances.static NameRewriterchain(NameRewriter... nameRewriters)Create a name rewriter which chains the given name rewriters; the name will be rewritten through the given rewriters in order and then returned.static NameRewriterchain(NameRewriter rewriter1, NameRewriter rewriter2)Create a name rewriter which chains the given name rewriters; the name will be rewritten through the given rewriters in order and then returned.static NameRewriterconstant(String name)Create a name rewriter which always returns the same name.StringrewriteName(String original)Rewrite a name.
-
-
-
Field Detail
-
IDENTITY_REWRITER
static final NameRewriter IDENTITY_REWRITER
The simple identity name rewriter, which does no rewriting.
-
-
Method Detail
-
rewriteName
String rewriteName(String original)
Rewrite a name. Must not returnnull.- Parameters:
original- the original name (must not benull)- Returns:
- the rewritten name, or
nullif the name is invalid
-
asPrincipalRewriter
default UnaryOperator<Principal> asPrincipalRewriter()
Get this name rewriter as a principal rewriter that applies only toNamePrincipalinstances.- Returns:
- the principal rewriter (not
null)
-
chain
static NameRewriter chain(NameRewriter rewriter1, NameRewriter rewriter2)
Create a name rewriter which chains the given name rewriters; the name will be rewritten through the given rewriters in order and then returned. If any rewriter returnsnull, thennullis returned.- Parameters:
rewriter1- the first name rewriter (must not benull)rewriter2- the second name rewriter (must not benull)- Returns:
- the name rewriter (not
null)
-
chain
static NameRewriter chain(NameRewriter... nameRewriters)
Create a name rewriter which chains the given name rewriters; the name will be rewritten through the given rewriters in order and then returned. If any rewriter returnsnull, thennullis returned.- Parameters:
nameRewriters- the name rewriters (must not benull, cannot havenullelements)- Returns:
- the name rewriter (not
null)
-
aggregate
static NameRewriter aggregate(NameRewriter rewriter1, NameRewriter rewriter2)
Create a name rewriter which aggregates the given name rewriters; the first rewriter which successfully rewrites the name is used. If all the rewriters returnnull, thennullis returned.- Parameters:
rewriter1- the first name rewriter (must not benull)rewriter2- the second name rewriter (must not benull)- Returns:
- the name rewriter (not
null)
-
aggregate
static NameRewriter aggregate(NameRewriter... nameRewriters)
Create a name rewriter which aggregates the given name rewriters; the first rewriter which successfully rewrites the name is used. If all the rewriters returnnull, thennullis returned.- Parameters:
nameRewriters- the name rewriters (must not benull, cannot havenullelements)- Returns:
- the name rewriter (not
null)
-
constant
static NameRewriter constant(String name)
Create a name rewriter which always returns the same name.- Parameters:
name- the name to return- Returns:
- the name
-
-