Search in sources :

Example 1 with CommandConnect

use of org.apache.pulsar.common.api.proto.CommandConnect in project pulsar by apache.

the class Commands method newConnect.

public static ByteBuf newConnect(String authMethodName, String authData, int protocolVersion, String libVersion, String targetBroker, String originalPrincipal, String originalAuthData, String originalAuthMethod) {
    BaseCommand cmd = localCmd(Type.CONNECT);
    CommandConnect connect = cmd.setConnect().setClientVersion(libVersion != null ? libVersion : "Pulsar Client").setAuthMethodName(authMethodName);
    if ("ycav1".equals(authMethodName)) {
        // Handle the case of a client that gets updated before the broker and starts sending the string auth method
        // name. An example would be in broker-to-broker replication. We need to make sure the clients are still
        // passing both the enum and the string until all brokers are upgraded.
        connect.setAuthMethod(AuthMethod.AuthMethodYcaV1);
    }
    if (targetBroker != null) {
        // When connecting through a proxy, we need to specify which broker do we want to be proxied through
        connect.setProxyToBrokerUrl(targetBroker);
    }
    if (authData != null) {
        connect.setAuthData(authData.getBytes(UTF_8));
    }
    if (originalPrincipal != null) {
        connect.setOriginalPrincipal(originalPrincipal);
    }
    if (originalAuthData != null) {
        connect.setOriginalAuthData(originalAuthData);
    }
    if (originalAuthMethod != null) {
        connect.setOriginalAuthMethod(originalAuthMethod);
    }
    connect.setProtocolVersion(protocolVersion);
    setFeatureFlags(connect.setFeatureFlags());
    return serializeWithSize(cmd);
}
Also used : CommandConnect(org.apache.pulsar.common.api.proto.CommandConnect) BaseCommand(org.apache.pulsar.common.api.proto.BaseCommand)

Example 2 with CommandConnect

use of org.apache.pulsar.common.api.proto.CommandConnect in project pulsar by apache.

the class Commands method newConnect.

public static ByteBuf newConnect(String authMethodName, AuthData authData, int protocolVersion, String libVersion, String targetBroker, String originalPrincipal, AuthData originalAuthData, String originalAuthMethod) {
    BaseCommand cmd = localCmd(Type.CONNECT);
    CommandConnect connect = cmd.setConnect().setClientVersion(libVersion != null ? libVersion : "Pulsar Client").setAuthMethodName(authMethodName);
    if (targetBroker != null) {
        // When connecting through a proxy, we need to specify which broker do we want to be proxied through
        connect.setProxyToBrokerUrl(targetBroker);
    }
    if (authData != null) {
        connect.setAuthData(authData.getBytes());
    }
    if (originalPrincipal != null) {
        connect.setOriginalPrincipal(originalPrincipal);
    }
    if (originalAuthData != null) {
        connect.setOriginalAuthData(new String(originalAuthData.getBytes(), UTF_8));
    }
    if (originalAuthMethod != null) {
        connect.setOriginalAuthMethod(originalAuthMethod);
    }
    connect.setProtocolVersion(protocolVersion);
    setFeatureFlags(connect.setFeatureFlags());
    return serializeWithSize(cmd);
}
Also used : CommandConnect(org.apache.pulsar.common.api.proto.CommandConnect) BaseCommand(org.apache.pulsar.common.api.proto.BaseCommand)

Example 3 with CommandConnect

use of org.apache.pulsar.common.api.proto.CommandConnect in project pulsar by yahoo.

the class Commands method newConnect.

public static ByteBuf newConnect(String authMethodName, AuthData authData, int protocolVersion, String libVersion, String targetBroker, String originalPrincipal, AuthData originalAuthData, String originalAuthMethod) {
    BaseCommand cmd = localCmd(Type.CONNECT);
    CommandConnect connect = cmd.setConnect().setClientVersion(libVersion != null ? libVersion : "Pulsar Client").setAuthMethodName(authMethodName);
    if (targetBroker != null) {
        // When connecting through a proxy, we need to specify which broker do we want to be proxied through
        connect.setProxyToBrokerUrl(targetBroker);
    }
    if (authData != null) {
        connect.setAuthData(authData.getBytes());
    }
    if (originalPrincipal != null) {
        connect.setOriginalPrincipal(originalPrincipal);
    }
    if (originalAuthData != null) {
        connect.setOriginalAuthData(new String(originalAuthData.getBytes(), UTF_8));
    }
    if (originalAuthMethod != null) {
        connect.setOriginalAuthMethod(originalAuthMethod);
    }
    connect.setProtocolVersion(protocolVersion);
    setFeatureFlags(connect.setFeatureFlags());
    return serializeWithSize(cmd);
}
Also used : CommandConnect(org.apache.pulsar.common.api.proto.CommandConnect) BaseCommand(org.apache.pulsar.common.api.proto.BaseCommand)

