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 PrincipalDecoder
DEFAULT
The default decoder, which just callsPrincipal.getName()
.static PrincipalDecoder
UNKNOWN
A 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 PrincipalDecoder
aggregate(PrincipalDecoder... decoders)
Create an aggregated credential decoder.default String
apply(Principal principal)
default UnaryOperator<Principal>
asPrincipalRewriter()
Get this principal decoder as a principal rewriter that produces aNamePrincipal
if the decode succeeds.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.static PrincipalDecoder
concatenating(PrincipalDecoder former, String joinString, PrincipalDecoder latter)
Create a principal decoder which concatenates the results of two principal decoders.static PrincipalDecoder
constant(String name)
Create a principal decoder which always returns the same name.String
getName(Principal principal)
Get the name from a principal.default PrincipalDecoder
withRewriter(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,null
is returned.- Parameters:
principal
- the principal to decode- Returns:
- the name, or
null
if this decoder does not understand the principal
-
asPrincipalRewriter
default UnaryOperator<Principal> asPrincipalRewriter()
Get this principal decoder as a principal rewriter that produces aNamePrincipal
if 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,null
is 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, thennull
is returned.- Parameters:
joinString
- the string to use to join the resultsdecoders
- the principal decoders (must not benull
, cannot havenull
elements)- 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
-
-