Quantitative theory of the Josephson effect in SFIFS junctions (S denotes bulk superconductor, F -- metallic ferromagnet, I -- insulating barrier) is presented in the dirty limit. Fully self-consistent numerical procedure is employed to solve the Usadel equations at arbitrary values of the F-layers thicknesses, magnetizations, and interface parameters. Various types of the current-phase relation I(φ) in superconductor-ferromagnet-superconductor (SFS) point contacts and planar double-barrier junctions are studied within the quasiclassical theory in the limit of thin diffusive ferromagnetic interlayers. The physical mechanisms leading to highly nontrivial I(φ) dependence are identified by studying the spectral supercurrent density. These mechanisms are also responsible for the 0-π transition in SFS Josephson junctions.