8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2009 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: AndCondition.java,v 1.3 2010/01/12 21:29:58 veiming Exp $
96a86856ac0b95878e74e5ed8d417572493324ceAndrew Forrest * Portions Copyrighted 2015 ForgeRock AS.
96a86856ac0b95878e74e5ed8d417572493324ceAndrew Forrestimport org.forgerock.openam.utils.CollectionUtils;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>EntitlementCondition</code> wrapper on a set of
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>EntitlementCondition</code>(s) to provide
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * boolean OR logic Membership is of <code>AndCondition</code> is satisfied
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * if the user is a member of any of the wrapped
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>EntitlementCondition</code>.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic class AndCondition extends LogicalCondition {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Constructs <code>AndCondition</code>
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Constructs AndCondition
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param eConditions wrapped <code>EntitlementCondition</code>(s)
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public AndCondition(Set<EntitlementCondition> eConditions) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Returns <code>ConditionDecision</code> of
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>EntitlementCondition</code> evaluation
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param realm Realm name.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param subject EntitlementCondition who is under evaluation.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param resourceName Resource name.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @param environment Environment parameters.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return <code>ConditionDecision</code> of
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * <code>EntitlementCondition</code> evaluation
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @throws EntitlementException if error occurs.
96a86856ac0b95878e74e5ed8d417572493324ceAndrew Forrest public ConditionDecision evaluate(String realm, Subject subject, String resourceName,
96a86856ac0b95878e74e5ed8d417572493324ceAndrew Forrest Map<String, Set<String>> environment) throws EntitlementException {
96a86856ac0b95878e74e5ed8d417572493324ceAndrew Forrest Set<EntitlementCondition> conditions = getEConditions();
f52ca8f9ce43f7765e8c5959e45a667b496526eeAndrew Forrest Map<String, Set<String>> advice = new HashMap<>();
96a86856ac0b95878e74e5ed8d417572493324ceAndrew Forrest Map<String, Set<String>> responseAttributes = new HashMap<>();
96a86856ac0b95878e74e5ed8d417572493324ceAndrew Forrest for (EntitlementCondition condition : conditions) {
96a86856ac0b95878e74e5ed8d417572493324ceAndrew Forrest ConditionDecision decision = condition.evaluate(realm, subject, resourceName, environment);