Use ExternalId.isValidUsername instead of ExternalId.USER_NAME_PATTERN_REGEX
Since ExternalId.USER_NAME_PATTERN_REGEX is now no longer used by external callers it is made private. Change-Id: Id7a108bf39baffc52273879bbf8973dbbea0ae0c Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
parent
2bf19ee6ee
commit
f1513ada38
@ -116,7 +116,7 @@ public class AccountResolver {
|
||||
}
|
||||
}
|
||||
|
||||
if (nameOrEmail.matches(ExternalId.USER_NAME_PATTERN_REGEX)) {
|
||||
if (ExternalId.isValidUsername(nameOrEmail)) {
|
||||
Optional<AccountState> who = byId.getByUsername(nameOrEmail);
|
||||
if (who.isPresent()) {
|
||||
return ImmutableSet.of(who.map(a -> a.getAccount().getId()).get());
|
||||
|
@ -51,7 +51,7 @@ public abstract class ExternalId implements Serializable {
|
||||
private static final String USER_NAME_PATTERN_LAST_REGEX = "[a-zA-Z0-9]";
|
||||
|
||||
/** Regular expression that a username must match. */
|
||||
public static final String USER_NAME_PATTERN_REGEX =
|
||||
private static final String USER_NAME_PATTERN_REGEX =
|
||||
"^"
|
||||
+ //
|
||||
"("
|
||||
|
@ -91,7 +91,7 @@ public class AccountIdHandler extends OptionHandler<Account.Id> {
|
||||
}
|
||||
|
||||
private Account.Id createAccountByLdap(String user) throws CmdLineException, IOException {
|
||||
if (!user.matches(ExternalId.USER_NAME_PATTERN_REGEX)) {
|
||||
if (!ExternalId.isValidUsername(user)) {
|
||||
throw new CmdLineException(owner, "user \"" + user + "\" not found");
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ public class CreateAccount implements RestModifyView<TopLevelResource, AccountIn
|
||||
throw new BadRequestException("username must match URL");
|
||||
}
|
||||
|
||||
if (!username.matches(ExternalId.USER_NAME_PATTERN_REGEX)) {
|
||||
if (!ExternalId.isValidUsername(username)) {
|
||||
throw new BadRequestException(
|
||||
"Username '" + username + "' must contain only letters, numbers, _, - or .");
|
||||
}
|
||||
|
@ -190,7 +190,7 @@ public class AddMembers implements RestModifyView<GroupResource, Input> {
|
||||
}
|
||||
|
||||
private Optional<Account> createAccountByLdap(String user) throws IOException {
|
||||
if (!user.matches(ExternalId.USER_NAME_PATTERN_REGEX)) {
|
||||
if (!ExternalId.isValidUsername(user)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 2c42f316091726ba34a4f3809cb20197d8a46575
|
||||
Subproject commit 9e65c400d31b2f6e51c9d2a07dd4484011c5a713
|
Loading…
Reference in New Issue
Block a user