/** * Creates a new message to the specified recipient and with the specified body. * * @param to the user to send the message to. * @param body the body of the message. * @throws XmppStringprepException if 'to' is not a valid XMPP address. */ public Message(String to, String body) throws XmppStringprepException { this(JidCreate.from(to), body); }
@Override public BareJid decode(String string) { try { return JidCreate.bareFrom(string); } catch (XmppStringprepException e) { throw new IllegalArgumentException("BareJid cannot be decoded.", e); } } }
public Builder setService(String service) throws XmppStringprepException { if (service == null) { // Do nothing if user did not specify the XMPP service domain. When the builder // builds a configuration using build() it will throw a meaningful exception. return this; } return setService(JidCreate.domainBareFrom(service)); }
invitation.invitee = JidCreate.from(inviteeString); invitation.inviter = JidCreate.entityFrom(inviterString); invitation.room = JidCreate.entityBareFrom(roomString);
public static EntityBareJid getBareJidAttribute(XmlPullParser parser, String name) throws XmppStringprepException { final String jidString = parser.getAttributeValue("", name); if (jidString == null) { return null; } return JidCreate.entityBareFrom(jidString); }
private void setNickname(Resourcepart nickname) { this.myRoomJid = JidCreate.entityFullFrom(room, nickname); }
assertEquals("hft54dqy", candidate1.getCandidateId()); assertEquals("192.168.4.1", candidate1.getHost()); assertEquals(JidCreate.from("romeo@montague.lit/orchard"), candidate1.getJid()); assertEquals(5086, candidate1.getPort()); assertEquals(8257636, candidate1.getPriority()); assertEquals("hutr46fe", candidate2.getCandidateId()); assertEquals("24.24.24.1", candidate2.getHost()); assertEquals(JidCreate.from("romeo@montague.lit/orchard"), candidate2.getJid()); assertEquals(5087, candidate2.getPort()); assertEquals(8258636, candidate2.getPriority()); assertEquals("xmdh4b7i", candidate3.getCandidateId()); assertEquals("123.456.7.8", candidate3.getHost()); assertEquals(JidCreate.domainBareFrom("streamer.shakespeare.lit"), candidate3.getJid()); assertEquals(7625, candidate3.getPort()); assertEquals(7878787, candidate3.getPriority());
protected void runTest(boolean useAuthzid) throws SmackException, InterruptedException, XmppStringprepException, UnsupportedEncodingException { EntityBareJid authzid = null; if (useAuthzid) { authzid = JidCreate.entityBareFrom("shazbat@xmpp.org"); } saslMechanism.authenticate("florian", "irrelevant", JidCreate.domainBareFrom("xmpp.org"), "secret", authzid, null); byte[] response = saslMechanism.evaluateChallenge(challengeBytes); String responseString = new String(response, StringUtils.UTF8); String[] responseParts = responseString.split(","); Map<String, String> responsePairs = new HashMap<String, String>(); for (String part : responseParts) { String[] keyValue = part.split("=", 2); String key = keyValue[0]; String value = keyValue[1].replace("\"", ""); responsePairs.put(key, value); } if (useAuthzid) { assertMapValue("authzid", "shazbat@xmpp.org", responsePairs); } else { assertTrue (!responsePairs.containsKey("authzid")); } assertMapValue("username", "florian", responsePairs); assertMapValue("realm", "xmpp.org", responsePairs); assertMapValue("digest-uri", "xmpp/xmpp.org", responsePairs); assertMapValue("qop", "auth", responsePairs); }
/** * Get a {@link EntityFullJid} constructed from the given parts. * * @param localpart the localpart. * @param domainpart the domainpart. * @param resource the resourcepart. * @return a full JID. */ public static EntityFullJid entityFullFrom(Localpart localpart, Domainpart domainpart, Resourcepart resource) { return entityFullFrom(entityBareFrom(localpart, domainpart), resource); }
continue; packetUnavailable.setFrom(JidCreate.fullFrom(bareUserJid, resource)); try { presencePacketListener.processStanza(packetUnavailable);
/** * Get a {@link FullJid} constructed from the given parts. * * @param localpart the optional localpart. * @param domainpart the domainpart. * @param resource the resourcepart. * @return a full JID. */ public static FullJid fullFrom(Localpart localpart, Domainpart domainpart, Resourcepart resource) { return fullFrom(entityBareFrom(localpart, domainpart), resource); }
/** * Get a domain full JID. * * @param domainpart the domainpart. * @param resource the resourcepart. * @return a domain full JID. */ public static DomainFullJid domainFullFrom(Domainpart domainpart, Resourcepart resource) { return domainFullFrom(domainBareFrom(domainpart), resource); }
public static void tlsTest(int runs, CharSequence jidCs, String password, String host, int port, String tlsPin, boolean shouldThrow) throws XmppStringprepException, KeyManagementException, NoSuchAlgorithmException { EntityBareJid jid = JidCreate.entityBareFrom(jidCs); for (int i = 0; i < runs; i++) { boolean res = tlsTest(jid, password, host, port, tlsPin, shouldThrow); if (!res) { throw new IllegalStateException(); } } }
public static EntityFullJid getFullJidAttribute(XmlPullParser parser, String name) throws XmppStringprepException { final String jidString = parser.getAttributeValue("", name); if (jidString == null) { return null; } return JidCreate.entityFullFrom(jidString); }
@Test(expected = IllegalArgumentException.class) public void transportCandidateIllegalPortTest() throws XmppStringprepException { FullJid jid = JidCreate.fullFrom("test@test.test/test"); @SuppressWarnings("unused") JingleS5BTransportCandidate candidate = new JingleS5BTransportCandidate( "cid", "host", jid, -5555, 30, JingleS5BTransportCandidate.Type.proxy); }
@Test public void checkUpdatePrefsStanza() throws Exception { List<Jid> alwaysJids = new ArrayList<>(); alwaysJids.add(JidCreate.from("romeo@montague.lit")); alwaysJids.add(JidCreate.from("other@montague.lit")); List<Jid> neverJids = new ArrayList<>(); neverJids.add(JidCreate.from("montague@montague.lit")); MamPrefsIQ mamPrefIQ = new MamPrefsIQ(alwaysJids, neverJids, DefaultBehavior.roster); mamPrefIQ.setStanzaId("sarasa"); Assert.assertEquals(mamPrefIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString(), updatePrefsStanzaExample); }
@Override public List<Integer> getSubDeviceSessions(String s) { BareJid jid; try { jid = JidCreate.bareFrom(s); } catch (XmppStringprepException e) { throw new AssertionError(e); } return new ArrayList<>(omemoStore.loadAllRawSessionsOf(getOurDevice(), jid).keySet()); }
public static boolean tlsTest(CharSequence jidCs, String password, String host, int port, String tlsPin, boolean shouldThrow) throws XmppStringprepException, KeyManagementException, NoSuchAlgorithmException { EntityBareJid jid = JidCreate.entityBareFrom(jidCs); return tlsTest(jid, password, host, port, tlsPin, shouldThrow); }
/** * Set the XMPP domain. The XMPP domain is what follows after the '@' sign in XMPP addresses (JIDs). * * @param xmppServiceDomain the XMPP domain. * @return a reference to this builder. * @throws XmppStringprepException if the given string is not a domain bare JID. */ public B setXmppDomain(String xmppServiceDomain) throws XmppStringprepException { this.xmppServiceDomain = JidCreate.domainBareFrom(xmppServiceDomain); return getThis(); }
Presence getJoinPresence(MultiUserChat multiUserChat) { final EntityFullJid jid = JidCreate.entityFullFrom(multiUserChat.getRoom(), nickname); joinPresence.setTo(jid); return joinPresence; }