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