def compose_username(nick, email, provider):
    """
    @brief Compose the username

    The username policy via openid is as follow:
    * Try to use the nick name
    * If not available fall back to email
    * Append the the openid provider as domain. Delimiter is % in order to 
      diferentiate from @ (if email is used)

    @param nick The nick name or None
    @param email The email or None
    @param provider the Authentication provider
    @return Non in case no user name was derived, otherwise the username
    """
    if nick:
        return '{0}%{1}'.format(nick, provider)
    else:
        if email:
            return '{0}%{1}'.format(email, provider)
    return None