private void checkJoinRoomPreconditions(
        @Nonnull final JID realAddress,
        @Nonnull final String nickname,
        @Nonnull final 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 '{}'.", realAddress, this.getJID() );

        checkJoinRoomPreconditionDelegate( realAddress );

        // If the room has a limit of max user then check if the limit has been reached
        checkJoinRoomPreconditionMaxOccupants( realAddress );

        // If the room is locked and this user is not an owner raise a RoomLocked exception
        checkJoinRoomPreconditionLocked( realAddress );

        // Check if the nickname is already used in the room
        checkJoinRoomPreconditionNicknameInUse( realAddress, nickname );

        // If the room is password protected and the provided password is incorrect raise an
        // Unauthorized exception - unless the JID that is joining is a system admin.
        checkJoinRoomPreconditionPasswordProtection( realAddress, password );

        // If another user attempts to join the room with a nickname reserved by the first user
        // raise a ConflictException
        checkJoinRoomPreconditionNicknameReserved( realAddress, nickname );

        checkJoinRoomPreconditionRestrictedToNickname( realAddress, nickname );

        // Check if the user can join the room.
        checkJoinRoomPreconditionIsOutcast( realAddress, affiliation );

        // If the room is members-only and the user is not a member. Raise a "Registration Required" exception.
        checkJoinRoomPreconditionMemberOnly( realAddress, affiliation );

        Log.debug( "All preconditions for user '{}' to join room '{}' have been met. User can join the room.", realAddress, this.getJID() );
    }
Checks all preconditions for joining a room. If one of them fails, an Exception is thrown.
xmppserver/src/main/java/org/jivesoftware/openfire/muc/MUCRoom.java