Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to native HttpClient in Olog ES #3219

Merged
merged 2 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 3 additions & 15 deletions app/logbook/olog/client-es/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,10 @@
<artifactId>app-logbook-olog-client-es</artifactId>

<dependencies>
<!-- https://mvnrepository.com/artifact/com.sun.jersey/jersey-core -->
<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>
<!-- https://mvnrepository.com/artifact/com.sun.jersey.contribs/jersey-multipart -->
<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
Loading