Package org.wildfly.security.auth.server
Interface PrincipalDecoder
-
- All Known Implementing Classes:
X500AttributePrincipalDecoder,X500AttributePrincipalDecoder
- 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 PrincipalDecoder extends Function<Principal,String>
A decoder for extracting a simple name from a principal.- Author:
- David M. Lloyd
-
-
Field Summary
Fields Modifier and Type Field Description static PrincipalDecoderDEFAULTThe default decoder, which just callsPrincipal.getName().static PrincipalDecoderUNKNOWNA principal decoder which cannot decode any principal.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static PrincipalDecoderaggregate(PrincipalDecoder... decoders)Create an aggregated credential decoder.default Stringapply(Principal principal)default UnaryOperator<Principal>asPrincipalRewriter()Get this principal decoder as a principal rewriter that produces aNamePrincipalif the decode succeeds.static PrincipalDecoderconcatenating(String joinString, PrincipalDecoder... decoders)Create a principal decoder that concatenates the results of the given principal decoders in the order in which they're given.static PrincipalDecoderconcatenating(PrincipalDecoder former, String joinString, PrincipalDecoder latter)Create a principal decoder which concatenates the results of two principal decoders.static PrincipalDecoderconstant(String name)Create a principal decoder which always returns the same name.StringgetName(Principal principal)Get the name from a principal.default PrincipalDecoderwithRewriter(NameRewriter nameRewriter)Add a name rewriter to this principal decoder.
-
-
-
Field Detail
-
DEFAULT
static final PrincipalDecoder DEFAULT
The default decoder, which just callsPrincipal.getName().
-
UNKNOWN
static final PrincipalDecoder UNKNOWN
A principal decoder which cannot decode any principal.
-
-
Method Detail
-
getName
String getName(Principal principal)
Get the name from a principal. If this decoder cannot understand the given principal type or contents,nullis returned.- Parameters:
principal- the principal to decode- Returns:
- the name, or
nullif this decoder does not understand the principal
-
asPrincipalRewriter
default UnaryOperator<Principal> asPrincipalRewriter()
Get this principal decoder as a principal rewriter that produces aNamePrincipalif the decode succeeds.- Returns:
- the rewriter (not
null)
-
withRewriter
default PrincipalDecoder withRewriter(NameRewriter nameRewriter)
Add a name rewriter to this principal decoder. If the name is decoded, it will then be rewritten with the given rewriter. If the rewriter deems the name invalid, then the name will be considered not decoded.- Parameters:
nameRewriter- the name rewriter- Returns:
- the combined decoder
-
aggregate
static PrincipalDecoder aggregate(PrincipalDecoder... decoders)
Create an aggregated credential decoder. The aggregated decoder will check each credential decoder until one matches the credential; this result will be returned.- Parameters:
decoders- the constituent decoders- Returns:
- the aggregated decoder
-
concatenating
static PrincipalDecoder concatenating(PrincipalDecoder former, String joinString, PrincipalDecoder latter)
Create a principal decoder which concatenates the results of two principal decoders. If one decoder is not able to decode the principal,nullis returned.- Parameters:
former- the former decoderjoinString- the string to use to join the resultslatter- the latter decoder- Returns:
- the concatenated result
-
concatenating
static PrincipalDecoder concatenating(String joinString, PrincipalDecoder... decoders)
Create a principal decoder that concatenates the results of the given principal decoders in the order in which they're given. If any decoder is not able to decode the principal, thennullis returned.- Parameters:
joinString- the string to use to join the resultsdecoders- the principal decoders (must not benull, cannot havenullelements)- Returns:
- the concatenating decoder
-
constant
static PrincipalDecoder constant(String name)
Create a principal decoder which always returns the same name.- Parameters:
name- the name to return- Returns:
- the constant decoder
-
-