Converted from https://code.google.com/p/django-saml2-idp/