FMActionMapper.java revision 4a2f0f0be43dfd4c1b490cbf3cc48b6ba6084b1c
342N/A/**
4196N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
342N/A *
342N/A * Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
342N/A *
342N/A * The contents of this file are subject to the terms
342N/A * of the Common Development and Distribution License
342N/A * (the License). You may not use this file except in
342N/A * compliance with the License.
342N/A *
342N/A * You can obtain a copy of the License at
342N/A * https://opensso.dev.java.net/public/CDDLv1.0.html or
342N/A * opensso/legal/CDDLv1.0.txt
342N/A * See the License for the specific language governing
342N/A * permission and limitations under the License.
342N/A *
342N/A * When distributing Covered Code, include this CDDL
342N/A * Header Notice in each file and include the License file
1472N/A * at opensso/legal/CDDLv1.0.txt.
1472N/A * If applicable, add the following below the CDDL Header,
1472N/A * with the fields enclosed by brackets [] replaced by
342N/A * your own identifying information:
342N/A * "Portions Copyrighted [year] [name of copyright owner]"
342N/A *
1879N/A * $Id: FMActionMapper.java,v 1.3 2008/06/25 05:50:15 qcheng Exp $
1879N/A *
1879N/A */
2037N/A
1879N/Apackage com.sun.identity.xacml.plugins;
1879N/A
342N/Aimport com.sun.identity.shared.xml.XMLUtils;
342N/A
3863N/Aimport com.sun.identity.xacml.common.XACMLConstants;
3863N/A
342N/Aimport com.sun.identity.xacml.context.Action;
1944N/Aimport com.sun.identity.xacml.context.Attribute;
1944N/Aimport com.sun.identity.xacml.common.XACMLException;
1944N/Aimport com.sun.identity.xacml.spi.ActionMapper;
1944N/A
1944N/Aimport java.net.URI;
1944N/A
1944N/Aimport java.util.List;
1944N/Aimport java.util.Map;
1944N/A
3659N/Aimport org.w3c.dom.Element;
1944N/A
1944N/A/**
1944N/A * This class implements ActionMapper to map between XACML context
1944N/A * action and FM native action.
1944N/A * This mapper would recognise only the following XACML
1944N/A * defined <code>attributeId</code>
1944N/A * <pre>
342N/A * urn:oasis:names:tc:xacml:1.0:action:action-id
342N/A * </pre>
342N/A * This attribute would be mapped to an action name in OpenSSO Policy.
549N/A * This mapper requires that the dataType of the attribute is
342N/A * <pre>
342N/A * http://www.w3.org/2001/XMLSchema#string
342N/A * </pre>
342N/A */
342N/Apublic class FMActionMapper implements ActionMapper {
342N/A
342N/A /**
342N/A * Initializes the mapper implementation. This would be called immediately
342N/A * after constructing an instance of the implementation.
342N/A *
342N/A * @param pdpEntityId EntityID of PDP
342N/A * @param pepEntityId EntityID of PEP
342N/A * @param properties configuration properties
342N/A * @exception XACMLException if can not initialize
342N/A */
342N/A public void initialize(String pdpEntityId, String pepEntityId,
342N/A Map properties) throws XACMLException {
342N/A }
342N/A
342N/A /**
342N/A * Returns native action name
342N/A * @param xacmlContextAction XACML context Action
342N/A * @param serviceName native service name the requested resource belongs to
342N/A * @return native action name
342N/A * @exception XACMLException if can not map to native action name
342N/A */
342N/A public String mapToNativeAction(Action xacmlContextAction,
342N/A String serviceName) throws XACMLException {
3110N/A String nativeAction = null;
3110N/A List attributes = xacmlContextAction.getAttributes();
342N/A if (attributes != null && !attributes.isEmpty()) {
342N/A Attribute attr = (Attribute) attributes.get(0);
342N/A if (attr != null) {
342N/A URI tmpURI = attr.getAttributeId();
342N/A if (tmpURI.toString().equals(XACMLConstants.
342N/A ACTION_ID)) {
342N/A tmpURI = attr.getDataType();
342N/A if (tmpURI.toString().equals(XACMLConstants.XS_STRING)) {
342N/A Element element = (Element)attr.getAttributeValues().get(0);
342N/A nativeAction = XMLUtils.getElementValue(element);
342N/A }
342N/A }
342N/A }
342N/A }
342N/A return nativeAction;
342N/A }
342N/A
342N/A /**
342N/A * Returns XACML context Action
342N/A * @param nativeActionName native action name
342N/A * @param serviceName native service name the requested resource belongs to
342N/A * @return XACML context Action
342N/A * @exception XACMLException if can not map to XACML context Action
342N/A */
342N/A public Action mapToXACMLAction(String nativeActionName,
342N/A String serviceName) throws XACMLException {
342N/A return null;
342N/A }
342N/A
342N/A /**
342N/A * Returns XACML context decision effect
342N/A * @param nativeActionEffect native action effect
342N/A * @param serviceName native service name the requested resource belongs to
342N/A * @exception XACMLException if can not map to XACML context Action
342N/A */
342N/A public String mapToXACMLActionEffect(String nativeActionEffect,
342N/A String serviceName) throws XACMLException {
342N/A return null;
342N/A }
342N/A
2596N/A}
342N/A
342N/A