<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def protected():
 """ A protected endpoint. The auth_required decorator will require a header containing a valid JWT .. example:: $ curl http://localhost:5000/protected -X GET \ -H "Authorization: Bearer <your_token>" """

    custom_claims = flask_praetorian.current_custom_claims()
    firstname = custom_claims.pop('firstname', None)
    nickname = custom_claims.pop('nickname', None)
    surname = custom_claims.pop('surname', None)

    if nickname is None:
        user_string = "{} {}".format(firstname, surname)
    else:
        user_string = "{} '{}' {}".format(firstname, nickname, surname)

    return flask.jsonify(
        message="protected endpoint (allowed user {u})".format(u=user_string),
    )