package meerkat.bulletinboard.sqlserver.mappers;

import com.google.protobuf.InvalidProtocolBufferException;
import meerkat.protobuf.BulletinBoardApi.BulletinBoardMessage;
import meerkat.protobuf.BulletinBoardApi.UnsignedBulletinBoardMessage;
import meerkat.protobuf.Crypto.Signature;
import org.springframework.jdbc.core.RowMapper;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Created by Arbel Deutsch Peled on 11-Dec-15.
 */
public class SignatureMapper implements RowMapper<Signature> {

    @Override
    public Signature mapRow(ResultSet rs, int rowNum) throws SQLException {

        try {
            return Signature.parseFrom(rs.getBytes(1));
        } catch (InvalidProtocolBufferException e) {
            throw new SQLException(e.getMessage(), e);
        }

    }

}
