use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project incubator-skywalking by apache.
the class SegmentEsUIDAO method load.
@Override
public TraceSegmentObject load(String segmentId) {
GetResponse response = getClient().prepareGet(SegmentTable.TABLE, segmentId).get();
Map<String, Object> source = response.getSource();
String dataBinaryBase64 = (String) source.get(SegmentTable.COLUMN_DATA_BINARY);
if (StringUtils.isNotEmpty(dataBinaryBase64)) {
byte[] dataBinary = Base64.getDecoder().decode(dataBinaryBase64);
try {
return TraceSegmentObject.parseFrom(dataBinary);
} catch (InvalidProtocolBufferException e) {
logger.error(e.getMessage(), e);
}
}
return null;
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project incubator-skywalking by apache.
the class SegmentH2UIDAO method load.
@Override
public TraceSegmentObject load(String segmentId) {
H2Client client = getClient();
String sql = SqlBuilder.buildSql(GET_SEGMENT_SQL, SegmentTable.COLUMN_DATA_BINARY, SegmentTable.TABLE, SegmentTable.COLUMN_ID);
Object[] params = new Object[] { segmentId };
try (ResultSet rs = client.executeQuery(sql, params)) {
if (rs.next()) {
byte[] dataBinary = rs.getBytes(SegmentTable.COLUMN_DATA_BINARY);
try {
return TraceSegmentObject.parseFrom(dataBinary);
} catch (InvalidProtocolBufferException e) {
logger.error(e.getMessage(), e);
}
}
} catch (SQLException | H2ClientException e) {
logger.error(e.getMessage(), e);
}
return null;
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project fabric-sdk-java by hyperledger.
the class Channel method queryBlockByTransactionID.
/**
* query a peer in this channel for a Block by a TransactionID contained in the block
*
* @param peers the peer to try to send the request to
* @param txID the transactionID to query on
* @param userContext the user context.
* @return the {@link BlockInfo} for the Block containing the transaction
* @throws InvalidArgumentException
* @throws ProposalException
*/
public BlockInfo queryBlockByTransactionID(Collection<Peer> peers, String txID, User userContext) throws InvalidArgumentException, ProposalException {
checkChannelState();
checkPeers(peers);
User.userContextCheck(userContext);
if (txID == null) {
throw new InvalidArgumentException("TxID parameter is null.");
}
try {
logger.debug("queryBlockByTransactionID with txID " + txID + " \n " + " on channel " + name);
QuerySCCRequest querySCCRequest = new QuerySCCRequest(userContext);
querySCCRequest.setFcn(QuerySCCRequest.GETBLOCKBYTXID);
querySCCRequest.setArgs(name, txID);
ProposalResponse proposalResponse = sendProposalSerially(querySCCRequest, peers);
return new BlockInfo(Block.parseFrom(proposalResponse.getProposalResponse().getResponse().getPayload()));
} catch (InvalidProtocolBufferException e) {
throw new ProposalException(e);
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project fabric-sdk-java by hyperledger.
the class Channel method queryBlockByNumber.
/**
* query a peer in this channel for a Block by the blockNumber
*
* @param peers the peers to try and send the request to
* @param blockNumber index of the Block in the chain
* @param userContext the user context to use.
* @return the {@link BlockInfo} with the given blockNumber
* @throws InvalidArgumentException
* @throws ProposalException
*/
public BlockInfo queryBlockByNumber(Collection<Peer> peers, long blockNumber, User userContext) throws InvalidArgumentException, ProposalException {
checkChannelState();
checkPeers(peers);
userContextCheck(userContext);
try {
logger.debug("queryBlockByNumber with blockNumber " + blockNumber + " on channel " + name);
QuerySCCRequest querySCCRequest = new QuerySCCRequest(userContext);
querySCCRequest.setFcn(QuerySCCRequest.GETBLOCKBYNUMBER);
querySCCRequest.setArgs(name, Long.toUnsignedString(blockNumber));
ProposalResponse proposalResponse = sendProposalSerially(querySCCRequest, peers);
return new BlockInfo(Block.parseFrom(proposalResponse.getProposalResponse().getResponse().getPayload()));
} catch (InvalidProtocolBufferException e) {
logger.error(e);
throw new ProposalException(e);
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project fabric-sdk-java by hyperledger.
the class ProposalResponse method verify.
/*
* Verifies that a Proposal response is properly signed. The payload is the
* concatenation of the response payload byte string and the endorsement The
* certificate (public key) is gotten from the Endorsement.Endorser.IdBytes
* field
*
* @param crypto the CryptoPrimitives instance to be used for signing and
* verification
*
* @return true/false depending on result of signature verification
*/
public boolean verify(CryptoSuite crypto) {
if (isVerified()) {
// check if this proposalResponse was already verified by client code
return isVerified();
}
if (isInvalid()) {
this.isVerified = false;
}
FabricProposalResponse.Endorsement endorsement = this.proposalResponse.getEndorsement();
ByteString sig = endorsement.getSignature();
try {
Identities.SerializedIdentity endorser = Identities.SerializedIdentity.parseFrom(endorsement.getEndorser());
ByteString plainText = proposalResponse.getPayload().concat(endorsement.getEndorser());
if (config.extraLogLevel(10)) {
if (null != diagnosticFileDumper) {
StringBuilder sb = new StringBuilder(10000);
sb.append("payload TransactionBuilderbytes in hex: " + DatatypeConverter.printHexBinary(proposalResponse.getPayload().toByteArray()));
sb.append("\n");
sb.append("endorser bytes in hex: " + DatatypeConverter.printHexBinary(endorsement.getEndorser().toByteArray()));
sb.append("\n");
sb.append("plainText bytes in hex: " + DatatypeConverter.printHexBinary(plainText.toByteArray()));
logger.trace("payload TransactionBuilderbytes: " + diagnosticFileDumper.createDiagnosticFile(sb.toString()));
}
}
this.isVerified = crypto.verify(endorser.getIdBytes().toByteArray(), config.getSignatureAlgorithm(), sig.toByteArray(), plainText.toByteArray());
} catch (InvalidProtocolBufferException | CryptoException e) {
logger.error("verify: Cannot retrieve peer identity from ProposalResponse. Error is: " + e.getMessage(), e);
this.isVerified = false;
}
return this.isVerified;
}
Aggregations