def join_authority(authority):
    """
       Reverse of split_authority()

       >>>join_authority(('user', 'password', 'host', 'port'))
       "user:password@host:port"

    """
    user, passwd, host, port = authority
    result = ''
    if user:
        result += user
        if passwd:
            result += ':' + passwd
        result += '@'
    result += host
    if port:
        result += ':' + port
    return result
