From 1403cfdb7ba9189906e28873d96bcf445937088e Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Tue, 15 Jan 2013 18:51:46 +0100 Subject: [PATCH] =?UTF-8?q?[lc=5Fldap,attributs]=20On=20ajoute=20sshFinger?= =?UTF-8?q?print=20et=20gpgFingerprint,=20on=20rend=20possible=20l'ajout?= =?UTF-8?q?=20d'attribut=20obtionnel=20optionnel=20quand=20le=20cardinal?= =?UTF-8?q?=20pr=C3=A9c=C3=A9dent=20de=20l'attribut=20est=200?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- attributs.py | 18 +++++++++++++++++- filter.py | 2 ++ lc_ldap.py | 5 +++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/attributs.py b/attributs.py index 02aca80..148dc9a 100644 --- a/attributs.py +++ b/attributs.py @@ -94,7 +94,9 @@ class Attr(object): def validate(self, ldif): """validates: vérifie déjà que ce qu'on a rentré est parsable""" - own_values = ldif[self.__class__.__name__] + if not self.__class__.__name__ in CRANS_ATTRIBUTES: + raise ValueError('Attribut %s inconnu' % self.__class__.__name__) + own_values = ldif.get(self.__class__.__name__, []) self._check_cardinality(own_values) self._check_uniqueness() self._check_users_restrictions(own_values) @@ -594,6 +596,18 @@ class mail(Attr): # XXX - to be implemented #def parse_value(self, mail, ldif): # pass + +class sshFingerprint(Attr): + singlevalue = False + optional = True + legend = "Clef ssh de la machine" + can_modify = ["parent", "Nounou"] + +class gpgFingerprint(Attr): + singlevalue = False + optional = True + legend = "Clef gpg d'un adhérent" + can_modify = ["self", "Nounou"] class cn(Attr): singlevalue = True @@ -639,8 +653,10 @@ CRANS_ATTRIBUTES= { 'chbre' : chbre, 'droits' : droits, 'solde' : solde, + 'gpgFingerprint' : gpgFingerprint, 'mid' : mid, 'host' : host, + 'sshFingerprint' : sshFingerprint, 'macAddress': macAddress, 'ipHostNumber': ipHostNumber, 'hostAlias' : hostAlias, diff --git a/filter.py b/filter.py index 8b0171f..42b1a35 100644 --- a/filter.py +++ b/filter.py @@ -232,6 +232,8 @@ def human_to_ldap(filtre): # Comme parenthèse fermante. if neg: argument = "!(%s)" % argument + + # Surtout ça if operateur == "&|": argument += ')' ext_stack += "(%s)" % argument diff --git a/lc_ldap.py b/lc_ldap.py index 69b4d36..c077c61 100644 --- a/lc_ldap.py +++ b/lc_ldap.py @@ -10,6 +10,7 @@ # Valentin Samir # Daniel Stan # Vincent Le Gallic +# Pierre-Elliott Bécue # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: @@ -614,7 +615,7 @@ class machine(CransLdapObject): ufields = ['mid', 'macAddress', 'host', 'midType'] ofields = [] mfields = ['info', 'blacklist', 'hostAlias', 'exempt', - 'portTCPout', 'portTCPin', 'portUDPout', 'portUDPin'] + 'portTCPout', 'portTCPin', 'portUDPout', 'portUDPin','sshFingerprint'] xfields = ['ipHostNumber'] def __init__(self, conn, dn, mode='ro', ldif = None): @@ -649,7 +650,7 @@ class adherent(proprio): ofields = proprio.ofields + ['charteMA', 'adherentPayant', 'typeAdhesion', 'canonicalAlias', 'solde', 'contourneGreylist', 'rewriteMailHeaders', 'derniereConnexion', - 'homepageAlias'] + 'homepageAlias','gpgFingerprint'] mfields = proprio.mfields + ['carteEtudiant', 'mailAlias', 'droits' ] xfields = ['etudes', 'postalAddress']