org.eclipse.higgins.util.idas.cp.jscript
Class JScriptCPMetadataPDPs

java.lang.Object
  extended byorg.eclipse.higgins.util.idas.cp.jscript.JScriptCPMetadataPDPs
All Implemented Interfaces:
IAttributePDPs

public class JScriptCPMetadataPDPs
extends Object
implements IAttributePDPs

Part of the JSPolicy Higgins Context provider. This implementation allows for javascript policy at critical points.

This module defines the PDP interfaces that are common to most property based Higgins objects.

Author:
dbuss@novell.com

Field Summary
static String consumerIDParamName
          Generic parameter name for for selected PDPs.
static String consumerTypeParamName
          Generic parameter name for for selected PDPs.
static String genericParamName
          Generic name which is used on many of the PDPs to pass a single parameter from java to the script.
static String genericResultName
          Generic name which is used on many of the PDPs to pass the result from JavaScript back to JAVA PDP code.
static String providerIDParamName
          Generic parameter name for for selected PDPs.
static String providerTypeParamName
          Generic parameter name for for selected PDPs.
 
Constructor Summary
JScriptCPMetadataPDPs(org.eclipse.higgins.util.jscript.JScriptExec consumerIDToProviderExec, org.eclipse.higgins.util.jscript.JScriptExec providerIDToConsumerExec, org.eclipse.higgins.util.jscript.JScriptExec consumerTypeToProviderExec, org.eclipse.higgins.util.jscript.JScriptExec providerTypeToConsumerExec, org.eclipse.higgins.util.jscript.JScriptExec consumerValueToProviderExec, org.eclipse.higgins.util.jscript.JScriptExec providerValueToConsumerExec, boolean allowAsymmetricPDP)
          TODO: add logging if mismached configuration
 
Method Summary
 URI consumerIDToProvider(URI consumerID)
          TODO document this one
 Iterator consumerIDToProviders(URI consumerID)
          PDP interface for converting from passed by consumer (presented) ID to what is correct for storage or relaying on to another Context Provider.
 URI consumerTypeToProvider(URI consumerID, URI type)
          PDP interface for converting from passed by consumer (presented) values to what is correct for storage or relaying on to another Context Provider.
 org.eclipse.higgins.idas.api.IAttributeValue consumerValueToProvider(URI consumerID, URI consumerType, URI providerID, URI providerType, org.eclipse.higgins.idas.api.IAttributeValue consumerValue)
          When this PDP is invoked the consumer type, the provider type and the Metadata Value are all stored in an evaluation specific JavaScript scope using the names consumerTypeParamName, providerTypeParamName, genericParamName respectively.
 URI providerIDToConsumer(URI providerID)
          Helper PDP for converting from stored or child Context Provider to consumer presented ID.
 URI providerTypeToConsumer(URI providerID, URI type)
          For JavaScript PDPs this passes the type in the JavaScript var PARAM as a java URI and handles a string or URI back.
 org.eclipse.higgins.idas.api.IAttributeValue providerValueToConsumer(URI providerID, URI providerType, URI consumerID, URI consumerType, org.eclipse.higgins.idas.api.IAttributeValue providerValue)
          When this PDP is invoked the consumer type, the provider type and the Metadata Value are all stored in an evaluation specific JavaScript scope using the names consumerTypeParamName, providerTypeParamName, genericParamName respectively.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

genericParamName

public static final String genericParamName
Generic name which is used on many of the PDPs to pass a single parameter from java to the script.

See Also:
Constant Field Values

genericResultName

public static final String genericResultName
Generic name which is used on many of the PDPs to pass the result from JavaScript back to JAVA PDP code.

See Also:
Constant Field Values

consumerTypeParamName

public static final String consumerTypeParamName
Generic parameter name for for selected PDPs. See specific PDP descriptions for details.

See Also:
Constant Field Values

providerTypeParamName

public static final String providerTypeParamName
Generic parameter name for for selected PDPs. See specific PDP descriptions for details.

