org.jivesoftware.openfire.auth.UnauthorizedException Java Examples
The following examples show how to use
org.jivesoftware.openfire.auth.UnauthorizedException.
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: ServerStanzaHandler.java From Openfire with Apache License 2.0 | 6 votes |
@Override boolean processUnknowPacket(Element doc) throws UnauthorizedException { // Handle subsequent db:result packets if ("db".equals(doc.getNamespacePrefix()) && "result".equals(doc.getName())) { if (!((LocalIncomingServerSession) session).validateSubsequentDomain(doc)) { throw new UnauthorizedException("Failed to validate domain when using piggyback."); } return true; } else if ("db".equals(doc.getNamespacePrefix()) && "verify".equals(doc.getName())) { // The Receiving Server is reusing an existing connection for sending the // Authoritative Server a request for verification of a key ((LocalIncomingServerSession) session).verifyReceivedKey(doc); return true; } return false; }
Example #2
Source File: HttpSession.java From Openfire with Apache License 2.0 | 6 votes |
private void failDelivery(final Collection<Packet> packets) { if (packets == null) { // Do nothing if someone asked to deliver nothing :) return; } // use a separate thread to schedule backup delivery TaskEngine.getInstance().submit(new Runnable() { @Override public void run() { for (Packet packet : packets) { try { backupDeliverer.deliver(packet); } catch (UnauthorizedException e) { Log.error("On session " + getStreamID() + " unable to deliver message to backup deliverer", e); } } } }); }
Example #3
Source File: HttpBindServlet.java From Openfire with Apache License 2.0 | 6 votes |
protected void createNewSession(AsyncContext context, HttpBindBody body) throws IOException { final long rid = body.getRid(); try { final HttpConnection connection = new HttpConnection(rid, context); SessionEventDispatcher.dispatchEvent( null, SessionEventDispatcher.EventType.pre_session_created, connection, context ); connection.setSession(sessionManager.createSession(body, connection)); if (JiveGlobals.getBooleanProperty("log.httpbind.enabled", false)) { Log.info("HTTP RECV(" + connection.getSession().getStreamID().getID() + "): " + body.asXML()); } SessionEventDispatcher.dispatchEvent( connection.getSession(), SessionEventDispatcher.EventType.post_session_created, connection, context ); } catch (UnauthorizedException | HttpBindException e) { // Server wasn't initialized yet. sendLegacyError(context, BoshBindingError.internalServerError, "Server has not finished initialization." ); } }
Example #4
Source File: MultiplexerPacketDeliverer.java From Openfire with Apache License 2.0 | 6 votes |
@Override public void deliver(Packet packet) throws UnauthorizedException, PacketException { // Check if we can send the packet using another session if (connectionManagerDomain == null) { // Packet deliverer has not yet been configured so handle unprocessed packet handleUnprocessedPacket(packet); } else { // Try getting another session to the same connection manager ConnectionMultiplexerSession session = multiplexerManager.getMultiplexerSession(connectionManagerDomain); if (session == null || session.isClosed()) { // No other session was found so handle unprocessed packet handleUnprocessedPacket(packet); } else { // Send the packet using this other session to the same connection manager session.process(packet); } } }
Example #5
Source File: TransportHandler.java From Openfire with Apache License 2.0 | 6 votes |
@Override public void process(Packet packet) throws UnauthorizedException, PacketException { boolean handled = false; String host = packet.getTo().getDomain(); for (Channel<Packet> channel : transports.values()) { if (channel.getName().equalsIgnoreCase(host)) { channel.add(packet); handled = true; } } if (!handled) { JID recipient = packet.getTo(); JID sender = packet.getFrom(); packet.setError(PacketError.Condition.remote_server_timeout); packet.setFrom(recipient); packet.setTo(sender); try { deliverer.deliver(packet); } catch (PacketException e) { Log.error(LocaleUtils.getLocalizedString("admin.error"), e); } } }
Example #6
Source File: IQSharedGroupHandler.java From Openfire with Apache License 2.0 | 6 votes |
@Override public IQ handleIQ(IQ packet) throws UnauthorizedException { IQ result = IQ.createResultIQ(packet); String username = packet.getFrom().getNode(); if (!serverName.equals(packet.getFrom().getDomain()) || username == null) { // Users of remote servers are not allowed to get their "shared groups". Users of // remote servers cannot have shared groups in this server. // Besides, anonymous users do not belong to shared groups so answer an error result.setChildElement(packet.getChildElement().createCopy()); result.setError(PacketError.Condition.not_allowed); return result; } Collection<Group> groups = rosterManager.getSharedGroups(username); Element sharedGroups = result.setChildElement("sharedgroup", "http://www.jivesoftware.org/protocol/sharedgroup"); for (Group sharedGroup : groups) { String displayName = sharedGroup.getProperties().get("sharedRoster.displayName"); if (displayName != null) { sharedGroups.addElement("group").setText(displayName); } } return result; }
Example #7
Source File: SessionManager.java From Openfire with Apache License 2.0 | 6 votes |
/** * Creates a new {@code ClientSession} with the specified streamID. * * @param connection the connection to create the session from. * @param id the streamID to use for the new session. * @param language The language to use for the session * @return a newly created session. * @throws UnauthorizedException if the server has not been initialised * @throws UnknownHostException if no IP address for the peer could be found, */ public HttpSession createClientHttpSession(StreamID id, HttpConnection connection, Locale language) throws UnauthorizedException, UnknownHostException { if (serverName == null) { throw new UnauthorizedException("Server not initialized"); } PacketDeliverer backupDeliverer = server.getPacketDeliverer(); HttpSession session = new HttpSession(backupDeliverer, serverName, id, connection, language); Connection conn = session.getConnection(); conn.init(session); conn.registerCloseListener(clientSessionListener, session); localSessionManager.getPreAuthenticatedSessions().put(session.getAddress().getResource(), session); connectionsCounter.incrementAndGet(); return session; }
Example #8
Source File: WebSocketConnection.java From Openfire with Apache License 2.0 | 6 votes |
@Override public void deliver(Packet packet) throws UnauthorizedException { final String xml; if (Namespace.NO_NAMESPACE.equals(packet.getElement().getNamespace())) { // use string-based operation here to avoid cascading xmlns wonkery StringBuilder packetXml = new StringBuilder(packet.toXML()); packetXml.insert(packetXml.indexOf(" "), " xmlns=\"jabber:client\""); xml = packetXml.toString(); } else { xml = packet.toXML(); } if (validate()) { deliverRawText(xml); } else { // use fallback delivery mechanism (offline) getPacketDeliverer().deliver(packet); } }
Example #9
Source File: LocalMUCRoom.java From Openfire with Apache License 2.0 | 6 votes |
/** * Checks if the user provided the correct password, if applicable. * * @param user The user that attempts to join. * @throws UnauthorizedException when joining is prevented by virtue of password protection. */ private void checkJoinRoomPreconditionPasswordProtection( @Nonnull final LocalMUCUser user, @Nullable String providedPassword ) throws UnauthorizedException { boolean canJoin = true; final JID bareJID = user.getAddress().asBareJID(); if (isPasswordProtected()) { final boolean isCorrectPassword = (providedPassword != null && providedPassword.equals(getPassword())); final boolean isSysadmin = mucService.isSysadmin(bareJID); final boolean requirePassword = !isSysadmin || mucService.isPasswordRequiredForSysadminsToJoinRoom(); if (!isCorrectPassword && requirePassword ) { canJoin = false; } } Log.trace( "{} Room join precondition 'password protection': User '{}' {} join room '{}'.", canJoin ? "PASS" : "FAIL", user.getAddress(), canJoin ? "can" : "cannot", this.getJID() ); if (!canJoin) { throw new UnauthorizedException( "You did not supply the correct password needed to join this room." ); } }
Example #10
Source File: ComponentStanzaHandler.java From Openfire with Apache License 2.0 | 6 votes |
@Override protected void processIQ(IQ packet) throws UnauthorizedException { if (session.getStatus() != Session.STATUS_AUTHENTICATED) { // Session is not authenticated so return error IQ reply = new IQ(); reply.setChildElement(packet.getChildElement().createCopy()); reply.setID(packet.getID()); reply.setTo(packet.getFrom()); reply.setFrom(packet.getTo()); reply.setError(PacketError.Condition.not_authorized); session.process(reply); return; } // Keep track of the component that sent an IQ get/set if (packet.getType() == IQ.Type.get || packet.getType() == IQ.Type.set) { // Handle subsequent bind packets LocalComponentSession componentSession = (LocalComponentSession) session; // Get the external component of this session LocalComponentSession.LocalExternalComponent component = (LocalComponentSession.LocalExternalComponent) componentSession.getExternalComponent(); component.track(packet); } super.processIQ(packet); }
Example #11
Source File: PresenceUpdateHandler.java From Openfire with Apache License 2.0 | 6 votes |
/** * Handle presence updates that affect roster subscriptions. * * @param presence The presence presence to handle * @throws PacketException if the packet is null or the packet could not be routed. */ public void process(Presence presence) throws PacketException { try { process((Packet)presence); } catch (UnauthorizedException e) { try { LocalSession session = (LocalSession) sessionManager.getSession(presence.getFrom()); presence = presence.createCopy(); if (session != null) { presence.setFrom(new JID(null, session.getServerName(), null, true)); presence.setTo(session.getAddress()); } else { JID sender = presence.getFrom(); presence.setFrom(presence.getTo()); presence.setTo(sender); } presence.setError(PacketError.Condition.not_authorized); deliverer.deliver(presence); } catch (Exception err) { Log.error(LocaleUtils.getLocalizedString("admin.error"), err); } } }
Example #12
Source File: PacketTransporterImpl.java From Openfire with Apache License 2.0 | 6 votes |
/** * Delivers the given packet based on packet recipient and sender. The * deliverer defers actual routing decisions to other classes. * <h2>Warning</h2> * Be careful to enforce concurrency DbC of concurrent by synchronizing * any accesses to class resources. * * @param packet The packet to route * @throws NullPointerException If the packet is null or the * packet could not be routed * @throws UnauthorizedException if the user is not authorised */ public void deliver(Packet packet) throws UnauthorizedException, PacketException { if (packet == null) { throw new NullPointerException(); } if (xmppServer != null && xmppServer.isLocal(packet.getTo())) { deliverer.deliver(packet); } else if (transportHandler != null) { transportHandler.process(packet); } else { Log.warn("Could not deliver message: no deliverer available " + packet.toString()); } }
Example #13
Source File: LocalMUCRoom.java From Openfire with Apache License 2.0 | 5 votes |
private void checkJoinRoomPreconditionDelegate( @Nonnull final LocalMUCUser user ) throws UnauthorizedException { boolean canJoin = true; if (((MultiUserChatServiceImpl)mucService).getMUCDelegate() != null) { if (!((MultiUserChatServiceImpl)mucService).getMUCDelegate().joiningRoom(this, user.getAddress())) { // Delegate said no, reject join. canJoin = false; } } Log.trace( "{} Room join precondition 'delegate': User '{}' {} join room '{}'.", canJoin ? "PASS" : "FAIL", user.getAddress(), canJoin ? "can" : "cannot", this.getJID() ); if (!canJoin) { throw new UnauthorizedException(); } }
Example #14
Source File: IQPrivateHandler.java From Openfire with Apache License 2.0 | 5 votes |
@Override public IQ handleIQ(IQ packet) throws UnauthorizedException, PacketException { IQ replyPacket = IQ.createResultIQ(packet); Element child = packet.getChildElement(); Element dataElement = child.elementIterator().next(); if ( !XMPPServer.getInstance().isLocal( packet.getFrom()) || !UserManager.getInstance().isRegisteredUser( packet.getFrom()) ) { replyPacket.setChildElement(packet.getChildElement().createCopy()); replyPacket.setError(PacketError.Condition.service_unavailable); replyPacket.getError().setText( "Service available only to locally registered users." ); return replyPacket; } if (dataElement != null) { if (IQ.Type.get.equals(packet.getType())) { Element dataStored = privateStorage.get(packet.getFrom().getNode(), dataElement); dataStored.setParent(null); child.remove(dataElement); child.setParent(null); replyPacket.setChildElement(child); child.add(dataStored); } else { if (privateStorage.isEnabled()) { privateStorage.add(packet.getFrom().getNode(), dataElement); } else { replyPacket.setChildElement(packet.getChildElement().createCopy()); replyPacket.setError(PacketError.Condition.service_unavailable); } } } else { replyPacket.setChildElement("query", "jabber:iq:private"); } return replyPacket; }
Example #15
Source File: HttpSessionManager.java From Openfire with Apache License 2.0 | 5 votes |
/** * Creates an HTTP binding session which will allow a user to exchange packets with Openfire. * * @param body the body element that was sent containing the request for a new session. * @param connection the HTTP connection object which abstracts the individual connections to * Openfire over the HTTP binding protocol. The initial session creation response is returned to * this connection. * @return the created HTTP session. * * @throws UnauthorizedException if the Openfire server is currently in an uninitialized state. * Either shutting down or starting up. * @throws HttpBindException when there is an internal server error related to the creation of * the initial session creation response. * @throws UnknownHostException if no IP address for the peer could be found */ public HttpSession createSession(HttpBindBody body, HttpConnection connection) throws UnauthorizedException, HttpBindException, UnknownHostException { // TODO Check if IP address is allowed to connect to the server HttpSession session = createSession(connection, Locale.forLanguageTag(body.getLanguage())); session.setWait(Math.min(body.getWait(), getMaxWait())); session.setHold(body.getHold()); session.setSecure(connection.isSecure()); session.setMaxPollingInterval(getPollingInterval()); session.setMaxRequests(getMaxRequests()); session.setMaxPause(getMaxPause()); if(session.isPollingSession()) { session.setDefaultInactivityTimeout(getPollingInactivityTimeout()); } else { session.setDefaultInactivityTimeout(getInactivityTimeout()); } session.resetInactivityTimeout(); session.setMajorVersion(body.getMajorVersion()); session.setMinorVersion(body.getMinorVersion()); connection.setSession(session); try { connection.deliverBody(createSessionCreationResponse(session), true); } catch (HttpConnectionClosedException | DocumentException | IOException e) { Log.error("Error creating session.", e); throw new HttpBindException("Internal server error", BoshBindingError.internalServerError); } return session; }
Example #16
Source File: CrowdAuthProvider.java From Openfire with Apache License 2.0 | 5 votes |
/** * Returns if the username and password are valid; otherwise this * method throws an UnauthorizedException.<p> * * @param username the username or full JID. * @param password the password * @throws UnauthorizedException if the username and password do * not match any existing user. * @throws ConnectionException it there is a problem connecting to user and group sytem * @throws InternalUnauthenticatedException if there is a problem authentication Openfire itself into the user and group system */ @Override public void authenticate(String username, String password) throws UnauthorizedException, ConnectionException, InternalUnauthenticatedException { if (manager == null) { throw new ConnectionException("Unable to connect to Crowd"); } if (username == null || password == null || "".equals(password.trim())) { throw new UnauthorizedException(); } if (username.contains("@")) { // Check that the specified domain matches the server's domain int index = username.indexOf("@"); String domain = username.substring(index + 1); if (domain.equals(XMPPServer.getInstance().getServerInfo().getXMPPDomain())) { username = username.substring(0, index); } else { // Unknown domain. Return authentication failed. throw new UnauthorizedException(); } } try { manager.authenticate(username, password); } catch (RemoteException re) { throw new UnauthorizedException(); } }
Example #17
Source File: LocalMUCRoom.java From Openfire with Apache License 2.0 | 5 votes |
/** * Checks all preconditions for joining a room. If one of them fails, an Exception is thrown. */ private void checkJoinRoomPreconditions( @Nonnull final LocalMUCUser user, @Nonnull final String nickname, @Nonnull final MUCRole.Affiliation affiliation, @Nullable final String password, @Nonnull final Presence presence) throws ServiceUnavailableException, RoomLockedException, UserAlreadyExistsException, UnauthorizedException, ConflictException, NotAcceptableException, ForbiddenException, RegistrationRequiredException { Log.debug( "Checking all preconditions for user '{}' to join room '{}'.", user.getAddress(), this.getJID() ); checkJoinRoomPreconditionDelegate( user ); // If the room has a limit of max user then check if the limit has been reached checkJoinRoomPreconditionMaxOccupants( user ); // If the room is locked and this user is not an owner raise a RoomLocked exception checkJoinRoomPreconditionLocked( user ); // Check if the nickname is already used in the room checkJoinRoomPreconditionNicknameInUse( user, nickname ); // If the room is password protected and the provided password is incorrect raise a // Unauthorized exception - unless the JID that is joining is a system admin. checkJoinRoomPreconditionPasswordProtection( user, password ); // If another user attempts to join the room with a nickname reserved by the first user // raise a ConflictException checkJoinRoomPreconditionNicknameReserved( user, nickname ); checkJoinRoomPreconditionRestrictedToNickname( user, nickname ); // Check if the user can join the room. checkJoinRoomPreconditionIsOutcast( user, affiliation ); // If the room is members-only and the user is not a member. Raise a "Registration Required" exception. checkJoinRoomPreconditionMemberOnly( user, affiliation ); Log.debug( "All preconditions for user '{}' to join room '{}' have been met. User can join the room.", user.getAddress(), this.getJID() ); }
Example #18
Source File: SessionManager.java From Openfire with Apache License 2.0 | 5 votes |
/** * Creates a session for a remote server. The session should be created only after the * remote server has been authenticated either using "server dialback" or SASL. * * @param conn the connection to the remote server. * @param id the stream ID used in the stream element when authenticating the server. * @param fromDomain The originating domain * @return the newly created {@link IncomingServerSession}. * @throws UnauthorizedException if the local server has not been initialized yet. */ public LocalIncomingServerSession createIncomingServerSession(Connection conn, StreamID id, String fromDomain) throws UnauthorizedException { if (serverName == null) { throw new UnauthorizedException("Server not initialized"); } LocalIncomingServerSession session = new LocalIncomingServerSession(serverName, conn, id, fromDomain); conn.init(session); // Register to receive close notification on this session so we can // remove its route from the sessions set conn.registerCloseListener(incomingServerListener, session); return session; }
Example #19
Source File: HttpSessionManager.java From Openfire with Apache License 2.0 | 5 votes |
private HttpSession createSession(HttpConnection connection, Locale language) throws UnauthorizedException, UnknownHostException { // Create a ClientSession for this user. StreamID streamID = SessionManager.getInstance().nextStreamID(); // Send to the server that a new client session has been created HttpSession session = sessionManager.createClientHttpSession(streamID, connection, language); // Register that the new session is associated with the specified stream ID sessionMap.put(streamID.getID(), session); SessionEventDispatcher.addListener( sessionListener ); return session; }
Example #20
Source File: FileTransferProxy.java From Openfire with Apache License 2.0 | 5 votes |
@Override public void process(Packet packet) throws UnauthorizedException, PacketException { // Check if the packet is a disco request or a packet with namespace iq:register if (packet instanceof IQ) { if (handleIQ((IQ) packet)) { // Do nothing } else { IQ reply = IQ.createResultIQ((IQ) packet); reply.setChildElement(((IQ) packet).getChildElement().createCopy()); reply.setError(PacketError.Condition.feature_not_implemented); router.route(reply); } } }
Example #21
Source File: DefaultFileTransferManager.java From Openfire with Apache License 2.0 | 5 votes |
@Override public void registerProxyTransfer(String transferDigest, ProxyTransfer proxyTransfer) throws UnauthorizedException { FileTransfer transfer = retrieveFileTransfer(transferDigest); if (isMatchProxyTransfer() && transfer == null) { throw new UnauthorizedException("Unable to match proxy transfer with a file transfer"); } else if (transfer == null) { return; } transfer.setProgress(proxyTransfer); cacheFileTransfer(transferDigest, transfer); }
Example #22
Source File: ServerSocketReader.java From Openfire with Apache License 2.0 | 5 votes |
@Override boolean createSession(String namespace) throws UnauthorizedException, XmlPullParserException, IOException { if ("jabber:server".equals(namespace)) { // The connected client is a server so create an IncomingServerSession session = LocalIncomingServerSession.createSession(serverName, reader, connection, directTLS); // After the session has been created, inform all listeners as well. ServerSessionEventDispatcher.dispatchEvent(session, ServerSessionEventDispatcher.EventType.session_created); return true; } return false; }
Example #23
Source File: SocketPacketWriteHandler.java From Openfire with Apache License 2.0 | 5 votes |
@Override public void process(Packet packet) throws UnauthorizedException, PacketException { try { JID recipient = packet.getTo(); // Check if the target domain belongs to a remote server or a component if (server.matchesComponent(recipient) || server.isRemote(recipient)) { routingTable.routePacket(recipient, packet, false); } // The target domain belongs to the local server else if (recipient == null || (recipient.getNode() == null && recipient.getResource() == null)) { // no TO was found so send back the packet to the sender routingTable.routePacket(packet.getFrom(), packet, false); } else if (recipient.getResource() != null || !(packet instanceof Presence)) { // JID is of the form <user@domain/resource> routingTable.routePacket(recipient, packet, false); } else { // JID is of the form <user@domain> for (JID route : routingTable.getRoutes(recipient, null)) { routingTable.routePacket(route, packet, false); } } } catch (Exception e) { Log.error(LocaleUtils.getLocalizedString("admin.error.deliver") + "\n" + packet.toString(), e); } }
Example #24
Source File: SocketConnection.java From Openfire with Apache License 2.0 | 5 votes |
@Override public void deliver(Packet packet) throws UnauthorizedException, PacketException { if (isClosed()) { backupDeliverer.deliver(packet); } else { boolean errorDelivering = false; boolean allowedToWrite = false; try { requestWriting(); allowedToWrite = true; xmlSerializer.write(packet.getElement()); if (flashClient) { writer.write('\0'); } xmlSerializer.flush(); } catch (Exception e) { Log.debug("Error delivering packet" + "\n" + this.toString(), e); errorDelivering = true; } finally { if (allowedToWrite) { releaseWriting(); } } if (errorDelivering) { close(); // Retry sending the packet again. Most probably if the packet is a // Message it will be stored offline backupDeliverer.deliver(packet); } else { session.incrementServerPacketCount(); } } }
Example #25
Source File: ComponentStanzaHandler.java From Openfire with Apache License 2.0 | 5 votes |
@Override protected void processPresence(Presence packet) throws UnauthorizedException { if (session.getStatus() != Session.STATUS_AUTHENTICATED) { // Session is not authenticated so return error Presence reply = new Presence(); reply.setID(packet.getID()); reply.setTo(packet.getFrom()); reply.setFrom(packet.getTo()); reply.setError(PacketError.Condition.not_authorized); session.process(reply); return; } super.processPresence(packet); }
Example #26
Source File: ComponentStanzaHandler.java From Openfire with Apache License 2.0 | 5 votes |
@Override protected void processMessage(Message packet) throws UnauthorizedException { if (session.getStatus() != Session.STATUS_AUTHENTICATED) { // Session is not authenticated so return error Message reply = new Message(); reply.setID(packet.getID()); reply.setTo(packet.getFrom()); reply.setFrom(packet.getTo()); reply.setError(PacketError.Condition.not_authorized); session.process(reply); return; } super.processMessage(packet); }
Example #27
Source File: MediaProxyService.java From Openfire with Apache License 2.0 | 5 votes |
@Override public void process(Packet packet) throws UnauthorizedException, PacketException { // Check if user is allowed to send packet to this service if (packet instanceof IQ) { // Handle disco packets IQ iq = (IQ) packet; // Ignore IQs of type ERROR or RESULT if (IQ.Type.error == iq.getType() || IQ.Type.result == iq.getType()) { return; } processIQ(iq); } }
Example #28
Source File: OfflinePacketDeliverer.java From Openfire with Apache License 2.0 | 5 votes |
@Override public void deliver(Packet packet) throws UnauthorizedException, PacketException { if (packet instanceof Message) { messageStrategy.storeOffline((Message) packet); } else if (packet instanceof Presence) { // presence packets are dropped silently } else if (packet instanceof IQ) { // IQ packets are logged before being dropped Log.warn(LocaleUtils.getLocalizedString("admin.error.routing") + "\n" + packet.toString()); } }
Example #29
Source File: NIOConnection.java From Openfire with Apache License 2.0 | 5 votes |
@Override public void deliver(Packet packet) throws UnauthorizedException { if (isClosed()) { backupDeliverer.deliver(packet); } else { boolean errorDelivering = false; IoBuffer buffer = IoBuffer.allocate(4096); buffer.setAutoExpand(true); try { buffer.putString(packet.getElement().asXML(), encoder.get()); if (flashClient) { buffer.put((byte) '\0'); } buffer.flip(); ioSessionLock.lock(); try { ioSession.write(buffer); } finally { ioSessionLock.unlock(); } } catch (Exception e) { Log.debug("Error delivering packet:\n" + packet, e); errorDelivering = true; } if (errorDelivering) { close(); // Retry sending the packet again. Most probably if the packet is a // Message it will be stored offline backupDeliverer.deliver(packet); } else { session.incrementServerPacketCount(); } } }
Example #30
Source File: LocationHandler.java From openfireLBS with Apache License 2.0 | 5 votes |
@Override public IQ handleIQ(IQ packet) throws UnauthorizedException { System.out.println(">>>>>>>>>>>>> RECV IQ: " + packet.toXML()); // XXX // get users near me(from JID) if (IQ.Type.get.equals(packet.getType())) { return getUsersNearme(packet); // set from JID's location to ... } else if (IQ.Type.set.equals(packet.getType())) { JID to = packet.getTo(); // send from JID's location to to JID if (to.getNode() != null && !to.getNode().equals("")){ XMPPServer.getInstance().getIQRouter().route(packet); // route to another user return IQ.createResultIQ(packet); // send from JID's location to server , and update ofLocation }else{ return updateLocation(packet); } } else { IQ reply = IQ.createResultIQ(packet); reply.setType(IQ.Type.error); reply.setError(PacketError.Condition.bad_request); return reply; } }