diff --git a/checkstyle.xml b/checkstyle.xml
index da46b4844..77e2dba54 100644
--- a/checkstyle.xml
+++ b/checkstyle.xml
@@ -229,6 +229,8 @@
+
+
diff --git a/src/main/java/com/google/firebase/auth/SamlProviderConfig.java b/src/main/java/com/google/firebase/auth/SamlProviderConfig.java
index c8970cc6d..e74478bea 100644
--- a/src/main/java/com/google/firebase/auth/SamlProviderConfig.java
+++ b/src/main/java/com/google/firebase/auth/SamlProviderConfig.java
@@ -27,6 +27,7 @@
import com.google.firebase.auth.ProviderConfig.AbstractCreateRequest;
import com.google.firebase.auth.ProviderConfig.AbstractUpdateRequest;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -177,7 +178,23 @@ public CreateRequest addX509Certificate(String x509Certificate) {
return this;
}
- // TODO(micahstairs): Add 'addAllX509Certificates' method.
+ /**
+ * Adds a collection of x509 certificates to the new provider.
+ *
+ * @param x509Certificates A non-null, non-empty collection of x509 certificate strings.
+ * @throws IllegalArgumentException If the collection is null or empty, or if any x509
+ * certificates are null or empty.
+ */
+ public CreateRequest addAllX509Certificates(Collection x509Certificates) {
+ checkArgument(x509Certificates != null,
+ "The collection of x509 certificates must not be null.");
+ checkArgument(!x509Certificates.isEmpty(),
+ "The collection of x509 certificates must not be empty.");
+ for (String certificate : x509Certificates) {
+ addX509Certificate(certificate);
+ }
+ return this;
+ }
/**
* Sets the RP entity ID for the new provider.
@@ -205,8 +222,6 @@ public CreateRequest setCallbackUrl(String callbackUrl) {
return this;
}
- // TODO(micahstairs): Add 'setRequestSigningEnabled' method.
-
CreateRequest getThis() {
return this;
}
@@ -279,7 +294,23 @@ public UpdateRequest addX509Certificate(String x509Certificate) {
return this;
}
- // TODO(micahstairs): Add 'addAllX509Certificates' method.
+ /**
+ * Adds a collection of x509 certificates to the existing provider.
+ *
+ * @param x509Certificates A non-null, non-empty collection of x509 certificate strings.
+ * @throws IllegalArgumentException If the collection is null or empty, or if any x509
+ * certificates are null or empty.
+ */
+ public UpdateRequest addAllX509Certificates(Collection x509Certificates) {
+ checkArgument(x509Certificates != null,
+ "The collection of x509 certificates must not be null.");
+ checkArgument(!x509Certificates.isEmpty(),
+ "The collection of x509 certificates must not be empty.");
+ for (String certificate : x509Certificates) {
+ addX509Certificate(certificate);
+ }
+ return this;
+ }
/**
* Sets the RP entity ID for the existing provider.
@@ -307,8 +338,6 @@ public UpdateRequest setCallbackUrl(String callbackUrl) {
return this;
}
- // TODO(micahstairs): Add 'setRequestSigningEnabled' method.
-
UpdateRequest getThis() {
return this;
}
diff --git a/src/test/java/com/google/firebase/auth/FirebaseUserManagerTest.java b/src/test/java/com/google/firebase/auth/FirebaseUserManagerTest.java
index 9f3a24d48..8c33d5ab8 100644
--- a/src/test/java/com/google/firebase/auth/FirebaseUserManagerTest.java
+++ b/src/test/java/com/google/firebase/auth/FirebaseUserManagerTest.java
@@ -1798,8 +1798,6 @@ public void testTenantAwareDeleteOidcProviderConfig() throws Exception {
public void testCreateSamlProvider() throws Exception {
TestResponseInterceptor interceptor = initializeAppForUserManagement(
TestUtils.loadResource("saml.json"));
- // TODO(micahstairs): Add 'signRequest' to the create request once that field is added to
- // SamlProviderConfig.
SamlProviderConfig.CreateRequest createRequest =
new SamlProviderConfig.CreateRequest()
.setProviderId("saml.provider-id")
@@ -1823,6 +1821,7 @@ public void testCreateSamlProvider() throws Exception {
GenericJson parsed = parseRequestContent(interceptor);
assertEquals("DISPLAY_NAME", parsed.get("displayName"));
assertTrue((boolean) parsed.get("enabled"));
+
Map idpConfig = (Map) parsed.get("idpConfig");
assertNotNull(idpConfig);
assertEquals(3, idpConfig.size());
@@ -1833,6 +1832,7 @@ public void testCreateSamlProvider() throws Exception {
assertEquals(2, idpCertificates.size());
assertEquals(ImmutableMap.of("x509Certificate", "certificate1"), idpCertificates.get(0));
assertEquals(ImmutableMap.of("x509Certificate", "certificate2"), idpCertificates.get(1));
+
Map spConfig = (Map) parsed.get("spConfig");
assertNotNull(spConfig);
assertEquals(2, spConfig.size());
@@ -1938,7 +1938,7 @@ public void testTenantAwareCreateSamlProvider() throws Exception {
TenantAwareFirebaseAuth tenantAwareAuth =
FirebaseAuth.getInstance().getTenantManager().getAuthForTenant("TENANT_ID");
- SamlProviderConfig config = tenantAwareAuth.createSamlProviderConfig(createRequest);
+ tenantAwareAuth.createSamlProviderConfig(createRequest);
checkRequestHeaders(interceptor);
checkUrl(interceptor, "POST", TENANTS_BASE_URL + "/TENANT_ID/inboundSamlConfigs");
@@ -1948,8 +1948,6 @@ public void testTenantAwareCreateSamlProvider() throws Exception {
public void testUpdateSamlProvider() throws Exception {
TestResponseInterceptor interceptor = initializeAppForUserManagement(
TestUtils.loadResource("saml.json"));
- // TODO(micahstairs): Add 'signRequest' to the create request once that field is added to
- // SamlProviderConfig.
SamlProviderConfig.UpdateRequest updateRequest =
new SamlProviderConfig.UpdateRequest("saml.provider-id")
.setDisplayName("DISPLAY_NAME")
diff --git a/src/test/java/com/google/firebase/auth/SamlProviderConfigTest.java b/src/test/java/com/google/firebase/auth/SamlProviderConfigTest.java
index 162c3b63e..135175227 100644
--- a/src/test/java/com/google/firebase/auth/SamlProviderConfigTest.java
+++ b/src/test/java/com/google/firebase/auth/SamlProviderConfigTest.java
@@ -106,6 +106,29 @@ public void testCreateRequest() throws IOException {
assertEquals("https://projectId.firebaseapp.com/__/auth/handler", spConfig.get("callbackUri"));
}
+ @Test
+ public void testCreateRequestX509Certificates() throws IOException {
+ SamlProviderConfig.CreateRequest createRequest =
+ new SamlProviderConfig.CreateRequest()
+ .addX509Certificate("certificate1")
+ .addAllX509Certificates(ImmutableList.of("certificate2", "certificate3"))
+ .addX509Certificate("certificate4");
+
+ Map properties = createRequest.getProperties();
+ assertEquals(1, properties.size());
+ Map idpConfig = (Map) properties.get("idpConfig");
+ assertNotNull(idpConfig);
+ assertEquals(1, idpConfig.size());
+
+ List