Skip to content

Commit 06d1db9

Browse files
committed
Move argument validation of create provider config methods outside CallableOperation.
1 parent 6efa9e7 commit 06d1db9

File tree

2 files changed

+22
-9
lines changed

2 files changed

+22
-9
lines changed

src/main/java/com/google/firebase/auth/AbstractFirebaseAuth.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,8 @@ protected String execute() throws FirebaseAuthException {
946946
* @return An {@link OidcProviderConfig} instance corresponding to the newly created provider
947947
* config.
948948
* @throws NullPointerException if the provided request is null.
949+
* @throws IllegalArgumentException If the provider ID string is null or empty, or is not
950+
* prefixed with 'oidc.'.
949951
* @throws FirebaseAuthException if an error occurs while creating the provider config.
950952
*/
951953
public OidcProviderConfig createOidcProviderConfig(
@@ -961,6 +963,8 @@ public OidcProviderConfig createOidcProviderConfig(
961963
* instance corresponding to the newly created provider config. If an error occurs while
962964
* creating the provider config, the future throws a {@link FirebaseAuthException}.
963965
* @throws NullPointerException if the provided request is null.
966+
* @throws IllegalArgumentException If the provider ID string is null or empty, or is not
967+
* prefixed with 'oidc.'.
964968
*/
965969
public ApiFuture<OidcProviderConfig> createOidcProviderConfigAsync(
966970
@NonNull OidcProviderConfig.CreateRequest request) {
@@ -971,6 +975,7 @@ public ApiFuture<OidcProviderConfig> createOidcProviderConfigAsync(
971975
createOidcProviderConfigOp(final OidcProviderConfig.CreateRequest request) {
972976
checkNotDestroyed();
973977
checkNotNull(request, "Create request must not be null.");
978+
OidcProviderConfig.checkOidcProviderId(request.getProviderId());
974979
final FirebaseUserManager userManager = getUserManager();
975980
return new CallableOperation<OidcProviderConfig, FirebaseAuthException>() {
976981
@Override
@@ -1025,7 +1030,8 @@ protected OidcProviderConfig execute() throws FirebaseAuthException {
10251030
*
10261031
* @param providerId A provider ID string.
10271032
* @return An {@link OidcProviderConfig} instance.
1028-
* @throws IllegalArgumentException If the provider ID string is null or empty.
1033+
* @throws IllegalArgumentException If the provider ID string is null or empty, or is not prefixed
1034+
* with 'oidc'.
10291035
* @throws FirebaseAuthException If an error occurs while retrieving the provider config.
10301036
*/
10311037
public OidcProviderConfig getOidcProviderConfig(@NonNull String providerId)
@@ -1153,7 +1159,8 @@ protected ListProviderConfigsPage<OidcProviderConfig> execute()
11531159
* Deletes the OIDC Auth provider config identified by the specified provider ID.
11541160
*
11551161
* @param providerId A provider ID string.
1156-
* @throws IllegalArgumentException If the provider ID string is null or empty.
1162+
* @throws IllegalArgumentException If the provider ID string is null or empty, or is not prefixed
1163+
* with 'oidc'.
11571164
* @throws FirebaseAuthException If an error occurs while deleting the provider config.
11581165
*/
11591166
public void deleteOidcProviderConfig(@NonNull String providerId) throws FirebaseAuthException {
@@ -1196,6 +1203,8 @@ protected Void execute() throws FirebaseAuthException {
11961203
* @return An {@link SamlProviderConfig} instance corresponding to the newly created provider
11971204
* config.
11981205
* @throws NullPointerException if the provided request is null.
1206+
* @throws IllegalArgumentException If the provider ID string is null or empty, or is not prefixed
1207+
* with 'saml'.
11991208
* @throws FirebaseAuthException if an error occurs while creating the provider config.
12001209
*/
12011210
public SamlProviderConfig createSamlProviderConfig(
@@ -1211,6 +1220,8 @@ public SamlProviderConfig createSamlProviderConfig(
12111220
* instance corresponding to the newly created provider config. If an error occurs while
12121221
* creating the provider config, the future throws a {@link FirebaseAuthException}.
12131222
* @throws NullPointerException if the provided request is null.
1223+
* @throws IllegalArgumentException If the provider ID string is null or empty, or is not prefixed
1224+
* with 'saml'.
12141225
*/
12151226
public ApiFuture<SamlProviderConfig> createSamlProviderConfigAsync(
12161227
@NonNull SamlProviderConfig.CreateRequest request) {
@@ -1221,6 +1232,7 @@ public ApiFuture<SamlProviderConfig> createSamlProviderConfigAsync(
12211232
createSamlProviderConfigOp(final SamlProviderConfig.CreateRequest request) {
12221233
checkNotDestroyed();
12231234
checkNotNull(request, "Create request must not be null.");
1235+
SamlProviderConfig.checkSamlProviderId(request.getProviderId());
12241236
final FirebaseUserManager userManager = getUserManager();
12251237
return new CallableOperation<SamlProviderConfig, FirebaseAuthException>() {
12261238
@Override
@@ -1234,7 +1246,8 @@ protected SamlProviderConfig execute() throws FirebaseAuthException {
12341246
* Deletes the SAML Auth provider config identified by the specified provider ID.
12351247
*
12361248
* @param providerId A provider ID string.
1237-
* @throws IllegalArgumentException If the provider ID string is null or empty.
1249+
* @throws IllegalArgumentException If the provider ID string is null or empty, or is not prefixed
1250+
* with "saml.".
12381251
* @throws FirebaseAuthException If an error occurs while deleting the provider config.
12391252
*/
12401253
public void deleteSamlProviderConfig(@NonNull String providerId) throws FirebaseAuthException {

src/main/java/com/google/firebase/auth/FirebaseUserManager.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ Tenant createTenant(Tenant.CreateRequest request) throws FirebaseAuthException {
252252

253253
Tenant updateTenant(Tenant.UpdateRequest request) throws FirebaseAuthException {
254254
Map<String, Object> properties = request.getProperties();
255+
// TODO(micahstairs): Move this check so that argument validation happens outside the
256+
// CallableOperation.
255257
checkArgument(!properties.isEmpty(), "tenant update must have at least one property set");
256258
GenericUrl url = new GenericUrl(tenantMgtBaseUrl + getTenantUrlSuffix(request.getTenantId()));
257259
url.put("updateMask", generateMask(properties));
@@ -318,24 +320,22 @@ String getEmailActionLink(EmailLinkType type, String email,
318320
OidcProviderConfig createOidcProviderConfig(
319321
OidcProviderConfig.CreateRequest request) throws FirebaseAuthException {
320322
GenericUrl url = new GenericUrl(idpConfigMgtBaseUrl + "/oauthIdpConfigs");
321-
String providerId = request.getProviderId();
322-
checkArgument(!Strings.isNullOrEmpty(providerId), "Provider ID must not be null or empty.");
323-
url.set("oauthIdpConfigId", providerId);
323+
url.set("oauthIdpConfigId", request.getProviderId());
324324
return sendRequest("POST", url, request.getProperties(), OidcProviderConfig.class);
325325
}
326326

327327
SamlProviderConfig createSamlProviderConfig(
328328
SamlProviderConfig.CreateRequest request) throws FirebaseAuthException {
329329
GenericUrl url = new GenericUrl(idpConfigMgtBaseUrl + "/inboundSamlConfigs");
330-
String providerId = request.getProviderId();
331-
checkArgument(!Strings.isNullOrEmpty(providerId), "Provider ID must not be null or empty.");
332-
url.set("inboundSamlConfigId", providerId);
330+
url.set("inboundSamlConfigId", request.getProviderId());
333331
return sendRequest("POST", url, request.getProperties(), SamlProviderConfig.class);
334332
}
335333

336334
OidcProviderConfig updateOidcProviderConfig(OidcProviderConfig.UpdateRequest request)
337335
throws FirebaseAuthException {
338336
Map<String, Object> properties = request.getProperties();
337+
// TODO(micahstairs): Move this check so that argument validation happens outside the
338+
// CallableOperation.
339339
checkArgument(!properties.isEmpty(),
340340
"Provider config update must have at least one property set.");
341341
GenericUrl url =

0 commit comments

Comments
 (0)