PolicyIdpAccessEnforcer implements JsonMapper { public List<PdpPolicyDefinition> filterPdpPolicies(List<PdpPolicyDefinition> policies) { FederatedUser user = federatedUser(); if (!user.isPolicyIdpAccessEnforcementRequired()) { return policies; } Set<String> idpsOfUserEntityIds = getEntityIds(user.getIdpEntities()); Set<String> spsOfUserEntityIds = getEntityIds(user.getSpEntities()); return policies.stream().filter(policy -> maySeePolicy(policy, user, idpsOfUserEntityIds, spsOfUserEntityIds)).collect(toList()); }  void actionAllowed(PdpPolicy pdpPolicy, PolicyAccess policyAccess, String serviceProviderId, List<String> identityProviderIds); boolean actionAllowedIndicator(PdpPolicy pdpPolicy, PolicyAccess policyAccess, String serviceProviderId, List<String> identityProviderIds); Iterable<PdpPolicyViolation> filterViolations(Iterable<PdpPolicyViolation> violations); List<PdpPolicyDefinition> filterPdpPolicies(List<PdpPolicyDefinition> policies); List<EntityMetaData> filterIdentityProviders(List<EntityMetaData> identityProviders); static FederatedUser federatedUser(); String username(); String authenticatingAuthority(); String userDisplayName(); boolean isPolicyIdpAccessEnforcementRequired();  }
@Test public void filterPdpPolicies() throws Exception { PdpPolicyDefinition definition = new PdpPolicyDefinition(); definition.setIdentityProviderIds(singletonList("http: definition.setServiceProviderId("http: this.setupSecurityContext(true, emptySet(), entityMetadata("http: List<PdpPolicyDefinition> policies = this.subject.filterPdpPolicies(singletonList(definition)); assertTrue(policies.isEmpty()); }