[saml] remove unused imports, remove * imports

This commit is contained in:
Benjamin Dauvergne 2011-04-27 11:48:32 +02:00
parent 35d50069c1
commit 4314565ee6
7 changed files with 17 additions and 43 deletions

View File

@ -3,9 +3,7 @@ import urllib
from django.contrib import admin
from django.utils.translation import ugettext as _
from django.conf import settings
from django.http import HttpResponseRedirect
from django.forms import ModelForm
from django.conf.urls.defaults import patterns, url
import django.forms
from django.contrib import messages

View File

@ -5,6 +5,7 @@ import httplib
import logging
import re
import datetime
import time
import lasso
from django.template import RequestContext
@ -13,12 +14,17 @@ from django.http import HttpResponseRedirect, Http404, HttpResponse
from django.shortcuts import render_to_response
from django.utils.translation import ugettext as _
from django.db import transaction
from django.core.exceptions import ValidationError
from django.core.exceptions import ObjectDoesNotExist
from models import *
from models import LibertyFederation, LibertyIdentityDump, LibertyProvider, \
LibertyManageDump, LibertySessionDump, LibertyServiceProvider, \
LibertyIdentityProvider, LibertySessionSP, IdPOptionsSPPolicy, \
AuthorizationSPPolicy, AuthorizationAttributeMapping, \
LIBERTY_SESSION_DUMP_KIND_IDP
import models
import saml2utils
import saml11utils
import authentic2.utils
from authentic2.authsaml2 import signals
@ -430,7 +436,7 @@ def lookup_federation_by_user(user, qualifier):
fed = LibertyFederation.objects.filter(user=user, name_id_qualifier=qualifier)
if fed and fed.count()>1:
# TODO: delete all but the last record
raise Exception('Unconsistent federation record for %s' % ni)
raise Exception('Unconsistent federation record for %s' % qualifier)
if not fed:
return None
return fed[0]

View File

@ -7,8 +7,8 @@ from django import forms
from django.db import models
from django.core.exceptions import ValidationError
from django.utils.text import capfirst
from django.contrib.humanize import apnumber
from django.template.defaultfilters import pluralize
# This is a copy of http://djangosnippets.org/snippets/513/
#
@ -115,8 +115,7 @@ class MultiSelectField(models.Field):
return self.get_choices(include_blank=False)
def _get_FIELD_display(self, field):
value = getattr(self, field.attname)
choicedict = dict(field.choices)
pass
def formfield(self, **kwargs):
# don't call super, as that overrides default widget if it has choices

View File

@ -1,5 +1,3 @@
import os.path
import time
import xml.etree.ElementTree as etree
import hashlib
import binascii
@ -11,12 +9,11 @@ from django.db import models
from django.conf import settings
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from django.core.files.storage import FileSystemStorage
from django.utils.translation import ugettext as _
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
from django.core.exceptions import ObjectDoesNotExist
from django.utils.importlib import import_module
from fields import *
from fields import PickledObjectField, MultiSelectField
# TODO: add other name formats with lasso next release
ATTRIBUTE_VALUE_FORMATS = (
@ -45,6 +42,7 @@ def get_prefered_content(etrees, languages = [None, 'en']):
else.
'''
best = None
best_score = -1
for tree in etrees:
if best is not None:
i = ls_find(languages, get_lang(tree))

View File

@ -1,8 +1,6 @@
import xml.etree.ElementTree as etree
import lasso
import x509utils
import base64
import binascii
from saml2utils import bool2xs, NamespacedTreeBuilder, keyinfo
class Saml11Metadata(object):
@ -156,11 +154,11 @@ class Saml11Metadata(object):
self.tb.end(self.IDP_SSO_DESCRIPTOR)
def generate_sp_descriptor(self, map, options):
self.generate_sso_descriptor(SP_SSO_DESCRIPTOR, map, options)
self.generate_sso_descriptor(self.SP_SSO_DESCRIPTOR, map, options)
# Add AssertionConsumerServiceURL
self.add_service_url(self.ASSERTION_CONSUMER)
self.simple_content(self.AUTHN_REQUESTS_SIGNED,
bool2xs(options.get(AUTHN_REQUESTS_SIGNED, False)))
bool2xs(options.get(self.AUTHN_REQUESTS_SIGNED, False)))
self.tb.end(self.SP_SSO_DESCRIPTOR)
def root_element(self):

View File

@ -146,12 +146,6 @@ class Saml2Metadata(object):
self.tb.start('NameIDFormat', {})
self.tb.data(name_id_format)
self.tb.end('NameIDFormat')
if 'cache_duration' in options:
attrib['cacheDuration'] = options['cache_duration']
if 'valid_until' in options:
attrib['validUntil'] = options['valid_until']
if 'error_url' in options:
attrib['errorURL'] = options['error_url']
if 'signing_key' in options:
self.add_keyinfo(options['signing_key'], 'signing')
if 'encryption_key' in options:

View File

@ -1,24 +1,5 @@
# w.c.s. - web application for online forms
# Copyright (C) 2005-2010 Entr'ouvert
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301 USA
import base64
import binascii
import sys
import tempfile
import os
import subprocess