Package org.jivesoftware.smack.packet

Examples of org.jivesoftware.smack.packet.XMPPError


        FormField streamMethodField = getStreamMethodField(si
                .getFeatureNegotiationForm());

        if (streamMethodField == null) {
            String errorMessage = "No stream methods contained in packet.";
            XMPPError error = new XMPPError(XMPPError.Condition.bad_request, errorMessage);
            IQ iqPacket = createIQ(si.getPacketID(), si.getFrom(), si.getTo(),
                    IQ.Type.ERROR);
            iqPacket.setError(error);
            connection.sendPacket(iqPacket);
            throw new XMPPException(errorMessage, error);
View Full Code Here


                isIBB = true;
            }
        }

        if (!isByteStream && !isIBB) {
            XMPPError error = new XMPPError(XMPPError.Condition.bad_request,
                    "No acceptable transfer mechanism");
            throw new XMPPException(error.getMessage(), error);
        }

        if (isByteStream && isIBB && field.getType().equals(FormField.TYPE_LIST_MULTI)) {
            return new FaultTolerantNegotiator(connection, byteStreamTransferManager, inbandTransferManager);
        }
View Full Code Here

     * Reject a stream initiation request from a remote user.
     *
     * @param si The Stream Initiation request to reject.
     */
    public void rejectStream(final StreamInitiation si) {
        XMPPError error = new XMPPError(XMPPError.Condition.forbidden, "Offer Declined");
        IQ iqPacket = createIQ(si.getPacketID(), si.getFrom(), si.getTo(),
                IQ.Type.ERROR);
        iqPacket.setError(error);
        connection.sendPacket(iqPacket);
    }
View Full Code Here

                isIBB = true;
            }
        }

        if (!isByteStream && !isIBB) {
            XMPPError error = new XMPPError(XMPPError.Condition.bad_request,
                    "No acceptable transfer mechanism");
            throw new XMPPException(error.getMessage(), error);
        }

        if (isByteStream && isIBB) {
            return new FaultTolerantNegotiator(connection, byteStreamTransferManager, inbandTransferManager);
        }
View Full Code Here

    StreamInitiation initiation = request.getStreamInitiation();

    IQ rejection = FileTransferNegotiator.createIQ(
        initiation.getPacketID(), initiation.getFrom(), initiation
            .getTo(), IQ.Type.ERROR);
    rejection.setError(new XMPPError(XMPPError.Condition.forbidden));
    connection.sendPacket(rejection);
  }
View Full Code Here

    transferThread.start();
  }

  private void handleXMPPException(XMPPException e) {
    setStatus(FileTransfer.Status.ERROR);
    XMPPError error = e.getXMPPError();
    if (error != null) {
      int code = error.getCode();
      if (code == 403) {
        setStatus(Status.REFUSED);
        return;
      } else if (code == 400) {
        setStatus(Status.ERROR);
View Full Code Here

                        }
                    } else if(discoverItems.getNode() != null) {
                        // Return <item-not-found/> error since client doesn't contain
                        // the specified node
                        response.setType(IQ.Type.ERROR);
                        response.setError(new XMPPError(XMPPError.Condition.item_not_found));
                    }
                    connection.sendPacket(response);
                }
            }
        };
        connection.addPacketListener(packetListener, packetFilter);

        // Listen for disco#info requests and answer the client's supported features
        // To add a new feature as supported use the #addFeature message       
        packetFilter = new PacketTypeFilter(DiscoverInfo.class);
        packetListener = new PacketListener() {
            public void processPacket(Packet packet) {
                DiscoverInfo discoverInfo = (DiscoverInfo) packet;
                // Answer the client's supported features if the request is of the GET type
                if (discoverInfo != null && discoverInfo.getType() == IQ.Type.GET) {
                    DiscoverInfo response = new DiscoverInfo();
                    response.setType(IQ.Type.RESULT);
                    response.setTo(discoverInfo.getFrom());
                    response.setPacketID(discoverInfo.getPacketID());
                    response.setNode(discoverInfo.getNode());
                     // Add the client's identity and features only if "node" is null
                    if (discoverInfo.getNode() == null) {
                        // Set this client identity
                        DiscoverInfo.Identity identity = new DiscoverInfo.Identity("client",
                                getIdentityName());
                        identity.setType(getIdentityType());
                        response.addIdentity(identity);
                        // Add the registered features to the response
                        synchronized (features) {
                            for (Iterator<String> it = getFeatures(); it.hasNext();) {
                                response.addFeature(it.next());
                            }
                        }
                    }
                    else {
                        // Disco#info was sent to a node. Check if we have information of the
                        // specified node
                        NodeInformationProvider nodeInformationProvider =
                                getNodeInformationProvider(discoverInfo.getNode());
                        if (nodeInformationProvider != null) {
                            // Node was found. Add node features
                            Iterator features = nodeInformationProvider.getNodeFeatures();
                            if (features != null) {
                                while (features.hasNext()) {
                                    response.addFeature((String) features.next());
                                }
                            }
                        }
                        else {
                            // Return <item-not-found/> error since specified node was not found
                            response.setType(IQ.Type.ERROR);
                            response.setError(new XMPPError(XMPPError.Condition.item_not_found));
                        }
                    }
                    connection.sendPacket(response);
                }
            }
View Full Code Here

                    AccountManager accountManager = new AccountManager(connection);
                    try {
                        log.info("Logging in to Jabber as user: " + user + " on connection: " + connection);
                        connection.login(user, password, resource);
                    } catch (XMPPException e) {
                        final XMPPError error = e.getXMPPError();
                        // 401 == Not Authorized
                        if (error != null && error.getCode() == 401) {
                            // is ist possible to create Accounts?
                            if (accountManager.supportsAccountCreation()) {
                                //try to create the Account (maybe it wasn't there)
                                accountManager.createAccount(user, password);
                                log.info("Logging in to Jabber as user: " + user + " on connection: " + connection);
View Full Code Here

                    AccountManager accountManager = new AccountManager(connection);
                    try {
                        log.info("Logging in to Jabber as user: " + user + " on connection: " + connection);
                        connection.login(user, password, resource);
                    } catch (XMPPException e) {
                        final XMPPError error = e.getXMPPError();
                        // 401 == Not Authorized
                        if (error != null && error.getCode() == 401) {
                            // is ist possible to create Accounts?
                            if (accountManager.supportsAccountCreation()) {
                                //try to create the Account (maybe it wasn't there)
                                accountManager.createAccount(user, password);
                                log.info("Logging in to Jabber as user: " + user + " on connection: " + connection);
View Full Code Here

    public static String getConnectionMessage(XMPPConnection connection) {
        return connection.getHost() + ":" + connection.getPort() + "/" + connection.getServiceName();
    }

    public static String getXmppExceptionLogMessage(XMPPException e) {
        XMPPError xmppError = e.getXMPPError();
        Throwable t = e.getWrappedThrowable();
        StringBuilder strBuff = new StringBuilder();
        if (xmppError != null) {
            strBuff.append("[ ").append(xmppError.getCode()).append(" ] ")
                .append(xmppError.getCondition()).append(" : ")
                .append(xmppError.getMessage());
        }
        if (t != null) {
            strBuff.append(" ( ").append(e.getWrappedThrowable().getMessage()).append(" )");
        }
        return strBuff.toString();
View Full Code Here

TOP

Related Classes of org.jivesoftware.smack.packet.XMPPError

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.