Police have charged a man allegedly motivated by racist ideology who was planning a terrorist attack targeting public buildings and mosques.