Update of /cvsroot/sunxacml/sunxacml/com/sun/xacml
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30273/com/sun/xacml
Modified Files:
BasicEvaluationCtx.java ConfigurationStore.java
EvaluationCtx.java PolicyMetaData.java PolicyReference.java
Log Message:
Added support for the XACML 2.0 functions, cleaned up current env handling
and date/time construction, and made most of the factory-related changes
to support the promised 2.0 features
Index: BasicEvaluationCtx.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/BasicEvaluationCtx.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** BasicEvaluationCtx.java 4 Jun 2004 17:50:39 -0000 1.3
--- BasicEvaluationCtx.java 13 Jan 2006 22:32:50 -0000 1.4
***************
*** 3,7 ****
* @(#)BasicEvaluationCtx.java
*
! * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
--- 3,7 ----
* @(#)BasicEvaluationCtx.java
*
! * Copyright 2004-2006 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
***************
*** 58,61 ****
--- 58,62 ----
import java.util.ArrayList;
+ import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
***************
*** 75,78 ****
--- 76,89 ----
* an XACML Request and falls back on an AttributeFinder if a requested
* value isn't available in the Request.
+ * <p>
+ * Note that this class can do some optional caching for current date, time,
+ * and dateTime values (defined by a boolean flag to the constructors). The
+ * XACML specification requires that these values always be available, but it
+ * does not specify whether or not they must remain constant over the course
+ * of an evaluation if the values are being generated by the PDP (if the
+ * values are provided in the Request, then obviously they will remain
+ * constant). The default behavior is for these environment values to be
+ * cached, so that (for example) the current time remains constant over the
+ * course of an evaluation.
*
* @since 1.2
***************
*** 344,358 ****
/**
- * Returns the <code>AttributeFinder</code> used by this context. Note
- * that this is a deprecated method and will be removed in the next
- * major release.
- *
- * @return the <code>AttributeFinder</code>
- */
- public AttributeFinder getAttributeFinder() {
- return finder;
- }
-
- /**
* Returns the DOM root of the original RequestType XML document.
*
--- 355,358 ----
***************
*** 364,376 ****
/**
- * Returns the resource named in the request as resource-id.
- *
- * @return the resource
- */
- public AttributeValue getResourceId() {
- return resourceId;
- }
-
- /**
* Returns the resource scope of the request, which will be one of the
* three fields denoting Immediate, Children, or Descendants.
--- 364,367 ----
***************
*** 383,386 ****
--- 374,386 ----
/**
+ * Returns the resource named in the request as resource-id.
+ *
+ * @return the resource
+ */
+ public AttributeValue getResourceId() {
+ return resourceId;
+ }
+
+ /**
* Changes the value of the resource-id attribute in this context. This
* is useful when you have multiple resources (ie, a scope other than
***************
*** 406,478 ****
/**
! * Returns the cached value for the current time. If The value has never
! * been set by a call to <code>setCurrentTime</code>, or if caching is
! * not enabled in this instance, then this will return null. Note that this
! * only applies to dynamically resolved values, not those supplied in the
! * Request.
*
! * @return the current time or null
*/
! public TimeAttribute getCurrentTime() {
! return currentTime;
! }
- /**
- * Sets the current time for this evaluation. If caching is not enabled
- * for this instance then the value is ignored.
- *
- * @param currentTime the dynamically resolved current time
- */
- public void setCurrentTime(TimeAttribute currentTime) {
if (useCachedEnvValues)
! this.currentTime = currentTime;
}
/**
! * Returns the cached value for the current date. If The value has never
! * been set by a call to <code>setCurrentDate</code>, or if caching is
! * not enabled in this instance, then this will return null. Note that this
! * only applies to dynamically resolved values, not those supplied in the
! * Request.
*
! * @return the current date or null
*/
! public DateAttribute getCurrentDate() {
! return currentDate;
! }
- /**
- * Sets the current date for this evaluation. If caching is not enabled
- * for this instance then the value is ignored.
- *
- * @param currentDate the dynamically resolved current date
- */
- public void setCurrentDate(DateAttribute currentDate) {
if (useCachedEnvValues)
! this.currentDate = currentDate;
}
/**
! * Returns the cached value for the current dateTime. If The value has
! * never been set by a call to <code>setCurrentDateTime</code>, or if
! * caching is not enabled in this instance, then this will return null.
! * Note that this only applies to dynamically resolved values, not those
! * supplied in the Request.
*
! * @return the current date or null
*/
! public DateTimeAttribute getCurrentDateTime() {
! return currentDateTime;
}
/**
! * Sets the current dateTime for this evaluation. If caching is not enabled
! * for this instance then the value is ignored.
! *
! * @param currentDateTime the dynamically resolved current dateTime
*/
! public void setCurrentDateTime(DateTimeAttribute currentDateTime) {
! if (useCachedEnvValues)
! this.currentDateTime = currentDateTime;
}
--- 406,508 ----
/**
! * Returns the value for the current time. The current time, current
! * date, and current dateTime are consistent, so that they all
! * represent the same moment. If this is the first time that one
! * of these three values has been requested, and caching is enabled,
! * then the three values will be resolved and stored.
! * <p>
! * Note that the value supplied here applies only to dynamically
! * resolved values, not those supplied in the Request. In other words,
! * this always returns a dynamically resolved value local to the PDP,
! * even if a different value was supplied in the Request. This is
! * handled correctly when the value is requested by its identifier.
*
! * @return the current time
*/
! public synchronized TimeAttribute getCurrentTime() {
! long millis = dateTimeHelper();
if (useCachedEnvValues)
! return currentTime;
! else
! return new TimeAttribute(new Date(millis));
}
/**
! * Returns the value for the current date. The current time, current
! * date, and current dateTime are consistent, so that they all
! * represent the same moment. If this is the first time that one
! * of these three values has been requested, and caching is enabled,
! * then the three values will be resolved and stored.
! * <p>
! * Note that the value supplied here applies only to dynamically
! * resolved values, not those supplied in the Request. In other words,
! * this always returns a dynamically resolved value local to the PDP,
! * even if a different value was supplied in the Request. This is
! * handled correctly when the value is requested by its identifier.
*
! * @return the current date
*/
! public synchronized DateAttribute getCurrentDate() {
! long millis = dateTimeHelper();
if (useCachedEnvValues)
! return currentDate;
! else
! return new DateAttribute(new Date(millis));
}
/**
! * Returns the value for the current dateTime. The current time, current
! * date, and current dateTime are consistent, so that they all
! * represent the same moment. If this is the first time that one
! * of these three values has been requested, and caching is enabled,
! * then the three values will be resolved and stored.
! * <p>
! * Note that the value supplied here applies only to dynamically
! * resolved values, not those supplied in the Request. In other words,
! * this always returns a dynamically resolved value local to the PDP,
! * even if a different value was supplied in the Request. This is
! * handled correctly when the value is requested by its identifier.
*
! * @return the current dateTime
*/
! public synchronized DateTimeAttribute getCurrentDateTime() {
! long millis = dateTimeHelper();
!
! if (useCachedEnvValues)
! return currentDateTime;
! else
! return new DateTimeAttribute(new Date(millis));
}
/**
! * Private helper that figures out if we need to resolve new values,
! * and returns either the current moment (if we're not caching) or
! * -1 (if we are caching)
*/
! private long dateTimeHelper() {
! // if we already have current values, then we can stop (note this
! // always means that we're caching)
! if (currentTime != null)
! return -1;
!
! // get the current moment
! Date time = new Date();
! long millis = time.getTime();
!
! // if we're not caching then we just return the current moment
! if (! useCachedEnvValues) {
! return millis;
! } else {
! // we're caching, so resolve all three values, making sure
! // to use clean copies of the date object since it may be
! // modified when creating the attributes
! currentTime = new TimeAttribute(time);
! currentDate = new DateAttribute(new Date(millis));
! currentDateTime = new DateTimeAttribute(new Date(millis));
! }
!
! return -1;
}
Index: PolicyMetaData.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/PolicyMetaData.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** PolicyMetaData.java 5 Dec 2005 23:34:51 -0000 1.1
--- PolicyMetaData.java 13 Jan 2006 22:32:50 -0000 1.2
***************
*** 3,7 ****
* @(#)PolicyMetaData.java
*
! * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
--- 3,7 ----
* @(#)PolicyMetaData.java
*
! * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
***************
*** 37,40 ****
--- 37,49 ----
package com.sun.xacml;
+ import com.sun.xacml.attr.AttributeFactory;
+ import com.sun.xacml.attr.AttributeFactoryProxy;
+
+ import com.sun.xacml.combine.CombiningAlgFactory;
+ import com.sun.xacml.combine.CombiningAlgFactoryProxy;
+
+ import com.sun.xacml.cond.FunctionFactory;
+ import com.sun.xacml.cond.FunctionFactoryProxy;
+
/**
***************
*** 115,121 ****
private int xpathVersion;
/**
* Creates a <code>PolicyMetaData</code> instance with the given
! * parameters.
*
* @param xacmlVersion the version of XACML used in a policy
--- 124,143 ----
private int xpathVersion;
+ // the factories used with this policy
+ private AttributeFactoryProxy afProxy;
+ private CombiningAlgFactoryProxy cafProxy;
+ private FunctionFactoryProxy ffProxy;
+
+ /**
+ * Creates a <code>PolicyMetaData</code> instance with all the parameters
+ * set to their default values.
+ */
+ public PolicyMetaData() {
+ this(XACML_DEFAULT_VERSION, XPATH_VERSION_UNSPECIFIED);
+ }
+
/**
* Creates a <code>PolicyMetaData</code> instance with the given
! * parameters. The default factories are assumed.
*
* @param xacmlVersion the version of XACML used in a policy
***************
*** 123,128 ****
--- 145,185 ----
*/
public PolicyMetaData(int xacmlVersion, int xpathVersion) {
+ this(xacmlVersion, xpathVersion, null, null, null);
+ }
+
+ /**
+ * Creates a <code>PolicyMetaData</code> instance with the given
+ * parameters. The default factories are assumed.
+ *
+ * @param xacmlVersion the version of XACML used in a policy
+ * @param xpathVersion the XPath version to use in any selectors, or
+ * null if this is unspecified (ie, not supplied in
+ * the defaults section of the policy)
+ *
+ * @throws IllegalArgumentException if the identifier strings are unknown
+ */
+ public PolicyMetaData(String xacmlVersion, String xpathVersion) {
+ this(xacmlVersion, xpathVersion, null, null, null);
+ }
+
+ /**
+ * Creates a <code>PolicyMetaData</code> instance with the given
+ * parameters. A proxy value of null implies the default factory.
+ *
+ * @param xacmlVersion the version of XACML used in a policy
+ * @param xpathVersion the XPath version to use in any selectors
+ * @param attributeFactoryProxy
+ * @param combiningAlgFactoryProxy
+ * @param functionFactoryProxy
+ */
+ public PolicyMetaData(int xacmlVersion, int xpathVersion,
+ AttributeFactoryProxy attributeFactoryProxy,
+ CombiningAlgFactoryProxy combiningAlgFactoryProxy,
+ FunctionFactoryProxy functionFactoryProxy) {
this.xacmlVersion = xacmlVersion;
this.xpathVersion = xpathVersion;
+
+ proxySetup(attributeFactoryProxy, combiningAlgFactoryProxy,
+ functionFactoryProxy);
}
***************
*** 135,142 ****
* null if this is unspecified (ie, not supplied in
* the defaults section of the policy)
*
* @throws IllegalArgumentException if the identifier strings are unknown
*/
! public PolicyMetaData(String xacmlVersion, String xpathVersion) {
if (xacmlVersion == null)
this.xacmlVersion = XACML_DEFAULT_VERSION;
--- 192,203 ----
* null if this is unspecified (ie, not supplied in
* the defaults section of the policy)
+ * @param
*
* @throws IllegalArgumentException if the identifier strings are unknown
*/
! public PolicyMetaData(String xacmlVersion, String xpathVersion,
! AttributeFactoryProxy attributeFactoryProxy,
! CombiningAlgFactoryProxy combiningAlgFactoryProxy,
! FunctionFactoryProxy functionFactoryProxy) {
if (xacmlVersion == null)
this.xacmlVersion = XACML_DEFAULT_VERSION;
***************
*** 158,161 ****
--- 219,255 ----
this.xpathVersion = XPATH_VERSION_UNSPECIFIED;
}
+
+ proxySetup(attributeFactoryProxy, combiningAlgFactoryProxy,
+ functionFactoryProxy);
+ }
+
+ /**
+ *
+ */
+ private void proxySetup(AttributeFactoryProxy attributeFactoryProxy,
+ CombiningAlgFactoryProxy combiningAlgFactoryProxy,
+ FunctionFactoryProxy functionFactoryProxy) {
+ if (attributeFactoryProxy == null)
+ this.afProxy = new AttributeFactoryProxy() {
+ public AttributeFactory getFactory() {
+ return AttributeFactory.getInstance();
+ }
+ };
+ else
+ this.afProxy = attributeFactoryProxy;
+
+ if (combiningAlgFactoryProxy == null)
+ this.cafProxy = new CombiningAlgFactoryProxy() {
+ public CombiningAlgFactory getFactory() {
+ return CombiningAlgFactory.getInstance();
+ }
+ };
+ else
+ this.cafProxy = combiningAlgFactoryProxy;
+
+ if (functionFactoryProxy == null)
+ this.ffProxy = FunctionFactory.getInstance();
+ else
+ this.ffProxy = functionFactoryProxy;
}
***************
*** 197,199 ****
--- 291,343 ----
}
+ /**
+ * Returns the <code>AttributeFactory</code> used by the associated
+ * policy.
+ *
+ * @return a <code>AttributeFactory</code>
+ */
+ public AttributeFactory getAttributeFactory() {
+ return afProxy.getFactory();
+ }
+
+ /**
+ * Returns the <code>CombiningAlgFactory</code> used by the associated
+ * policy.
+ *
+ * @return a <code>CombiningAlgFactory</code>
+ */
+ public CombiningAlgFactory getCombiningAlgFactory() {
+ return cafProxy.getFactory();
+ }
+
+ /**
+ * Returns the Target <code>FunctionFactory</code> used by the associated
+ * policy.
+ *
+ * @return a <code>FunctionFactory</code>
+ */
+ public FunctionFactory getTargetFunctionFactory() {
+ return ffProxy.getTargetFactory();
+ }
+
+ /**
+ * Returns the Condition <code>FunctionFactory</code> used by the
+ * associated policy.
+ *
+ * @return a <code>FunctionFactory</code>
+ */
+ public FunctionFactory getConditionFunctionFactory() {
+ return ffProxy.getConditionFactory();
+ }
+
+ /**
+ * Returns the General <code>FunctionFactory</code> used by the associated
+ * policy.
+ *
+ * @return a <code>FunctionFactory</code>
+ */
+ public FunctionFactory getGeneralFunctionFactory() {
+ return ffProxy.getGeneralFactory();
+ }
+
}
Index: EvaluationCtx.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/EvaluationCtx.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** EvaluationCtx.java 13 Jun 2004 23:20:17 -0000 1.9
--- EvaluationCtx.java 13 Jan 2006 22:32:50 -0000 1.10
***************
*** 3,7 ****
* @(#)EvaluationCtx.java
*
! * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
--- 3,7 ----
* @(#)EvaluationCtx.java
*
! * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
***************
*** 54,68 ****
* Manages the context of a single policy evaluation. Typically, an instance
* is instantiated whenever the PDP gets a request and needs to perform an
! * evaluation as a result.
! * <p>
! * Note that this class does some optional caching for current date, time,
! * and dateTime values (defined by a boolean flag to the constructors). The
! * XACML specification requires that these values always be available, but it
! * does not specify whether or not they must remain constant over the course
! * of an evaluation if the values are being generated by the PDP (if the
! * values are provided in the Request, then obviously they will remain
! * constant). The default behavior is for these environment values to be
! * cached, so that (for example) the current time remains constant over the
! * course of an evaluation.
*
* @since 1.0
--- 54,59 ----
* Manages the context of a single policy evaluation. Typically, an instance
* is instantiated whenever the PDP gets a request and needs to perform an
! * evaluation as a result. The <code>BasicEvaluationCtx</code> class
! * provides a basic implementation that is used by default.
*
* @since 1.0
***************
*** 102,116 ****
/**
- * Returns the <code>AttributeFinder</code> used by this context.
- *
- * @deprecated As of version 1.2, this method should not be used, as it
- * provides access to a mutable interface. This method will
- * be removed in the next major release.
- *
- * @return the <code>AttributeFinder</code>
- */
- public AttributeFinder getAttributeFinder();
-
- /**
* Returns the DOM root of the original RequestType XML document, if
* this context is backed by an XACML Request. If this context is not
--- 93,96 ----
***************
*** 125,135 ****
/**
- * Returns the identifier for the resource being requested.
- *
- * @return the resource
- */
- public AttributeValue getResourceId();
-
- /**
* Returns the resource scope, which will be one of the three fields
* denoting Immediate, Children, or Descendants.
--- 105,108 ----
***************
*** 140,143 ****
--- 113,123 ----
/**
+ * Returns the identifier for the resource being requested.
+ *
+ * @return the resource
+ */
+ public AttributeValue getResourceId();
+
+ /**
* Changes the value of the resource-id attribute in this context. This
* is useful when you have multiple resources (ie, a scope other than
***************
*** 150,204 ****
/**
! * Returns the cached value for the current time. If the value has never
! * been set by a call to <code>setCurrentTime</code>, or if caching is
! * not enabled in this instance, then this will return null.
*
! * @return the current time or null
*/
public TimeAttribute getCurrentTime();
/**
! * Sets the current time for this evaluation. If caching is not enabled
! * for this instance then the value is ignored.
! *
! * @param currentTime the dynamically resolved current time
! */
! public void setCurrentTime(TimeAttribute currentTime);
!
! /**
! * Returns the cached value for the current date. If the value has never
! * been set by a call to <code>setCurrentDate</code>, or if caching is
! * not enabled in this instance, then this will return null.
*
! * @return the current date or null
*/
public DateAttribute getCurrentDate();
/**
! * Sets the current date for this evaluation. If caching is not enabled
! * for this instance then the value is ignored.
! *
! * @param currentDate the dynamically resolved current date
! */
! public void setCurrentDate(DateAttribute currentDate);
!
! /**
! * Returns the cached value for the current dateTime. If the value has
! * never been set by a call to <code>setCurrentDateTime</code>, or if
! * caching is not enabled in this instance, then this will return null.
*
! * @return the current date or null
*/
public DateTimeAttribute getCurrentDateTime();
/**
- * Sets the current dateTime for this evaluation. If caching is not enabled
- * for this instance then the value is ignored.
- *
- * @param currentDateTime the dynamically resolved current dateTime
- */
- public void setCurrentDateTime(DateTimeAttribute currentDateTime);
-
- /**
* Returns available subject attribute value(s) ignoring the issuer.
*
--- 130,163 ----
/**
! * Returns the value for the current time as known by the PDP (if this
! * value was also supplied in the Request, this will generally be a
! * different value). Details of caching or location-based resolution
! * are left to the underlying implementation.
*
! * @return the current time
*/
public TimeAttribute getCurrentTime();
/**
! * Returns the value for the current date as known by the PDP (if this
! * value was also supplied in the Request, this will generally be a
! * different value). Details of caching or location-based resolution
! * are left to the underlying implementation.
*
! * @return the current date
*/
public DateAttribute getCurrentDate();
/**
! * Returns the value for the current dateTime as known by the PDP (if this
! * value was also supplied in the Request, this will generally be a
! * different value). Details of caching or location-based resolution
! * are left to the underlying implementation.
*
! * @return the current date
*/
public DateTimeAttribute getCurrentDateTime();
/**
* Returns available subject attribute value(s) ignoring the issuer.
*
***************
*** 258,261 ****
--- 217,224 ----
/**
* Returns available environment attribute value(s).
+ * <p>
+ * Note that if you want to resolve the correct current date, time, or
+ * dateTime as seen from an evaluation point of view, you should use
+ * this method and supply the corresponding identifier.
*
* @param type the type of the attribute value(s) to find
Index: ConfigurationStore.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/ConfigurationStore.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** ConfigurationStore.java 17 Feb 2005 16:01:25 -0000 1.10
--- ConfigurationStore.java 13 Jan 2006 22:32:50 -0000 1.11
***************
*** 3,7 ****
* @(#)ConfigurationStore.java
*
! * Copyright 2004-2005 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
--- 3,7 ----
* @(#)ConfigurationStore.java
*
! * Copyright 2004-2006 Sun Microsystems, Inc. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
***************
*** 105,109 ****
* This way, the programmer still has full control over their security model,
* but also has the convenience of re-using a common configuration
! * mechanism. See http://sunxacml.sourceforge.net/schema/config-0.3.xsd for
* the valid schema.
* <p>
--- 105,109 ----
* This way, the programmer still has full control over their security model,
* but also has the convenience of re-using a common configuration
! * mechanism. See http://sunxacml.sourceforge.net/schema/config-0.4.xsd for
* the valid schema.
* <p>
***************
*** 112,119 ****
* is simply provided as a convenience, and so that all programmers can start
* from a common point.
- * <p>
- * NOTE: The name of this class, its interfaces, and they way it interacts
- * with the rest of the code is currently unstable, so expect some changes
- * between now and the next release.
*
* @since 1.2
--- 112,115 ----
***************
*** 229,238 ****
NamedNodeMap attrs = root.getAttributes();
String defaultPDP = attrs.getNamedItem("defaultPDP").getNodeValue();
! String defaultAF = attrs.getNamedItem("defaultAttributeFactory").
! getNodeValue();
! String defaultCAF = attrs.getNamedItem("defaultCombiningAlgFactory").
! getNodeValue();
! String defaultFF = attrs.getNamedItem("defaultFunctionFactory").
! getNodeValue();
// loop through all the root-level elements, for each one getting its
--- 225,232 ----
NamedNodeMap attrs = root.getAttributes();
String defaultPDP = attrs.getNamedItem("defaultPDP").getNodeValue();
! String defaultAF = getDefaultFactory(attrs, "defaultAttributeFactory");
! String defaultCAF = getDefaultFactory(attrs,
! "defaultCombiningAlgFactory");
! String defaultFF = getDefaultFactory(attrs, "defaultFunctionFactory");
// loop through all the root-level elements, for each one getting its
***************
*** 289,298 ****
--- 283,331 ----
// finally, extract the default elements
defaultPDPConfig = (PDPConfig)(pdpConfigMap.get(defaultPDP));
+
defaultAttributeFactory = (AttributeFactory)
(attributeMap.get(defaultAF));
+ if (defaultAttributeFactory == null) {
+ try {
+ defaultAttributeFactory =
+ AttributeFactory.getInstance(defaultAF);
+ } catch (Exception e) {
+ throw new ParsingException("Unknown AttributeFactory", e);
+ }
+ }
+
defaultCombiningFactory = (CombiningAlgFactory)
(combiningMap.get(defaultCAF));
+ if (defaultCombiningFactory == null) {
+ try {
+ defaultCombiningFactory =
+ CombiningAlgFactory.getInstance(defaultCAF);
+ } catch (Exception e) {
+ throw new ParsingException("Unknown CombininAlgFactory", e);
+ }
+ }
+
defaultFunctionFactoryProxy = (FunctionFactoryProxy)
(functionMap.get(defaultFF));
+ if (defaultFunctionFactoryProxy == null) {
+ try {
+ defaultFunctionFactoryProxy =
+ FunctionFactory.getInstance(defaultFF);
+ } catch (Exception e) {
+ throw new ParsingException("Unknown FunctionFactory", e);
+ }
+ }
+ }
+
+ /**
+ * Private helper that gets a default factory identifier, or fills in
+ * the default value if no identifier is provided.
+ */
+ private String getDefaultFactory(NamedNodeMap attrs, String factoryName) {
+ Node node = attrs.getNamedItem(factoryName);
+ if (node != null)
+ return node.getNodeValue();
+ else
+ return PolicyMetaData.XACML_1_0_IDENTIFIER;
}
***************
*** 385,391 ****
logger.config("Starting with standard Datatypes");
! StandardAttributeFactory sf =
! StandardAttributeFactory.getFactory();
! factory = new BaseAttributeFactory(sf.getStandardDatatypes());
} else {
factory = new BaseAttributeFactory();
--- 418,422 ----
logger.config("Starting with standard Datatypes");
! factory = StandardAttributeFactory.getNewFactory();
} else {
factory = new BaseAttributeFactory();
***************
*** 429,435 ****
logger.config("Starting with standard Combining Algorithms");
! StandardCombiningAlgFactory sf =
! StandardCombiningAlgFactory.getFactory();
! factory = new BaseCombiningAlgFactory(sf.getStandardAlgorithms());
} else {
factory = new BaseCombiningAlgFactory();
--- 460,464 ----
logger.config("Starting with standard Combining Algorithms");
! factory = StandardCombiningAlgFactory.getNewFactory();
} else {
factory = new BaseCombiningAlgFactory();
***************
*** 771,787 ****
/**
! * Returns the default attribute factory. If no default was specified
! * then this throws an exception.
*
* @return the default attribute factory
- *
- * @throws UnknownIdentifierException if there is no default factory
*/
! public AttributeFactory getDefaultAttributeFactory()
! throws UnknownIdentifierException
! {
! if (defaultAttributeFactory == null)
! throw new UnknownIdentifierException("no default available");
!
return defaultAttributeFactory;
}
--- 800,808 ----
/**
! * Returns the default attribute factory.
*
* @return the default attribute factory
*/
! public AttributeFactory getDefaultAttributeFactory() {
return defaultAttributeFactory;
}
***************
*** 817,833 ****
/**
! * Returns the default combiningAlg factory. If no default was specified
! * then this throws an exception.
*
* @return the default combiningAlg factory
- *
- * @throws UnknownIdentifierException if there is no default factory
*/
! public CombiningAlgFactory getDefaultCombiningAlgFactory()
! throws UnknownIdentifierException
! {
! if (defaultCombiningFactory == null)
! throw new UnknownIdentifierException("no default available");
!
return defaultCombiningFactory;
}
--- 838,869 ----
/**
! * Registers all the supported factories with the given identifiers. If
! * a given identifier is already in use, then that factory is not
! * registered. This method is provided only as a convenience, and
! * any registration that may involve identifier clashes should be done
! * by registering each factory individually.
! */
! public void registerAttributeFactories() {
! Iterator it = attributeMap.keySet().iterator();
!
! while (it.hasNext()) {
! String id = (String)(it.next());
! AttributeFactory af = (AttributeFactory)(attributeMap.get(id));
!
! try {
! AttributeFactory.registerFactory(id, new AFProxy(af));
! } catch (IllegalArgumentException iae) {
! logger.log(Level.WARNING, "Couldn't register AttributeFactory:"
! + id + " (already in use)", iae);
! }
! }
! }
!
! /**
! * Returns the default combiningAlg factory.
*
* @return the default combiningAlg factory
*/
! public CombiningAlgFactory getDefaultCombiningAlgFactory() {
return defaultCombiningFactory;
}
***************
*** 863,879 ****
/**
! * Returns the default function factory proxy. If no default was specified
! * then this throws an exception.
*
* @return the default function factory proxy
- *
- * @throws UnknownIdentifierException if there is no default factory
*/
! public FunctionFactoryProxy getDefaultFunctionFactoryProxy()
! throws UnknownIdentifierException
! {
! if (defaultFunctionFactoryProxy == null)
! throw new UnknownIdentifierException("no default available");
!
return defaultFunctionFactoryProxy;
}
--- 899,932 ----
/**
! * Registers all the supported factories with the given identifiers. If
! * a given identifier is already in use, then that factory is not
! * registered. This method is provided only as a convenience, and
! * any registration that may involve identifier clashes should be done
! * by registering each factory individually.
! */
! public void registerCombiningAlgFactories() {
! Iterator it = combiningMap.keySet().iterator();
!
! while (it.hasNext()) {
! String id = (String)(it.next());
! CombiningAlgFactory cf =
! (CombiningAlgFactory)(combiningMap.get(id));
!
! try {
! CombiningAlgFactory.registerFactory(id, new CAFProxy(cf));
! } catch (IllegalArgumentException iae) {
! logger.log(Level.WARNING, "Couldn't register " +
! "CombiningAlgFactory: " + id + " (already in use)",
! iae);
! }
! }
! }
!
! /**
! * Returns the default function factory proxy.
*
* @return the default function factory proxy
*/
! public FunctionFactoryProxy getDefaultFunctionFactoryProxy() {
return defaultFunctionFactoryProxy;
}
***************
*** 909,912 ****
--- 962,989 ----
/**
+ * Registers all the supported factories with the given identifiers. If
+ * a given identifier is already in use, then that factory is not
+ * registered. This method is provided only as a convenience, and
+ * any registration that may involve identifier clashes should be done
+ * by registering each factory individually.
+ */
+ public void registerFunctionFactories() {
+ Iterator it = functionMap.keySet().iterator();
+
+ while (it.hasNext()) {
+ String id = (String)(it.next());
+ FunctionFactoryProxy ffp =
+ (FunctionFactoryProxy)(functionMap.get(id));
+
+ try {
+ FunctionFactory.registerFactory(id, ffp);
+ } catch (IllegalArgumentException iae) {
+ logger.log(Level.WARNING, "Couldn't register FunctionFactory: "
+ + id + " (already in use)", iae);
+ }
+ }
+ }
+
+ /**
* Uses the default configuration to re-set the default factories used
* by the system (attribute, combining algorithm, and function). If
***************
*** 919,927 ****
// set the default attribute factory, if it exists here
if (defaultAttributeFactory != null) {
! AttributeFactory.setDefaultFactory(new AttributeFactoryProxy() {
! public AttributeFactory getFactory() {
! return defaultAttributeFactory;
! }
! });
}
--- 996,1001 ----
// set the default attribute factory, if it exists here
if (defaultAttributeFactory != null) {
! AttributeFactory.
! setDefaultFactory(new AFProxy(defaultAttributeFactory));
}
***************
*** 929,937 ****
if (defaultCombiningFactory != null) {
CombiningAlgFactory.
! setDefaultFactory(new CombiningAlgFactoryProxy() {
! public CombiningAlgFactory getFactory() {
! return defaultCombiningFactory;
! }
! });
}
--- 1003,1007 ----
if (defaultCombiningFactory != null) {
CombiningAlgFactory.
! setDefaultFactory(new CAFProxy(defaultCombiningFactory));
}
***************
*** 941,943 ****
--- 1011,1041 ----
}
+ /**
+ *
+ */
+ class AFProxy implements AttributeFactoryProxy {
+ private AttributeFactory factory;
+
+ public AFProxy(AttributeFactory factory) {
+ this.factory = factory;
+ }
+ public AttributeFactory getFactory() {
+ return factory;
+ }
+ }
+
+ /**
+ *
+ */
+ class CAFProxy implements CombiningAlgFactoryProxy {
+ private CombiningAlgFactory factory;
+
+ public CAFProxy(CombiningAlgFactory factory) {
+ this.factory = factory;
+ }
+ public CombiningAlgFactory getFactory() {
+ return factory;
+ }
+ }
+
}
Index: PolicyReference.java
===================================================================
RCS file: /cvsroot/sunxacml/sunxacml/com/sun/xacml/PolicyReference.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** PolicyReference.java 5 Dec 2005 23:34:51 -0000 1.9
--- PolicyReference.java 13 Jan 2006 22:32:50 -0000 1.10
***************
*** 104,107 ****
--- 104,110 ----
private PolicyFinder finder;
+ // the meta-data for the parent policy
+ private PolicyMetaData parentMetaData;
+
// the logger we'll use for all messages
private static final Logger logger =
***************
*** 116,127 ****
* @param policyType one of the two fields in this class
* @param finder the <code>PolicyFinder</code> used to handle the reference
*
* @throws IllegalArgumentException if the input policyType isn't valid
*/
! public PolicyReference(URI reference, int policyType, PolicyFinder finder)
throws IllegalArgumentException
{
this(reference, policyType, new VersionConstraints(null, null, null),
! finder);
}
--- 119,133 ----
* @param policyType one of the two fields in this class
* @param finder the <code>PolicyFinder</code> used to handle the reference
+ * @param parentMetaData the meta-data associated with the containing
+ * (parent) policy
*
* @throws IllegalArgumentException if the input policyType isn't valid
*/
! public PolicyReference(URI reference, int policyType, PolicyFinder finder,
! PolicyMetaData parentMetaData)
throws IllegalArgumentException
{
this(reference, policyType, new VersionConstraints(null, null, null),
! finder, parentMetaData);
}
***************
*** 139,147 ****
* XACML policy)
* @param finder the <code>PolicyFinder</code> used to handle the reference
*
* @throws IllegalArgumentException if the input policyType isn't valid
*/
public PolicyReference(URI reference, int policyType,
! VersionConstraints constraints, PolicyFinder finder)
throws IllegalArgumentException {
--- 145,156 ----
* XACML policy)
* @param finder the <code>PolicyFinder</code> used to handle the reference
+ * @param parentMetaData the meta-data associated with the containing
+ * (parent) policy
*
* @throws IllegalArgumentException if the input policyType isn't valid
*/
public PolicyReference(URI reference, int policyType,
! VersionConstraints constraints, PolicyFinder finder,
! PolicyMetaData parentMetaData)
throws IllegalArgumentException {
***************
*** 156,159 ****
--- 165,169 ----
this.constraints = constraints;
this.finder = finder;
+ this.parentMetaData = parentMetaData;
}
***************
*** 176,183 ****
throws ParsingException
{
! return getInstance(root, finder,
! new PolicyMetaData(
! PolicyMetaData.XACML_VERSION_1_0,
! PolicyMetaData.XPATH_VERSION_UNSPECIFIED));
}
--- 186,190 ----
throws ParsingException
{
! return getInstance(root, finder, new PolicyMetaData());
}
***************
*** 240,244 ****
// finally, create the reference
! return new PolicyReference(reference, policyType, constraints, finder);
}
--- 247,252 ----
// finally, create the reference
! return new PolicyReference(reference, policyType, constraints, finder,
! metaData);
}
***************
*** 387,390 ****
--- 395,401 ----
* Returns the meta-data associated with this policy. If the policy is
* invalid or can't be retrieved, then a runtime exception is thrown.
+ * Note that this is the meta-data for the referenced policy, not the
+ * meta-data for the parent policy (which is what gets provided to the
+ * constructors of this class).
*
* @return the policy's meta-data
***************
*** 435,440 ****
}
! PolicyFinderResult pfr = finder.findPolicy(reference, policyType,
! constraints);
if (pfr.notApplicable())
--- 446,452 ----
}
! PolicyFinderResult pfr =
! finder.findPolicy(reference, policyType, constraints,
! parentMetaData);
if (pfr.notApplicable())
***************
*** 464,468 ****
PolicyFinderResult pfr = finder.findPolicy(reference, policyType,
! constraints);
// if we found nothing, then we return NotApplicable
--- 476,481 ----
PolicyFinderResult pfr = finder.findPolicy(reference, policyType,
! constraints,
! parentMetaData);
// if we found nothing, then we return NotApplicable
|