001/*
002 * acme4j - Java ACME client
003 *
004 * Copyright (C) 2026 Richard "Shred" Körber
005 *   http://acme4j.shredzone.org
006 *
007 * Licensed under the Apache License, Version 2.0 (the "License");
008 * you may not use this file except in compliance with the License.
009 *
010 * This program is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
013 */
014package org.shredzone.acme4j.connector;
015
016import java.net.URL;
017import java.security.KeyPair;
018
019import edu.umd.cs.findbugs.annotations.Nullable;
020import org.shredzone.acme4j.toolbox.JSONBuilder;
021
022/**
023 * Function for assembling and signing an ACME JOSE request.
024 *
025 * @since 5.0.0
026 */
027@FunctionalInterface
028public interface RequestSigner {
029
030    /**
031     * Creates an ACME JOSE request.
032     * <p>
033     * Implementors can use
034     * {@link org.shredzone.acme4j.toolbox.JoseUtils#createJoseRequest(URL, KeyPair,
035     * JSONBuilder, String, String)} without giving the signing {@link KeyPair} out of
036     * their control.
037     *
038     * @param url
039     *         {@link URL} of the ACME call
040     * @param payload
041     *         ACME JSON payload. If {@code null}, a POST-as-GET request is generated
042     *         instead.
043     * @param nonce
044     *         Nonce to be used. {@code null} if no nonce is to be used in the JOSE
045     *         header.
046     * @return JSON structure of the JOSE request, ready to be sent.
047     * @see org.shredzone.acme4j.toolbox.JoseUtils#createJoseRequest(URL, KeyPair,
048     * JSONBuilder, String, String)
049     */
050    JSONBuilder createRequest(URL url, @Nullable JSONBuilder payload, @Nullable String nonce);
051
052}