'Registers email_id as SAML2 Based Auth.'

@defer.inlineCallbacks
def register_saml2(self, localpart):

    if (urllib.quote(localpart) != localpart):
        raise SynapseError(400, 'User    ID    must    only    contain    characters    which    do    not    require    URL    encoding.')
    user = UserID(localpart, self.hs.hostname)
    user_id = user.to_string()
    (yield self.check_user_id_not_appservice_exclusive(user_id))
    token = self.macaroon_gen.generate_access_token(user_id)
    try:
        (yield self.store.register(user_id=user_id, token=token, password_hash=None, create_profile_with_localpart=user.localpart))
    except Exception as e:
        (yield self.store.add_access_token_to_user(user_id, token))
        logger.exception(e)
    defer.returnValue((user_id, token))
