mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-22 20:47:57 +01:00
Handle empty array in SASLMechanism.authenticate()
like null array. Thanks to Anthony Sorvari for reporting. Fixes SMACK-670.
This commit is contained in:
parent
576980097e
commit
c120bc1cbc
1 changed files with 6 additions and 2 deletions
|
@ -195,7 +195,10 @@ public abstract class SASLMechanism implements Comparable<SASLMechanism> {
|
|||
private final void authenticate() throws SmackException, NotConnectedException {
|
||||
byte[] authenticationBytes = getAuthenticationText();
|
||||
String authenticationText;
|
||||
if (authenticationBytes != null) {
|
||||
// Some SASL mechanisms do return an empty array (e.g. EXTERNAL from javax), so check that
|
||||
// the array is not-empty. Mechanisms are allowed to return either 'null' or an empty array
|
||||
// if there is no authentication text.
|
||||
if (authenticationBytes != null && authenticationBytes.length > 0) {
|
||||
authenticationText = Base64.encodeToString(authenticationBytes);
|
||||
} else {
|
||||
// RFC6120 6.4.2 "If the initiating entity needs to send a zero-length initial response,
|
||||
|
@ -209,7 +212,8 @@ public abstract class SASLMechanism implements Comparable<SASLMechanism> {
|
|||
|
||||
/**
|
||||
* Should return the initial response of the SASL mechanism. The returned byte array will be
|
||||
* send base64 encoded to the server. SASL mechanism are free to return <code>null</code> here.
|
||||
* send base64 encoded to the server. SASL mechanism are free to return <code>null</code> or an
|
||||
* empty array here.
|
||||
*
|
||||
* @return the initial response or null
|
||||
* @throws SmackException
|
||||
|
|
Loading…
Reference in a new issue