AuthzHelper { public static boolean matchDelegatedTrustPolicy(Policy policy, final String roleName, final String roleMember, List<Role> roles, GroupMembersFetcher groupMembersFetcher) { List<Assertion> assertions = policy.getAssertions(); if (assertions == null) { return false; } for (Assertion assertion : assertions) { if (matchDelegatedTrustAssertion(assertion, roleName, roleMember, roles, groupMembersFetcher)) { return true; } } return false; }  static void removeRoleMembers(List<RoleMember> originalRoleMembers, List<RoleMember> removeRoleMembers); static void removeGroupMembers(List<GroupMember> originalGroupMembers, List<GroupMember> removeGroupMembers); static boolean isMemberDisabled(Integer systemDisabled); static boolean isMemberExpired(Timestamp expiration, long currentTime); static boolean shouldSkipGroupMember(GroupMember member, long currentTime); static boolean isMemberOfGroup(List<GroupMember> groupMembers, final String member); static boolean checkGroupMemberValidity(List<GroupMember> groupMembers, final String member); static boolean memberNameMatch(final String memberName, final  String matchName); static boolean shouldRunDelegatedTrustCheck(final String trust, final String trustDomain); static String retrieveResourceDomain(String resource, String op, String trustDomain); static String extractResourceDomainName(final String resource); static boolean authorityAuthorizationAllowed(Principal principal); static boolean checkRoleMemberValidity(List<RoleMember> roleMembers, final String member,
                                                  GroupMembersFetcher groupMembersFetcher); static boolean isMemberOfRole(Role role, final String member, GroupMembersFetcher groupMembersFetcher); static boolean assumeRoleResourceMatch(String roleName, Assertion assertion); static boolean matchDelegatedTrustPolicy(Policy policy, final String roleName, final String roleMember,
                                                    List<Role> roles, GroupMembersFetcher groupMembersFetcher); static boolean matchDelegatedTrustAssertion(Assertion assertion, final String roleName, final String roleMember,
                                                       List<Role> roles, GroupMembersFetcher groupMembersFetcher);  }
@Test public void testMatchDelegatedTrustPolicyNullAssertions() { Policy policy = new Policy(); assertFalse(AuthzHelper.matchDelegatedTrustPolicy(policy, "testRole", "testMember", null, nullFetcher)); }
@Test public void testMatchDelegatedTrustPolicyMatch() { Assertion assertion = new Assertion(); assertion.setAction("ASSUME_ROLE"); assertion.setEffect(AssertionEffect.ALLOW); assertion.setResource("*:role.Role"); assertion.setRole("weather:role.*"); List<Assertion> assertions = new ArrayList<>(); assertions.add(assertion); Policy policy = new Policy(); policy.setAssertions(assertions); List<Role> roles = new ArrayList<>(); Role role = createRoleObject("weather", "Role1", "user.user1"); roles.add(role); role = createRoleObject("weather", "Role", "user.user2"); roles.add(role); assertTrue(AuthzHelper.matchDelegatedTrustPolicy(policy, "weather:role.Role", "user.user2", roles, devTeamFetcher)); assertFalse(AuthzHelper.matchDelegatedTrustPolicy(policy, "weather:role.Role", "user.unknown", roles, devTeamFetcher)); }