Search in sources :

Example 31 with InvalidProtocolBufferException

use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project java-tron by tronprotocol.

the class AssetIssueActuatorTest method repeatAssetIssue.

@Test
public void repeatAssetIssue() {
    AssetIssueActuator actuator = new AssetIssueActuator(getContract(), dbManager);
    TransactionResultCapsule ret = new TransactionResultCapsule();
    try {
        dbManager.getAssetIssueStore().put(ByteArray.fromString(NAME), new AssetIssueCapsule(getContract().unpack(Contract.AssetIssueContract.class)));
        actuator.validate();
        actuator.execute(ret);
        Assert.assertTrue(false);
    } catch (ContractValidateException e) {
        Assert.assertTrue(e instanceof ContractValidateException);
        AccountCapsule owner = dbManager.getAccountStore().get(ByteArray.fromHexString(OWNER_ADDRESS));
        AssetIssueCapsule assetIssueCapsule = dbManager.getAssetIssueStore().get(ByteArray.fromString(NAME));
        Assert.assertNotNull(assetIssueCapsule);
        Assert.assertNull(owner.getInstance().getAssetMap().get(NAME));
    } catch (ContractExeException e) {
        Assert.assertFalse(e instanceof ContractExeException);
    } catch (InvalidProtocolBufferException e) {
        Assert.assertFalse(e instanceof InvalidProtocolBufferException);
    } finally {
        dbManager.getAssetIssueStore().delete(ByteArray.fromString(NAME));
    }
}
Also used : AccountCapsule(org.tron.core.capsule.AccountCapsule) TransactionResultCapsule(org.tron.core.capsule.TransactionResultCapsule) ContractValidateException(org.tron.core.exception.ContractValidateException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) AssetIssueCapsule(org.tron.core.capsule.AssetIssueCapsule) Contract(org.tron.protos.Contract) ContractExeException(org.tron.core.exception.ContractExeException) Test(org.junit.Test)

Example 32 with InvalidProtocolBufferException

use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project android_packages_apps_Dialer by LineageOS.

the class Coalescer method rowsShouldBeCombined.

/**
 * @param row1 a row from {@link AnnotatedCallLog}
 * @param row2 a row from {@link AnnotatedCallLog}
 */
private static boolean rowsShouldBeCombined(DialerPhoneNumberUtil dialerPhoneNumberUtil, ContentValues row1, ContentValues row2) {
    // TODO: Real implementation.
    DialerPhoneNumber number1;
    DialerPhoneNumber number2;
    try {
        number1 = DialerPhoneNumber.parseFrom(row1.getAsByteArray(AnnotatedCallLog.NUMBER));
        number2 = DialerPhoneNumber.parseFrom(row2.getAsByteArray(AnnotatedCallLog.NUMBER));
    } catch (InvalidProtocolBufferException e) {
        throw Assert.createAssertionFailException("error parsing DialerPhoneNumber proto", e);
    }
    if (!number1.hasDialerInternalPhoneNumber() && !number2.hasDialerInternalPhoneNumber()) {
        // Empty numbers should not be combined.
        return false;
    }
    if (!number1.hasDialerInternalPhoneNumber() || !number2.hasDialerInternalPhoneNumber()) {
        // An empty number should not be combined with a non-empty number.
        return false;
    }
    return dialerPhoneNumberUtil.isExactMatch(number1, number2);
}
Also used : DialerPhoneNumber(com.android.dialer.DialerPhoneNumber) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException)

Example 33 with InvalidProtocolBufferException

use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project android_packages_apps_Dialer by LineageOS.

the class SystemCallLogDataSource method getMostRecentPhoneNumber.

private static DialerPhoneNumber getMostRecentPhoneNumber(List<ContentValues> individualRowsSortedByTimestampDesc) {
    DialerPhoneNumber dialerPhoneNumber;
    byte[] protoBytes = individualRowsSortedByTimestampDesc.get(0).getAsByteArray(AnnotatedCallLog.NUMBER);
    try {
        dialerPhoneNumber = DialerPhoneNumber.parseFrom(protoBytes);
    } catch (InvalidProtocolBufferException e) {
        throw Assert.createAssertionFailException("couldn't parse DialerPhoneNumber", e);
    }
    return dialerPhoneNumber;
}
Also used : DialerPhoneNumber(com.android.dialer.DialerPhoneNumber) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException)