See Also:
Constant Field Values

consumerIDParamName

public static final String consumerIDParamName
Generic parameter name for for selected PDPs. See specific PDP descriptions for details.

See Also:
Constant Field Values

providerIDParamName

public static final String providerIDParamName
Generic parameter name for for selected PDPs. See specific PDP descriptions for details.

See Also:
Constant Field Values
Constructor Detail

JScriptCPMetadataPDPs

public JScriptCPMetadataPDPs(org.eclipse.higgins.util.jscript.JScriptExec consumerIDToProviderExec,
                             org.eclipse.higgins.util.jscript.JScriptExec providerIDToConsumerExec,
                             org.eclipse.higgins.util.jscript.JScriptExec consumerTypeToProviderExec,
                             org.eclipse.higgins.util.jscript.JScriptExec providerTypeToConsumerExec,
                             org.eclipse.higgins.util.jscript.JScriptExec consumerValueToProviderExec,
                             org.eclipse.higgins.util.jscript.JScriptExec providerValueToConsumerExec,
                             boolean allowAsymmetricPDP)
TODO: add logging if mismached configuration

Parameters:
consumerIDToProviderExec - consumerIDToProvider(java.net.URI)
providerIDToConsumerExec - providerIDToConsumer(java.net.URI)
consumerTypeToProviderExec - consumerTypeToProvider(java.net.URI, java.net.URI)
providerTypeToConsumerExec - providerTypeToConsumer(java.net.URI, java.net.URI)
consumerValueToProviderExec - consumerValueToProvider(java.net.URI, java.net.URI, java.net.URI, java.net.URI, org.eclipse.higgins.idas.api.IAttributeValue)
providerValueToConsumerExec - providerValueToConsumer(java.net.URI, java.net.URI, java.net.URI, java.net.URI, org.eclipse.higgins.idas.api.IAttributeValue)
Method Detail

providerIDToConsumer

public URI providerIDToConsumer(URI providerID)
                         throws org.eclipse.higgins.idas.api.IdASException
Helper PDP for converting from stored or child Context Provider to consumer presented ID.

Specified by:
providerIDToConsumer in interface IAttributePDPs
Parameters:
providerID - The actual or provider ID of the metadata
Returns:
The consumer or mapped ID of the metadata, returning null indicates that this property should not be returned to the consumer. The providerID may be returned when no PDP has been configured.
Throws:
org.eclipse.higgins.idas.api.IdASException

consumerIDToProviders

public Iterator consumerIDToProviders(URI consumerID)
                               throws org.eclipse.higgins.idas.api.IdASException
PDP interface for converting from passed by consumer (presented) ID to what is correct for storage or relaying on to another Context Provider.

Specified by:
consumerIDToProviders in interface IAttributePDPs
Parameters:
consumerID - the consumer or unmapped ID of the metadata
Returns:
The actual or provider basic type of the metadata value, returning null indicates that this property should not be returned to the consumer.
Throws:
org.eclipse.higgins.idas.api.IdASException

consumerIDToProvider

public URI consumerIDToProvider(URI consumerID)
                         throws org.eclipse.higgins.idas.api.IdASException
TODO document this one

Specified by:
consumerIDToProvider in interface IAttributePDPs
Parameters:
consumerID - the consumer or unmapped ID of the attribute
Returns:
The actual or provider ID of the attribute value, returning null indicates that this property should not be returned to the consumer.
Throws:
org.eclipse.higgins.idas.api.IdASException

consumerTypeToProvider

public URI consumerTypeToProvider(URI consumerID,
                                  URI type)
                           throws org.eclipse.higgins.idas.api.IdASException
Description copied from interface: IAttributePDPs
PDP interface for converting from passed by consumer (presented) values to what is correct for storage or relaying on to another Context Provider.

