org.jivesoftware.smack.SmackException.NoResponseException Java Examples
The following examples show how to use
org.jivesoftware.smack.SmackException.NoResponseException.
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: HttpFileUploadIntegrationTest.java From Smack with Apache License 2.0 | 6 votes |
public HttpFileUploadIntegrationTest(SmackIntegrationTestEnvironment environment) throws XMPPErrorException, NotConnectedException, NoResponseException, InterruptedException, TestNotPossibleException { super(environment); hfumOne = HttpFileUploadManager.getInstanceFor(conOne); if (!hfumOne.discoverUploadService()) { throw new TestNotPossibleException( "HttpFileUploadManager was unable to discover a HTTP File Upload service"); } UploadService uploadService = hfumOne.getDefaultUploadService(); if (!uploadService.acceptsFileOfSize(FILE_SIZE)) { throw new TestNotPossibleException("The upload service at " + uploadService.getAddress() + " does not accept files of size " + FILE_SIZE + ". It only accepts files with a maximum size of " + uploadService.getMaxFileSize()); } if (environment.configuration.sslContextFactory != null) { hfumOne.setTlsContext(environment.configuration.sslContextFactory.createSslContext()); } }
Example #2
Source File: IoTDiscoveryManager.java From Smack with Apache License 2.0 | 6 votes |
/** * Try to find an XMPP IoT registry. * * @return the JID of a Thing Registry if one could be found, <code>null</code> otherwise. * @throws InterruptedException if the calling thread was interrupted. * @throws NotConnectedException if the XMPP connection is not connected. * @throws XMPPErrorException if there was an XMPP error returned. * @throws NoResponseException if there was no response from the remote entity. * @see <a href="http://xmpp.org/extensions/xep-0347.html#findingregistry">XEP-0347 § 3.5 Finding Thing Registry</a> */ public Jid findRegistry() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { if (preconfiguredRegistry != null) { return preconfiguredRegistry; } final XMPPConnection connection = connection(); ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection); List<DiscoverInfo> discoverInfos = sdm.findServicesDiscoverInfo(Constants.IOT_DISCOVERY_NAMESPACE, true, true); if (!discoverInfos.isEmpty()) { return discoverInfos.get(0).getFrom(); } return null; }
Example #3
Source File: MultiUserChatIntegrationTest.java From Smack with Apache License 2.0 | 6 votes |
@SmackIntegrationTest public void mucJoinLeaveTest() throws XmppStringprepException, NotAMucServiceException, NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, MucNotJoinedException { EntityBareJid mucAddress = JidCreate.entityBareFrom(Localpart.from("smack-inttest-join-leave-" + randomString), mucService.getDomain()); MultiUserChat muc = mucManagerOne.getMultiUserChat(mucAddress); muc.join(Resourcepart.from("nick-one")); Presence reflectedLeavePresence = muc.leave(); MUCUser mucUser = MUCUser.from(reflectedLeavePresence); assertNotNull(mucUser); assertTrue(mucUser.getStatus().contains(MUCUser.Status.PRESENCE_TO_SELF_110)); }
Example #4
Source File: MultiUserChat.java From Smack with Apache License 2.0 | 6 votes |
/** * Like {@link #create(Resourcepart)}, but will return a {@link MucCreateConfigFormHandle} if the room creation was acknowledged by * the service (with an 201 status code). It's up to the caller to decide, based on the return * value, if he needs to continue sending the room configuration. If {@code null} is returned, the room * already existed and the user is able to join right away, without sending a form. * * @param mucEnterConfiguration the configuration used to enter the MUC. * @return A {@link MucCreateConfigFormHandle} if the room was created while joining, or {@code null} if the room was just joined. * @throws XMPPErrorException if the room couldn't be created for some reason (e.g. 405 error if * the user is not allowed to create the room) * @throws NoResponseException if there was no response from the server. * @throws InterruptedException if the calling thread was interrupted. * @throws MucAlreadyJoinedException if the MUC is already joined * @throws NotConnectedException if the XMPP connection is not connected. * @throws NotAMucServiceException if the entity is not a MUC serivce. */ public synchronized MucCreateConfigFormHandle createOrJoin(MucEnterConfiguration mucEnterConfiguration) throws NoResponseException, XMPPErrorException, InterruptedException, MucAlreadyJoinedException, NotConnectedException, NotAMucServiceException { if (isJoined()) { throw new MucAlreadyJoinedException(); } Presence presence = enter(mucEnterConfiguration); // Look for confirmation of room creation from the server MUCUser mucUser = MUCUser.from(presence); if (mucUser != null && mucUser.getStatus().contains(Status.ROOM_CREATED_201)) { // Room was created and the user has joined the room return new MucCreateConfigFormHandle(); } return null; }
Example #5
Source File: MucChatService.java From xyTalk-pc with GNU Affero General Public License v3.0 | 6 votes |
public static void join(Message message) { // TODO 收到加入群的离线消息,被邀请进入群 MucInvitation mi = message.getExtension("x", "xytalk:muc:invitation"); String jid = mi.getRoomid(); String roomname = mi.getRoomName(); MultiUserChat muc; try { muc = MultiUserChatManager.getInstanceFor(Launcher.connection) .getMultiUserChat(JidCreate.entityBareFrom(jid)); muc.join(Resourcepart.from(UserCache.CurrentUserName + "-" + UserCache.CurrentUserRealName)); // 更新左侧panel,将群组UI新建出来 createNewRoomByInvitation(jid, roomname); } catch (NotAMucServiceException | NoResponseException | XMPPErrorException | NotConnectedException | XmppStringprepException | InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
Example #6
Source File: IoTDiscoveryManager.java From Smack with Apache License 2.0 | 5 votes |
public void disownThing(Jid registry, Jid thing, NodeInfo nodeInfo) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { interactWithRegistry(registry); IoTDisown iotDisown = new IoTDisown(thing, nodeInfo); iotDisown.setTo(registry); connection().createStanzaCollectorAndSend(iotDisown).nextResultOrThrow(); }
Example #7
Source File: SASLAuthentication.java From Smack with Apache License 2.0 | 5 votes |
/** * Performs SASL authentication of the specified user. If SASL authentication was successful * then resource binding and session establishment will be performed. This method will return * the full JID provided by the server while binding a resource to the connection.<p> * * The server may assign a full JID with a username or resource different than the requested * by this method. * * @param username the username that is authenticating with the server. * @param password the password to send to the server. * @param authzid the authorization identifier (typically null). * @param sslSession the optional SSL/TLS session (if one was established) * @return the used SASLMechanism. * @throws XMPPErrorException if there was an XMPP error returned. * @throws SASLErrorException if a SASL protocol error was returned. * @throws IOException if an I/O error occurred. * @throws InterruptedException if the calling thread was interrupted. * @throws SmackSaslException if a SASL specific error occurred. * @throws NotConnectedException if the XMPP connection is not connected. * @throws NoResponseException if there was no response from the remote entity. */ SASLMechanism authenticate(String username, String password, EntityBareJid authzid, SSLSession sslSession) throws XMPPErrorException, SASLErrorException, IOException, InterruptedException, SmackSaslException, NotConnectedException, NoResponseException { final SASLMechanism mechanism = selectMechanism(authzid); final CallbackHandler callbackHandler = configuration.getCallbackHandler(); final String host = connection.getHost(); final DomainBareJid xmppServiceDomain = connection.getXMPPServiceDomain(); synchronized (this) { currentMechanism = mechanism; if (callbackHandler != null) { currentMechanism.authenticate(host, xmppServiceDomain, callbackHandler, authzid, sslSession); } else { currentMechanism.authenticate(username, host, xmppServiceDomain, password, authzid, sslSession); } final long deadline = System.currentTimeMillis() + connection.getReplyTimeout(); while (!mechanism.isFinished()) { final long now = System.currentTimeMillis(); if (now >= deadline) break; // Wait until SASL negotiation finishes wait(deadline - now); } } mechanism.throwExceptionIfRequired(); return mechanism; }
Example #8
Source File: IoTDiscoveryIntegrationTest.java From Smack with Apache License 2.0 | 5 votes |
static void checkPrerequisites(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, TestNotPossibleException { IoTDiscoveryManager discoveryManager = IoTDiscoveryManager.getInstanceFor(connection); Jid registry = discoveryManager.findRegistry(); if (registry == null) { throw new TestNotPossibleException("Could not find IoT Registry"); } }
Example #9
Source File: ServiceAdministrationManager.java From Smack with Apache License 2.0 | 5 votes |
public void addUser(final EntityBareJid userJid, final String password) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { RemoteCommand command = addUser(); command.execute(); FillableForm answerForm = new FillableForm(command.getForm()); answerForm.setAnswer("accountjid", userJid); answerForm.setAnswer("password", password); answerForm.setAnswer("password-verify", password); command.execute(answerForm); assert command.isCompleted(); }
Example #10
Source File: XmppConnectionManager.java From Smack with Apache License 2.0 | 5 votes |
private <C extends AbstractXMPPConnection> C constructConnection( XmppConnectionDescriptor<C, ? extends ConnectionConfiguration, ? extends ConnectionConfiguration.Builder<?, ?>> connectionDescriptor, Collection<ConnectionConfigurationBuilderApplier> customConnectionConfigurationAppliers) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { String username = "sinttest-" + testRunId + '-' + (connections.size() + 1); String password = StringUtils.randomString(24); return constructConnection(username, password, connectionDescriptor, customConnectionConfigurationAppliers); }
Example #11
Source File: VersionIntegrationTest.java From Smack with Apache License 2.0 | 5 votes |
@SmackIntegrationTest public void testVersion() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { // TODO put into @BeforeClass method VersionManager.setAutoAppendSmackVersion(false); VersionManager versionManagerOne = VersionManager.getInstanceFor(conOne); VersionManager versionManagerTwo = VersionManager.getInstanceFor(conTwo); final String versionName = "Smack Integration Test " + testRunId; versionManagerTwo.setVersion(versionName, "1.0"); assertTrue (versionManagerOne.isSupported(conTwo.getUser())); Version version = versionManagerOne.getVersion(conTwo.getUser()); assertEquals(versionName, version.getName()); }
Example #12
Source File: AbstractSmackLowLevelIntegrationTest.java From Smack with Apache License 2.0 | 5 votes |
protected List<AbstractXMPPConnection> getUnconnectedConnections(int count) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { List<AbstractXMPPConnection> connections = new ArrayList<>(count); for (int i = 0; i < count; i++) { AbstractXMPPConnection connection = getUnconnectedConnection(); connections.add(connection); } return connections; }
Example #13
Source File: AbstractSmackIntTest.java From Smack with Apache License 2.0 | 5 votes |
protected void performActionAndWaitUntilStanzaReceived(Runnable action, XMPPConnection connection, StanzaFilter filter) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { StanzaCollector.Configuration configuration = StanzaCollector.newConfiguration().setStanzaFilter( filter).setSize(1); try (StanzaCollector collector = connection.createStanzaCollector(configuration)) { action.run(); collector.nextResultOrThrow(timeout); } }
Example #14
Source File: MultiUserChatLight.java From Smack with Apache License 2.0 | 5 votes |
/** * Leave the MUCLight. * * @throws NotConnectedException if the XMPP connection is not connected. * @throws InterruptedException if the calling thread was interrupted. * @throws NoResponseException if there was no response from the remote entity. * @throws XMPPErrorException if there was an XMPP error returned. */ public void leave() throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException { HashMap<Jid, MUCLightAffiliation> affiliations = new HashMap<>(); affiliations.put(connection.getUser(), MUCLightAffiliation.none); MUCLightChangeAffiliationsIQ changeAffiliationsIQ = new MUCLightChangeAffiliationsIQ(room, affiliations); IQ responseIq = connection.createStanzaCollectorAndSend(changeAffiliationsIQ).nextResultOrThrow(); boolean roomLeft = responseIq.getType().equals(IQ.Type.result); if (roomLeft) { removeConnectionCallbacks(); } }
Example #15
Source File: MultiUserChatLight.java From Smack with Apache License 2.0 | 5 votes |
/** * Get the MUC Light info. * * @param version TODO javadoc me please * @return the room info * @throws NoResponseException if there was no response from the remote entity. * @throws XMPPErrorException if there was an XMPP error returned. * @throws NotConnectedException if the XMPP connection is not connected. * @throws InterruptedException if the calling thread was interrupted. */ public MUCLightRoomInfo getFullInfo(String version) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MUCLightGetInfoIQ mucLightGetInfoIQ = new MUCLightGetInfoIQ(room, version); IQ responseIq = connection.createStanzaCollectorAndSend(mucLightGetInfoIQ).nextResultOrThrow(); MUCLightInfoIQ mucLightInfoResponseIQ = (MUCLightInfoIQ) responseIq; return new MUCLightRoomInfo(mucLightInfoResponseIQ.getVersion(), room, mucLightInfoResponseIQ.getConfiguration(), mucLightInfoResponseIQ.getOccupants()); }
Example #16
Source File: PubSubManager.java From Smack with Apache License 2.0 | 5 votes |
/** * Delete the specified node. * * @param nodeId TODO javadoc me please * @throws XMPPErrorException if there was an XMPP error returned. * @throws NoResponseException if there was no response from the remote entity. * @throws NotConnectedException if the XMPP connection is not connected. * @throws InterruptedException if the calling thread was interrupted. * @return <code>true</code> if this node existed and was deleted and <code>false</code> if this node did not exist. */ public boolean deleteNode(String nodeId) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { boolean res = true; try { sendPubsubPacket(Type.set, new NodeExtension(PubSubElementType.DELETE, nodeId), PubSubElementType.DELETE.getNamespace()); } catch (XMPPErrorException e) { if (e.getStanzaError().getCondition() == StanzaError.Condition.item_not_found) { res = false; } else { throw e; } } nodeMap.remove(nodeId); return res; }
Example #17
Source File: AgentSession.java From Smack with Apache License 2.0 | 5 votes |
public void makeRoomOwner(XMPPConnection con, String sessionID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MonitorPacket request = new MonitorPacket(); request.setType(IQ.Type.set); request.setTo(workgroupJID); request.setSessionID(sessionID); connection.createStanzaCollectorAndSend(request).nextResultOrThrow(); }
Example #18
Source File: IoTDiscoveryManager.java From Smack with Apache License 2.0 | 5 votes |
/** * Claim a thing by providing a collection of meta tags. If the claim was successful, then a {@link IoTClaimed} * instance will be returned, which contains the XMPP address of the thing. Use {@link IoTClaimed#getJid()} to * retrieve this address. * * @param registry the registry use to claim the thing. * @param metaTags a collection of meta tags used to identify the thing. * @param publicThing if this is a public thing. * @return a {@link IoTClaimed} if successful. * @throws NoResponseException if there was no response from the remote entity. * @throws XMPPErrorException if there was an XMPP error returned. * @throws NotConnectedException if the XMPP connection is not connected. * @throws InterruptedException if the calling thread was interrupted. */ public IoTClaimed claimThing(Jid registry, Collection<Tag> metaTags, boolean publicThing) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { interactWithRegistry(registry); IoTMine iotMine = new IoTMine(metaTags, publicThing); iotMine.setTo(registry); IoTClaimed iotClaimed = connection().createStanzaCollectorAndSend(iotMine).nextResultOrThrow(); // The 'jid' attribute of the <claimed/> response now represents the XMPP address of the thing we just successfully claimed. Jid thing = iotClaimed.getJid(); IoTProvisioningManager.getInstanceFor(connection()).sendFriendshipRequest(thing.asBareJid()); return iotClaimed; }
Example #19
Source File: IBBTransferNegotiator.java From Smack with Apache License 2.0 | 5 votes |
@Override public OutputStream createOutgoingStream(String streamID, Jid initiator, Jid target) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { InBandBytestreamSession session = this.manager.establishSession(target, streamID); session.setCloseBothStreamsEnabled(true); return session.getOutputStream(); }
Example #20
Source File: MultiUserChatLightManager.java From Smack with Apache License 2.0 | 5 votes |
private void sendBlockRooms(DomainBareJid mucLightService, HashMap<Jid, Boolean> rooms) throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException { MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(rooms, null); mucLightBlockingIQ.setType(Type.set); mucLightBlockingIQ.setTo(mucLightService); connection().createStanzaCollectorAndSend(mucLightBlockingIQ).nextResultOrThrow(); }
Example #21
Source File: LeafNode.java From Smack with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private <T extends Item> List<T> getItems(PubSub request, List<ExtensionElement> returnedExtensions) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { PubSub result = pubSubManager.getConnection().createStanzaCollectorAndSend(request).nextResultOrThrow(); ItemsExtension itemsElem = result.getExtension(PubSubElementType.ITEMS); if (returnedExtensions != null) { returnedExtensions.addAll(result.getExtensions()); } return (List<T>) itemsElem.getItems(); }
Example #22
Source File: MultiUserChatLightManager.java From Smack with Apache License 2.0 | 5 votes |
private void sendBlockUsers(DomainBareJid mucLightService, HashMap<Jid, Boolean> users) throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException { MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, users); mucLightBlockingIQ.setType(Type.set); mucLightBlockingIQ.setTo(mucLightService); connection().createStanzaCollectorAndSend(mucLightBlockingIQ).nextResultOrThrow(); }
Example #23
Source File: IoTDiscoveryManager.java From Smack with Apache License 2.0 | 5 votes |
public boolean isRegistry(Jid jid) { try { return isRegistry(jid.asBareJid()); } catch (NoResponseException | XMPPErrorException | NotConnectedException | InterruptedException e) { LOGGER.log(Level.WARNING, "Could not determine if " + jid + " is a registry", e); return false; } }
Example #24
Source File: MamManager.java From Smack with Apache License 2.0 | 5 votes |
public MamQuery queryArchive(MamQueryArgs mamQueryArgs) throws NoResponseException, XMPPErrorException, NotConnectedException, NotLoggedInException, InterruptedException { String queryId = StringUtils.secureUniqueRandomString(); String node = mamQueryArgs.node; DataForm dataForm = mamQueryArgs.getDataForm(); MamQueryIQ mamQueryIQ = new MamQueryIQ(queryId, node, dataForm); mamQueryIQ.setType(IQ.Type.set); mamQueryIQ.setTo(archiveAddress); mamQueryArgs.maybeAddRsmSet(mamQueryIQ); return queryArchive(mamQueryIQ); }
Example #25
Source File: IBBTransferNegotiator.java From Smack with Apache License 2.0 | 5 votes |
@Override public InputStream createIncomingStream(StreamInitiation initiation) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { /* * In-Band Bytestream initiation listener must ignore next in-band bytestream request with * given session ID */ this.manager.ignoreBytestreamRequestOnce(initiation.getSessionID()); Stanza streamInitiation = initiateIncomingStream(connection(), initiation); return negotiateIncomingStream(streamInitiation); }
Example #26
Source File: MamManager.java From Smack with Apache License 2.0 | 5 votes |
/** * Get the form fields supported by the server. * * @param node The PubSub node name, can be null * @return the list of form fields. * @throws NoResponseException if there was no response from the remote entity. * @throws XMPPErrorException if there was an XMPP error returned. * @throws NotConnectedException if the XMPP connection is not connected. * @throws InterruptedException if the calling thread was interrupted. * @throws NotLoggedInException if the XMPP connection is not authenticated. */ public List<FormField> retrieveFormFields(String node) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotLoggedInException { String queryId = StringUtils.secureUniqueRandomString(); MamQueryIQ mamQueryIq = new MamQueryIQ(queryId, node, null); mamQueryIq.setTo(archiveAddress); MamQueryIQ mamResponseQueryIq = connection().createStanzaCollectorAndSend(mamQueryIq).nextResultOrThrow(); return mamResponseQueryIq.getDataForm().getFields(); }
Example #27
Source File: MamManager.java From Smack with Apache License 2.0 | 5 votes |
private List<Message> page(RSMSet requestRsmSet) throws NoResponseException, XMPPErrorException, NotConnectedException, NotLoggedInException, InterruptedException { String queryId = StringUtils.secureUniqueRandomString(); MamQueryIQ mamQueryIQ = new MamQueryIQ(queryId, node, form); mamQueryIQ.setType(IQ.Type.set); mamQueryIQ.setTo(archiveAddress); mamQueryIQ.addExtension(requestRsmSet); mamQueryPage = queryArchivePage(mamQueryIQ); return mamQueryPage.messages; }
Example #28
Source File: FileTransferNegotiatorTest.java From Smack with Apache License 2.0 | 5 votes |
@Test public void verifyForm() throws Exception { FileTransferNegotiator fileNeg = FileTransferNegotiator.getInstanceFor(connection); try { fileNeg.negotiateOutgoingTransfer(JidTestUtil.DUMMY_AT_EXAMPLE_ORG, "streamid", "file", 1024, null, 10); } catch (NoResponseException e) { // We do not expect an answer. This unit test only checks the request sent. } Stanza packet = connection.getSentPacket(); String xml = packet.toXML().toString(); assertTrue(xml.indexOf("var='stream-method' type='list-single'") != -1); }
Example #29
Source File: AbstractSmackIntTest.java From Smack with Apache License 2.0 | 5 votes |
protected void waitUntilTrue(Condition condition) throws TimeoutException, NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { final long deadline = System.currentTimeMillis() + timeout; do { if (condition.evaluate()) { return; } Thread.sleep(15); } while (System.currentTimeMillis() <= deadline); throw new TimeoutException("Timeout waiting for condition to become true. Timeout was " + timeout + " ms."); }
Example #30
Source File: AbstractXMPPConnection.java From Smack with Apache License 2.0 | 5 votes |
@Override public <I extends IQ> I sendIqRequestAndWaitForResponse(IQ request) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { StanzaCollector collector = createStanzaCollectorAndSend(request); IQ resultResponse = collector.nextResultOrThrow(); @SuppressWarnings("unchecked") I concreteResultResponse = (I) resultResponse; return concreteResultResponse; }