Skip to content

Commit a88b0ed

Browse files
authored
Merge pull request #4 from Framonti/update-Elasticsearch-to-7.12
Update elasticsearch to 7.12
2 parents 5871c9f + 18d541d commit a88b0ed

File tree

8 files changed

+29
-27
lines changed

8 files changed

+29
-27
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ There is no way to configure this on a per index basis.
1818
|-----------------------------|------------------------------|
1919
| v0.0.1 | 6.3.2 |
2020
| v0.1.0 | 7.6.0 |
21-
21+
| v0.2.0 | 7.12.0 |
2222

2323
## Installation
2424

pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>com.cleafy.elasticsearch</groupId>
77
<artifactId>elasticsearch-http-basic-auth-plugin</artifactId>
8-
<version>0.1.0</version>
8+
<version>0.2.0</version>
99
<packaging>jar</packaging>
1010
<name>Elasticsearch Http Basic plugin</name>
1111
<description>Adds HTTP Basic authentication (BA) to your Elasticsearch cluster</description>
@@ -15,20 +15,20 @@
1515
<properties>
1616
<tests.jvms>1</tests.jvms>
1717
<es.logger.level>INFO</es.logger.level>
18+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1819
</properties>
1920

2021
<dependencies>
2122
<dependency>
2223
<groupId>org.elasticsearch</groupId>
2324
<artifactId>elasticsearch</artifactId>
24-
<version>7.6.0</version>
25+
<version>7.12.0</version>
2526
<scope>provided</scope>
2627
</dependency>
27-
2828
<dependency>
2929
<groupId>org.elasticsearch.test</groupId>
3030
<artifactId>framework</artifactId>
31-
<version>7.6.0</version>
31+
<version>7.12.0</version>
3232
<scope>test</scope>
3333
</dependency>
3434
<dependency>
@@ -54,7 +54,7 @@
5454
<artifactId>maven-assembly-plugin</artifactId>
5555
<version>2.6</version>
5656
<configuration>
57-
<appendAssemblyId>false</appendAssemblyId>
57+
<appendAssemblyId>true</appendAssemblyId>
5858
<outputDirectory>${project.build.directory}/releases/</outputDirectory>
5959
<descriptors>
6060
<descriptor>${basedir}/src/main/assemblies/plugin.xml</descriptor>

src/main/assemblies/plugin.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
<?xml version="1.0"?>
22
<assembly>
3-
<id>plugin</id>
3+
<id>0.2.0</id>
44
<formats>
55
<format>zip</format>
66
</formats>
77
<includeBaseDirectory>false</includeBaseDirectory>
8+
<fileSets>
9+
<fileSet>
10+
<outputDirectory>/</outputDirectory>
11+
<directory>src/main/resources</directory>
12+
<includes>
13+
<include>*.properties</include>
14+
</includes>
15+
</fileSet>
16+
</fileSets>
817
<dependencySets>
918
<dependencySet>
1019
<outputDirectory>/</outputDirectory>
@@ -19,7 +28,7 @@
1928
<useProjectArtifact>true</useProjectArtifact>
2029
<useTransitiveFiltering>true</useTransitiveFiltering>
2130
<includes>
22-
<include>com.cleafy.elasticsearch:elasticsearch6-http-basic</include>
31+
<include>com.cleafy.elasticsearch:elasticsearch-http-basic</include>
2332
</includes>
2433
</dependencySet>
2534
</dependencySets>

