Skip to content

Commit

Permalink
use in-project SASL fix instead of fork
Browse files Browse the repository at this point in the history
(cherry picked from commit 004aefb)
  • Loading branch information
kadet1090 committed Oct 4, 2016
1 parent 39c111b commit 7262a2e
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 265 deletions.
17 changes: 9 additions & 8 deletions Component/SaslAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Fabiang\Sasl\Exception\InvalidArgumentException;
use Fabiang\Sasl\Sasl;
use Kadet\Xmpp\Exception\Protocol\AuthenticationException;
use Kadet\Xmpp\Sasl\SaslFactory;
use Kadet\Xmpp\Stream\Features;
use Kadet\Xmpp\Xml\XmlElement;
use Kadet\Xmpp\XmppClient;
Expand Down Expand Up @@ -56,7 +57,7 @@ class SaslAuthenticator extends Component implements Authenticator
public function __construct($password = null, Sasl $sasl = null)
{
$this->setPassword($password);
$this->_sasl = $sasl ?: new Sasl();
$this->_sasl = $sasl ?: new SaslFactory();
}

public function setClient(XmppClient $client)
Expand Down Expand Up @@ -95,11 +96,11 @@ private function tryMechanism($name) {
$auth = new XmlElement('auth', self::XMLNS);
$auth->setAttribute('mechanism', $name);

$auth->append(base64_encode(
$mechanism instanceof ChallengeAuthenticationInterface
? $this->mechanismWithChallenge($mechanism)
: $this->mechanismWithoutChallenge($mechanism)
));
$response = $mechanism instanceof ChallengeAuthenticationInterface
? $this->mechanismWithChallenge($mechanism)
: $this->mechanismWithoutChallenge($mechanism);

$auth->append($response ? base64_encode($response) : '=');

$this->_client->write($auth);

Expand All @@ -111,9 +112,9 @@ private function tryMechanism($name) {

private function mechanismWithChallenge(ChallengeAuthenticationInterface $mechanism) {
try {
$response = base64_encode($mechanism->createResponse());
$response = $mechanism->createResponse();
} catch (InvalidArgumentException $e) {
$response = '=';
$response = '';
}

$callback = $this->_client->on('element', function (XmlElement $challenge) use ($mechanism) {
Expand Down
Loading

0 comments on commit 7262a2e

Please sign in to comment.