def _registerKey(self, callback=None): data = 'username:%s' % self.userName digestType = DigestType('SHA1') digest = Digest(digestType).digest(data) signature = self.rsaKey.sign(digest, digestType) form = dict(username=self.userName, public_key=self.rsaKey.toDER_PublicKey(), signature=signature) postData = urllib.urlencode(form) request = HttpRequest(self.reactor) def onResponse(returnCode, data): if returnCode != 200: op.notify(-1) return try: keyId = int(data) op.notify(keyId) except ValueError: op.notify(-1) httpOp = request.post('http://cspace.in/addkey', postData, onResponse) op = AsyncOp(callback, httpOp.cancel) return op
def callAction( self, name, params, reactor, callback=None ) : payload = self.getActionPayload( name, params ) http = HttpRequest( reactor ) http.addHeader( 'Content-Type: text/xml; charset="utf-8"' ) http.addHeader( 'SOAPACTION: "%s#%s"' % (self.service,name) ) def onResponse( result, data ) : self._onActionResponse( op, name, result, data ) httpOp = http.post( self.controlUrl, payload, onResponse ) op = AsyncOp( callback, httpOp.cancel ) return op
def _registerKey( self, callback=None ) : data = 'username:%s' % self.userName digestType = DigestType( 'SHA1' ) digest = Digest(digestType).digest( data ) signature = self.rsaKey.sign( digest, digestType ) form = dict( username=self.userName, public_key=self.rsaKey.toDER_PublicKey(), signature=signature ) postData = urllib.urlencode( form ) request = HttpRequest( self.reactor ) def onResponse( returnCode, data ) : if returnCode != 200 : op.notify( -1 ) return try : keyId = int(data) op.notify( keyId ) except ValueError : op.notify( -1 ) httpOp = request.post( 'http://cspace.in/addkey', postData, onResponse ) op = AsyncOp( callback, httpOp.cancel ) return op