use of com.google.crypto.tink.proto.testing.KeysetTemplateResponse in project tink by google.
the class KeysetServiceImpl method getTemplate.
@Override
public void getTemplate(KeysetTemplateRequest request, StreamObserver<KeysetTemplateResponse> responseObserver) {
KeysetTemplateResponse response;
try {
KeyTemplate template = KeyTemplates.get(request.getTemplateName());
response = KeysetTemplateResponse.newBuilder().setKeyTemplate(ByteString.copyFrom(KeyTemplateProtoConverter.toByteArray(template))).build();
} catch (GeneralSecurityException e) {
response = KeysetTemplateResponse.newBuilder().setErr(e.toString()).build();
}
responseObserver.onNext(response);
responseObserver.onCompleted();
}
use of com.google.crypto.tink.proto.testing.KeysetTemplateResponse in project tink by google.
the class TestingServicesTest method template_success.
@Test
public void template_success() throws Exception {
KeysetTemplateRequest request = KeysetTemplateRequest.newBuilder().setTemplateName("AES256_GCM").build();
KeysetTemplateResponse response = keysetStub.getTemplate(request);
assertThat(response.getErr()).isEmpty();
KeyTemplate template = KeyTemplateProtoConverter.fromByteArray(response.getKeyTemplate().toByteArray());
assertThat(template.getTypeUrl()).isEqualTo("type.googleapis.com/google.crypto.tink.AesGcmKey");
}
use of com.google.crypto.tink.proto.testing.KeysetTemplateResponse in project tink by google.
the class TestingServicesTest method template_not_found.
@Test
public void template_not_found() throws Exception {
KeysetTemplateRequest request = KeysetTemplateRequest.newBuilder().setTemplateName("UNKNOWN_TEMPLATE").build();
KeysetTemplateResponse response = keysetStub.getTemplate(request);
assertThat(response.getErr()).isNotEmpty();
}
Aggregations