Refactor context trust_id check to wsgi.Application base class

Move the ec2 controller check for a trust_id in the token
specified in the request context, renaming it to match the
existing convention in the controller base classes.

This function can be used by both v2 and v3 controllers
hence putting it into the common Application base class.

Test coverage for this is provided via existing tests in
test_keystoneclient_sql.py

Change-Id: I6028a2cfa0e9e2e16acc99b5a0a027cd6cc42ada
Partial-Bug: #1259584
Store trust_id for v3/credentials ec2 keypairs

To fix bug #1259584 without re-opening the vulnerablility fixed in
bug #1242597, we need to store the trust_id in the data blob when
storing an ec2 keypair via the v3/credentials API.  This is already
done when keypairs are created/stored via the ec2tokens interface,
so this aligns the behavior when the credentials are created via
v3/credentials.

Change-Id: I8443d30dffed4201b46d10cef6a0bb43ccdcddc1
Partial-Bug: #1259584
Store ec2 credentials blob as json

For compatibility with the v3/credentials API, the blob dict should
be stored serialized as json.  To maintain backwards compatibility
with existing DB contents stored via the ec2tokens interface, we
fall back to the previous behavior if we fail to load the blob.

Change-Id: I21f068c308df5aa6a818031d3bc86a81b2bd25f4
Closes-Bug: #1259584
v3 credentials, ensure blob response is json

The v3/credentials API specifies the blob response to be json, but
due to bug #1259584, any credentials stored via the ec2tokens extension
will incorrectly return a dict.  This makes it hard for clients (and
in particular users migrating from ec2tokens to v3/credentials) to
handle the blob data consistently, so add a workaround to ensure the
response is always serialized as json if the existing DB contents is
a dict instead of a json string.

Change-Id: I340cdf4e565fdadacb41b39acace3948aafb9b92
Related-Bug: #1259584
Closes-Bug: #1269637
Merge "Refactor context trust_id check to wsgi.Application base class"
Merge "Store trust_id for v3/credentials ec2 keypairs"
Merge "Store ec2 credentials blob as json"
Merge "v3 credentials, ensure blob response is json"