001/**
002 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003 *
004 * Copyright (c) 2008 Sun Microsystems Inc. All Rights Reserved
005 *
006 * The contents of this file are subject to the terms
007 * of the Common Development and Distribution License
008 * (the License). You may not use this file except in
009 * compliance with the License.
010 *
011 * You can obtain a copy of the License at
012 * https://opensso.dev.java.net/public/CDDLv1.0.html or
013 * opensso/legal/CDDLv1.0.txt
014 * See the License for the specific language governing
015 * permission and limitations under the License.
016 *
017 * When distributing Covered Code, include this CDDL
018 * Header Notice in each file and include the License file
019 * at opensso/legal/CDDLv1.0.txt.
020 * If applicable, add the following below the CDDL Header,
021 * with the fields enclosed by brackets [] replaced by
022 * your own identifying information:
023 * "Portions Copyrighted [year] [name of copyright owner]"
024 *
025 * $Id: EntitlementCondition.java,v 1.2 2009/09/05 00:24:04 veiming Exp $
026 */
027
028/*
029 * Portions copyright 2010-2014 ForgeRock AS.
030 */
031package com.sun.identity.entitlement;
032
033import javax.security.auth.Subject;
034import java.util.Map;
035import java.util.Set;
036
037/**
038 * Encapsulates a Strategy to decide if a {@link com.sun.identity.entitlement.Privilege} applies to a given request.
039 *
040 * @supported.all.api
041 */
042public interface EntitlementCondition {
043
044    /**
045     * Sets display type.
046     *
047     * @param displayType Display Type.
048     */
049    void setDisplayType(String displayType);
050
051    /**
052     * Returns display type.
053     *
054     * @return Display Type.
055     */
056    String getDisplayType();
057
058    /**
059     * Initializes the condition object.
060     *
061     * @param parameters Parameters for initializing the condition.
062     */
063    void init(Map<String, Set<String>> parameters);
064
065    /**
066     * Sets state of this object from a JSON string.
067     *
068     * @param state State of the object encoded as a JSON string
069     */
070    void setState(String state);
071
072    /**
073     * Returns state of the object encoded as a JSON string.
074     *
075     * @return state of the object encoded as a JSON string.
076     */
077    String getState();
078
079    /**
080     * Checks that this condition is configured correctly. Throws {@link EntitlementException} if not with an
081     * informative message to display to the user creating/updating the policy.
082     *
083     * @throws EntitlementException if the configuration state is not valid.
084     */
085    void validate() throws EntitlementException;
086
087    /**
088     * Returns condition decision.
089     *
090     * @param realm Realm Name.
091     * @param subject Subject who is under evaluation.
092     * @param resourceName Resource name.
093     * @param environment Environment parameters.
094     * @return resulting condition decision.
095     * @throws EntitlementException if cannot get condition decision.
096     */
097    ConditionDecision evaluate(
098        String realm,
099        Subject subject,
100        String resourceName,
101        Map<String, Set<String>> environment)
102        throws EntitlementException;
103}




























































Copyright © 2010-2017, ForgeRock All Rights Reserved.