Buggy code:
public Facility updateFacility ( PerunSession sess , Facility facility ) throws FacilityNotExistsException , InternalErrorException , PrivilegeException { } public List < Facility > getOwnerFacilities ( PerunSession sess , Owner owner ) throws InternalErrorException , OwnerNotExistsException , PrivilegeException { } public List < Facility > getAssignedFacilities ( PerunSession sess , Group group ) throws GroupNotExistsException , InternalErrorException , PrivilegeException { } public List < Facility > getAssignedFacilities ( PerunSession sess , Member member ) throws InternalErrorException , MemberNotExistsException , PrivilegeException { } public List < Facility > getAssignedFacilities ( PerunSession sess , User user ) throws InternalErrorException , PrivilegeException , UserNotExistsException { } public List < Facility > getAssignedFacilities ( PerunSession sess , Service service ) throws InternalErrorException , PrivilegeException , ServiceNotExistsException { } public FacilitiesManagerBl getFacilitiesManagerBl ( ) { } public void setPerunBl ( PerunBl perunBl ) { } public List < Host > getHosts ( PerunSession sess , Facility facility ) throws FacilityNotExistsException , InternalErrorException , PrivilegeException { } public int getHostsCount ( PerunSession sess , Facility facility ) throws FacilityNotExistsException , InternalErrorException , PrivilegeException { } public List < Host > addHosts ( PerunSession sess , List < Host > hosts , Facility facility ) throws FacilityNotExistsException , HostExistsException , InternalErrorException , PrivilegeException { } public List < Host > addHosts ( PerunSession sess , Facility facility , List < String > hosts ) throws FacilityNotExistsException , HostExistsException , InternalErrorException , PrivilegeException , WrongPatternException { } public void removeHosts ( PerunSession sess , List < Host > hosts , Facility facility ) throws FacilityNotExistsException , HostAlreadyRemovedException , InternalErrorException , PrivilegeException { } public void addAdmin ( PerunSession sess , Facility facility , User user ) throws AlreadyAdminException , FacilityNotExistsException , InternalErrorException , PrivilegeException , UserNotExistsException { } @ Override public void addAdmin ( PerunSession sess , Facility facility , Group group ) throws AlreadyAdminException , FacilityNotExistsException , GroupNotExistsException , InternalErrorException , PrivilegeException { } public void removeAdmin ( PerunSession sess , Facility facility , User user ) throws FacilityNotExistsException , InternalErrorException , PrivilegeException , UserNotAdminException , UserNotExistsException { } @ Override public void removeAdmin ( PerunSession sess , Facility facility , Group group ) throws FacilityNotExistsException , GroupNotAdminException , GroupNotExistsException , InternalErrorException , PrivilegeException { } public List < User > getAdmins ( PerunSession sess , Facility facility ) throws FacilityNotExistsException , InternalErrorException , PrivilegeException { } @ Override public List < User > getDirectAdmins ( PerunSession sess , Facility facility ) throws FacilityNotExistsException , InternalErrorException , PrivilegeException { } @ Override public List < Group > getAdminGroups ( PerunSession sess , Facility facility ) throws FacilityNotExistsException , InternalErrorException , PrivilegeException { } public List < RichUser > getRichAdmins ( PerunSession sess , Facility facility ) throws FacilityNotExistsException , InternalErrorException , PrivilegeException , UserNotExistsException { } public List < RichUser > getRichAdminsWithAttributes ( PerunSession sess , Facility facility ) throws FacilityNotExistsException , InternalErrorException , PrivilegeException , UserNotExistsException { } public List < RichUser > getRichAdminsWithSpecificAttributes ( PerunSession perunSession , Facility facility , List < String > specificAttributes ) throws FacilityNotExistsException , InternalErrorException , PrivilegeException { } public List < RichUser > getDirectRichAdminsWithSpecificAttributes ( PerunSession perunSession , Facility facility , List < String > specificAttributes ) throws FacilityNotExistsException , InternalErrorException , PrivilegeException { } public List < Facility > getFacilitiesWhereUserIsAdmin ( PerunSession sess , User user ) throws InternalErrorException , PrivilegeException , UserNotExistsException { } public void copyManagers ( PerunSession sess , Facility sourceFacility , Facility destinationFacility ) throws FacilityNotExistsException , InternalErrorException , PrivilegeException { } public void copyAttributes ( PerunSession sess , Facility sourceFacility , Facility destinationFacility ) throws FacilityNotExistsException , InternalErrorException , PrivilegeException , WrongAttributeAssignmentException , WrongAttributeValueException , WrongReferenceAttributeValueException { } public void setFacilitiesManagerBl ( FacilitiesManagerBl facilitiesManagerBl ) { } public PerunBl getPerunBl ( ) { } public Host addHost ( PerunSession sess , Host host , Facility facility ) throws FacilityNotExistsException , InternalErrorException , PrivilegeException { } public void removeHost ( PerunSession sess , Host host ) throws HostAlreadyRemovedException , HostNotExistsException , InternalErrorException , PrivilegeException { } public Host getHostById ( PerunSession sess , int hostId ) throws HostNotExistsException , InternalErrorException , PrivilegeException { } public List < Host > getHostsByHostname ( PerunSession sess , String hostname ) throws InternalErrorException , PrivilegeException { Utils . checkPerunSession ( sess ) ; Utils . notNull ( hostname , "hostname" ) ; if ( ! ( AuthzResolver . isAuthorized ( sess , FACILITYADMIN ) ) ) { throw new PrivilegeException ( sess , "getHostsByHostname" ) ; } List < Host > hostsByHostname = getFacilitiesManagerBl ( ) . getHostsByHostname ( sess , hostname ) ; <START_BUG> if ( AuthzResolver . isAuthorized ( sess , FACILITYADMIN ) ) { <END_BUG> List < Facility > authorizedFacilities = new ArrayList < > ( ) ; List < PerunBean > complementaryObjects = AuthzResolver . getComplementaryObjectsForRole ( sess , FACILITYADMIN ) ; for ( PerunBean pb : complementaryObjects ) { if ( pb instanceof Facility ) authorizedFacilities . add ( ( ( Facility ) ( pb ) ) ) ; } Iterator < Host > hostIterator = hostsByHostname . iterator ( ) ; while ( hostIterator . hasNext ( ) ) { Host host = hostIterator . next ( ) ; Facility fac = getPerunBl ( ) . getFacilitiesManagerBl ( ) . getFacilityForHost ( sess , host ) ; if ( ! ( authorizedFacilities . contains ( fac ) ) ) hostIterator . remove ( ) ; } } return hostsByHostname ; } @ Override public Facility getFacilityForHost ( PerunSession sess , Host host ) throws HostNotExistsException , InternalErrorException , PrivilegeException { } public List < Facility > getFacilitiesByHostName ( PerunSession sess , String hostname ) throws InternalErrorException , PrivilegeException { } public List < User > getAssignedUsers ( PerunSession sess , Facility facility ) throws InternalErrorException , PrivilegeException { } public List < User > getAssignedUsers ( PerunSession sess , Facility facility , Service service ) throws InternalErrorException , PrivilegeException { } }

Fix:
if ( ( ! ( AuthzResolver . hasRole ( sess . getPerunPrincipal ( ) , PERUNADMIN ) ) ) && ( AuthzResolver . hasRole ( sess . getPerunPrincipal ( ) , FACILITYADMIN ) ) ) {