@@ -786,13 +786,8 @@ public void checkAccess(Account caller, AccessType accessType, boolean sameOwner
786786 && !(entity instanceof Network && (accessType == AccessType .UseEntry || accessType == AccessType .OperateEntry ))
787787 && !(entity instanceof AffinityGroup ) && !(entity instanceof VirtualRouter )
788788 && !(entity instanceof DnsServer ) && !(entity instanceof DnsZone )) {
789- List <ControlledEntity > toBeChecked = domains .get (entity .getDomainId ());
790789 // for templates, we don't have to do cross domains check
791- if (toBeChecked == null ) {
792- toBeChecked = new ArrayList <>();
793- domains .put (domainId , toBeChecked );
794- }
795- toBeChecked .add (entity );
790+ domains .computeIfAbsent (domainId , k -> new ArrayList <>()).add (entity );
796791 }
797792 boolean granted = false ;
798793 for (SecurityChecker checker : _securityCheckers ) {
@@ -834,7 +829,7 @@ public void checkAccess(Account caller, AccessType accessType, boolean sameOwner
834829
835830 }
836831
837- private static long getDomainIdFor (ControlledEntity entity ) {
832+ private long getDomainIdFor (ControlledEntity entity ) {
838833 long domainId = entity .getDomainId ();
839834 if (entity .getAccountId () != -1 && domainId == -1 ) {
840835 // If account exists domainId should too so calculate it.
@@ -3076,7 +3071,7 @@ public UserAccount authenticateUser(final String username, final String password
30763071
30773072 // Block when is not in the list of allowed IPs
30783073 if (!NetUtils .isIpInCidrList (loginIpAddress , accessAllowedCidrs .split ("," ))) {
3079- logger .warn ("Request by account '{}' was denied since {} does not match {}" , account , loginIpAddress .toString ().replace ("/" , "" ), accessAllowedCidrs );
3074+ logger .warn ("Request by account '{}' was denied since {} does not match {}" , account , loginIpAddress .toString ().replace ("/" , "" ), accessAllowedCidrs );
30803075 throw new CloudAuthenticationException ("Failed to authenticate user '" + username + "' in domain '" + domain .getPath () + "' from ip "
30813076 + loginIpAddress .toString ().replace ("/" , "" ) + "; please provide valid credentials" );
30823077 }
0 commit comments