def in_realm(self, name, realm, strict=True):
        """ Simple test - is the given L{name} in the realm L{realm}

        @type name: str
        @param name: The name (account name group name)

        @type realm: str
        @param realm: The realm, e.g. 'webid.uio.no'

        @type strict: bool
        @param strict: If false, we consider 'some.sub.realm' as being in the realm
                      'realm'. Otherwise, the realm must be an exact match.

        @rtype: bool
        @return: True if the name is within the realm, false if not.
        """
        assert isinstance(name, (str, six.text_type)), 'Invalid name'
        assert not self.illegal_realm(realm), 'Invalid realm'

        # We know the realm only contains :alnum: and periods. Should be safe to do:
        regex_realm = realm.replace('.', '\.')
        regex = re.compile('^(.+)@((.+\.)?%s)$' % regex_realm)
        # Groups: 1: <name>, 2: <matched realm> (3: <subrealm.>)

        match = regex.match(name)
        if not match:
            return False
        assert isinstance(match.group(1), (str, six.text_type))
        assert isinstance(match.group(2), (str, six.text_type))

        if not strict:
            return not self.illegal_realm(match.group(2))

        return match.group(2) == realm