@Override
    public void process(Presence presence) throws PacketException {
        try {
            process(presence, sessionManager.getSession(presence.getFrom()));
        }
        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);
            }
        }
    }
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.
xmppserver/src/main/java/org/jivesoftware/openfire/handler/PresenceUpdateHandler.java