Example 4 with CommandConnect

use of org.apache.pulsar.common.api.proto.CommandConnect in project incubator-pulsar by apache.

the class Commands method newConnect.

public static ByteBuf newConnect(String authMethodName, String authData, int protocolVersion, String libVersion, String targetBroker, String originalPrincipal, String originalAuthData, String originalAuthMethod) {
    BaseCommand cmd = localCmd(Type.CONNECT);
    CommandConnect connect = cmd.setConnect().setClientVersion(libVersion != null ? libVersion : "Pulsar Client").setAuthMethodName(authMethodName);
    if ("ycav1".equals(authMethodName)) {
        // Handle the case of a client that gets updated before the broker and starts sending the string auth method
        // name. An example would be in broker-to-broker replication. We need to make sure the clients are still
        // passing both the enum and the string until all brokers are upgraded.
        connect.setAuthMethod(AuthMethod.AuthMethodYcaV1);
    }
    if (targetBroker != null) {
        // When connecting through a proxy, we need to specify which broker do we want to be proxied through
        connect.setProxyToBrokerUrl(targetBroker);
    }
    if (authData != null) {
        connect.setAuthData(authData.getBytes(UTF_8));
    }
    if (originalPrincipal != null) {
        connect.setOriginalPrincipal(originalPrincipal);
    }
    if (originalAuthData != null) {
        connect.setOriginalAuthData(originalAuthData);
    }
    if (originalAuthMethod != null) {
        connect.setOriginalAuthMethod(originalAuthMethod);
    }
    connect.setProtocolVersion(protocolVersion);
    setFeatureFlags(connect.setFeatureFlags());
    return serializeWithSize(cmd);
}
Also used : CommandConnect(org.apache.pulsar.common.api.proto.CommandConnect) BaseCommand(org.apache.pulsar.common.api.proto.BaseCommand)

Example 5 with CommandConnect

use of org.apache.pulsar.common.api.proto.CommandConnect in project incubator-pulsar by apache.

the class Commands method newConnect.

public static ByteBuf newConnect(String authMethodName, AuthData authData, int protocolVersion, String libVersion, String targetBroker, String originalPrincipal, AuthData originalAuthData, String originalAuthMethod) {
    BaseCommand cmd = localCmd(Type.CONNECT);
    CommandConnect connect = cmd.setConnect().setClientVersion(libVersion != null ? libVersion : "Pulsar Client").setAuthMethodName(authMethodName);
    if (targetBroker != null) {
        // When connecting through a proxy, we need to specify which broker do we want to be proxied through
        connect.setProxyToBrokerUrl(targetBroker);
    }
    if (authData != null) {
        connect.setAuthData(authData.getBytes());
    }
    if (originalPrincipal != null) {
        connect.setOriginalPrincipal(originalPrincipal);
    }
    if (originalAuthData != null) {
        connect.setOriginalAuthData(new String(originalAuthData.getBytes(), UTF_8));
    }
    if (originalAuthMethod != null) {
        connect.setOriginalAuthMethod(originalAuthMethod);
    }
    connect.setProtocolVersion(protocolVersion);
    setFeatureFlags(connect.setFeatureFlags());
    return serializeWithSize(cmd);
}
Also used : CommandConnect(org.apache.pulsar.common.api.proto.CommandConnect) BaseCommand(org.apache.pulsar.common.api.proto.BaseCommand)

Aggregations

BaseCommand (org.apache.pulsar.common.api.proto.BaseCommand)6 CommandConnect (org.apache.pulsar.common.api.proto.CommandConnect)6