I want to change the color of the shadow casting by a cube to green. While it's very easy to do it in Blender Internal (you select the lamp, go to the Lamp data header and change the shadow's color in the Shadow panel) in Cycles there're no such options. How to achieve it in Cycles?
With the Cycles renderer enabled select the cube, give it a new material and set the material nodes as pictured below. Use the Is Camera Ray of the Light Path node as a factor for mixing the Diffuse and Transparent nodes (Is Shadow Ray works good as well).