Search in sources :

Example 91 with InvalidProtocolBufferException

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

the class CompatibilityTest method testMergeFromInvalidProtocolBufferException.

public void testMergeFromInvalidProtocolBufferException() throws Exception {
    try {
        ByteArrayInputStream in = new ByteArrayInputStream(new byte[] { 0x00 });
        @SuppressWarnings("unused") TypicalData output = TypicalData.newBuilder().mergeFrom(in, ExtensionRegistry.getEmptyRegistry()).build();
        fail("Expected InvalidProtocolBufferException to be thrown.");
    } catch (InvalidProtocolBufferException e) {
    // Expected
    }
}
Also used : TypicalData(protos.TypicalData) ByteArrayInputStream(java.io.ByteArrayInputStream) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException)

Example 92 with InvalidProtocolBufferException

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

the class GroupsV2AuthorizationSignalStoreCache method read.

@Override
@NonNull
public Map<Integer, AuthCredentialResponse> read() {
    byte[] credentialBlob = store.getBlob(KEY, null);
    if (credentialBlob == null) {
        Log.i(TAG, "No credentials responses are cached locally");
        return Collections.emptyMap();
    }
    try {
        TemporalAuthCredentialResponses temporalCredentials = TemporalAuthCredentialResponses.parseFrom(credentialBlob);
        HashMap<Integer, AuthCredentialResponse> result = new HashMap<>(temporalCredentials.getCredentialResponseCount());
        for (TemporalAuthCredentialResponse credential : temporalCredentials.getCredentialResponseList()) {
            result.put(credential.getDate(), new AuthCredentialResponse(credential.getAuthCredentialResponse().toByteArray()));
        }
        Log.i(TAG, String.format(Locale.US, "Loaded %d credentials from local storage", result.size()));
        return result;
    } catch (InvalidProtocolBufferException | InvalidInputException e) {
        throw new AssertionError(e);
    }
}
Also used : TemporalAuthCredentialResponse(org.thoughtcrime.securesms.database.model.databaseprotos.TemporalAuthCredentialResponse) InvalidInputException(org.signal.zkgroup.InvalidInputException) HashMap(java.util.HashMap) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) TemporalAuthCredentialResponses(org.thoughtcrime.securesms.database.model.databaseprotos.TemporalAuthCredentialResponses) AuthCredentialResponse(org.signal.zkgroup.auth.AuthCredentialResponse) TemporalAuthCredentialResponse(org.thoughtcrime.securesms.database.model.databaseprotos.TemporalAuthCredentialResponse) NonNull(androidx.annotation.NonNull)

Example 93 with InvalidProtocolBufferException

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

the class WebSocketConnection method onMessage.

@Override
public synchronized void onMessage(WebSocket webSocket, ByteString payload) {
    try {
        WebSocketMessage message = WebSocketMessage.parseFrom(payload.toByteArray());
        if (message.getType().getNumber() == WebSocketMessage.Type.REQUEST_VALUE) {
            incomingRequests.add(message.getRequest());
        } else if (message.getType().getNumber() == WebSocketMessage.Type.RESPONSE_VALUE) {
            OutgoingRequest listener = outgoingRequests.remove(message.getResponse().getId());
            if (listener != null) {
                listener.onSuccess(new WebsocketResponse(message.getResponse().getStatus(), new String(message.getResponse().getBody().toByteArray()), message.getResponse().getHeadersList(), !credentialsProvider.isPresent()));
                if (message.getResponse().getStatus() >= 400) {
                    healthMonitor.onMessageError(message.getResponse().getStatus(), credentialsProvider.isPresent());
                }
            } else if (keepAlives.remove(message.getResponse().getId())) {
                healthMonitor.onKeepAliveResponse(message.getResponse().getId(), credentialsProvider.isPresent());
            }
        }
        notifyAll();
    } catch (InvalidProtocolBufferException e) {
        warn(e);
    }
}
Also used : InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) WebSocketMessage(org.whispersystems.signalservice.internal.websocket.WebSocketProtos.WebSocketMessage) ByteString(okio.ByteString)

Example 94 with InvalidProtocolBufferException

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

the class SignalServiceCipher method decrypt.

/**
 * Decrypt a received {@link SignalServiceEnvelope}
 *
 * @param envelope The received SignalServiceEnvelope
 *
 * @return a decrypted SignalServiceContent
 */
public SignalServiceContent decrypt(SignalServiceEnvelope envelope) throws InvalidMetadataMessageException, InvalidMetadataVersionException, ProtocolInvalidKeyIdException, ProtocolLegacyMessageException, ProtocolUntrustedIdentityException, ProtocolNoSessionException, ProtocolInvalidVersionException, ProtocolInvalidMessageException, ProtocolInvalidKeyException, ProtocolDuplicateMessageException, SelfSendException, UnsupportedDataMessageException, InvalidMessageStructureException {
    try {
        if (envelope.hasLegacyMessage()) {
            Plaintext plaintext = decrypt(envelope, envelope.getLegacyMessage());
            SignalServiceProtos.DataMessage dataMessage = SignalServiceProtos.DataMessage.parseFrom(plaintext.getData());
            SignalServiceContentProto contentProto = SignalServiceContentProto.newBuilder().setLocalAddress(SignalServiceAddressProtobufSerializer.toProtobuf(localAddress)).setMetadata(SignalServiceMetadataProtobufSerializer.toProtobuf(plaintext.metadata)).setLegacyDataMessage(dataMessage).build();
            return SignalServiceContent.createFromProto(contentProto);
        } else if (envelope.hasContent()) {
            Plaintext plaintext = decrypt(envelope, envelope.getContent());
            SignalServiceProtos.Content content = SignalServiceProtos.Content.parseFrom(plaintext.getData());
            SignalServiceContentProto contentProto = SignalServiceContentProto.newBuilder().setLocalAddress(SignalServiceAddressProtobufSerializer.toProtobuf(localAddress)).setMetadata(SignalServiceMetadataProtobufSerializer.toProtobuf(plaintext.metadata)).setContent(content).build();
            return SignalServiceContent.createFromProto(contentProto);
        }
        return null;
    } catch (InvalidProtocolBufferException e) {
        throw new InvalidMetadataMessageException(e);
    }
}
Also used : SignalServiceProtos(org.whispersystems.signalservice.internal.push.SignalServiceProtos) SignalServiceContent(org.whispersystems.signalservice.api.messages.SignalServiceContent) PlaintextContent(org.whispersystems.libsignal.protocol.PlaintextContent) UnidentifiedSenderMessageContent(org.signal.libsignal.metadata.protocol.UnidentifiedSenderMessageContent) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) SignalServiceContentProto(org.whispersystems.signalservice.internal.serialize.protos.SignalServiceContentProto) InvalidMetadataMessageException(org.signal.libsignal.metadata.InvalidMetadataMessageException)

Example 95 with InvalidProtocolBufferException

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

the class ProtobufUtils method deserializeJson.

/* Protobuf json */
static <T> T deserializeJson(String json, Class<T> requestClass) throws InvalidProtocolBufferException {
    Builder builder;
    try {
        builder = getMessageBuilder(requestClass);
    } catch (Exception e) {
        throw new IllegalArgumentException("Get google protobuf message builder from " + requestClass.getName() + "failed", e);
    }
    JsonFormat.parser().merge(json, builder);
    return (T) builder.build();
}
Also used : MessageOrBuilder(com.google.protobuf.MessageOrBuilder) Builder(com.google.protobuf.GeneratedMessageV3.Builder) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) IOException(java.io.IOException)

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