CLOUDSTACK-7085, CLOUDSTACK-7084: disallow empty passwords

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit e5cd75790a)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>

Conflicts:
	api/src/org/apache/cloudstack/api/command/admin/account/CreateAccountCmd.java
	api/src/org/apache/cloudstack/api/command/admin/user/CreateUserCmd.java
This commit is contained in:
Rohit Yadav 2015-02-16 15:31:22 +05:30
parent aa3b615037
commit 30ec59817d
2 changed files with 8 additions and 1 deletions

View File

@ -28,6 +28,7 @@ import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.AccountResponse;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
@ -162,6 +163,9 @@ public class CreateAccountCmd extends BaseCmd {
@Override
public void execute(){
if (StringUtils.isEmpty(getPassword())) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Empty passwords are not allowed");
}
CallContext.current().setEventDetails("Account Name: "+getAccountName()+", Domain Id:"+getDomainId());
UserAccount userAccount = _accountService.createUserAccount(getUsername(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimeZone(), getAccountName(), getAccountType(),
getDomainId(), getNetworkDomain(), getDetails(), getAccountUUID(), getUserUUID());

View File

@ -25,7 +25,7 @@ import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.UserResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import com.cloud.user.Account;
@ -139,6 +139,9 @@ public class CreateUserCmd extends BaseCmd {
@Override
public void execute(){
if (StringUtils.isEmpty(getPassword())) {
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Empty passwords are not allowed");
}
CallContext.current().setEventDetails("UserName: "+getUserName()+", FirstName :"+getFirstName()+", LastName: "+getLastName());
User user = _accountService.createUser(getUserName(), getPassword(), getFirstName(), getLastName(), getEmail(), getTimezone(), getAccountName(), getDomainId(), getUserUUID());
if (user != null) {