Quantum theory of light scattering for arbitrary finite-size dielectric and conducting structures