public Builder mergeFrom(com.google.cloud.kms.v1.EncryptRequest other) { if (other == com.google.cloud.kms.v1.EncryptRequest.getDefaultInstance()) return this; if (!other.getName().isEmpty()) { name_ = other.name_; onChanged(); } if (other.getPlaintext() != com.google.protobuf.ByteString.EMPTY) { setPlaintext(other.getPlaintext()); } if (other.getAdditionalAuthenticatedData() != com.google.protobuf.ByteString.EMPTY) { setAdditionalAuthenticatedData(other.getAdditionalAuthenticatedData()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); }
@java.lang.Override public com.google.cloud.kms.v1.EncryptRequest buildPartial() { com.google.cloud.kms.v1.EncryptRequest result = new com.google.cloud.kms.v1.EncryptRequest(this); result.name_ = name_; result.plaintext_ = plaintext_; result.additionalAuthenticatedData_ = additionalAuthenticatedData_; onBuilt(); return result; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.cloud.kms.v1.EncryptRequest)) { return super.equals(obj); } com.google.cloud.kms.v1.EncryptRequest other = (com.google.cloud.kms.v1.EncryptRequest) obj; boolean result = true; result = result && getName().equals(other.getName()); result = result && getPlaintext().equals(other.getPlaintext()); result = result && getAdditionalAuthenticatedData().equals(other.getAdditionalAuthenticatedData()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + NAME_FIELD_NUMBER; hash = (53 * hash) + getName().hashCode(); hash = (37 * hash) + PLAINTEXT_FIELD_NUMBER; hash = (53 * hash) + getPlaintext().hashCode(); hash = (37 * hash) + ADDITIONAL_AUTHENTICATED_DATA_FIELD_NUMBER; hash = (53 * hash) + getAdditionalAuthenticatedData().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
/** * * * <pre> * Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] or [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] * to use for encryption. * If a [CryptoKey][google.cloud.kms.v1.CryptoKey] is specified, the server will use its * [primary version][google.cloud.kms.v1.CryptoKey.primary]. * </pre> * * <code>string name = 1;</code> */ public Builder clearName() { name_ = getDefaultInstance().getName(); onChanged(); return this; } /**
@Test @SuppressWarnings("all") public void encryptTest() { String name2 = "name2-1052831874"; ByteString ciphertext = ByteString.copyFromUtf8("-72"); EncryptResponse expectedResponse = EncryptResponse.newBuilder().setName(name2).setCiphertext(ciphertext).build(); mockKeyManagementService.addResponse(expectedResponse); CryptoKeyPathName name = CryptoKeyPathName.of("[PROJECT]", "[LOCATION]", "[KEY_RING]", "[CRYPTO_KEY_PATH]"); ByteString plaintext = ByteString.copyFromUtf8("-9"); EncryptResponse actualResponse = client.encrypt(name, plaintext); Assert.assertEquals(expectedResponse, actualResponse); List<GeneratedMessageV3> actualRequests = mockKeyManagementService.getRequests(); Assert.assertEquals(1, actualRequests.size()); EncryptRequest actualRequest = (EncryptRequest) actualRequests.get(0); Assert.assertEquals(name, CryptoKeyPathName.parse(actualRequest.getName())); Assert.assertEquals(plaintext, actualRequest.getPlaintext()); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
/** * * * <pre> * Required. The data to encrypt. Must be no larger than 64KiB. * The maximum size depends on the key version's * [protection_level][google.cloud.kms.v1.CryptoKeyVersionTemplate.protection_level]. For * [SOFTWARE][google.cloud.kms.v1.ProtectionLevel.SOFTWARE] keys, the plaintext must be no larger * than 64KiB. For [HSM][google.cloud.kms.v1.ProtectionLevel.HSM] keys, the combined length of the * plaintext and additional_authenticated_data fields must be no larger than * 8KiB. * </pre> * * <code>bytes plaintext = 2;</code> */ public Builder clearPlaintext() { plaintext_ = getDefaultInstance().getPlaintext(); onChanged(); return this; }
@Override public Map<String, String> extract(EncryptRequest request) { ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); params.put("name", String.valueOf(request.getName())); return params.build(); } })
/** * * * <pre> * Optional data that, if specified, must also be provided during decryption * through [DecryptRequest.additional_authenticated_data][google.cloud.kms.v1.DecryptRequest.additional_authenticated_data]. * The maximum size depends on the key version's * [protection_level][google.cloud.kms.v1.CryptoKeyVersionTemplate.protection_level]. For * [SOFTWARE][google.cloud.kms.v1.ProtectionLevel.SOFTWARE] keys, the AAD must be no larger than * 64KiB. For [HSM][google.cloud.kms.v1.ProtectionLevel.HSM] keys, the combined length of the * plaintext and additional_authenticated_data fields must be no larger than * 8KiB. * </pre> * * <code>bytes additional_authenticated_data = 3;</code> */ public Builder clearAdditionalAuthenticatedData() { additionalAuthenticatedData_ = getDefaultInstance().getAdditionalAuthenticatedData(); onChanged(); return this; }
@java.lang.Override public com.google.cloud.kms.v1.EncryptRequest getDefaultInstanceForType() { return com.google.cloud.kms.v1.EncryptRequest.getDefaultInstance(); }
@java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (!getNameBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); } if (!plaintext_.isEmpty()) { output.writeBytes(2, plaintext_); } if (!additionalAuthenticatedData_.isEmpty()) { output.writeBytes(3, additionalAuthenticatedData_); } unknownFields.writeTo(output); }
@java.lang.Override public com.google.cloud.kms.v1.EncryptRequest build() { com.google.cloud.kms.v1.EncryptRequest result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + NAME_FIELD_NUMBER; hash = (53 * hash) + getName().hashCode(); hash = (37 * hash) + PLAINTEXT_FIELD_NUMBER; hash = (53 * hash) + getPlaintext().hashCode(); hash = (37 * hash) + ADDITIONAL_AUTHENTICATED_DATA_FIELD_NUMBER; hash = (53 * hash) + getAdditionalAuthenticatedData().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.cloud.kms.v1.EncryptRequest)) { return super.equals(obj); } com.google.cloud.kms.v1.EncryptRequest other = (com.google.cloud.kms.v1.EncryptRequest) obj; boolean result = true; result = result && getName().equals(other.getName()); result = result && getPlaintext().equals(other.getPlaintext()); result = result && getAdditionalAuthenticatedData().equals(other.getAdditionalAuthenticatedData()); result = result && unknownFields.equals(other.unknownFields); return result; }
/** * * * <pre> * Required. The resource name of the [CryptoKey][google.cloud.kms.v1.CryptoKey] or [CryptoKeyVersion][google.cloud.kms.v1.CryptoKeyVersion] * to use for encryption. * If a [CryptoKey][google.cloud.kms.v1.CryptoKey] is specified, the server will use its * [primary version][google.cloud.kms.v1.CryptoKey.primary]. * </pre> * * <code>string name = 1;</code> */ public Builder clearName() { name_ = getDefaultInstance().getName(); onChanged(); return this; } /**
/** * * * <pre> * Required. The data to encrypt. Must be no larger than 64KiB. * The maximum size depends on the key version's * [protection_level][google.cloud.kms.v1.CryptoKeyVersionTemplate.protection_level]. For * [SOFTWARE][google.cloud.kms.v1.ProtectionLevel.SOFTWARE] keys, the plaintext must be no larger * than 64KiB. For [HSM][google.cloud.kms.v1.ProtectionLevel.HSM] keys, the combined length of the * plaintext and additional_authenticated_data fields must be no larger than * 8KiB. * </pre> * * <code>bytes plaintext = 2;</code> */ public Builder clearPlaintext() { plaintext_ = getDefaultInstance().getPlaintext(); onChanged(); return this; }
@Override public Map<String, String> extract(EncryptRequest request) { ImmutableMap.Builder<String, String> params = ImmutableMap.builder(); params.put("name", String.valueOf(request.getName())); return params.build(); } })
/** * * * <pre> * Optional data that, if specified, must also be provided during decryption * through [DecryptRequest.additional_authenticated_data][google.cloud.kms.v1.DecryptRequest.additional_authenticated_data]. * The maximum size depends on the key version's * [protection_level][google.cloud.kms.v1.CryptoKeyVersionTemplate.protection_level]. For * [SOFTWARE][google.cloud.kms.v1.ProtectionLevel.SOFTWARE] keys, the AAD must be no larger than * 64KiB. For [HSM][google.cloud.kms.v1.ProtectionLevel.HSM] keys, the combined length of the * plaintext and additional_authenticated_data fields must be no larger than * 8KiB. * </pre> * * <code>bytes additional_authenticated_data = 3;</code> */ public Builder clearAdditionalAuthenticatedData() { additionalAuthenticatedData_ = getDefaultInstance().getAdditionalAuthenticatedData(); onChanged(); return this; }
.setRequestMarshaller( io.grpc.protobuf.ProtoUtils.marshaller( com.google.cloud.kms.v1.EncryptRequest.getDefaultInstance())) .setResponseMarshaller( io.grpc.protobuf.ProtoUtils.marshaller(