KeyInfoBuilder { public static KeyInfo build(String keyId, String signingKey, String uaaUrl) { if (StringUtils.isEmpty(signingKey)) { throw new IllegalArgumentException("Signing key cannot be empty"); } Assert.hasText(signingKey, "[Assertion failed] - this String argument must have text; it must not be null, empty, or blank"); signingKey = signingKey.trim(); if (isAssymetricKey(signingKey)) { return new RsaKeyInfo(keyId, signingKey, uaaUrl); } return new HmacKeyInfo(keyId, signingKey, uaaUrl); }  static KeyInfo build(String keyId, String signingKey, String uaaUrl);  }
@Test public void whenProvidingSecret_ShouldBuildHmacKey() { KeyInfo keyInfo = KeyInfoBuilder.build("key-id", "secret", "https: assertThat(keyInfo.type(), is("MAC")); }
@Test public void whenProvidingSecret_ShouldBuildRsaKey() { KeyInfo keyInfo = KeyInfoBuilder.build("key-id", sampleRsaPrivateKey, "https: assertThat(keyInfo.type(), is("RSA")); }
@Test public void whenProvidingNoSigningKey_shouldError() { expectedException.expect(IllegalArgumentException.class); KeyInfoBuilder.build("key-id", null, "https: }