20
20
21
21
import com .google .api .client .util .Key ;
22
22
import com .google .common .base .Strings ;
23
- import com .google .common .collect .ImmutableMap ;
24
23
import com .google .firebase .auth .ProviderConfig .AbstractCreateRequest ;
25
24
import com .google .firebase .auth .ProviderConfig .AbstractUpdateRequest ;
26
- import java .net .MalformedURLException ;
27
- import java .net .URL ;
28
- import java .util .HashMap ;
29
- import java .util .Map ;
30
25
31
26
/**
32
27
* Contains metadata associated with an OIDC Auth provider.
@@ -59,14 +54,6 @@ public UpdateRequest updateRequest() {
59
54
return new UpdateRequest (getProviderId ());
60
55
}
61
56
62
- private static void assertValidUrl (String url ) throws IllegalArgumentException {
63
- try {
64
- new URL (url );
65
- } catch (MalformedURLException e ) {
66
- throw new IllegalArgumentException (url + " is a malformed URL" , e );
67
- }
68
- }
69
-
70
57
/**
71
58
* A specification class for creating a new OIDC Auth provider.
72
59
*
@@ -90,18 +77,18 @@ public CreateRequest() { }
90
77
* @param clientId a non-null, non-empty client ID string.
91
78
*/
92
79
public CreateRequest setClientId (String clientId ) {
93
- checkArgument (!Strings .isNullOrEmpty (clientId ), "client ID must not be null or empty" );
80
+ checkArgument (!Strings .isNullOrEmpty (clientId ), "Client ID must not be null or empty. " );
94
81
properties .put ("clientId" , clientId );
95
82
return this ;
96
83
}
97
84
98
85
/**
99
86
* Sets the issuer for the new provider.
100
87
*
101
- * @param issuer a non-null, non-empty issuer string.
88
+ * @param issuer a non-null, non-empty issuer URL string.
102
89
*/
103
90
public CreateRequest setIssuer (String issuer ) {
104
- checkArgument (!Strings .isNullOrEmpty (issuer ), "issuer must not be null or empty" );
91
+ checkArgument (!Strings .isNullOrEmpty (issuer ), "Issuer must not be null or empty. " );
105
92
assertValidUrl (issuer );
106
93
properties .put ("issuer" , issuer );
107
94
return this ;
@@ -130,10 +117,12 @@ public static final class UpdateRequest extends AbstractUpdateRequest<UpdateRequ
130
117
* information persistently.
131
118
*
132
119
* @param tenantId a non-null, non-empty provider ID string.
133
- * @throws IllegalArgumentException If the provider ID is null or empty.
120
+ * @throws IllegalArgumentException If the provider ID is null or empty, or if it's an invalid
121
+ * format
134
122
*/
135
123
public UpdateRequest (String providerId ) {
136
124
super (providerId );
125
+ checkArgument (providerId .startsWith ("oidc." ), "Invalid OIDC provider ID: " + providerId );
137
126
}
138
127
139
128
/**
@@ -142,18 +131,18 @@ public UpdateRequest(String providerId) {
142
131
* @param clientId a non-null, non-empty client ID string.
143
132
*/
144
133
public UpdateRequest setClientId (String clientId ) {
145
- checkArgument (!Strings .isNullOrEmpty (clientId ), "client ID must not be null or empty" );
134
+ checkArgument (!Strings .isNullOrEmpty (clientId ), "Client ID must not be null or empty. " );
146
135
properties .put ("clientId" , clientId );
147
136
return this ;
148
137
}
149
138
150
139
/**
151
140
* Sets the issuer for the existing provider.
152
141
*
153
- * @param issuer a non-null, non-empty issuer string.
142
+ * @param issuer a non-null, non-empty issuer URL string.
154
143
*/
155
144
public UpdateRequest setIssuer (String issuer ) {
156
- checkArgument (!Strings .isNullOrEmpty (issuer ), "issuer must not be null or empty" );
145
+ checkArgument (!Strings .isNullOrEmpty (issuer ), "Issuer must not be null or empty. " );
157
146
assertValidUrl (issuer );
158
147
properties .put ("issuer" , issuer );
159
148
return this ;
0 commit comments