diff --git a/README.md b/README.md
index e8802c2..8eb849b 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ There is no way to configure this on a per index basis.
|-----------------------------|------------------------------|
| v0.0.1 | 6.3.2 |
| v0.1.0 | 7.6.0 |
-
+| v0.2.0 | 7.12.0 |
## Installation
diff --git a/pom.xml b/pom.xml
index 8067d0b..cdc557e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
4.0.0
com.cleafy.elasticsearch
elasticsearch-http-basic-auth-plugin
- 0.1.0
+ 0.2.0
jar
Elasticsearch Http Basic plugin
Adds HTTP Basic authentication (BA) to your Elasticsearch cluster
@@ -15,20 +15,20 @@
1
INFO
+ UTF-8
org.elasticsearch
elasticsearch
- 7.6.0
+ 7.12.0
provided
-
org.elasticsearch.test
framework
- 7.6.0
+ 7.12.0
test
@@ -54,7 +54,7 @@
maven-assembly-plugin
2.6
- false
+ true
${project.build.directory}/releases/
${basedir}/src/main/assemblies/plugin.xml
diff --git a/src/main/assemblies/plugin.xml b/src/main/assemblies/plugin.xml
index 2253aba..2c83876 100644
--- a/src/main/assemblies/plugin.xml
+++ b/src/main/assemblies/plugin.xml
@@ -1,10 +1,19 @@
- plugin
+ 0.2.0
zip
false
+
+
+ /
+ src/main/resources
+
+ *.properties
+
+
+
/
@@ -19,7 +28,7 @@
true
true
- com.cleafy.elasticsearch:elasticsearch6-http-basic
+ com.cleafy.elasticsearch:elasticsearch-http-basic
diff --git a/src/main/java/com/cleafy/elasticsearch/plugins/http/BasicRestFilter.java b/src/main/java/com/cleafy/elasticsearch/plugins/http/BasicRestFilter.java
index 6b07b7e..3154b3c 100644
--- a/src/main/java/com/cleafy/elasticsearch/plugins/http/BasicRestFilter.java
+++ b/src/main/java/com/cleafy/elasticsearch/plugins/http/BasicRestFilter.java
@@ -12,7 +12,7 @@
public class BasicRestFilter {
private final HttpBasicAuthenticator httpBasicAuthenticator;
- private boolean isUnauthLogEnabled;
+ private final boolean isUnauthLogEnabled;
public BasicRestFilter(final Settings settings) {
super();
diff --git a/src/main/java/com/cleafy/elasticsearch/plugins/http/HttpBasicServerPlugin.java b/src/main/java/com/cleafy/elasticsearch/plugins/http/HttpBasicServerPlugin.java
index 2f36f87..ea4283f 100644
--- a/src/main/java/com/cleafy/elasticsearch/plugins/http/HttpBasicServerPlugin.java
+++ b/src/main/java/com/cleafy/elasticsearch/plugins/http/HttpBasicServerPlugin.java
@@ -19,7 +19,7 @@
*/
public class HttpBasicServerPlugin extends Plugin implements ActionPlugin {
- private boolean enabledByDefault = false;
+ private final boolean enabledByDefault = false;
private final Settings settings;
BasicRestFilter basicFilter;
@@ -40,9 +40,9 @@ public String description() {
@Override
public UnaryOperator getRestHandlerWrapper(final ThreadContext threadContext) {
if (this.settings.getAsBoolean(Globals.SETTINGS_ENABLED, enabledByDefault)) {
- return (rh) -> basicFilter.wrap(rh);
+ return rh -> basicFilter.wrap(rh);
}
- return (rh) -> rh;
+ return rh -> rh;
}
@Override
@@ -58,9 +58,8 @@ public Settings additionalSettings() {
@Override
public List> getSettings() {
- List> settings = new ArrayList>();
- settings.addAll(super.getSettings());
+ List> settings = new ArrayList<>(super.getSettings());
settings.add(Setting.boolSetting(Globals.SETTINGS_ENABLED, enabledByDefault, Setting.Property.NodeScope, Setting.Property.Filtered));
settings.add(Setting.simpleString(Globals.SETTINGS_USERNAME, Setting.Property.NodeScope, Setting.Property.Filtered));
diff --git a/src/main/java/com/cleafy/elasticsearch/plugins/http/auth/AuthCredentials.java b/src/main/java/com/cleafy/elasticsearch/plugins/http/auth/AuthCredentials.java
index bb1bee8..5e24c18 100644
--- a/src/main/java/com/cleafy/elasticsearch/plugins/http/auth/AuthCredentials.java
+++ b/src/main/java/com/cleafy/elasticsearch/plugins/http/auth/AuthCredentials.java
@@ -11,7 +11,7 @@ public class AuthCredentials {
private final String username;
private byte[] password;
private Object nativeCredentials;
- private final Set backendRoles = new HashSet();
+ private final Set backendRoles = new HashSet<>();
private boolean complete;
private final byte[] internalPasswordHash;
private final Map attributes = new HashMap<>();
@@ -116,11 +116,8 @@ public boolean equals(Object obj) {
if (internalPasswordHash == null || other.internalPasswordHash == null || !MessageDigest.isEqual(internalPasswordHash, other.internalPasswordHash))
return false;
if (username == null) {
- if (other.username != null)
- return false;
- } else if (!username.equals(other.username))
- return false;
- return true;
+ return other.username == null;
+ } else return username.equals(other.username);
}
@Override
@@ -133,7 +130,7 @@ public String toString() {
* @return Defensive copy of the roles this user is member of.
*/
public Set getBackendRoles() {
- return new HashSet(backendRoles);
+ return new HashSet<>(backendRoles);
}
public boolean isComplete() {
diff --git a/src/main/java/com/cleafy/elasticsearch/plugins/http/auth/HttpBasicAuthenticator.java b/src/main/java/com/cleafy/elasticsearch/plugins/http/auth/HttpBasicAuthenticator.java
index 555e947..db5bec2 100644
--- a/src/main/java/com/cleafy/elasticsearch/plugins/http/auth/HttpBasicAuthenticator.java
+++ b/src/main/java/com/cleafy/elasticsearch/plugins/http/auth/HttpBasicAuthenticator.java
@@ -4,7 +4,7 @@
import org.elasticsearch.rest.RestRequest;
public class HttpBasicAuthenticator extends Authenticator {
- private AuthCredentials credentials;
+ private final AuthCredentials credentials;
public HttpBasicAuthenticator(Settings settings, AuthCredentials credentials) {
super(settings);
@@ -13,10 +13,7 @@ public HttpBasicAuthenticator(Settings settings, AuthCredentials credentials) {
@Override
public boolean authenticate(RestRequest request) {
- if (this.extractCredentials(request).equals(credentials)) {
- return true;
- }
- return false;
+ return this.extractCredentials(request).equals(credentials);
}
private AuthCredentials extractCredentials(final RestRequest request) {
diff --git a/src/main/resources/plugin-descriptor.properties b/src/main/resources/plugin-descriptor.properties
index b9c36f7..46f438c 100644
--- a/src/main/resources/plugin-descriptor.properties
+++ b/src/main/resources/plugin-descriptor.properties
@@ -3,4 +3,4 @@ name=elasticsearch-http-basic-auth-plugin
description=Plugin to enable HTTP basic authentication and/or Ip based authentication
version=1.0.0
java.version=1.8
-elasticsearch.version=7.6.0
\ No newline at end of file
+elasticsearch.version=7.12.0
\ No newline at end of file