@Test public void testECV2SigningOnlyWithPrecomputedKeys() throws Exception { PaymentMethodTokenSender sender = new PaymentMethodTokenSender.Builder() .protocolVersion(PaymentMethodTokenConstants.PROTOCOL_VERSION_EC_V2_SIGNING_ONLY) .senderIntermediateSigningKey( GOOGLE_SIGNING_EC_V2_SIGNING_ONLY_INTERMEDIATE_PRIVATE_KEY_PKCS8_BASE64) .senderIntermediateCert( new SenderIntermediateCertFactory.Builder() .protocolVersion( PaymentMethodTokenConstants.PROTOCOL_VERSION_EC_V2_SIGNING_ONLY) .addSenderSigningKey(GOOGLE_SIGNING_EC_V2_SIGNING_ONLY_PRIVATE_KEY_PKCS8_BASE64) .senderIntermediateSigningKey( GOOGLE_SIGNING_EC_V2_SIGNING_ONLY_INTERMEDIATE_PUBLIC_KEY_X509_BASE64) .expiration(Instant.now().plus(Duration.standardDays(1)).getMillis()) .build() .create()) .recipientId(RECIPIENT_ID) .build(); PaymentMethodTokenRecipient recipient = new PaymentMethodTokenRecipient.Builder() .protocolVersion(PaymentMethodTokenConstants.PROTOCOL_VERSION_EC_V2_SIGNING_ONLY) .senderVerifyingKeys(GOOGLE_VERIFYING_PUBLIC_KEYS_JSON) .recipientId(RECIPIENT_ID) .build(); String plaintext = "blah"; assertEquals(plaintext, recipient.unseal(sender.seal(plaintext))); }
public String seal(final String message) throws GeneralSecurityException { if (protocolVersion.equals(PaymentMethodTokenConstants.PROTOCOL_VERSION_EC_V1) || protocolVersion.equals(PaymentMethodTokenConstants.PROTOCOL_VERSION_EC_V2) || protocolVersion.equals( PaymentMethodTokenConstants.PROTOCOL_VERSION_EC_V2_SIGNING_ONLY)) { return sealV1OrV2(message); } throw new GeneralSecurityException("Unsupported version: " + protocolVersion); }
PaymentMethodTokenSender { public String seal(final String message) throws GeneralSecurityException { if (protocolVersion.equals(PaymentMethodTokenConstants.PROTOCOL_VERSION_EC_V1) || protocolVersion.equals(PaymentMethodTokenConstants.PROTOCOL_VERSION_EC_V2) || protocolVersion.equals( PaymentMethodTokenConstants.PROTOCOL_VERSION_EC_V2_SIGNING_ONLY)) { return sealV1OrV2(message); } throw new GeneralSecurityException("Unsupported version: " + protocolVersion); } }
PaymentMethodTokenSender { public String seal(final String message) throws GeneralSecurityException { if (protocolVersion.equals(PaymentMethodTokenConstants.PROTOCOL_VERSION_EC_V1) || protocolVersion.equals(PaymentMethodTokenConstants.PROTOCOL_VERSION_EC_V2) || protocolVersion.equals( PaymentMethodTokenConstants.PROTOCOL_VERSION_EC_V2_SIGNING_ONLY)) { return sealV1OrV2(message); } throw new GeneralSecurityException("Unsupported version: " + protocolVersion); } PaymentMethodTokenSender(Builder builder); }
PaymentMethodTokenSender { public String seal(final String message) throws GeneralSecurityException { if (protocolVersion.equals(PaymentMethodTokenConstants.PROTOCOL_VERSION_EC_V1) || protocolVersion.equals(PaymentMethodTokenConstants.PROTOCOL_VERSION_EC_V2) || protocolVersion.equals( PaymentMethodTokenConstants.PROTOCOL_VERSION_EC_V2_SIGNING_ONLY)) { return sealV1OrV2(message); } throw new GeneralSecurityException("Unsupported version: " + protocolVersion); } PaymentMethodTokenSender(Builder builder); String seal(final String message); }
PaymentMethodTokenSender { public String seal(final String message) throws GeneralSecurityException { if (protocolVersion.equals(PaymentMethodTokenConstants.PROTOCOL_VERSION_EC_V1) || protocolVersion.equals(PaymentMethodTokenConstants.PROTOCOL_VERSION_EC_V2) || protocolVersion.equals( PaymentMethodTokenConstants.PROTOCOL_VERSION_EC_V2_SIGNING_ONLY)) { return sealV1OrV2(message); } throw new GeneralSecurityException("Unsupported version: " + protocolVersion); } PaymentMethodTokenSender(Builder builder); String seal(final String message);  }