summaryrefslogtreecommitdiffstats
path: root/authentic/admin/settings.ptl
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2008-02-21 15:40:08 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2008-02-21 15:40:08 (GMT)
commit4da36f7b098a24f36689902cc36e544683a65720 (patch)
tree11cfa16ee5b104934df11252a86f7990aaf9626f /authentic/admin/settings.ptl
parent625f4e8d0d6a7cf3a0cbb114974a449144e2bf87 (diff)
downloadauthentic-old-4da36f7b098a24f36689902cc36e544683a65720.zip
authentic-old-4da36f7b098a24f36689902cc36e544683a65720.tar.gz
authentic-old-4da36f7b098a24f36689902cc36e544683a65720.tar.bz2
updated to new-binding lasso.Provider exception raising (and compatibility with
swig binding from qommon/__init.py)
Diffstat (limited to 'authentic/admin/settings.ptl')
-rw-r--r--authentic/admin/settings.ptl46
1 files changed, 28 insertions, 18 deletions
diff --git a/authentic/admin/settings.ptl b/authentic/admin/settings.ptl
index 8e8a7cf..cd5b2ac 100644
--- a/authentic/admin/settings.ptl
+++ b/authentic/admin/settings.ptl
@@ -223,15 +223,18 @@ class LibertyProvidersDir(Directory):
publickey_fn = misc.get_abs_path(lp['publickey'])
if lp.has_key('cacertchain') and os.path.exists(misc.get_abs_path(lp['cacertchain'])):
cacertchain_fn = misc.get_abs_path(lp['cacertchain'])
- p = lasso.Provider(lp['role'], misc.get_abs_path(lp['metadata']),
- publickey_fn, cacertchain_fn)
- if p.this is None:
+
+ try:
+ p = lasso.Provider(lp['role'], misc.get_abs_path(lp['metadata']),
+ publickey_fn, cacertchain_fn)
+ except lasso.Error:
# this happens when the public key is missing from both params
# and metadata file
if publickey_fn:
return (None, error_page(_('Bad metadata')))
else:
return (None, error_page(_('Bad metadata or missing public key')))
+
try:
p, l = misc.get_provider_and_label(key_provider_id)
except (TypeError, KeyError):
@@ -276,8 +279,11 @@ class LibertyProvidersDir(Directory):
s = rfd.read()
(bfd, metadata_pathname) = tempfile.mkstemp(str('.metadata'))
file(metadata_pathname, str('w')).write(s)
- p = lasso.Provider(lasso.PROVIDER_ROLE_SP, metadata_pathname, None, None)
- if p.this is not None:
+ try:
+ p = lasso.Provider(lasso.PROVIDER_ROLE_SP, metadata_pathname, None, None)
+ except lasso.Error:
+ pass
+ else:
t = self.submit_new_remote(metadata_pathname, publickey_pathname,
metadata_url, publickey_url)
if t:
@@ -302,9 +308,10 @@ class LibertyProvidersDir(Directory):
(bfd, publickey_pathname) = tempfile.mkstemp(str('.publickey'))
file(publickey_pathname, str('w')).write(s)
- p = lasso.Provider(lasso.PROVIDER_ROLE_SP, metadata_pathname,
- publickey_pathname, None)
- if p.this is None:
+ try:
+ p = lasso.Provider(lasso.PROVIDER_ROLE_SP, metadata_pathname,
+ publickey_pathname, None)
+ except lasso.Error:
form.get_widget('metadata_url').set_error(
_('Error in this metadata file'))
else:
@@ -319,17 +326,18 @@ class LibertyProvidersDir(Directory):
# being broken; test them with our our public key file
pubkey = misc.get_abs_path(get_cfg('idp')['publickey'])
- p = lasso.Provider(lasso.PROVIDER_ROLE_SP, metadata_pathname,
- pubkey, None)
- if p.this:
+ try:
+ p = lasso.Provider(lasso.PROVIDER_ROLE_SP, metadata_pathname,
+ pubkey, None)
+ except lasso.Error:
+ # this was an error in the metadata file itself
+ form.get_widget('metadata_url').set_error(
+ _('File looks like a bad metadata file'))
+ else:
# ok when provided with a public key -> adding it for real
form.add(StringWidget, 'publickey_url', title = _('URL to public key'),
required=True, size = 60,
hint = _('The metadata file does not embed a public key, please provide it here.'))
- else:
- # this was an error in the metadata file itself
- form.get_widget('metadata_url').set_error(
- _('File looks like a bad metadata file'))
if publickey_pathname and os.path.exists(publickey_pathname):
@@ -627,15 +635,17 @@ class LibertyProviderUI(Directory):
publickey_fn = misc.get_abs_path(lp['publickey'])
if lp.has_key('cacertchain') and os.path.exists(misc.get_abs_path(lp['cacertchain'])):
cacertchain_fn = misc.get_abs_path(lp['cacertchain'])
- p = lasso.Provider(lp['role'], misc.get_abs_path(lp['metadata']),
- publickey_fn, cacertchain_fn)
- if p.this is None:
+ try:
+ p = lasso.Provider(lp['role'], misc.get_abs_path(lp['metadata']),
+ publickey_fn, cacertchain_fn)
+ except lasso.Error:
# this happens when the public key is missing from both params
# and metadata file
if publickey_fn:
return (None, error_page(_('Bad metadata')))
else:
return (None, error_page(_('Bad metadata or missing public key')))
+
try:
p, l = misc.get_provider_and_label(key_provider_id)
except (TypeError, KeyError):