Skip to content

Commit e5cd757

Browse files
committed
CLOUDSTACK-7085, CLOUDSTACK-7084: disallow empty passwords
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 8ad2e30 commit e5cd757

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

‎api/src/org/apache/cloudstack/api/command/admin/account/CreateAccountCmd.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import org.apache.cloudstack.api.response.AccountResponse;
3232
import org.apache.cloudstack.api.response.DomainResponse;
3333
import org.apache.cloudstack.context.CallContext;
34+
import org.apache.commons.lang.StringUtils;
3435

3536
import com.cloud.user.Account;
3637
import com.cloud.user.UserAccount;
@@ -174,6 +175,9 @@ public long getEntityOwnerId() {
174175

175176
@Override
176177
public void execute() {
178+
if (StringUtils.isEmpty(getPassword())) {
179+
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Empty passwords are not allowed");
180+
}
177181
CallContext.current().setEventDetails("Account Name: " + getAccountName() + ", Domain Id:" + getDomainId());
178182
UserAccount userAccount =
179183
_accountService.createUserAccount(getUsername(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimeZone(), getAccountName(), getAccountType(),

‎api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.cloudstack.api.response.DomainResponse;
2626
import org.apache.cloudstack.api.response.UserResponse;
2727
import org.apache.cloudstack.context.CallContext;
28+
import org.apache.commons.lang.StringUtils;
2829
import org.apache.log4j.Logger;
2930

3031
import com.cloud.user.Account;
@@ -149,6 +150,9 @@ public long getEntityOwnerId() {
149150

150151
@Override
151152
public void execute() {
153+
if (StringUtils.isEmpty(getPassword())) {
154+
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Empty passwords are not allowed");
155+
}
152156
CallContext.current().setEventDetails("UserName: " + getUserName() + ", FirstName :" + getFirstName() + ", LastName: " + getLastName());
153157
User user =
154158
_accountService.createUser(getUserName(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimezone(), getAccountName(), getDomainId(),

0 commit comments

Comments
 (0)