Class OAuthBearerExtensionsValidatorCallback
- java.lang.Object
-
- org.apache.kafka.common.security.oauthbearer.OAuthBearerExtensionsValidatorCallback
-
- All Implemented Interfaces:
Callback
public class OAuthBearerExtensionsValidatorCallback extends Object implements Callback
ACallbackfor use by theSaslServerimplementation when it needs to validate the SASL extensions for the OAUTHBEARER mechanism Callback handlers should use thevalid(String)method to communicate valid extensions back to the SASL server. Callback handlers should use theerror(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 callingerror(String, String)norvalid(String). Callback handlers should communicate other problems by raising anIOException.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
OAuthBearerValidatorCallbackirregardless of provided extensions, as they are inherently insecure.
-
-
Constructor Summary
Constructors Constructor Description OAuthBearerExtensionsValidatorCallback(OAuthBearerToken token, SaslExtensions extensions)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiderror(String invalidExtensionName, String errorMessage)Set the error value for a specific extension key-value pair if validation has failedMap<String,String>ignoredExtensions()SaslExtensionsinputExtensions()Map<String,String>invalidExtensions()OAuthBearerTokentoken()voidvalid(String extensionName)Validates a specific extension in the originalinputExtensionsmapMap<String,String>validatedExtensions()
-
-
-
Constructor Detail
-
OAuthBearerExtensionsValidatorCallback
public OAuthBearerExtensionsValidatorCallback(OAuthBearerToken token, SaslExtensions extensions)
-
-
Method Detail
-
token
public OAuthBearerToken token()
- Returns:
OAuthBearerTokenthe OAuth bearer token of the client
-
inputExtensions
public SaslExtensions inputExtensions()
- Returns:
SaslExtensionsconsisting of the unvalidated extension names and values that were sent by the client
-
validatedExtensions
public Map<String,String> validatedExtensions()
- Returns:
- an unmodifiable
Mapconsisting of the validated and recognized by the server extension names and values
-
invalidExtensions
public Map<String,String> invalidExtensions()
- Returns:
- An immutable
Mapconsisting of the name->error messages of extensions which failed validation
-
ignoredExtensions
public Map<String,String> ignoredExtensions()
- Returns:
- An immutable
Mapconsisting of the extensions that have neither been validated nor invalidated
-
valid
public void valid(String extensionName)
Validates a specific extension in the originalinputExtensionsmap- Parameters:
extensionName- - the name of the extension which was validated
-
error
public void error(String invalidExtensionName, String errorMessage)
Set the error value for a specific extension key-value pair if validation has failed- Parameters:
invalidExtensionName- the mandatory extension name which caused the validation failureerrorMessage- error message describing why the validation failed
-
-