public static < KeyType , ResType > Map < KeyType , List < ResType > > filterAuthorizedResources ( final HttpServletRequest request , final Map < KeyType , List < ResType > > unfilteredResources , final Function < ? super ResType , Iterable < ResourceAction > > resourceActionGenerator , final AuthorizerMapper authorizerMapper ) { if ( request . getAttribute ( AuthConfig . DRUID_ALLOW_UNSECURED_PATH ) != null ) { return unfilteredResources ; } if ( request . getAttribute ( AuthConfig . DRUID_AUTHORIZATION_CHECKED ) != null ) { throw new ISE ( "Request already had authorization check." ) ; } final AuthenticationResult authenticationResult = AuthorizationUtils . authenticationResultFromRequest ( request ) ; Map < KeyType , List < ResType > > filteredResources = new HashMap <> ( ) ; for ( Map . Entry < KeyType , List < ResType > > entry : unfilteredResources . entrySet ( ) ) { if ( entry . getValue ( ) == null ) { continue ; } final List < ResType > filteredList = Lists . newArrayList ( AuthorizationUtils . filterAuthorizedResources ( authenticationResult , entry . getValue ( ) , resourceActionGenerator , authorizerMapper ) ) ; if ( filteredList . size ( ) > 0 ) { filteredResources . put ( entry . getKey ( ) , filteredList ) ; } } request . setAttribute ( AuthConfig . DRUID_AUTHORIZATION_CHECKED , true ) ; return filteredResources ; }
Given a map of resource lists filter each resources list by applying the resource action generator to each item in each resource list .