Search in sources :

Example 41 with InvalidProtocolBufferException

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;
}
Also used : InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) TraceSegmentObject(org.apache.skywalking.apm.network.proto.TraceSegmentObject) GetResponse(org.elasticsearch.action.get.GetResponse)

Example 42 with InvalidProtocolBufferException

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;
}
Also used : H2Client(org.apache.skywalking.apm.collector.client.h2.H2Client) SQLException(java.sql.SQLException) ResultSet(java.sql.ResultSet) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) H2ClientException(org.apache.skywalking.apm.collector.client.h2.H2ClientException) TraceSegmentObject(org.apache.skywalking.apm.network.proto.TraceSegmentObject)

Example 43 with InvalidProtocolBufferException

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);
    }
}
Also used : InvalidArgumentException(org.hyperledger.fabric.sdk.exception.InvalidArgumentException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ProposalException(org.hyperledger.fabric.sdk.exception.ProposalException) FabricProposalResponse(org.hyperledger.fabric.protos.peer.FabricProposalResponse)

Example 44 with InvalidProtocolBufferException

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);
    }
}
Also used : InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ProposalException(org.hyperledger.fabric.sdk.exception.ProposalException) FabricProposalResponse(org.hyperledger.fabric.protos.peer.FabricProposalResponse)

Example 45 with InvalidProtocolBufferException

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;
}
Also used : ByteString(com.google.protobuf.ByteString) FabricProposalResponse(org.hyperledger.fabric.protos.peer.FabricProposalResponse) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) Identities(org.hyperledger.fabric.protos.msp.Identities) CryptoException(org.hyperledger.fabric.sdk.exception.CryptoException)

Aggregations

InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)334 IOException (java.io.IOException)69 ByteString (com.google.protobuf.ByteString)46 ServerRequest (com.pokegoapi.main.ServerRequest)46 RequestFailedException (com.pokegoapi.exceptions.request.RequestFailedException)39 GeneralSecurityException (java.security.GeneralSecurityException)32 CleartextKeysetHandle (com.google.crypto.tink.CleartextKeysetHandle)25 KeysetHandle (com.google.crypto.tink.KeysetHandle)25 HashMap (java.util.HashMap)25 ArrayList (java.util.ArrayList)22 InvalidProtocolBufferException (org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException)22 List (java.util.List)19 Any (com.google.protobuf.Any)18 Map (java.util.Map)18 Key (org.apache.accumulo.core.data.Key)17 Value (org.apache.accumulo.core.data.Value)17 Status (org.apache.accumulo.server.replication.proto.Replication.Status)17 Text (org.apache.hadoop.io.Text)17 HashSet (java.util.HashSet)12 RunnerApi (org.apache.beam.model.pipeline.v1.RunnerApi)11