mirror of
https://github.com/google/nomulus.git
synced 2025-05-15 08:57:12 +02:00
Log a warning when MarksDB password isn't configured
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=231287550
This commit is contained in:
parent
44e822ed86
commit
88aa13d1a4
3 changed files with 17 additions and 8 deletions
|
@ -18,6 +18,7 @@ import static com.google.common.base.Verify.verifyNotNull;
|
|||
import static google.registry.util.UrlFetchUtils.setAuthorizationHeader;
|
||||
|
||||
import com.google.appengine.api.urlfetch.HTTPRequest;
|
||||
import com.google.common.flogger.FluentLogger;
|
||||
import google.registry.keyring.api.KeyModule.Key;
|
||||
import google.registry.model.registry.Registry;
|
||||
import java.util.Optional;
|
||||
|
@ -26,8 +27,14 @@ import javax.inject.Inject;
|
|||
/** Helper class for setting the authorization header on a MarksDB LORDN request. */
|
||||
final class LordnRequestInitializer {
|
||||
|
||||
@Inject @Key("marksdbLordnPassword") Optional<String> marksdbLordnPassword;
|
||||
@Inject LordnRequestInitializer() {}
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
|
||||
private final Optional<String> marksdbLordnPassword;
|
||||
|
||||
@Inject
|
||||
LordnRequestInitializer(@Key("marksdbLordnPassword") Optional<String> marksdbLordnPassword) {
|
||||
this.marksdbLordnPassword = marksdbLordnPassword;
|
||||
}
|
||||
|
||||
/** Initializes a URL fetch request for talking to the MarksDB server. */
|
||||
void initialize(HTTPRequest request, String tld) {
|
||||
|
@ -41,6 +48,8 @@ final class LordnRequestInitializer {
|
|||
"lordnUsername is not set for %s.", Registry.get(tld).getTld());
|
||||
return Optional.of(String.format("%s:%s", lordnUsername, marksdbLordnPassword.get()));
|
||||
} else {
|
||||
logger.atWarning().log(
|
||||
"Cannot set credentials for LORDN request because password isn't configured.");
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue