Skip to content

Commit 36c0a4e

Browse files
author
Prachi Damle
committed
Removed the AccessType.UseNetwork - replaced all referrences by AccessType.UseEntry
1 parent 84a528f commit 36c0a4e

8 files changed

Lines changed: 15 additions & 13 deletions

File tree

api/src/org/apache/cloudstack/acl/SecurityChecker.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public interface SecurityChecker extends Adapter {
3232

3333
public enum AccessType {
3434
ModifyProject,
35-
UseNetwork,
3635
OperateEntry,
3736
UseEntry
3837
}

api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd {
105105
private Long domainId;
106106

107107
//Network information
108-
@ACL(accessType = AccessType.UseNetwork)
108+
@ACL(accessType = AccessType.UseEntry)
109109
@Parameter(name = ApiConstants.NETWORK_IDS, type = CommandType.LIST, collectionType = CommandType.UUID, entityType = NetworkResponse.class, description = "list of network ids used by virtual machine. Can't be specified with ipToNetworkList parameter")
110110
private List<Long> networkIds;
111111

server/src/com/cloud/acl/DomainChecker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public boolean checkAccess(Account caller, ControlledEntity entity, AccessType a
134134
}
135135

136136
return true;
137-
} else if (entity instanceof Network && accessType != null && accessType == AccessType.UseNetwork) {
137+
} else if (entity instanceof Network && accessType != null && accessType == AccessType.UseEntry) {
138138
_networkMgr.checkNetworkPermissions(caller, (Network)entity);
139139
} else if (entity instanceof AffinityGroup) {
140140
return false;

server/src/com/cloud/network/IpAddressManagerImpl.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,8 @@ public IPAddressVO associateIPToGuestNetwork(long ipId, long networkId, boolean
11641164
if (zone.getNetworkType() == NetworkType.Advanced) {
11651165
if (network.getGuestType() == Network.GuestType.Shared) {
11661166
if (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId())) {
1167-
_accountMgr.checkAccess(CallContext.current().getCallingAccount(), AccessType.UseNetwork, false, network);
1167+
_accountMgr.checkAccess(CallContext.current().getCallingAccount(), AccessType.UseEntry, false,
1168+
network);
11681169
} else {
11691170
throw new InvalidParameterValueException("IP can be associated with guest network of 'shared' type only if "
11701171
+ "network services Source Nat, Static Nat, Port Forwarding, Load balancing, firewall are enabled in the network");
@@ -1186,7 +1187,7 @@ public IPAddressVO associateIPToGuestNetwork(long ipId, long networkId, boolean
11861187

11871188
Network network = _networksDao.findById(networkId);
11881189
if (network != null) {
1189-
_accountMgr.checkAccess(owner, AccessType.UseNetwork, false, network);
1190+
_accountMgr.checkAccess(owner, AccessType.UseEntry, false, network);
11901191
} else {
11911192
s_logger.debug("Unable to find ip address by id: " + ipId);
11921193
return null;
@@ -1318,7 +1319,8 @@ public IPAddressVO disassociatePortableIPToGuestNetwork(long ipId, long networkI
13181319
if (zone.getNetworkType() == NetworkType.Advanced) {
13191320
if (network.getGuestType() == Network.GuestType.Shared) {
13201321
assert (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId()));
1321-
_accountMgr.checkAccess(CallContext.current().getCallingAccount(), AccessType.UseNetwork, false, network);
1322+
_accountMgr.checkAccess(CallContext.current().getCallingAccount(), AccessType.UseEntry, false,
1323+
network);
13221324
}
13231325
} else {
13241326
_accountMgr.checkAccess(caller, null, true, ipToAssoc);

server/src/com/cloud/network/NetworkServiceImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ public IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId, Boolea
535535
// if shared network in the advanced zone, then check the caller against the network for 'AccessType.UseNetwork'
536536
if (zone.getNetworkType() == NetworkType.Advanced) {
537537
if (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId())) {
538-
_accountMgr.checkAccess(caller, AccessType.UseNetwork, false, network);
538+
_accountMgr.checkAccess(caller, AccessType.UseEntry, false, network);
539539
if (s_logger.isDebugEnabled()) {
540540
s_logger.debug("Associate IP address called by the user " + callerUserId + " account " + ipOwner.getId());
541541
}
@@ -578,7 +578,7 @@ public IpAddress allocatePortableIP(Account ipOwner, int regionId, Long zoneId,
578578
// if shared network in the advanced zone, then check the caller against the network for 'AccessType.UseNetwork'
579579
if (zone.getNetworkType() == NetworkType.Advanced) {
580580
if (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId())) {
581-
_accountMgr.checkAccess(caller, AccessType.UseNetwork, false, network);
581+
_accountMgr.checkAccess(caller, AccessType.UseEntry, false, network);
582582
if (s_logger.isDebugEnabled()) {
583583
s_logger.debug("Associate IP address called by the user " + callerUserId + " account " + ipOwner.getId());
584584
}

server/src/com/cloud/user/AccountManagerImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
import com.cloud.exception.ResourceUnavailableException;
9292
import com.cloud.network.IpAddress;
9393
import com.cloud.network.IpAddressManager;
94+
import com.cloud.network.Network;
9495
import com.cloud.network.VpnUserVO;
9596
import com.cloud.network.as.AutoScaleManager;
9697
import com.cloud.network.dao.AccountGuestVlanMapDao;
@@ -490,7 +491,7 @@ public void checkAccess(Account caller, AccessType accessType, boolean sameOwner
490491
domainId = account != null ? account.getDomainId() : -1;
491492
}
492493
if (entity.getAccountId() != -1 && domainId != -1 && !(entity instanceof VirtualMachineTemplate) &&
493-
!(accessType != null && accessType == AccessType.UseNetwork) && !(entity instanceof AffinityGroup)) {
494+
!(entity instanceof Network && accessType != null && accessType == AccessType.UseEntry) && !(entity instanceof AffinityGroup)) {
494495
List<ControlledEntity> toBeChecked = domains.get(entity.getDomainId());
495496
// for templates, we don't have to do cross domains check
496497
if (toBeChecked == null) {

server/src/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ public UserVm addNicToVirtualMachine(AddNicToVMCmd cmd) throws InvalidParameterV
987987
}
988988

989989
// Perform account permission check on network
990-
_accountMgr.checkAccess(caller, AccessType.UseNetwork, false, network);
990+
_accountMgr.checkAccess(caller, AccessType.UseEntry, false, network);
991991

992992
//ensure network belongs in zone
993993
if (network.getDataCenterId() != vmInstance.getDataCenterId()) {
@@ -1061,7 +1061,7 @@ public UserVm removeNicFromVirtualMachine(RemoveNicFromVMCmd cmd) throws Invalid
10611061
}
10621062

10631063
// Perform account permission check on network
1064-
_accountMgr.checkAccess(caller, AccessType.UseNetwork, false, network);
1064+
_accountMgr.checkAccess(caller, AccessType.UseEntry, false, network);
10651065

10661066
boolean nicremoved = false;
10671067

@@ -2336,7 +2336,7 @@ public UserVm createAdvancedSecurityGroupVirtualMachine(DataCenter zone, Service
23362336

23372337
// Perform account permission check
23382338
if (network.getAclType() == ACLType.Account) {
2339-
_accountMgr.checkAccess(caller, AccessType.UseNetwork, false, network);
2339+
_accountMgr.checkAccess(caller, AccessType.UseEntry, false, network);
23402340
}
23412341
networkList.add(network);
23422342
}

server/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public ApplicationLoadBalancerRule createApplicationLoadBalancer(String name, St
114114
}
115115

116116
Account caller = CallContext.current().getCallingAccount();
117-
_accountMgr.checkAccess(caller, AccessType.UseNetwork, false, guestNtwk);
117+
_accountMgr.checkAccess(caller, AccessType.UseEntry, false, guestNtwk);
118118

119119
Network sourceIpNtwk = _networkModel.getNetwork(sourceIpNetworkId);
120120
if (sourceIpNtwk == null) {

0 commit comments

Comments
 (0)