public class OAuthBearerExtensionsValidatorCallback extends Object implements Callback
Callback
for use by the SaslServer
implementation when it
needs to validate the SASL extensions for the OAUTHBEARER mechanism
Callback handlers should use the valid(String)
method to communicate valid extensions back to the SASL server.
Callback handlers should use the
error(String, String)
method to communicate validation errors back to
the SASL Server.
As per RFC-7628 (https://tools.ietf.org/html/rfc7628#section-3.1), unknown extensions must be ignored by the server.
The callback handler implementation should simply ignore unknown extensions,
not calling error(String, String)
nor valid(String)
.
Callback handlers should communicate other problems by raising an IOException
.
The OAuth bearer token is provided in the callback for better context in extension validation.
It is very important that token validation is done in its own OAuthBearerValidatorCallback
irregardless of provided extensions, as they are inherently insecure.
Constructor and Description |
---|
OAuthBearerExtensionsValidatorCallback(OAuthBearerToken token,
SaslExtensions extensions) |
Modifier and Type | Method and Description |
---|---|
void |
error(String invalidExtensionName,
String errorMessage)
Set the error value for a specific extension key-value pair if validation has failed
|
String |
errorMessage() |
void |
errorMessage(String errorMessage) |
Map<String,String> |
ignoredExtensions() |
SaslExtensions |
inputExtensions() |
Map<String,String> |
invalidExtensions() |
OAuthBearerToken |
token() |
void |
valid(String extensionName)
Validates a specific extension in the original
inputExtensions map |
void |
valid(String extensionName,
String extensionValue) |
Map<String,String> |
validatedExtensions() |
public OAuthBearerExtensionsValidatorCallback(OAuthBearerToken token, SaslExtensions extensions)
public OAuthBearerToken token()
OAuthBearerToken
the OAuth bearer token of the clientpublic SaslExtensions inputExtensions()
SaslExtensions
consisting of the unvalidated extension names and values that were sent by the clientpublic Map<String,String> validatedExtensions()
Map
consisting of the validated and recognized by the server extension names and valuespublic Map<String,String> invalidExtensions()
Map
consisting of the name->error messages of extensions which failed validationpublic Map<String,String> ignoredExtensions()
Map
consisting of the extensions that have neither been validated nor invalidatedpublic void valid(String extensionName)
inputExtensions
mapextensionName
- - the name of the extension which was validatedpublic void error(String invalidExtensionName, String errorMessage)
invalidExtensionName
- the mandatory extension name which caused the validation failureerrorMessage
- error message describing why the validation failedpublic String errorMessage()
public void errorMessage(String errorMessage)