boolean validateAudience ( List < String > allowedAudiences , List < String > audiences ) { boolean valid = false ; if ( allowedAudiences != null && allowedAudiences . contains ( Constants . ALL_AUDIENCES ) ) { return true ; } if ( allowedAudiences != null && audiences != null ) { for ( String audience : audiences ) { for ( String allowedAud : allowedAudiences ) { if ( allowedAud . equals ( audience ) ) { valid = true ; break ; } } } } else if ( allowedAudiences == null && ( audiences == null || audiences . isEmpty ( ) ) ) { valid = true ; } return valid ; }
Verifies that at least one of the values specified in audiences is contained in the allowedAudiences list .