public List<Presence> addOutcast(@Nonnull final JID targetUserAddress, @Nullable final String reason, @Nullable final JID actorUserAddress, @Nonnull final Affiliation actorAffiliation, @Nullable final Role actorRole) throws NotAllowedException, ForbiddenException, ConflictException
    {
        if (Affiliation.admin != actorAffiliation && Affiliation.owner != actorAffiliation && Role.moderator != actorRole) {
            throw new ForbiddenException();
        }

        final JID targetUserAddressBare = targetUserAddress.asBareJID();

        synchronized (this) {
            // Check that the room always has an owner
            if (owners.contains(targetUserAddressBare) && owners.size() == 1) {
                throw new ConflictException();
            }
            // Check if user is already an outcast
            if (outcasts.contains(targetUserAddressBare)) {
                // Do nothing
                return Collections.emptyList();
            }

            // Remove the user from other affiliation lists. This can throw a 'forbidden' when the actor tries to demote a higher-up!
            final Affiliation oldAffiliation = getAffiliation(targetUserAddressBare);
            switch (oldAffiliation) {
                case owner:
                    removeOwner(targetUserAddressBare, actorAffiliation);
                    break;
                case admin:
                    removeAdmin(targetUserAddressBare, actorAffiliation);
                    break;
                case member:
                    removeMember(targetUserAddressBare, actorAffiliation, actorRole);
                    break;
            }

            // Update the affiliation lists
            outcasts.add(targetUserAddressBare);

            // Update the DB if the room is persistent
            MUCPersistenceManager.saveAffiliationToDB(
                this,
                targetUserAddressBare,
                null,
                Affiliation.outcast,
                oldAffiliation);
        }
        // apply the affiliation change, assigning a new affiliation
        // based on the group(s) of the affected user(s)
        return applyAffiliationChange(targetUserAddressBare, actorUserAddress, null, reason);
    }
Adds a new user to the list of outcast users.

@param targetUserAddress The (real) JID of the user to add as an outcast.
@param reason an optional reason why the user was banned.
@param actorUserAddress The (real) address of the user that initiated the ban.
@param actorAffiliation The room affiliation of the user that initiated the ban.
@param actorRole The room role of the user that initiated the ban (can be null when the user is currently not an occupant).
@return the list of updated presences of all the client resources that the client used to
        join the room.
@throws NotAllowedException Thrown if trying to ban an owner or an administrator.
@throws ForbiddenException If the user is not allowed to modify the outcast list.
@throws ConflictException If the room was going to lose all its owners.
xmppserver/src/main/java/org/jivesoftware/openfire/muc/MUCRoom.java