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 * Portions Copyrighted 2010-2015 ForgeRock AS. 028 */ 029 030package com.sun.identity.entitlement; 031 032import javax.security.auth.Subject; 033import java.util.Map; 034import java.util.Set; 035 036/** 037 * Encapsulates a Strategy to decide if a {@link com.sun.identity.entitlement.Privilege} applies to a given request. 038 * 039 * @supported.all.api 040 */ 041public interface EntitlementCondition { 042 043 /** 044 * Sets display type. 045 * 046 * @param displayType Display Type. 047 */ 048 void setDisplayType(String displayType); 049 050 /** 051 * Returns display type. 052 * 053 * @return Display Type. 054 */ 055 String getDisplayType(); 056 057 /** 058 * Initializes the condition object. 059 * 060 * @param parameters Parameters for initializing the condition. 061 */ 062 void init(Map<String, Set<String>> parameters); 063 064 /** 065 * Sets state of this object from a JSON string. 066 * 067 * @param state State of the object encoded as a JSON string 068 */ 069 void setState(String state); 070 071 /** 072 * Returns state of the object encoded as a JSON string. 073 * 074 * @return state of the object encoded as a JSON string. 075 */ 076 String getState(); 077 078 /** 079 * Checks that this condition is configured correctly. Throws {@link EntitlementException} if not with an 080 * informative message to display to the user creating/updating the policy. 081 * 082 * @throws EntitlementException if the configuration state is not valid. 083 */ 084 void validate() throws EntitlementException; 085 086 /** 087 * Returns condition decision. 088 * 089 * @param realm Realm Name. 090 * @param subject Subject who is under evaluation. 091 * @param resourceName Resource name. 092 * @param environment Environment parameters. 093 * @return resulting condition decision. 094 * @throws EntitlementException if cannot get condition decision. 095 */ 096 ConditionDecision evaluate( 097 String realm, 098 Subject subject, 099 String resourceName, 100 Map<String, Set<String>> environment) 101 throws EntitlementException; 102}