Optical properties of excitons in semiconductor superlattices and microcavities