Solution of the Dirac equation in presence of an uniform magnetic field