src/main/java/com/cleafy/elasticsearch/plugins/http/BasicRestFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
public class BasicRestFilter {
1414
private final HttpBasicAuthenticator httpBasicAuthenticator;
15-
private boolean isUnauthLogEnabled;
15+
private final boolean isUnauthLogEnabled;
1616

1717
public BasicRestFilter(final Settings settings) {
1818
super();

src/main/java/com/cleafy/elasticsearch/plugins/http/HttpBasicServerPlugin.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
public class HttpBasicServerPlugin extends Plugin implements ActionPlugin {
2121

22-
private boolean enabledByDefault = false;
22+
private final boolean enabledByDefault = false;
2323
private final Settings settings;
2424
BasicRestFilter basicFilter;
2525

@@ -40,9 +40,9 @@ public String description() {
4040
@Override
4141
public UnaryOperator<RestHandler> getRestHandlerWrapper(final ThreadContext threadContext) {
4242
if (this.settings.getAsBoolean(Globals.SETTINGS_ENABLED, enabledByDefault)) {
43-
return (rh) -> basicFilter.wrap(rh);
43+
return rh -> basicFilter.wrap(rh);
4444
}
45-
return (rh) -> rh;
45+
return rh -> rh;
4646
}
4747

4848
@Override
@@ -58,9 +58,8 @@ public Settings additionalSettings() {
5858

5959
@Override
6060
public List<Setting<?>> getSettings() {
61-
List<Setting<?>> settings = new ArrayList<Setting<?>>();
6261

63-
settings.addAll(super.getSettings());
62+
List<Setting<?>> settings = new ArrayList<>(super.getSettings());
6463

6564
settings.add(Setting.boolSetting(Globals.SETTINGS_ENABLED, enabledByDefault, Setting.Property.NodeScope, Setting.Property.Filtered));
6665
settings.add(Setting.simpleString(Globals.SETTINGS_USERNAME, Setting.Property.NodeScope, Setting.Property.Filtered));

src/main/java/com/cleafy/elasticsearch/plugins/http/auth/AuthCredentials.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class AuthCredentials {
1111
private final String username;
1212
private byte[] password;
1313
private Object nativeCredentials;
14-
private final Set<String> backendRoles = new HashSet<String>();
14+
private final Set<String> backendRoles = new HashSet<>();
1515
private boolean complete;
1616
private final byte[] internalPasswordHash;
1717
private final Map<String, String> attributes = new HashMap<>();
@@ -116,11 +116,8 @@ public boolean equals(Object obj) {
116116
if (internalPasswordHash == null || other.internalPasswordHash == null || !MessageDigest.isEqual(internalPasswordHash, other.internalPasswordHash))
117117
return false;
118118
if (username == null) {
119-
if (other.username != null)
120-
return false;
121-
} else if (!username.equals(other.username))
122-
return false;
123-
return true;
119+
return other.username == null;
120+
} else return username.equals(other.username);
124121
}
125122

126123
@Override
@@ -133,7 +130,7 @@ public String toString() {
133130
* @return Defensive copy of the roles this user is member of.
134131
*/
135132
public Set<String> getBackendRoles() {
136-
return new HashSet<String>(backendRoles);
133+
return new HashSet<>(backendRoles);
137134
}
138135

139136
public boolean isComplete() {

src/main/java/com/cleafy/elasticsearch/plugins/http/auth/HttpBasicAuthenticator.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import org.elasticsearch.rest.RestRequest;
55

66
public class HttpBasicAuthenticator extends Authenticator {
7-
private AuthCredentials credentials;
7+
private final AuthCredentials credentials;
88

99
public HttpBasicAuthenticator(Settings settings, AuthCredentials credentials) {
1010
super(settings);
@@ -13,10 +13,7 @@ public HttpBasicAuthenticator(Settings settings, AuthCredentials credentials) {
1313

1414
@Override
1515
public boolean authenticate(RestRequest request) {
16-
if (this.extractCredentials(request).equals(credentials)) {
17-
return true;
18-
}
19-
return false;
16+
return this.extractCredentials(request).equals(credentials);
2017
}
2118

2219
private AuthCredentials extractCredentials(final RestRequest request) {

src/main/resources/plugin-descriptor.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ name=elasticsearch-http-basic-auth-plugin
33
description=Plugin to enable HTTP basic authentication and/or Ip based authentication
44
version=1.0.0
55
java.version=1.8
6-
elasticsearch.version=7.6.0
6+
elasticsearch.version=7.12.0

0 commit comments

Comments
 (0)