io.quarkus.websockets.BearerTokenClientEndpointConfigurator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of quarkus-websockets-client Show documentation
Show all versions of quarkus-websockets-client Show documentation
Client for WebSocket communication channel
package io.quarkus.websockets;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import javax.net.ssl.SSLContext;
import jakarta.websocket.ClientEndpointConfig;
import jakarta.websocket.Decoder;
import jakarta.websocket.Encoder;
import jakarta.websocket.Extension;
import io.vertx.core.http.HttpHeaders;
public class BearerTokenClientEndpointConfigurator implements ClientEndpointConfig {
final String token;
public BearerTokenClientEndpointConfigurator(String token) {
this.token = token;
}
@Override
public List getPreferredSubprotocols() {
return Collections.emptyList();
}
@Override
public List getExtensions() {
return Collections.emptyList();
}
@Override
public Configurator getConfigurator() {
return new Configurator() {
@Override
public void beforeRequest(Map> headers) {
headers.put(HttpHeaders.AUTHORIZATION.toString(), Collections.singletonList("Bearer " + token));
}
};
}
@Override
public List> getEncoders() {
return Collections.emptyList();
}
@Override
public List> getDecoders() {
return Collections.emptyList();
}
@Override
public Map getUserProperties() {
return Collections.emptyMap();
}
@Override
public SSLContext getSSLContext() {
return null;
}
}