def __init__(self, inputstream, dictionary): self.tokenMap = dictionary self.rawIn = inputstream self.inn = ByteArray() self.buf = bytearray(1024) self.bufSize = 0 self.readSize = 1
def fillBuffer(self, stanzaSize): if len(self.buf) < stanzaSize: newsize = max(len(self.buf) * 3 / 2, stanzaSize) self.buf = bytearray(newsize) self.bufSize = stanzaSize self.fillArray(self.buf, stanzaSize, self.rawIn) self.inn = ByteArray() self.inn.write(self.buf)
def __init__(self, inputstream, dictionary): Utilities.debug('Reader init') self.tokenMap = dictionary self.rawIn = inputstream self.inn = ByteArray() self.buf = bytearray(1024) self.bufSize = 0 self.readSize = 1
def __init__(self, o, dictionary): self.realOut = o # self.out = o self.tokenMap = {} self.out = ByteArray() for i in range(0, len(dictionary)): if dictionary[i] is not None: self.tokenMap[dictionary[i]] = i
def __init__(self, o, dictionary): self.realOut = o #self.out = o; self.tokenMap = {} self.out = ByteArray() #this.tokenMap = new Hashtable(dictionary.length); for i in range(0, len(dictionary)): if dictionary[i] is not None: self.tokenMap[dictionary[i]] = i #Utilities.debug(self.tokenMap); '''
def getResponse(self, challenge): print "CHALLENGE: " + str(challenge) i = challenge.index(WALogin.nonce_key) i += len(WALogin.nonce_key) j = challenge.index('"', i) nonce = challenge[i:j] cnonce = Utilities.str(abs(random.getrandbits(64)), 36) nc = "00000001" bos = ByteArray() bos.write( self.md5Digest(self.connection.user + ":" + self.connection.domain + ":" + self.connection.password)) bos.write(58) bos.write(nonce) bos.write(58) bos.write(cnonce) digest_uri = "xmpp/" + self.connection.domain A1 = bos.toByteArray() A2 = "AUTHENTICATE:" + digest_uri KD = str(self.bytesToHex(self.md5Digest(A1.getBuffer())) ) + ":" + nonce + ":" + nc + ":" + cnonce + ":auth:" + str( self.bytesToHex(self.md5Digest(A2))) response = str(self.bytesToHex(self.md5Digest(KD))) bigger_response = "" bigger_response += "realm=\"" bigger_response += self.connection.domain bigger_response += "\",response=" bigger_response += response bigger_response += ",nonce=\"" bigger_response += nonce bigger_response += "\",digest-uri=\"" bigger_response += digest_uri bigger_response += "\",cnonce=\"" bigger_response += cnonce bigger_response += "\",qop=auth" bigger_response += ",username=\"" bigger_response += self.connection.user bigger_response += "\",nc=" bigger_response += nc print "SENDING: " + str(bigger_response) return bigger_response
def getResponse(self, challenge): i = challenge.index(Login.nonce_key) i += len(Login.nonce_key) j = challenge.index('"', i) nonce = challenge[i:j] cnonce = str_base(abs(random.getrandbits(64)), 36) nc = '00000001' bos = ByteArray() bos.write(self.md5Digest(self.connection.user + ':' + self.connection.domain + ':' + self.connection.password)) bos.write(58) bos.write(nonce) bos.write(58) bos.write(cnonce) digest_uri = 'xmpp/' + self.connection.domain A1 = bos.toByteArray() A2 = 'AUTHENTICATE:' + digest_uri KD = str(self.bytesToHex(self.md5Digest(A1.getBuffer()))) + ':' \ + nonce + ':' + nc + ':' + cnonce + ':auth:' \ + str(self.bytesToHex(self.md5Digest(A2))) response = str(self.bytesToHex(self.md5Digest(KD))) bigger_response = '' bigger_response += 'realm="' bigger_response += self.connection.domain bigger_response += '",response=' bigger_response += response bigger_response += ',nonce="' bigger_response += nonce bigger_response += '",digest-uri="' bigger_response += digest_uri bigger_response += '",cnonce="' bigger_response += cnonce bigger_response += '",qop=auth' bigger_response += ',username="******",nc=' bigger_response += nc return bigger_response