diff --git a/api/src/com/cloud/api/commands/AddVpnUserCmd.java b/api/src/com/cloud/api/commands/AddVpnUserCmd.java index 4a4be0178ec..10dc11a6e43 100644 --- a/api/src/com/cloud/api/commands/AddVpnUserCmd.java +++ b/api/src/com/cloud/api/commands/AddVpnUserCmd.java @@ -120,7 +120,7 @@ public class AddVpnUserCmd extends BaseAsyncCreateCmd { public void execute(){ VpnUser vpnUser = _entityMgr.findById(VpnUser.class, getEntityId()); Account account = _entityMgr.findById(Account.class, vpnUser.getAccountId()); - if (!_ravService.applyVpnUsers(vpnUser.getAccountId())) { + if (!_ravService.applyVpnUsers(vpnUser.getAccountId(), userName)) { throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add vpn user"); } diff --git a/api/src/com/cloud/api/commands/RemoveVpnUserCmd.java b/api/src/com/cloud/api/commands/RemoveVpnUserCmd.java index 57a4301c8aa..28fe3670c24 100644 --- a/api/src/com/cloud/api/commands/RemoveVpnUserCmd.java +++ b/api/src/com/cloud/api/commands/RemoveVpnUserCmd.java @@ -113,7 +113,7 @@ public class RemoveVpnUserCmd extends BaseAsyncCmd { throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to remove vpn user"); } - if (!_ravService.applyVpnUsers(owner.getId())) { + if (!_ravService.applyVpnUsers(owner.getId(), userName)) { throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to apply vpn user removal"); } SuccessResponse response = new SuccessResponse(getCommandName()); diff --git a/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java b/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java index b1c07a113cf..b2fb34b6831 100644 --- a/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java +++ b/api/src/com/cloud/network/vpn/RemoteAccessVpnService.java @@ -35,7 +35,7 @@ public interface RemoteAccessVpnService { VpnUser addVpnUser(long vpnOwnerId, String userName, String password); boolean removeVpnUser(long vpnOwnerId, String userName); List listVpnUsers(long vpnOwnerId, String userName); - boolean applyVpnUsers(long vpnOwnerId); + boolean applyVpnUsers(long vpnOwnerId, String userName); List searchForRemoteAccessVpns(ListRemoteAccessVpnsCmd cmd); List searchForVpnUsers(ListVpnUsersCmd cmd); diff --git a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java index 1f7fbaace50..c01dc6e91fe 100755 --- a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java +++ b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java @@ -418,7 +418,7 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag @DB @Override - public boolean applyVpnUsers(long vpnOwnerId) { + public boolean applyVpnUsers(long vpnOwnerId, String userName) { Account caller = UserContext.current().getCaller(); Account owner = _accountDao.findById(vpnOwnerId); _accountMgr.checkAccess(caller, null, true, owner); @@ -481,7 +481,7 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag _vpnUsersDao.remove(user.getId()); } } else { - if (user.getState() == State.Add) { + if (user.getState() == State.Add && (user.getUsername()).equals(userName)) { Transaction txn = Transaction.currentTxn(); txn.start(); _vpnUsersDao.remove(user.getId());