org.jxmpp.jid.impl.JidCreate Java Examples
The following examples show how to use
org.jxmpp.jid.impl.JidCreate.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Jid.java From Conversations with GNU General Public License v3.0 | 6 votes |
static Jid of(CharSequence local, CharSequence domain, CharSequence resource) { if (local == null) { if (resource == null) { return ofDomain(domain); } else { return ofDomainAndResource(domain, resource); } } if (resource == null) { return ofLocalAndDomain(local, domain); } try { return new WrappedJid(JidCreate.entityFullFrom( Localpart.fromUnescaped(local.toString()), Domainpart.from(domain.toString()), Resourcepart.from(resource.toString()) )); } catch (XmppStringprepException e) { throw new IllegalArgumentException(e); } }
Example #2
Source File: StanzaThread.java From tutorials with MIT License | 6 votes |
@Override public void run() { XMPPTCPConnectionConfiguration config = null; try { config = XMPPTCPConnectionConfiguration.builder() .setUsernameAndPassword("baeldung2","baeldung2") .setXmppDomain("jabb3r.org") .setHost("jabb3r.org") .build(); AbstractXMPPConnection connection = new XMPPTCPConnection(config); connection.connect(); connection.login(); ChatManager chatManager = ChatManager.getInstanceFor(connection); Chat chat = chatManager.chatWith(JidCreate.from("[email protected]").asEntityBareJidOrThrow()); chat.send("Hello!"); } catch (Exception e) { logger.error(e.getMessage(), e); } }
Example #3
Source File: OmemoKeyUtilTest.java From Smack with Apache License 2.0 | 6 votes |
@Test public void parsedBundlesDoNotContainNullValues() throws Exception { OmemoDevice device = new OmemoDevice(JidCreate.bareFrom("[email protected]"), 1337); String bundleXML = "<bundle xmlns='eu.siacs.conversations.axolotl'><signedPreKeyPublic signedPreKeyId='1'>BYKq4s6+plpjAAuCnGO+YFpLP71tMUPgj9ZZmkMSko4E</signedPreKeyPublic><signedPreKeySignature>TYMUtzWpc5USMCXStUrCbXFeHTOX3xkBTrU6/MuE/16s4ql1vRN0+JLtYPgZtTm3hb2dHwLA5BUzeTRGjSZwig==</signedPreKeySignature><identityKey>BY3AYRje4YBA6W4uuAXYNKzbII/UJbw7qE8kWHI15eti</identityKey><prekeys><preKeyPublic preKeyId='1'>BbzKUJbnqYW19h2dWCyLMbYEpF8r477Ukv9wqMayERQE</preKeyPublic><preKeyPublic preKeyId='2'>Beit9Pz31QxklV69BZ0qIxktnUO5TYAgHacFWDYsDnhd</preKeyPublic><preKeyPublic preKeyId='3'>BSlbqC8nOpG4TMqvZmCPr6TCPNRcuuoO8Fp2rLGwLFYz</preKeyPublic><preKeyPublic preKeyId='4'>BWYsJTsJLtmOgChiz4ilS/cgoEptnfv87tuvq5VpZFV+</preKeyPublic><preKeyPublic preKeyId='5'>BY/xq67AkvgIaUO1NbROJeG+r6CcpzByoKvpIaPYyaw/</preKeyPublic><preKeyPublic preKeyId='6'>BVRkNWaoocepKEqah95F1DG/uTE1iNEgIZ40wnGd39g/</preKeyPublic><preKeyPublic preKeyId='7'>BWMI2ivYBIziOiJsnxJHmiUNN1GcPs3vP/E4vn7hu10B</preKeyPublic><preKeyPublic preKeyId='8'>Bd7QSMnxJULdKHohRhxUW/DVVRhdaY9SSX16j+CJF8Yd</preKeyPublic><preKeyPublic preKeyId='9'>BSgQ8NXIkq9fZrtYEdV6qkz5EK7YXVRAiIAFaaDuwUZH</preKeyPublic><preKeyPublic preKeyId='10'>Bf9Q2r9P4P15GvIiaHWTEU5gLyk/A8ys6Pzz01pLuu9Z</preKeyPublic><preKeyPublic preKeyId='11'>BVU6/JKCXqaNa4ApbPFxYExxKuQKuRctk8a1brNcRbJU</preKeyPublic><preKeyPublic preKeyId='12'>BfFGHormRpE7x92Eo3IcZcyhxa1//lKyLCNLdlL5Gg1P</preKeyPublic><preKeyPublic preKeyId='13'>Bd/Je4PdYYJy+6gXrcy7CRqDxBHVgPKN9AOiGxpRX7gk</preKeyPublic><preKeyPublic preKeyId='14'>BVtdD2xyJnxPYNJPCT7sYdCXAoD7pMLgf27Dj0dU9vU3</preKeyPublic><preKeyPublic preKeyId='15'>BX41BkuSp/qGYDlEzsuE5Tlia1IjzmYsiZRcjAp8D2tq</preKeyPublic><preKeyPublic preKeyId='16'>BRY9W9zotVhB7DV2s/I7RYFzzg/Rok0AjU6ODs+iBUtF</preKeyPublic><preKeyPublic preKeyId='17'>Bb4DW8bURvMuh21PzHGqQlQm6eaI2S4pPLD482yV65IU</preKeyPublic><preKeyPublic preKeyId='18'>BSFOrkueqrJDACBIUDpaYiOV51fUuFit4dGYYkvV3Sty</preKeyPublic><preKeyPublic preKeyId='19'>BT402/OG5FLw2jt+cpYepykpoRVPbI+bWcUx42CqSlwx</preKeyPublic><preKeyPublic preKeyId='20'>BeMDEcZ23jnocObmU+esIhAGUvEVCyeiqq+n29Ex38Fw</preKeyPublic><preKeyPublic preKeyId='21'>BYUDDsKjORZTuZ1ImIIcwhL2peK1K+kTS+QhqCufoIRJ</preKeyPublic><preKeyPublic preKeyId='22'>BcC/x3Q3zZKv2DKaZlTWpM2Qzg8UogXJ2MmyKQzNI6RJ</preKeyPublic><preKeyPublic preKeyId='23'>Bad8sDrpoVujQTlenKtSfc7JbWlXq5MGDb71q+5DCo88</preKeyPublic><preKeyPublic preKeyId='24'>BYlAA5ZyhfiKLFE/U6lufiokNmQjGYP5eMCKhZsuv9BX</preKeyPublic><preKeyPublic preKeyId='25'>BbK+LNKsLizmJtd6iEd+QUDdBEgmxIylkTyAS2gxghEH</preKeyPublic><preKeyPublic preKeyId='26'>BZ+9oZGHWkRJXPnzT54+UPhQY0vpUdzGltMvneZHqfML</preKeyPublic><preKeyPublic preKeyId='27'>BRRXzcCruX3Gb+kbBodA9OaHcEx/XYT3dpwKK6hx8mYf</preKeyPublic><preKeyPublic preKeyId='28'>BTgeei2VCoKk3dBG0FP45UjDoJBV9wQiDn2pW9xwTMkS</preKeyPublic><preKeyPublic preKeyId='29'>BZHFWmtevdvuYAbMOpQ7nAAdv+oJxY+A7GFi2jU/PftP</preKeyPublic><preKeyPublic preKeyId='30'>BRn4+vobphaBHjOl4gYrVIPHEGMvsn63pbAVgdx69XQR</preKeyPublic><preKeyPublic preKeyId='31'>BaUv1tnXFTkJ2jiFT0vlUjH9upOASZHN4EmXGX9n9UAc</preKeyPublic><preKeyPublic preKeyId='32'>BU+13hmRR2dkuIqBKxItFFaIdnaAti3beOnmezR+/VtW</preKeyPublic><preKeyPublic preKeyId='33'>BbmmB27Q1B72qhxxW++CyrNHCy0UwiAOdkKOBUKCkyZ0</preKeyPublic><preKeyPublic preKeyId='34'>BemHNdH5VhufFn9n4qu6e1pVyYjn47ivQy1xHmQL6eh1</preKeyPublic><preKeyPublic preKeyId='35'>BSnbvvDgCRGpu/SkapLOe66hxxeJKw7U160d6vxUkYM6</preKeyPublic><preKeyPublic preKeyId='36'>BVaUjCB5ZhooG2umXa4CVu6BjmNDkkUUM19pzangbfEU</preKeyPublic><preKeyPublic preKeyId='37'>BZD+gzgJ4jXxjfJtMMuWvHJmr/f5vJ+u7vhH4y7KjYM3</preKeyPublic><preKeyPublic preKeyId='38'>BW3zmMGSm5jhMTpSjT8u0dsDnK2pXMRVPTr08xmh7vhJ</preKeyPublic><preKeyPublic preKeyId='39'>BSE7XKChX5zcJrJtoBTAVtUL/gB9iFFb2rE0fKj2b2UQ</preKeyPublic><preKeyPublic preKeyId='40'>BXVao8jlCDAeOMr4thch7T8Gl+7h2OhcihFAOqkmzf9M</preKeyPublic><preKeyPublic preKeyId='41'>BdPqg07COBd2OInhQqc1yCZbixd1CpEbpcG9NjbxGwRU</preKeyPublic><preKeyPublic preKeyId='42'>BTzmunAmQX61OaIlTYdfWQU3VtkVXdiLCcegUIOzg/hw</preKeyPublic><preKeyPublic preKeyId='43'>BfRxST8negQ2vxMQLufVXdOM/U5IPHCETGsV2uhkdz4H</preKeyPublic><preKeyPublic preKeyId='44'>BTlbSzgCQwwkjD/EbEWfcontJobg9u5Odqn/x9QAmu1j</preKeyPublic><preKeyPublic preKeyId='45'>BczhPhwuz7KQJW8KICaOgQ0J/+baVwptpqxOtwjFphQh</preKeyPublic><preKeyPublic preKeyId='46'>Bc0xu3QbrVWQDlIh2VdrfP/GowUF8CN5Q3iCpuabLhIK</preKeyPublic><preKeyPublic preKeyId='47'>BaiPlpNAjMviSv3n3tJ+8vAQS7IORAuYJz8pZ/k7Cdth</preKeyPublic><preKeyPublic preKeyId='48'>BUDuxRt02ajimnvq8BeBQEies6TNDs/E0uvZ7aLHBJAI</preKeyPublic><preKeyPublic preKeyId='49'>BQFVdgojx8r3LOjJbAk3CWhtCxU2DxFQHyoBewfJyTk9</preKeyPublic><preKeyPublic preKeyId='50'>BdMJqMd7Rkiu9tcmcG1TDU0XKoEHJYPK3FBfRScvqlBr</preKeyPublic><preKeyPublic preKeyId='51'>BSyfLhWFdFkUcyczOpIgwo5M5JrJEWWLBJLrOYZHlkYb</preKeyPublic><preKeyPublic preKeyId='52'>BeM0hOY/zjvwbGgFHTLAKplV2A57bKzJOd0qhkc22zk1</preKeyPublic><preKeyPublic preKeyId='53'>BRIohETGkJNWCDmZjnq7kgawbPWjjBaok4QMTSynT3Qc</preKeyPublic><preKeyPublic preKeyId='54'>BZykP11RVcyQQmYD+gxGYzL1aQlKce3+EzPZDunh0ftO</preKeyPublic><preKeyPublic preKeyId='55'>BYwQvPfzvB97+QcBfCR2YW1EOIDw8KW5FrGmhw4/JxlP</preKeyPublic><preKeyPublic preKeyId='56'>BYNXW8MBYvPvtsjo2LVUBy4JZdRfG1WKq2dNY8gt+OFe</preKeyPublic><preKeyPublic preKeyId='57'>BSXp4XWf7UkZnM5IK0nQf2/PqHqkMXBq9s/z0YRWUt44</preKeyPublic><preKeyPublic preKeyId='58'>BUzNkOEe1jnuoJ4sQpz9DeBojDr1qfpadPr6UbC9SSoz</preKeyPublic><preKeyPublic preKeyId='59'>BXONDctFe7rI0h5+erFwpp+LjU9MnVONIhpOsX+aiTQT</preKeyPublic><preKeyPublic preKeyId='60'>BRElBbzl1sPRtu3r7kQfjqzXn1LxwnRU7gpWxjVMrplK</preKeyPublic><preKeyPublic preKeyId='61'>BdGuy7iMtNqzmLOgG8QH63Jc22Mo7Tyquz4UkeT1F+8j</preKeyPublic><preKeyPublic preKeyId='62'>Bas8r4IYxDpWYCvwTE+esHgELip8d/C3BJP14W74RjJq</preKeyPublic><preKeyPublic preKeyId='63'>BTJCGy3cDLmpDqHaXE9NPaEs1kKibx4fNx4SmEc74xMs</preKeyPublic><preKeyPublic preKeyId='64'>BRLV4n9fTnOnt0omE4xfl9XsYlml78F7bs585qiWyAwN</preKeyPublic><preKeyPublic preKeyId='65'>BUWflPRltdUAfkQbFWjEbTDc5FBImnSAxZk/GYqyGwB1</preKeyPublic><preKeyPublic preKeyId='66'>BfKrwvFbKawM8Y18oPzXd8dNk821fZ3s2r+yXFrsLDlH</preKeyPublic><preKeyPublic preKeyId='67'>BbqXgiP75kNoQPZ6MYNUdLvepRLQc1EBm5ZYV9VW56Ef</preKeyPublic><preKeyPublic preKeyId='68'>BazAZ71zu++p6o0LAJNBJIgKSacrque4veToF850TpQW</preKeyPublic><preKeyPublic preKeyId='69'>BQptZxpQZugPAK9CMZnR3p+gF0rqYVihRnUIdWAmhMB9</preKeyPublic><preKeyPublic preKeyId='70'>Ba70cNznf57ndU6NY62paZcDTTOZmPPS8/JZqLyP+ZVr</preKeyPublic><preKeyPublic preKeyId='71'>BSDQwgSHsNjf3MOh4SRRd5jzq/kcjIlf6JEa1SoX06Bn</preKeyPublic><preKeyPublic preKeyId='72'>BQ1ATRmYMPCyNt8fu/GZ0UeAYWG+WtiDs0uDLsmklI4e</preKeyPublic><preKeyPublic preKeyId='73'>BSAofueQkVpDo+I4SoFMdC8S35EOvOn7zmyOG4stSy4B</preKeyPublic><preKeyPublic preKeyId='74'>BcpdJVI1JARw8QeKXhbsMIgFxQzTvMSuQeAyvdYfgFIX</preKeyPublic><preKeyPublic preKeyId='75'>BURqmjb1lZU66KyPBlCWrjBbISJyqgMW8OaJOchk39YL</preKeyPublic><preKeyPublic preKeyId='76'>BVcQm66sdtSBIYK9KymoaZnSvLQPNftBPi+BPfg20Vwh</preKeyPublic><preKeyPublic preKeyId='77'>BQDNPKib8FK5YquNUAzB7sirGjdj+El+HrOTlMr0w1om</preKeyPublic><preKeyPublic preKeyId='78'>BQ66K4ENDGMAlZc7AqcE9dodeeAWfGzSyRYMto57iGAX</preKeyPublic><preKeyPublic preKeyId='79'>BTnfRRbPKKBLyoV/BTeIZhkfs629J462AvxuE3pHgvca</preKeyPublic><preKeyPublic preKeyId='80'>Bfyu+Cln9QhDLWz1AqOuYgqkh78LROOk4g326gj378gX</preKeyPublic><preKeyPublic preKeyId='81'>BRZovbjk6iAtKaKGLvLWlGGml/SUhMtSJEgjrO4tWd9s</preKeyPublic><preKeyPublic preKeyId='82'>BZ6OUOFAbuIPTaOwy0qyA6zZ9uYyxskF6i7EXWNQr1Nr</preKeyPublic><preKeyPublic preKeyId='83'>BWV8bGYfPvLq7Dla1gEqZv3eFej2UzcMWvFOiwurY7AS</preKeyPublic><preKeyPublic preKeyId='84'>BSZQ8prazrspZeNKzJzZc0bp1PEs1odEHsI7PLYCUVQd</preKeyPublic><preKeyPublic preKeyId='85'>BbAYn4nIg9EjRh92dTHKfgrTC/oAU/92U2WkDtCS+fs1</preKeyPublic><preKeyPublic preKeyId='86'>BehKd0MHqJauFPVQsS37SIFwUXo0OOcMembkOhyMGPF8</preKeyPublic><preKeyPublic preKeyId='87'>BS7CeBYN+H0s+GwxIrUc5SmdMZEXTprVZD6RYoM+YyxK</preKeyPublic><preKeyPublic preKeyId='88'>BSBc48kcT2EN1Siv/hoX8ozuHSEfQXIS93SNY8+Jg7pz</preKeyPublic><preKeyPublic preKeyId='89'>Bdr7WFoKkG1m/CsTV7J2G9/yXV1pOupqPyU7Rs5FjVoJ</preKeyPublic><preKeyPublic preKeyId='90'>Bc+i4mSLKDMm+ZxkcWMdVdM4p/MlBOFQLb+NF9j4QxlT</preKeyPublic><preKeyPublic preKeyId='91'>BfQslqyOk1QwcdrJRJVUvlHUYGJc115O17sb5HIP7GE2</preKeyPublic><preKeyPublic preKeyId='92'>BbHvfsMnJu2y60YmI509hoUkgGN1UqrOMLMwoC8TDqp6</preKeyPublic><preKeyPublic preKeyId='93'>BVQDMiH5KfKHZLbhTwXxR4RdsADov1gD2elDd6SO+hIQ</preKeyPublic><preKeyPublic preKeyId='94'>BaNnLStoh3EygkLfA9tjULQYg6X7L/n1jNQeaFKaGjsa</preKeyPublic><preKeyPublic preKeyId='95'>Bffy5atUJ49XgzsxXMiAopLhTU0rJtGIId0g+kggLBYa</preKeyPublic><preKeyPublic preKeyId='96'>Bb5fC0qp2eJq8HvJVkf7MIJk+eBZ3TVasvwCn8t4MhEh</preKeyPublic><preKeyPublic preKeyId='97'>Bb8H48LSq/nxpOKovpLVYw8X3mIJM7JMk3yYgFUKdL0p</preKeyPublic><preKeyPublic preKeyId='98'>BTfHeYAsa2hl/aoA3wslmL9RT+O26P6OWs0J2dif5o5p</preKeyPublic><preKeyPublic preKeyId='99'>Bf7u5QrY3Wrn0PYaRri5nDL6p6iNHFLSk6781wys0hkp</preKeyPublic><preKeyPublic preKeyId='100'>BSBryRkeNrvLgGJgh95g9oWLmrptWVPIGPSzoXrVNlAd</preKeyPublic></prekeys></bundle>"; OmemoBundleElement_VAxolotl bundle = new OmemoBundleVAxolotlProvider().parse(TestUtils.getParser(bundleXML)); HashMap<Integer, T_Bundle> bundles = keyUtil.BUNDLE.bundles(bundle, device); assertEquals("There must be 100 bundles in the HashMap.", 100, bundles.size()); assertNotNull(keyUtil.BUNDLE.identityKey(bundle)); Iterator<Integer> it = bundles.keySet().iterator(); while (it.hasNext()) { assertNotNull(keyUtil.BUNDLE.preKeyPublic(bundle, it.next())); } assertEquals(1, keyUtil.BUNDLE.signedPreKeyId(bundle)); assertNotNull(keyUtil.BUNDLE.signedPreKeyPublic(bundle)); assertNotNull(keyUtil.BUNDLE.signedPreKeySignature(bundle)); }
Example #4
Source File: OmemoExceptionsTest.java From Smack with Apache License 2.0 | 6 votes |
@Test public void undecidedOmemoIdentityExceptionTest() throws XmppStringprepException { OmemoDevice alice = new OmemoDevice(JidCreate.bareFrom("[email protected]"), 1234); OmemoDevice bob = new OmemoDevice(JidCreate.bareFrom("[email protected]"), 5678); OmemoDevice mallory = new OmemoDevice(JidCreate.bareFrom("[email protected]"), 9876); UndecidedOmemoIdentityException u = new UndecidedOmemoIdentityException(alice); assertTrue(u.getUndecidedDevices().contains(alice)); assertTrue(u.getUndecidedDevices().size() == 1); UndecidedOmemoIdentityException v = new UndecidedOmemoIdentityException(bob); v.getUndecidedDevices().add(mallory); assertTrue(v.getUndecidedDevices().size() == 2); assertTrue(v.getUndecidedDevices().contains(bob)); assertTrue(v.getUndecidedDevices().contains(mallory)); u.getUndecidedDevices().add(bob); u.join(v); assertTrue(u.getUndecidedDevices().size() == 3); }
Example #5
Source File: UriManager.java From Spark with Apache License 2.0 | 6 votes |
/** * Gets JID from URI. Returns the full jid including resource * * @param uri * the URI * @return [email protected] */ public Jid retrieveJID(URI uri) { StringBuilder sb = new StringBuilder(32); String user = uri.getUserInfo(); if (user != null) { sb.append(user); sb.append('@'); } sb.append(uri.getHost()); // Resource contains the leading / String resource = uri.getPath(); if (resource != null && resource.length() > 0 && !resource.equals("/")) { sb.append(resource); } return JidCreate.fromOrThrowUnchecked(sb); }
Example #6
Source File: IQResponseTest.java From Smack with Apache License 2.0 | 6 votes |
/** * Test creating a error response based on an IQ request. * @throws XmppStringprepException if the provided string is invalid. */ @Test public void testGeneratingValidErrorResponse() throws XmppStringprepException { final StanzaError error = StanzaError.getBuilder(StanzaError.Condition.bad_request).build(); final IQ request = new TestIQ(ELEMENT, NAMESPACE); request.setType(IQ.Type.set); request.setFrom(JidCreate.from("sender@test/Smack")); request.setTo(JidCreate.from("receiver@test/Smack")); final IQ result = IQ.createErrorResponse(request, error); assertEquals(IQ.Type.error, result.getType()); assertNotNull(result.getStanzaId()); assertEquals(request.getStanzaId(), result.getStanzaId()); assertEquals(request.getFrom(), result.getTo()); assertEquals(error.toXML().toString(), result.getError().toXML().toString()); // TODO this test was never valid // assertEquals(CHILD_ELEMENT, result.getChildElementXML()); }
Example #7
Source File: MUCLightCreateIQTest.java From Smack with Apache License 2.0 | 6 votes |
@Test public void checkCreateMUCLightStanza() throws Exception { List<Jid> occupants = new ArrayList<>(); occupants.add(JidCreate.from("[email protected]")); occupants.add(JidCreate.from("[email protected]")); MUCLightCreateIQ mucLightCreateIQ = new MUCLightCreateIQ( JidCreate.from("[email protected]").asEntityJidIfPossible(), "test", occupants); mucLightCreateIQ.setStanzaId("1c72W-50"); assertEquals(mucLightCreateIQ.getConfiguration().getRoomName(), "test"); HashMap<Jid, MUCLightAffiliation> iqOccupants = mucLightCreateIQ.getOccupants(); assertEquals(iqOccupants.get(JidCreate.from("[email protected]")), MUCLightAffiliation.member); assertEquals(iqOccupants.get(JidCreate.from("[email protected]")), MUCLightAffiliation.member); }
Example #8
Source File: MucChatService.java From xyTalk-pc with GNU Affero General Public License v3.0 | 6 votes |
public static MucRoomInfo mucGetInfo(String jid) { // MultiUserChatManager manager = // MultiUserChatManager.getInstanceFor(Launcher.connection); // RoomInfo info; try { // info = manager.getRoomInfo(JidCreate.entityBareFrom(jid)); MucRoomInfo info = new MucRoomInfo(getRoomInfo(JidCreate.entityBareFrom(jid))); DebugUtil.debug("Room jid:" + info.getRoom().toString()); DebugUtil.debug("Room of occupants:" + info.getOccupantsCount()); DebugUtil.debug("Room getName:" + info.getName()); DebugUtil.debug("Room getOwnerJid:" + info.getOwnerJid()); DebugUtil.debug("Room getAdminJid:" + info.getAdminJid()); return info; } catch (NoResponseException | XMPPErrorException | NotConnectedException | XmppStringprepException | InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
Example #9
Source File: XMPPIntegrationTest.java From wildfly-camel with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { KeyStore keyStore = KeyStore.getInstance("JKS"); keyStore.load(XMPPIntegrationTest.class.getResourceAsStream("/server.jks"), "secret".toCharArray()); TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); trustManagerFactory.init(keyStore); SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, trustManagerFactory.getTrustManagers(), new SecureRandom()); String port = AvailablePortFinder.readServerData("xmpp-port"); ConnectionConfiguration connectionConfig = XMPPTCPConnectionConfiguration.builder() .setXmppDomain(JidCreate.domainBareFrom("apache.camel")) .setHostAddress(InetAddress.getLocalHost()) .setPort(Integer.parseInt(port)) .setCustomSSLContext(sslContext) .setHostnameVerifier((hostname, session) -> true) .build(); context.bind("customConnectionConfig", connectionConfig); }
Example #10
Source File: UserSearchResults.java From Spark with Apache License 2.0 | 6 votes |
private void openChatRoom(int row) { String jidString = (String)resultsTable.getValueAt(row, 0); EntityBareJid jid = JidCreate.entityBareFromOrThrowUnchecked(jidString); Localpart nickname = jid.getLocalpart(); TableColumn column; try { column = resultsTable.getColumn("nick"); int col = column.getModelIndex(); String nicknameString = (String)resultsTable.getValueAt(row, col); if (!ModelUtil.hasLength(nicknameString)) { nickname = JidCreate.from(nicknameString).getLocalpartOrThrow(); } } catch (Exception e1) { // Ignore e1 } ChatManager chatManager = SparkManager.getChatManager(); ChatRoom chatRoom = chatManager.createChatRoom(jid, nickname, nickname); ChatContainer chatRooms = chatManager.getChatContainer(); chatRooms.activateChatRoom(chatRoom); }
Example #11
Source File: JidUtil.java From jxmpp with Apache License 2.0 | 6 votes |
/** * Convert a collection of Strings to a Set of {@link Jid}'s. * <p> * If the optional argument <code>exceptions</code> is given, then all {@link XmppStringprepException} thrown while * converting will be added to the list. Otherwise, if an XmppStringprepExceptions is thrown, it will be wrapped in * a AssertionError Exception and throw. * </p> * * @param jidStrings * the strings that are going to get converted * @param output * the collection where the Jid's will be added to * @param exceptions the list of exceptions thrown while converting. */ public static void jidsFrom(Collection<? extends CharSequence> jidStrings, Collection<? super Jid> output, List<XmppStringprepException> exceptions) { for (CharSequence jidString : jidStrings) { try { Jid jid = JidCreate.from(jidString); output.add(jid); } catch (XmppStringprepException e) { if (exceptions != null) { exceptions.add(e); } else { throw new AssertionError(e); } } } }
Example #12
Source File: ChatManager.java From Spark with Apache License 2.0 | 6 votes |
/** * Returns the icon from a <code>ContactItemHandler</code>. * * @param jid the jid. * @return the icon of the handler. */ public Icon getIconForContactHandler( String jid ) { BareJid bareJid = JidCreate.bareFromOrThrowUnchecked(jid); for ( ContactItemHandler handler : contactItemHandlers ) { try { Icon icon = handler.getIcon( bareJid ); if ( icon != null ) { return icon; } } catch ( Exception e ) { Log.error( "A ContactItemHandler ('" + handler + "') threw an exception while processing an icon request for: '" + jid + "'.", e ); } } return null; }
Example #13
Source File: JidUtil.java From jxmpp with Apache License 2.0 | 6 votes |
/** * Check if the given CharSequence is a valid entity bare JID. That * is, it must consists exactly of a local- and a domainpart * (<localpart@domainpart>). * <p> * This is a convenience method meant to validate user entered bare JIDs. If * the given {@code jid} is not a valid bare JID, then this method will * throw either {@link NotAEntityBareJidStringException} or * {@link XmppStringprepException}. The NotABareJidStringException will * contain a meaningful message explaining why the given CharSequence is not a * valid bare JID (e.g. "does not contain a '@' character"). * </p> * * @param jidcs the JID CharSequence * @return a BareJid instance representing the given JID CharSequence * @throws NotAEntityBareJidStringException if the given CharSequence is not a bare JID. * @throws XmppStringprepException if an error happens. */ public static EntityBareJid validateEntityBareJid(CharSequence jidcs) throws NotAEntityBareJidStringException, XmppStringprepException { String jid = jidcs.toString(); final int atIndex = jid.indexOf('@'); if (atIndex == -1) { throw new NotAEntityBareJidStringException("'" + jid + "' does not contain a '@' character"); } else if (jid.indexOf('@', atIndex + 1) != -1) { throw new NotAEntityBareJidStringException("'" + jid + "' contains multiple '@' characters"); } final String localpart = XmppStringUtils.parseLocalpart(jid); if (localpart.length() == 0) { throw new NotAEntityBareJidStringException("'" + jid + "' has empty localpart"); } final String domainpart = XmppStringUtils.parseDomain(jid); if (domainpart.length() == 0) { throw new NotAEntityBareJidStringException("'" + jid + "' has empty domainpart"); } return JidCreate.entityBareFromUnescaped(jid); }
Example #14
Source File: Workpane.java From Spark with Apache License 2.0 | 6 votes |
/** * Invite or transfer this conversation to another agent, queue or workgroup. * * @param room the <code>ChatRoom</code>. * @param sessionID the current sessionid of this conversation. * @param transfer true if you wish to transfer this room. */ private void inviteOrTransfer(ChatRoom room, String workgroup, String sessionID, boolean transfer) { WorkgroupInvitationDialog dialog = new WorkgroupInvitationDialog(); boolean ok = dialog.hasSelectedAgent(room, transfer); if (ok) { String jidString = dialog.getSelectedJID(); Jid jid = JidCreate.fromUnescapedOrThrowUnchecked(jidString); String message = dialog.getMessage(); // Determine who to send to. if (jid.hasResource()) { // Queueu InvitationManager.transferOrInviteToQueue(room, workgroup, sessionID, jid, message, transfer); } else if (jid.getDomain().toString().startsWith("workgroup")) { InvitationManager.transferOrInviteToWorkgroup(room, workgroup, sessionID, jid, message, transfer); } else { InvitationManager.transferOrInviteUser(room, workgroup, sessionID, jid, message, transfer); } } }
Example #15
Source File: JingleS5BTransportTest.java From Smack with Apache License 2.0 | 6 votes |
@Test public void candidateFromStreamHostTest() throws XmppStringprepException, UnknownHostException { FullJid jid = JidCreate.fullFrom("[email protected]/test"); String host = "localhost"; int port = 1234; Bytestream.StreamHost streamHost = new Bytestream.StreamHost(jid, host, port); JingleS5BTransportCandidate candidate = new JingleS5BTransportCandidate(streamHost, 2000, JingleS5BTransportCandidate.Type.direct); assertEquals(2000, candidate.getPriority()); assertEquals(jid, candidate.getJid()); assertEquals(host, candidate.getHost().toString()); assertEquals(port, candidate.getPort()); assertEquals(streamHost.toXML().toString(), candidate.getStreamHost().toXML().toString()); }
Example #16
Source File: Jid.java From Pix-Art-Messenger with GNU General Public License v3.0 | 6 votes |
static Jid ofEscaped(CharSequence local, CharSequence domain, CharSequence resource) { try { if (resource == null) { return new WrappedJid( JidCreate.bareFrom( Localpart.from(local.toString()), Domainpart.from(domain.toString()) ) ); } return new WrappedJid(JidCreate.entityFullFrom( Localpart.from(local.toString()), Domainpart.from(domain.toString()), Resourcepart.from(resource.toString()) )); } catch (XmppStringprepException e) { throw new IllegalArgumentException(e); } }
Example #17
Source File: DigestMd5SaslTest.java From Smack with Apache License 2.0 | 6 votes |
protected void runTest(boolean useAuthzid) throws SmackException, InterruptedException, XmppStringprepException { EntityBareJid authzid = null; if (useAuthzid) { authzid = JidCreate.entityBareFrom("[email protected]"); } saslMechanism.authenticate("florian", "irrelevant", JidCreate.domainBareFrom("xmpp.org"), "secret", authzid, null); byte[] response = saslMechanism.evaluateChallenge(challengeBytes); String responseString = new String(response, StandardCharsets.UTF_8); 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", "[email protected]", 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); }
Example #18
Source File: XMPPSession.java From mangosta-android with Apache License 2.0 | 6 votes |
public void sendPresenceAvailable() { if (mXMPPConnection.isAuthenticated()) { new Thread(new Runnable() { @Override public void run() { try { Presence presence = new Presence(JidCreate.from(SERVICE_NAME), Presence.Type.available); presence.setMode(Presence.Mode.available); sendStanza(presence); } catch (Exception e) { e.printStackTrace(); } } }).start(); } }
Example #19
Source File: Jid.java From Pix-Art-Messenger with GNU General Public License v3.0 | 6 votes |
static Jid of(CharSequence local, CharSequence domain, CharSequence resource) { if (local == null) { if (resource == null) { return ofDomain(domain); } else { return ofDomainAndResource(domain, resource); } } if (resource == null) { return ofLocalAndDomain(local, domain); } try { return new WrappedJid(JidCreate.entityFullFrom( Localpart.fromUnescaped(local.toString()), Domainpart.from(domain.toString()), Resourcepart.from(resource.toString()) )); } catch (XmppStringprepException e) { throw new IllegalArgumentException(e); } }
Example #20
Source File: ChatArgumentsPlugin.java From Spark with Apache License 2.0 | 6 votes |
@Override public void initialize() { EntityBareJid start_chat_jid = null; try { start_chat_jid = JidCreate.entityBareFromUnescaped(Spark.getArgumentValue("start_chat_jid")); } catch (XmppStringprepException e1) { } EntityBareJid start_chat_muc = null; try { start_chat_muc = JidCreate.entityBareFromUnescaped(Spark.getArgumentValue("start_chat_muc")); } catch (XmppStringprepException e) { } if (start_chat_jid != null) { Localpart nickname = start_chat_jid.getLocalpart(); SparkManager.getChatManager().createChatRoom(start_chat_jid, nickname.toString(), start_chat_jid.toString()); } if (start_chat_muc != null) { ConferenceUtils.joinConferenceOnSeperateThread(start_chat_muc, start_chat_muc, null); } }
Example #21
Source File: UnblockContactsIQTest.java From Smack with Apache License 2.0 | 5 votes |
@Test public void checkUnblockContactIQStanza() throws Exception { List<Jid> jids = new ArrayList<>(); jids.add(JidCreate.from("[email protected]")); jids.add(JidCreate.from("[email protected]")); UnblockContactsIQ unblockContactIQ = new UnblockContactsIQ(jids); unblockContactIQ.setStanzaId("unblock1"); assertEquals(unblockContactIQExample, unblockContactIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); }
Example #22
Source File: OmemoClient.java From Smack with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws XMPPException, SmackException, IOException, InterruptedException, CorruptedOmemoKeyException { SmackConfiguration.DEBUG = true; if (args.length != 2) { print("Missing arguments: <jid> <password>"); return; } SignalOmemoService.acknowledgeLicense(); SignalOmemoService.setup(); SignalOmemoService omemoService = (SignalOmemoService) SignalOmemoService.getInstance(); Path omemoStoreDirectory = Files.createTempDirectory("omemo-store"); omemoService.setOmemoStoreBackend(new SignalCachingOmemoStore(new SignalFileBasedOmemoStore(omemoStoreDirectory.toFile()))); EntityBareJid jid = JidCreate.entityBareFromOrThrowUnchecked(args[0]); String password = args[1]; OmemoClient client = new OmemoClient(jid, password); try { client.start(); while (true) { String input = scanner.nextLine(); if (input.startsWith("/quit")) { break; } if (input.isEmpty()) { continue; } client.handleInput(input); } } finally { client.stop(); } }
Example #23
Source File: PresenceManager.java From Spark with Apache License 2.0 | 5 votes |
/** * Returns the presence of a user. * * @param jidString the users jid. * @return the users presence. * @deprecated use {@link #getPresence(BareJid)} instead. */ @Deprecated public static Presence getPresence(String jidString) { if ( jidString == null ) { Log.error( "Unable to get the presence of a null jid!" ); return null; } BareJid jid; try { jid = JidCreate.bareFrom(jidString); } catch (XmppStringprepException e) { throw new IllegalStateException(e); } return getPresence(jid); }
Example #24
Source File: JingleNodeDescriptor.java From jitsi with Apache License 2.0 | 5 votes |
/** * Loads this descriptor from the specified {@link Map}.The method is meant * for use with account property maps. It also allows prepending an account * prefix to all property names so that multiple descriptors can be read * in a single {@link Map}. * * @param props the account properties {@link Map} that we'd like to load * this descriptor from. * @param namePrefix the prefix that we should prepend to every property * name. * * @return the newly created descriptor or null if no descriptor was found. */ public static JingleNodeDescriptor loadDescriptor( Map<String, String> props, String namePrefix) { if(namePrefix == null) namePrefix = ""; String relayAddress = props.get(namePrefix + JN_ADDRESS); if (relayAddress == null) return null; String relayStr = props.get(namePrefix + JN_IS_RELAY_SUPPORTED); boolean relay = false; try { relay = Boolean.parseBoolean(relayStr); } catch(Throwable t) { } try { return new JingleNodeDescriptor(JidCreate.from(relayAddress), relay); } catch (XmppStringprepException e) { return null; } }
Example #25
Source File: XmppConnection.java From Zom-Android-XMPP with GNU General Public License v3.0 | 5 votes |
@Override public void inviteUserAsync(final ChatGroup group, final Contact invitee) { executeNow(new Runnable () { public void run() { String chatRoomJid = group.getAddress().getAddress(); if (mMUCs.containsKey(chatRoomJid)) { MultiUserChat muc = mMUCs.get(chatRoomJid); String reason = group.getName(); //no reason for now try { EntityBareJid inviteeJid = JidCreate.entityBareFrom(invitee.getAddress().getAddress()); muc.invite(inviteeJid, reason); group.notifyMemberJoined(null, invitee); group.notifyMemberRoleUpdate(invitee, "none", "member"); muc.grantMembership(inviteeJid); } catch (Exception nce) { Log.e(ImApp.LOG_TAG, "not connected error trying to add invite", nce); } } } }); }
Example #26
Source File: MUCLightBlockingTest.java From Smack with Apache License 2.0 | 5 votes |
@Test public void checkBlockUsersIQ() throws Exception { HashMap<Jid, Boolean> users = new HashMap<>(); users.put(JidCreate.from("[email protected]"), false); users.put(JidCreate.from("[email protected]"), false); MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, users); mucLightBlockingIQ.setType(Type.set); mucLightBlockingIQ.setTo(JidCreate.from("muclight.shakespeare.lit")); mucLightBlockingIQ.setStanzaId("block2"); assertEquals(blockingUsersIQExample, mucLightBlockingIQ.toXML(StreamOpen.CLIENT_NAMESPACE).toString()); }
Example #27
Source File: ParserUtils.java From Smack with Apache License 2.0 | 5 votes |
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); }
Example #28
Source File: SignalOmemoStoreConnector.java From Smack with Apache License 2.0 | 5 votes |
@Override public void deleteAllSessions(String s) { BareJid jid; try { jid = JidCreate.bareFrom(s); } catch (XmppStringprepException e) { throw new AssertionError(e); } omemoStore.removeAllRawSessionsOf(getOurDevice(), jid); }
Example #29
Source File: RosterTest.java From Smack with Apache License 2.0 | 5 votes |
/** * Test a simple roster push according to the example in * <a href="http://xmpp.org/internet-drafts/draft-ietf-xmpp-3921bis-03.html#roster-syntax-actions-push" * >RFC3921bis-03: Roster Push</a>. * @throws Throwable in case a throwable is thrown. */ @Test public void testSimpleRosterPush() throws Throwable { final BareJid contactJID = JidCreate.entityBareFrom("[email protected]"); assertNotNull("Can't get the roster from the provided connection!", roster); final StringBuilder sb = new StringBuilder(); sb.append("<iq id=\"rostertest1\" type=\"set\" ") .append("to=\"").append(connection.getUser()).append("\">") .append("<query xmlns=\"jabber:iq:roster\">") .append("<item jid=\"").append(contactJID).append("\"/>") .append("</query>") .append("</iq>"); final XmlPullParser parser = TestUtils.getIQParser(sb.toString()); final IQ rosterPush = PacketParserUtils.parseIQ(parser); initRoster(); rosterListener.reset(); // Simulate receiving the roster push connection.processStanza(rosterPush); rosterListener.waitUntilInvocationOrTimeout(); // Verify the roster entry of the new contact final RosterEntry addedEntry = roster.getEntry(contactJID); assertNotNull("The new contact wasn't added to the roster!", addedEntry); assertTrue("The roster listener wasn't invoked for the new contact!", rosterListener.getAddedAddresses().contains(contactJID)); assertSame("Setup wrong default subscription status!", ItemType.none, addedEntry.getType()); assertSame("The new contact shouldn't be member of any group!", 0, addedEntry.getGroups().size()); // Verify the unchanged roster items verifyRomeosEntry(roster.getEntry(JidCreate.entityBareFrom("[email protected]"))); verifyMercutiosEntry(roster.getEntry(JidCreate.entityBareFrom("[email protected]"))); verifyBenvoliosEntry(roster.getEntry(JidCreate.entityBareFrom("[email protected]"))); assertSame("Wrong number of roster entries.", 4, roster.getEntries().size()); }
Example #30
Source File: JingleS5BTransportTest.java From Smack with Apache License 2.0 | 5 votes |
@Test public void transportCandidateIllegalPriorityTest() throws XmppStringprepException, UnknownHostException { FullJid jid = JidCreate.fullFrom("[email protected]/test"); assertThrows(IllegalArgumentException.class, () -> { new JingleS5BTransportCandidate( "cid", "localhost", jid, 5555, -30, JingleS5BTransportCandidate.Type.proxy); }); }