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: ResourceAttribute.java,v 1.1 2009/08/19 05:40:33 veiming Exp $
026 *
027 * Portions Copyrighted 2010-2015 ForgeRock AS.
028 */
029
030package com.sun.identity.entitlement;
031
032import java.util.Map;
033import java.util.Set;
034import javax.security.auth.Subject;
035
036/**
037 * Encapsulates a Strategy to derive attributes to be returned with a particular
038 * {@link com.sun.identity.entitlement.Entitlement} when evaluating {@link com.sun.identity.entitlement.Privilege}s.
039 *
040 * For example, these may be statically defined ({@link com.sun.identity.entitlement.StaticAttributes})
041 * or derived from the {@link Subject}'s account details ({@link com.sun.identity.entitlement.UserAttributes}).
042 *
043 * @supported.all.api
044 */
045public interface ResourceAttribute {
046
047    /**
048     * Sets property name.
049     *
050     * @param name property name.
051     */
052    void setPropertyName(String name);
053
054    /**
055     * Returns property name.
056     *
057     * @return name property name.
058     */
059    String getPropertyName();
060
061    /**
062     * Returns property values.
063     *
064     * @return properties for this <code>ResourceAttribute</code>.
065     */
066    Set<String> getPropertyValues();
067
068    /**
069     * Returns resource attributes applicable to the request.
070     *
071     * @param adminSubject Subject who is performing the evaluation.
072     * @param realm Realm name.
073     * @param subject Subject who is under evaluation.
074     * @param resourceName Resource name.
075     * @param environment Environment parameters.
076     * @return applicable resource attributes.
077     * @throws EntitlementException if a condition decision cannot be reached.
078     */
079    Map<String, Set<String>> evaluate(
080        Subject adminSubject,
081        String realm,
082        Subject subject,
083        String resourceName,
084        Map<String, Set<String>> environment)
085        throws EntitlementException;
086
087    /**
088     * Sets OpenAM policy response provider name of the object.
089     *
090     * @param pResponseProviderName response provider name as used in OpenAM policy, this is relevant only
091     *        when StaticAttributes was created from OpenAM policy Subject
092     *
093     * @deprecated
094     */
095    @Deprecated
096    void setPResponseProviderName(String pResponseProviderName);
097
098    /**
099     * Returns OpenAM policy response provider name of the object
100     *
101     * @return response provider name as used in OpenAM policy, this is relevant only when StaticAttributes
102     *         were created from OpenAM policy Subject
103     *
104     * @deprecated
105     */
106    @Deprecated
107    String getPResponseProviderName();
108
109    /**
110     * Returns state of the object encoded as a JSON string.
111     *
112     * @return state of the object encoded as a JSON string.
113     */
114    String getState();
115
116    /**
117     * Sets state of this object from a JSON string.
118     *
119     * @param state State of the object encoded as a JSON string
120     */
121    void setState(String state);
122}