This sounds like the Investigatory Powers Act in the UK, though I haven't heard of similar laws in other liberal democracies.