Specified by:
consumerTypeToProvider in interface IAttributePDPs
Parameters:
consumerID - the consumer's version of the ID of the metadata, passed on to the javascript pdp as consumerIDParamName
type - The consumer data type, passed on to the javascript pdp as consumerTypeParamName
Returns:
A single URI if the policy results in multiple URIs being returned then the first one is selected and returned. When this PDP is invoked the parameters are stored in an evaluation specific JavaScript scope. It is required that either the result of the script or a JavaScript variable with the name genericResultName is the new type.

To avoid problems it is recomended that the reverse mapping also be defined using the id providerTypeToConsumer(java.net.URI, java.net.URI)

A simple nonsensical sample where the provider Entity Type mappings are stored in a globally scoped metadata multimap, and are referenced using JavaScript Associative Arrays.

  
 		<JSPolicyAction id="consumerEntityTypeToProvider" evalType="javascript">
 			RESULT = multimap.consumer[(PARAM.toString())];
 		</JSPolicyAction>
 		<JSPolicyAction id="providerEntityTypeToConsumer" evalType="javascript">
 			RESULT = multimap.provider[String(PARAM.toString())];
 		</JSPolicyAction>
 
Throws:
org.eclipse.higgins.idas.api.IdASException

providerTypeToConsumer

public URI providerTypeToConsumer(URI providerID,
                                  URI type)
                           throws org.eclipse.higgins.idas.api.IdASException
For JavaScript PDPs this passes the type in the JavaScript var PARAM as a java URI and handles a string or URI back.

Specified by:
providerTypeToConsumer in interface IAttributePDPs
Parameters:
providerID -
type - The consumer type
Returns:
A single URI if the policy results in multiple URIs being returned then the first one is selected and returned.
Throws:
org.eclipse.higgins.idas.api.IdASException
See Also:
IPropertyPDP.providerTypeToConsumer(URI type)

consumerValueToProvider

public org.eclipse.higgins.idas.api.IAttributeValue consumerValueToProvider(URI consumerID,
                                                                            URI consumerType,
                                                                            URI providerID,
                                                                            URI providerType,
                                                                            org.eclipse.higgins.idas.api.IAttributeValue consumerValue)
                                                                     throws org.eclipse.higgins.idas.api.IdASException
When this PDP is invoked the consumer type, the provider type and the Metadata Value are all stored in an evaluation specific JavaScript scope using the names consumerTypeParamName, providerTypeParamName, genericParamName respectively. It is consumer that either the result of the script or a JavaScript variable with the name genericResultName is the new value

To avoid problems it is recommended that the reverse mapping also be defined.

Specified by:
consumerValueToProvider in interface IAttributePDPs
Parameters:
consumerType - The consumer or mapped type of the attribute value
providerType - The actual or provider type of the attribute value
consumerValue - The data comprising the consumer view of the value
Returns:
If the PDP creates a new value that will be returned, if no mapping called for then the original value should be returned. A null means this value is not to be presented to the next interface.
Throws:
org.eclipse.higgins.idas.api.IdASException

providerValueToConsumer

public org.eclipse.higgins.idas.api.IAttributeValue providerValueToConsumer(URI providerID,
                                                                            URI providerType,
                                                                            URI consumerID,
                                                                            URI consumerType,
                                                                            org.eclipse.higgins.idas.api.IAttributeValue providerValue)
                                                                     throws org.eclipse.higgins.idas.api.IdASException
When this PDP is invoked the consumer type, the provider type and the Metadata Value are all stored in an evaluation specific JavaScript scope using the names consumerTypeParamName, providerTypeParamName, genericParamName respectively. It is consumer that either the result of the script or a JavaScript variable with the name genericResultName is the new value

To avoid problems it is recommended that the reverse mapping also be defined

Specified by:
providerValueToConsumer in interface IAttributePDPs
Parameters:
providerType - The actual or provider type of the attribute value
consumerType - The consumer or mapped type of the attribute value
providerValue - The data stored or child Context Provider view of the value
Returns:
If the PDP creates a new value that will be returned, if no mapping called for then the original value should be returned. A null means this value is not to be presented to the next interface.
Throws:
org.eclipse.higgins.idas.api.IdASException