Centralize token generation and formats

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=135313726
This commit is contained in:
ctingue 2016-10-05 19:59:00 -07:00 committed by Ben McIlwain
parent 886d6f8e17
commit 79387f5d1e
21 changed files with 131 additions and 39 deletions

View file

@ -18,6 +18,8 @@ import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Strings.isNullOrEmpty;
import static google.registry.model.registry.Registries.findTldForNameOrThrow;
import static google.registry.pricing.PricingEngineProxy.getDomainCreateCost;
import static google.registry.util.TokenUtils.TokenType.ANCHOR_TENANT;
import static google.registry.util.TokenUtils.createToken;
import static org.joda.time.DateTimeZone.UTC;
import com.beust.jcommander.Parameter;
@ -25,6 +27,7 @@ import com.beust.jcommander.Parameters;
import com.google.common.net.InternetDomainName;
import com.google.template.soy.data.SoyMapData;
import google.registry.tools.soy.CreateAnchorTenantSoyInfo;
import google.registry.util.StringGenerator;
import javax.inject.Inject;
import org.joda.money.Money;
import org.joda.time.DateTime;
@ -33,7 +36,6 @@ import org.joda.time.DateTime;
@Parameters(separators = " =", commandDescription = "Provision a domain for an anchor tenant.")
final class CreateAnchorTenantCommand extends MutatingEppToolCommand {
private static final int PASSWORD_LENGTH = 16;
private static final int DEFAULT_ANCHOR_TENANT_PERIOD_YEARS = 2;
@Parameter(
@ -78,7 +80,7 @@ final class CreateAnchorTenantCommand extends MutatingEppToolCommand {
checkArgument(superuser, "This command must be run as a superuser.");
findTldForNameOrThrow(InternetDomainName.from(domainName)); // Check that the tld exists.
if (isNullOrEmpty(password)) {
password = passwordGenerator.createString(PASSWORD_LENGTH);
password = createToken(ANCHOR_TENANT, passwordGenerator);
}
Money cost = null;