'Common code shared between the V2 and V3 authenticate methods.
:returns: user_ref, tenant_ref, roles_ref, catalog_ref'

def _authenticate(self, credentials=None, ec2credentials=None):

    if ((not credentials) and ec2credentials):
        credentials = ec2credentials
    if ('access' not in credentials):
        raise exception.Unauthorized(message=_('EC2    signature    not    supplied.'))
    creds_ref = self._get_credentials(credentials['access'])
    self.check_signature(creds_ref, credentials)
    tenant_ref = self.resource_api.get_project(creds_ref['tenant_id'])
    user_ref = self.identity_api.get_user(creds_ref['user_id'])
    try:
        self.identity_api.assert_user_enabled(user_id=user_ref['id'], user=user_ref)
        self.resource_api.assert_domain_enabled(domain_id=user_ref['domain_id'])
        self.resource_api.assert_project_enabled(project_id=tenant_ref['id'], project=tenant_ref)
    except AssertionError as e:
        six.reraise(exception.Unauthorized, exception.Unauthorized(e), sys.exc_info()[2])
    roles = self.assignment_api.get_roles_for_user_and_project(user_ref['id'], tenant_ref['id'])
    if (not roles):
        raise exception.Unauthorized(message=_('User    not    valid    for    tenant.'))
    roles_ref = [self.role_api.get_role(role_id) for role_id in roles]
    catalog_ref = self.catalog_api.get_catalog(user_ref['id'], tenant_ref['id'])
    return (user_ref, tenant_ref, roles_ref, catalog_ref)
