<filename>tools/dockerize/webportal/usr/lib/python2.7/site-packages/daoliproxy/api/user.py
import hashlib

from oslo.config import cfg

from daoliproxy.utils import replace_url
from daoliproxy.utils import is_ans1_token

CONF = cfg.CONF
CONF.register_opt(cfg.IntOpt('identity_version', default=2.0))


class Token(object):
    """Token object that encapsulates the auth_ref (AccessInfo)from keystone
       client.

       Added for maintaining backward compatibility with horizon that expects
       Token object in the user object.
    """
    def __init__(self, auth_ref, host=None):
        # User-related attributes
        user = {}
        user['id'] = auth_ref.user_id
        user['name'] = auth_ref.username
        self.user = user
        self.user_domain_id = auth_ref.user_domain_id
        self.user_domain_name = auth_ref.user_domain_name

        # Token-related attributes
        self.id = auth_ref.auth_token
        if len(self.id) > 64:
            algorithm = 'md5'
            hasher = hashlib.new(algorithm)
            hasher.update(self.id)
            self.id = hasher.hexdigest()
        self.expires = auth_ref.expires

        # Project-related attributes
        project = {}
        project['id'] = auth_ref.project_id
        project['name'] = auth_ref.project_name
        self.project = project
        self.tenant = self.project

        if auth_ref.version == 'v2.0':
            self.roles = auth_ref['user'].get('roles', [])
        else:
            self.roles = auth_ref.get('roles', [])

        if CONF.identity_version < 3:
            self.serviceCatalog = auth_ref.get('serviceCatalog', [])
        else:
            self.serviceCatalog = auth_ref.get('catalog', [])

        if host is not None and self.serviceCatalog:
            for service in self.serviceCatalog:
                for endpoint in service['endpoints']:
                    endpoint['publicURL'] = replace_url(endpoint['publicURL'], host)

    @property
    def default_services_region(self):
        """
        Returns the first endpoint region for first non-identify service
        in the service catalog
        """
        if self.serviceCatalog:
            for service in self.serviceCatalog:
                if service['type'] == 'identity':
                    continue
                for endpoint in service['endpoints']:
                    return endpoint['region']
        return None

<filename>tools/dockerize/webportal/usr/lib/python2.7/site-packages/daoliproxy/api/user.py
import hashlib

from oslo.config import cfg

from daoliproxy.utils import replace_url
from daoliproxy.utils import is_ans1_token

CONF = cfg.CONF
CONF.register_opt(cfg.IntOpt('identity_version', default=2.0))


class Token(object):
    """Token object that encapsulates the auth_ref (AccessInfo)from keystone
       client.

       Added for maintaining backward compatibility with horizon that expects
       Token object in the user object.
    """
    def __init__(self, auth_ref, host=None):
        # User-related attributes
        user = {}
        user['id'] = auth_ref.user_id
        user['name'] = auth_ref.username
        self.user = user
        self.user_domain_id = auth_ref.user_domain_id
        self.user_domain_name = auth_ref.user_domain_name

        # Token-related attributes
        self.id = auth_ref.auth_token
        if len(self.id) > 64:
            algorithm = 'md5'
            hasher = hashlib.new(algorithm)
            hasher.update(self.id)
            self.id = hasher.hexdigest()
        self.expires = auth_ref.expires

        # Project-related attributes
        project = {}
        project['id'] = auth_ref.project_id
        project['name'] = auth_ref.project_name
        self.project = project
        self.tenant = self.project

        if auth_ref.version == 'v2.0':
            self.roles = auth_ref['user'].get('roles', [])
        else:
            self.roles = auth_ref.get('roles', [])

        if CONF.identity_version < 3:
            self.serviceCatalog = auth_ref.get('serviceCatalog', [])
        else:
            self.serviceCatalog = auth_ref.get('catalog', [])

        if host is not None and self.serviceCatalog:
            for service in self.serviceCatalog:
                for endpoint in service['endpoints']:
                    endpoint['publicURL'] = replace_url(endpoint['publicURL'], host)

    @property
    def default_services_region(self):
        """
        Returns the first endpoint region for first non-identify service
        in the service catalog
        """
        if self.serviceCatalog:
            for service in self.serviceCatalog:
                if service['type'] == 'identity':
                    continue
                for endpoint in service['endpoints']:
                    return endpoint['region']
        return None

Token object that encapsulates the auth_ref (AccessInfo)from keystone        client.         Added for maintaining backward compatibility with horizon that expects        Token object in the user object. # User-related attributes # Token-related attributes # Project-related attributes Returns the first endpoint region for first non-identify service         in the service catalog