'Return a SAMLIdentityProvider instance for use by SAMLAuthBackend.
Essentially this just returns the values of this object and its
associated \'SAMLProviderData\' entry.'

def get_config(self):

    if self.other_settings:
        conf = json.loads(self.other_settings)
    else:
        conf = {}
    attrs = ('attr_user_permanent_id', 'attr_full_name', 'attr_first_name', 'attr_last_name', 'attr_username', 'attr_email', 'entity_id')
    for field in attrs:
        val = getattr(self, field)
        if val:
            conf[field] = val
    data = SAMLProviderData.current(self.entity_id)
    if ((not data) or (not data.is_valid())):
        log.error("No    SAMLProviderData    found    for    %s.    Run    'manage.py    saml    pull'    to    fix    or    debug.", self.entity_id)
        raise AuthNotConfigured(provider_name=self.name)
    conf['x509cert'] = data.public_key
    conf['url'] = data.sso_url
    idp_class = get_saml_idp_class(self.identity_provider_type)
    return idp_class(self.idp_slug, **conf)
