diff --git a/src/main/java/com/google/firebase/auth/OidcProviderConfig.java b/src/main/java/com/google/firebase/auth/OidcProviderConfig.java index 689298b74..e2587dad2 100644 --- a/src/main/java/com/google/firebase/auth/OidcProviderConfig.java +++ b/src/main/java/com/google/firebase/auth/OidcProviderConfig.java @@ -20,13 +20,8 @@ import com.google.api.client.util.Key; import com.google.common.base.Strings; -import com.google.common.collect.ImmutableMap; import com.google.firebase.auth.ProviderConfig.AbstractCreateRequest; import com.google.firebase.auth.ProviderConfig.AbstractUpdateRequest; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; /** * Contains metadata associated with an OIDC Auth provider. @@ -59,14 +54,6 @@ public UpdateRequest updateRequest() { return new UpdateRequest(getProviderId()); } - private static void assertValidUrl(String url) throws IllegalArgumentException { - try { - new URL(url); - } catch (MalformedURLException e) { - throw new IllegalArgumentException(url + " is a malformed URL", e); - } - } - /** * A specification class for creating a new OIDC Auth provider. * @@ -90,7 +77,7 @@ public CreateRequest() { } * @param clientId a non-null, non-empty client ID string. */ public CreateRequest setClientId(String clientId) { - checkArgument(!Strings.isNullOrEmpty(clientId), "client ID must not be null or empty"); + checkArgument(!Strings.isNullOrEmpty(clientId), "Client ID must not be null or empty."); properties.put("clientId", clientId); return this; } @@ -98,10 +85,10 @@ public CreateRequest setClientId(String clientId) { /** * Sets the issuer for the new provider. * - * @param issuer a non-null, non-empty issuer string. + * @param issuer a non-null, non-empty issuer URL string. */ public CreateRequest setIssuer(String issuer) { - checkArgument(!Strings.isNullOrEmpty(issuer), "issuer must not be null or empty"); + checkArgument(!Strings.isNullOrEmpty(issuer), "Issuer must not be null or empty."); assertValidUrl(issuer); properties.put("issuer", issuer); return this; @@ -130,10 +117,12 @@ public static final class UpdateRequest extends AbstractUpdateRequest properties = new HashMap<>(); AbstractUpdateRequest(String providerId) { - checkArgument(!Strings.isNullOrEmpty(providerId), "provider ID must not be null or empty"); + checkArgument(!Strings.isNullOrEmpty(providerId), "Provider ID must not be null or empty."); this.providerId = providerId; } @@ -128,7 +138,7 @@ String getProviderId() { * @param displayName a non-null, non-empty display name string. */ public T setDisplayName(String displayName) { - checkArgument(!Strings.isNullOrEmpty(displayName), "display name must not be null or empty"); + checkArgument(!Strings.isNullOrEmpty(displayName), "Display name must not be null or empty."); properties.put("displayName", displayName); return getThis(); } diff --git a/src/test/java/com/google/firebase/auth/OidcProviderConfigTest.java b/src/test/java/com/google/firebase/auth/OidcProviderConfigTest.java index 2c62e5746..8079c5deb 100644 --- a/src/test/java/com/google/firebase/auth/OidcProviderConfigTest.java +++ b/src/test/java/com/google/firebase/auth/OidcProviderConfigTest.java @@ -114,6 +114,11 @@ public void testUpdateRequestMissingProviderId() { new OidcProviderConfig.UpdateRequest(null); } + @Test(expected = IllegalArgumentException.class) + public void testUpdateRequestInvalidProviderId() { + new OidcProviderConfig.UpdateRequest("saml.provider-id"); + } + @Test(expected = IllegalArgumentException.class) public void testUpdateRequestMissingClientId() { new OidcProviderConfig.UpdateRequest("oidc.provider-id").setClientId(null);