25 lines
820 B
Java
25 lines
820 B
Java
package info.frostfs.sdk.mappers;
|
|
|
|
import com.google.protobuf.ByteString;
|
|
import frostfs.refs.Types;
|
|
import info.frostfs.sdk.dto.Signature;
|
|
|
|
import static java.util.Objects.isNull;
|
|
|
|
public class SignatureMapper {
|
|
|
|
public static Types.Signature ToGrpcMessage(Signature signature) {
|
|
var scheme = Types.SignatureScheme.forNumber(signature.getScheme().value);
|
|
if (isNull(scheme)) {
|
|
throw new IllegalArgumentException(
|
|
String.format("Unknown SignatureScheme. Value: %s.", signature.getScheme().name())
|
|
);
|
|
}
|
|
|
|
return Types.Signature.newBuilder()
|
|
.setKey(ByteString.copyFrom(signature.getKey()))
|
|
.setSign(ByteString.copyFrom(signature.getSign()))
|
|
.setScheme(scheme)
|
|
.build();
|
|
}
|
|
}
|