Exemplo n.º 1
0
def call_peer(remote_host, remote_user, local_host, local_user, ts, nonce,
              signature):
    ''' make remote REST call to retreive foreign sessionKey '''
    postargs = {
        'name': '_create',
        'userid': local_user,
        'peername': local_host,
        'username': remote_user,
        'ts': ts,
        'nonce': nonce,
        'sig': signature
    }

    resp, cont = rest.simpleRequest(remote_host + REMOTE_ENDPOINT,
                                    postargs=postargs)

    if resp.status not in [200, 201]:
        logger.error('unable to get session key from remote peer %s' %
                     remote_host)

        return None

    try:
        atomEntry = rest.format.parseFeedDocument(cont)
        ret = atomEntry.toPrimitive()[remote_user][remote_user]
        return ret
    except Exception, ex:
        logger.error('unable to parse response from remote peer %s' %
                     remote_host)
        logger.exception(ex)
        return None
Exemplo n.º 2
0
def call_peer(remote_host, remote_user, local_host, local_user, ts, nonce, signature):
    ''' make remote REST call to retreive foreign sessionKey '''
    postargs = {
        'name': '_create',
        'userid': local_user,
        'peername': local_host,
        'username': remote_user,
        'ts': ts,
        'nonce': nonce,
        'sig': signature
    }
    
    resp, cont = rest.simpleRequest(remote_host + REMOTE_ENDPOINT, postargs=postargs)

    if resp.status not in [200, 201]:
        logger.error('unable to get session key from remote peer %s' % remote_host)
        
        return None

    try:
        atomEntry = rest.format.parseFeedDocument(cont)
        ret = atomEntry.toPrimitive()[remote_user][remote_user]
        return ret
    except Exception, ex:
        logger.error('unable to parse response from remote peer %s' % remote_host)
        logger.exception(ex) 
        return None
Exemplo n.º 3
0
def get_private_key():
    ''' load local instance private key and return rsa instance '''
    try:
        return RSA.load_key(PRIV_KEY_PATH)
    except Exception, ex:
        logger.error('unable to load private key %s' % PRIV_KEY_PATH)
        logger.debug(ex)
        return None
Exemplo n.º 4
0
def get_private_key():
    ''' load local instance private key and return rsa instance ''' 
    try:
        return RSA.load_key(PRIV_KEY_PATH)
    except Exception, ex:
        logger.error('unable to load private key %s' % PRIV_KEY_PATH)
        logger.debug(ex)
        return None