'Get groups for the given token.
:param env: The current WSGI environment dictionary.
:param token: Token to validate and return a group string for.
:returns: None if the token is invalid or a string containing a comma
separated list of groups the authenticated user is a member
of. The first group in the list is also considered a unique
identifier for that user.'

def get_groups(self, env, token):

    groups = None
    memcache_client = cache_from_env(env)
    if (not memcache_client):
        raise Exception('Memcache    required')
    memcache_token_key = ('%s/token/%s' % (self.reseller_prefix, token))
    cached_auth_data = memcache_client.get(memcache_token_key)
    if cached_auth_data:
        (expires, groups) = cached_auth_data
        if (expires < time()):
            groups = None
    s3_auth_details = env.get('swift3.auth_details')
    if s3_auth_details:
        account_user = s3_auth_details['access_key']
        signature_from_user = s3_auth_details['signature']
        if (account_user not in self.users):
            return None
        (account, user) = account_user.split(':', 1)
        account_id = self.users[account_user]['url'].rsplit('/', 1)[(-1)]
        path = env['PATH_INFO']
        env['PATH_INFO'] = path.replace(account_user, account_id, 1)
        valid_signature = base64.encodestring(hmac.new(self.users[account_user]['key'], s3_auth_details['string_to_sign'], sha1).digest()).strip()
        if (signature_from_user != valid_signature):
            return None
        groups = self._get_user_groups(account, account_user, account_id)
    return groups
