private void checkJoinRoomPreconditionPasswordProtection(@Nonnull final JID realAddress, @Nullable String providedPassword ) throws UnauthorizedException
    {
        boolean canJoin = true;
        final JID bareJID = realAddress.asBareJID();
        if (isPasswordProtected()) {
            final boolean isCorrectPassword = (providedPassword != null && providedPassword.equals(getPassword()));
            final boolean isSysadmin = mucService.isSysadmin(bareJID);
            final boolean requirePassword = !isSysadmin || mucService.isPasswordRequiredForSysadminsToJoinRoom();
            if (!isCorrectPassword && requirePassword ) {
                canJoin = false;
            }
        }
        Log.trace( "{} Room join precondition 'password protection': User '{}' {} join room '{}'.", canJoin ? "PASS" : "FAIL", realAddress, canJoin ? "can" : "cannot", this.getJID() );
        if (!canJoin) {
            throw new UnauthorizedException( "You did not supply the correct password needed to join this room." );
        }
    }
Checks if the user provided the correct password, if applicable.

@param realAddress The address of the user that attempts to join.
@throws UnauthorizedException when joining is prevented by virtue of password protection.
xmppserver/src/main/java/org/jivesoftware/openfire/muc/MUCRoom.java