def _create_token_id(self): # Use a token signed by the cms module token_id = "" for i in range(1, 20): token_id += uuid.uuid4().hex return cms.cms_sign_token(token_id, CONF.signing.certfile, CONF.signing.keyfile)
def _get_token_id(self, token_data): try: token_id = cms.cms_sign_token(json.dumps(token_data), CONF.signing.certfile, CONF.signing.keyfile) return token_id except environment.subprocess.CalledProcessError: LOG.exception(_('Unable to sign token')) raise exception.UnexpectedError(_('Unable to sign token.'))
def _get_token_id(self, token_data): try: token_id = cms.cms_sign_token(json.dumps(token_data), CONF.signing.certfile, CONF.signing.keyfile) return token_id except environment.subprocess.CalledProcessError: LOG.exception(_('Unable to sign token')) raise exception.UnexpectedError(_( 'Unable to sign token.'))
def _get_token_id(self, token_data): try: # force conversion to a string as the keystone client cms code # produces unicode. This can be removed if the client returns # str() # TODO(ayoung): Make to a byte_str for Python3 token_json = jsonutils.dumps(token_data, cls=utils.PKIEncoder) token_id = str(cms.cms_sign_token(token_json, CONF.signing.certfile, CONF.signing.keyfile)) return token_id except environment.subprocess.CalledProcessError: LOG.exception(_LE("Unable to sign token")) raise exception.UnexpectedError(_("Unable to sign token."))
def _get_token_id(self, token_data): try: # force conversion to a string as the keystone client cms code # produces unicode. This can be removed if the client returns # str() # TODO(ayoung): Make to a byte_str for Python3 token_json = jsonutils.dumps(token_data, cls=utils.PKIEncoder) token_id = str( cms.cms_sign_token(token_json, CONF.signing.certfile, CONF.signing.keyfile)) return token_id except environment.subprocess.CalledProcessError: LOG.exception(_LE('Unable to sign token')) raise exception.UnexpectedError(_('Unable to sign token.'))
def _get_token_id(self, token_data): try: # force conversion to a string as the keystone client cms code # produces unicode. This can be removed if the client returns # str() # TODO(ayoung): Make to a byte_str for Python3 #original # token_id = str(cms.cms_sign_token(json.dumps(token_data), # CONF.signing.certfile, # CONF.signing.keyfile)) # sazzad modified here # taking the string of the token string_token=json.dumps(token_data) print(type(string_token)) print(string_token) # hash the token hashed_data = cms.cms_hash_data(string_token, mode='md5') token_id = str(cms.cms_sign_token(json.dumps(hashed_data), CONF.signing.certfile, CONF.signing.keyfile)) return token_id except environment.subprocess.CalledProcessError: LOG.exception(_('Unable to sign token')) raise exception.UnexpectedError(_( 'Unable to sign token.'))
def test_cms_sign_token_success(self): self.assertTrue( cms.cms_sign_token(self.examples.SIGNED_TOKEN_SCOPED, self.examples.SIGNING_CERT_FILE, self.examples.SIGNING_KEY_FILE))
def test_cms_sign_token_success(self): self.assertTrue( cms.cms_sign_token(client_fixtures.SIGNED_TOKEN_SCOPED, client_fixtures.SIGNING_CERT_FILE, client_fixtures.SIGNING_KEY_FILE))