Example 34 with InvalidProtocolBufferException

use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project bisq-core by bisq-network.

the class IssuanceService method getRevealedVotes.

private Set<RevealedVote> getRevealedVotes(Map<String, SecretKey> secretKeysByTxIdMap, Set<BlindVoteWithRevealTxId> blindVoteWithRevealTxIdSet) {
    return blindVoteWithRevealTxIdSet.stream().map(blindVoteWithRevealTxId -> {
        try {
            // TODO check if cloning here is needed (we might want to keep the blindVote separated from the
            // blindVoteList to the RevealedVote...)
            final BlindVote blindVote = BlindVote.clone(blindVoteWithRevealTxId.getBlindVote());
            final byte[] encryptedProposalList = blindVote.getEncryptedProposalList();
            final SecretKey secretKey = secretKeysByTxIdMap.get(blindVoteWithRevealTxId.getTxId());
            final byte[] decrypted = Encryption.decrypt(encryptedProposalList, secretKey);
            // TODO move to ProposalList
            final PB.PersistableEnvelope envelope = PB.PersistableEnvelope.parseFrom(decrypted);
            ProposalList proposalList = ProposalList.fromProto(envelope.getProposalList());
            return new RevealedVote(proposalList, blindVote);
        } catch (CryptoException e) {
            e.printStackTrace();
            return null;
        } catch (InvalidProtocolBufferException e) {
            e.printStackTrace();
            return null;
        }
    }).filter(Objects::nonNull).collect(Collectors.toSet());
}
Also used : SecretKey(javax.crypto.SecretKey) PB(io.bisq.generated.protobuffer.PB) RevealedVote(bisq.core.dao.vote.RevealedVote) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) CryptoException(bisq.common.crypto.CryptoException) BlindVote(bisq.core.dao.vote.BlindVote) ProposalList(bisq.core.dao.proposal.ProposalList)

Example 35 with InvalidProtocolBufferException

use of org.apache.beam.vendor.grpc.v1p43p2.com.google.protobuf.InvalidProtocolBufferException in project Signal-Android by signalapp.

the class WebRtcCallService method onMessage.

@Override
public void onMessage(DataChannel.Buffer buffer) {
    Log.w(TAG, "onMessage...");
    try {
        byte[] data = new byte[buffer.data.remaining()];
        buffer.data.get(data);
        Data dataMessage = Data.parseFrom(data);
        if (dataMessage.hasConnected()) {
            Log.w(TAG, "hasConnected...");
            Intent intent = new Intent(this, WebRtcCallService.class);
            intent.setAction(ACTION_CALL_CONNECTED);
            intent.putExtra(EXTRA_CALL_ID, dataMessage.getConnected().getId());
            startService(intent);
        } else if (dataMessage.hasHangup()) {
            Log.w(TAG, "hasHangup...");
            Intent intent = new Intent(this, WebRtcCallService.class);
            intent.setAction(ACTION_REMOTE_HANGUP);
            intent.putExtra(EXTRA_CALL_ID, dataMessage.getHangup().getId());
            startService(intent);
        } else if (dataMessage.hasVideoStreamingStatus()) {
            Log.w(TAG, "hasVideoStreamingStatus...");
            Intent intent = new Intent(this, WebRtcCallService.class);
            intent.setAction(ACTION_REMOTE_VIDEO_MUTE);
            intent.putExtra(EXTRA_CALL_ID, dataMessage.getVideoStreamingStatus().getId());
            intent.putExtra(EXTRA_MUTE, !dataMessage.getVideoStreamingStatus().getEnabled());
            startService(intent);
        }
    } catch (InvalidProtocolBufferException e) {
        Log.w(TAG, e);
    }
}
Also used : InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) Data(org.thoughtcrime.securesms.webrtc.WebRtcDataProtos.Data) Intent(android.content.Intent)

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