Fix typo of ANS1 to ASN1
Replace all occurrences of 'ANS1|ans1' with 'ASN1|asn1'. Keep cms.is_ans1_token() around for backwards compatibility. Change-Id: I89da78b89aa9daf2637754dc93031d7ca81e85cb Closes-bug: 1306874
This commit is contained in:
@@ -29,7 +29,7 @@ from keystoneclient import exceptions
|
|||||||
|
|
||||||
subprocess = None
|
subprocess = None
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
PKI_ANS1_PREFIX = 'MII'
|
PKI_ASN1_PREFIX = 'MII'
|
||||||
|
|
||||||
|
|
||||||
def _ensure_subprocess():
|
def _ensure_subprocess():
|
||||||
@@ -166,7 +166,7 @@ def verify_token(token, signing_cert_file_name, ca_file_name):
|
|||||||
ca_file_name)
|
ca_file_name)
|
||||||
|
|
||||||
|
|
||||||
def is_ans1_token(token):
|
def is_asn1_token(token):
|
||||||
"""Determine if a token appears to be PKI-based.
|
"""Determine if a token appears to be PKI-based.
|
||||||
|
|
||||||
thx to ayoung for sorting this out.
|
thx to ayoung for sorting this out.
|
||||||
@@ -213,7 +213,14 @@ def is_ans1_token(token):
|
|||||||
It's not practical to support a token of this length or greater in http
|
It's not practical to support a token of this length or greater in http
|
||||||
therefore, we will check for MII only and ignore the case of larger tokens
|
therefore, we will check for MII only and ignore the case of larger tokens
|
||||||
"""
|
"""
|
||||||
return token[:3] == PKI_ANS1_PREFIX
|
return token[:3] == PKI_ASN1_PREFIX
|
||||||
|
|
||||||
|
|
||||||
|
def is_ans1_token(token):
|
||||||
|
"""Deprecated. Use is_asn1_token() instead."""
|
||||||
|
LOG.warning("The function is_ans1_token() is deprecated, "
|
||||||
|
"use is_asn1_token() instead.")
|
||||||
|
return is_asn1_token(token)
|
||||||
|
|
||||||
|
|
||||||
def cms_sign_text(text, signing_cert_file_name, signing_key_file_name):
|
def cms_sign_text(text, signing_cert_file_name, signing_key_file_name):
|
||||||
@@ -264,12 +271,12 @@ def cms_to_token(cms_text):
|
|||||||
def cms_hash_token(token_id, mode='md5'):
|
def cms_hash_token(token_id, mode='md5'):
|
||||||
"""Hash PKI tokens.
|
"""Hash PKI tokens.
|
||||||
|
|
||||||
return: for ans1_token, returns the hash of the passed in token
|
return: for asn1_token, returns the hash of the passed in token
|
||||||
otherwise, returns what it was passed in.
|
otherwise, returns what it was passed in.
|
||||||
"""
|
"""
|
||||||
if token_id is None:
|
if token_id is None:
|
||||||
return None
|
return None
|
||||||
if is_ans1_token(token_id):
|
if is_asn1_token(token_id):
|
||||||
hasher = hashlib.new(mode)
|
hasher = hashlib.new(mode)
|
||||||
if isinstance(token_id, six.text_type):
|
if isinstance(token_id, six.text_type):
|
||||||
token_id = token_id.encode('utf-8')
|
token_id = token_id.encode('utf-8')
|
||||||
|
@@ -847,7 +847,7 @@ class AuthProtocol(object):
|
|||||||
cached = self._cache_get(token_id)
|
cached = self._cache_get(token_id)
|
||||||
if cached:
|
if cached:
|
||||||
return cached
|
return cached
|
||||||
if cms.is_ans1_token(user_token):
|
if cms.is_asn1_token(user_token):
|
||||||
verified = self.verify_signed_token(user_token)
|
verified = self.verify_signed_token(user_token)
|
||||||
data = jsonutils.loads(verified)
|
data = jsonutils.loads(verified)
|
||||||
else:
|
else:
|
||||||
|
@@ -48,9 +48,9 @@ class CMSTest(utils.TestCase, testresources.ResourcedTestCase):
|
|||||||
self.examples.SIGNED_TOKEN_SCOPED))
|
self.examples.SIGNED_TOKEN_SCOPED))
|
||||||
self.assertEqual(tok, self.examples.SIGNED_TOKEN_SCOPED)
|
self.assertEqual(tok, self.examples.SIGNED_TOKEN_SCOPED)
|
||||||
|
|
||||||
def test_ans1_token(self):
|
def test_asn1_token(self):
|
||||||
self.assertTrue(cms.is_ans1_token(self.examples.SIGNED_TOKEN_SCOPED))
|
self.assertTrue(cms.is_asn1_token(self.examples.SIGNED_TOKEN_SCOPED))
|
||||||
self.assertFalse(cms.is_ans1_token('FOOBAR'))
|
self.assertFalse(cms.is_asn1_token('FOOBAR'))
|
||||||
|
|
||||||
def test_cms_sign_token_no_files(self):
|
def test_cms_sign_token_no_files(self):
|
||||||
self.assertRaises(subprocess.CalledProcessError,
|
self.assertRaises(subprocess.CalledProcessError,
|
||||||
@@ -119,7 +119,7 @@ class CMSTest(utils.TestCase, testresources.ResourcedTestCase):
|
|||||||
def test_cms_hash_token_not_pki(self):
|
def test_cms_hash_token_not_pki(self):
|
||||||
"""If the token_id is not a PKI token then it returns the token_id."""
|
"""If the token_id is not a PKI token then it returns the token_id."""
|
||||||
token = 'something'
|
token = 'something'
|
||||||
self.assertFalse(cms.is_ans1_token(token))
|
self.assertFalse(cms.is_asn1_token(token))
|
||||||
self.assertThat(cms.cms_hash_token(token), matchers.Is(token))
|
self.assertThat(cms.cms_hash_token(token), matchers.Is(token))
|
||||||
|
|
||||||
def test_cms_hash_token_default_md5(self):
|
def test_cms_hash_token_default_md5(self):
|
||||||
|
Reference in New Issue
Block a user