BERLIN—German politicians are debating a new Internet-security law that could exclude U.S. technology companies from Germany’s digital economy, a sign Berlin is beginning to press its commercial advantage after revelations of spying by the NSA.

The draft law, which is still being hammered out, envisions new requirements like revealing source code or other proprietary data for companies that sell information technology to the German government or to private companies that are part of industries Berlin deems critical to the...