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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations