The cohomology ring of certain compactified Jacobians