/** * {@inheritDoc} */ public function toString() { $presence = '<presence'; if (null !== $this->getTo()) { $presence .= ' to="' . XML::quote($this->getTo()) . '/' . XML::quote($this->getNickname()) . '"'; } return $presence . '><priority>' . $this->getPriority() . '</priority></presence>'; }
/** * Get generated id. * * @return string */ public function getId() { if (null === $this->id) { $this->id = XML::generateId(); } return $this->id; }
/** * {@inheritDoc} */ public function connect() { if (false === $this->connected) { $address = $this->getAddress(); $this->getSocket()->connect($this->getOptions()->getTimeout()); $this->getSocket()->setBlocking(true); $this->connected = true; $this->log("Connected to '{$address}'", LogLevel::DEBUG); } $this->send(sprintf(static::STREAM_START, XML::quote($this->getOptions()->getTo()))); }
/** * Build XML message * @return type */ public function toString() { $query = "<iq type='set' id='%s'><query xmlns='jabber:iq:register'><username>%s</username><password>%s</password><email>%s</email></query></iq>"; return XML::quoteMessage($query, XML::generateId(), (string) $this->username, (string) $this->password, (string) $this->email); }
/** * {@inheritDoc} */ public function authenticate($username, $password) { $authString = XML::quote(base64_encode("" . $username . "" . $password)); $this->getConnection()->send('<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">' . $authString . '</auth>'); }
/** * {@inheritDoc} */ public function toString() { return '<iq type="get" id="' . XML::generateId() . '" kk="rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr"><query xmlns="jabber:iq:roster"/></iq>'; }
/** * Generate response data. * * @param array $values */ protected function response($values) { $values['cnonce'] = uniqid(mt_rand(), false); $values['nc'] = '00000001'; $values['qop'] = 'auth'; if (!isset($values['realm'])) { $values['realm'] = $this->getOptions()->getTo(); } if (!isset($values['digest-uri'])) { $values['digest-uri'] = 'xmpp/' . $this->getOptions()->getTo(); } $a1 = sprintf('%s:%s:%s', $this->getUsername(), $values['realm'], $this->getPassword()); if ('md5-sess' === $values['algorithm']) { $a1 = pack('H32', md5($a1)) . ':' . $values['nonce'] . ':' . $values['cnonce']; } $a2 = "AUTHENTICATE:" . $values['digest-uri']; $password = md5($a1) . ':' . $values['nonce'] . ':' . $values['nc'] . ':' . $values['cnonce'] . ':' . $values['qop'] . ':' . md5($a2); $password = md5($password); $response = sprintf('username="******",realm="%s",nonce="%s",cnonce="%s",nc=%s,qop=%s,digest-uri="%s",response=%s,charset=utf-8', $this->getUsername(), $values['realm'], $values['nonce'], $values['cnonce'], $values['nc'], $values['qop'], $values['digest-uri'], $password); return XML::base64Encode($response); }
/** * Build XML message. * * @return type */ public function toString() { $query = "<iq type='set' id='%s'><query xmlns='jabber:iq:register'><username>%s</username><password>%s</password><name>%s</name></query></iq>"; return XML::quoteMessage($query, XML::generateId(), $this->user->getUsername(), $this->user->getGuid(), $this->user->getFirstName() . ' ' . $this->user->getLastName()); }
/** * {@inheritDoc} */ public function toString() { return XML::quoteMessage('<message type="%s" id="%s" to="%s"><body>%s</body></message>', $this->getType(), XML::generateId(), $this->getTo(), $this->getMessage()); }