mirror of
https://github.com/google/nomulus.git
synced 2025-07-31 23:16:31 +02:00
Add console-api/settings/security endpoint (#2057)
This commit is contained in:
parent
3ea31d024e
commit
304e7c9726
8 changed files with 396 additions and 3 deletions
|
@ -19,6 +19,10 @@ import static com.google.common.base.Preconditions.checkArgument;
|
|||
import com.google.common.collect.AbstractSequentialIterator;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import com.google.common.net.InetAddresses;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
@ -476,4 +480,20 @@ public class CidrAddressBlock implements Iterable<InetAddress>, Serializable {
|
|||
public String toString() {
|
||||
return getCidrString(ip, netmask);
|
||||
}
|
||||
|
||||
public static class CidrAddressBlockAdapter extends TypeAdapter<CidrAddressBlock> {
|
||||
@Override
|
||||
public CidrAddressBlock read(JsonReader reader) throws IOException {
|
||||
String stringValue = reader.nextString();
|
||||
if (stringValue.equals("null")) {
|
||||
return null;
|
||||
}
|
||||
return new CidrAddressBlock(stringValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(JsonWriter writer, CidrAddressBlock cidrAddressBlock) throws IOException {
|
||||
writer.value(cidrAddressBlock.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ import com.google.gson.GsonBuilder;
|
|||
import dagger.Binds;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
import google.registry.util.CidrAddressBlock.CidrAddressBlockAdapter;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.ProviderException;
|
||||
import java.security.SecureRandom;
|
||||
|
@ -79,6 +80,7 @@ public abstract class UtilsModule {
|
|||
public static Gson provideGson() {
|
||||
return new GsonBuilder()
|
||||
.registerTypeAdapter(DateTime.class, new DateTimeTypeAdapter())
|
||||
.registerTypeAdapter(CidrAddressBlock.class, new CidrAddressBlockAdapter())
|
||||
.excludeFieldsWithoutExposeAnnotation()
|
||||
.create();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue