Skip to content

Commit

Permalink
Switch to native HttpClient in olog es
Browse files Browse the repository at this point in the history
  • Loading branch information
georgweiss committed Dec 20, 2024
1 parent 4064f8f commit 7a96829
Show file tree
Hide file tree
Showing 15 changed files with 750 additions and 1,081 deletions.
16 changes: 3 additions & 13 deletions app/logbook/olog/client-es/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,9 @@

<dependencies>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>com.sun.jersey.contribs</groupId>
<artifactId>jersey-multipart</artifactId>
<version>1.19</version>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import org.phoebus.logbook.LogClient;
import org.phoebus.logbook.LogFactory;
import org.phoebus.olog.es.api.OlogClient.OlogClientBuilder;
import org.phoebus.olog.es.api.OlogHttpClient;
import org.phoebus.security.tokens.SimpleAuthenticationToken;

import java.util.logging.Level;
Expand Down Expand Up @@ -33,7 +33,7 @@ public String getId() {
@Override
public LogClient getLogClient() {
try {
return OlogClientBuilder.serviceURL().create();
return OlogHttpClient.builder().build();
} catch (Exception e) {
logger.log(Level.SEVERE, "Failed to create olog es client", e);
}
Expand All @@ -50,8 +50,8 @@ public LogClient getLogClient(Object authToken) {
try {
if (authToken instanceof SimpleAuthenticationToken) {
SimpleAuthenticationToken token = (SimpleAuthenticationToken) authToken;
return OlogClientBuilder.serviceURL().withHTTPAuthentication(true).username(token.getUsername()).password(token.getPassword())
.create();
return OlogHttpClient.builder().username(token.getUsername()).password(token.getPassword())
.build();
} else {
return getLogClient();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@

package org.phoebus.applications.logbook.authentication;

import org.phoebus.olog.es.api.OlogClient;
import org.phoebus.olog.es.api.OlogClient.OlogClientBuilder;
import org.phoebus.olog.es.api.OlogHttpClient;
import org.phoebus.security.authorization.ServiceAuthenticationProvider;
import org.phoebus.security.tokens.AuthenticationScope;

Expand All @@ -30,12 +29,11 @@ public class OlogServiceAuthenticationProvider implements ServiceAuthenticationP

@Override
public void authenticate(String username, String password){
OlogClient ologClient = OlogClientBuilder.serviceURL().create();
try {
ologClient.authenticate(username, password);
OlogHttpClient.builder().build().authenticate(username, password);
} catch (Exception e) {
Logger.getLogger(OlogServiceAuthenticationProvider.class.getName())
.log(Level.WARNING, "Failed to authenticate user " + username + " against Olog service", e);
.log(Level.WARNING, "Failed to authenticate user " + username + " with logbook service", e);
throw new RuntimeException(e);
}
}
Expand Down
Loading

0 comments on commit 7a96829

Please sign in to comment.