1#!/usr/bin/env python 2# Copyright (c) 2007, Secure64 Software Corporation 3# 4# Permission is hereby granted, free of charge, to any person obtaining a copy 5# of this software and associated documentation files (the "Software"), to deal 6# in the Software without restriction, including without limitation the rights 7# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8# copies of the Software, and to permit persons to whom the Software is 9# furnished to do so, subject to the following conditions: 10# 11# The above copyright notice and this permission notice shall be included in 12# all copies or substantial portions of the Software. 13# 14# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20# THE SOFTWARE. 21# 22# 23# 24# class to represent a named.conf key 25# 26# 27 28import os 29import os.path 30import sys 31 32if os.path.exists('../bind2nsd/Config.py'): 33 sys.path.append('../bind2nsd') 34 from Utils import * 35else: 36 from bind2nsd.Utils import * 37 38 39class Key: 40 41 def __init__(self, name): 42 self.name = name 43 self.algorithm = '' 44 self.secret = '' 45 self.ipaddrs = [] 46 return 47 48 def dump(self): 49 report_info('=> Key:') 50 report_info(' algorithm = %s' % (self.algorithm)) 51 report_info(' name = %s' % (self.name)) 52 report_info(' secret = %s' % (self.secret)) 53 report_info(' ipaddrs = %s' % (str(self.ipaddrs))) 54 return 55 56 def setName(self, val): 57 self.name = val 58 return 59 60 def getName(self): 61 return self.name 62 63 def setAlgorithm(self, val): 64 self.algorithm = val 65 return 66 67 def getAlgorithm(self): 68 return self.algorithm 69 70 def setSecret(self, val): 71 self.secret = val 72 return 73 74 def getSecret(self): 75 return self.secret 76 77 def addIpAddr(self, addr): 78 if addr not in self.ipaddrs: 79 self.ipaddrs.append(addr) 80 return 81 82 def getIpAddrs(self): 83 return self.ipaddrs 84 85