001/*
002 * acme4j - Java ACME client
003 *
004 * Copyright (C) 2016 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.exception;
015
016import java.net.URI;
017
018/**
019 * An exception that is thrown when the client needs to accept the terms of service in
020 * order to continue.
021 */
022public class AcmeAgreementRequiredException extends AcmeServerException {
023    private static final long serialVersionUID = 7719055447283858352L;
024
025    private final URI agreementUri;
026    private final URI instance;
027
028    /**
029     * Creates a new {@link AcmeAgreementRequiredException}.
030     *
031     * @param type
032     *            System readable error type (here
033     *            {@code "urn:ietf:params:acme:error:agreementRequired"})
034     * @param detail
035     *            Human readable error message
036     * @param agreementUri
037     *            {@link URI} of the agreement document to accept
038     * @param instance
039     *            {@link URI} to be visited by a human, showing instructions for how to
040     *            agree to the terms and conditions.
041     */
042    public AcmeAgreementRequiredException(String type, String detail, URI agreementUri, URI instance) {
043        super(type, detail);
044        this.agreementUri = agreementUri;
045        this.instance = instance;
046    }
047
048    /**
049     * Returns the {@link URI} of the agreement document to accept, or {@code null} if
050     * the server did not provide a link to such a document.
051     */
052    public URI getAgreementUri() {
053        return agreementUri;
054    }
055
056    /**
057     * Returns the {@link URI} of a document showing a human how to agree to the terms and
058     * conditions, or {@code null} if the server did not provide such a link.
059     */
060    public URI getInstance() {
061        return instance;
062    }
063
064}