[DMAAP-48] Initial code import
[dmaap/datarouter.git] / datarouter-prov / src / main / java / com / att / research / datarouter / authz / impl / AuthRespImpl.java
diff --git a/datarouter-prov/src/main/java/com/att/research/datarouter/authz/impl/AuthRespImpl.java b/datarouter-prov/src/main/java/com/att/research/datarouter/authz/impl/AuthRespImpl.java
new file mode 100644 (file)
index 0000000..db318d3
--- /dev/null
@@ -0,0 +1,97 @@
+/*******************************************************************************\r
+ * ============LICENSE_START==================================================\r
+ * * org.onap.dmaap\r
+ * * ===========================================================================\r
+ * * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * * ===========================================================================\r
+ * * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * * you may not use this file except in compliance with the License.\r
+ * * You may obtain a copy of the License at\r
+ * * \r
+ *  *      http://www.apache.org/licenses/LICENSE-2.0\r
+ * * \r
+ *  * Unless required by applicable law or agreed to in writing, software\r
+ * * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * * See the License for the specific language governing permissions and\r
+ * * limitations under the License.\r
+ * * ============LICENSE_END====================================================\r
+ * *\r
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ * *\r
+ ******************************************************************************/\r
+\r
+\r
+package com.att.research.datarouter.authz.impl;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import com.att.research.datarouter.authz.AuthorizationResponse;\r
+import com.att.research.datarouter.authz.AuthorizationResponseSupplement;\r
+\r
+\r
+/** A representation of an authorization response returned by a XACML Policy Decision Point.\r
+ *  In Data Router R1, advice and obligations are not used.\r
+ * @author J. F. Lucas\r
+ *\r
+ */\r
+public class AuthRespImpl implements AuthorizationResponse {\r
+       private boolean authorized;\r
+       private List<AuthorizationResponseSupplement> advice;\r
+       private List<AuthorizationResponseSupplement> obligations;\r
+       \r
+       /** Constructor.  This version will not be used in Data Router R1 since we will not have advice and obligations.\r
+        * \r
+        * @param authorized flag indicating whether the response carried a permit response (<code>true</code>) \r
+        * or something else (<code>false</code>).\r
+        * @param advice list of advice elements returned in the response.\r
+        * @param obligations list of obligation elements returned in the response.\r
+        */\r
+       public AuthRespImpl(boolean authorized, List<AuthorizationResponseSupplement> advice, List<AuthorizationResponseSupplement> obligations) {\r
+               this.authorized = authorized;\r
+               this.advice = (advice == null ? null : new ArrayList<AuthorizationResponseSupplement> (advice));\r
+               this.obligations = (obligations == null ? null : new ArrayList<AuthorizationResponseSupplement> (obligations));\r
+       }\r
+       \r
+       /** Constructor.  Simple version for authorization responses that have no advice and no obligations.\r
+        * \r
+        * @param authorized flag indicating whether the response carried a permit (<code>true</code>) or something else (<code>false</code>).\r
+        */\r
+       public AuthRespImpl(boolean authorized) {\r
+               this(authorized, null, null);\r
+       }\r
+\r
+       /**\r
+        * Indicates whether the request is authorized or not.\r
+        * \r
+        * @return a boolean flag that is <code>true</code> if the request is permitted, and <code>false</code> otherwise.\r
+        */\r
+       @Override\r
+       public boolean isAuthorized() {\r
+                       return authorized;\r
+       }\r
+\r
+       /**\r
+        * Returns any advice elements that were included in the authorization response.\r
+        * \r
+        * @return A list of objects implementing the <code>AuthorizationResponseSupplement</code> interface, with each object representing an\r
+        * advice element from the authorization response.\r
+        */\r
+       @Override\r
+       public List<AuthorizationResponseSupplement> getAdvice() {\r
+                       return advice;\r
+       }\r
+\r
+       /**\r
+        * Returns any obligation elements that were included in the authorization response.\r
+        * \r
+        * @return A list of objects implementing the <code>AuthorizationResponseSupplement</code> interface, with each object representing an\r
+        * obligation element from the authorization response.\r
+        */\r
+       @Override\r
+       public List<AuthorizationResponseSupplement> getObligations() {\r
+               return obligations;\r
+       }\r
+\r
+}\r