14
14
15
15
package google .registry .model .registrar ;
16
16
17
- import static com .google .common .base .Preconditions .checkArgument ;
18
17
import static com .google .common .base .Preconditions .checkNotNull ;
19
- import static com .google .common .base .Strings .isNullOrEmpty ;
20
18
import static com .google .common .collect .ImmutableSet .toImmutableSet ;
21
- import static com .google .common .io .BaseEncoding .base64 ;
22
19
import static google .registry .model .registrar .Registrar .checkValidEmail ;
23
20
import static google .registry .persistence .transaction .TransactionManagerFactory .tm ;
24
21
import static google .registry .util .CollectionUtils .nullToEmptyImmutableSortedCopy ;
25
- import static google .registry .util .PasswordUtils .SALT_SUPPLIER ;
26
- import static google .registry .util .PasswordUtils .hashPassword ;
27
22
import static java .util .stream .Collectors .joining ;
28
23
29
24
import com .google .common .annotations .VisibleForTesting ;
38
33
import google .registry .model .UnsafeSerializable ;
39
34
import google .registry .persistence .VKey ;
40
35
import google .registry .persistence .transaction .QueryComposer ;
41
- import google .registry .util .PasswordUtils ;
42
36
import jakarta .persistence .Column ;
43
37
import jakarta .persistence .Entity ;
44
38
import jakarta .persistence .EnumType ;
47
41
import jakarta .persistence .IdClass ;
48
42
import java .io .Serializable ;
49
43
import java .util .Map ;
50
- import java .util .Optional ;
51
44
import java .util .Set ;
52
- import javax .annotation .Nullable ;
53
45
54
46
/**
55
47
* A contact for a Registrar. Note, equality, hashCode and comparable have been overridden to only
@@ -107,9 +99,6 @@ public boolean isRequired() {
107
99
108
100
@ Id @ Expose public String registrarId ;
109
101
110
- /** External email address of this contact used for registry lock confirmations. */
111
- String registryLockEmailAddress ;
112
-
113
102
/** The voice number of the contact. */
114
103
@ Expose String phoneNumber ;
115
104
@@ -147,22 +136,10 @@ public boolean isRequired() {
147
136
@ Expose
148
137
boolean visibleInDomainWhoisAsAbuse = false ;
149
138
150
- /**
151
- * Whether the contact is allowed to set their registry lock password through the registrar
152
- * console. This will be set to false on contact creation and when the user sets a password.
153
- */
139
+ /** Legacy field, around until we can remove the non-null constraint and the column from SQL. */
154
140
@ Column (nullable = false )
155
141
boolean allowedToSetRegistryLockPassword = false ;
156
142
157
- /**
158
- * A hashed password that exists iff this contact is registry-lock-enabled. The hash is a base64
159
- * encoded SHA256 string.
160
- */
161
- String registryLockPasswordHash ;
162
-
163
- /** Randomly generated hash salt. */
164
- String registryLockPasswordSalt ;
165
-
166
143
/**
167
144
* Helper to update the contacts associated with a Registrar. This requires querying for the
168
145
* existing contacts, deleting existing contacts that are not part of the given {@code contacts}
@@ -197,10 +174,6 @@ public String getEmailAddress() {
197
174
return emailAddress ;
198
175
}
199
176
200
- public Optional <String > getRegistryLockEmailAddress () {
201
- return Optional .ofNullable (registryLockEmailAddress );
202
- }
203
-
204
177
public String getPhoneNumber () {
205
178
return phoneNumber ;
206
179
}
@@ -229,24 +202,6 @@ public Builder asBuilder() {
229
202
return new Builder (clone (this ));
230
203
}
231
204
232
- public boolean isAllowedToSetRegistryLockPassword () {
233
- return allowedToSetRegistryLockPassword ;
234
- }
235
-
236
- public boolean isRegistryLockAllowed () {
237
- return !isNullOrEmpty (registryLockPasswordHash ) && !isNullOrEmpty (registryLockPasswordSalt );
238
- }
239
-
240
- public boolean verifyRegistryLockPassword (String registryLockPassword ) {
241
- if (isNullOrEmpty (registryLockPassword )
242
- || isNullOrEmpty (registryLockPasswordSalt )
243
- || isNullOrEmpty (registryLockPasswordHash )) {
244
- return false ;
245
- }
246
- return PasswordUtils .verifyPassword (
247
- registryLockPassword , registryLockPasswordHash , registryLockPasswordSalt );
248
- }
249
-
250
205
/**
251
206
* Returns a string representation that's human friendly.
252
207
*
@@ -296,15 +251,12 @@ public Map<String, Object> toJsonMap() {
296
251
return new JsonMapBuilder ()
297
252
.put ("name" , name )
298
253
.put ("emailAddress" , emailAddress )
299
- .put ("registryLockEmailAddress" , registryLockEmailAddress )
300
254
.put ("phoneNumber" , phoneNumber )
301
255
.put ("faxNumber" , faxNumber )
302
256
.put ("types" , getTypes ().stream ().map (Object ::toString ).collect (joining ("," )))
303
257
.put ("visibleInWhoisAsAdmin" , visibleInWhoisAsAdmin )
304
258
.put ("visibleInWhoisAsTech" , visibleInWhoisAsTech )
305
259
.put ("visibleInDomainWhoisAsAbuse" , visibleInDomainWhoisAsAbuse )
306
- .put ("allowedToSetRegistryLockPassword" , allowedToSetRegistryLockPassword )
307
- .put ("registryLockAllowed" , isRegistryLockAllowed ())
308
260
.put ("id" , getId ())
309
261
.build ();
310
262
}
@@ -344,14 +296,6 @@ protected Builder(RegistrarPoc instance) {
344
296
public RegistrarPoc build () {
345
297
checkNotNull (getInstance ().registrarId , "Registrar ID cannot be null" );
346
298
checkValidEmail (getInstance ().emailAddress );
347
- // Check allowedToSetRegistryLockPassword here because if we want to allow the user to set
348
- // a registry lock password, we must also set up the correct registry lock email concurrently
349
- // or beforehand.
350
- if (getInstance ().allowedToSetRegistryLockPassword ) {
351
- checkArgument (
352
- !isNullOrEmpty (getInstance ().registryLockEmailAddress ),
353
- "Registry lock email must not be null if allowing registry lock access" );
354
- }
355
299
return cloneEmptyToNull (super .build ());
356
300
}
357
301
@@ -365,11 +309,6 @@ public Builder setEmailAddress(String emailAddress) {
365
309
return this ;
366
310
}
367
311
368
- public Builder setRegistryLockEmailAddress (@ Nullable String registryLockEmailAddress ) {
369
- getInstance ().registryLockEmailAddress = registryLockEmailAddress ;
370
- return this ;
371
- }
372
-
373
312
public Builder setPhoneNumber (String phoneNumber ) {
374
313
getInstance ().phoneNumber = phoneNumber ;
375
314
return this ;
@@ -409,28 +348,6 @@ public Builder setVisibleInDomainWhoisAsAbuse(boolean visible) {
409
348
getInstance ().visibleInDomainWhoisAsAbuse = visible ;
410
349
return this ;
411
350
}
412
-
413
- public Builder setAllowedToSetRegistryLockPassword (boolean allowedToSetRegistryLockPassword ) {
414
- if (allowedToSetRegistryLockPassword ) {
415
- getInstance ().registryLockPasswordSalt = null ;
416
- getInstance ().registryLockPasswordHash = null ;
417
- }
418
- getInstance ().allowedToSetRegistryLockPassword = allowedToSetRegistryLockPassword ;
419
- return this ;
420
- }
421
-
422
- public Builder setRegistryLockPassword (String registryLockPassword ) {
423
- checkArgument (
424
- getInstance ().allowedToSetRegistryLockPassword ,
425
- "Not allowed to set registry lock password for this contact" );
426
- checkArgument (
427
- !isNullOrEmpty (registryLockPassword ), "Registry lock password was null or empty" );
428
- byte [] salt = SALT_SUPPLIER .get ();
429
- getInstance ().registryLockPasswordSalt = base64 ().encode (salt );
430
- getInstance ().registryLockPasswordHash = hashPassword (registryLockPassword , salt );
431
- getInstance ().allowedToSetRegistryLockPassword = false ;
432
- return this ;
433
- }
434
351
}
435
352
436
353
public static ImmutableList <RegistrarPoc > loadForRegistrar (String registrarId ) {
0 commit comments