@Override
    public void execute(@Nonnull SessionData sessionData, Element command)
    {
        final Locale preferredLocale = SessionManager.getInstance().getLocaleForSession(sessionData.getOwner());

        Element note = command.addElement("note");

        Map<String, List<String>> data = sessionData.getData();

        // Let's create the jids and check that they are a local user
        boolean requestError = false;
        final List<JID> addresses = new ArrayList<>();
        for ( final String accountjid : data.get( "accountjids" ))
        {
            JID address;
            try
            {
                address = new JID( accountjid );

                if ( !XMPPServer.getInstance().isLocal( address ) )
                {
                    note.addAttribute( "type", "error" );
                    note.setText(LocaleUtils.getLocalizedString("commands.admin.user.endusersession.note.jid-not-local", List.of(accountjid), preferredLocale));
                    requestError = true;
                } else {
                    addresses.add(address);
                }
            }
            catch ( NullPointerException npe )
            {
                note.addAttribute( "type", "error" );
                note.setText(LocaleUtils.getLocalizedString("commands.admin.user.endusersession.note.jid-required", preferredLocale));
                requestError = true;
            }
            catch (IllegalArgumentException npe)
            {
                note.addAttribute( "type", "error" );
                note.setText(LocaleUtils.getLocalizedString("commands.admin.user.endusersession.note.jid-invalid", preferredLocale));
                requestError = true;
            }
        }

        if ( requestError )
        {
            // We've collected all errors. Return without applying changes.
            return;
        }

        // No errors. Disable all users.
        for (final JID address : addresses) {
            // Note: If the JID is of the form <user@host>, the service MUST end all of the user's sessions; if the JID
            // is of the form <user@host/resource>, the service MUST end only the session associated with that resource.
            final Collection<ClientSession> sessions = new HashSet<>();
            if (address.getResource() != null) {
                // Full JID: only close this session.
                sessions.add(SessionManager.getInstance().getSession(address));
            } else {
                // Bare JID: close all sessions for the user.
                sessions.addAll(SessionManager.getInstance().getSessions(address.getNode()));
            }

            for (final ClientSession session : sessions) {
                session.close();
            }
        }

        // Answer that the operation was successful
        note.addAttribute("type", "info");
        note.setText(LocaleUtils.getLocalizedString("commands.global.operation.finished.success", preferredLocale));
    }
End a user session

@author Guus der Kinderen, guus@goodbytes.nl
@see <a href="https://xmpp.org/extensions/xep-0133.html#end-user-session">XEP-0133 Service Administration: End User Session</a>
xmppserver/src/main/java/org/jivesoftware/openfire/commands/admin/user/EndUserSession.java