diff --git a/acme4j-client/src/main/java/org/shredzone/acme4j/exception/AcmeRateLimitExceededException.java b/acme4j-client/src/main/java/org/shredzone/acme4j/exception/AcmeRateLimitExceededException.java new file mode 100644 index 00000000..0a9db98a --- /dev/null +++ b/acme4j-client/src/main/java/org/shredzone/acme4j/exception/AcmeRateLimitExceededException.java @@ -0,0 +1,36 @@ +/* + * acme4j - Java ACME client + * + * Copyright (C) 2015 Richard "Shred" Körber + * http://acme4j.shredzone.org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + */ +package org.shredzone.acme4j.exception; + +/** + * An exception that is thrown when a rate limit was exceeded. + * + * @author Richard "Shred" Körber + */ +public class AcmeRateLimitExceededException extends AcmeServerException { + private static final long serialVersionUID = 4150484059796413069L; + + /** + * Creates a new {@link AcmeRateLimitExceededException}. + * + * @param type + * System readable error type (here {@code "urn:acme:error:rateLimited"}) + * @param detail + * Human readable error message + */ + public AcmeRateLimitExceededException(String type, String detail) { + super(type, detail); + } + +} diff --git a/acme4j-client/src/main/java/org/shredzone/acme4j/impl/DefaultConnection.java b/acme4j-client/src/main/java/org/shredzone/acme4j/impl/DefaultConnection.java index 5d95d12f..56924407 100644 --- a/acme4j-client/src/main/java/org/shredzone/acme4j/impl/DefaultConnection.java +++ b/acme4j-client/src/main/java/org/shredzone/acme4j/impl/DefaultConnection.java @@ -43,6 +43,7 @@ import org.shredzone.acme4j.connector.HttpConnector; import org.shredzone.acme4j.connector.Resource; import org.shredzone.acme4j.connector.Session; import org.shredzone.acme4j.exception.AcmeException; +import org.shredzone.acme4j.exception.AcmeRateLimitExceededException; import org.shredzone.acme4j.exception.AcmeServerException; import org.shredzone.acme4j.exception.AcmeUnauthorizedException; import org.shredzone.acme4j.util.ClaimBuilder; @@ -334,6 +335,9 @@ public class DefaultConnection implements Connection { case "urn:acme:error:unauthorized": throw new AcmeUnauthorizedException(type, detail); + case "urn:acme:error:rateLimited": + throw new AcmeRateLimitExceededException(type, detail); + default: throw new AcmeServerException(type, detail); }