You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openaz.apache.org by pd...@apache.org on 2015/05/13 18:03:12 UTC
[50/56] [abbrv] [partial] incubator-openaz git commit: Merging
re-factoring with PMD work
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepAgent.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/main/java/org/apache/openaz/pepapi/PepAgent.java
index 0dfe649,0000000..18e96a5
mode 100644,000000..100644
--- a/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepAgent.java
+++ b/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepAgent.java
@@@ -1,108 -1,0 +1,94 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.openaz.pepapi;
+
+import java.util.List;
+
+/**
- *
- * Serves as the main entry point into the PepAPI framework. It coordinates authorization request creation, execution and
- * response assemblage. Applications typically work with a single instance of PepAgent which is thread-safe.
- *
- * The <code>decide()</code> method, which provides the most general mechanism for authorization, accepts a collection of application Domain Objects,
- * each with it's own <code>ObjectMapper</code> defined. The client application thus passes these Domain Objects directly, <code>decide()</code> uses
- * reflection to determine their type, and then finds a type-specific mapper.
- *
- * This mechanism relies on application defined library of Object Mappers, one for each Domain Object that the client
- * program expects to use in an authorization call.
- *
- * It is important to note that Java Primitives/Wrappers and other standard types(except Collections) are not supported out of the box.
- * This is primarily because there is no sensible default mapping between a Java Standard Type and a XACML category and hence
- * it's impossible for the framework to make a mapping decision at runtime. However, client applications may enforce their own rules as
- * they see fit by providing Custom ObjectMapper(s) for these types.
- *
- * <code>simpleDecide()</code> method addresses the simplest of use cases where attributes involved are simple userId, actionId and resourceId Strings.
- *
- * <code>bulkDecide()</code> provides an abstraction for a MultiRequest, where in client applications may provide collection of Domain Object
- * bindings/associations each of which map to individual requests. The method separates out Domain Object associations with multiple cardinality
- * from the ones shared across requests.
- *
- * Thus, in a <code>bulkDecide()</code> call applications provide two sets of arguments:
- * - a List of Domain Object bindings, each of which map to an individual request.
- * - a collection of common Domain Objects shared across all requests.
- *
- * Specific AzService implementations(PDP Providers) may implement bulkDecide() as a XACML MultiRequest (Note: XACML Multi Decision Profile is optional)
- * or as individual requests executed iteratively.
- *
- *
++ * Serves as the main entry point into the PepAPI framework. It coordinates authorization request creation,
++ * execution and response assemblage. Applications typically work with a single instance of PepAgent which is
++ * thread-safe. The <code>decide()</code> method, which provides the most general mechanism for authorization,
++ * accepts a collection of application Domain Objects, each with it's own <code>ObjectMapper</code> defined.
++ * The client application thus passes these Domain Objects directly, <code>decide()</code> uses reflection to
++ * determine their type, and then finds a type-specific mapper. This mechanism relies on application defined
++ * library of Object Mappers, one for each Domain Object that the client program expects to use in an
++ * authorization call. It is important to note that Java Primitives/Wrappers and other standard types(except
++ * Collections) are not supported out of the box. This is primarily because there is no sensible default
++ * mapping between a Java Standard Type and a XACML category and hence it's impossible for the framework to
++ * make a mapping decision at runtime. However, client applications may enforce their own rules as they see
++ * fit by providing Custom ObjectMapper(s) for these types. <code>simpleDecide()</code> method addresses the
++ * simplest of use cases where attributes involved are simple userId, actionId and resourceId Strings.
++ * <code>bulkDecide()</code> provides an abstraction for a MultiRequest, where in client applications may
++ * provide collection of Domain Object bindings/associations each of which map to individual requests. The
++ * method separates out Domain Object associations with multiple cardinality from the ones shared across
++ * requests. Thus, in a <code>bulkDecide()</code> call applications provide two sets of arguments: - a List of
++ * Domain Object bindings, each of which map to an individual request. - a collection of common Domain Objects
++ * shared across all requests. Specific AzService implementations(PDP Providers) may implement bulkDecide() as
++ * a XACML MultiRequest (Note: XACML Multi Decision Profile is optional) or as individual requests executed
++ * iteratively.
+ */
+public interface PepAgent {
+
-
+ /**
- * Returns a authorization decision for the given subjectId, actionId,
- * resourceId Strings.
++ * Returns a authorization decision for the given subjectId, actionId, resourceId Strings.
+ *
+ * @param subjectId
+ * @param actionId
+ * @param resourceId
+ * @return
- * @throws PepException
- * - if an appropriate ObjectMapper cannot be found.
- * - if the underlying AzService instance/PDP throws an exception
- * - if the PepAgent is configured to throw PepExceptions for "Indeterminate" or "Not Applicable" decisions.
++ * @throws PepException - if an appropriate ObjectMapper cannot be found. - if the underlying AzService
++ * instance/PDP throws an exception - if the PepAgent is configured to throw PepExceptions for
++ * "Indeterminate" or "Not Applicable" decisions.
+ * @throws IllegalArgumentException if any of the arguments are null
+ */
- public PepResponse simpleDecide(String subjectId, String actionId, String resourceId);
++ PepResponse simpleDecide(String subjectId, String actionId, String resourceId);
+
+ /**
+ * Returns an authorization decision for the given collection of Domain Objects each with it's own
- * ObjectMapper instance. Java Primitives/Wrappers or other Standard types (except Collections) are not supported
- * out of the box. However, client applications may enforce their own rules as they see fit by providing Custom ObjectMapper(s)
- * for these types.
++ * ObjectMapper instance. Java Primitives/Wrappers or other Standard types (except Collections) are not
++ * supported out of the box. However, client applications may enforce their own rules as they see fit by
++ * providing Custom ObjectMapper(s) for these types.
+ *
+ * @param objects
+ * @return
- * @throws PepException
- * - if an appropriate ObjectMapper cannot be found.
- * - if the underlying AzService instance/PDP throws an exception
- * - if the PepAgent is configured to throw PepException for "Indeterminate" or "Not Applicable" decisions.
++ * @throws PepException - if an appropriate ObjectMapper cannot be found. - if the underlying AzService
++ * instance/PDP throws an exception - if the PepAgent is configured to throw PepException for
++ * "Indeterminate" or "Not Applicable" decisions.
+ * @throws IllegalArgumentException if any of the arguments are null
+ */
- public PepResponse decide(Object... objects);
++ PepResponse decide(Object... objects);
+
+ /**
- * Returns a PepResponse instance representing a collection of decisions, each of which corresponds to
- * an association. Each association represents a specific instance of Domain Object binding. A typical example for an association
- * would be an Action-Resource pair.
++ * Returns a PepResponse instance representing a collection of decisions, each of which corresponds to an
++ * association. Each association represents a specific instance of Domain Object binding. A typical
++ * example for an association would be an Action-Resource pair.
+ *
+ * @param associations a list of Domain Object bindings, each of which maps to a individual Request.
+ * @param objects a collection of common Domain Objects shared across all Requests.
+ * @return
- * @throws PepException
- * - if an appropriate ObjectMapper cannot be found.
- * - if the underlying AzService instance/PDP throws an exception
- * - if the PepAgent is configured to throw PepExceptions for "Indeterminate" or "Not Applicable" decisions.
++ * @throws PepException - if an appropriate ObjectMapper cannot be found. - if the underlying AzService
++ * instance/PDP throws an exception - if the PepAgent is configured to throw PepExceptions for
++ * "Indeterminate" or "Not Applicable" decisions.
+ * @throws IllegalArgumentException if any of the arguments are null
+ */
- public List<PepResponse> bulkDecide(List<?> associations, Object... objects);
++ List<PepResponse> bulkDecide(List<?> associations, Object... objects);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepAgentFactory.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/main/java/org/apache/openaz/pepapi/PepAgentFactory.java
index f2954d1,0000000..a6a67ac
mode 100644,000000..100644
--- a/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepAgentFactory.java
+++ b/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepAgentFactory.java
@@@ -1,35 -1,0 +1,35 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.openaz.pepapi;
+
+/**
+ *
+ *
+ */
+public interface PepAgentFactory {
+
+ /**
+ * Returns a PepAgent instance
+ *
+ * @return
+ */
- public PepAgent getPepAgent();
++ PepAgent getPepAgent();
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepConfig.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/main/java/org/apache/openaz/pepapi/PepConfig.java
index aa248a2,0000000..e09f291
mode 100644,000000..100644
--- a/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepConfig.java
+++ b/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepConfig.java
@@@ -1,70 -1,0 +1,63 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.openaz.pepapi;
+
+import java.util.List;
+
+/**
+ */
+public interface PepConfig {
+
+ /**
- *
+ * @return
+ */
- public String getIssuer();
++ String getIssuer();
+
+ /**
- *
+ * @return
+ */
- public String getDefaultSubjectId();
++ String getDefaultSubjectId();
+
+ /**
- *
+ * @return
+ */
- public String getDefaultResourceId();
++ String getDefaultResourceId();
+
+ /**
- *
+ * @return
+ */
- public String getDefaultActionId();
++ String getDefaultActionId();
+
+ /**
- *
+ * @return
+ */
- public PepResponseBehavior getIndeterminateBehavior();
++ PepResponseBehavior getIndeterminateBehavior();
+
+ /**
- *
+ * @return
+ */
- public PepResponseBehavior getNotApplicableBehavior();
++ PepResponseBehavior getNotApplicableBehavior();
+
+ /**
- *
+ * @return
+ */
- public List<String> getMapperClassNames();
++ List<String> getMapperClassNames();
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepException.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/main/java/org/apache/openaz/pepapi/PepException.java
index 582823d,0000000..9d1d9c3
mode 100644,000000..100644
--- a/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepException.java
+++ b/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepException.java
@@@ -1,67 -1,0 +1,65 @@@
+/**
+ * Copyright 2009-2011 Oracle, Inc.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
- * 1.1 (2011): Rich Levinson, Prateek Mishra (Oracle)
- * 1.0 (2009): Josh Bregman, Rich Levinson, Prateek Mishra (Oracle)
++ * 1.1 (2011): Rich Levinson, Prateek Mishra (Oracle)
++ * 1.0 (2009): Josh Bregman, Rich Levinson, Prateek Mishra (Oracle)
+ * Contributor:
- * Rich Levinson (Oracle)
++ * Rich Levinson (Oracle)
+ */
+package org.apache.openaz.pepapi;
+
+/**
- * The PepException is used to provide additional
- * information to callers of the PepApi when
- * exception conditions occur.
++ * The PepException is used to provide additional information to callers of the PepApi when exception
++ * conditions occur.
+ * <p>
- * PepApi 1.1: now extends RuntimeException in order
- * that users do not require try/catch blocks
- * when using PepApi 1.1.
++ * PepApi 1.1: now extends RuntimeException in order that users do not require try/catch blocks when using
++ * PepApi 1.1.
+ * <p>
+ */
+public class PepException extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
- * Create a PepException containing a Throwable that
- * specifies the cause of this PepException.
++ * Create a PepException containing a Throwable that specifies the cause of this PepException.
++ *
+ * @param cause
+ */
+ public PepException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
- * Create a PepException containing the message provided
- * and a Throwable containing further information as to
- * the cause of the PepException.
++ * Create a PepException containing the message provided and a Throwable containing further information as
++ * to the cause of the PepException.
++ *
+ * @param message
+ * @param cause
+ */
+ public PepException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Create a PepException containing the message provided.
++ *
+ * @param message
+ */
+ public PepException(String message) {
+ super(message);
+ }
+
+ public PepException() {
+ super();
+ }
+}
-
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepRequest.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/main/java/org/apache/openaz/pepapi/PepRequest.java
index ac4f571,0000000..193b72a
mode 100644,000000..100644
--- a/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepRequest.java
+++ b/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepRequest.java
@@@ -1,45 -1,0 +1,44 @@@
+/**
+ * Copyright 2009-2011 Oracle, Inc.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
+ * (2014): Ajith Nair, David Laurance
- * 1.1 (2011): Rich Levinson, Prateek Mishra (Oracle)
- * 1.0 (2009): Josh Bregman, Rich Levinson, Prateek Mishra (Oracle)
++ * 1.1 (2011): Rich Levinson, Prateek Mishra (Oracle)
++ * 1.0 (2009): Josh Bregman, Rich Levinson, Prateek Mishra (Oracle)
+ * Contributor:
- * Rich Levinson (Oracle)
++ * Rich Levinson (Oracle)
+ */
+package org.apache.openaz.pepapi;
+
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.api.Request;
+
+/**
+ *
+ *
+ */
+public interface PepRequest {
+
+ /**
- * Returns a PepRequestAttributes instance that represents the attribute category identified
- * by the categoryIdentfier parameter.
++ * Returns a PepRequestAttributes instance that represents the attribute category identified by the
++ * categoryIdentfier parameter.
+ *
+ * @param categoryIdentifier an identifier for a category
+ */
- public PepRequestAttributes getPepRequestAttributes(Identifier categoryIdentifier);
++ PepRequestAttributes getPepRequestAttributes(Identifier categoryIdentifier);
+
+ /**
- *
+ * @return
+ */
- public Request getWrappedRequest();
++ Request getWrappedRequest();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepRequestAttributes.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/main/java/org/apache/openaz/pepapi/PepRequestAttributes.java
index f248333,0000000..48797de
mode 100644,000000..100644
--- a/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepRequestAttributes.java
+++ b/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepRequestAttributes.java
@@@ -1,148 -1,0 +1,131 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.openaz.pepapi;
+
+import java.net.URI;
+import java.util.Date;
+
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.api.RequestAttributes;
+
+/**
+ * Convenient wrapper around a RequestAttributes{@link org.apache.openaz.xacml.api.RequestAttributes} instance,
+ * representing a collection of request attributes that belong to a particular category.
- *
+ */
+public interface PepRequestAttributes {
+
+ /**
+ * Returns an Indentifier representing the attribute category that the PepRequestAttributes encapsulates
+ *
+ * @return Identifier
+ */
- public Identifier getCategory();
++ Identifier getCategory();
+
+ /**
+ * Returns an id representing the xml:id
+ *
+ * @return Identifier
+ */
- public String getId();
++ String getId();
+
+ /**
- * Creates and adds an attribute with the name as the AttributeId,
- * Date array elements as AttributeValue(s) into the underlying attribute collection.
- * The attribute will NOT be returned by the PDP in the response after request evaluation.
++ * Creates and adds an attribute with the name as the AttributeId, Date array elements as
++ * AttributeValue(s) into the underlying attribute collection. The attribute will NOT be returned by the
++ * PDP in the response after request evaluation.
+ *
- * @param name
- * a string with a name to be used as AttributeId
- * @param values
- * a Date array to be used as AttributeValue(s)
++ * @param name a string with a name to be used as AttributeId
++ * @param values a Date array to be used as AttributeValue(s)
+ * @throws IllegalArgumentException if the array is null
+ */
- public void addAttribute(String name, Date... values);
++ void addAttribute(String name, Date... values);
+
+ /**
- * Creates and adds an attribute with the name as the AttributeId,
- * String array elements as AttributeValue(s) into the underlying attribute collection.
- * The attribute will NOT be returned by the PDP in the response after request evaluation.
++ * Creates and adds an attribute with the name as the AttributeId, String array elements as
++ * AttributeValue(s) into the underlying attribute collection. The attribute will NOT be returned by the
++ * PDP in the response after request evaluation.
+ *
- * @param name
- * a string with a name to be used as AttributeId
- * @param values
- * a String array to be used as AttributeValue(s)
++ * @param name a string with a name to be used as AttributeId
++ * @param values a String array to be used as AttributeValue(s)
+ * @throws IllegalArgumentException if the array is null
+ */
- public void addAttribute(String name, String... values);
++ void addAttribute(String name, String... values);
+
+ /**
- * Creates and adds an attribute with the name as the AttributeId,
- * Integer array elements as AttributeValue(s) into the underlying attribute collection.
- * The attribute will NOT be returned by the PDP in the response after request evaluation.
++ * Creates and adds an attribute with the name as the AttributeId, Integer array elements as
++ * AttributeValue(s) into the underlying attribute collection. The attribute will NOT be returned by the
++ * PDP in the response after request evaluation.
+ *
- * @param name
- * a string with a name to be used as AttributeId
- * @param values
- * an Integer array to be used as AttributeValue(s)
++ * @param name a string with a name to be used as AttributeId
++ * @param values an Integer array to be used as AttributeValue(s)
+ * @throws IllegalArgumentException if the array is null
+ */
- public void addAttribute(String name, Integer... values);
++ void addAttribute(String name, Integer... values);
+
+ /**
- * Creates and adds an attribute with the name as the AttributeId,
- * Boolean array elements as AttributeValue(s) into the underlying attribute collection.
- * The attribute will NOT be returned by the PDP in the response after request evaluation.
++ * Creates and adds an attribute with the name as the AttributeId, Boolean array elements as
++ * AttributeValue(s) into the underlying attribute collection. The attribute will NOT be returned by the
++ * PDP in the response after request evaluation.
+ *
- * @param name
- * a string with a name to be used as AttributeId
- * @param values
- * a Boolean array to be used as AttributeValue(s)
++ * @param name a string with a name to be used as AttributeId
++ * @param values a Boolean array to be used as AttributeValue(s)
+ * @throws IllegalArgumentException if the array is null
+ */
- public void addAttribute(String name, Boolean... values);
-
++ void addAttribute(String name, Boolean... values);
+
+ /**
- * Creates and adds an attribute with the name as the AttributeId,
- * Long array elements as AttributeValue(s) into the underlying attribute collection.
- * The attribute will NOT be returned by the PDP in the response after request evaluation.
++ * Creates and adds an attribute with the name as the AttributeId, Long array elements as
++ * AttributeValue(s) into the underlying attribute collection. The attribute will NOT be returned by the
++ * PDP in the response after request evaluation.
+ *
- * @param name
- * a string with a name to be used as AttributeId
- * @param values
- * a Long array to be used as AttributeValue(s)
++ * @param name a string with a name to be used as AttributeId
++ * @param values a Long array to be used as AttributeValue(s)
+ * @throws IllegalArgumentException if the array is null
+ */
- public void addAttribute(String name, Long... values);
++ void addAttribute(String name, Long... values);
+
+ /**
- * Creates and adds an attribute with the name as the AttributeId,
- * Double array elements as AttributeValue(s) into the underlying attribute collection.
- * The attribute will NOT be returned by the PDP in the response after request evaluation.
++ * Creates and adds an attribute with the name as the AttributeId, Double array elements as
++ * AttributeValue(s) into the underlying attribute collection. The attribute will NOT be returned by the
++ * PDP in the response after request evaluation.
+ *
- * @param name
- * a string with a name to be used as AttributeId
- * @param values
- * a Double array to be used as AttributeValue(s)
++ * @param name a string with a name to be used as AttributeId
++ * @param values a Double array to be used as AttributeValue(s)
+ * @throws IllegalArgumentException if the array is null
+ */
- public void addAttribute(String name, Double... values);
++ void addAttribute(String name, Double... values);
+
+ /**
- * Creates and adds an attribute with the name as the AttributeId,
- * URI array elements as AttributeValue(s) into the underlying attribute collection.
- * The attribute will NOT be returned by the PDP in the response after request evaluation.
++ * Creates and adds an attribute with the name as the AttributeId, URI array elements as AttributeValue(s)
++ * into the underlying attribute collection. The attribute will NOT be returned by the PDP in the response
++ * after request evaluation.
+ *
- * @param name
- * a string AttributeId of the attribute being set
- * @param values
- * a URI array to be used as AttributeValue(s
++ * @param name a string AttributeId of the attribute being set
++ * @param values a URI array to be used as AttributeValue(s
+ * @throws IllegalArgumentException if the array is null
+ */
- public void addAttribute(String name, URI... values);
++ void addAttribute(String name, URI... values);
+
+ /**
- *
+ * @return
+ */
- public RequestAttributes getWrappedRequestAttributes();
++ RequestAttributes getWrappedRequestAttributes();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepRequestFactory.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/main/java/org/apache/openaz/pepapi/PepRequestFactory.java
index b54363b,0000000..5adfe33
mode 100644,000000..100644
--- a/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepRequestFactory.java
+++ b/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepRequestFactory.java
@@@ -1,47 -1,0 +1,45 @@@
+/**
+ * Copyright 2009-2011 Oracle, Inc.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Authors:
- * 1.1 (2011): Rich Levinson, Prateek Mishra (Oracle)
- * 1.0 (2009): Josh Bregman, Rich Levinson, Prateek Mishra (Oracle)
++ * 1.1 (2011): Rich Levinson, Prateek Mishra (Oracle)
++ * 1.0 (2009): Josh Bregman, Rich Levinson, Prateek Mishra (Oracle)
+ * Contributor:
- * Rich Levinson (Oracle)
++ * Rich Levinson (Oracle)
+ */
+package org.apache.openaz.pepapi;
+
+import java.util.List;
+
+/**
+ *
+ *
+ */
+public interface PepRequestFactory {
+
+ /**
- *
+ * @return
+ * @throws org.apache.openaz.pepapi.PepException, if no ObjectMappers found.
+ * @throws IllegalArgumentException,, if any argument is null.
+ */
- public PepRequest newPepRequest(Object[] objects);
++ PepRequest newPepRequest(Object[] objects);
+
+ /**
- *
+ * @param associations
+ * @param objects
+ * @return
+ * @throws org.apache.openaz.pepapi.PepException, if ObjectMappers are not found.
+ * @throws IllegalArgumentException,, if the arguments are null.
+ */
- public PepRequest newBulkPepRequest(List<?> associations, Object[] objects);
++ PepRequest newBulkPepRequest(List<?> associations, Object[] objects);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepResponse.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/main/java/org/apache/openaz/pepapi/PepResponse.java
index 9fb28cc,0000000..e9c7f81
mode 100644,000000..100644
--- a/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepResponse.java
+++ b/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepResponse.java
@@@ -1,91 -1,0 +1,86 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.openaz.pepapi;
+
+import java.util.Collection;
+import java.util.Map;
+
+import org.apache.openaz.xacml.api.Attribute;
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.api.Result;
+
+/**
+ */
+public interface PepResponse {
+
+ /**
+ * Returns the decision associated with the current result.
- * @return true if the user was granted access to the resource,
- * otherwise false
- * @throws PepException if the {@link PepResponseBehavior}
- * configured in the {@link PepResponseFactory}
- * indicates that for the response should be thrown
++ *
++ * @return true if the user was granted access to the resource, otherwise false
++ * @throws PepException if the {@link PepResponseBehavior} configured in the {@link PepResponseFactory}
++ * indicates that for the response should be thrown
+ */
- public boolean allowed() throws PepException;
++ boolean allowed() throws PepException;
+
+ /**
+ * Return the set of {@link org.apache.openaz.pepapi.Obligation}s associated with the
+ * current result indexed by ObligationId.
+ * @return a Map of ObligationId, Obligation pairs
+ * @throws PepException
+ * @see org.apache.openaz.pepapi.Obligation#getId()
+ */
- public Map<String, Obligation> getObligations() throws PepException;
++ Map<String, Obligation> getObligations() throws PepException;
+
+ /**
+ * Return the set of {@link org.apache.openaz.pepapi.Advice}s associated with the
+ * current result indexed by adviceId.
+ * @return a Map of adviceId, Advice pairs
+ * @throws PepException
+ * @see org.apache.openaz.pepapi.Advice#getId()
+ */
- public Map<String, Advice> getAdvices() throws PepException;
++ Map<String, Advice> getAdvices() throws PepException;
+
+ /**
- * Return the object association that is tied to the current
- * result. The association is the same object that was
- * used to create the PepRequest and may be used to
- * correlate the PepResponse results with the association
- * pairs that were used to create the PepRequest.
- * @return an object that was used as the action-resource in the PepRequest
- * @throws PepException
- */
- public Object getAssociation() throws PepException;
++ * Return the object association that is tied to the current result. The association is the same object
++ * that was used to create the PepRequest and may be used to correlate the PepResponse results with the
++ * association pairs that were used to create the PepRequest.
++ *
++ * @return an object that was used as the action-resource in the PepRequest
++ * @throws PepException
++ */
++ Object getAssociation() throws PepException;
+
+ /**
- *
+ * @return
+ */
- public Collection<Attribute> getAttributes();
++ Collection<Attribute> getAttributes();
+
+ /**
- *
+ * @return
+ */
- public Map<Identifier, Collection<Attribute>> getAttributesByCategory();
++ Map<Identifier, Collection<Attribute>> getAttributesByCategory();
+
+ /**
- *
+ * @return
+ */
- public Result getWrappedResult();
++ Result getWrappedResult();
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepResponseBehavior.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/main/java/org/apache/openaz/pepapi/PepResponseBehavior.java
index 8a55a60,0000000..c521e11
mode 100644,000000..100644
--- a/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepResponseBehavior.java
+++ b/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepResponseBehavior.java
@@@ -1,41 -1,0 +1,50 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.openaz.pepapi;
+
+/**
+ * This enum provides the options that can be set using the
+ * {@link org.apache.openaz.pepapi.PepResponseFactory} to determine the behavior when
+ * {@link org.apache.openaz.pepapi.PepResponse#allowed()} is called AND the
+ * decision is either Indeterminate or NotApplicable.
+ *
+ *
+ */
+public enum PepResponseBehavior {
+
- /** The behavior is to allow (Permit) access by returning true when the condition for which this behavior is assigned occurs */
++ /**
++ * The behavior is to allow (Permit) access by returning true when the condition for which this behavior
++ * is assigned occurs
++ */
+ RETURN_YES,
+
- /** The behavior is to disallow (Deny) access by returning false when the condition for which this behavior is assigned occurs */
++ /**
++ * The behavior is to disallow (Deny) access by returning false when the condition for which this behavior
++ * is assigned occurs
++ */
+ RETURN_NO,
+
- /** The behavior is to disallow (Deny) access by throwing a PepException when the condition for which this behavior is assigned occurs */
++ /**
++ * The behavior is to disallow (Deny) access by throwing a PepException when the condition for which this
++ * behavior is assigned occurs
++ */
+ THROW_EXCEPTION
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepResponseFactory.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/main/java/org/apache/openaz/pepapi/PepResponseFactory.java
index 063ab08,0000000..b54ff32
mode 100644,000000..100644
--- a/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepResponseFactory.java
+++ b/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepResponseFactory.java
@@@ -1,70 -1,0 +1,64 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.openaz.pepapi;
+
+import org.apache.openaz.xacml.api.Result;
+
+/**
+ * Factory for creating and configuring <code>PepResponse</code>.
+ * <br>
+ * This class creates {@link org.apache.openaz.pepapi.PepResponse} objects and configures
+ * the behavior of how the <code>PepResponse</code> interprets the
+ * results from the AzService or any other PDP that is supported
+ * by an implementation of PepApi (org.openliberty.openaz.azapi.pep.*).
+ * <br>
+ * The {@link PepResponseBehavior} that is invoked when
+ * {@link org.apache.openaz.pepapi.PepResponse#allowed()} is called and the associated status code
+ * has been returned by the PDP and is being handled by the PepResponse
+ * provider impl, can be configured to be one of:
+ * <ul>
+ * <li>
+ * {@link org.apache.openaz.pepapi.PepResponse#allowed()} returns true (PERMIT: {@link PepResponseBehavior#RETURN_YES}),
+ * <li>
+ * {@link org.apache.openaz.pepapi.PepResponse#allowed()} returns false (DENY: {@link PepResponseBehavior#RETURN_NO}),
+ * <li>
+ * or{@link org.apache.openaz.pepapi.PepResponse#allowed()} throws an exception (DENY: {@link PepResponseBehavior#THROW_EXCEPTION}).
+ * </ul>
+ * <p>
- * In general, a Permit returns true, and a Deny returns false,
- * but there are also other types of returns, including
- * NotApplicable and Indeterminate. The configuration is to
- * specify for each of the 4 xacml-defined conditions, what
- * the behavior will be. i.e. for each of the "special"
- * conditions there is a choice to return either true (Permit),
- * false (Deny), or throw an Exception.
++ * In general, a Permit returns true, and a Deny returns false, but there are also other types of returns,
++ * including NotApplicable and Indeterminate. The configuration is to specify for each of the 4 xacml-defined
++ * conditions, what the behavior will be. i.e. for each of the "special" conditions there is a choice to
++ * return either true (Permit), false (Deny), or throw an Exception.
+ * <p>
- * In addition, PDP-specific status codes can be specified, such
- * that when the impl detects one of the configured status codes
- * has been returned, then the {@link PepResponseBehavior} configured
- * for that status code will be returned.
++ * In addition, PDP-specific status codes can be specified, such that when the impl detects one of the
++ * configured status codes has been returned, then the {@link PepResponseBehavior} configured for that status
++ * code will be returned.
+ * <p>
- * Finally, a default {@link PepResponseBehavior} may be configured
- * for any status code that has not been explicitly configured
- * or does not have its own default provided by the impl. The
- * default if the statusCode default has not been configured is
- * {@link PepResponseBehavior#THROW_EXCEPTION}.
++ * Finally, a default {@link PepResponseBehavior} may be configured for any status code that has not been
++ * explicitly configured or does not have its own default provided by the impl. The default if the statusCode
++ * default has not been configured is {@link PepResponseBehavior#THROW_EXCEPTION}.
+ * <p>
+ */
+public interface PepResponseFactory {
+
- public PepResponse newPepResponse(Result result);
++ PepResponse newPepResponse(Result result);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepResponseType.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/main/java/org/apache/openaz/pepapi/PepResponseType.java
index f48d723,0000000..aafb025
mode 100644,000000..100644
--- a/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepResponseType.java
+++ b/openaz-pep/src/main/java/org/apache/openaz/pepapi/PepResponseType.java
@@@ -1,44 -1,0 +1,43 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.openaz.pepapi;
+
+/**
+ *
+ */
+public enum PepResponseType {
- /** The PepResponse returned for this query type will contain
- * only the list of resource action associations that are
- * allowed.
++ /**
++ * The PepResponse returned for this query type will contain only the list of resource action associations
++ * that are allowed.
+ */
+ ONLY_ALLOWED_RESULTS,
+ /**
- * The PepResponse returned for this query type will contain
- * only the list of resource action associations that are
- * denied.
++ * The PepResponse returned for this query type will contain only the list of resource action associations
++ * that are denied.
+ */
+ ONLY_DENIED_RESULTS,
- /** The PepResponse returned for this query type will contain
- * the complete list of results for each resource action association
- * that was requested, including allowed, denied, notapplicable,
- * and indeterminate.
++ /**
++ * The PepResponse returned for this query type will contain the complete list of results for each
++ * resource action association that was requested, including allowed, denied, notapplicable, and
++ * indeterminate.
+ */
+ ALL_RESULTS;
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/main/java/org/apache/openaz/pepapi/PostDecisionHandler.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/main/java/org/apache/openaz/pepapi/PostDecisionHandler.java
index 12068cb,0000000..ac0e67c
mode 100644,000000..100644
--- a/openaz-pep/src/main/java/org/apache/openaz/pepapi/PostDecisionHandler.java
+++ b/openaz-pep/src/main/java/org/apache/openaz/pepapi/PostDecisionHandler.java
@@@ -1,43 -1,0 +1,39 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.openaz.pepapi;
+
+/**
- * An interface that may be implemented to process the
- * PepResponse that is returned from the main decide()
++ * An interface that may be implemented to process the PepResponse that is returned from the main decide()
+ * call before the final results are returned to the user.
- *
- *
+ */
+public interface PostDecisionHandler {
+
+ /**
+ * This method is used to apply post-decision custom
+ * processing to the {@link org.apache.openaz.pepapi.PepResponse} after it has
+ * been returned.
+ *
+ * @param request
+ * @throws org.apache.openaz.pepapi.PepException
+ */
- public void postDecide(PepRequest request, PepResponse response)
- throws PepException;
++ void postDecide(PepRequest request, PepResponse response) throws PepException;
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/main/java/org/apache/openaz/pepapi/PreDecisionHandler.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/main/java/org/apache/openaz/pepapi/PreDecisionHandler.java
index bb9a93f,0000000..35db69f
mode 100644,000000..100644
--- a/openaz-pep/src/main/java/org/apache/openaz/pepapi/PreDecisionHandler.java
+++ b/openaz-pep/src/main/java/org/apache/openaz/pepapi/PreDecisionHandler.java
@@@ -1,42 -1,0 +1,38 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.openaz.pepapi;
+
+/**
- * An interface that can be used for preliminary processing
- * of a PepRequest before it is actually submitted to the
- * main decide() method.
- *
- *
++ * An interface that can be used for preliminary processing of a PepRequest before it is actually submitted to
++ * the main decide() method.
+ */
+public interface PreDecisionHandler {
+
+ /**
+ * This method is used to apply preliminary custom
+ * processing to the {@link org.apache.openaz.pepapi.PepRequest} prior to its
+ * being submitted.
+ *
+ * @param request
+ * @throws org.apache.openaz.pepapi.PepException
+ */
- public void preDecide(PepRequest request)
- throws PepException;
++ void preDecide(PepRequest request) throws PepException;
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/main/java/org/apache/openaz/pepapi/Resource.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/main/java/org/apache/openaz/pepapi/Resource.java
index c786e51,0000000..8d7e1a4
mode 100644,000000..100644
--- a/openaz-pep/src/main/java/org/apache/openaz/pepapi/Resource.java
+++ b/openaz-pep/src/main/java/org/apache/openaz/pepapi/Resource.java
@@@ -1,148 -1,0 +1,146 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.openaz.pepapi;
+
+import java.net.URI;
+import java.util.Date;
+
+import org.apache.openaz.xacml.api.XACML3;
+
+/**
+ * Container class that maps attributes to predefined XACML Resource category.
- *
- *
+ */
+public final class Resource extends CategoryContainer {
+
+ public static final String RESOURCE_ID_KEY = "RESOURCE_ID_KEY";
+
+ private Object resourceIdValue;
+
+ private Resource() {
+ super(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE);
+ }
+
+ /**
+ * Creates a new Resource instance
+ *
+ * @return
+ */
+ public static Resource newInstance() {
+ return new Resource();
+ }
+
+ /**
+ * Creates a new Resource instance containing a single default attribute with the given String value.
+ *
+ * @param resourceIdValue
+ * @return
+ */
+ public static Resource newInstance(String resourceIdValue) {
+ Resource r = new Resource();
+ r.resourceIdValue = resourceIdValue;
+ r.addAttribute(RESOURCE_ID_KEY, resourceIdValue);
+ return r;
+ }
+
+ /**
+ * Creates a new Resource instance containing a single default attribute with the given URI value.
+ *
+ * @param resourceIdValue
+ * @return
+ */
+ public static Resource newInstance(URI resourceIdValue) {
+ Resource r = new Resource();
+ r.resourceIdValue = resourceIdValue;
+ r.addAttribute(RESOURCE_ID_KEY, resourceIdValue);
+ return r;
+ }
+
+ /**
+ * Creates a new Resource instance containing a single default attribute with the given Long value.
+ *
+ * @param resourceIdValue
+ * @return
+ */
+ public static Resource newInstance(Long resourceIdValue) {
+ Resource r = new Resource();
+ r.resourceIdValue = resourceIdValue;
+ r.addAttribute(RESOURCE_ID_KEY, resourceIdValue);
+ return r;
+ }
+
+ /**
+ * Creates a new Resource instance containing a single default attribute with the given Double value.
+ *
+ * @param resourceIdValue
+ * @return
+ */
+ public static Resource newInstance(Double resourceIdValue) {
+ Resource r = new Resource();
+ r.resourceIdValue = resourceIdValue;
+ r.addAttribute(RESOURCE_ID_KEY, resourceIdValue);
+ return r;
+ }
+
+ /**
+ * Creates a new Resource instance containing a single default attribute with the given Boolean value.
+ *
+ * @param resourceIdValue
+ * @return
+ */
+ public static Resource newInstance(Boolean resourceIdValue) {
+ Resource r = new Resource();
+ r.resourceIdValue = resourceIdValue;
+ r.addAttribute(RESOURCE_ID_KEY, resourceIdValue);
+ return r;
+ }
+
+ /**
- * Creates a new Resource instance containing a single default attribute with the given <code>java.util.Date</code> value.
++ * Creates a new Resource instance containing a single default attribute with the given
++ * <code>java.util.Date</code> value.
+ *
+ * @param resourceIdValue
+ * @return
+ */
+ public static Resource newInstance(Date resourceIdValue) {
+ Resource r = new Resource();
+ r.resourceIdValue = resourceIdValue;
+ r.addAttribute(RESOURCE_ID_KEY, resourceIdValue);
+ return r;
+ }
+
+ /**
+ * Returns the value of the default resourceIdValue attribute
+ *
+ * @return
+ */
+ public Object getResourceIdValue() {
+ return resourceIdValue;
+ }
+
-
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("resource-id value : " + resourceIdValue);
+ builder.append("\n");
+ builder.append(super.toString());
+ return builder.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/main/java/org/apache/openaz/pepapi/Subject.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/main/java/org/apache/openaz/pepapi/Subject.java
index a711888,0000000..1fedb4f
mode 100644,000000..100644
--- a/openaz-pep/src/main/java/org/apache/openaz/pepapi/Subject.java
+++ b/openaz-pep/src/main/java/org/apache/openaz/pepapi/Subject.java
@@@ -1,79 -1,0 +1,77 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.openaz.pepapi;
+
+import org.apache.openaz.xacml.api.XACML3;
+
+/**
+ * Container class that maps attributes to predefined XACML AccessSubject category.
- *
- *
+ */
+public class Subject extends CategoryContainer {
+
+ public static final String SUBJECT_ID_KEY = "SUBJECT_ID_KEY";
+
+ private String subjectIdValue;
+
+ private Subject() {
+ super(XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT);
+ }
+
+ /**
+ * Creates a new Subject instance
+ *
+ * @return
+ */
+ public static Subject newInstance() {
+ return new Subject();
+ }
+
+ /**
+ * Creates a new Subject instance containing a single default attribute with the given String value.
+ *
+ * @param subjectIdValue
+ * @return
+ */
+ public static Subject newInstance(String subjectIdValue) {
+ Subject s = new Subject();
+ s.subjectIdValue = subjectIdValue;
+ s.addAttribute(SUBJECT_ID_KEY, subjectIdValue);
+ return s;
+ }
+
+ /**
+ * Returns the value of the default subjectIdValue attribute
+ *
+ * @return
+ */
+ public String getSubjectIdValue() {
+ return subjectIdValue;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("subject-id value : " + subjectIdValue);
+ builder.append("\n");
+ builder.append(super.toString());
+ return builder.toString();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/main/java/org/apache/openaz/pepapi/UnhandleableObligationException.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/main/java/org/apache/openaz/pepapi/UnhandleableObligationException.java
index c585c6b,0000000..a0adef5
mode 100644,000000..100644
--- a/openaz-pep/src/main/java/org/apache/openaz/pepapi/UnhandleableObligationException.java
+++ b/openaz-pep/src/main/java/org/apache/openaz/pepapi/UnhandleableObligationException.java
@@@ -1,46 -1,0 +1,44 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.openaz.pepapi;
+
+/**
+ * Runtime Exception thrown when the framework cannot find a registered handler to deal with the obligation.
- *
- *
+ */
+@SuppressWarnings("serial")
+public class UnhandleableObligationException extends RuntimeException {
+
+ public UnhandleableObligationException() {
+ super();
+ }
+
+ public UnhandleableObligationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public UnhandleableObligationException(String message) {
+ super(message);
+ }
+
+ public UnhandleableObligationException(Throwable cause) {
+ super(cause);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/main/java/org/apache/openaz/pepapi/std/ActionMapper.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/main/java/org/apache/openaz/pepapi/std/ActionMapper.java
index 7bac35c,0000000..347710a
mode 100644,000000..100644
--- a/openaz-pep/src/main/java/org/apache/openaz/pepapi/std/ActionMapper.java
+++ b/openaz-pep/src/main/java/org/apache/openaz/pepapi/std/ActionMapper.java
@@@ -1,42 -1,0 +1,41 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.openaz.pepapi.std;
+
-
+import org.apache.openaz.pepapi.Action;
+
+/**
+ * Created by ajith on 12/11/14.
+ */
+public class ActionMapper extends CategoryContainerMapper {
+
+ public ActionMapper() {
+ super(Action.class);
+ }
+
+ @Override
+ protected String resolveAttributeId(String attributeId) {
- if(attributeId.equals(Action.ACTION_ID_KEY)) {
++ if (attributeId.equals(Action.ACTION_ID_KEY)) {
+ return getPepConfig().getDefaultActionId();
+ }
+ return attributeId;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/main/java/org/apache/openaz/pepapi/std/ActionResourcePairMapper.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/main/java/org/apache/openaz/pepapi/std/ActionResourcePairMapper.java
index 1836bb9,0000000..94e8e81
mode 100644,000000..100644
--- a/openaz-pep/src/main/java/org/apache/openaz/pepapi/std/ActionResourcePairMapper.java
+++ b/openaz-pep/src/main/java/org/apache/openaz/pepapi/std/ActionResourcePairMapper.java
@@@ -1,55 -1,0 +1,54 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.openaz.pepapi.std;
+
-
+import org.apache.openaz.pepapi.*;
+
+public final class ActionResourcePairMapper implements ObjectMapper {
+
+ private MapperRegistry mapperRegistry;
+
- private PepConfig pepConfig;
++ private PepConfig pepConfig; //NOPMD
+
+ @Override
+ public Class<?> getMappedClass() {
+ return ActionResourcePair.class;
+ }
+
+ @Override
+ public void map(Object o, PepRequest pepRequest) {
+ ActionResourcePair actionResource = (ActionResourcePair)o;
+ Object action = actionResource.getAction();
+ Object resource = actionResource.getResource();
+ mapperRegistry.getMapper(action.getClass()).map(action, pepRequest);
+ mapperRegistry.getMapper(resource.getClass()).map(resource, pepRequest);
+ }
+
+ @Override
+ public void setMapperRegistry(MapperRegistry mapperRegistry) {
+ this.mapperRegistry = mapperRegistry;
+ }
+
+ @Override
+ public void setPepConfig(PepConfig pepConfig) {
+ this.pepConfig = pepConfig;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/main/java/org/apache/openaz/pepapi/std/ArrayMapper.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/main/java/org/apache/openaz/pepapi/std/ArrayMapper.java
index 26341dc,0000000..7f741a8
mode 100644,000000..100644
--- a/openaz-pep/src/main/java/org/apache/openaz/pepapi/std/ArrayMapper.java
+++ b/openaz-pep/src/main/java/org/apache/openaz/pepapi/std/ArrayMapper.java
@@@ -1,66 -1,0 +1,65 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.openaz.pepapi.std;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.openaz.pepapi.*;
+
-
+public final class ArrayMapper implements ObjectMapper {
+
+ private static final Log logger = LogFactory.getLog(ArrayMapper.class);
+
- private PepConfig pepConfig;
++ private PepConfig pepConfig; //NOPMD
+
+ private MapperRegistry mapperRegistry;
+
+ @Override
+ public Class<Object[]> getMappedClass() {
+ return Object[].class;
+ }
+
+ @Override
+ public void map(Object o, PepRequest pepRequest) {
+ Object[] array = (Object[])o;
- if(array != null && array.length > 0) {
++ if (array != null && array.length > 0) {
+ ObjectMapper mapper = mapperRegistry.getMapper(array[0].getClass());
- if(mapper != null) {
- for(Object item: array) {
++ if (mapper != null) {
++ for (Object item : array) {
+ mapper.map(item, pepRequest);
+ }
+ } else {
+ logger.error("Can't map an Object of class: " + array[0].getClass().getName());
+ throw new PepException("Can't map an Object of class: " + array[0].getClass().getName());
+ }
+ }
+ }
+
+ @Override
+ public void setMapperRegistry(MapperRegistry mapperRegistry) {
+ this.mapperRegistry = mapperRegistry;
+ }
+
+ @Override
+ public void setPepConfig(PepConfig pepConfig) {
+ this.pepConfig = pepConfig;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/main/java/org/apache/openaz/pepapi/std/CategoryContainerMapper.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/main/java/org/apache/openaz/pepapi/std/CategoryContainerMapper.java
index 09ff308,0000000..30d5b1c
mode 100644,000000..100644
--- a/openaz-pep/src/main/java/org/apache/openaz/pepapi/std/CategoryContainerMapper.java
+++ b/openaz-pep/src/main/java/org/apache/openaz/pepapi/std/CategoryContainerMapper.java
@@@ -1,115 -1,0 +1,114 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.openaz.pepapi.std;
+
-
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.openaz.pepapi.*;
+
+import java.net.URI;
+import java.util.Date;
+import java.util.Map;
+import java.util.Map.Entry;
+
-
+public class CategoryContainerMapper implements ObjectMapper {
+
+ private static final Log logger = LogFactory.getLog(CategoryContainerMapper.class);
+
+ private Class<?> mappedClass;
+
+ private MapperRegistry mapperRegistry;
+
+ private PepConfig pepConfig;
+
+ public CategoryContainerMapper(Class<?> mappedClass) {
+ this.mappedClass = mappedClass;
+ }
+
+ @Override
+ public Class<?> getMappedClass() {
+ return this.mappedClass;
+ }
+
+ @Override
+ public void map(Object o, PepRequest pepRequest) {
+ CategoryContainer a = (CategoryContainer)o;
- PepRequestAttributes pepRequestAttributes = pepRequest.getPepRequestAttributes(a.getCategoryIdentifier());
++ PepRequestAttributes pepRequestAttributes = pepRequest.getPepRequestAttributes(a
++ .getCategoryIdentifier());
+ Map<String, Object[]> aMap = a.getAttributeMap();
- if(aMap != null) {
- for(Entry<String, Object[]> e: aMap.entrySet()) {
++ if (aMap != null) {
++ for (Entry<String, Object[]> e : aMap.entrySet()) {
+ String attributeId = resolveAttributeId(e.getKey());
+ Object[] values = e.getValue();
- if(values != null && values.length > 0) {
++ if (values != null && values.length > 0) {
+ map(pepRequestAttributes, attributeId, values);
+ } else {
+ logger.error("No value assigned for attribute : " + attributeId);
+ throw new IllegalArgumentException("No or null value for attribute : " + attributeId);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void setMapperRegistry(MapperRegistry mapperRegistry) {
+ this.mapperRegistry = mapperRegistry;
+ }
+
+ @Override
+ public void setPepConfig(PepConfig pepConfig) {
+ this.pepConfig = pepConfig;
+ }
+
+ protected String resolveAttributeId(String attributeId) {
+ return attributeId;
+ }
+
+ private final void map(PepRequestAttributes pepRequestAttributes, String key, Object... values) {
+ Object value = values[0];
+ if (value instanceof String) {
- pepRequestAttributes.addAttribute(key, (String[]) values);
++ pepRequestAttributes.addAttribute(key, (String[])values);
+ } else if (value instanceof Long) {
- pepRequestAttributes.addAttribute(key, (Long[]) values);
++ pepRequestAttributes.addAttribute(key, (Long[])values);
+ } else if (value instanceof Integer) {
- pepRequestAttributes.addAttribute(key, (Integer[]) values);
++ pepRequestAttributes.addAttribute(key, (Integer[])values);
+ } else if (value instanceof Double) {
- pepRequestAttributes.addAttribute(key, (Double[]) values);
++ pepRequestAttributes.addAttribute(key, (Double[])values);
+ } else if (value instanceof Boolean) {
- pepRequestAttributes.addAttribute(key, (Boolean[]) values);
++ pepRequestAttributes.addAttribute(key, (Boolean[])values);
+ } else if (value instanceof URI) {
- pepRequestAttributes.addAttribute(key, (URI[]) values);
++ pepRequestAttributes.addAttribute(key, (URI[])values);
+ } else if (value instanceof Date) {
- pepRequestAttributes.addAttribute(key, (Date[]) values);
++ pepRequestAttributes.addAttribute(key, (Date[])values);
+ } else {
+ logger.error("Type: " + value.getClass().getName() + " cannot be mapped for attribute: " + key);
+ throw new PepException("Can't map an object of class: " + value.getClass().getName());
+ }
+ }
+
+ protected PepConfig getPepConfig() {
+ return this.pepConfig;
+ }
+
+ protected MapperRegistry getMapperRegistry() {
+ return this.mapperRegistry;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/main/java/org/apache/openaz/pepapi/std/CollectionMapper.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/main/java/org/apache/openaz/pepapi/std/CollectionMapper.java
index ea80e6a,0000000..610d7e8
mode 100644,000000..100644
--- a/openaz-pep/src/main/java/org/apache/openaz/pepapi/std/CollectionMapper.java
+++ b/openaz-pep/src/main/java/org/apache/openaz/pepapi/std/CollectionMapper.java
@@@ -1,66 -1,0 +1,65 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.openaz.pepapi.std;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.openaz.pepapi.*;
+
+import java.util.Collection;
+
-
+public final class CollectionMapper implements ObjectMapper {
+
+ private static final Log logger = LogFactory.getLog(CollectionMapper.class);
+
+ private MapperRegistry mapperRegistry;
+
- private PepConfig pepConfig;
++ private PepConfig pepConfig; //NOPMD
+
+ @Override
+ public Class<?> getMappedClass() {
+ return Collection.class;
+ }
+
+ @Override
+ public void map(Object o, PepRequest pepRequest) {
+ Collection<?> collection = (Collection<?>)o;
- for(Object item: collection) {
++ for (Object item : collection) {
+ ObjectMapper mapper = mapperRegistry.getMapper(item.getClass());
- if(mapper != null) {
++ if (mapper != null) {
+ mapper.map(item, pepRequest);
+ } else {
+ logger.error("Can't map an Object of class: " + item.getClass().getName());
+ throw new PepException("Can't map an Object of class: " + item.getClass().getName());
+ }
+ }
+ }
+
+ @Override
+ public void setMapperRegistry(MapperRegistry mapperRegistry) {
+ this.mapperRegistry = mapperRegistry;
+ }
+
+ @Override
+ public void setPepConfig(PepConfig pepConfig) {
+ this.pepConfig = pepConfig;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/main/java/org/apache/openaz/pepapi/std/MatchAnyCriterion.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/main/java/org/apache/openaz/pepapi/std/MatchAnyCriterion.java
index 2ad8bad,0000000..2ae9800
mode 100644,000000..100644
--- a/openaz-pep/src/main/java/org/apache/openaz/pepapi/std/MatchAnyCriterion.java
+++ b/openaz-pep/src/main/java/org/apache/openaz/pepapi/std/MatchAnyCriterion.java
@@@ -1,33 -1,0 +1,32 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.openaz.pepapi.std;
+
-
+import org.apache.openaz.pepapi.Obligation;
+
+public final class MatchAnyCriterion implements ObligationCriterion {
+
+ @Override
+ public boolean match(Obligation obligation) {
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/cfbe399c/openaz-pep/src/main/java/org/apache/openaz/pepapi/std/MultiRequest.java
----------------------------------------------------------------------
diff --cc openaz-pep/src/main/java/org/apache/openaz/pepapi/std/MultiRequest.java
index 95adca5,0000000..4a2b4f7
mode 100644,000000..100644
--- a/openaz-pep/src/main/java/org/apache/openaz/pepapi/std/MultiRequest.java
+++ b/openaz-pep/src/main/java/org/apache/openaz/pepapi/std/MultiRequest.java
@@@ -1,143 -1,0 +1,148 @@@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.openaz.pepapi.std;
+
+import org.apache.openaz.pepapi.*;
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.api.Request;
+import org.apache.openaz.xacml.api.RequestReference;
+import org.apache.openaz.xacml.std.StdMutableRequest;
+import org.apache.openaz.xacml.std.StdMutableRequestReference;
+import org.apache.openaz.xacml.std.StdRequestAttributesReference;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ *
+ */
+final class MultiRequest implements PepRequest {
+
+ private static final String REQUEST_ATTR_ID_PREFIX = "attributes";
+
+ private final Map<Identifier, PepRequestAttributes> pepRequestAttributesMapByCategory;
+
+ private final MapperRegistry mapperRegistry;
+
+ private final PepConfig pepConfig;
+
+ private final Object[] sharedRequestObjects;
+
+ private List<?> associations;
+
+ private final AtomicInteger idCounter;
+
+ private final StdMutableRequest wrappedRequest;
+
+ private StdMutableRequestReference currentRequestReference;
+
+ private RequestReference sharedRequestReference;
+
- static MultiRequest newInstance(PepConfig pepConfig, MapperRegistry mapperRegistry, List<?> associations, Object[] sharedRequestObjects) {
++ static MultiRequest newInstance(PepConfig pepConfig, MapperRegistry mapperRegistry, List<?> associations,
++ Object[] sharedRequestObjects) {
+ MultiRequest m = new MultiRequest(pepConfig, mapperRegistry, associations, sharedRequestObjects);
+ m.mapSharedRequestObjects();
+ m.mapAssociations();
+ return m;
+ }
+
- private MultiRequest(PepConfig pepConfig, MapperRegistry mapperRegistry, List<?> associations, Object[] sharedRequestObjects) {
++ private MultiRequest(PepConfig pepConfig, MapperRegistry mapperRegistry, List<?> associations,
++ Object[] sharedRequestObjects) {
+ this.pepRequestAttributesMapByCategory = new HashMap<Identifier, PepRequestAttributes>();
+ this.sharedRequestObjects = sharedRequestObjects;
+ this.associations = associations;
+ this.mapperRegistry = mapperRegistry;
+ this.pepConfig = pepConfig;
+ this.idCounter = new AtomicInteger(1);
+ this.wrappedRequest = new StdMutableRequest();
+ this.currentRequestReference = new StdMutableRequestReference();
+ }
+
+ private void mapSharedRequestObjects() {
- if(sharedRequestObjects == null) {
++ if (sharedRequestObjects == null) {
+ throw new IllegalArgumentException("One or more arguments are null");
+ }
- for(Object o: sharedRequestObjects) {
- if(o == null) {
++ for (Object o : sharedRequestObjects) {
++ if (o == null) {
+ throw new IllegalArgumentException("One or more arguments are null");
+ }
+ ObjectMapper mapper = mapperRegistry.getMapper(o.getClass());
- if(mapper == null) {
++ if (mapper == null) {
+ throw new IllegalArgumentException("No mappers found for class: " + o.getClass().getName());
+ }
+ mapper.map(o, this);
+ }
- //Collect
++ // Collect
+ sharedRequestReference = currentRequestReference;
+ }
+
+ private void mapAssociations() {
- if(associations == null) {
++ if (associations == null) {
+ throw new IllegalArgumentException("One or more arguments are null");
+ }
- for(Object association: associations) {
- if(association == null) {
++ for (Object association : associations) {
++ if (association == null) {
+ throw new IllegalArgumentException("One or more arguments are null");
+ }
+
- //Prepare
++ // Prepare
+ pepRequestAttributesMapByCategory.clear();
- currentRequestReference = new StdMutableRequestReference(sharedRequestReference.getAttributesReferences());
++ currentRequestReference = new StdMutableRequestReference(
++ sharedRequestReference
++ .getAttributesReferences());
+ wrappedRequest.add(currentRequestReference);
+
- //Map
++ // Map
+ ObjectMapper mapper = mapperRegistry.getMapper(association.getClass());
- if(mapper == null) {
- throw new IllegalArgumentException("No mappers found for class: " + association.getClass().getName());
++ if (mapper == null) {
++ throw new IllegalArgumentException("No mappers found for class: "
++ + association.getClass().getName());
+ }
+ mapper.map(association, this);
+ }
+ }
+
+ @Override
+ public PepRequestAttributes getPepRequestAttributes(Identifier categoryIdentifier) {
+ PepRequestAttributes pepRequestAttributes = pepRequestAttributesMapByCategory.get(categoryIdentifier);
- if(pepRequestAttributes == null) {
++ if (pepRequestAttributes == null) {
+ String xmlId = generateRequestAttributesXmlId();
+ StdPepRequestAttributes p = new StdPepRequestAttributes(xmlId, categoryIdentifier);
+ p.setIssuer(pepConfig.getIssuer());
+ pepRequestAttributes = p;
+ pepRequestAttributesMapByCategory.put(categoryIdentifier, pepRequestAttributes);
+ wrappedRequest.add(pepRequestAttributes.getWrappedRequestAttributes());
+ currentRequestReference.add(new StdRequestAttributesReference(xmlId));
+ }
+ return pepRequestAttributes;
+ }
+
+ private String generateRequestAttributesXmlId() {
+ return REQUEST_ATTR_ID_PREFIX + idCounter.getAndIncrement();
+ }
+
+ @Override
+ public Request getWrappedRequest() {
+ return wrappedRequest;
+ }
+}