001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyrighted [year] [name of copyright owner]". 013 * 014 * Copyright 2014-2016 ForgeRock AS. All rights reserved. 015 */ 016 017package org.forgerock.openam.sts.tokengeneration.saml2.statements; 018 019import com.iplanet.sso.SSOToken; 020import com.sun.identity.saml2.assertion.Attribute; 021import org.forgerock.openam.sts.TokenCreationException; 022 023import java.util.List; 024import java.util.Map; 025 026/** 027 * Defines the concerns of mapping attributes into SAML2 AttributeStatements. The AttributeStatementsProvider implementation 028 * will return a list of AttributeStatements. Only a single AttributeMapper will be provided to the AttributeStatementsProvider, 029 * and the attributeMap specification will be pulled from the SAML2Config associated with the STS instance currently 030 * consuming the TokenGenerationService. 031 * 032 * @supported.all.api 033 */ 034public interface AttributeMapper { 035 /** 036 * Gets a list of populated SAML2 Attribute instances. 037 * 038 * @param token The SSOToken corresponding to the subject whose attributes will be referenced. 039 * @param attributeMap Contains the mapping of saml attribute names (Map keys) to local OpenAM attributes (Map values) in 040 * various stores. The DefaultAttributeMapper looks at profile attributes in various places: 041 * LDAP or SQL, depending on data store setup, or in Session properties. 042 * The keys will define the name of the attributes included in the Assertion Attribute statements, 043 * and the data pulled from the subject's directory entry or session state 044 * corresponding to the map value will define the value corresponding to this attribute name. 045 * If no state is present corresponding to this attribute value, then it will not appear in the AttributeStatement. 046 * @return This list of populated SAML2 Attribute instances. If the list is empty, no AttributeStatement should be created. 047 * @throws TokenCreationException if an exception is encountered mapping attributes. 048 * exceptions? 049 */ 050 List<Attribute> getAttributes(SSOToken token, Map<String, String> attributeMap) throws TokenCreationException; 051}