  The junction conditions for the most general gravitational theory with a
Lagrangian containing terms quadratic in the curvature are derived. We include
the cases with a possible concentration of matter on the joining hypersurface
-termed as thin shells, domain walls or braneworlds in the literature- as well
as the proper matching conditions where only finite jumps of the
energy-momentum tensor are allowed. In the latter case we prove that the
matching conditions are more demanding than in General Relativity. In the
former case, we show that generically the shells/domain walls are of a new kind
because they possess, in addition to the standard energy-momentum tensor, a
double layer energy-momentum contribution which actually induces an external
energy flux vector and an external scalar pressure/tension on the shell. We
prove that all these contributions are necessary to make the entire
energy-momentum tensor divergence-free, and we present the field equations
satisfied by these energy-momentum quantities. The consequences of all these
results are briefly analyzed.
