summaryrefslogtreecommitdiffstats
path: root/ipa-python/radius_client.py
diff options
context:
space:
mode:
authorJohn Dennis <jdennis@redhat.com>2007-11-21 13:11:10 -0500
committerJohn Dennis <jdennis@redhat.com>2007-11-21 13:11:10 -0500
commitd98686e96758870cb4a56d41fb0aaae54d4067c5 (patch)
tree6fc7101684591afdfb9677732352e59067066bc1 /ipa-python/radius_client.py
parent087d11af5cebe7bb7a87d0581c7fa95353d9aa3b (diff)
downloadfreeipa.git-d98686e96758870cb4a56d41fb0aaae54d4067c5.tar.gz
freeipa.git-d98686e96758870cb4a56d41fb0aaae54d4067c5.tar.xz
freeipa.git-d98686e96758870cb4a56d41fb0aaae54d4067c5.zip
Add radius profile implementations:
get_radius_profile_by_uid add_radius_profile update_radius_profile delete_radius_profile find_radius_profiles Rewrite command line arg handling, now support pair entry, interactive mode with auto completion, reading pairs from a file, better handling of mandatory values, better help, long arg names now match attribute name in pairs Establish mappings for all attributes and names used in clients and profiles Add notion of containers to radius clients and profiles in LDAP Move common code, variables, constants, and strings into the files radius_client.py, radius_util.py, ipautil.py to eliminate redundant elements which could get out of sync if modified and to provide access to other code which might benefit from using these items in the future. Add utility functions: format_list() parse_key_value_pairs() Add utility class: AttributeValueCompleter Unify attribute usage in radius ldap schema
Diffstat (limited to 'ipa-python/radius_client.py')
-rw-r--r--ipa-python/radius_client.py39
1 files changed, 33 insertions, 6 deletions
diff --git a/ipa-python/radius_client.py b/ipa-python/radius_client.py
index 2709c4d9..907e0210 100644
--- a/ipa-python/radius_client.py
+++ b/ipa-python/radius_client.py
@@ -21,6 +21,7 @@ import getpass
import re
from ipa.entity import Entity
+import ipa.ipavalidate as ipavalidate
__all__ = ['RadiusClient',
'get_secret',
@@ -29,6 +30,7 @@ __all__ = ['RadiusClient',
'validate_name',
'validate_nastype',
'validate_desc',
+ 'validate',
]
#------------------------------------------------------------------------------
@@ -41,7 +43,10 @@ valid_name_len = (1,31)
valid_nastype_len = (1,31)
valid_ip_addr_len = (1,255)
-valid_ip_addr_msg = "IP address must be either a DNS name (letters,digits,dot,hyphen, beginning with a letter),or a dotted octet followed by an optional mask (e.g 192.168.1.0/24)"
+valid_ip_addr_msg = '''\
+IP address must be either a DNS name (letters,digits,dot,hyphen, beginning with
+a letter),or a dotted octet followed by an optional mask (e.g 192.168.1.0/24)'''
+
valid_desc_msg = "Description must text string"
#------------------------------------------------------------------------------
@@ -101,38 +106,60 @@ def validate_length(value, limits):
def valid_length_msg(name, limits):
return "%s length must be at least %d and not more than %d" % (name, limits[0], limits[1])
+def err_msg(variable, variable_name=None):
+ if variable_name is None: variable_name = 'value'
+ print "ERROR: %s = %s" % (variable_name, variable)
+
#------------------------------------------------------------------------------
-def validate_ip_addr(ip_addr):
+def validate_ip_addr(ip_addr, variable_name=None):
if not validate_length(ip_addr, valid_ip_addr_len):
+ err_msg(ip_addr, variable_name)
print valid_length_msg('ip address', valid_ip_addr_len)
return False
if not valid_ip_addr(ip_addr):
+ err_msg(ip_addr, variable_name)
print valid_ip_addr_msg
return False
return True
-def validate_secret(secret):
+def validate_secret(secret, variable_name=None):
if not validate_length(secret, valid_secret_len):
+ err_msg(secret, variable_name)
print valid_length_msg('secret', valid_secret_len)
return False
return True
-def validate_name(name):
+def validate_name(name, variable_name=None):
if not validate_length(name, valid_name_len):
+ err_msg(name, variable_name)
print valid_length_msg('name', valid_name_len)
return False
return True
-def validate_nastype(nastype):
+def validate_nastype(nastype, variable_name=None):
if not validate_length(nastype, valid_nastype_len):
+ err_msg(nastype, variable_name)
print valid_length_msg('NAS Type', valid_nastype_len)
return False
return True
-def validate_desc(desc):
+def validate_desc(desc, variable_name=None):
if ipavalidate.plain(desc, notEmpty=True) != 0:
print valid_desc_msg
return False
return True
+def validate(attribute, value):
+ if attribute == 'Client-IP-Address':
+ return validate_ip_addr(value, attribute)
+ if attribute == 'Secret':
+ return validate_secret(value, attribute)
+ if attribute == 'NAS-Type':
+ return validate_nastype(value, attribute)
+ if attribute == 'Name':
+ return validate_name(value, attribute)
+ if attribute == 'Description':
+ return validate_desc(value, attribute)
+ return True
+