Partially fix errors when using DummyKeyringModule

This fixes a few problems encountered when building and running according to the Install Guide using the DummyKeyring. It's still failing when trying to parse the JSON credential, which I haven't solved, but before proceeding I wanted to get agreement that it needs to be fixed at all since the best we could do is provide a valid format (as with the PGP keyrings), but the metrics logging will still fail for a different reason (i.e. the credential will not work for the GC project).

Things fixed in this PR:

Fix format string causing MissingFormatArgumentException in FrontendServlet
when keyring fails to load.
Include exception cause in VerifyException in PgpHelper.
Replace dummy PGP keyrings with ones without a password, as code expects.
Document how the PGP keyrings are created.
P.S. I see a tab character snuck into PgpHelper. I'll fix that if you're interested in this PR.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=188342973
This commit is contained in:
Hans Ridder 2018-03-08 09:30:46 -08:00 committed by jianglai
parent 00bf8a999f
commit c4f1be4baa
4 changed files with 70 additions and 51 deletions

View file

@ -42,6 +42,29 @@ import org.bouncycastle.openpgp.bc.BcPGPSecretKeyRingCollection;
* with all attempted outgoing connections failing because the supplied dummy credentials aren't
* valid. For a real system that needs to connect with external services, you should replace this
* module with one that loads real credentials from secure sources.
*
* <p>The dummy PGP keyrings are created using gnupg1/pgp1 roughly like the following (using
* gnupg2/pgp2 is an exercise left for the developer):
*
* <pre>{@code
* # mkdir gpg
* # chmod 700 gpg
* # gpg1 --homedir gpg --gen-key <<<EOF
* 1
* 1024
* 0
* Y
* Test Registry
* test-registry@example.com
*
* O
* EOF
* [press enter twice at keyring password prompts]
* # gpg1 --homedir gpg -a -o pgp-public-keyring.asc --export test-registry@example.com
* # gpg1 --homedir gpg -a -o pgp-private-keyring.asc --export-secret-keys test-registry@example.com
* # mv pgp*keyring.asc java/google/registry/keyring/api
* # rm -rf gpg
* }</pre>
*/
@Module
@Immutable
@ -56,7 +79,7 @@ public final class DummyKeyringModule {
Resources.asByteSource(getResource(InMemoryKeyring.class, "pgp-private-keyring.asc"));
/** The email address of the aforementioned PGP key. */
private static final String EMAIL_ADDRESS = "domain-registry-users@googlegroups.com";
private static final String EMAIL_ADDRESS = "test-registry@example.com";
/** Always returns a {@link InMemoryKeyring} instance. */
@Provides