@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();

        boolean requestError = false;
        final List<String> listed = new ArrayList<>();
        for ( final String whitelistjid : data.get( "whitelistjids" ))
        {
            JID domain;
            try
            {
                domain = new JID( whitelistjid );
                if (domain.getResource() != null || domain.getNode() != null) {
                    note.addAttribute( "type", "error" );
                    note.setText(LocaleUtils.getLocalizedString("commands.admin.editallowedlist.note.jid-domain-required", List.of(whitelistjid), preferredLocale));
                    requestError = true;
                }

                listed.add(domain.getDomain());
            }
            catch ( NullPointerException npe )
            {
                note.addAttribute( "type", "error" );
                note.setText(LocaleUtils.getLocalizedString("commands.admin.editallowedlist.note.jid-required", preferredLocale));
                requestError = true;
            }
            catch (IllegalArgumentException npe)
            {
                note.addAttribute( "type", "error" );
                note.setText(LocaleUtils.getLocalizedString("commands.admin.editallowedlist.note.jid-invalid", preferredLocale));
                requestError = true;
            }
        }

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

        // No errors.
        final Collection<RemoteServerConfiguration> allowedServers = RemoteServerManager.getAllowedServers();
        for (final String domain : listed) {
            if (allowedServers.stream().noneMatch(s -> s.getDomain().equals(domain))) {
                final RemoteServerConfiguration configuration = new RemoteServerConfiguration( domain );
                configuration.setPermission( RemoteServerConfiguration.Permission.allowed );
                RemoteServerManager.allowAccess(configuration);
            }
        }
        for (final RemoteServerConfiguration allowedServer : allowedServers) {
            if ( !listed.contains(allowedServer.getDomain())) {
                // No longer on the list.
                RemoteServerManager.deleteConfiguration(allowedServer.getDomain());
            }
        }

        // Answer that the operation was successful
        note.addAttribute("type", "info");
        note.setText(LocaleUtils.getLocalizedString("commands.global.operation.finished.success", preferredLocale));
    }
Edits the list of external domains that are allowed to connect to Openfire

@author Guus der Kinderen, guus@goodbytes.nl
@see <a href="https://xmpp.org/extensions/xep-0133.html#edit-whitelist">XEP-0133 Service Administration: Edit Whitelist</a>
xmppserver/src/main/java/org/jivesoftware/openfire/commands/admin/EditAllowedList.java