Changed the license expiration exception to ElasticsearchSecurityException

We'd like to have an UNAUTHORIZED behaviour when the license is expired

Original commit: elastic/x-pack-elasticsearch@f46a92b6f8
This commit is contained in:
uboness 2015-07-03 16:01:08 +02:00
parent e0e4f07348
commit eec962f7f8

View File

@ -5,8 +5,8 @@
*/ */
package org.elasticsearch.license.plugin.core; package org.elasticsearch.license.plugin.core;
import org.elasticsearch.ElasticsearchException; import org.elasticsearch.ElasticsearchSecurityException;
import org.elasticsearch.common.collect.Tuple; import org.elasticsearch.rest.RestStatus;
public class LicenseUtils { public class LicenseUtils {
@ -19,9 +19,9 @@ public class LicenseUtils {
* <code>feature</code> accessible through {@link #EXPIRED_FEATURE_HEADER} in the * <code>feature</code> accessible through {@link #EXPIRED_FEATURE_HEADER} in the
* exception's rest header * exception's rest header
*/ */
public static ElasticsearchException newExpirationException(String feature) { public static ElasticsearchSecurityException newExpirationException(String feature) {
// TODO: after https://github.com/elastic/elasticsearch/pull/12006 use ElasicsearchException with addHeader(EXPIRED_FEATURE_HEADER, feature) ElasticsearchSecurityException e = new ElasticsearchSecurityException("license expired for feature [{}]", RestStatus.UNAUTHORIZED, feature);
return new ElasticsearchException.WithRestHeadersException("license expired for feature [" + feature + "]", e.addHeader(EXPIRED_FEATURE_HEADER, feature);
Tuple.tuple(EXPIRED_FEATURE_HEADER, new String[] {feature})); return e;
} }
} }