Ejemplo n.º 1
0
 def _doGetPubKey( self, words ) :
     if len(words) > 1 :
         self._writeError( 'Malformed request' )
         return
     if not self.session.isOnline() :
         self._writeError( 'Not online' )
         return
     if len(words) == 0 :
         keyData = self.session.getProfile().rsaKey.toDER_PublicKey()
         self._writeResult( [hexEncode(keyData)] )
         return
     contact = self.session.getProfile().getContactByName( words[0] )
     if contact is None :
         self._writeError( 'Unknown contact' )
         return
     self._writeResult( [hexEncode(contact.publicKeyData)] )
Ejemplo n.º 2
0
def saveProfileContacts( profile, location='CSpaceProfiles' ) :
    out = StringIO.StringIO()
    for name in profile.getContactNames() :
        c = profile.getContactByName( name )
        hexKey = hexEncode( c.publicKeyData )
        print>>out, '%s:%s' % (name,hexKey)
    ps = profileSettings(location)
    ps.setData( profile.storeEntry + '/ContactList', out.getvalue() )
Ejemplo n.º 3
0
def saveProfileContacts(profile):
    out = StringIO.StringIO()
    for name in profile.getContactNames():
        c = profile.getContactByName(name)
        hexKey = hexEncode(c.publicKeyData)
        print >> out, '%s:%s' % (name, hexKey)
    ps = profileSettings()
    ps.setData(profile.storeEntry + '/ContactList', out.getvalue())
Ejemplo n.º 4
0
 def addIncoming( self, sslConn, peerKey ) :
     while True :
         connectionId = hexEncode( rand_bytes(8) )
         if connectionId not in self.connections : break
     def onTimeout() : self._onTimeout( connectionId )
     timerOp = self.reactor.callLater( 30, onTimeout )
     self.connections[connectionId] = (sslConn,peerKey,timerOp)
     return connectionId
Ejemplo n.º 5
0
 def _doGetIncomingPubKey( self, words ) :
     if len(words) != 1 :
         self._writeError( 'Malformed request' )
         return
     connectionId = words[0]
     peerKey = self.incoming.getPeerKey( connectionId )
     if not peerKey :
         self._writeError( 'Invalid connection' )
         return
     self._writeResult( [hexEncode(peerKey.toDER_PublicKey())] )
Ejemplo n.º 6
0
 def _doGetContactPubKeys( self, words ) :
     if len(words) != 0 :
         self._writeError( 'Malformed request' )
         return
     if not self.session.isOnline() :
         self._writeError( 'Not online' )
         return
     out = []
     profile = self.session.getProfile()
     for name in profile.getContactNames() :
         c = profile.getContactByName( name )
         out.extend( [c.name,hexEncode(c.publicKeyData)] )
     self._writeResult( out )
Ejemplo n.º 7
0
    def contactinfo(self, buddy):
        if self.status != self.ONLINE:
            return self._error("Not online.")

        if buddy not in self.profile.contactNames:
            return self._error("Bad buddy name: %s" % buddy)

        contact = self.profile.contactNames[buddy]
        contactKey = hexEncode(contact.publicKeyData)
        if hasattr(contact, "status"):
            contactStatus = contact.status
        else:
            contactStatus = -1
        return [contact.name, contactKey, self.STATII[contactStatus]]