google-nomulus/java/google/registry/keyring/api/KeyModule.java
mcilwain f0c677b18b Rename DNL and SMDRL "login" to "loginAndPassword"
They are passed around in the format username:password, whereas just saying
"login" implies it's just a username and not necessarily also a secret
password. Putting password in the variable name makes it obvious what this is
and reduces the likelihood of anyone ever logging it or otherwise using it
inappropriately.

Note that this does not require data migrations as the actual key used to store
the data in KMS remains unchanged.

This is a follow-up to []

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=231253964
2019-01-28 16:15:04 -05:00

129 lines
3.7 KiB
Java

// Copyright 2017 The Nomulus Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package google.registry.keyring.api;
import static com.google.common.base.Strings.emptyToNull;
import dagger.Module;
import dagger.Provides;
import java.lang.annotation.Documented;
import java.util.Optional;
import javax.inject.Qualifier;
import org.bouncycastle.openpgp.PGPKeyPair;
import org.bouncycastle.openpgp.PGPPrivateKey;
import org.bouncycastle.openpgp.PGPPublicKey;
/** Dagger module for keys stored in {@link Keyring}. */
@Module
public final class KeyModule {
/** Dagger qualifier for keys from {@link Keyring}. */
@Qualifier
@Documented
public @interface Key {
String value();
}
@Provides
@Key("brdaReceiverKey")
static PGPPublicKey provideBrdaReceiverKey(Keyring keyring) {
return keyring.getBrdaReceiverKey();
}
@Provides
@Key("brdaSigningKey")
static PGPKeyPair provideBrdaSigningKey(Keyring keyring) {
return keyring.getBrdaSigningKey();
}
@Provides
@Key("icannReportingPassword")
static String provideIcannReportingPassword(Keyring keyring) {
return keyring.getIcannReportingPassword();
}
@Provides
@Key("marksdbDnlLoginAndPassword")
static Optional<String> provideMarksdbDnlLoginAndPassword(Keyring keyring) {
return Optional.ofNullable(emptyToNull(keyring.getMarksdbDnlLoginAndPassword()));
}
@Provides
@Key("marksdbLordnPassword")
static Optional<String> provideMarksdbLordnPassword(Keyring keyring) {
return Optional.ofNullable(emptyToNull(keyring.getMarksdbLordnPassword()));
}
@Provides
@Key("marksdbSmdrlLoginAndPassword")
static Optional<String> provideMarksdbSmdrlLoginAndPassword(Keyring keyring) {
return Optional.ofNullable(emptyToNull(keyring.getMarksdbSmdrlLoginAndPassword()));
}
@Provides
@Key("rdeStagingEncryptionKey")
static PGPPublicKey provideRdeStagingEncryptionKey(Keyring keyring) {
return keyring.getRdeStagingEncryptionKey();
}
@Provides
@Key("rdeStagingEncryptionKey")
static byte[] provideRdeStagingEncryptionKeyAsBytes(
@Key("rdeStagingEncryptionKey") PGPPublicKey rdeStagingEncryptionKey) {
return PgpHelper.convertPublicKeyToBytes(rdeStagingEncryptionKey);
}
@Provides
@Key("rdeStagingDecryptionKey")
static PGPPrivateKey provideRdeStagingDecryptionKey(Keyring keyring) {
return keyring.getRdeStagingDecryptionKey();
}
@Provides
@Key("rdeReceiverKey")
static PGPPublicKey provideRdeReceiverKey(Keyring keyring) {
return keyring.getRdeReceiverKey();
}
@Provides
@Key("rdeSigningKey")
static PGPKeyPair provideRdeSigningKey(Keyring keyring) {
return keyring.getRdeSigningKey();
}
@Provides
@Key("rdeSshClientPrivateKey")
static String provideRdeSshClientPrivateKey(Keyring keyring) {
return keyring.getRdeSshClientPrivateKey();
}
@Provides
@Key("rdeSshClientPublicKey")
static String provideRdeSshClientPublicKey(Keyring keyring) {
return keyring.getRdeSshClientPublicKey();
}
@Provides
@Key("safeBrowsingAPIKey")
static String provideSafeBrowsingAPIKey(Keyring keyring) {
return keyring.getSafeBrowsingAPIKey();
}
@Provides
@Key("jsonCredential")
static String provideJsonCredential(Keyring keyring) {
return keyring.getJsonCredential();
}
}