57 lines
1.6 KiB
Java
57 lines
1.6 KiB
Java
package info.frostfs.sdk.jdo;
|
|
|
|
import info.frostfs.sdk.FrostFSClient;
|
|
import info.frostfs.sdk.annotations.NotNull;
|
|
import info.frostfs.sdk.annotations.Validate;
|
|
import info.frostfs.sdk.dto.netmap.Version;
|
|
import info.frostfs.sdk.dto.object.OwnerId;
|
|
import info.frostfs.sdk.pool.SessionCache;
|
|
import io.grpc.Channel;
|
|
import lombok.Getter;
|
|
import lombok.Setter;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import static info.frostfs.sdk.Helper.getHexString;
|
|
import static info.frostfs.sdk.pool.Pool.formCacheKey;
|
|
|
|
@Getter
|
|
@Setter
|
|
public class ClientEnvironment {
|
|
|
|
@NotNull
|
|
private final OwnerId ownerId;
|
|
@NotNull
|
|
private final Version version;
|
|
@NotNull
|
|
@Validate
|
|
private final ECDsa key;
|
|
@NotNull
|
|
private final Channel channel;
|
|
@NotNull
|
|
private final FrostFSClient frostFSClient;
|
|
|
|
private String sessionKey;
|
|
private String address;
|
|
private NetworkSettings networkSettings;
|
|
|
|
private SessionCache sessionCache;
|
|
|
|
public ClientEnvironment(ECDsa key, Channel channel, Version version, FrostFSClient frostFSClient,
|
|
SessionCache sessionCache) {
|
|
this.key = key;
|
|
this.ownerId = new OwnerId(key.getAccount().getAddress());
|
|
this.version = version;
|
|
this.channel = channel;
|
|
this.frostFSClient = frostFSClient;
|
|
this.sessionCache = sessionCache;
|
|
this.address = channel.authority();
|
|
}
|
|
|
|
public String getSessionKey() {
|
|
if (StringUtils.isBlank(sessionKey)) {
|
|
this.sessionKey = formCacheKey(address, getHexString(key.getPublicKeyByte()));
|
|
}
|
|
|
|
return sessionKey;
|
|
}
|
|
}
|