hsato03 commented on code in PR #9195:
URL: https://github.com/apache/cloudstack/pull/9195#discussion_r1644828016
##########
server/src/main/java/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java:
##########
@@ -326,6 +315,46 @@ public Site2SiteVpnConnection
createVpnConnection(CreateVpnConnectionCmd cmd) th
return conn;
}
+ @NotNull
+ private Site2SiteCustomerGateway
getAndValidateSite2SiteCustomerGateway(Long customerGatewayId, String errMsg,
Account caller) {
+ Site2SiteCustomerGateway customerGateway =
_customerGatewayDao.findById(customerGatewayId);
+ if (customerGateway == null) {
+ throw new InvalidParameterValueException(String.format(errMsg,
customerGatewayId));
+ }
+ _accountMgr.checkAccess(caller, null, false, customerGateway);
+ return customerGateway;
+ }
+
+ @NotNull
+ private Site2SiteVpnGateway getAndValidateSite2SiteVpnGateway(Long
vpnGatewayId, String errMsg, Account caller) {
+ Site2SiteVpnGateway vpnGateway = _vpnGatewayDao.findById(vpnGatewayId);
+ if (vpnGateway == null) {
+ throw new InvalidParameterValueException(String.format(errMsg,
vpnGatewayId));
+ }
+ _accountMgr.checkAccess(caller, null, false, vpnGateway);
+ return vpnGateway;
+ }
+
+ private static void
validateVpnConnectionOfTheRightAccount(Site2SiteCustomerGateway
customerGateway, Site2SiteVpnGateway vpnGateway) {
+ if (customerGateway.getAccountId() != vpnGateway.getAccountId() ||
customerGateway.getDomainId() != vpnGateway.getDomainId()) {
+ throw new InvalidParameterValueException("VPN connection can only
be esitablished between same account's VPN gateway and customer gateway!");
Review Comment:
```suggestion
throw new InvalidParameterValueException("VPN connection can
only be established between same account's VPN gateway and customer gateway!");
```
##########
server/src/main/java/com/cloud/network/vpn/Site2SiteVpnManagerImpl.java:
##########
@@ -326,6 +315,46 @@ public Site2SiteVpnConnection
createVpnConnection(CreateVpnConnectionCmd cmd) th
return conn;
}
+ @NotNull
+ private Site2SiteCustomerGateway
getAndValidateSite2SiteCustomerGateway(Long customerGatewayId, String errMsg,
Account caller) {
+ Site2SiteCustomerGateway customerGateway =
_customerGatewayDao.findById(customerGatewayId);
+ if (customerGateway == null) {
+ throw new InvalidParameterValueException(String.format(errMsg,
customerGatewayId));
+ }
+ _accountMgr.checkAccess(caller, null, false, customerGateway);
+ return customerGateway;
+ }
+
+ @NotNull
+ private Site2SiteVpnGateway getAndValidateSite2SiteVpnGateway(Long
vpnGatewayId, String errMsg, Account caller) {
+ Site2SiteVpnGateway vpnGateway = _vpnGatewayDao.findById(vpnGatewayId);
+ if (vpnGateway == null) {
+ throw new InvalidParameterValueException(String.format(errMsg,
vpnGatewayId));
+ }
+ _accountMgr.checkAccess(caller, null, false, vpnGateway);
+ return vpnGateway;
+ }
+
+ private static void
validateVpnConnectionOfTheRightAccount(Site2SiteCustomerGateway
customerGateway, Site2SiteVpnGateway vpnGateway) {
Review Comment:
```suggestion
private void
validateVpnConnectionOfTheRightAccount(Site2SiteCustomerGateway
customerGateway, Site2SiteVpnGateway vpnGateway) {
```
Should this method be static?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]