All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkus.websockets.BearerTokenClientEndpointConfigurator Maven / Gradle / Ivy

There is a newer version: 3.17.0
Show newest version
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;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy