mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-22 12:02:05 +01:00
Add ConnectionConfiguration.setXmppAddressAndPassword()
This commit is contained in:
parent
38384a1eed
commit
d6b6fdca17
2 changed files with 34 additions and 2 deletions
|
@ -554,6 +554,39 @@ public abstract class ConnectionConfiguration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method to configure the username, password and XMPP service domain.
|
||||||
|
*
|
||||||
|
* @param jid the XMPP address of the user.
|
||||||
|
* @param password the password of the user.
|
||||||
|
* @return a reference to this builder.
|
||||||
|
* @throws XmppStringprepException in case the XMPP address is not valid.
|
||||||
|
* @see #setXmppAddressAndPassword(EntityBareJid, String)
|
||||||
|
* @since 4.4.0
|
||||||
|
*/
|
||||||
|
public B setXmppAddressAndPassword(CharSequence jid, String password) throws XmppStringprepException {
|
||||||
|
return setXmppAddressAndPassword(JidCreate.entityBareFrom(jid), password);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method to configure the username, password and XMPP service domain. The localpart of the provided
|
||||||
|
* JID is used as username and the domanipart is used as XMPP service domain.
|
||||||
|
* <p>
|
||||||
|
* Please note that this does and can not configure the client XMPP address. XMPP services are not required to
|
||||||
|
* assign bound JIDs where the localpart matches the username and the domainpart matches the verified domainpart.
|
||||||
|
* Although most services will follow that pattern.
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @param jid
|
||||||
|
* @param password
|
||||||
|
* @return a reference to this builder.
|
||||||
|
* @since 4.4.0
|
||||||
|
*/
|
||||||
|
public B setXmppAddressAndPassword(EntityBareJid jid, String password) {
|
||||||
|
setUsernameAndPassword(jid.getLocalpart(), password);
|
||||||
|
return setXmppDomain(jid.asDomainBareJid());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the XMPP entities username and password.
|
* Set the XMPP entities username and password.
|
||||||
* <p>
|
* <p>
|
||||||
|
|
|
@ -121,7 +121,6 @@ import org.jivesoftware.smack.util.dns.HostAddress;
|
||||||
import org.jxmpp.jid.impl.JidCreate;
|
import org.jxmpp.jid.impl.JidCreate;
|
||||||
import org.jxmpp.jid.parts.Resourcepart;
|
import org.jxmpp.jid.parts.Resourcepart;
|
||||||
import org.jxmpp.stringprep.XmppStringprepException;
|
import org.jxmpp.stringprep.XmppStringprepException;
|
||||||
import org.jxmpp.util.XmppStringUtils;
|
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
import org.xmlpull.v1.XmlPullParserException;
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
@ -319,7 +318,7 @@ public class XMPPTCPConnection extends AbstractXMPPConnection {
|
||||||
* @throws XmppStringprepException
|
* @throws XmppStringprepException
|
||||||
*/
|
*/
|
||||||
public XMPPTCPConnection(CharSequence jid, String password) throws XmppStringprepException {
|
public XMPPTCPConnection(CharSequence jid, String password) throws XmppStringprepException {
|
||||||
this(XmppStringUtils.parseLocalpart(jid.toString()), password, XmppStringUtils.parseDomain(jid.toString()));
|
this(XMPPTCPConnectionConfiguration.builder().setXmppAddressAndPassword(jid, password).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue