  We present a detailed and self-consistent modeling of the cosmic X-ray
background (XRB) based on the most up-to-date X-ray luminosity functions (XLF)
and evolution of Active Galactic Nuclei (AGN). The large body of observational
results collected by soft (0.5-2 keV) and hard (2-10 keV) X-ray surveys are
used to constrain at best the properties of the Compton-thin AGN population and
its contribution to the XRB emission. The number ratio R between moderately
obscured (Compton-thin) AGN and unobscured AGN is fixed by the comparison
between the soft and hard XLFs, which suggests that R decreases from 4 at low
luminosities to 1 at high luminosities. From the same comparison there is no
clear evidence of an evolution of the obscured AGN fraction with redshift. The
distribution of the absorbing column densities in obscured AGN is determined by
matching the soft and hard source counts. A distribution rising towards larger
column densities is able to reproduce the soft and hard AGN counts over about 6
dex in flux. The model also reproduces with excellent accuracy the fraction of
obscured objects in AGN samples selected at different X-ray fluxes. The
integrated emission of the Compton-thin AGN population is found to
underestimate the XRB flux at about 30 keV and a population of heavily obscured
-Compton-thick- AGN, as large as that of moderately obscured AGN, is required
to fit the residual background emission. Remarkably, the fractions of
Compton-thick AGN observed in the Chandra Deep Field South and in the first
INTEGRAL and Swift catalogs of AGN selected above 10 keV are in excellent
agreement with the model predictions. [abridged]
