Minnesota judge allows 'necessity defense' in pipeline case