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 2016/03/17 02:06:40 UTC
[01/23] incubator-openaz git commit: Ported original att source to
openaz
Repository: incubator-openaz
Updated Branches:
refs/heads/master 54d66c1d4 -> a1d931009
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/META-INF/drop.sql
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/META-INF/drop.sql b/openaz-xacml-pap-admin/src/main/resources/META-INF/drop.sql
new file mode 100644
index 0000000..8aee7ee
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/resources/META-INF/drop.sql
@@ -0,0 +1,21 @@
+DROP TABLE IF EXISTS AttributeAssignment;
+DROP TABLE IF EXISTS ConstraintValues;
+DROP TABLE IF EXISTS ObadviceExpressions;
+DROP TABLE IF EXISTS Attribute;
+DROP TABLE IF EXISTS Category;
+DROP TABLE IF EXISTS ConstraintType;
+DROP VIEW IF EXISTS match_functions;
+DROP VIEW IF EXISTS higherorder_bag_functions;
+DROP VIEW IF EXISTS function_flattener;
+DROP TABLE IF EXISTS FunctionArguments;
+DROP TABLE IF EXISTS FunctionDefinition;
+DROP TABLE IF EXISTS Datatype;
+DROP TABLE IF EXISTS Obadvice;
+DROP TABLE IF EXISTS PIPConfigParams;
+DROP TABLE IF EXISTS PIPResolverParams;
+DROP TABLE IF EXISTS PIPResolver;
+DROP TABLE IF EXISTS PIPConfiguration;
+DROP TABLE IF EXISTS PIPType;
+DROP TABLE IF EXISTS PolicyAlgorithms;
+DROP TABLE IF EXISTS RuleAlgorithms;
+DROP TABLE IF EXISTS SEQUENCE;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/META-INF/empty.sql
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/META-INF/empty.sql b/openaz-xacml-pap-admin/src/main/resources/META-INF/empty.sql
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/META-INF/persistence.xml b/openaz-xacml-pap-admin/src/main/resources/META-INF/persistence.xml
new file mode 100644
index 0000000..79594a9
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/resources/META-INF/persistence.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
+ <persistence-unit name="XACML-PAP-ADMIN">
+ <class>org.apache.openaz.xacml.admin.jpa.Attribute</class>
+ <class>org.apache.openaz.xacml.admin.jpa.AttributeAssignment</class>
+ <class>org.apache.openaz.xacml.admin.jpa.Category</class>
+ <class>org.apache.openaz.xacml.admin.jpa.ConstraintType</class>
+ <class>org.apache.openaz.xacml.admin.jpa.ConstraintValue</class>
+ <class>org.apache.openaz.xacml.admin.jpa.Datatype</class>
+ <class>org.apache.openaz.xacml.admin.jpa.Obadvice</class>
+ <class>org.apache.openaz.xacml.admin.jpa.ObadviceExpression</class>
+ <class>org.apache.openaz.xacml.admin.jpa.PolicyAlgorithms</class>
+ <class>org.apache.openaz.xacml.admin.jpa.RuleAlgorithms</class>
+ <class>org.apache.openaz.xacml.admin.jpa.FunctionArgument</class>
+ <class>org.apache.openaz.xacml.admin.jpa.FunctionDefinition</class>
+ <class>org.apache.openaz.xacml.admin.jpa.PIPConfigParam</class>
+ <class>org.apache.openaz.xacml.admin.jpa.PIPConfiguration</class>
+ <class>org.apache.openaz.xacml.admin.jpa.PIPResolver</class>
+ <class>org.apache.openaz.xacml.admin.jpa.PIPResolverParam</class>
+ <class>org.apache.openaz.xacml.admin.jpa.PIPType</class>
+ <properties>
+ <!--
+ The properties defined below are the default settings to be used when someone initially
+ wants to start working with the XACML-PAP-ADMIN web gui. They are not intended for production
+ use.
+
+ They are setup to drop and create the tables and then load an initial set of data into the database
+ every time the application is deployed. So if you add anything to the dictionaries or PIP
+ configuration, they will get lost upon each deployment. It uses an H2 database engine configured
+ for a local file so you don't have to setup you're own SQL database environment to start.
+
+ Instead of modifying this file directly, please refer to the xacml.admin.properties file for
+ customizing the application settings.
+
+ -->
+ <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
+ <property name="javax.persistence.schema-generation.create-source" value="metadata-then-script"/>
+ <property name="javax.persistence.schema-generation.create-script-source" value="META-INF/views.sql" />
+ <property name="javax.persistence.schema-generation.drop-source" value="script"/>
+ <property name="javax.persistence.schema-generation.drop-script-source" value="META-INF/drop.sql" />
+ <property name="javax.persistence.sql-load-script-source" value="META-INF/data.sql" />
+
+ <!--
+
+ These properties should be set in the xacml.admin.properties file, so they can be re-used by non-JPA
+ database functionality.
+
+ <property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
+ <property name="javax.persistence.jdbc.url" value="jdbc:h2:file:sql/xacml"/>
+ <property name="javax.persistence.jdbc.user" value="sa"/>
+ <property name="javax.persistence.jdbc.password" value=""/>
+ -->
+ </properties>
+ </persistence-unit>
+</persistence>
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/META-INF/views.sql
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/META-INF/views.sql b/openaz-xacml-pap-admin/src/main/resources/META-INF/views.sql
new file mode 100644
index 0000000..7c4a820
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/resources/META-INF/views.sql
@@ -0,0 +1,6 @@
+
+CREATE VIEW match_functions AS SELECT D.ID AS id, D.SHORT_NAME AS shortname, D.XACML_ID AS xacmlid, D.RETURN_DATATYPE AS return_datatype, D.IS_BAG_RETURN AS is_bag_return, D.ARG_LB AS arg_lb, D.ARG_UB AS arg_ub, A1.IS_BAG AS arg1_isbag, A1.DATATYPE_ID AS arg1_datatype, A2.IS_BAG AS arg2_isbag, A2.DATATYPE_ID AS arg2_datatype FROM (FunctionDefinition D left join FunctionArguments A1 on (A1.FUNCTION_ID = D.ID and A1.ARG_INDEX = 1) left join FunctionArguments A2 on (A2.FUNCTION_ID = D.ID and A2.ARG_INDEX = 2)) where (D.ARG_LB = 2 and D.ARG_UB = 2 and D.RETURN_DATATYPE = 18 and A1.IS_BAG = 0) order by D.SHORT_NAME;
+
+CREATE VIEW function_flattener AS SELECT D.ID AS id, D.SHORT_NAME AS shortname, D.RETURN_DATATYPE AS return_datatype, D.IS_BAG_RETURN AS is_bag_return, D.IS_HIGHER_ORDER AS is_higher_order, D.ARG_LB AS arg_lb, D.ARG_UB AS arg_ub, A1.IS_BAG AS arg1_isbag, A1.DATATYPE_ID AS arg1_datatype, A2.IS_BAG AS arg2_isbag, A2.DATATYPE_ID AS arg2_datatype, A3.IS_BAG AS arg3_isbag, A3.DATATYPE_ID AS arg3_datatype FROM (FunctionDefinition D left join FunctionArguments A1 ON (A1.FUNCTION_ID = D.ID and A1.ARG_INDEX = 1) left join FunctionArguments A2 ON (A2.FUNCTION_ID = D.ID and A2.ARG_INDEX = 2) LEFT JOIN FunctionArguments A3 ON (A3.FUNCTION_ID = D.ID and A3.ARG_INDEX = 3)) ORDER BY D.ID;
+
+CREATE VIEW higherorder_bag_functions AS SELECT * FROM function_flattener WHERE is_higher_order = 1 AND is_bag_return = 1 AND return_datatype=18 AND arg_lb=2 AND arg_ub=2 AND arg1_isbag = 1 AND (arg2_isbag = 1 OR arg2_isbag IS NULL);
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/addons.scss
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/addons.scss b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/addons.scss
new file mode 100644
index 0000000..a5670b7
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/addons.scss
@@ -0,0 +1,7 @@
+/* This file is automatically managed and will be overwritten from time to time. */
+/* Do not manually edit this file. */
+
+/* Import and include this mixin into your project theme to include the addon themes */
+@mixin addons {
+}
+
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/favicon.ico
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/favicon.ico b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/favicon.ico
new file mode 100644
index 0000000..bfd212e
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/favicon.ico differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/MenuSeparator.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/MenuSeparator.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/MenuSeparator.png
new file mode 100644
index 0000000..9980604
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/MenuSeparator.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/add.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/add.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/add.png
new file mode 100644
index 0000000..c7443d1
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/add.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/advice-16.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/advice-16.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/advice-16.png
new file mode 100644
index 0000000..3de9e04
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/advice-16.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/advice-32.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/advice-32.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/advice-32.png
new file mode 100644
index 0000000..a3c243b
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/advice-32.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_approval_icon_blu_rgb.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_approval_icon_blu_rgb.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_approval_icon_blu_rgb.png
new file mode 100644
index 0000000..bc7ad9e
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_approval_icon_blu_rgb.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_approval_icon_dkblu_rgb.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_approval_icon_dkblu_rgb.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_approval_icon_dkblu_rgb.png
new file mode 100644
index 0000000..ef73ffa
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_approval_icon_dkblu_rgb.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_approval_icon_grn_rgb.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_approval_icon_grn_rgb.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_approval_icon_grn_rgb.png
new file mode 100644
index 0000000..7b22aa8
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_approval_icon_grn_rgb.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_approval_icon_mag_rgb.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_approval_icon_mag_rgb.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_approval_icon_mag_rgb.png
new file mode 100644
index 0000000..e0592a6
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_approval_icon_mag_rgb.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_approval_icon_org_rgb.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_approval_icon_org_rgb.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_approval_icon_org_rgb.png
new file mode 100644
index 0000000..65e4985
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_approval_icon_org_rgb.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_lock_icon_blu_rgb.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_lock_icon_blu_rgb.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_lock_icon_blu_rgb.png
new file mode 100644
index 0000000..282bba6
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_lock_icon_blu_rgb.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_lock_icon_dkblu_rgb.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_lock_icon_dkblu_rgb.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_lock_icon_dkblu_rgb.png
new file mode 100644
index 0000000..c033369
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_lock_icon_dkblu_rgb.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_lock_icon_grn_rgb.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_lock_icon_grn_rgb.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_lock_icon_grn_rgb.png
new file mode 100644
index 0000000..05787f5
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_lock_icon_grn_rgb.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_lock_icon_mag_rgb.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_lock_icon_mag_rgb.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_lock_icon_mag_rgb.png
new file mode 100644
index 0000000..8d207b9
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_lock_icon_mag_rgb.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_lock_icon_org_rgb.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_lock_icon_org_rgb.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_lock_icon_org_rgb.png
new file mode 100644
index 0000000..f735262
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_lock_icon_org_rgb.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_protect_icon_blu_rgb.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_protect_icon_blu_rgb.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_protect_icon_blu_rgb.png
new file mode 100644
index 0000000..5feb76c
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_protect_icon_blu_rgb.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_protect_icon_dkblu_rgb.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_protect_icon_dkblu_rgb.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_protect_icon_dkblu_rgb.png
new file mode 100644
index 0000000..69f72f9
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_protect_icon_dkblu_rgb.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_protect_icon_grn_rgb.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_protect_icon_grn_rgb.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_protect_icon_grn_rgb.png
new file mode 100644
index 0000000..758257f
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_protect_icon_grn_rgb.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_protect_icon_mag_rgb.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_protect_icon_mag_rgb.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_protect_icon_mag_rgb.png
new file mode 100644
index 0000000..247d066
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_protect_icon_mag_rgb.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_protect_icon_org_rgb.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_protect_icon_org_rgb.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_protect_icon_org_rgb.png
new file mode 100644
index 0000000..993faab
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_protect_icon_org_rgb.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_support_icon_blu_rgb.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_support_icon_blu_rgb.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_support_icon_blu_rgb.png
new file mode 100644
index 0000000..a5e228f
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_support_icon_blu_rgb.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_support_icon_dkblu_rgb.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_support_icon_dkblu_rgb.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_support_icon_dkblu_rgb.png
new file mode 100644
index 0000000..d8239e1
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_support_icon_dkblu_rgb.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_support_icon_grn_rgb.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_support_icon_grn_rgb.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_support_icon_grn_rgb.png
new file mode 100644
index 0000000..6e249f7
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_support_icon_grn_rgb.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_support_icon_mag_rgb.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_support_icon_mag_rgb.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_support_icon_mag_rgb.png
new file mode 100644
index 0000000..b4fc229
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_support_icon_mag_rgb.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_support_icon_org_rgb.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_support_icon_org_rgb.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_support_icon_org_rgb.png
new file mode 100644
index 0000000..b7f0fa7
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/att_support_icon_org_rgb.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/combine.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/combine.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/combine.png
new file mode 100644
index 0000000..ffeec58
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/combine.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/condition-16.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/condition-16.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/condition-16.png
new file mode 100644
index 0000000..fa300a8
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/condition-16.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/condition-32.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/condition-32.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/condition-32.png
new file mode 100644
index 0000000..2d8ba95
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/condition-32.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/deny-16.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/deny-16.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/deny-16.png
new file mode 100644
index 0000000..234f9f5
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/deny-16.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/deny-32.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/deny-32.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/deny-32.png
new file mode 100644
index 0000000..1c53527
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/deny-32.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/key.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/key.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/key.png
new file mode 100644
index 0000000..732d7b6
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/key.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/link.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/link.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/link.png
new file mode 100644
index 0000000..c35c84d
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/link.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/obligation-16.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/obligation-16.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/obligation-16.png
new file mode 100644
index 0000000..a1533f2
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/obligation-16.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/obligation-32.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/obligation-32.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/obligation-32.png
new file mode 100644
index 0000000..189cc11
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/obligation-32.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/permit-16.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/permit-16.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/permit-16.png
new file mode 100644
index 0000000..4524177
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/permit-16.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/permit-32.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/permit-32.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/permit-32.png
new file mode 100644
index 0000000..a11fffd
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/permit-32.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/policy.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/policy.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/policy.png
new file mode 100644
index 0000000..99cd51b
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/policy.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/policyset.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/policyset.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/policyset.png
new file mode 100644
index 0000000..64693e2
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/policyset.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/refresh.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/refresh.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/refresh.png
new file mode 100644
index 0000000..4a23967
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/refresh.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/remove.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/remove.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/remove.png
new file mode 100644
index 0000000..945e15c
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/remove.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/rule.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/rule.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/rule.png
new file mode 100644
index 0000000..01e9c68
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/rule.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/target-green-16.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/target-green-16.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/target-green-16.png
new file mode 100644
index 0000000..48f3b6c
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/target-green-16.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/target-green-32.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/target-green-32.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/target-green-32.png
new file mode 100644
index 0000000..7386e4f
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/target-green-32.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/target.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/target.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/target.png
new file mode 100644
index 0000000..74a6ca2
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/target.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/variable-16.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/variable-16.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/variable-16.png
new file mode 100644
index 0000000..43e92f9
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/variable-16.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/variable-32.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/variable-32.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/variable-32.png
new file mode 100644
index 0000000..c4affb6
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/icons/variable-32.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/img/att.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/img/att.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/img/att.png
new file mode 100644
index 0000000..9f6e629
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/img/att.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/img/att_globe_rgb_grd_pos.png
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/img/att_globe_rgb_grd_pos.png b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/img/att_globe_rgb_grd_pos.png
new file mode 100644
index 0000000..8f612a7
Binary files /dev/null and b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/img/att_globe_rgb_grd_pos.png differ
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/styles.scss
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/styles.scss b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/styles.scss
new file mode 100644
index 0000000..77baa29
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/styles.scss
@@ -0,0 +1,9 @@
+@import "addons.scss";
+@import "xacml_pap_admin.scss";
+
+/* This file prefixes all rules with the theme name to avoid causing conflicts with other themes. */
+/* The actual styles should be defined in xacml_pap_admin.scss */
+.xacml_pap_admin {
+ @include addons;
+ @include xacml_pap_admin;
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/xacml_pap_admin.scss
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/xacml_pap_admin.scss b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/xacml_pap_admin.scss
new file mode 100644
index 0000000..fb29c5d
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/resources/VAADIN/themes/xacml_pap_admin/xacml_pap_admin.scss
@@ -0,0 +1,42 @@
+/* Import the reindeer theme.*/
+/* This only allows us to use the mixins defined in it and does not add any styles by itself. */
+@import "../reindeer/reindeer.scss";
+
+/* This contains all of your theme.*/
+/* If somebody wants to extend the theme she will include this mixin. */
+@mixin xacml_pap_admin {
+ /* Include all the styles from the reindeer theme */
+ @include reindeer;
+
+ /* Insert your theme rules here */
+
+ .v-textfield-dashing {
+ border: thin dashed;
+ background: white; /* Has shading image by default */
+ }
+
+/* Lay the options horizontally */
+.v-select-optiongroup-horizontal .v-select-option {
+ display: inline-block;
+}
+
+/* Avoid wrapping if the layout is too tight */
+.v-select-optiongroup-horizontal {
+ white-space: nowrap;
+}
+
+/* Some extra spacing is needed */
+.v-select-optiongroup-horizontal
+ .v-select-option.v-radiobutton {
+ padding-right: 10px;
+}
+
+.v-textfield {
+ min-width:400px;
+}
+
+.v-textarea {
+ min-width:250px;
+}
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/log4j.properties b/openaz-xacml-pap-admin/src/main/resources/log4j.properties
new file mode 100644
index 0000000..aeee9f8
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/resources/log4j.properties
@@ -0,0 +1,13 @@
+#
+# Use this properties for debugging and development.
+#
+#
+# Set root logger level
+log4j.rootLogger=DEBUG, MAIN_LOG
+
+# console is set to be a ConsoleAppender.
+log4j.appender.MAIN_LOG=org.apache.log4j.ConsoleAppender
+
+# A1 uses PatternLayout.
+log4j.appender.MAIN_LOG.layout=org.apache.log4j.PatternLayout
+log4j.appender.MAIN_LOG.layout.ConversionPattern=%d{yyyy_MM_dd_HH_mm_ss_SSS} [%t] %-5p %l- %m%n
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/webapp/WEB-INF/web.xml b/openaz-xacml-pap-admin/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 0000000..9e06c81
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ 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.
+-->
+
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+ http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0"
+ metadata-complete="true">
+
+ <display-name>Apache OpenAZ</display-name>
+ <description></description>
+ <welcome-file-list>
+ <welcome-file>index.html</welcome-file>
+ <welcome-file>index.htm</welcome-file>
+ <welcome-file>index.jsp</welcome-file>
+ <welcome-file>default.html</welcome-file>
+ <welcome-file>default.htm</welcome-file>
+ <welcome-file>default.jsp</welcome-file>
+ </welcome-file-list>
+
+
+ <!-- Policy Engine PAP Administration -->
+ <servlet>
+ <servlet-name>PePapAdmin</servlet-name>
+
+ <!-- <servlet-class>com.vaadin.server.VaadinServlet</servlet-class> -->
+ <servlet-class>org.apache.openaz.xacml.admin.XacmlAdminServlet</servlet-class>
+
+ <init-param>
+ <description>Vaadin UI Class: XacmlAdminUI</description>
+ <param-name>UI</param-name>
+ <param-value>org.apache.openaz.xacml.admin.XacmlAdminUI</param-value>
+ </init-param>
+
+ <init-param>
+ <description>The location of the properties file holding configuration information.</description>
+ <param-name>XACML_PROPERTIES_NAME</param-name>
+ <param-value>/opt/app/xacml/etc/xacml.admin.properties</param-value>
+ </init-param>
+
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>PePapAdmin</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+</web-app>
[03/23] incubator-openaz git commit: Ported original att source to
openaz
Posted by pd...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PolicyNameEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PolicyNameEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PolicyNameEditorWindow.java
new file mode 100644
index 0000000..73149cc
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PolicyNameEditorWindow.java
@@ -0,0 +1,369 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicySetType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.jpa.PolicyAlgorithms;
+import org.apache.openaz.xacml.admin.jpa.RuleAlgorithms;
+import org.apache.openaz.xacml.api.XACML3;
+import com.vaadin.addon.jpacontainer.JPAContainer;
+import com.vaadin.addon.jpacontainer.JPAContainerItem;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.Validator;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.AbstractSelect.ItemCaptionMode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.FormLayout;
+import com.vaadin.ui.OptionGroup;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Window;
+
+public class PolicyNameEditorWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ private static final long serialVersionUID = 1L;
+ private static final Log logger = LogFactory.getLog(PolicyNameEditorWindow.class);
+ private final PolicyNameEditorWindow self = this;
+ private Object data = null;
+ private String filename = null;
+ private boolean isSaved = false;
+
+ @AutoGenerated
+ private FormLayout mainLayout;
+ @AutoGenerated
+ private ComboBox comboAlgorithms;
+ @AutoGenerated
+ private OptionGroup optionPolicySet;
+ @AutoGenerated
+ private TextArea textAreaDescription;
+ @AutoGenerated
+ private TextField textFieldPolicyName;
+ @AutoGenerated
+ private Button buttonSave;
+
+ JPAContainer<PolicyAlgorithms> policyAlgorithms;
+ JPAContainer<RuleAlgorithms> ruleAlgorithms;
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public PolicyNameEditorWindow(String filename, Object policyData, JPAContainer<PolicyAlgorithms> policyAlgs, JPAContainer<RuleAlgorithms> ruleAlgs) {
+ buildMainLayout();
+ setContent(mainLayout);
+
+ this.mainLayout.setMargin(true);
+
+ this.filename = filename;
+ this.data = policyData;
+ this.policyAlgorithms = policyAlgs;
+ this.ruleAlgorithms = ruleAlgs;
+
+ this.optionPolicySet.addItem("Policy Set");
+ this.optionPolicySet.addItem("Policy");
+
+ this.comboAlgorithms.setNewItemsAllowed(false);
+ this.comboAlgorithms.setNullSelectionAllowed(false);
+ this.comboAlgorithms.setItemCaptionMode(ItemCaptionMode.PROPERTY);
+ this.comboAlgorithms.setItemCaptionPropertyId("xacmlId");
+ //
+ // Setup the policy filename
+ //
+ this.textFieldPolicyName.setImmediate(true);
+ this.textFieldPolicyName.setNullRepresentation("");
+ if (filename != null) {
+ this.textFieldPolicyName.setValue(filename);
+ }
+ this.textFieldPolicyName.addValidator(new Validator() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void validate(Object value) throws InvalidValueException {
+ if (value instanceof String) {
+ String filename = (String) value;
+ if (filename.endsWith(".xml")) {
+ filename = filename.substring(0, filename.length() - 4);
+ }
+ if (filename.length() == 0) {
+ throw new InvalidValueException("Invalid filename.");
+ }
+ if (filename.indexOf('.') != -1) {
+ throw new InvalidValueException("Please do not use a \'.\' in the filename.");
+ }
+ }
+ }
+
+ });
+ this.textFieldPolicyName.setValidationVisible(true);
+ //
+ // Are we editing or creating?
+ //
+ if (this.data != null) {
+ //
+ // We are editing
+ //
+ if (this.data instanceof PolicySetType) {
+ this.optionPolicySet.setValue("Policy Set");
+ this.optionPolicySet.setVisible(false);
+ this.textAreaDescription.setValue(((PolicySetType)this.data).getDescription());
+ this.comboAlgorithms.setContainerDataSource(policyAlgs);
+ for (Object object : this.policyAlgorithms.getItemIds()) {
+ PolicyAlgorithms a = (PolicyAlgorithms) this.policyAlgorithms.getItem(object).getEntity();
+ if (a.getXacmlId().equals(((PolicySetType)this.data).getPolicyCombiningAlgId())) {
+ this.comboAlgorithms.select(object);
+ break;
+ }
+ }
+ }
+ if (this.data instanceof PolicyType) {
+ this.optionPolicySet.setValue("Policy");
+ this.optionPolicySet.setVisible(false);
+ this.textAreaDescription.setValue(((PolicyType)this.data).getDescription());
+ this.comboAlgorithms.setContainerDataSource(ruleAlgs);
+ for (Object object : this.ruleAlgorithms.getItemIds()) {
+ RuleAlgorithms a = (RuleAlgorithms) this.ruleAlgorithms.getItem(object).getEntity();
+ if (a.getXacmlId().equals(((PolicyType)this.data).getRuleCombiningAlgId())) {
+ this.comboAlgorithms.select(object);
+ break;
+ }
+ }
+ }
+ } else {
+ //
+ // Creating a new policy
+ //
+ this.optionPolicySet.setValue("Policy Set");
+ this.comboAlgorithms.setContainerDataSource(policyAlgs);
+ this.comboAlgorithms.setItemCaptionMode(ItemCaptionMode.PROPERTY);
+ this.comboAlgorithms.setItemCaptionPropertyId("xacmlId");
+ for (Object object : this.policyAlgorithms.getItemIds()) {
+ PolicyAlgorithms a = (PolicyAlgorithms) this.policyAlgorithms.getItem(object).getEntity();
+ if (a.getXacmlId().equals(XACML3.ID_POLICY_FIRST_APPLICABLE.stringValue())) {
+ this.comboAlgorithms.select(object);
+ break;
+ }
+ }
+
+ this.optionPolicySet.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ if (self.optionPolicySet.getValue().toString().equals("Policy Set")) {
+ self.comboAlgorithms.setContainerDataSource(self.policyAlgorithms);
+ for (Object object : self.policyAlgorithms.getItemIds()) {
+ PolicyAlgorithms a = (PolicyAlgorithms) self.policyAlgorithms.getItem(object).getEntity();
+ if (a.getXacmlId().equals(XACML3.ID_POLICY_FIRST_APPLICABLE.stringValue())) {
+ self.comboAlgorithms.select(object);
+ break;
+ }
+ }
+ } else if (self.optionPolicySet.getValue().toString().equals("Policy")) {
+ self.comboAlgorithms.setContainerDataSource(self.ruleAlgorithms);
+ for (Object object : self.ruleAlgorithms.getItemIds()) {
+ RuleAlgorithms a = (RuleAlgorithms) self.ruleAlgorithms.getItem(object).getEntity();
+ if (a.getXacmlId().equals(XACML3.ID_RULE_FIRST_APPLICABLE.stringValue())) {
+ self.comboAlgorithms.select(object);
+ break;
+ }
+ }
+ }
+ }
+
+ });
+ }
+
+ this.buttonSave.setClickShortcut(KeyCode.ENTER);
+
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ //
+ // Make sure the policy filename was valid
+ //
+ if (self.textFieldPolicyName.isValid() == false) {
+ return;
+ }
+ //
+ // Grab the filename (NOTE: The user may or may not
+ // have changed the name).
+ //
+ self.filename = self.textFieldPolicyName.getValue();
+ //
+ // Make sure the filename ends with an extension
+ //
+ if (self.filename.endsWith(".xml") == false) {
+ self.filename = self.filename + ".xml";
+ }
+ //
+ // Set ourselves as saved
+ //
+ self.isSaved = true;
+ //
+ // Now grab the policy file's data
+ //
+ if (self.data == null) {
+ //
+ // This is a brand new Policy
+ //
+ if (self.optionPolicySet.getValue().toString().equals("Policy Set")) {
+ PolicySetType policySet = new PolicySetType();
+ policySet.setVersion("1");
+ policySet.setPolicySetId(((XacmlAdminUI)getUI()).newPolicyID());
+ policySet.setTarget(new TargetType());
+ self.data = policySet;
+ } else if (self.optionPolicySet.getValue().toString().equals("Policy")) {
+ PolicyType policy = new PolicyType();
+ policy.setVersion("1");
+ policy.setPolicyId(((XacmlAdminUI)getUI()).newPolicyID());
+ policy.setTarget(new TargetType());
+ self.data = policy;
+ } else {
+ logger.error("Policy option NOT setup correctly.");
+ }
+ }
+ if (self.data != null) {
+ //
+ // Save off everything
+ //
+ if (self.data instanceof PolicySetType) {
+ ((PolicySetType)self.data).setDescription(self.textAreaDescription.getValue());
+ Object a = self.comboAlgorithms.getValue();
+ PolicyAlgorithms alg = (PolicyAlgorithms) ((JPAContainerItem<?>)self.comboAlgorithms.getItem(a)).getEntity();
+ ((PolicySetType)self.data).setPolicyCombiningAlgId(alg.getXacmlId());
+ } else if (self.data instanceof PolicyType) {
+ ((PolicyType)self.data).setDescription(self.textAreaDescription.getValue());
+ Object a = self.comboAlgorithms.getValue();
+ RuleAlgorithms alg = (RuleAlgorithms) ((JPAContainerItem<?>)self.comboAlgorithms.getItem(a)).getEntity();
+ ((PolicyType)self.data).setRuleCombiningAlgId(alg.getXacmlId());
+ } else {
+ logger.error("Unsupported data object." + self.data.getClass().getCanonicalName());
+ }
+ }
+ //
+ // Now we can close the window
+ //
+ self.close();
+ }
+ });
+
+ this.textFieldPolicyName.focus();
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ public Object getPolicyData() {
+ if (this.isSaved) {
+ return this.data;
+ }
+ return null;
+ }
+
+ public String getPolicyFilename() {
+ if (this.isSaved) {
+ return this.filename;
+ }
+ return null;
+ }
+
+ @AutoGenerated
+ private FormLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new FormLayout();
+ mainLayout.setImmediate(false);
+
+ // textFieldPolicyName
+ textFieldPolicyName = new TextField();
+ textFieldPolicyName.setCaption("Policy File Name");
+ textFieldPolicyName.setImmediate(true);
+ textFieldPolicyName.setWidth("-1px");
+ textFieldPolicyName.setHeight("-1px");
+ textFieldPolicyName.setInputPrompt("Enter filename eg. foobar.xml");
+ textFieldPolicyName.setRequired(true);
+ mainLayout.addComponent(textFieldPolicyName);
+
+ // textAreaDescription
+ textAreaDescription = new TextArea();
+ textAreaDescription.setCaption("Description");
+ textAreaDescription.setImmediate(false);
+ textAreaDescription.setWidth("100%");
+ textAreaDescription.setHeight("-1px");
+ textAreaDescription
+ .setInputPrompt("Enter a description for the Policy/PolicySet.");
+ textAreaDescription.setNullSettingAllowed(true);
+ mainLayout.addComponent(textAreaDescription);
+
+ // optionPolicySet
+ optionPolicySet = new OptionGroup();
+ optionPolicySet.setCaption("Policy or PolicySet?");
+ optionPolicySet.setImmediate(true);
+ optionPolicySet
+ .setDescription("Is the root level a Policy or Policy Set.");
+ optionPolicySet.setWidth("-1px");
+ optionPolicySet.setHeight("-1px");
+ optionPolicySet.setRequired(true);
+ mainLayout.addComponent(optionPolicySet);
+
+ // comboAlgorithms
+ comboAlgorithms = new ComboBox();
+ comboAlgorithms.setCaption("Combining Algorithm");
+ comboAlgorithms.setImmediate(false);
+ comboAlgorithms.setDescription("Select the combining algorithm.");
+ comboAlgorithms.setWidth("-1px");
+ comboAlgorithms.setHeight("-1px");
+ comboAlgorithms.setRequired(true);
+ mainLayout.addComponent(comboAlgorithms);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save");
+ buttonSave.setImmediate(true);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PolicySetEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PolicySetEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PolicySetEditorWindow.java
new file mode 100644
index 0000000..af2ae20
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PolicySetEditorWindow.java
@@ -0,0 +1,252 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicySetType;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.jpa.PolicyAlgorithms;
+import org.apache.openaz.xacml.admin.util.JPAUtils;
+import org.apache.openaz.xacml.api.XACML3;
+import com.vaadin.addon.jpacontainer.JPAContainer;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Buffered.SourceException;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.data.validator.RegexpValidator;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.AbstractSelect.ItemCaptionMode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.ListSelect;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class PolicySetEditorWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSave;
+ @AutoGenerated
+ private TextArea textAreaDescription;
+ @AutoGenerated
+ private ListSelect listSelectAlgorithm;
+ @AutoGenerated
+ private TextField textFieldVersion;
+ @AutoGenerated
+ private Label labelID;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private final PolicySetEditorWindow self = this;
+ private final PolicySetType policySet;
+ private JPAContainer<PolicyAlgorithms> algorithms = ((XacmlAdminUI)UI.getCurrent()).getPolicyAlgorithms();
+ private boolean isSaved = false;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public PolicySetEditorWindow(PolicySetType policySet) {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Save
+ //
+ this.policySet = policySet;
+ //
+ // Close shortcut
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ // Initialize GUI
+ //
+ this.initializeLabel();
+ this.initializeText();
+ this.initializeSelect();
+ this.initializeButton();
+ //
+ // Focus
+ //
+ this.textAreaDescription.focus();
+ }
+
+ protected void initializeLabel() {
+ if (this.policySet.getPolicySetId() == null) {
+ this.policySet.setPolicySetId(((XacmlAdminUI)UI.getCurrent()).newPolicyID());
+ }
+ this.labelID.setValue(this.policySet.getPolicySetId());
+ }
+
+ protected void initializeText() {
+ //
+ //
+ //
+ this.textAreaDescription.setNullRepresentation("");
+ this.textAreaDescription.setValue(this.policySet.getDescription());
+ //
+ //
+ //
+ if (this.policySet.getVersion() == null) {
+ this.policySet.setVersion("1");
+ }
+ this.textFieldVersion.setRequiredError("The exact format is: ((\\d+|\\*)\\.)*(\\d+|\\*|\\+)");
+ this.textFieldVersion.addValidator(new RegexpValidator("((\\d+|\\*)\\.)*(\\d+|\\*|\\+)", true, "The version MUST a number optionally separated by '.' eg. 1 or 1.0 or 1.1.1 etc."));
+ this.textFieldVersion.setValue(this.policySet.getVersion());
+ }
+
+ protected void initializeSelect() {
+ this.listSelectAlgorithm.setContainerDataSource(this.algorithms);
+ this.listSelectAlgorithm.setItemCaptionMode(ItemCaptionMode.PROPERTY);
+ this.listSelectAlgorithm.setItemCaptionPropertyId("xacmlId");
+ this.listSelectAlgorithm.setNullSelectionAllowed(false);
+
+ if (this.policySet.getPolicyCombiningAlgId() == null) {
+ this.policySet.setPolicyCombiningAlgId(XACML3.ID_POLICY_FIRST_APPLICABLE.stringValue());
+ }
+ this.listSelectAlgorithm.setValue(JPAUtils.findPolicyAlgorithm(this.policySet.getPolicyCombiningAlgId()).getId());
+ }
+
+ protected void initializeButton() {
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ try {
+ //
+ // Commit
+ //
+ self.listSelectAlgorithm.commit();
+ self.textFieldVersion.commit();
+ self.textAreaDescription.commit();
+ //
+ // Save everything
+ //
+ self.policySet.setDescription(self.textAreaDescription.getValue());
+ self.policySet.setVersion(self.textFieldVersion.getValue());
+ Object id = self.listSelectAlgorithm.getValue();
+ self.policySet.setPolicyCombiningAlgId(algorithms.getItem(id).getEntity().getXacmlId());
+ //
+ // Mark ourselves as saved
+ //
+ self.isSaved = true;
+ //
+ // Close window
+ //
+ self.close();
+ } catch (SourceException | InvalidValueException e) { //NOPMD
+ //
+ // VAADIN will show the required error message to the user
+ //
+ }
+ }
+ });
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ public PolicySetType getPolicySet() {
+ return this.policySet;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // labelID
+ labelID = new Label();
+ labelID.setCaption("Policy Set ID");
+ labelID.setImmediate(false);
+ labelID.setWidth("100.0%");
+ labelID.setHeight("-1px");
+ labelID.setValue("Label");
+ mainLayout.addComponent(labelID);
+
+ // textFieldVersion
+ textFieldVersion = new TextField();
+ textFieldVersion.setCaption("Version");
+ textFieldVersion.setImmediate(false);
+ textFieldVersion
+ .setDescription("The format is numbers only separated by decimal point.");
+ textFieldVersion.setWidth("-1px");
+ textFieldVersion.setHeight("-1px");
+ textFieldVersion.setInvalidAllowed(false);
+ textFieldVersion.setRequired(true);
+ textFieldVersion.setInputPrompt("Eg. 1 or 1.0 or 1.0.0 etc.");
+ mainLayout.addComponent(textFieldVersion);
+
+ // listSelectAlgorithm
+ listSelectAlgorithm = new ListSelect();
+ listSelectAlgorithm.setCaption("Policy Combining Algorithm");
+ listSelectAlgorithm.setImmediate(false);
+ listSelectAlgorithm.setWidth("100.0%");
+ listSelectAlgorithm.setHeight("-1px");
+ listSelectAlgorithm.setInvalidAllowed(false);
+ listSelectAlgorithm.setRequired(true);
+ mainLayout.addComponent(listSelectAlgorithm);
+
+ // textAreaDescription
+ textAreaDescription = new TextArea();
+ textAreaDescription.setCaption("Description");
+ textAreaDescription.setImmediate(false);
+ textAreaDescription.setWidth("100.0%");
+ textAreaDescription.setHeight("-1px");
+ mainLayout.addComponent(textAreaDescription);
+ mainLayout.setExpandRatio(textAreaDescription, 1.0f);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save");
+ buttonSave.setImmediate(true);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PolicyUploadWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PolicyUploadWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PolicyUploadWindow.java
new file mode 100644
index 0000000..06afe28
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PolicyUploadWindow.java
@@ -0,0 +1,238 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Upload;
+import com.vaadin.ui.Upload.Receiver;
+import com.vaadin.ui.Upload.SucceededEvent;
+import com.vaadin.ui.Upload.SucceededListener;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class PolicyUploadWindow extends Window implements Receiver, SucceededListener {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private CheckBox checkBoxImportAdvice;
+ @AutoGenerated
+ private CheckBox checkBoxImportObligations;
+ @AutoGenerated
+ private CheckBox checkBoxIgnoreStandard;
+ @AutoGenerated
+ private CheckBox checkBoxImportAttributes;
+ @AutoGenerated
+ private Upload upload;
+ private static final long serialVersionUID = 1L;
+ private final PolicyUploadWindow self = this;
+ private static final Log logger = LogFactory.getLog(PolicyUploadWindow.class);
+ private Path directory = null;
+ private Path newfile = null;
+ private boolean succeeded = false;
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public PolicyUploadWindow(Path directory) {
+ buildMainLayout();
+ //
+ // Create our main layout
+ //
+ this.setContent(mainLayout);
+ //
+ // Finish setting up the main layout
+ //
+ this.mainLayout.setSpacing(true);
+ this.mainLayout.setMargin(true);
+
+ this.checkBoxImportAdvice.setValue(true);
+ this.checkBoxIgnoreStandard.setValue(true);
+ this.checkBoxImportAttributes.setValue(true);
+ this.checkBoxImportObligations.setValue(true);
+
+ this.directory = directory;
+
+ this.upload.addSucceededListener(this);
+ this.upload.setReceiver(this);
+
+ this.checkBoxImportAttributes.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ if (self.checkBoxImportAttributes.getValue()) {
+ self.checkBoxIgnoreStandard.setEnabled(true);
+ } else {
+ self.checkBoxIgnoreStandard.setEnabled(false);
+ }
+ }
+
+ });
+ }
+
+ @Override
+ public OutputStream receiveUpload(String filename, String mimeType) {
+ //
+ // Validate the mime type
+ //
+ if (! mimeType.equalsIgnoreCase("text/xml")) {
+ return null;
+ }
+ //
+ // Create its new full path
+ //
+ this.newfile = Paths.get(self.directory.toString(), filename);
+ //
+ // Does it already exist?
+ //
+ if (Files.exists(this.newfile)) {
+ //
+ // TODO Prompt them to overwrite and/or bump the version???
+ //
+ return null;
+ }
+ //
+ // Try to create the output stream
+ //
+ try {
+ return new FileOutputStream(this.newfile.toFile());
+ } catch (FileNotFoundException e) {
+ logger.error("Failed to create uploaded file", e);
+ }
+ return null;
+ }
+
+ @Override
+ public void uploadSucceeded(SucceededEvent event) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("upload succeeded");
+ }
+ this.succeeded = true;
+ this.close();
+ }
+
+ public Path getUploadedFile() {
+ if (this.succeeded) {
+ return this.newfile;
+ }
+ return null;
+ }
+
+ public boolean importAttributes() {
+ return this.checkBoxImportAttributes.getValue();
+ }
+
+ public boolean importObligations() {
+ return this.checkBoxImportObligations.getValue();
+ }
+
+ public boolean importAdvice() {
+ return this.checkBoxImportAdvice.getValue();
+ }
+
+ public boolean ignoreStandard() {
+ return this.checkBoxIgnoreStandard.getValue();
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // upload
+ upload = new Upload();
+ upload.setCaption("Upload Xacml Policy File");
+ upload.setImmediate(false);
+ upload.setWidth("-1px");
+ upload.setHeight("-1px");
+ mainLayout.addComponent(upload);
+
+ // checkBoxImportAttributes
+ checkBoxImportAttributes = new CheckBox();
+ checkBoxImportAttributes
+ .setCaption("Import attributes into attribute dictionary.");
+ checkBoxImportAttributes.setImmediate(false);
+ checkBoxImportAttributes.setWidth("-1px");
+ checkBoxImportAttributes.setHeight("-1px");
+ mainLayout.addComponent(checkBoxImportAttributes);
+
+ // checkBoxIgnoreStandard
+ checkBoxIgnoreStandard = new CheckBox();
+ checkBoxIgnoreStandard.setCaption("Ignore Standard Attributes");
+ checkBoxIgnoreStandard.setImmediate(false);
+ checkBoxIgnoreStandard.setWidth("-1px");
+ checkBoxIgnoreStandard.setHeight("-1px");
+ mainLayout.addComponent(checkBoxIgnoreStandard);
+ mainLayout.setComponentAlignment(checkBoxIgnoreStandard, new Alignment(
+ 20));
+
+ // checkBoxImportObligations
+ checkBoxImportObligations = new CheckBox();
+ checkBoxImportObligations
+ .setCaption("Import obligations into obligation dictionary.");
+ checkBoxImportObligations.setImmediate(false);
+ checkBoxImportObligations.setWidth("-1px");
+ checkBoxImportObligations.setHeight("-1px");
+ mainLayout.addComponent(checkBoxImportObligations);
+
+ // checkBoxImportAdvice
+ checkBoxImportAdvice = new CheckBox();
+ checkBoxImportAdvice
+ .setCaption("Import advice into advice dictionary.");
+ checkBoxImportAdvice.setImmediate(false);
+ checkBoxImportAdvice.setWidth("-1px");
+ checkBoxImportAdvice.setHeight("-1px");
+ mainLayout.addComponent(checkBoxImportAdvice);
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/RenamePolicyFileWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/RenamePolicyFileWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/RenamePolicyFileWindow.java
new file mode 100644
index 0000000..3b9ade9
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/RenamePolicyFileWindow.java
@@ -0,0 +1,147 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.event.FieldEvents.TextChangeEvent;
+import com.vaadin.event.FieldEvents.TextChangeListener;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+// import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class RenamePolicyFileWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSave;
+ @AutoGenerated
+ private TextField textFieldFilename;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private RenamePolicyFileWindow self = this;
+ private String newFilename = null;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public RenamePolicyFileWindow(String currentFilename) {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ // Initialize the text field
+ //
+ this.textFieldFilename.setValue(currentFilename);
+ this.textFieldFilename.setImmediate(true);
+ this.textFieldFilename.addTextChangeListener(new TextChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void textChange(TextChangeEvent event) {
+ if (event.getText() == null || event.getText().isEmpty()) {
+ self.buttonSave.setEnabled(false);
+ } else {
+ self.buttonSave.setEnabled(true);
+ }
+ }
+ });
+ //
+ // Initialize the button
+ //
+ this.buttonSave.setClickShortcut(KeyCode.ENTER);
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ //
+ // Save the value
+ //
+ self.newFilename = self.textFieldFilename.getValue();
+ //
+ // Make sure it ends with .xml
+ //
+ if (self.newFilename.endsWith(".xml") == false) {
+ self.newFilename = self.newFilename + ".xml";
+ }
+ //
+ // Close the window
+ //
+ self.close();
+ }
+ });
+ this.textFieldFilename.focus();
+ }
+
+ public String getNewFilename() {
+ return this.newFilename;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // textFieldFilename
+ textFieldFilename = new TextField();
+ textFieldFilename.setCaption("Policy File Name");
+ textFieldFilename.setImmediate(false);
+ textFieldFilename.setWidth("-1px");
+ textFieldFilename.setHeight("-1px");
+ mainLayout.addComponent(textFieldFilename);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save");
+ buttonSave.setImmediate(false);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(24));
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/RuleEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/RuleEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/RuleEditorWindow.java
new file mode 100644
index 0000000..e6baf44
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/RuleEditorWindow.java
@@ -0,0 +1,219 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.EffectType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.RuleType;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Buffered.SourceException;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.OptionGroup;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class RuleEditorWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSave;
+ @AutoGenerated
+ private TextArea textAreaDescription;
+ @AutoGenerated
+ private OptionGroup optionGroupEffect;
+ @AutoGenerated
+ private Label labelRuleID;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private final RuleEditorWindow self = this;
+ private final RuleType rule;
+ private boolean isSaved = false;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public RuleEditorWindow(RuleType rule) {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Save
+ //
+ this.rule = rule;
+ //
+ // Close shortcut
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ // Initialize
+ //
+ this.initializeLabel();
+ this.initializeOption();
+ this.initializeText();
+ this.initializeButton();
+ }
+
+ protected void initializeLabel() {
+ if (this.rule.getRuleId() == null) {
+ this.rule.setRuleId(((XacmlAdminUI)UI.getCurrent()).newRuleID());
+ }
+ this.labelRuleID.setValue(this.rule.getRuleId());
+ }
+
+ protected void initializeOption() {
+ this.optionGroupEffect.setRequiredError("You MUST select an effect (Permit or Deny for the rule.");
+ this.optionGroupEffect.addItem("Permit");
+ this.optionGroupEffect.addItem("Deny");
+ if (this.rule.getEffect() == null) {
+ this.rule.setEffect(EffectType.PERMIT);
+ }
+ if (this.rule.getEffect() == EffectType.PERMIT) {
+ this.optionGroupEffect.setValue("Permit");
+ } else {
+ this.optionGroupEffect.setValue("Deny");
+ }
+ }
+
+ protected void initializeText() {
+ this.textAreaDescription.setValue(this.rule.getDescription());
+ }
+
+ protected void initializeButton() {
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ try {
+ //
+ // Commit
+ //
+ self.optionGroupEffect.commit();
+ self.textAreaDescription.commit();
+ //
+ // Save everything
+ //
+ if (self.optionGroupEffect.getValue() == "Permit") {
+ self.rule.setEffect(EffectType.PERMIT);
+ } else {
+ self.rule.setEffect(EffectType.DENY);
+ }
+ self.rule.setDescription(self.textAreaDescription.getValue());
+ //
+ // Set ourselves as saved
+ //
+ self.isSaved = true;
+ //
+ // Close the window
+ //
+ self.close();
+ } catch (SourceException | InvalidValueException e) { //NOPMD
+ //
+ // VAADIN will show the required error message to the user
+ //
+ }
+ }
+ });
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ public RuleType getRule() {
+ return this.rule;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // labelRuleID
+ labelRuleID = new Label();
+ labelRuleID.setCaption("Rule ID");
+ labelRuleID.setImmediate(false);
+ labelRuleID.setWidth("100.0%");
+ labelRuleID.setHeight("-1px");
+ labelRuleID.setValue("Label");
+ mainLayout.addComponent(labelRuleID);
+ mainLayout.setExpandRatio(labelRuleID, 1.0f);
+
+ // optionGroupEffect
+ optionGroupEffect = new OptionGroup();
+ optionGroupEffect.setCaption("Choose the effect.");
+ optionGroupEffect.setImmediate(false);
+ optionGroupEffect.setWidth("-1px");
+ optionGroupEffect.setHeight("-1px");
+ optionGroupEffect.setInvalidAllowed(false);
+ optionGroupEffect.setRequired(true);
+ mainLayout.addComponent(optionGroupEffect);
+
+ // textAreaDescription
+ textAreaDescription = new TextArea();
+ textAreaDescription.setCaption("Enter a description for the Rule.");
+ textAreaDescription.setImmediate(false);
+ textAreaDescription.setWidth("100.0%");
+ textAreaDescription.setHeight("-1px");
+ textAreaDescription.setNullSettingAllowed(true);
+ textAreaDescription.setNullRepresentation("");
+ mainLayout.addComponent(textAreaDescription);
+ mainLayout.setExpandRatio(textAreaDescription, 1.0f);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save");
+ buttonSave.setImmediate(true);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/SelectPDPGroupWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/SelectPDPGroupWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/SelectPDPGroupWindow.java
new file mode 100644
index 0000000..fd3d8cb
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/SelectPDPGroupWindow.java
@@ -0,0 +1,207 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import java.util.Set;
+
+import org.apache.openaz.xacml.api.pap.PDPGroup;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.AbstractSelect.ItemCaptionMode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.ListSelect;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class SelectPDPGroupWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSave;
+ @AutoGenerated
+ private ListSelect listSelectPDPGroup;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private final SelectPDPGroupWindow self = this;
+
+ private boolean saved = false;
+
+ private PDPGroup selectedGroup = null;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ // TODO - Refactor. Unused formal parameter: caption. Either determine
+ // that this parameter is unnecessary and remove it (including removing
+ // it from all constructor method consumers), or use it.
+ // NOTE: Setting to NOPMD for now.
+ public SelectPDPGroupWindow(Set<PDPGroup> groups, String caption) { //NOPMD
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Setup the shortcuts
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ this.buttonSave.setClickShortcut(KeyCode.ENTER);
+ //
+ // initialize
+ //
+ this.initialize(groups);
+ //
+ // Focus
+ //
+ this.listSelectPDPGroup.focus();
+ //
+ // setup the button
+ //
+ this.setupButtons();
+ }
+
+ protected void initialize(Set<PDPGroup> groups) {
+ //
+ // Initialize the list
+ //
+ this.initializeSelect(groups);
+ //
+ // Buttons
+ //
+ this.initializeButtons();
+ }
+
+ protected void initializeButtons() {
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ //
+ // Get the selected value
+ //
+ self.selectedGroup = (PDPGroup) self.listSelectPDPGroup.getValue();
+ assert self.selectedGroup != null;
+ //
+ // Mark ourselves as saved
+ //
+ self.saved = true;
+ //
+ // Close window
+ //
+ self.close();
+ }
+ });
+ }
+
+ public boolean isSaved() {
+ return saved;
+ }
+
+ public PDPGroup selectedGroup() {
+ return this.selectedGroup;
+ }
+
+ private void initializeSelect(Set<PDPGroup> groups) {
+ //
+ // Initialize GUI properties
+ //
+ this.listSelectPDPGroup.setImmediate(true);
+ this.listSelectPDPGroup.setItemCaptionMode(ItemCaptionMode.EXPLICIT);
+ this.listSelectPDPGroup.setNullSelectionAllowed(false);
+ this.listSelectPDPGroup.setNewItemsAllowed(false);
+ this.listSelectPDPGroup.setMultiSelect(false);
+ //
+ // Add items
+ //
+ for (PDPGroup group : groups) {
+ this.listSelectPDPGroup.addItem(group);
+ this.listSelectPDPGroup.setItemCaption(group, group.getName());
+ }
+ //
+ // Listen to events
+ //
+ this.listSelectPDPGroup.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ self.setupButtons();
+ }
+ });
+ }
+
+ protected void setupButtons() {
+ if (self.listSelectPDPGroup.getValue() == null) {
+ self.buttonSave.setEnabled(false);
+ } else {
+ self.buttonSave.setEnabled(true);
+ }
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // listSelectPDPGroup
+ listSelectPDPGroup = new ListSelect();
+ listSelectPDPGroup.setImmediate(false);
+ listSelectPDPGroup.setWidth("-1px");
+ listSelectPDPGroup.setHeight("-1px");
+ listSelectPDPGroup.setInvalidAllowed(false);
+ listSelectPDPGroup.setRequired(true);
+ mainLayout.addComponent(listSelectPDPGroup);
+ mainLayout.setExpandRatio(listSelectPDPGroup, 1.0f);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save");
+ buttonSave.setImmediate(true);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/SelectPIPConfigurationWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/SelectPIPConfigurationWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/SelectPIPConfigurationWindow.java
new file mode 100644
index 0000000..dfa92ee
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/SelectPIPConfigurationWindow.java
@@ -0,0 +1,217 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.jpa.PIPConfiguration;
+import org.apache.openaz.xacml.api.pap.PDPGroup;
+import org.apache.openaz.xacml.api.pap.PDPPIPConfig;
+import org.apache.openaz.xacml.std.pap.StdPDPPIPConfig;
+import com.vaadin.addon.jpacontainer.EntityItem;
+import com.vaadin.addon.jpacontainer.JPAContainer;
+import com.vaadin.addon.jpacontainer.provider.CachingLocalEntityProvider;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+// import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class SelectPIPConfigurationWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSave;
+ @AutoGenerated
+ private Table table;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static final Log logger = LogFactory.getLog(SelectPIPConfigurationWindow.class);
+ private final SelectPIPConfigurationWindow self = this;
+ private final JPAContainer<PIPConfiguration> container = new JPAContainer<PIPConfiguration>(PIPConfiguration.class);
+ private boolean isSaved = false;
+ private Set<PDPPIPConfig> selectedConfigs = null;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public SelectPIPConfigurationWindow(PDPGroup group) {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Initialize
+ //
+ this.initialize(group);
+ }
+
+ protected void initialize(PDPGroup group) {
+ //
+ // Setup the container
+ //
+ this.container.setEntityProvider(new CachingLocalEntityProvider<PIPConfiguration>(PIPConfiguration.class, ((XacmlAdminUI)UI.getCurrent()).getEntityManager()));
+
+ this.initializeTable(group);
+ this.initializeButton();
+ }
+
+ protected void initializeTable(PDPGroup group) {
+ //
+ // GUI properties
+ //
+ this.table.setContainerDataSource(this.container);
+ this.table.setImmediate(true);
+ this.table.setSelectable(true);
+ this.table.setMultiSelect(true);
+ this.table.setPageLength(this.container.size() > 10 ? 10 : this.container.size());
+ this.table.setVisibleColumns("name", "description");
+ //
+ // Pre-select the group's configurations
+ //
+ for (PDPPIPConfig config : group.getPipConfigs()) {
+ try {
+ Integer id = Integer.parseInt(config.getId());
+ if (this.container.containsId(id)) {
+ this.table.select(id);
+ }
+ } catch (NumberFormatException e) {
+ logger.error("invalid config id: " + config.getId());
+ }
+ }
+ }
+
+ protected void initializeButton() {
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ //
+ // Commit the table so we have everything that was selected
+ //
+ self.table.commit();
+ //
+ // We are going to fill this structure
+ //
+ self.selectedConfigs = new HashSet<PDPPIPConfig>();
+ //
+ // Get all the selected values
+ //
+ Object values = self.table.getValue();
+ if (values != null && values instanceof Collection) {
+ Collection<?> ids = (Collection<?>) values;
+ for (Object id : ids) {
+ //
+ // Get the entity
+ //
+ EntityItem<PIPConfiguration> entity = self.container.getItem(id);
+ PIPConfiguration config = entity.getEntity();
+ //
+ // Create object needed by PAP REST
+ //
+ StdPDPPIPConfig pipConfig = new StdPDPPIPConfig();
+ pipConfig.setId(Integer.toString(config.getId()));
+ pipConfig.setClassname(config.getClassname());
+ pipConfig.setName(config.getName());
+ pipConfig.setDescription(config.getDescription());
+ Map<String, String> map = config.getConfiguration(null);
+ pipConfig.setValues(map);
+ //
+ // Add it to the saved Set
+ //
+ self.selectedConfigs.add(pipConfig);
+ }
+ }
+ //
+ // Mark ourselves as saved
+ //
+ self.isSaved = true;
+ //
+ // Close the window
+ //
+ self.close();
+ }
+ });
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ public Set<PDPPIPConfig> getSelectedConfigs() {
+ return this.selectedConfigs;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // table
+ table = new Table();
+ table.setCaption("PIP Configurations");
+ table.setImmediate(false);
+ table.setWidth("-1px");
+ table.setHeight("-1px");
+ mainLayout.addComponent(table);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save");
+ buttonSave.setImmediate(false);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/SelectWorkspacePoliciesWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/SelectWorkspacePoliciesWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/SelectWorkspacePoliciesWindow.java
new file mode 100644
index 0000000..93cea8c
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/SelectWorkspacePoliciesWindow.java
@@ -0,0 +1,331 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.net.URI;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.model.GitRepositoryContainer;
+import org.apache.openaz.xacml.admin.model.GitRepositoryContainer.FileItem;
+import org.apache.openaz.xacml.admin.util.AdminNotification;
+import org.apache.openaz.xacml.std.pap.StdPDPPolicy;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.TreeTable;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class SelectWorkspacePoliciesWindow extends Window {
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+
+ @AutoGenerated
+ private Button buttonSave;
+
+ @AutoGenerated
+ private TreeTable treeWorkspace;
+
+ private static Log logger = LogFactory.getLog(SelectWorkspacePoliciesWindow.class);
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private final SelectWorkspacePoliciesWindow self = this;
+ private GitRepositoryContainer treeContainer;
+ private boolean isSaved = false;
+ private StdPDPPolicy selectedPolicy = null;
+
+
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public SelectWorkspacePoliciesWindow() {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Shortcuts
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ this.buttonSave.setClickShortcut(KeyCode.ENTER);
+ //
+ //
+ //
+ this.initializeTree();
+ this.initializeButton();
+ //
+ //
+ //
+ this.treeWorkspace.focus();
+ }
+
+ protected void initializeTree() {
+ //
+ // This is where the user's Git repository is located
+ //
+ final Path gitPath = ((XacmlAdminUI)UI.getCurrent()).getUserGitPath();
+ //
+ // Create our Git file system container
+ //
+ this.treeContainer = new GitRepositoryContainer(gitPath, gitPath.toFile());
+ //
+ // Create our own filter to filter out File extensions and
+ // also the Git directory.
+ //
+ this.treeContainer.setFilter(new FilenameFilter() {
+
+ @Override
+ public boolean accept(File dir, String name) {
+ //
+ // We don't want any of the hidden files
+ //
+ if (name.startsWith(".git") || name.equals(".DS_Store")) {
+ return false;
+ }
+ //
+ // We definitely want xml files
+ //
+ if (name.endsWith(".xml")) {
+ return true;
+ }
+ //
+ // We should test if its a directory, we want those
+ // included.
+ //
+ Path path = Paths.get(dir.getAbsolutePath(), name);
+ if (Files.isDirectory(path)) {
+ return true;
+ }
+ logger.warn("Filtering out: " + path.toString());
+ return false;
+ }
+
+ });
+ //
+ // Set TreeTables datasource as our git container
+ //
+ this.treeWorkspace.setContainerDataSource(this.treeContainer);
+ //
+ // Setup other properties etc.
+ //
+ this.treeWorkspace.setItemIconPropertyId("Icon");
+ this.treeWorkspace.setVisibleColumns(new Object[]{"Name", "Version", "Size", "Last Modified", "Status"});
+ this.treeWorkspace.setSizeFull();
+ this.treeWorkspace.setSelectable(true);
+ this.treeWorkspace.setEditable(false);
+ //
+ // Expand the first couple of directories
+ //
+ for (Object id : this.treeWorkspace.getItemIds()) {
+ this.treeWorkspace.setCollapsed(id, false);
+ for (Object child : this.treeWorkspace.getChildren(id)) {
+ this.treeWorkspace.setCollapsed(child, false);
+ }
+ }
+ //
+ // Respond to table selections
+ //
+ this.treeWorkspace.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ if (self.treeWorkspace.getValue() != null) {
+ self.buttonSave.setEnabled(true);
+ } else {
+ self.buttonSave.setEnabled(false);
+ }
+ }
+ });
+ //
+ // Double-click events
+ //
+ this.treeWorkspace.addItemClickListener(new ItemClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void itemClick(ItemClickEvent event) {
+ if (event.isDoubleClick()) {
+ //
+ // Save and close
+ //
+ self.doSave();
+ }
+ }
+ });
+ }
+
+ protected void initializeButton() {
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ assert treeWorkspace.getValue() != null;
+ //
+ // Save everything
+ //
+ self.doSave();
+ }
+ });
+ }
+
+ protected void doSave() {
+ //
+ // Get the current selection
+ //
+ FileItem selectedItem = (FileItem) this.treeWorkspace.getItem(this.treeWorkspace.getValue());
+ //
+ //
+ //
+ assert selectedItem != null;
+ if (selectedItem == null) {
+ return;
+ }
+
+ // create the id of the target file
+
+ // Our standard for file naming is:
+ // <domain>.<filename>.<version>.xml
+
+ // since the file name usually has a ".xml", we need to strip that before adding the other parts
+ String name = selectedItem.getName();
+ String id = name;
+ if (id.endsWith(".xml")) {
+ id = id.substring(0, id.length() - 4);
+ }
+
+ // add on the version string
+
+ String version = selectedItem.getVersion();
+ id += "." + version;
+
+ // put the .xml on the end
+ id += ".xml";
+
+ // tack on the domain in front. Do this one level at a time until we reach one of the roots
+
+
+ File parentFile = selectedItem.getFile();
+ while ((parentFile = (File) this.treeWorkspace.getParent(parentFile)) != null) {
+ if (this.treeContainer.isRoot(parentFile)) {
+ break;
+ }
+ id = parentFile.getName() + "." + id;
+ }
+
+ // Default policy to be Root policy; user can change to deferred later
+ URI selectedURI = selectedItem.getFile().toURI();
+ try {
+ //
+ // Create the policy
+ //
+ this.selectedPolicy = new StdPDPPolicy(id, true, name, selectedURI);
+ //
+ // Mark ourselves as saved
+ //
+ this.isSaved = true;
+ } catch (IOException e) {
+ logger.error("Unable to create policy '" + id + "': " + e.getMessage());
+ AdminNotification.warn("Unable to create policy '" + id + "': " + e.getMessage());
+ }
+
+ //
+ // Close the window
+ //
+ this.close();
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ public StdPDPPolicy getSelectedPolicy() {
+ return this.selectedPolicy;
+ }
+
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // treeWorkspace
+ treeWorkspace = new TreeTable();
+ treeWorkspace.setCaption("Select Policy(s) for PDP Group");
+ treeWorkspace.setImmediate(true);
+ treeWorkspace.setWidth("100.0%");
+ treeWorkspace.setHeight("-1px");
+ mainLayout.addComponent(treeWorkspace);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save");
+ buttonSave.setImmediate(false);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
+
+ return mainLayout;
+ }
+
+
+
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/SubDomainEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/SubDomainEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/SubDomainEditorWindow.java
new file mode 100644
index 0000000..0e38a67
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/SubDomainEditorWindow.java
@@ -0,0 +1,204 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.vaadin.annotations.AutoGenerated;
+// import com.vaadin.data.Property.ValueChangeEvent;
+// import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.data.validator.RegexpValidator;
+import com.vaadin.event.FieldEvents.TextChangeEvent;
+import com.vaadin.event.FieldEvents.TextChangeListener;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.FormLayout;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Window;
+
+public class SubDomainEditorWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private FormLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSave;
+ @AutoGenerated
+ private TextField textFieldSubdomain;
+
+ //
+ // Full domain pattern:
+ // "^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9])(.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]))*$";
+ //
+ // We just want one part of it.
+ //
+ private static final String SUBDOMAIN_NAME_PATTERN = "^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9])$";
+ private static final String ERROR_MESSAGE = "Either enter a single subdomain via RFC1123 - letters, digits and a hyphen. Cannot start or end with a hyphen.";
+
+ private static final long serialVersionUID = 1L;
+ private static final Log logger = LogFactory.getLog(SubDomainEditorWindow.class);
+ private final SubDomainEditorWindow self = this;
+ private boolean saved = false;
+ private String subdomain = null;
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public SubDomainEditorWindow(String subdomain) {
+ buildMainLayout();
+ setContent(mainLayout);
+ //
+ // Save
+ //
+ this.subdomain = subdomain;
+ //
+ // Set our shortcuts
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ // Initialize
+ //
+ this.initializeTextField();
+ this.initializeButtons();
+ //
+ // Focus
+ //
+ this.textFieldSubdomain.focus();
+ }
+
+ protected void initializeTextField() {
+ this.textFieldSubdomain.setRequired(true);
+ this.textFieldSubdomain.setRequiredError("Please enter a valid sub domain");
+ //
+ // Validate the name entered
+ //
+ this.textFieldSubdomain.addValidator(new RegexpValidator(SUBDOMAIN_NAME_PATTERN, true, ERROR_MESSAGE) {
+ private static final long serialVersionUID = 1L;
+
+ });
+ //
+ // Respond to events
+ //
+ this.textFieldSubdomain.setImmediate(true);
+ this.textFieldSubdomain.addTextChangeListener(new TextChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void textChange(TextChangeEvent event) {
+ if (event.getText() != null && event.getText().length() > 0) {
+ self.buttonSave.setEnabled(true);
+ } else {
+ self.buttonSave.setEnabled(false);
+ }
+ }
+
+ });
+ }
+
+ protected void initializeButtons() {
+ this.buttonSave.setClickShortcut(KeyCode.ENTER);
+ this.buttonSave.setEnabled(false);
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ try {
+ //
+ // Make sure the text is valid
+ //
+ self.textFieldSubdomain.validate();
+ //
+ // Parse our the subdomain parts
+ //
+ self.subdomain = self.textFieldSubdomain.getValue();
+ self.saved = true;
+ //
+ // Close it up
+ //
+ self.close();
+ } catch (InvalidValueException e) {
+ logger.error(e);
+ }
+ }
+
+ });
+ }
+
+ public boolean isSaved() {
+ return this.saved;
+ }
+
+ public String getSubDomain() {
+ return this.subdomain;
+ }
+
+ @AutoGenerated
+ private FormLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new FormLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // textFieldSubdomain
+ textFieldSubdomain = new TextField();
+ textFieldSubdomain.setCaption("Enter Sub Domain");
+ textFieldSubdomain.setImmediate(false);
+ textFieldSubdomain
+ .setDescription("You can enter sub domain name - do not use spaces or wildcard characters.");
+ textFieldSubdomain.setWidth("-1px");
+ textFieldSubdomain.setHeight("-1px");
+ textFieldSubdomain.setInvalidAllowed(false);
+ textFieldSubdomain
+ .setInputPrompt("Examples: sales hr business marketing.");
+ mainLayout.addComponent(textFieldSubdomain);
+ mainLayout.setExpandRatio(textFieldSubdomain, 1.0f);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save");
+ buttonSave.setImmediate(true);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/VariableDefinitionEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/VariableDefinitionEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/VariableDefinitionEditorWindow.java
new file mode 100644
index 0000000..bec843e
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/VariableDefinitionEditorWindow.java
@@ -0,0 +1,202 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableDefinitionType;
+
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Buffered.SourceException;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.event.FieldEvents.TextChangeEvent;
+import com.vaadin.event.FieldEvents.TextChangeListener;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class VariableDefinitionEditorWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSave;
+ @AutoGenerated
+ private TextField textFieldID;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private final VariableDefinitionEditorWindow self = this;
+ private final VariableDefinitionType variable;
+ private boolean isSaved = false;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public VariableDefinitionEditorWindow(VariableDefinitionType variable) {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Save
+ //
+ this.variable = variable;
+ //
+ // Set our shortcuts
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ // Initialize
+ //
+ this.initializeText();
+ this.initializeButton();
+ //
+ // Initial focus
+ //
+ this.textFieldID.focus();
+ }
+
+ protected void initializeText() {
+ //
+ // Initialize GUI properties
+ //
+ this.textFieldID.setImmediate(true);
+ //
+ // Listen to changes
+ //
+ this.textFieldID.addTextChangeListener(new TextChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void textChange(TextChangeEvent event) {
+ if (event.getText() != null && event.getText().isEmpty() == false) {
+ self.buttonSave.setEnabled(true);
+ } else {
+ self.buttonSave.setEnabled(false);
+ }
+ }
+
+ });
+ this.textFieldID.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ if (self.textFieldID.getValue() != null && self.textFieldID.getValue().isEmpty() == false) {
+ self.buttonSave.setEnabled(true);
+ } else {
+ self.buttonSave.setEnabled(false);
+ }
+ }
+ });
+ //
+ // Set the value
+ //
+ this.textFieldID.setValue(variable.getVariableId());
+ }
+
+ protected void initializeButton() {
+ this.buttonSave.setClickShortcut(KeyCode.ENTER);
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ try {
+ //
+ // Commit it
+ //
+ self.textFieldID.commit();
+ //
+ // Save it
+ //
+ self.variable.setVariableId(self.textFieldID.getValue());
+ self.isSaved = true;
+ //
+ // Close window
+ //
+ self.close();
+ } catch (SourceException | InvalidValueException e) { //NOPMD
+ // Vaadin will display error
+ // TODO - Verify that Vaadin will display error and update this
+ // inline documentation accordingly
+ }
+ }
+ });
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ public VariableDefinitionType getVariable() {
+ return this.variable;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // textFieldID
+ textFieldID = new TextField();
+ textFieldID.setCaption("Variable ID");
+ textFieldID.setImmediate(false);
+ textFieldID.setWidth("-1px");
+ textFieldID.setHeight("-1px");
+ textFieldID.setInvalidAllowed(false);
+ textFieldID.setRequired(true);
+ textFieldID.setNullRepresentation("");
+ mainLayout.addComponent(textFieldID);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save and Continue");
+ buttonSave.setImmediate(false);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/VariableReferenceEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/VariableReferenceEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/VariableReferenceEditorWindow.java
new file mode 100644
index 0000000..53b47c4
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/VariableReferenceEditorWindow.java
@@ -0,0 +1,242 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import java.util.Map;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableDefinitionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableReferenceType;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Buffered.SourceException;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.event.FieldEvents.TextChangeEvent;
+import com.vaadin.event.FieldEvents.TextChangeListener;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.ListSelect;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class VariableReferenceEditorWindow extends Window {
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSave;
+ @AutoGenerated
+ private TextField textFieldVariable;
+ @AutoGenerated
+ private ListSelect listSelectVariables;
+ /*
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static Log logger = LogFactory.getLog(VariableReferenceEditorWindow.class);
+ private final VariableReferenceEditorWindow self = this;
+ private final VariableReferenceType variable;
+ private boolean isSaved = false;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public VariableReferenceEditorWindow(VariableReferenceType variable, Map<VariableDefinitionType, PolicyType> variables) {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Save parameters
+ //
+ this.variable = variable;
+ //
+ // Set our shortcuts
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ // Initialize
+ //
+ this.initializeTextField();
+ this.initializeSelect(variables);
+ this.initializeButtons();
+ //
+ // Focus
+ //
+ this.textFieldVariable.focus();
+ }
+
+ protected void initializeTextField() {
+ this.textFieldVariable.setImmediate(true);
+ this.textFieldVariable.setNullRepresentation("");
+ this.textFieldVariable.addTextChangeListener(new TextChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void textChange(TextChangeEvent event) {
+ if (event.getText() != null && event.getText().isEmpty() == false) {
+ self.buttonSave.setEnabled(true);
+ } else {
+ self.buttonSave.setEnabled(false);
+ }
+ }
+
+ });
+ this.textFieldVariable.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ String value = self.textFieldVariable.getValue();
+ if (value == null || value.isEmpty()) {
+ self.buttonSave.setEnabled(false);
+ } else {
+ self.buttonSave.setEnabled(true);
+ }
+ }
+ });
+ if (this.variable != null) {
+ this.textFieldVariable.setValue(this.variable.getVariableId());
+ }
+ }
+
+ protected void initializeSelect(Map<VariableDefinitionType, PolicyType> vars) {
+ //
+ // Add existing variables into the table
+ //
+ if (vars != null) {
+ for (VariableDefinitionType var : vars.keySet()) {
+ this.listSelectVariables.addItem(var.getVariableId());
+ }
+ }
+ //
+ // Respond to changes
+ //
+ this.listSelectVariables.setImmediate(true);
+ this.listSelectVariables.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ Object value = self.listSelectVariables.getValue();
+ if (value != null) {
+ self.textFieldVariable.setValue(value.toString());
+ }
+ }
+ });
+ }
+
+ protected void initializeButtons() {
+ this.buttonSave.setClickShortcut(KeyCode.ENTER);
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ try {
+ //
+ // Commit
+ //
+ self.textFieldVariable.commit();
+ //
+ // Now we can save
+ //
+ self.isSaved = true;
+ self.variable.setVariableId(self.textFieldVariable.getValue());
+ //
+ // And close the window
+ //
+ self.close();
+ } catch (SourceException | InvalidValueException e) {
+ logger.error("Commit variable id: " + e);
+ }
+ }
+ });
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ public VariableReferenceType getVariableReference() {
+ return this.variable;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // listSelectVariables
+ listSelectVariables = new ListSelect();
+ listSelectVariables.setCaption("Defined Variables");
+ listSelectVariables.setImmediate(false);
+ listSelectVariables.setWidth("100.0%");
+ listSelectVariables.setHeight("-1px");
+ mainLayout.addComponent(listSelectVariables);
+ mainLayout.setExpandRatio(listSelectVariables, 1.0f);
+
+ // textFieldVariable
+ textFieldVariable = new TextField();
+ textFieldVariable.setCaption("Variable");
+ textFieldVariable.setImmediate(false);
+ textFieldVariable.setWidth("-1px");
+ textFieldVariable.setHeight("-1px");
+ textFieldVariable.setInvalidAllowed(false);
+ textFieldVariable.setRequired(true);
+ textFieldVariable.setInputPrompt("Eg. \"12345\" or \"myVariable1\"");
+ mainLayout.addComponent(textFieldVariable);
+ mainLayout.setExpandRatio(textFieldVariable, 1.0f);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save");
+ buttonSave.setImmediate(true);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
+
+ return mainLayout;
+ }
+
+}
[16/23] incubator-openaz git commit: Ported original att source to
openaz
Posted by pd...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/RuleAlgorithms.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/RuleAlgorithms.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/RuleAlgorithms.java
new file mode 100644
index 0000000..961984e
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/RuleAlgorithms.java
@@ -0,0 +1,115 @@
+/*
+ * 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.xacml.admin.jpa;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import org.apache.openaz.xacml.api.Identifier;
+
+@Entity
+@Table(name="RuleAlgorithms")
+@NamedQuery(name="RuleAlgorithms.findAll", query="SELECT d FROM RuleAlgorithms d")
+public class RuleAlgorithms implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final char STANDARD = 'S';
+ public static final char CUSTOM = 'C';
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name="id")
+ private int id;
+
+ @Column(name="is_standard", nullable=false)
+ private char isStandard;
+
+ @Column(name="xacml_id", nullable=false, unique=true, length=255)
+ private String xacmlId;
+
+ @Column(name="short_name", nullable=false, length=64)
+ private String shortName;
+
+ public RuleAlgorithms(Identifier id, char standard) {
+ if (id != null) {
+ this.xacmlId = id.stringValue();
+ }
+ this.isStandard = standard;
+ }
+ public RuleAlgorithms(Identifier id) {
+ this(id, RuleAlgorithms.STANDARD);
+ }
+
+ public RuleAlgorithms() {
+ this(null, RuleAlgorithms.STANDARD);
+ }
+
+ public int getId() {
+ return this.id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public char getIsStandard() {
+ return this.isStandard;
+ }
+
+ public void setIsStandard(char isStandard) {
+ this.isStandard = isStandard;
+ }
+
+ @Transient
+ public boolean isStandard() {
+ return this.isStandard == RuleAlgorithms.STANDARD;
+ }
+
+ @Transient
+ public boolean isCustom() {
+ return this.isStandard == RuleAlgorithms.CUSTOM;
+ }
+
+ public String getXacmlId() {
+ return this.xacmlId;
+ }
+
+ public void setXacmlId(String xacmlId) {
+ this.xacmlId = xacmlId;
+ }
+
+ public String getShortName() {
+ return shortName;
+ }
+
+ public void setShortName(String shortName) {
+ this.shortName = shortName;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/package-info.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/package-info.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/package-info.java
new file mode 100644
index 0000000..85d06f5
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/package-info.java
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ *
+ */
+
+/**
+ *
+ */
+/**
+ * @author pameladragosh
+ *
+ */
+package org.apache.openaz.xacml.admin.jpa;
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/AttributeContainer.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/AttributeContainer.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/AttributeContainer.java
new file mode 100644
index 0000000..37d2fd4
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/AttributeContainer.java
@@ -0,0 +1,500 @@
+/*
+ * 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.xacml.admin.model;
+
+import java.lang.reflect.Method;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.jpa.Category;
+import org.apache.openaz.xacml.admin.jpa.Datatype;
+import org.apache.openaz.xacml.admin.util.JPAUtils;
+import org.apache.openaz.xacml.api.AttributeValue;
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.util.XACMLPolicyAggregator;
+import org.apache.openaz.xacml.util.XACMLPolicyScanner;
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.util.MethodProperty;
+import com.vaadin.ui.Table;
+
+public class AttributeContainer extends ItemSetChangeNotifier implements Container.Hierarchical, Container.ItemSetChangeNotifier {
+ private static final long serialVersionUID = 1L;
+ private static Log logger = LogFactory.getLog(AttributeContainer.class);
+ //private final AttributeContainer self = this;
+ private final Map<Category, Map<Datatype, Map<String, Set<ContainerAttribute>>>> mapAttributes = new HashMap<Category, Map<Datatype, Map<String, Set<ContainerAttribute>>>>();
+
+ class ContainerAttribute {
+ Path policy;
+ boolean isRoot;
+ AttributeValue<?> value;
+
+ public ContainerAttribute(Path policy, boolean isRoot, AttributeValue<?> value) {
+ this.policy = policy;
+ this.isRoot = isRoot;
+ this.value = value;
+ }
+
+ public Path getPolicy() {
+ return policy;
+ }
+
+ public boolean isRoot() {
+ return isRoot;
+ }
+
+ public AttributeValue<?> getValue() {
+ return value;
+ }
+
+ public boolean isCustom() {
+ return this.policy == null;
+ }
+ }
+ /**
+ * String identifier of an object's "id" property.
+ */
+ public static String PROPERTY_ID = "Id";
+
+ /**
+ * String identifier of an object's "category" property.
+ */
+ public static String PROPERTY_CATEGORY = "Category";
+
+ /**
+ * String identifier of an object's "datatype" property.
+ */
+ public static String PROPERTY_DATATYPE = "Datatype";
+
+ /**
+ * String identifier of an object's "value" property.
+ */
+ public static String PROPERTY_VALUES = "Values";
+
+ /**
+ * List of the string identifiers for the available properties.
+ */
+ public static Collection<String> ATTRIBUTE_PROPERTIES;
+
+ private final static Method ATTRIBUTEITEM_ID;
+ private final static Method ATTRIBUTEITEM_CATEGORY;
+ private final static Method ATTRIBUTEITEM_DATATYPE;
+ private final static Method ATTRIBUTEITEM_VALUES;
+ static {
+ ATTRIBUTE_PROPERTIES = new ArrayList<String>();
+ ATTRIBUTE_PROPERTIES.add(PROPERTY_ID);
+ ATTRIBUTE_PROPERTIES.add(PROPERTY_CATEGORY);
+ ATTRIBUTE_PROPERTIES.add(PROPERTY_DATATYPE);
+ ATTRIBUTE_PROPERTIES.add(PROPERTY_VALUES);
+ ATTRIBUTE_PROPERTIES = Collections.unmodifiableCollection(ATTRIBUTE_PROPERTIES);
+ try {
+ ATTRIBUTEITEM_ID = AttributeItem.class.getMethod("getId", new Class[]{});
+ ATTRIBUTEITEM_CATEGORY = AttributeItem.class.getMethod("getCategory", new Class[]{});
+ ATTRIBUTEITEM_DATATYPE = AttributeItem.class.getMethod("getDatatype", new Class[]{});
+ ATTRIBUTEITEM_VALUES = AttributeItem.class.getMethod("getValues", new Class[]{});
+ } catch (final NoSuchMethodException e) {
+ throw new RuntimeException("Internal error finding methods in AttributeContainer");
+ }
+ }
+
+ public AttributeContainer(Path rootPolicy, Collection<Path> referencedPolicies) {
+ super();
+ this.setContainer(this);
+ this.initialize(rootPolicy, referencedPolicies);
+ }
+
+ protected void initialize(Path rootPolicy, Collection<Path> referencedPolicies) {
+ XACMLPolicyAggregator aggregator = new XACMLPolicyAggregator();
+ //
+ // Scan the policy
+ //
+ new XACMLPolicyScanner(rootPolicy, aggregator).scan();
+ this.addAttributes(aggregator, rootPolicy, true);
+ aggregator = new XACMLPolicyAggregator();
+ //
+ // Scan the referenced policies
+ //
+ for (Path policy : referencedPolicies) {
+ new XACMLPolicyScanner(policy, aggregator).scan();
+ this.addAttributes(aggregator, policy, false);
+ aggregator = new XACMLPolicyAggregator();
+ }
+ }
+
+ protected void addAttributes(XACMLPolicyAggregator aggregator, Path policy, boolean isRoot) {
+ for (Identifier cat : aggregator.getAttributeMap().keySet()) {
+ Category category = JPAUtils.findCategory(cat);
+ if (category == null) {
+ logger.warn("Could not find category: " + cat);
+ continue;
+ }
+ if (this.mapAttributes.containsKey(category) == false) {
+ this.mapAttributes.put(category, new HashMap<Datatype, Map<String, Set<ContainerAttribute>>>());
+ }
+ Map<Datatype, Map<String, Set<ContainerAttribute>>> datatypeMap = this.mapAttributes.get(category);
+ for (Identifier dt : aggregator.getAttributeMap().get(cat).keySet()) {
+ Datatype datatype = JPAUtils.findDatatype(dt);
+ if (datatype == null) {
+ logger.warn("Could not find datatype: " + dt);
+ }
+ //
+ // Need a unique datatype object
+ //
+ datatype = new Datatype((int) System.currentTimeMillis(), datatype);
+ if (datatypeMap.containsKey(datatype) == false) {
+ datatypeMap.put(datatype, new HashMap<String, Set<ContainerAttribute>>());
+ }
+ Map<String, Set<ContainerAttribute>> attributeMap = datatypeMap.get(datatype);
+ for (Identifier id : aggregator.getAttributeMap().get(cat).get(dt).keySet()) {
+ if (attributeMap.containsKey(id.stringValue()) == false) {
+ attributeMap.put(id.stringValue(), new HashSet<ContainerAttribute>());
+ }
+ for (AttributeValue<?> attribute : aggregator.getAttributeMap().get(cat).get(dt).get(id)) {
+ attributeMap.get(id.stringValue()).add(new ContainerAttribute(policy, isRoot, attribute));
+ }
+ }
+ }
+ }
+ }
+
+ protected boolean isObjectSupported(Object itemId) {
+ if (itemId instanceof Category ||
+ itemId instanceof Datatype ||
+ itemId instanceof String ||
+ itemId instanceof ContainerAttribute) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public Item getItem(Object itemId) {
+ if (this.isObjectSupported(itemId)) {
+ return new AttributeItem(itemId);
+ }
+ return null;
+ }
+
+ @Override
+ public Collection<?> getContainerPropertyIds() {
+ return ATTRIBUTE_PROPERTIES;
+ }
+
+ @Override
+ public Collection<?> getItemIds() {
+ final Collection<Object> items = new ArrayList<Object>();
+ for (Category category : this.mapAttributes.keySet()) {
+ items.add(category);
+ for (Datatype datatype : this.mapAttributes.get(category).keySet()) {
+ items.add(datatype);
+ for (String id : this.mapAttributes.get(category).get(datatype).keySet()) {
+ items.add(id);
+ for (ContainerAttribute attribute : this.mapAttributes.get(category).get(datatype).get(id)) {
+ items.add(attribute);
+ }
+ }
+ }
+ }
+ return Collections.unmodifiableCollection(items);
+ }
+
+ @Override
+ public Property<?> getContainerProperty(Object itemId, Object propertyId) {
+ if (this.isObjectSupported(itemId) == false) {
+ return null;
+ }
+ if (propertyId.equals(PROPERTY_ID)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new AttributeItem(itemId), ATTRIBUTEITEM_ID, null);
+ }
+ if (propertyId.equals(PROPERTY_CATEGORY)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new AttributeItem(itemId), ATTRIBUTEITEM_CATEGORY, null);
+ }
+ if (propertyId.equals(PROPERTY_DATATYPE)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new AttributeItem(itemId), ATTRIBUTEITEM_DATATYPE, null);
+ }
+ if (propertyId.equals(PROPERTY_VALUES)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new AttributeItem(itemId), ATTRIBUTEITEM_VALUES, null);
+ }
+ return null;
+ }
+
+ @Override
+ public Class<?> getType(Object propertyId) {
+ if (propertyId.equals(PROPERTY_ID)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_CATEGORY)) {
+ return Category.class;
+ }
+ if (propertyId.equals(PROPERTY_DATATYPE)) {
+ return Datatype.class;
+ }
+ if (propertyId.equals(PROPERTY_VALUES)) {
+ return Table.class;
+ }
+ return null;
+ }
+
+ @Override
+ public int size() {
+ return this.mapAttributes.size();
+ }
+
+ @Override
+ public boolean containsId(Object itemId) {
+ if (this.isObjectSupported(itemId) == false) {
+ return false;
+ }
+ if (itemId instanceof Category) {
+ return this.mapAttributes.containsKey(itemId);
+ }
+ for (Category category : this.mapAttributes.keySet()) {
+ if (itemId instanceof Datatype) {
+ return this.mapAttributes.get(category).containsKey(itemId);
+ }
+ for (Datatype datatype : this.mapAttributes.get(category).keySet()) {
+ if (itemId instanceof String) {
+ return this.mapAttributes.get(category).get(datatype).containsKey(itemId);
+ }
+ for (String id : this.mapAttributes.get(category).get(datatype).keySet()) {
+ if (itemId instanceof ContainerAttribute) {
+ return this.mapAttributes.get(category).get(datatype).get(id).contains(itemId);
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public Item addItem(Object itemId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Use addItem(Category, Datatype, AttributeValue<?>) instead.");
+ }
+
+ @Override
+ public Object addItem() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Use addItem(Category, Datatype, AttributeValue<?>) instead.");
+ }
+
+ @Override
+ public boolean addContainerProperty(Object propertyId, Class<?> type,
+ Object defaultValue) throws UnsupportedOperationException {
+ return false;
+ }
+
+ @Override
+ public boolean removeContainerProperty(Object propertyId)
+ throws UnsupportedOperationException {
+ return false;
+ }
+
+ @Override
+ public boolean removeAllItems() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Can't remove all the items. You can remove custom user attributes.");
+ }
+
+ @Override
+ public Collection<?> getChildren(Object itemId) {
+ //
+ // PLD TODO - this may not work for Datatype
+ //
+ final Collection<Object> items = new ArrayList<Object>();
+ for (Category category : this.mapAttributes.keySet()) {
+ for (Datatype datatype : this.mapAttributes.get(category).keySet()) {
+ if (itemId instanceof Category) {
+ items.add(datatype);
+ }
+ for (String id : this.mapAttributes.get(category).get(datatype).keySet()) {
+ if (itemId instanceof Category ||
+ itemId instanceof Datatype) {
+ items.add(id);
+ items.addAll(this.mapAttributes.get(category).get(datatype).get(id));
+ } else if (itemId instanceof String) {
+ items.addAll(this.mapAttributes.get(category).get(datatype).get(id));
+ }
+ }
+ }
+ }
+ return Collections.unmodifiableCollection(items);
+ }
+
+ @Override
+ public Object getParent(Object itemId) {
+ if (this.isObjectSupported(itemId) == false) {
+ return null;
+ }
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<?> rootItemIds() {
+ final Collection<Object> items = new ArrayList<Object>();
+ items.add(this.mapAttributes.keySet());
+ return Collections.unmodifiableCollection(items);
+ }
+
+ @Override
+ public boolean setParent(Object itemId, Object newParentId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Can't move attributes around. Use addItem(Category, Datatype, Attribute).");
+ }
+
+ @Override
+ public boolean areChildrenAllowed(Object itemId) {
+ if (itemId instanceof Category ||
+ itemId instanceof Datatype ||
+ itemId instanceof String) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed)
+ throws UnsupportedOperationException {
+ if (itemId instanceof Category ||
+ itemId instanceof Datatype ||
+ itemId instanceof String) {
+ if (areChildrenAllowed) {
+ return true;
+ }
+ return false;
+ }
+ if (areChildrenAllowed == false) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isRoot(Object itemId) {
+ return this.mapAttributes.containsKey(itemId);
+ }
+
+ @Override
+ public boolean hasChildren(Object itemId) {
+ if (itemId instanceof ContainerAttribute) {
+ return false;
+ }
+ if (itemId instanceof Category) {
+ if (this.mapAttributes.containsKey(itemId)) {
+ return this.mapAttributes.get(itemId).size() > 0;
+ }
+ return false;
+ }
+ //
+ // PLD TODO - this may not work. Datatype may prove difficult
+ // to distinguish which category it is in.
+ //
+ for (Category category : this.mapAttributes.keySet()) {
+ if (itemId instanceof Datatype) {
+ if (this.mapAttributes.get(category).containsKey(itemId)) {
+ return this.mapAttributes.get(category).get(itemId).size() > 0;
+ }
+ continue;
+ }
+ for (Datatype datatype : this.mapAttributes.get(category).keySet()) {
+ if (itemId instanceof String) {
+ if (this.mapAttributes.get(category).get(datatype).containsKey(itemId)) {
+ return this.mapAttributes.get(category).get(datatype).get(itemId).size() > 0;
+ }
+ continue;
+ }
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean removeItem(Object itemId) throws UnsupportedOperationException {
+ if (! (itemId instanceof ContainerAttribute)) {
+ return false;
+ }
+ for (Category category : this.mapAttributes.keySet()) {
+ for (Datatype datatype : this.mapAttributes.get(category).keySet()) {
+ for (String id : this.mapAttributes.get(category).get(datatype).keySet()) {
+ if (this.mapAttributes.get(category).get(datatype).get(id).contains(itemId)) {
+ return this.mapAttributes.get(category).get(datatype).get(id).remove(itemId);
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public class AttributeItem implements Item {
+ private static final long serialVersionUID = 1L;
+ private final Object data;
+
+ public AttributeItem(Object data) {
+ this.data = data;
+ }
+
+ public String getId() {
+ return null;
+ }
+
+ public Category getCategory() {
+ return null;
+ }
+
+ public Datatype getDatatype() {
+ return null;
+ }
+
+ public Table getValues() {
+ return null;
+ }
+
+ @Override
+ public Property<?> getItemProperty(Object id) {
+ return getContainerProperty(this.data, id);
+ }
+
+ @Override
+ public Collection<?> getItemPropertyIds() {
+ return getContainerPropertyIds();
+ }
+
+ @Override
+ public boolean addItemProperty(Object id, @SuppressWarnings("rawtypes") Property property) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Attribute container does not support adding new properties");
+ }
+ @Override
+ public boolean removeItemProperty(Object id) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Attribute container does not support removing properties");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/AttributeValueContainer.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/AttributeValueContainer.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/AttributeValueContainer.java
new file mode 100644
index 0000000..1074936
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/AttributeValueContainer.java
@@ -0,0 +1,300 @@
+/*
+ * 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.xacml.admin.model;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.openaz.xacml.admin.jpa.Datatype;
+import org.apache.openaz.xacml.admin.model.AttributeContainer.ContainerAttribute;
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.util.MethodProperty;
+
+public class AttributeValueContainer extends ItemSetChangeNotifier implements Container.Ordered, Container.ItemSetChangeNotifier {
+ private static final long serialVersionUID = 1L;
+ private final Datatype datatype; //NOPMD
+ private final List<ContainerAttribute> attributes;
+
+ /**
+ * String identifier of an object's "Value" property.
+ */
+ public static String PROPERTY_VALUE = "Value";
+
+ /**
+ * String identifier of an object's "Source" property.
+ */
+ public static String PROPERTY_SOURCE = "Source";
+
+ /**
+ * List of the string identifiers for the available properties.
+ */
+ public static Collection<String> ATTRIBUTEVALUE_PROPERTIES;
+
+ private final static Method ATTRIBUTEVALUEITEM_VALUE;
+ private final static Method ATTRIBUTEVALUEITEM_SOURCE;
+ static {
+ ATTRIBUTEVALUE_PROPERTIES = new ArrayList<String>();
+ ATTRIBUTEVALUE_PROPERTIES.add(PROPERTY_VALUE);
+ ATTRIBUTEVALUE_PROPERTIES.add(PROPERTY_SOURCE);
+ ATTRIBUTEVALUE_PROPERTIES = Collections.unmodifiableCollection(ATTRIBUTEVALUE_PROPERTIES);
+ try {
+ ATTRIBUTEVALUEITEM_VALUE = AttributeValueItem.class.getMethod("getValue", new Class[]{});
+ ATTRIBUTEVALUEITEM_SOURCE = AttributeValueItem.class.getMethod("getSource", new Class[]{});
+ } catch (final NoSuchMethodException e) {
+ throw new RuntimeException("Internal error finding methods in AttributeValueContainer");
+ }
+ }
+
+ public AttributeValueContainer(Datatype datatype, List<ContainerAttribute> attributes) {
+ this.datatype = datatype;
+ this.attributes = attributes;
+ }
+
+ public boolean isObjectSupported(Object itemId) {
+ return itemId instanceof ContainerAttribute;
+ }
+
+ @Override
+ public Item getItem(Object itemId) {
+ if (itemId instanceof ContainerAttribute) {
+ return new AttributeValueItem((ContainerAttribute) itemId);
+ }
+ return null;
+ }
+
+ @Override
+ public Collection<?> getContainerPropertyIds() {
+ return ATTRIBUTEVALUE_PROPERTIES;
+ }
+
+ @Override
+ public Collection<?> getItemIds() {
+ return Collections.unmodifiableList(this.attributes);
+ }
+
+ @Override
+ public Property<?> getContainerProperty(Object itemId, Object propertyId) {
+ if (this.isObjectSupported(itemId) == false) {
+ return null;
+ }
+ if (propertyId.equals(PROPERTY_VALUE)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new AttributeValueItem((ContainerAttribute) itemId), ATTRIBUTEVALUEITEM_VALUE, null);
+ }
+
+ if (propertyId.equals(PROPERTY_SOURCE)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new AttributeValueItem((ContainerAttribute) itemId), ATTRIBUTEVALUEITEM_SOURCE, null);
+ }
+ return null;
+ }
+
+ @Override
+ public Class<?> getType(Object propertyId) {
+ if (propertyId.equals(PROPERTY_VALUE)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_SOURCE)) {
+ return String.class;
+ }
+ return null;
+ }
+
+ @Override
+ public int size() {
+ return this.attributes.size();
+ }
+
+ @Override
+ public boolean containsId(Object itemId) {
+ return this.attributes.contains(itemId);
+ }
+
+ @Override
+ public Item addItem(Object itemId) throws UnsupportedOperationException {
+ if (this.isObjectSupported(itemId) == false) {
+ return null;
+ }
+ return new AttributeValueItem((ContainerAttribute) itemId);
+ }
+
+ @Override
+ public Object addItem() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Please use addItem(Object itemId) - setup the container attribute first.");
+ }
+
+ @Override
+ public boolean removeItem(Object itemId) throws UnsupportedOperationException {
+ if (this.isObjectSupported(itemId) == false) {
+ return false;
+ }
+ throw new UnsupportedOperationException("TODO");
+// return this.attributes.remove(itemId);
+ }
+
+ @Override
+ public boolean addContainerProperty(Object propertyId, Class<?> type,
+ Object defaultValue) throws UnsupportedOperationException {
+ return false;
+ }
+
+ @Override
+ public boolean removeContainerProperty(Object propertyId)
+ throws UnsupportedOperationException {
+ return false;
+ }
+
+ @Override
+ public boolean removeAllItems() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("TODO");
+// this.attributes.clear();
+// return true;
+ }
+
+ @Override
+ public Object nextItemId(Object itemId) {
+ if (this.isObjectSupported(itemId) == false) {
+ return null;
+ }
+ int index = this.getItemIndex((ContainerAttribute) itemId);
+ if (index == -1 || index >= this.attributes.size()) {
+ return null;
+ }
+ return this.attributes.get(index + 1);
+ }
+
+ @Override
+ public Object prevItemId(Object itemId) {
+ if (this.isObjectSupported(itemId) == false) {
+ return null;
+ }
+ int index = this.getItemIndex((ContainerAttribute) itemId);
+ if (index == -1 || index == 0) {
+ return null;
+ }
+ return this.attributes.get(index - 1);
+ }
+
+ @Override
+ public Object firstItemId() {
+ if (this.attributes.size() > 0) {
+ return this.attributes.get(0);
+ }
+ return null;
+ }
+
+ @Override
+ public Object lastItemId() {
+ if (this.attributes.size() > 0) {
+ return this.attributes.get(this.attributes.size() - 1);
+ }
+ return null;
+ }
+
+ @Override
+ public boolean isFirstId(Object itemId) {
+ if (this.attributes.size() > 0) {
+ return this.attributes.get(0).equals(itemId);
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isLastId(Object itemId) {
+ if (this.attributes.size() > 0) {
+ return this.attributes.get(this.attributes.size() - 1).equals(itemId);
+ }
+ return false;
+ }
+
+ @Override
+ public Object addItemAfter(Object previousItemId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Use addItemAfter(Object previousItemId, Object newItemId) - please create the object yourself.");
+ }
+
+ @Override
+ public Item addItemAfter(Object previousItemId, Object newItemId) throws UnsupportedOperationException {
+ if (this.isObjectSupported(previousItemId) == false || this.isObjectSupported(newItemId) == false) {
+ return null;
+ }
+ int index = this.getItemIndex((ContainerAttribute) previousItemId);
+ if (index >= 0) {
+ this.attributes.add(index, (ContainerAttribute) newItemId);
+ }
+ return null;
+ }
+
+ protected int getItemIndex(ContainerAttribute itemId) {
+ int index;
+ for (index = 0; index < this.attributes.size(); index++) {
+ if (this.attributes.get(index).equals(itemId)) {
+ return index;
+ }
+ }
+ return -1;
+ }
+
+ public class AttributeValueItem implements Item {
+ private static final long serialVersionUID = 1L;
+ private final ContainerAttribute attribute;
+
+ public AttributeValueItem(ContainerAttribute attribute) {
+ this.attribute = attribute;
+ }
+
+ public String getValue() {
+ if (this.attribute == null) {
+ return null;
+ }
+ return this.attribute.value.toString();
+ }
+
+ public String getSource() {
+ if (this.attribute == null) {
+ return null;
+ }
+ return this.attribute.value.toString();
+ }
+
+ @Override
+ public Property<?> getItemProperty(Object id) {
+ return getContainerProperty(this.attribute, id);
+ }
+ @Override
+ public Collection<?> getItemPropertyIds() {
+ return getContainerPropertyIds();
+ }
+ @Override
+ public boolean addItemProperty(Object id, @SuppressWarnings("rawtypes") Property property) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Attribute Value container does not support adding new properties");
+ }
+ @Override
+ public boolean removeItemProperty(Object id) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Attribute Value container does not support removing properties");
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/ExpressionContainer.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/ExpressionContainer.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/ExpressionContainer.java
new file mode 100644
index 0000000..30c8670
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/ExpressionContainer.java
@@ -0,0 +1,1215 @@
+/*
+ * 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.xacml.admin.model;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.bind.JAXBElement;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeAssignmentExpressionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeSelectorType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ConditionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ExpressionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.FunctionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObjectFactory;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableDefinitionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableReferenceType;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.jpa.FunctionArgument;
+import org.apache.openaz.xacml.admin.jpa.FunctionDefinition;
+import org.apache.openaz.xacml.admin.util.JPAUtils;
+import org.apache.openaz.xacml.admin.util.XACMLFunctionValidator;
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.util.MethodProperty;
+
+public class ExpressionContainer extends ItemSetChangeNotifier implements Container.Hierarchical, Container.ItemSetChangeNotifier {
+ private static final long serialVersionUID = 1L;
+ private static Log logger = LogFactory.getLog(ExpressionContainer.class);
+
+ /**
+ * String identifier of a file's "name" property.
+ */
+ public static String PROPERTY_NAME = "Name";
+
+ /**
+ * String identifier of an object's "id" property.
+ */
+ public static String PROPERTY_ID = "Id";
+
+ /**
+ * String identifier of an object's "datatype" property.
+ */
+ public static String PROPERTY_DATATYPE_SHORT = "shortDatatype";
+
+ /**
+ * String identifier of an object's "id" property.
+ */
+ public static String PROPERTY_ID_SHORT = "shortId";
+
+ /**
+ * String identifier of an object's "datatype" property.
+ */
+ public static String PROPERTY_DATATYPE = "Datatype";
+
+ /**
+ * List of the string identifiers for the available properties.
+ */
+ public static Collection<String> EXPRESSION_PROPERTIES;
+
+ private final static Method EXPRESSIONITEM_NAME;
+
+ private final static Method EXPRESSIONITEM_ID;
+
+ private final static Method EXPRESSIONITEM_DATATYPE;
+
+ private final static Method EXPRESSIONITEM_ID_SHORT;
+
+ private final static Method EXPRESSIONITEM_DATATYPE_SHORT;
+
+ static {
+ EXPRESSION_PROPERTIES = new ArrayList<String>();
+ EXPRESSION_PROPERTIES.add(PROPERTY_NAME);
+ EXPRESSION_PROPERTIES.add(PROPERTY_ID);
+ EXPRESSION_PROPERTIES.add(PROPERTY_DATATYPE);
+ EXPRESSION_PROPERTIES.add(PROPERTY_ID_SHORT);
+ EXPRESSION_PROPERTIES.add(PROPERTY_DATATYPE_SHORT);
+ EXPRESSION_PROPERTIES = Collections.unmodifiableCollection(EXPRESSION_PROPERTIES);
+ try {
+ EXPRESSIONITEM_NAME = ExpressionItem.class.getMethod("getName", new Class[]{});
+ EXPRESSIONITEM_ID = ExpressionItem.class.getMethod("getId", new Class[]{});
+ EXPRESSIONITEM_DATATYPE = ExpressionItem.class.getMethod("getDatatype", new Class[]{});
+ EXPRESSIONITEM_ID_SHORT = ExpressionItem.class.getMethod("getIdShort", new Class[]{});
+ EXPRESSIONITEM_DATATYPE_SHORT = ExpressionItem.class.getMethod("getDatatypeShort", new Class[]{});
+ } catch (final NoSuchMethodException e) {
+ throw new RuntimeException(
+ "Internal error finding methods in PolicyContainer");
+ }
+ }
+
+ protected class ApplyParent {
+ ApplyType apply;
+ FunctionArgument argument;
+
+ public ApplyParent(ApplyType apply, FunctionArgument argument) {
+ this.apply = apply;
+ this.argument = argument;
+ }
+
+ public ApplyType getApply() {
+ return apply;
+ }
+
+ public void setApply(ApplyType apply) {
+ this.apply = apply;
+ }
+
+ public FunctionArgument getArgument() {
+ return argument;
+ }
+
+ public void setArgument(FunctionArgument argument) {
+ this.argument = argument;
+ }
+ }
+ //
+ // Our parent object information and which argument we are
+ // from our parent (relevant to the Apply).
+ //
+ private final Object parent;
+ private final FunctionArgument argument;
+ //
+ // The root object of the expression
+ //
+ private Object root;
+ //
+ // Our helper tables for organization purposes and to
+ // make sure the correct functions/datatypes are being
+ // setup.
+ //
+ private Map<ApplyType, ApplyParent> applys = new HashMap<ApplyType, ApplyParent>();
+ private Map<FunctionType, ApplyParent> functions = new HashMap<FunctionType, ApplyParent>();
+ private Map<AttributeValueType, ApplyParent> values = new HashMap<AttributeValueType, ApplyParent>();
+ private Map<AttributeDesignatorType, ApplyParent> designators = new HashMap<AttributeDesignatorType, ApplyParent>();
+ private Map<AttributeSelectorType, ApplyParent> selectors = new HashMap<AttributeSelectorType, ApplyParent>();
+ private Map<VariableReferenceType, ApplyParent> variables = new HashMap<VariableReferenceType, ApplyParent>();
+ private Map<ExpressionType, ApplyParent> expressions = new HashMap<ExpressionType, ApplyParent>();
+
+ public ExpressionContainer(Object parent, Object root, FunctionArgument argument) {
+ super();
+ this.setContainer(this);
+ this.parent = parent;
+ this.root = root;
+ this.argument = argument;
+ this.initialize();
+ }
+
+ private void initialize() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Initializing: " + this.parent + " " + this.argument + " " + this.root);
+ }
+ //
+ // Make sure we support the parent object
+ //
+ @SuppressWarnings("unused")
+ JAXBElement<?> rootElement = null;
+ if (this.parent instanceof ConditionType) {
+ rootElement = ((ConditionType) this.parent).getExpression();
+ } else if (this.parent instanceof VariableDefinitionType) {
+ rootElement = ((VariableDefinitionType) this.parent).getExpression();
+ } else if (this.parent instanceof AttributeAssignmentExpressionType) {
+ rootElement = ((AttributeAssignmentExpressionType) this.parent).getExpression();
+ } else if (this.parent instanceof ApplyType) {
+ //
+ // They must tell us which argument we are
+ //
+ if (this.argument == null) {
+ throw new IllegalArgumentException("Must supply Argument object when editing a parent ApplyType's child node");
+ }
+ //
+ // Finish the initialization
+ //
+ this.initializeRoot();
+ } else {
+ throw new IllegalArgumentException("Unsupported Parent Object: " + this.parent.getClass().getCanonicalName());
+ }
+ /*
+ //
+ // Check if there actually is a root
+ //
+ if (rootElement == null || rootElement.getValue() == null) {
+ //
+ // Creating a new one
+ //
+ return;
+ }
+ //
+ // Save the root
+ //
+ this.root = rootElement.getValue();
+ */
+ //
+ // Finish initializing
+ //
+ this.initializeRoot();
+ }
+
+ private void initializeRoot() {
+ //
+ // Sanity check
+ //
+ if (this.root == null) {
+ return;
+ }
+ //
+ // Figure out the expression type
+ //
+ if (this.root instanceof ApplyType) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Root Is Apply");
+ }
+ //
+ // Save it
+ //
+ this.applys.put((ApplyType) this.root, null);
+ //
+ // Determine the function for this Apply
+ //
+ Map<String, FunctionDefinition> functions = JPAUtils.getFunctionIDMap();
+ FunctionDefinition function = functions.get(((ApplyType) this.root).getFunctionId());
+ if (function == null) {
+ logger.warn("root apply does not have a function defined");
+ return;
+ }
+ //
+ // Bring in its children
+ //
+ this.initializeChildren((ApplyType) this.root, function);
+ } else if (this.root instanceof AttributeValueType) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Root Is Attribute Value");
+ }
+ //
+ // Save it
+ //
+ this.values.put((AttributeValueType) this.root, null);
+ } else if (this.root instanceof AttributeDesignatorType) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Root Is Attribute Designator");
+ }
+ //
+ // Save it
+ //
+ this.designators.put((AttributeDesignatorType) this.root, null);
+ } else if (this.root instanceof AttributeSelectorType) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Root Is Attribute Selector");
+ }
+ //
+ // Save it
+ //
+ this.selectors.put((AttributeSelectorType) this.root, null);
+ } else if (this.root instanceof VariableReferenceType) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Root Is Variable Reference");
+ }
+ //
+ // Save it
+ //
+ this.variables.put((VariableReferenceType) this.root, null);
+ } else if (this.root instanceof FunctionType) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Root Is Function");
+ }
+ //
+ // Save it - Really? I don't think the root would ever be a function.
+ //
+ this.functions.put((FunctionType) this.root, null);
+ } else {
+ throw new IllegalArgumentException("Unsupported Expression Root Item: " + this.root.getClass().getCanonicalName());
+ }
+ }
+
+ private void initializeChildren(ApplyType apply, FunctionDefinition function) {
+ int index = 1;
+ for (JAXBElement<?> child : apply.getExpression()) {
+ //
+ // Validate the child
+ //
+ if (child.getValue() == null) {
+ logger.warn("child element " + index + "has a null object.");
+ index++;
+ continue;
+ }
+ if (logger.isTraceEnabled()) {
+ logger.trace("Child " + index + " is " + child.getValue());
+ }
+ //
+ // Get the argument for this child
+ //
+ if (function == null) {
+ throw new IllegalArgumentException("Apply has children but no function defined.");
+ }
+ FunctionArgument argument = XACMLFunctionValidator.getFunctionArgument(index, function);
+ if (logger.isTraceEnabled()) {
+ logger.trace("Child's argument is: " + argument);
+ }
+ if (argument == null) {
+ //throw new Exception("Unable to find function argument: " + index + " " + function.getId() + " " + function.getShortname());
+ return;
+ }
+ //
+ // See if its another apply type
+ //
+ if (child.getValue() instanceof ApplyType) {
+ //
+ // Save it
+ //
+ this.applys.put((ApplyType) child.getValue(), new ApplyParent(apply, argument));
+ //
+ // Get its function information
+ //
+ Map<String, FunctionDefinition> functions = JPAUtils.getFunctionIDMap();
+ FunctionDefinition childFunction = functions.get(((ApplyType) child.getValue()).getFunctionId());
+ if (childFunction == null) {
+ logger.warn("Apply object " + index + " does not have a function defined");
+ } else {
+ //
+ // Bring in its children
+ //
+ this.initializeChildren((ApplyType) child.getValue(), childFunction);
+ }
+ } else if (child.getValue() instanceof AttributeValueType) {
+ //
+ // Save it
+ //
+ this.values.put((AttributeValueType) child.getValue(), new ApplyParent(apply, argument));
+ } else if (child.getValue() instanceof AttributeDesignatorType) {
+ //
+ // Save it
+ //
+ this.designators.put((AttributeDesignatorType) child.getValue(), new ApplyParent(apply, argument));
+ } else if (child.getValue() instanceof AttributeSelectorType) {
+ //
+ // Save it
+ //
+ this.selectors.put((AttributeSelectorType) child.getValue(), new ApplyParent(apply, argument));
+ } else if (child.getValue() instanceof VariableReferenceType) {
+ //
+ // Save it
+ //
+ this.variables.put((VariableReferenceType) child.getValue(), new ApplyParent(apply, argument));
+ } else if (child.getValue() instanceof FunctionType) {
+ //
+ // Save it
+ //
+ this.functions.put((FunctionType) child.getValue(), new ApplyParent(apply, argument));
+ } else if (child.getValue() instanceof ExpressionType) {
+ //
+ // Save it
+ //
+ this.expressions.put((ExpressionType) child.getValue(), new ApplyParent(apply, argument));
+ } else {
+ logger.error("Unknown child type: " + child.getClass().getCanonicalName());
+ }
+ index++;
+ }
+ }
+
+ protected boolean isObjectSupported(Object itemId) {
+ if (itemId instanceof ApplyType ||
+ itemId instanceof AttributeValueType ||
+ itemId instanceof AttributeDesignatorType ||
+ itemId instanceof AttributeSelectorType ||
+ itemId instanceof VariableReferenceType ||
+ itemId instanceof FunctionType ||
+ itemId instanceof ExpressionType) {
+ return true;
+ }
+ return false;
+ }
+
+ protected boolean isParentObjectSupport(Object parent) {
+ if (parent instanceof ApplyType ||
+ parent instanceof ConditionType ||
+ parent instanceof VariableDefinitionType ||
+ parent instanceof AttributeAssignmentExpressionType) {
+ return true;
+ }
+ return false;
+ }
+
+ public void updateItem(Object itemId) {
+ //
+ // Sanity check
+ //
+ if (this.isObjectSupported(itemId) == false) {
+ return;// null;
+ }
+ //
+ // Notify - the real reason for this function
+ //
+ this.fireItemSetChange();
+ //
+ // Return the item
+ //
+ //return new ExpressionItem(itemId);
+ }
+
+ @Override
+ public Item getItem(Object itemId) {
+ if (this.isObjectSupported(itemId) == false) {
+ return null;
+ }
+ return new ExpressionItem(itemId);
+ }
+
+ @Override
+ public Collection<?> getContainerPropertyIds() {
+ return EXPRESSION_PROPERTIES;
+ }
+
+ @Override
+ public Collection<?> getItemIds() {
+ final Collection<Object> items = new ArrayList<Object>();
+ if (this.root != null) {
+ //
+ // Add the root object
+ //
+ items.add(this.root);
+ //
+ // If its an apply, it could have children
+ //
+ if (this.root instanceof ApplyType) {
+ items.add(this.getChildrenIds((ApplyType) this.root, true));
+ }
+ }
+ if (logger.isTraceEnabled()) {
+ logger.trace("getItemIds (" + items.size() + "):" + items);
+ }
+ return Collections.unmodifiableCollection(items);
+ }
+
+ protected Collection<?> getChildrenIds(ApplyType apply, boolean recursive) {
+ Collection<Object> items = new ArrayList<Object>();
+ for (JAXBElement<?> child : apply.getExpression()) {
+ //
+ // Make sure there's a value
+ //
+ if (child.getValue() == null) {
+ continue;
+ }
+ //
+ // What kind is it?
+ //
+ if (child.getValue() instanceof ApplyType) {
+ items.add(child.getValue());
+ //
+ // Do we add its children?
+ //
+ if (recursive) {
+ items.addAll(this.getChildrenIds((ApplyType) child.getValue(), true));
+ }
+ } else if (child.getValue() instanceof AttributeValueType) {
+ items.add(child.getValue());
+ } else if (child.getValue() instanceof AttributeDesignatorType) {
+ items.add(child.getValue());
+ } else if (child.getValue() instanceof AttributeSelectorType) {
+ items.add(child.getValue());
+ } else if (child.getValue() instanceof VariableReferenceType) {
+ items.add(child.getValue());
+ } else if (child.getValue() instanceof FunctionType) {
+ items.add(child.getValue());
+ } else if (child.getValue() instanceof ExpressionType) {
+ items.add(child.getValue());
+ }
+ }
+ if (logger.isTraceEnabled()) {
+ logger.trace("getChildrenIds " + apply.getFunctionId() + " (" + items.size() + "):" + items);
+ }
+ return items;
+ }
+
+ @Override
+ public Property<?> getContainerProperty(Object itemId, Object propertyId) {
+ if (this.isObjectSupported(itemId) == false) {
+ return null;
+ }
+ if (propertyId.equals(PROPERTY_NAME)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new ExpressionItem(itemId), EXPRESSIONITEM_NAME, null);
+ }
+
+ if (propertyId.equals(PROPERTY_ID)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new ExpressionItem(itemId), EXPRESSIONITEM_ID, null);
+ }
+
+ if (propertyId.equals(PROPERTY_DATATYPE)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new ExpressionItem(itemId), EXPRESSIONITEM_DATATYPE, null);
+ }
+
+ if (propertyId.equals(PROPERTY_ID_SHORT)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new ExpressionItem(itemId), EXPRESSIONITEM_ID_SHORT, null);
+ }
+
+ if (propertyId.equals(PROPERTY_DATATYPE_SHORT)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new ExpressionItem(itemId), EXPRESSIONITEM_DATATYPE_SHORT, null);
+ }
+
+ return null;
+ }
+
+ @Override
+ public Class<?> getType(Object propertyId) {
+ if (propertyId.equals(PROPERTY_NAME)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_ID)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_DATATYPE)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_ID_SHORT)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_DATATYPE_SHORT)) {
+ return String.class;
+ }
+ return null;
+ }
+
+ @Override
+ public int size() {
+ int size = 0;
+ size += this.applys.size();
+ size += this.designators.size();
+ size += this.functions.size();
+ size += this.selectors.size();
+ size += this.values.size();
+ size += this.variables.size();
+ size += this.expressions.size();
+ return size;
+ }
+
+ @Override
+ public boolean containsId(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("containsId: " + itemId);
+ }
+ if (itemId instanceof ApplyType) {
+ return this.applys.containsKey(itemId);
+ }
+ if (itemId instanceof AttributeValueType) {
+ return this.values.containsKey(itemId);
+ }
+ if (itemId instanceof AttributeDesignatorType) {
+ return this.designators.containsKey(itemId);
+ }
+ if (itemId instanceof AttributeSelectorType) {
+ return this.selectors.containsKey(itemId);
+ }
+ if (itemId instanceof VariableReferenceType) {
+ return this.variables.containsKey(itemId);
+ }
+ if (itemId instanceof FunctionType) {
+ return this.functions.containsKey(itemId);
+ }
+ if (itemId instanceof ExpressionType) {
+ return this.expressions.containsKey(itemId);
+ }
+ return false;
+ }
+
+ @Override
+ public Item addItem(Object itemId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Please use the addItem(Object, Object) method instead.");
+ }
+
+ @Override
+ public Object addItem() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("use addItem(Object itemId)");
+ }
+
+ public Item addItem(Object itemId, ApplyType parent, FunctionArgument argument) throws UnsupportedOperationException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("addItem: " + itemId + " " + parent + " " + argument);
+ }
+ //
+ // Make sure we support the object
+ //
+ if (this.isObjectSupported(itemId) == false) {
+ return null;
+ }
+ //
+ // Is is a root?
+ //
+ if (parent == null) {
+ //
+ // Setting root
+ //
+ if (this.root != null) {
+ throw new UnsupportedOperationException("Cannot add another root item. Remove the current root first.");
+ }
+ //
+ // Save the root information
+ //
+ this.root = itemId;
+ //
+ // Add its children
+ //
+ this.initializeRoot();
+ //
+ // Add it to our root container
+ //
+ if (this.parent instanceof ApplyType) {
+ ((ApplyType) this.parent).getExpression().add(this.createElement(this.root));
+ } else if (this.parent instanceof ConditionType) {
+ ((ConditionType) this.parent).setExpression(this.createElement(this.root));
+ } else if (this.parent instanceof VariableDefinitionType) {
+ ((VariableDefinitionType) this.parent).setExpression(this.createElement(this.root));
+ } else if (this.parent instanceof AttributeAssignmentExpressionType) {
+ ((AttributeAssignmentExpressionType) this.parent).setExpression(this.createElement(this.root));
+ } else {
+ logger.error("unknown parent class: " + this.parent.getClass().getCanonicalName());
+ }
+ //
+ // Notify that we changed
+ //
+ this.fireItemSetChange();
+ //
+ // Return new item
+ //
+ return new ExpressionItem(this.root);
+ }
+ //
+ // Check what kind of item this is
+ //
+ if (itemId instanceof ApplyType) {
+ //
+ this.applys.put((ApplyType) itemId, new ApplyParent(parent, argument));
+ ((ApplyType) parent).getExpression().add(new ObjectFactory().createApply((ApplyType) itemId));
+ //
+ // Get its function information
+ //
+ Map<String, FunctionDefinition> functions = JPAUtils.getFunctionIDMap();
+ FunctionDefinition childFunction = functions.get(((ApplyType) itemId).getFunctionId());
+ if (childFunction == null) {
+ //
+ // NO function defined
+ //
+ logger.warn("no function defined for apply being added.");
+ } else {
+ //
+ // Add its children
+ //
+ this.initializeChildren((ApplyType) itemId, childFunction);
+ }
+ } else if (itemId instanceof AttributeValueType) {
+ //
+ this.values.put((AttributeValueType) itemId, new ApplyParent(parent, argument));
+ parent.getExpression().add(new ObjectFactory().createAttributeValue((AttributeValueType) itemId));
+ //
+ } else if (itemId instanceof AttributeDesignatorType) {
+ //
+ this.designators.put((AttributeDesignatorType) itemId, new ApplyParent(parent, argument));
+ parent.getExpression().add(new ObjectFactory().createAttributeDesignator((AttributeDesignatorType) itemId));
+ //
+ } else if (itemId instanceof AttributeSelectorType) {
+ //
+ this.selectors.put((AttributeSelectorType) itemId, new ApplyParent(parent, argument));
+ parent.getExpression().add(new ObjectFactory().createAttributeSelector((AttributeSelectorType) itemId));
+ //
+ } else if (itemId instanceof VariableReferenceType) {
+ //
+ this.variables.put((VariableReferenceType) itemId, new ApplyParent(parent, argument));
+ parent.getExpression().add(new ObjectFactory().createVariableReference((VariableReferenceType) itemId));
+ //
+ } else if (itemId instanceof FunctionType) {
+ //
+ this.functions.put((FunctionType) itemId, new ApplyParent(parent, argument));
+ parent.getExpression().add(new ObjectFactory().createFunction((FunctionType) itemId));
+ //
+ } else if (itemId instanceof ExpressionType) {
+ //
+ this.expressions.put((ExpressionType) itemId, new ApplyParent(parent, argument));
+ parent.getExpression().add(new ObjectFactory().createExpression((ExpressionType) itemId));
+ } else {
+ logger.error("unknown itemId class: " + itemId.getClass().getCanonicalName());
+ return null;
+ }
+ //
+ // Notify
+ //
+ this.fireItemSetChange();
+ return new ExpressionItem(itemId);
+ }
+
+ private JAXBElement<?> createElement(Object item) {
+ if (item instanceof ApplyType) {
+ return new ObjectFactory().createApply((ApplyType) item);
+ } else if (item instanceof AttributeValueType) {
+ return new ObjectFactory().createAttributeValue((AttributeValueType) item);
+ } else if (item instanceof AttributeDesignatorType) {
+ return new ObjectFactory().createAttributeDesignator((AttributeDesignatorType) item);
+ } else if (item instanceof AttributeSelectorType) {
+ return new ObjectFactory().createAttributeSelector((AttributeSelectorType) item);
+ } else if (item instanceof VariableReferenceType) {
+ return new ObjectFactory().createVariableReference((VariableReferenceType) item);
+ } else if (item instanceof FunctionType) {
+ return new ObjectFactory().createFunction((FunctionType) item);
+ } else if (item instanceof ExpressionType) {
+ return new ObjectFactory().createExpression((ExpressionType) item);
+ }
+ return null;
+ }
+
+ @Override
+ public boolean addContainerProperty(Object propertyId, Class<?> type,
+ Object defaultValue) throws UnsupportedOperationException {
+ return false;
+ }
+
+ @Override
+ public boolean removeContainerProperty(Object propertyId)
+ throws UnsupportedOperationException {
+ return false;
+ }
+
+ @Override
+ public boolean removeAllItems() throws UnsupportedOperationException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("removeAllItems: ");
+ }
+ boolean result = this.doRemoveAllItems();
+ if (result == false) {
+ return false;
+ }
+ //
+ // Notify
+ //
+ this.fireItemSetChange();
+ //
+ // Done
+ //
+ return true;
+ }
+
+ public boolean doRemoveAllItems() throws UnsupportedOperationException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("doRemoveAllItems: ");
+ }
+ //
+ // Removing the root item, make sure its removed from
+ // the parent.
+ //
+ if (this.parent instanceof ConditionType) {
+ ((ConditionType) this.parent).setExpression(null);
+ } else if (this.parent instanceof VariableDefinitionType) {
+ ((VariableDefinitionType) this.parent).setExpression(null);
+ } else if (this.parent instanceof AttributeAssignmentExpressionType) {
+ ((AttributeAssignmentExpressionType) this.parent).setExpression(null);
+ } else if (this.parent instanceof ApplyType) {
+ //
+ // TODO ?? Special case
+ //
+ return false;
+ } else {
+ return false;
+ }
+ //
+ // Null our root
+ //
+ this.root = null;
+ //
+ // Clear out our maps
+ //
+ this.applys.clear();
+ this.designators.clear();
+ this.functions.clear();
+ this.values.clear();
+ this.selectors.clear();
+ this.variables.clear();
+ this.expressions.clear();
+ //
+ // Done
+ //
+ return true;
+ }
+
+ @Override
+ public Collection<?> getChildren(Object itemId) {
+ final Collection<Object> items = new ArrayList<Object>();
+ if (itemId instanceof ApplyType) {
+ items.addAll(this.getChildrenIds((ApplyType) itemId, false));
+ }
+ if (logger.isTraceEnabled()) {
+ logger.trace("getChildren " + itemId + " (" + items.size() + "):" + items);
+ }
+ return Collections.unmodifiableCollection(items);
+ }
+
+ public FunctionArgument getArgument(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getArgument: " + itemId);
+ }
+ //
+ // First check if its a root
+ //
+ if (this.isRoot(itemId)) {
+ return null;
+ }
+ //
+ // Not a root - should be in the maps
+ //
+ if (itemId instanceof ApplyType) {
+ return this.applys.get(itemId).getArgument();
+ }
+ if (itemId instanceof AttributeValueType) {
+ return this.values.get(itemId).getArgument();
+ }
+ if (itemId instanceof AttributeDesignatorType) {
+ return this.designators.get(itemId).getArgument();
+ }
+ if (itemId instanceof AttributeSelectorType) {
+ return this.selectors.get(itemId).getArgument();
+ }
+ if (itemId instanceof VariableReferenceType) {
+ return this.variables.get(itemId).getArgument();
+ }
+ if (itemId instanceof FunctionType) {
+ return this.functions.get(itemId).getArgument();
+ }
+ if (itemId instanceof ExpressionType) {
+ return this.expressions.get(itemId).getArgument();
+ }
+ return null;
+ }
+
+ @Override
+ public Object getParent(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getParent: " + itemId);
+ }
+ //
+ // First check if its a root
+ //
+ if (this.isRoot(itemId)) {
+ return null;
+ }
+ //
+ // Not a root - should be in the maps
+ //
+ if (itemId instanceof ApplyType) {
+ return this.applys.get(itemId).getApply();
+ }
+ if (itemId instanceof AttributeValueType) {
+ return this.values.get(itemId).getApply();
+ }
+ if (itemId instanceof AttributeDesignatorType) {
+ return this.designators.get(itemId).getApply();
+ }
+ if (itemId instanceof AttributeSelectorType) {
+ return this.selectors.get(itemId).getApply();
+ }
+ if (itemId instanceof VariableReferenceType) {
+ return this.variables.get(itemId).getApply();
+ }
+ if (itemId instanceof FunctionType) {
+ return this.functions.get(itemId).getApply();
+ }
+ if (itemId instanceof ExpressionType) {
+ return this.expressions.get(itemId).getApply();
+ }
+ return null;
+ }
+
+ @Override
+ public Collection<?> rootItemIds() {
+ final Collection<Object> items = new ArrayList<Object>();
+ if (this.root != null) {
+ items.add(this.root);
+ }
+ if (logger.isTraceEnabled()) {
+ logger.trace("rootItemIds " + " (" + items.size() + "):" + items);
+ }
+ return Collections.unmodifiableCollection(items);
+ }
+
+ @Override
+ public boolean setParent(Object itemId, Object newParentId) throws UnsupportedOperationException {
+ //
+ // TODO we can support this later
+ //
+ throw new UnsupportedOperationException("Should we support this? Can be tricky. Most likely user dragging an item from one area to another. For now, use removeItem, addItem.");
+ }
+
+ @Override
+ public boolean areChildrenAllowed(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("areChildrenAllowed: " + itemId);
+ }
+ if (itemId instanceof ApplyType) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed)
+ throws UnsupportedOperationException {
+ if (itemId instanceof ApplyType && areChildrenAllowed) {
+ return true;
+ }
+ if (! areChildrenAllowed) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isRoot(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("isRoot: " + itemId);
+ }
+ if (itemId == null) {
+ logger.error("isRoot itemId is NULL");
+ }
+ return this.root == itemId;
+ }
+
+ @Override
+ public boolean hasChildren(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("hasChildren: " + itemId);
+ }
+ if (itemId instanceof ApplyType) {
+ return ((ApplyType)itemId).getExpression().size() > 0;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean removeItem(Object itemId) throws UnsupportedOperationException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("removeItem: " + itemId);
+ }
+ //
+ // Check if they are removing the root
+ //
+ if (this.root == itemId) {
+ //
+ // Removing the root item, make sure its removed from
+ // the parent.
+ //
+ boolean result = this.doRemoveAllItems();
+ if (result == false) {
+ return false;
+ }
+ //
+ // Notify
+ //
+ this.fireItemSetChange();
+ return true;
+ }
+ //
+ // There should be a parent
+ //
+ ApplyParent parent = null;
+ //
+ // Remove the item from the maps
+ //
+ if (itemId instanceof ApplyType) {
+ parent = this.applys.get(itemId);
+ if (parent == null) {
+ return false;
+ }
+ if (this.applys.remove(itemId) == null) {
+ return false;
+ }
+ } else if (itemId instanceof AttributeValueType) {
+ parent = this.values.get(itemId);
+ if (this.values.remove(itemId) == null) {
+ return false;
+ }
+ } else if (itemId instanceof AttributeDesignatorType) {
+ parent = this.designators.get(itemId);
+ if (this.designators.remove(itemId) == null) {
+ return false;
+ }
+ } else if (itemId instanceof AttributeSelectorType) {
+ parent = this.selectors.get(itemId);
+ if (this.selectors.remove(itemId) == null) {
+ return false;
+ }
+ } else if (itemId instanceof VariableReferenceType) {
+ parent = this.variables.get(itemId);
+ if (this.variables.remove(itemId) == null) {
+ return false;
+ }
+ } else if (itemId instanceof FunctionType) {
+ parent = this.functions.get(itemId);
+ if (this.functions.remove(itemId) == null) {
+ return false;
+ }
+ } else if (itemId instanceof ExpressionType) {
+ parent = this.expressions.get(itemId);
+ if (this.expressions.remove(itemId) != null) {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ //
+ // Remove it from the parent Apply
+ //
+ boolean removed = false;
+ for (JAXBElement<?> element : parent.getApply().getExpression()) {
+ if (element.getValue().equals(itemId)) {
+ if (parent.getApply().getExpression().remove(element)) {
+ removed = true;
+ break;
+ }
+ break;
+ }
+ }
+ if (! removed) {
+ //
+ // Out of sync
+ //
+ logger.warn("Removing item from parent returned false, although we were able to remove it from our maps.");
+ }
+ //
+ // Notify
+ //
+ this.fireItemSetChange();
+ return true;
+ }
+
+ public class ExpressionItem implements Item {
+ private static final long serialVersionUID = 1L;
+ private final Object data;
+
+ public ExpressionItem(Object data) {
+ this.data = data;
+ }
+
+ public String getName() {
+ if (this.data instanceof ApplyType) {
+ if (((ApplyType) this.data).getDescription() != null) {
+ return "Apply - " + ((ApplyType) this.data).getDescription();
+ }
+ return "Apply";
+ }
+ if (this.data instanceof AttributeValueType) {
+ return "Attribute Value";
+ }
+ if (this.data instanceof AttributeDesignatorType) {
+ return "Attribute Designator";
+ }
+ if (this.data instanceof AttributeSelectorType) {
+ return "Attribute Selector";
+ }
+ if (this.data instanceof VariableReferenceType) {
+ return "Variable Reference";
+ }
+ if (this.data instanceof FunctionType) {
+ return "Function";
+ }
+ if (this.data instanceof ExpressionType) {
+ return "<Argument Placeholder>";
+ }
+ return null;
+ }
+
+ public String getId() {
+ if (this.data instanceof ApplyType) {
+ return ((ApplyType) this.data).getFunctionId();
+ }
+ if (this.data instanceof AttributeValueType) {
+ StringBuilder builder = new StringBuilder();
+ for (Object content : ((AttributeValueType) this.data).getContent()) {
+ builder.append(content);
+ }
+ return builder.toString();
+ }
+ if (this.data instanceof AttributeDesignatorType) {
+ return ((AttributeDesignatorType) this.data).getAttributeId();
+ }
+ if (this.data instanceof AttributeSelectorType) {
+ return ((AttributeSelectorType) this.data).getPath();
+ }
+ if (this.data instanceof VariableReferenceType) {
+ return ((VariableReferenceType) this.data).getVariableId();
+ }
+ if (this.data instanceof FunctionType) {
+ return ((FunctionType) this.data).getFunctionId();
+ }
+ return null;
+ }
+
+ public String getIdShort() {
+ String id = this.getId();
+ if (id == null) {
+ return id;
+ }
+ //
+ // Make it short
+ //
+ String[] parts = id.split("[:]");
+
+ if (parts != null && parts.length > 0) {
+ return parts[parts.length - 1];
+ }
+ return id;
+ }
+
+ public String getDatatype() {
+ if (this.data instanceof ApplyType) {
+
+ Map<String, FunctionDefinition> map = JPAUtils.getFunctionIDMap();
+ FunctionDefinition function = map.get(((ApplyType) this.data).getFunctionId());
+ if (function != null) {
+ return function.getDatatypeBean().getXacmlId();
+ }
+ }
+ if (this.data instanceof AttributeValueType) {
+ return ((AttributeValueType) this.data).getDataType();
+ }
+ if (this.data instanceof AttributeDesignatorType) {
+ return ((AttributeDesignatorType) this.data).getDataType();
+ }
+ if (this.data instanceof AttributeSelectorType) {
+ return ((AttributeSelectorType) this.data).getDataType();
+ }
+
+ /*
+ if (this.data instanceof VariableReferenceType) {
+ if (this.function instanceof FunctionArgument) {
+ return ((FunctionArgument) this.function).getDatatypeBean().getXacmlId();
+ }
+ }
+ */
+ /*
+ if (this.data instanceof FunctionType) {
+ if (this.function instanceof FunctionArgument) {
+ return ((FunctionArgument) this.function).getDatatypeBean().getXacmlId();
+ }
+ }
+ */
+ return null;
+ }
+
+ public String getDatatypeShort() {
+ String dt = this.getDatatype();
+ if (dt == null) {
+ return dt;
+ }
+ //
+ // Get short part
+ //
+ int index = dt.lastIndexOf('#');
+ if (index == -1) {
+ String[] parts = dt.split("[:]");
+
+ if (parts != null && parts.length > 0) {
+ return parts[parts.length - 1];
+ }
+ } else {
+ return dt.substring(index + 1);
+ }
+ return dt;
+ }
+
+ @Override
+ public Property<?> getItemProperty(Object id) {
+ return getContainerProperty(this.data, id);
+ }
+ @Override
+ public Collection<?> getItemPropertyIds() {
+ return getContainerPropertyIds();
+ }
+ @Override
+ public boolean addItemProperty(Object id, @SuppressWarnings("rawtypes") Property property) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Expression container does not support adding new properties");
+ }
+ @Override
+ public boolean removeItemProperty(Object id) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Expression container does not support removing properties");
+ }
+ }
+}
[19/23] incubator-openaz git commit: Ported original att source to
openaz
Posted by pd...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/PolicyEditor.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/PolicyEditor.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/PolicyEditor.java
new file mode 100644
index 0000000..f6ab0f8
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/PolicyEditor.java
@@ -0,0 +1,1679 @@
+/*
+ * 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.xacml.admin.components;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionsType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ConditionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObligationExpressionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObligationExpressionsType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicySetType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.RuleType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableDefinitionType;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.jpa.Attribute;
+import org.apache.openaz.xacml.admin.model.GitRepositoryContainer;
+import org.apache.openaz.xacml.admin.model.PolicyContainer;
+import org.apache.openaz.xacml.admin.util.AdminNotification;
+import org.apache.openaz.xacml.admin.util.JPAUtils;
+import org.apache.openaz.xacml.admin.view.windows.AttributeSelectionWindow;
+import org.apache.openaz.xacml.admin.view.windows.AttributeValueEditorWindow;
+import org.apache.openaz.xacml.admin.view.windows.ExpressionBuilderComponent;
+import org.apache.openaz.xacml.admin.view.windows.MatchEditorWindow;
+import org.apache.openaz.xacml.admin.view.windows.ObligationAdviceEditorWindow;
+import org.apache.openaz.xacml.admin.view.windows.PolicyEditorWindow;
+import org.apache.openaz.xacml.admin.view.windows.PolicySetEditorWindow;
+import org.apache.openaz.xacml.admin.view.windows.RuleEditorWindow;
+import org.apache.openaz.xacml.admin.view.windows.VariableDefinitionEditorWindow;
+import org.apache.openaz.xacml.util.XACMLObjectCopy;
+import org.apache.openaz.xacml.util.XACMLPolicyWriter;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Container.ItemSetChangeEvent;
+import com.vaadin.data.Container.ItemSetChangeListener;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.event.Action;
+import com.vaadin.event.Action.Handler;
+import com.vaadin.event.DataBoundTransferable;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.event.ShortcutAction;
+import com.vaadin.event.dd.DragAndDropEvent;
+import com.vaadin.event.dd.DropHandler;
+import com.vaadin.event.dd.acceptcriteria.AcceptAll;
+import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
+import com.vaadin.server.BrowserWindowOpener;
+import com.vaadin.server.FileDownloader;
+import com.vaadin.server.StreamResource;
+import com.vaadin.shared.ui.dd.VerticalDropLocation;
+import com.vaadin.ui.AbstractSelect.AbstractSelectTargetDetails;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.TabSheet.Tab;
+import com.vaadin.ui.Table.TableDragMode;
+import com.vaadin.ui.TreeTable;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window.CloseEvent;
+import com.vaadin.ui.Window.CloseListener;
+
+public class PolicyEditor extends CustomComponent {
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+
+ @AutoGenerated
+ private TreeTable tree;
+
+ @AutoGenerated
+ private HorizontalLayout horizontalLayoutToolbar;
+
+ @AutoGenerated
+ private Button buttonExport;
+
+ @AutoGenerated
+ private Button buttonViewXML;
+
+ @AutoGenerated
+ private Button buttonSave;
+
+ @AutoGenerated
+ private CheckBox checkBoxAutoSave;
+
+ @AutoGenerated
+ private CheckBox checkBoxReadOnly;
+
+ private static final long serialVersionUID = 1L;
+ private static Log logger = LogFactory.getLog(PolicyEditor.class);
+ private final PolicyEditor self = this;
+
+ private static final Action CREATE_POLICY = new Action ("New Policy");
+ private static final Action CREATE_POLICYSET = new Action ("New Policy Set");
+ private static final Action CREATE_RULE = new Action ("New Rule");
+ private static final Action EDIT_POLICY = new Action ("Edit Policy");
+ private static final Action EDIT_POLICYSET = new Action ("Edit Policy Set");
+ private static final Action EDIT_RULE = new Action ("Edit Rule");
+ private static final Action DELETE_POLICYSET = new Action ("Delete Policy Set");
+ private static final Action DELETE_POLICY = new Action ("Delete Policy");
+ private static final Action DELETE_RULE = new Action ("Delete Rule");
+ private static final Action CREATE_NEWANYOF = new Action ("New Any Of (Match)");
+ private static final Action CREATE_NEWALLOF = new Action ("New All Of (Match)");
+ private static final Action CREATE_NEWMATCH = new Action ("New Match");
+ private static final Action DELETE_ANYOF = new Action ("Delete Any Of");
+ private static final Action DELETE_ALLOF = new Action ("Delete All Of");
+ private static final Action DELETE_MATCH = new Action ("Delete Match");
+ private static final Action EDIT_MATCH = new Action ("Edit Match");
+ private static final Action EDIT_OBLIGATIONS = new Action ("Edit Obligations");
+ private static final Action DELETE_OBLIGATIONS = new Action ("Delete Obligations");
+ private static final Action EDIT_ADVICE = new Action ("Edit Advice");
+ private static final Action DELETE_ADVICE = new Action ("Delete Advice");
+ private static final Action CREATE_VARIABLE = new Action ("Create Variable");
+ private static final Action EDIT_VARIABLE = new Action ("Edit Variable");
+ private static final Action DELETE_VARIABLE = new Action ("Delete Variable");
+ private static final Action CREATE_TARGET = new Action ("Create Target");
+ private static final Action CREATE_CONDITION = new Action ("Create Condition");
+ private static final Action EDIT_CONDITION = new Action ("Edit Condition");
+ private static final Action DELETE_CONDITION = new Action ("Delete Condition");
+ private static final Action EDIT_EXPRESSIONS = new Action ("Edit Expressions");
+
+ private static final Action CLIPBOARD_CUT = new ShortcutAction ("Cut", ShortcutAction.KeyCode.S, new int[] {ShortcutAction.ModifierKey.CTRL});
+ private static final Action CLIPBOARD_COPY = new ShortcutAction ("Copy", ShortcutAction.KeyCode.C, new int[] {ShortcutAction.ModifierKey.CTRL});
+ private static final Action CLIPBOARD_PASTE = new ShortcutAction ("Paste", ShortcutAction.KeyCode.V, new int[] {ShortcutAction.ModifierKey.CTRL});
+
+ private static final Object[] VISIBLE_COLUMNS = new Object[] {PolicyContainer.PROPERTY_NAME, PolicyContainer.PROPERTY_SHORTALGORITHM, PolicyContainer.PROPERTY_DESCRIPTION};
+ private static final String[] COLUMN_HEADERS = new String[] { "Name", "Algorithm or Effect", "Description"};
+
+ private final File file;
+ private final GitRepositoryContainer gitContainer;
+ private final PolicyContainer policyContainer;
+ private Tab tab = null;
+ private boolean isModified = false;
+
+ private Object clipboardObject = null;
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ * @throws IOException
+ */
+ public PolicyEditor(File policyFile, GitRepositoryContainer gitContainer, boolean readOnly) throws IOException {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+ this.mainLayout.setSizeFull();
+ //
+ // Save
+ //
+ this.file = policyFile;
+ this.gitContainer = gitContainer;
+ this.policyContainer = new PolicyContainer(this.file);
+ //
+ // Its our data also
+ //
+ this.setData(policyFile);
+ //
+ // Initialize GUI
+ //
+ this.initializeCheckboxes(readOnly);
+ this.initializeButtons();
+ this.initializeDownload();
+ this.initializeTree();
+// PLD TODO next release this.initializeContextMenu();
+ //
+ // setup the caption etc.
+ //
+ this.setupCaption();
+ this.resetComponents();
+ }
+
+ protected void initializeCheckboxes(boolean readOnly) {
+ //
+ // The readonly check box
+ //
+ this.checkBoxReadOnly.setImmediate(true);
+ this.checkBoxReadOnly.setValue(readOnly);
+ this.checkBoxReadOnly.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ self.resetComponents();
+ self.setupCaption();
+ }
+
+ });
+ //
+ // The autosave check box
+ //
+ this.checkBoxAutoSave.setImmediate(true);
+ this.checkBoxAutoSave.setValue(true);
+ }
+
+ protected void initializeButtons() {
+ //
+ // The Save button
+ //
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ self.savePolicy();
+ }
+ });
+ //
+ // Attach a window opener to the View XML button
+ //
+ BrowserWindowOpener opener = new BrowserWindowOpener(new StreamResource(new StreamResource.StreamSource() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public InputStream getStream() {
+ try {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Setting view xml button to: " + self.file.getAbsolutePath());
+ }
+ return new FileInputStream(self.file);
+ } catch (Exception e) {
+ logger.error("Failed to open input stream " + self.file);
+ }
+ return null;
+ }
+ }, self.file.getName()));
+ opener.setWindowName("_new");
+ opener.extend(this.buttonViewXML);
+ }
+
+ protected void initializeDownload() {
+ //
+ // Create a stream resource pointing to the file
+ //
+ StreamResource r = new StreamResource(new StreamResource.StreamSource() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public InputStream getStream() {
+ try {
+ return new FileInputStream(self.file);
+ } catch (Exception e) {
+ logger.error("Failed to open input stream " + self.file);
+ }
+ return null;
+ }
+ }, self.file.getName());
+ r.setCacheTime(-1);
+ r.setMIMEType("application/xml");
+ //
+ // Extend a downloader to attach to the Export Button
+ //
+ FileDownloader downloader = new FileDownloader(r);
+ downloader.extend(this.buttonExport);
+ }
+
+ public void setTab(Tab tab) {
+ this.tab = tab;
+ this.setupCaption();
+ }
+
+ public boolean isAutoSave() {
+ if (this.checkBoxAutoSave.isEnabled() == false) {
+ return false;
+ }
+ return this.checkBoxAutoSave.getValue();
+ }
+
+ public boolean isReadOnly() {
+ return this.checkBoxReadOnly.getValue();
+ }
+
+ protected void initializeTree() {
+ //
+ // Create our container and set it as the tree's data source
+ //
+ this.tree.setContainerDataSource(this.policyContainer);
+ this.tree.setItemIconPropertyId("Icon");
+ this.tree.setVisibleColumns(VISIBLE_COLUMNS);
+ this.tree.setColumnHeaders(COLUMN_HEADERS);
+ this.tree.setSelectable(true);
+ this.tree.setSizeFull();
+ //
+ // Expand it down a few items
+ //
+ for (Object id : this.tree.getItemIds()) {
+ this.tree.setCollapsed(id, false);
+ for (Object child : this.tree.getChildren(id)) {
+ this.tree.setCollapsed(child, false);
+ }
+ }
+ //
+ // Respond to double-click's
+ //
+ this.tree.addItemClickListener(new ItemClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void itemClick(ItemClickEvent event) {
+ if (event.isDoubleClick()) {
+ if (self.isReadOnly()) {
+ AdminNotification.info("You are in read-only mode.");
+ return;
+ }
+ Object target = event.getItemId();
+ if (target instanceof PolicySetType) {
+ self.editPolicySet((PolicySetType) target, (PolicySetType) self.policyContainer.getParent(target));
+ } else if (target instanceof PolicyType) {
+ self.editPolicy((PolicyType) target, (PolicySetType) self.policyContainer.getParent(target));
+ } else if (target instanceof RuleType) {
+ self.editRule((RuleType) target, (PolicyType) self.policyContainer.getParent(target));
+ } else if (target instanceof ConditionType) {
+ self.editCondition((ConditionType) target, (RuleType) self.policyContainer.getParent(target));
+ } else if (target instanceof VariableDefinitionType) {
+ self.editVariable((VariableDefinitionType) target, (PolicyType) self.policyContainer.getParent(target));
+ } else if (target instanceof MatchType) {
+ self.editMatch((MatchType) target, (AllOfType) self.policyContainer.getParent(target), null, null, "Edit Match");
+ } else if (target instanceof ObligationExpressionType) {
+ self.editObAdvice(true, self.policyContainer.getParent(target));
+ } else if (target instanceof AdviceExpressionType) {
+ self.editObAdvice(false, self.policyContainer.getParent(target));
+ }
+ }
+ }
+
+ });
+ //
+ // Respond to container changes
+ //
+ this.policyContainer.addItemSetChangeListener(new ItemSetChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void containerItemSetChange(ItemSetChangeEvent event) {
+ self.isModified = true;
+ if (self.isAutoSave()) {
+ self.savePolicy();
+ } else {
+ self.setupCaption();
+ self.buttonSave.setEnabled(true);
+ }
+ }
+ });
+ //
+ // Implement drag-n-drop
+ //
+ this.tree.setDropHandler(new DropHandler() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void drop(DragAndDropEvent event) {
+ DataBoundTransferable t = (DataBoundTransferable) event.getTransferable();
+ AbstractSelectTargetDetails target = (AbstractSelectTargetDetails) event.getTargetDetails();
+
+ //
+ // Get ids of the dragged item and the target item
+ //
+ Object sourceItemId = t.getData("itemId");
+ Object targetItemId = target.getItemIdOver();
+ VerticalDropLocation location = target.getDropLocation();
+ if (logger.isDebugEnabled()) {
+ logger.debug("Drop " + sourceItemId + " target " + targetItemId + " location " + location);
+ }
+ //
+ // Tell our container what to do
+ //
+ try {
+ if (location == VerticalDropLocation.MIDDLE) {
+ //
+ // Drop right on top of item making it a child
+ //
+ self.policyContainer.setParent(sourceItemId, targetItemId);
+ }
+
+ /*
+ } else if (location == VerticalDropLocation.TOP) {
+ //
+ // Drop at the top of the tree making it the previous
+ //
+ Object parent = self.policyContainer.getParent(targetItemId);
+ self.policyContainer.setParent(sourceItemId, parent);
+ self.policyContainer.moveAfterSibling(sourceItemId, targetItemId);
+ self.policyContainer.moveAfterSibling(targetItemId, sourceItemId);
+ } else if (location == VerticalDropLocation.BOTTOM) {
+ //
+ // Drop below another item
+ //
+ Object parent = self.policyContainer.getParent(targetItemId);
+ self.policyContainer.setParent(sourceItemId, targetItemId);
+ self.policyContainer.moveAfterSibling(sourceItemId, targetItemId);
+ }
+ */
+ } catch (UnsupportedOperationException e) {
+ logger.error("Unsupported " + e.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public AcceptCriterion getAcceptCriterion() {
+ return AcceptAll.get();
+ }
+ });
+ }
+
+ protected void removeObject(Object target) {
+ if (target instanceof PolicySetType) {
+ this.removePolicySet((PolicySetType) target);
+ } else if (target instanceof PolicyType) {
+ this.removePolicy((PolicyType) target);
+ } else if (target instanceof RuleType) {
+ this.removeRule((RuleType) target);
+ } else if (target instanceof ConditionType) {
+ this.removeCondition((ConditionType) target);
+ } else if (target instanceof VariableDefinitionType) {
+ this.removeVariable((VariableDefinitionType) target);
+ } else if (target instanceof AdviceExpressionType) {
+ this.removeAdvice((AdviceExpressionType) target);
+ } else if (target instanceof ObligationExpressionType) {
+ this.removeObligations((ObligationExpressionType) target);
+ }
+ }
+
+ protected void removeAdvice(AdviceExpressionType target) {
+ if (this.tree.removeItem(target) == false) {
+ logger.error("Failed to remove advice.");
+ }
+ }
+
+ protected void removeVariable(VariableDefinitionType target) {
+ if (this.tree.removeItem(target) == false) {
+ logger.error("Failed to remove variable.");
+ }
+ }
+
+ protected void removeCondition(ConditionType target) {
+ if (this.tree.removeItem(target) == false) {
+ logger.error("Failed to remove condition.");
+ }
+ }
+
+ protected void removeObligations(ObligationExpressionType target) {
+ if (this.tree.removeItem(target) == false) {
+ logger.error("Failed to remove obligations.");
+ }
+ }
+
+ protected void removeRule(RuleType target) {
+ if (this.tree.removeItem(target) == false) {
+ logger.error("Failed to remove rule.");
+ }
+ }
+
+ protected void removePolicy(PolicyType target) {
+ Object parent = this.tree.getParent(target);
+ if (parent == null) {
+ this.deleteRoot(target);
+ } else {
+ if (this.tree.removeItem(target) == false) {
+ logger.error("Failed to remove policy.");
+ }
+ }
+ }
+
+ protected void removePolicySet(PolicySetType target) {
+ Object parent = this.tree.getParent(target);
+ if (parent == null) {
+ this.deleteRoot(target);
+ } else {
+ if (this.tree.removeItem(target) == false) {
+ logger.error("Failed to remove policy set.");
+ }
+ }
+ }
+
+ /*
+ protected void initializeContextMenu() {
+ ContextMenu menu = new ContextMenu();
+ menu.setAsTableContextMenu(this.tree);
+ menu.addContextMenuTableListener(new TableListener() {
+
+ @Override
+ public void onContextMenuOpenFromFooter(
+ ContextMenuOpenedOnTableFooterEvent event) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void onContextMenuOpenFromHeader(
+ ContextMenuOpenedOnTableHeaderEvent event) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void onContextMenuOpenFromRow(ContextMenuOpenedOnTableRowEvent event) {
+ logger.info("context menu row");
+ }
+ });
+ menu.addItem("test");
+ }
+ */
+
+ protected void savePolicy() {
+ if (this.isReadOnly()) {
+ logger.warn("Should not call savePolicy when in read only mode.");
+ return;
+ }
+ Collection<?> roots = this.policyContainer.rootItemIds();
+ if (roots.size() > 1) {
+ logger.warn("More than one root policy.");
+ }
+ //
+ // There should only be one root
+ // Save the policy to disk.
+ //
+ for (Object root : roots) {
+ logger.info("Saving policy: " + this.file.getName());
+ //
+ // TODO - Bump the version?
+ //
+ if (root instanceof PolicySetType) {
+ XACMLPolicyWriter.writePolicyFile(Paths.get(this.file.getAbsolutePath()), (PolicySetType) root);
+ } else if (root instanceof PolicyType) {
+ XACMLPolicyWriter.writePolicyFile(Paths.get(this.file.getAbsolutePath()), (PolicyType) root);
+ }
+ //
+ // TODO ????
+ //
+ this.gitContainer.updateItem(this.file);
+ break; // NOPMD
+ }
+ //
+ // No longer modified
+ //
+ this.isModified = false;
+ this.setupCaption();
+ this.resetComponents();
+ }
+
+ protected void installTreeActionHandler() {
+ //
+ // Remove any existing action handlers
+ //
+ this.tree.removeAllActionHandlers();
+ //
+ // Are we read-only?
+ //
+ if (this.isReadOnly()) {
+ //
+ // Yes - no action handler's allowed
+ //
+ return;
+ }
+ //
+ // Setup our action handlers
+ //
+ this.tree.addActionHandler(new Handler() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Action[] getActions(Object target, Object sender) {
+ //
+ // Are we read-only?
+ //
+ if (self.isReadOnly()) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Policy is read-only");
+ }
+ return null;
+ }
+ if (target == null) {
+ //
+ // Nothing is selected, they right-clicked empty space
+ //
+ if (logger.isDebugEnabled()) {
+ logger.debug("action tree target is null");
+ }
+ return null;
+ }
+ if (target instanceof PolicySetType) {
+ List<Action> actions = new ArrayList<Action>();
+ actions.add(EDIT_POLICYSET);
+ if (((PolicySetType) target).getTarget() == null) {
+ actions.add(CREATE_TARGET);
+ }
+ /*
+ actions.add(CLIPBOARD_CUT);
+ actions.add(CLIPBOARD_COPY);
+ actions.add(CLIPBOARD_PASTE);
+ */
+ actions.add(CREATE_POLICYSET);
+ actions.add(CREATE_POLICY);
+ actions.add(EDIT_OBLIGATIONS);
+ actions.add(EDIT_ADVICE);
+ actions.add(DELETE_POLICYSET);
+ return (Action[]) actions.toArray(new Action[0]);
+ }
+ if (target instanceof PolicyType) {
+ List<Action> actions = new ArrayList<Action>();
+ actions.add(EDIT_POLICY);
+ if (((PolicyType) target).getTarget() == null) {
+ actions.add(CREATE_TARGET);
+ }
+ /*
+ actions.add(CLIPBOARD_CUT);
+ actions.add(CLIPBOARD_COPY);
+ actions.add(CLIPBOARD_PASTE);
+ */
+ actions.add(CREATE_RULE);
+ actions.add(CREATE_VARIABLE);
+ actions.add(EDIT_OBLIGATIONS);
+ actions.add(EDIT_ADVICE);
+ actions.add(DELETE_POLICY);
+ return (Action[]) actions.toArray(new Action[0]);
+ }
+ if (target instanceof RuleType) {
+ List<Action> actions = new ArrayList<Action>();
+ actions.add(EDIT_RULE);
+ if (((RuleType) target).getTarget() == null) {
+ actions.add(CREATE_TARGET);
+ }
+ /*
+ actions.add(CLIPBOARD_CUT);
+ actions.add(CLIPBOARD_COPY);
+ actions.add(CLIPBOARD_PASTE);
+ */
+ if (((RuleType)target).getCondition() == null) {
+ actions.add(CREATE_CONDITION);
+ }
+ actions.add(EDIT_OBLIGATIONS);
+ actions.add(EDIT_ADVICE);
+ actions.add(DELETE_RULE);
+ return (Action[]) actions.toArray(new Action[0]);
+ }
+ if (target instanceof TargetType) {
+ return new Action[] {CREATE_NEWANYOF};
+ }
+ if (target instanceof AnyOfType) {
+ return new Action[] {CREATE_NEWALLOF, DELETE_ANYOF};
+ }
+ if (target instanceof AllOfType) {
+ return new Action[] {CREATE_NEWMATCH, DELETE_ALLOF};
+ }
+ if (target instanceof MatchType) {
+ return new Action[] {EDIT_MATCH, DELETE_MATCH};
+ }
+ if (target instanceof ConditionType) {
+ return new Action[] {EDIT_CONDITION, DELETE_CONDITION};
+ }
+ if (target instanceof VariableDefinitionType) {
+ return new Action[] {EDIT_VARIABLE, DELETE_VARIABLE};
+ }
+ if (target instanceof ObligationExpressionType) {
+ return new Action[] {EDIT_OBLIGATIONS, DELETE_OBLIGATIONS};
+ }
+ if (target instanceof AdviceExpressionType) {
+ return new Action[] {EDIT_ADVICE, DELETE_ADVICE};
+ }
+ return null;
+ }
+
+ @Override
+ public void handleAction(Action action, Object sender, Object target) {
+ if (action == CLIPBOARD_CUT) {
+ assert target != null;
+ self.clipboardObject = XACMLObjectCopy.deepCopy(target);
+ self.removeObject(target);
+ return;
+ }
+ if (action == CLIPBOARD_COPY) {
+ assert target != null;
+ self.clipboardObject = XACMLObjectCopy.deepCopy(target);
+ return;
+ }
+ if (action == CLIPBOARD_PASTE) {
+ assert target != null;
+ self.clipboardPaste(target, true);
+ return;
+ }
+ if (action == CREATE_POLICYSET) {
+ assert target instanceof PolicySetType;
+ self.editPolicySet(null, (PolicySetType) target);
+ return;
+ }
+ if (action == CREATE_POLICY) {
+ assert target instanceof PolicySetType;
+ self.editPolicy(null, (PolicySetType) target);
+ return;
+ }
+ if (action == CREATE_RULE) {
+ assert target instanceof PolicyType;
+ self.editRule(null, (PolicyType) target);
+ return;
+ }
+ if (action == CREATE_TARGET) {
+ assert target instanceof RuleType || target instanceof PolicyType || target instanceof PolicySetType;
+ TargetType newTarget = new TargetType();
+ self.policyContainer.addItem(newTarget, target);
+ return;
+ }
+ if (action == EDIT_POLICYSET) {
+ assert target instanceof PolicySetType;
+ self.editPolicySet((PolicySetType) target, (PolicySetType) self.policyContainer.getParent(target));
+ return;
+ }
+ if (action == EDIT_POLICY) {
+ assert target instanceof PolicyType;
+ self.editPolicy((PolicyType) target, (PolicySetType) self.policyContainer.getParent(target));
+ return;
+ }
+ if (action == EDIT_RULE) {
+ assert target instanceof RuleType;
+ self.editRule((RuleType) target, (PolicyType) self.policyContainer.getParent(target));
+ return;
+ }
+ if (action == DELETE_POLICYSET) {
+ assert target instanceof PolicySetType;
+ self.removePolicySet((PolicySetType) target);
+ return;
+ }
+ if (action == DELETE_POLICY) {
+ assert target instanceof PolicyType;
+ self.removePolicy((PolicyType) target);
+ return;
+ }
+ if (action == DELETE_RULE) {
+ assert target instanceof RuleType;
+ self.removeRule((RuleType) target);
+ return;
+ }
+ if (action == CREATE_NEWANYOF) {
+ assert target instanceof TargetType;
+ self.editMatch(null, null, null, (TargetType) target, "Create New Match");
+ return;
+ }
+ if (action == CREATE_NEWALLOF) {
+ assert target instanceof AnyOfType;
+ self.editMatch(null, null, (AnyOfType) target, null, "Create New Match");
+ return;
+ }
+ if (action == CREATE_NEWMATCH) {
+ if (target instanceof AllOfType) {
+ self.editMatch(null, (AllOfType) target, null, null, "Create New Match");
+ } else if (target instanceof TargetType) {
+ self.editMatch(null, null, null, (TargetType) target, "Create New Match");
+ } else {
+ assert false;
+ }
+ return;
+ }
+ if (action == DELETE_ANYOF) {
+ assert target instanceof AnyOfType;
+ self.removeAnyOf((AnyOfType) target, (TargetType) self.policyContainer.getParent(target));
+ return;
+ }
+ if (action == DELETE_ALLOF) {
+ assert target instanceof AllOfType;
+ self.removeAllOf((AllOfType) target, (AnyOfType) self.policyContainer.getParent(target));
+ return;
+ }
+ if (action == DELETE_MATCH) {
+ assert target instanceof MatchType;
+ self.removeMatch((MatchType) target, (AllOfType) self.policyContainer.getParent(target));
+ return;
+ }
+ if (action == EDIT_MATCH) {
+ assert target instanceof MatchType;
+ self.editMatch((MatchType) target, (AllOfType) self.policyContainer.getParent(target), null, null, "Edit Match");
+ return;
+ }
+ if (action == EDIT_OBLIGATIONS) {
+ assert target instanceof RuleType ||
+ target instanceof PolicyType ||
+ target instanceof PolicySetType ||
+ target instanceof ObligationExpressionType;
+ if (target instanceof ObligationExpressionType) {
+ self.editObAdvice(true, self.policyContainer.getParent(target));
+ } else {
+ self.editObAdvice(true, target);
+ }
+ return;
+ }
+ if (action == DELETE_OBLIGATIONS) {
+ assert target instanceof ObligationExpressionType;
+ self.removeObligations((ObligationExpressionType) target);
+ return;
+ }
+ if (action == EDIT_ADVICE) {
+ assert target instanceof RuleType ||
+ target instanceof PolicyType ||
+ target instanceof PolicySetType ||
+ target instanceof AdviceExpressionType;
+ if (target instanceof AdviceExpressionType) {
+ self.editObAdvice(false, self.policyContainer.getParent(target));
+ } else {
+ self.editObAdvice(false, target);
+ }
+ return;
+ }
+ if (action == DELETE_ADVICE) {
+ assert target instanceof AdviceExpressionType;
+ self.removeAdvice((AdviceExpressionType) target);
+ return;
+ }
+ if (action == CREATE_VARIABLE) {
+ assert target instanceof PolicyType;
+ self.editVariable(null, (PolicyType) target);
+ return;
+ }
+ if (action == CREATE_CONDITION) {
+ assert target instanceof RuleType;
+ self.editCondition(null, (RuleType) target);
+ return;
+ }
+ if (action == EDIT_CONDITION) {
+ assert target instanceof ConditionType;
+ self.editCondition((ConditionType) target, (RuleType) self.policyContainer.getParent(target));
+ return;
+ }
+ if (action == DELETE_CONDITION) {
+ assert target instanceof ConditionType;
+ self.removeCondition((ConditionType) target);
+ return;
+ }
+ if (action == EDIT_EXPRESSIONS) {
+ return;
+ }
+ if (action == DELETE_VARIABLE) {
+ assert target instanceof VariableDefinitionType;
+ self.removeVariable((VariableDefinitionType) target);
+ return;
+ }
+ if (action == EDIT_VARIABLE) {
+ assert target instanceof VariableDefinitionType;
+ self.editVariable((VariableDefinitionType) target, (PolicyType) self.policyContainer.getParent(target));
+ return;
+ }
+ }
+ });
+ }
+
+ protected void resetComponents() {
+ if (this.isReadOnly()) {
+ this.checkBoxAutoSave.setEnabled(false);
+ this.buttonSave.setEnabled(false);
+ this.tree.setDragMode(TableDragMode.NONE);
+ this.tree.removeAllActionHandlers();
+ this.tree.setReadOnly(true);
+ } else {
+ this.checkBoxAutoSave.setEnabled(true);
+ this.buttonSave.setEnabled(this.isModified);
+ this.tree.setReadOnly(false);
+ this.tree.setDragMode(TableDragMode.ROW);
+ this.installTreeActionHandler();
+ }
+ }
+
+ public void setupCaption() {
+ String caption = this.file.getName();
+ if (this.isModified) {
+ caption = caption + " *";
+ }
+ if (this.isReadOnly()) {
+ caption = caption + " (Read-Only)";
+ }
+ if (this.tab != null) {
+ this.tab.setCaption(caption);
+ }
+ }
+
+ protected void editPolicySet(final PolicySetType policy, final PolicySetType parent) {
+ logger.info("editPolicySet: " + policy + " parent " + parent);
+ //
+ // Create a copy
+ //
+ final PolicySetType newPolicySet = (policy == null ? new PolicySetType() : XACMLObjectCopy.copy(policy));
+ //
+ // Create window
+ //
+ final PolicySetEditorWindow window = new PolicySetEditorWindow(newPolicySet);
+ window.setCaption(policy == null ? "Create New Policy Set" : "Edit Policy Set");
+ window.setModal(true);
+ window.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Did the user click save?
+ //
+ if (window.isSaved() == false) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("user did NOT save");
+ }
+ return;
+ }
+ //
+ // Was it a new Policy Set?
+ //
+ if (policy == null) {
+ logger.info("adding new policy set " + newPolicySet.getPolicySetId());
+ //
+ // Yes - new add it in
+ //
+ if (newPolicySet.getTarget() == null) {
+ newPolicySet.setTarget(new TargetType());
+ }
+ if (self.policyContainer.addItem(newPolicySet, parent) == null) {
+ logger.error("Failed to add new policy set");
+ } else {
+ self.tree.setCollapsed(parent, false);
+ self.tree.setCollapsed(newPolicySet, false);
+ self.tree.select(newPolicySet);
+ }
+ } else {
+ logger.info("updating new policy set " + newPolicySet.getPolicySetId());
+ //
+ // No - copy everything
+ //
+ policy.setDescription(newPolicySet.getDescription());
+ policy.setVersion(newPolicySet.getVersion());
+ policy.setPolicyCombiningAlgId(newPolicySet.getPolicyCombiningAlgId());
+ //
+ // Update
+ //
+ self.policyContainer.updateItem(policy);
+ }
+ }
+ });
+ window.center();
+ UI.getCurrent().addWindow(window);
+ }
+
+ protected void editPolicy(final PolicyType policy, final PolicySetType parent) {
+ //
+ // Create a copy
+ //
+ final PolicyType newPolicy = (policy == null ? new PolicyType() : XACMLObjectCopy.copy(policy));
+ //
+ // Create window
+ //
+ final PolicyEditorWindow window = new PolicyEditorWindow(newPolicy);
+ window.setCaption(policy == null ? "Create New Policy" : "Edit Policy");
+ window.setModal(true);
+ window.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Did the user click save?
+ //
+ if (window.isSaved() == false) {
+ return;
+ }
+ //
+ // Was it a new Policy?
+ //
+ if (policy == null) {
+ //
+ // Yes - new add it in
+ //
+ if (newPolicy.getTarget() == null) {
+ newPolicy.setTarget(new TargetType());
+ }
+ if (self.policyContainer.addItem(newPolicy, parent) == null) {
+ logger.error("Failed to add policy");
+ } else {
+ self.tree.setCollapsed(parent, false);
+ self.tree.setCollapsed(newPolicy, false);
+ self.tree.select(newPolicy);
+ }
+ } else {
+ //
+ // No - copy everything
+ //
+ policy.setDescription(newPolicy.getDescription());
+ policy.setVersion(newPolicy.getVersion());
+ policy.setRuleCombiningAlgId(newPolicy.getRuleCombiningAlgId());
+ //
+ // Update
+ //
+ self.policyContainer.updateItem(policy);
+ }
+ }
+ });
+ window.center();
+ UI.getCurrent().addWindow(window);
+ }
+
+ protected void editRule(final RuleType rule, final PolicyType parent) {
+ //
+ // Create a copy
+ //
+ final RuleType newRule = (rule == null ? new RuleType() : XACMLObjectCopy.copy(rule));
+ //
+ // Create window
+ //
+ final RuleEditorWindow window = new RuleEditorWindow(newRule);
+ window.setCaption(rule == null ? "Create New Rule" : "Edit Rule");
+ window.setModal(true);
+ window.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Did the user click save?
+ //
+ if (window.isSaved() == false) {
+ return;
+ }
+ //
+ // Was this a new rule?
+ //
+ if (rule == null) {
+ //
+ // Yes a new rule
+ //
+ if (newRule.getTarget() == null) {
+ newRule.setTarget(new TargetType());
+ }
+ if (self.policyContainer.addItem(newRule, parent) == null) {
+ logger.error("Failed to add new rule");
+ } else {
+ self.tree.setCollapsed(parent, false);
+ self.tree.setCollapsed(newRule, false);
+ self.tree.select(newRule);
+ }
+ } else {
+ //
+ // No - editing existing rule. Copy everything
+ //
+ rule.setEffect(newRule.getEffect());
+ rule.setDescription(newRule.getDescription());
+ self.policyContainer.updateItem(rule);
+ }
+ }
+ });
+ window.center();
+ UI.getCurrent().addWindow(window);
+ }
+
+ protected void editCondition(final ConditionType condition, final RuleType rule) {
+ //
+ // Make a copy of it first, in case the user manipulates it
+ // and then decides to NOT save it
+ //
+ final ConditionType copyCondition = (condition == null ? new ConditionType() : XACMLObjectCopy.copy(condition));
+ //
+ // Create the window
+ //
+ final ExpressionBuilderComponent expression = new ExpressionBuilderComponent(copyCondition,
+ (copyCondition.getExpression() != null ? copyCondition.getExpression().getValue() : null),
+ null,
+ self.policyContainer.getVariables());
+ if (condition == null) {
+ expression.setCaption("Create An Expression For The Condition");
+ } else {
+ expression.setCaption("Edit The Condition Expression");
+ }
+ expression.setModal(true);
+ //
+ // Add the close listener
+ //
+ expression.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Did the user hit save?
+ //
+ if (expression.isSaved() == false) {
+ return;
+ }
+ //
+ // Were we creating something new?
+ //
+ if (condition == null) {
+ //
+ // Yes add the new one into the container
+ //
+ if (self.policyContainer.addItem(copyCondition, rule) == null) {
+ logger.error("Failed to add condition");
+ } else {
+ self.tree.setCollapsed(rule, false);
+ self.tree.setCollapsed(copyCondition, false);
+ self.tree.select(copyCondition);
+ }
+ } else {
+ //
+ // We were editing an existing condition, so copy
+ // over the new edited expression.
+ //
+ condition.setExpression(copyCondition.getExpression());
+ //
+ // Update the container
+ //
+ self.policyContainer.updateItem(condition);
+ }
+ }
+ });
+ expression.center();
+ UI.getCurrent().addWindow(expression);
+ }
+
+ protected void editVariable(final VariableDefinitionType variable, final PolicyType parent) {
+ //
+ // Make a copy of it first, in case the user manipulates it
+ // and then decides to NOT save it
+ //
+ final VariableDefinitionType copyVariable = (variable == null ? new VariableDefinitionType(): XACMLObjectCopy.copy(variable));
+ //
+ // Have the user create or edit the Variables ID
+ //
+ final VariableDefinitionEditorWindow editor = new VariableDefinitionEditorWindow(copyVariable);
+ if (variable == null) {
+ editor.setCaption("Create Variable");
+ } else {
+ editor.setCaption("Edit Variable" + (copyVariable.getVariableId() == null ? "" : copyVariable.getVariableId()));
+ }
+ editor.setModal(true);
+ editor.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Did the user click save button?
+ //
+ if (editor.isSaved() == false) {
+ return;
+ }
+ //
+ // Create the window
+ //
+ final ExpressionBuilderComponent expression = new ExpressionBuilderComponent(copyVariable,
+ (copyVariable.getExpression() != null ? copyVariable.getExpression().getValue() : null),
+ null,
+ self.policyContainer.getVariables());
+ expression.setCaption("Edit The Variable \"" + copyVariable.getVariableId() + "\" Expression");
+ //
+ // Add the close listener
+ //
+ expression.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Did the user click save button?
+ //
+ if (expression.isSaved() == false) {
+ return;
+ }
+ //
+ // Was it a new variable or were we editing an existing one?
+ //
+ if (variable == null) {
+ //
+ // New one, add it to the container
+ //
+ if (self.policyContainer.addItem(copyVariable, parent) == null) {
+ logger.error("Failed to add variable");
+ } else {
+ self.tree.setCollapsed(parent, false);
+ self.tree.setCollapsed(copyVariable, false);
+ self.tree.select(copyVariable);
+ }
+ } else {
+ //
+ // We were editing one, copy it back over.
+ //
+ variable.setVariableId(copyVariable.getVariableId());
+ variable.setExpression(copyVariable.getExpression());
+ //
+ // Update the container
+ //
+ self.policyContainer.updateItem(variable);
+ }
+ }
+ });
+ expression.center();
+ UI.getCurrent().addWindow(expression);
+ }
+ });
+ editor.center();
+ UI.getCurrent().addWindow(editor);
+ }
+
+ protected void editMatch(final MatchType match, final AllOfType allOf, final AnyOfType anyOf, final TargetType target, final String caption) {
+ //
+ // Create an empty match or copy the one we are going to edit.
+ //
+ final MatchType newMatch = (match == null ? new MatchType() : XACMLObjectCopy.copy(match));
+ //
+ // Have user select an attribute
+ //
+ final AttributeSelectionWindow selection = new AttributeSelectionWindow(null,
+ (newMatch.getAttributeDesignator() != null ? newMatch.getAttributeDesignator() : newMatch.getAttributeSelector()));
+ selection.setCaption("Select Attribute To Match Against");
+ selection.setModal(true);
+ selection.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent event) {
+ //
+ // Did the user save anything?
+ //
+ if (selection.isSaved() == false) {
+ return;
+ }
+ //
+ // Save the selected attribute
+ //
+ final Attribute attribute = selection.getAttribute();
+ if (attribute.isDesignator()) {
+ newMatch.setAttributeDesignator(JPAUtils.createDesignator(attribute));
+ } else {
+ newMatch.setAttributeSelector(JPAUtils.createSelector(attribute));
+ }
+ //
+ // Yes - now match it up to a function
+ //
+ final MatchEditorWindow editor = new MatchEditorWindow(newMatch, attribute.getDatatypeBean());
+ editor.setCaption(caption);
+ editor.setModal(true);
+ editor.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent event) {
+ //
+ // Did the user hit save?
+ //
+ if (editor.isSaved() == false) {
+ return;
+ }
+ //
+ // Yes - now we need the value to check the attribute against
+ //
+ final AttributeValueType copyAttributeValue = (newMatch.getAttributeValue() == null ? new AttributeValueType() : newMatch.getAttributeValue());
+// String currentValue = null;
+// if (newMatch.getAttributeValue() != null) {
+// currentValue = XACMLObjectCopy.getContent(newMatch.getAttributeValue().getContent());
+// }
+ final AttributeValueEditorWindow value = new AttributeValueEditorWindow(copyAttributeValue, attribute.getDatatypeBean());
+ value.setCaption("Set the value the attribute should match against.");
+ value.setModal(true);
+ value.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent event) {
+ //
+ // Did the user save?
+ //
+ if (value.isSaved() == false) {
+ return;
+ }
+ //
+ // Yes - copy the value into the match
+ //
+ AttributeValueType val = new AttributeValueType();
+ val.getContent().add(value.getValue());
+ val.setDataType(value.getDatatype().getXacmlId());
+ newMatch.setAttributeValue(val);
+ //
+ // Was this a new match or were we editing an
+ // existing match?
+ //
+ if (match != null) {
+ //
+ // Editing - now we can save it
+ //
+ match.setAttributeDesignator(newMatch.getAttributeDesignator());
+ match.setAttributeSelector(newMatch.getAttributeSelector());
+ match.setAttributeValue(newMatch.getAttributeValue());
+ match.setMatchId(newMatch.getMatchId());
+ //
+ // Update the container
+ //
+ self.policyContainer.updateItem(match);
+ } else {
+ //
+ // Do we have a parent(s)?
+ //
+ AllOfType allOfParent = allOf;
+ AnyOfType anyOfParent = anyOf;
+ if (allOfParent == null) {
+ //
+ // No direct AllOfParent
+ //
+ if (anyOfParent == null) {
+ //
+ // No AnyOfParent
+ //
+ if (target == null) {
+ logger.error("We should NOT get this");
+ return;
+ }
+ anyOfParent = new AnyOfType();
+ if (self.policyContainer.addItem(anyOfParent, target) == null) {
+ logger.error("Failed to add anyOf parent");
+ assert false;
+ }
+ self.tree.setCollapsed(anyOfParent, false);
+ }
+ allOfParent = new AllOfType();
+ if (self.policyContainer.addItem(allOfParent, anyOfParent) == null) {
+ logger.error("Failed to add allOf parent");
+ assert false;
+ }
+ self.tree.setCollapsed(allOfParent, false);
+ }
+ //
+ // Add the MatchType into the Tree
+ //
+ if (self.policyContainer.addItem(newMatch, allOfParent) == null) {
+ logger.error("Failed to add match");
+ assert false;
+ }
+ self.tree.select(newMatch);
+ }
+ }
+ });
+ value.center();
+ UI.getCurrent().addWindow(value);
+ }
+ });
+ editor.center();
+ UI.getCurrent().addWindow(editor);
+ }
+ });
+ selection.center();
+ UI.getCurrent().addWindow(selection);
+ }
+
+ protected void deleteRoot(Object root) {
+ //
+ // TODO - prompt user for new root object
+ //
+
+ }
+
+ protected void editObAdvice(boolean isObligation, final Object target) {
+ //
+ // Get the object
+ //
+ String caption;
+ Object expressionsObject = null;
+ if (target instanceof RuleType) {
+ if (isObligation) {
+ expressionsObject = ((RuleType) target).getObligationExpressions();
+ if (expressionsObject == null) {
+ caption = "Create New Obligation for Rule";
+ } else {
+ caption = "Edit Obligations for Rule";
+ }
+ } else {
+ expressionsObject = ((RuleType) target).getAdviceExpressions();
+ if (expressionsObject == null) {
+ caption = "Create New Advice for Rule";
+ } else {
+ caption = "Edit Advice for Rule";
+ }
+ }
+ } else if (target instanceof PolicyType) {
+ if (isObligation) {
+ expressionsObject = ((PolicyType) target).getObligationExpressions();
+ if (expressionsObject == null) {
+ caption = "Create New Obligation for Policy";
+ } else {
+ caption = "Edit Obligations for Policy";
+ }
+ } else {
+ expressionsObject = ((PolicyType) target).getAdviceExpressions();
+ if (expressionsObject == null) {
+ caption = "Create New Advice for Policy";
+ } else {
+ caption = "Edit Advice for Policy";
+ }
+ }
+ } else if (target instanceof PolicySetType) {
+ if (isObligation) {
+ expressionsObject = ((PolicySetType) target).getObligationExpressions();
+ if (expressionsObject == null) {
+ caption = "Create New Obligation for Policy Set";
+ } else {
+ caption = "Edit Obligation for Policy Set";
+ }
+ } else {
+ expressionsObject = ((PolicySetType) target).getAdviceExpressions();
+ if (expressionsObject == null) {
+ caption = "Create New Advice for Policy Set";
+ } else {
+ caption = "Edit Advice for Policy Set";
+ }
+ }
+ } else {
+ throw new IllegalArgumentException("Expected a rule/policy/policyset.");
+ }
+ //
+ // Make a copy
+ //
+ final Object originalExpressions = expressionsObject;
+ final Object copyExpression = (originalExpressions == null
+ ? (isObligation ? new ObligationExpressionsType() : new AdviceExpressionsType())
+ : originalExpressions instanceof ObligationExpressionsType
+ ? XACMLObjectCopy.copy((ObligationExpressionsType) originalExpressions)
+ : XACMLObjectCopy.copy((AdviceExpressionsType) originalExpressions))
+ ;
+ //
+ // Invoke the editor window
+ //
+ final ObligationAdviceEditorWindow window = new ObligationAdviceEditorWindow(copyExpression, this.policyContainer.getVariables());
+ window.setCaption(caption);
+ window.setModal(true);
+ window.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Did the user save?
+ //
+ if (window.isSaved() == false) {
+ return;
+ }
+ //
+ // It was saved - is this a new object?
+ //
+ if (originalExpressions == null) {
+ //
+ // New object
+ //
+ if (self.policyContainer.addItem(copyExpression, target) == null) {
+ logger.error("Failed to add expression");
+ assert false;
+ }
+ } else {
+ //
+ // Editing an existing object.
+ //
+ if (originalExpressions instanceof ObligationExpressionsType) {
+ //
+ // Remove old obligations
+ //
+ while (((ObligationExpressionsType) originalExpressions).getObligationExpression().isEmpty() == false) {
+// for (ObligationExpressionType old : ((ObligationExpressionsType) originalExpressions).getObligationExpression()) {
+ ObligationExpressionType old = ((ObligationExpressionsType) originalExpressions).getObligationExpression().get(0);
+ self.policyContainer.removeItem(old);
+ }
+ //
+ // Copy new ones in
+ //
+ for (ObligationExpressionType newObligation : ((ObligationExpressionsType) copyExpression).getObligationExpression()) {
+ self.policyContainer.addItem(newObligation, (ObligationExpressionsType) originalExpressions);
+ }
+ } else if (originalExpressions instanceof AdviceExpressionsType) {
+ ((AdviceExpressionsType) originalExpressions).getAdviceExpression().clear();
+ ((AdviceExpressionsType) originalExpressions).getAdviceExpression().addAll(((AdviceExpressionsType) copyExpression).getAdviceExpression());
+ }
+ }
+ }
+ });
+ window.center();
+ UI.getCurrent().addWindow(window);
+ }
+
+ protected void removeMatch(MatchType match, AllOfType parent) {
+ assert match != null && parent != null;
+ if (self.policyContainer.removeItem(match) == false) {
+ logger.error("Failed to remove match");
+ assert false;
+ }
+ //
+ // Check for empty AllOf's
+ //
+ if (parent.getMatch().isEmpty()) {
+ this.removeAllOf(parent, (AnyOfType) this.policyContainer.getParent(parent));
+ }
+ }
+
+ protected void removeAllOf(AllOfType allOf, AnyOfType parent) {
+ assert allOf != null && parent != null;
+ if (self.policyContainer.removeItem(allOf) == false) {
+ logger.error("Failed to remove AllOf");
+ assert false;
+ }
+ //
+ // Check for empty AnyOf's
+ //
+ if (parent.getAllOf().isEmpty()) {
+ this.removeAnyOf(parent, (TargetType) this.policyContainer.getParent(parent));
+ }
+ }
+
+ protected void removeAnyOf(AnyOfType anyOf, TargetType parent) {
+ assert anyOf != null && parent != null;
+ if (self.policyContainer.removeItem(anyOf) == false) {
+ logger.error("Failed to remove anyOf");
+ assert false;
+ }
+ }
+
+ protected boolean clipboardPaste(final Object target, boolean performPaste) {
+ if (this.clipboardObject == null) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("nothing in clipboard.");
+ }
+ return false;
+ }
+ boolean doPaste = false;
+ if (this.clipboardObject instanceof PolicySetType && target instanceof PolicySetType) {
+ doPaste = true;
+ }
+ if (this.clipboardObject instanceof PolicyType && target instanceof PolicySetType) {
+ doPaste = true;
+ }
+ if (this.clipboardObject instanceof RuleType && target instanceof PolicyType) {
+ doPaste = true;
+ }
+ if (doPaste == false) {
+ //
+ // Pasting clipboard object onto target not
+ // possible.
+ //
+ return false;
+ }
+ if (performPaste == false) {
+ //
+ // They did not ask to do the actual paste,
+ // but the called wanted to know if it was
+ // possible.
+ //
+ return true;
+ }
+ //
+ // Do the actual paste
+ //
+ Item item = this.policyContainer.addItem(XACMLObjectCopy.deepCopy(this.clipboardObject), target);
+ assert item != null;
+ this.tree.select(this.clipboardObject);
+
+ return true;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("100.0%");
+ mainLayout.setMargin(false);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("100.0%");
+
+ // horizontalLayoutToolbar
+ horizontalLayoutToolbar = buildHorizontalLayoutToolbar();
+ mainLayout.addComponent(horizontalLayoutToolbar);
+ mainLayout.setExpandRatio(horizontalLayoutToolbar, 1.0f);
+
+ // tree
+ tree = new TreeTable();
+ tree.setImmediate(true);
+ tree.setWidth("100.0%");
+ tree.setHeight("100.0%");
+ mainLayout.addComponent(tree);
+ mainLayout.setExpandRatio(tree, 1.0f);
+
+ return mainLayout;
+ }
+
+ @AutoGenerated
+ private HorizontalLayout buildHorizontalLayoutToolbar() {
+ // common part: create layout
+ horizontalLayoutToolbar = new HorizontalLayout();
+ horizontalLayoutToolbar.setImmediate(false);
+ horizontalLayoutToolbar.setWidth("-1px");
+ horizontalLayoutToolbar.setHeight("-1px");
+ horizontalLayoutToolbar.setMargin(true);
+ horizontalLayoutToolbar.setSpacing(true);
+
+ // checkBoxReadOnly
+ checkBoxReadOnly = new CheckBox();
+ checkBoxReadOnly.setCaption("Read Only");
+ checkBoxReadOnly.setImmediate(false);
+ checkBoxReadOnly
+ .setDescription("Check this to turn-off policy editing.");
+ checkBoxReadOnly.setWidth("-1px");
+ checkBoxReadOnly.setHeight("-1px");
+ horizontalLayoutToolbar.addComponent(checkBoxReadOnly);
+
+ // checkBoxAutoSave
+ checkBoxAutoSave = new CheckBox();
+ checkBoxAutoSave.setCaption("Auto Save");
+ checkBoxAutoSave.setImmediate(false);
+ checkBoxAutoSave
+ .setDescription("Check this to turn-on automatic saving of policy when a change occurs.");
+ checkBoxAutoSave.setWidth("-1px");
+ checkBoxAutoSave.setHeight("-1px");
+ horizontalLayoutToolbar.addComponent(checkBoxAutoSave);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save");
+ buttonSave.setImmediate(true);
+ buttonSave.setDescription("Click to save the policy.");
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ horizontalLayoutToolbar.addComponent(buttonSave);
+
+ // buttonViewXML
+ buttonViewXML = new Button();
+ buttonViewXML.setCaption("View XML");
+ buttonViewXML.setImmediate(true);
+ buttonViewXML.setWidth("-1px");
+ buttonViewXML.setHeight("-1px");
+ horizontalLayoutToolbar.addComponent(buttonViewXML);
+
+ // buttonExport
+ buttonExport = new Button();
+ buttonExport.setCaption("Export Policy");
+ buttonExport.setImmediate(false);
+ buttonExport.setWidth("-1px");
+ buttonExport.setHeight("-1px");
+ horizontalLayoutToolbar.addComponent(buttonExport);
+
+ return horizontalLayoutToolbar;
+ }
+}
[11/23] incubator-openaz git commit: Ported original att source to
openaz
Posted by pd...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/OnDemandFileDownloader.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/OnDemandFileDownloader.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/OnDemandFileDownloader.java
new file mode 100644
index 0000000..ba8cd82
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/OnDemandFileDownloader.java
@@ -0,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.xacml.admin.util;
+
+import java.io.IOException;
+
+import com.vaadin.server.FileDownloader;
+import com.vaadin.server.StreamResource;
+import com.vaadin.server.StreamResource.StreamSource;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.server.VaadinResponse;
+import com.vaadin.ui.UI;
+
+public class OnDemandFileDownloader extends FileDownloader {
+ private static final long serialVersionUID = 1L;
+ private final OnDemandStreamResource resource;
+
+ public interface OnDemandStreamResource extends StreamSource {
+ String getFilename ();
+ }
+
+ public OnDemandFileDownloader(OnDemandStreamResource resource) {
+ super(new StreamResource(resource, ""));
+ this.resource = resource;
+ if (this.resource == null) {
+ throw new NullPointerException("Can't send null resource");
+ }
+ }
+
+ @Override
+ public boolean handleConnectorRequest(VaadinRequest request,
+ VaadinResponse response, String path) throws IOException {
+ this.getResource().setFilename(this.resource.getFilename());
+ return super.handleConnectorRequest(request, response, path);
+ }
+
+ private StreamResource getResource() {
+ StreamResource resource = null;
+ UI.getCurrent().getSession().lock();
+ try {
+ resource = (StreamResource) this.getResource("dl");
+ } finally {
+ UI.getCurrent().getSession().unlock();
+ }
+ return resource;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/RESTfulPAPEngine.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/RESTfulPAPEngine.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/RESTfulPAPEngine.java
new file mode 100644
index 0000000..3958100
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/RESTfulPAPEngine.java
@@ -0,0 +1,495 @@
+/*
+ * 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.xacml.admin.util;
+
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.Collections;
+import java.util.Set;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.api.pap.PAPEngine;
+import org.apache.openaz.xacml.api.pap.PAPException;
+import org.apache.openaz.xacml.api.pap.PDP;
+import org.apache.openaz.xacml.api.pap.PDPGroup;
+import org.apache.openaz.xacml.api.pap.PDPPolicy;
+import org.apache.openaz.xacml.api.pap.PDPStatus;
+import org.apache.openaz.xacml.rest.XACMLRestProperties;
+import org.apache.openaz.xacml.std.pap.StdPDP;
+import org.apache.openaz.xacml.std.pap.StdPDPGroup;
+import org.apache.openaz.xacml.std.pap.StdPDPItemSetChangeNotifier;
+import org.apache.openaz.xacml.std.pap.StdPDPPolicy;
+import org.apache.openaz.xacml.std.pap.StdPDPStatus;
+import org.apache.openaz.xacml.util.XACMLProperties;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.type.CollectionType;
+
+/**
+ * Implementation of the PAPEngine interface that communicates with a PAP engine in a remote servlet
+ * through a RESTful interface
+ *
+ * @author glenngriffin
+ *
+ */
+public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAPEngine {
+ private static final Log logger = LogFactory.getLog(RESTfulPAPEngine.class);
+
+ //
+ // URL of the PAP Servlet that this Admin Console talks to
+ //
+ private String papServletURLString;
+
+ /**
+ * Set up link with PAP Servlet and get our initial set of Groups
+ * @throws Exception
+ */
+ public RESTfulPAPEngine (String myURLString) throws PAPException, IOException {
+ //
+ // Get our URL to the PAP servlet
+ //
+ this.papServletURLString = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL);
+ if (this.papServletURLString == null || this.papServletURLString.length() == 0) {
+ String message = "The property 'POLICYENGINE_ADMIN_ACTIVE' was not set during installation. Admin Console cannot call PAP.";
+ logger.error(message);
+ throw new PAPException(message);
+ }
+
+ //
+ // register this Admin Console with the PAP Servlet to get updates
+ //
+ Object newURL = sendToPAP("PUT", null, null, null, "adminConsoleURL=" + myURLString);
+ if (newURL != null) {
+ // assume this was a re-direct and try again
+ logger.warn("Redirecting to '" + newURL + "'");
+ this.papServletURLString = (String)newURL;
+ newURL = sendToPAP("PUT", null, null, null, "adminConsoleURL=" + myURLString);
+ if (newURL != null) {
+ logger.error("Failed to redirect to " + this.papServletURLString);
+ throw new PAPException("Failed to register with PAP");
+ }
+ }
+ }
+
+
+ //
+ // High-level commands used by the Admin Console code through the PAPEngine Interface
+ //
+
+ @Override
+ public PDPGroup getDefaultGroup() throws PAPException {
+ PDPGroup newGroup = (PDPGroup)sendToPAP("GET", null, null, StdPDPGroup.class, "groupId=", "default=");
+ return newGroup;
+ }
+
+ @Override
+ public void SetDefaultGroup(PDPGroup group) throws PAPException {
+ sendToPAP("POST", null, null, null, "groupId=" + group.getId(), "default=true");
+ }
+
+ @Override
+ public Set<PDPGroup> getPDPGroups() throws PAPException {
+ Set<PDPGroup> newGroupSet;
+ newGroupSet = (Set<PDPGroup>) this.sendToPAP("GET", null, Set.class, StdPDPGroup.class, "groupId=");
+ return Collections.unmodifiableSet(newGroupSet);
+ }
+
+
+ @Override
+ public PDPGroup getGroup(String id) throws PAPException {
+ PDPGroup newGroup = (PDPGroup)sendToPAP("GET", null, null, StdPDPGroup.class, "groupId=" + id);
+ return newGroup;
+ }
+
+ @Override
+ public void newGroup(String name, String description)
+ throws PAPException, NullPointerException {
+ String escapedName = null;
+ String escapedDescription = null;
+ try {
+ escapedName = URLEncoder.encode(name, "UTF-8");
+ escapedDescription = URLEncoder.encode(description, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new PAPException("Unable to send name or description to PAP: " + e.getMessage());
+ }
+
+ this.sendToPAP("POST", null, null, null, "groupId=", "groupName="+escapedName, "groupDescription=" + escapedDescription);
+ }
+
+
+ /**
+ * Update the configuration on the PAP for a single Group.
+ *
+ * @param group
+ * @return
+ * @throws PAPException
+ */
+ public void updateGroup(PDPGroup group) throws PAPException {
+
+ try {
+
+ //
+ // ASSUME that all of the policies mentioned in this group are already located in the correct directory on the PAP!
+ //
+ // Whenever a Policy is added to the group, that file must be automatically copied to the PAP from the Workspace.
+ //
+
+
+// // Copy all policies from the local machine's workspace to the PAP's PDPGroup directory.
+// // This is not efficient since most of the policies will already exist there.
+// // However, the policy files are (probably!) not too huge, and this is a good way to ensure that any corrupted files on the PAP get refreshed.
+//
+//TODO WRONG!!!! The policy.getStream() is based on the location in the PAP directory, not the Workspace.
+//TODO
+// for (PDPPolicy policy : group.getPolicies()) {
+// try (InputStream is = policy.getStream()) {
+// copyFile(policy.getId(), group, is);
+// }
+// }
+
+ // now update the group object on the PAP
+
+ sendToPAP("PUT", group, null, null, "groupId=" + group.getId());
+ } catch (Exception e) {
+ String message = "Unable to PUT policy '" + group.getId() + "', e:" + e;
+ logger.error(message, e);
+ throw new PAPException(message);
+ }
+ }
+
+
+ @Override
+ public void removeGroup(PDPGroup group, PDPGroup newGroup)
+ throws PAPException, NullPointerException {
+ String moveToGroupString = null;
+ if (newGroup != null) {
+ moveToGroupString = "movePDPsToGroupId=" + newGroup.getId();
+ }
+ sendToPAP("DELETE", null, null, null, "groupId=" + group.getId(), moveToGroupString);
+ }
+
+ @Override
+ public PDPGroup getPDPGroup(PDP pdp) throws PAPException {
+ return getPDPGroup(pdp.getId());
+ }
+
+ @Override
+ public PDPGroup getPDPGroup(String pdpId) throws PAPException {
+ PDPGroup newGroup = (PDPGroup)sendToPAP("GET", null, null, StdPDPGroup.class, "groupId=", "pdpId=" + pdpId, "getPDPGroup=");
+ return newGroup;
+ }
+
+ @Override
+ public PDP getPDP(String pdpId) throws PAPException {
+ PDP newPDP = (PDP)sendToPAP("GET", null, null, StdPDP.class, "groupId=", "pdpId=" + pdpId);
+ return newPDP;
+ }
+
+ @Override
+ public void newPDP(String id, PDPGroup group, String name, String description) throws PAPException,
+ NullPointerException {
+ StdPDP newPDP = new StdPDP(id, name, description);
+ sendToPAP("PUT", newPDP, null, null, "groupId=" + group.getId(), "pdpId=" + id);
+ }
+
+
+ @Override
+ public void movePDP(PDP pdp, PDPGroup newGroup) throws PAPException {
+ sendToPAP("POST", null, null, null, "groupId=" + newGroup.getId(), "pdpId=" + pdp.getId());
+ }
+
+ @Override
+ public void updatePDP(PDP pdp) throws PAPException {
+ PDPGroup group = getPDPGroup(pdp);
+ sendToPAP("PUT", pdp, null, null, "groupId=" + group.getId(), "pdpId=" + pdp.getId());
+ }
+
+ @Override
+ public void removePDP(PDP pdp) throws PAPException {
+ PDPGroup group = getPDPGroup(pdp);
+ sendToPAP("DELETE", null, null, null, "groupId=" + group.getId(), "pdpId=" + pdp.getId());
+ }
+
+
+
+ @Override
+ public void publishPolicy(String id, String name, boolean isRoot,
+ InputStream policy, PDPGroup group) throws PAPException {
+
+//TODO - this method should take as input a Policy object, add it to the group, then call updateGroup
+//TODO - ?? Where does the Policy object (with the version info) get created?
+
+ // copy the (one) file into the target directory on the PAP servlet
+ copyFile(id, group, policy);
+
+ // adjust the local copy of the group to include the new policy
+ PDPPolicy pdpPolicy = new StdPDPPolicy(id, isRoot, name);
+ group.getPolicies().add(pdpPolicy);
+
+ // tell the PAP servlet to include the policy in the configuration
+ updateGroup(group);
+ }
+
+
+
+ /**
+ * Copy a single Policy file from the input stream to the PAP Servlet.
+ * Either this works (silently) or it throws an exception.
+ *
+ * @param policyId
+ * @param group
+ * @param policy
+ * @return
+ * @throws PAPException
+ */
+ public void copyFile(String policyId, PDPGroup group, InputStream policy) throws PAPException {
+ // send the policy file to the PAP Servlet
+ try {
+ sendToPAP("POST", policy, null, null, "groupId=" + group.getId(), "policyId="+policyId);
+ } catch (Exception e) {
+ String message = "Unable to PUT policy '" + policyId + "', e:" + e;
+ logger.error(message, e);
+ throw new PAPException(message);
+ }
+ }
+
+
+ @Override
+ public void copyPolicy(PDPPolicy policy, PDPGroup group) throws PAPException {
+ if (policy == null || group == null) {
+ throw new PAPException("Null input policy="+policy+" group="+group);
+ }
+ try (InputStream is = new FileInputStream(new File(policy.getLocation())) ) {
+ copyFile(policy.getId(), group, is );
+ } catch (Exception e) {
+ String message = "Unable to PUT policy '" + policy.getId() + "', e:" + e;
+ logger.error(message, e);
+ throw new PAPException(message);
+ }
+ }
+
+
+
+
+ @Override
+ public void removePolicy(PDPPolicy policy, PDPGroup group) throws PAPException {
+ throw new PAPException("NOT IMPLEMENTED");
+
+ }
+
+
+
+ /**
+ * Special operation - Similar to the normal PAP operations but this one contacts the PDP directly
+ * to get detailed status info.
+ *
+ * @param pdp
+ * @return
+ * @throws PAPException
+ */
+ @Override
+ public PDPStatus getStatus(PDP pdp) throws PAPException {
+ StdPDPStatus status = (StdPDPStatus)sendToPAP("GET", pdp, null, StdPDPStatus.class);
+ return status;
+ }
+
+
+
+
+ //
+ // Internal Operations called by the PAPEngine Interface methods
+ //
+
+ /**
+ * Send a request to the PAP Servlet and get the response.
+ *
+ * The content is either an InputStream to be copied to the Request OutputStream
+ * OR it is an object that is to be encoded into JSON and pushed into the Request OutputStream.
+ *
+ * The Request parameters may be encoded in multiple "name=value" sets, or parameters may be combined by the caller.
+ *
+ * @param method
+ * @param content - EITHER an InputStream OR an Object to be encoded in JSON
+ * @param collectionTypeClass
+ * @param responseContentClass
+ * @param parameters
+ * @return
+ * @throws Exception
+ */
+ private Object sendToPAP(String method, Object content, Class collectionTypeClass, Class responseContentClass, String... parameters ) throws PAPException {
+ HttpURLConnection connection = null;
+ try {
+ String fullURL = papServletURLString;
+ if (parameters != null && parameters.length > 0) {
+ String queryString = "";
+ for (String p : parameters) {
+ queryString += "&" + p;
+ }
+ fullURL += "?" + queryString.substring(1);
+ }
+
+ // special case - Status (actually the detailed status) comes from the PDP directly, not the PAP
+ if (method.equals("GET") &&
+ content instanceof PDP &&
+ responseContentClass == StdPDPStatus.class) {
+ // Adjust the url and properties appropriately
+ fullURL = ((PDP)content).getId() + "?type=Status";
+ content = null;
+ }
+
+
+ URL url = new URL(fullURL);
+
+ //
+ // Open up the connection
+ //
+ connection = (HttpURLConnection)url.openConnection();
+ //
+ // Setup our method and headers
+ //
+ connection.setRequestMethod(method);
+// connection.setRequestProperty("Accept", "text/x-java-properties");
+// connection.setRequestProperty("Content-Type", "text/x-java-properties");
+ connection.setUseCaches(false);
+ //
+ // Adding this in. It seems the HttpUrlConnection class does NOT
+ // properly forward our headers for POST re-direction. It does so
+ // for a GET re-direction.
+ //
+ // So we need to handle this ourselves.
+ //
+ connection.setInstanceFollowRedirects(false);
+ connection.setDoOutput(true);
+ connection.setDoInput(true);
+ if (content != null) {
+ if (content instanceof InputStream) {
+ try {
+ //
+ // Send our current policy configuration
+ //
+ try (OutputStream os = connection.getOutputStream()) {
+ int count = IOUtils.copy((InputStream)content, os);
+ if (logger.isDebugEnabled()) {
+ logger.debug("copied to output, bytes="+count);
+ }
+ }
+ } catch (Exception e) {
+ logger.error("Failed to write content in '" + method + "'", e);
+ throw e;
+ }
+ } else {
+ // The content is an object to be encoded in JSON
+ ObjectMapper mapper = new ObjectMapper();
+ mapper.writeValue(connection.getOutputStream(), content);
+ }
+ }
+ //
+ // Do the connect
+ //
+ connection.connect();
+ if (connection.getResponseCode() == 204) {
+ logger.info("Success - no content.");
+ return null;
+ } else if (connection.getResponseCode() == 200) {
+ logger.info("Success. We have a return object.");
+
+ // get the response content into a String
+ String json = null;
+ // read the inputStream into a buffer (trick found online scans entire input looking for end-of-file)
+ java.util.Scanner scanner = new java.util.Scanner(connection.getInputStream());
+ scanner.useDelimiter("\\A");
+ json = scanner.hasNext() ? scanner.next() : "";
+ scanner.close();
+ logger.info("JSON response from PAP: " + json);
+
+ // convert Object sent as JSON into local object
+ ObjectMapper mapper = new ObjectMapper();
+
+ if (collectionTypeClass != null) {
+ // collection of objects expected
+ final CollectionType javaType =
+ mapper.getTypeFactory().constructCollectionType(collectionTypeClass, responseContentClass);
+
+ Object objectFromJSON = mapper.readValue(json, javaType);
+ return objectFromJSON;
+ } else {
+ // single value object expected
+ Object objectFromJSON = mapper.readValue(json, responseContentClass);
+ return objectFromJSON;
+ }
+
+ } else if (connection.getResponseCode() >= 300 && connection.getResponseCode() <= 399) {
+ // redirection
+ String newURL = connection.getHeaderField("Location");
+ if (newURL == null) {
+ logger.error("No Location header to redirect to when response code="+connection.getResponseCode());
+ throw new IOException("No redirect Location header when response code="+connection.getResponseCode());
+ }
+ int qIndex = newURL.indexOf("?");
+ if (qIndex > 0) {
+ newURL = newURL.substring(0, qIndex);
+ }
+ logger.info("Redirect seen. Redirecting " + fullURL + " to " + newURL);
+ return newURL;
+ } else {
+ logger.warn("Unexpected response code: " + connection.getResponseCode() + " message: " + connection.getResponseMessage());
+ throw new IOException("Server Response: " + connection.getResponseCode() + ": " + connection.getResponseMessage());
+ }
+
+ } catch (Exception e) {
+ logger.error("HTTP Request/Response to PAP: " + e,e);
+ throw new PAPException("Request/Response threw :" + e);
+ } finally {
+ // cleanup the connection
+ if (connection != null) {
+ try {
+ // For some reason trying to get the inputStream from the connection
+ // throws an exception rather than returning null when the InputStream does not exist.
+ InputStream is = null;
+ try {
+ is = connection.getInputStream();
+ } catch (Exception e1) { //NOPMD
+ // ignore this
+ }
+ if (is != null) {
+ is.close();
+ }
+
+ } catch (IOException ex) {
+ logger.error("Failed to close connection: " + ex, ex);
+ }
+ connection.disconnect();
+ }
+ }
+ }
+}
+
+
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/XACMLConstants.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/XACMLConstants.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/XACMLConstants.java
new file mode 100644
index 0000000..28bf377
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/XACMLConstants.java
@@ -0,0 +1,237 @@
+/*
+ * 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.xacml.admin.util;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.api.XACML3;
+
+public class XACMLConstants {
+
+ public static final Set<Identifier> SUBJECT_CATEGORIES = new HashSet<Identifier>();
+ public static final Set<Identifier> ACTION_CATEGORIES = new HashSet<Identifier>();
+ public static final Set<Identifier> RESOURCE_CATEGORIES = new HashSet<Identifier>();
+ public static final Set<Identifier> ENVIRONMENT_CATEGORIES = new HashSet<Identifier>();
+
+ public static final Set<Identifier> CATEGORIES = new HashSet<Identifier>();
+ static {
+ SUBJECT_CATEGORIES.addAll(Arrays.asList(XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT,
+ XACML3.ID_SUBJECT_CATEGORY_CODEBASE,
+ XACML3.ID_SUBJECT_CATEGORY_INTERMEDIARY_SUBJECT,
+ XACML3.ID_SUBJECT_CATEGORY_RECIPIENT_SUBJECT,
+ XACML3.ID_SUBJECT_CATEGORY_REQUESTING_MACHINE)
+ );
+
+ ACTION_CATEGORIES.addAll(Arrays.asList(
+ XACML3.ID_ATTRIBUTE_CATEGORY_ACTION)
+ );
+
+ RESOURCE_CATEGORIES.addAll(Arrays.asList(
+ XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE)
+ );
+
+ ENVIRONMENT_CATEGORIES.addAll(Arrays.asList(
+ XACML3.ID_ATTRIBUTE_CATEGORY_ENVIRONMENT)
+ );
+
+ CATEGORIES.addAll(SUBJECT_CATEGORIES);
+ CATEGORIES.addAll(ACTION_CATEGORIES);
+ CATEGORIES.addAll(RESOURCE_CATEGORIES);
+ CATEGORIES.addAll(ENVIRONMENT_CATEGORIES);
+
+ }
+ public static final Set<Identifier> DATATYPES = new HashSet<Identifier>();
+ static {
+ DATATYPES.addAll(Arrays.asList(XACML3.ID_DATATYPE_STRING,
+ XACML3.ID_DATATYPE_BOOLEAN,
+ XACML3.ID_DATATYPE_INTEGER,
+ XACML3.ID_DATATYPE_DOUBLE,
+ XACML3.ID_DATATYPE_TIME,
+ XACML3.ID_DATATYPE_DATE,
+ XACML3.ID_DATATYPE_DATETIME,
+ XACML3.ID_DATATYPE_DAYTIMEDURATION,
+ XACML3.ID_DATATYPE_YEARMONTHDURATION,
+ XACML3.ID_DATATYPE_ANYURI,
+ XACML3.ID_DATATYPE_HEXBINARY,
+ XACML3.ID_DATATYPE_BASE64BINARY,
+ XACML3.ID_DATATYPE_RFC822NAME,
+ XACML3.ID_DATATYPE_X500NAME,
+ XACML3.ID_DATATYPE_IPADDRESS,
+ XACML3.ID_DATATYPE_DNSNAME));
+ }
+
+ public static final Set<Identifier> POLICY_ALGORITHMS = new HashSet<Identifier>();
+ static {
+ POLICY_ALGORITHMS.addAll(Arrays.asList(
+ XACML3.ID_POLICY_DENY_OVERRIDES,
+ XACML3.ID_POLICY_DENY_UNLESS_PERMIT,
+ XACML3.ID_POLICY_FIRST_APPLICABLE,
+ XACML3.ID_POLICY_ON_PERMIT_APPLY_SECOND,
+ XACML3.ID_POLICY_ONLY_ONE_APPLICABLE,
+ XACML3.ID_POLICY_ORDERED_DENY_OVERRIDES,
+ XACML3.ID_POLICY_ORDERED_PERMIT_OVERRIDES,
+ XACML3.ID_POLICY_PERMIT_OVERRIDES,
+ XACML3.ID_POLICY_PERMIT_UNLESS_DENY
+ ));
+ }
+
+ public static final Set<Identifier> RULE_ALGORITHMS = new HashSet<Identifier>();
+ static {
+ RULE_ALGORITHMS.addAll(Arrays.asList(
+ XACML3.ID_RULE_DENY_OVERRIDES,
+ XACML3.ID_RULE_DENY_UNLESS_PERMIT,
+ XACML3.ID_RULE_FIRST_APPLICABLE,
+ XACML3.ID_RULE_ONLY_ONE_APPLICABLE,
+ XACML3.ID_RULE_ORDERED_DENY_OVERRIDES,
+ XACML3.ID_RULE_ORDERED_PERMIT_OVERRIDES,
+ XACML3.ID_RULE_PERMIT_OVERRIDES,
+ XACML3.ID_RULE_PERMIT_UNLESS_DENY
+ ));
+ }
+
+ public static final Set<Identifier> STANDARD_ATTRIBUTES = new HashSet<Identifier>();
+ static {
+ STANDARD_ATTRIBUTES.addAll(Arrays.asList(
+ XACML3.ID_SUBJECT_SUBJECT_ID,
+ XACML3.ID_SUBJECT_SUBJECT_ID_QUALIFIER,
+ XACML3.ID_SUBJECT_KEY_INFO,
+ XACML3.ID_SUBJECT_AUTHENTICATION_TIME,
+ XACML3.ID_SUBJECT_AUTHENTICATION_METHOD,
+ XACML3.ID_SUBJECT_REQUEST_TIME,
+ XACML3.ID_SUBJECT_SESSION_START_TIME,
+ XACML3.ID_SUBJECT_AUTHN_LOCALITY_IP_ADDRESS,
+ XACML3.ID_SUBJECT_AUTHN_LOCALITY_DNS_NAME,
+ XACML3.ID_SUBJECT_ROLE,
+ XACML3.ID_ACTION_ACTION_ID,
+ XACML3.ID_ACTION_IMPLIED_ACTION,
+ XACML3.ID_RESOURCE_RESOURCE_ID,
+ XACML3.ID_RESOURCE_RESOURCE_LOCATION,
+ XACML3.ID_RESOURCE_SIMPLE_FILE_NAME,
+ XACML3.ID_ENVIRONMENT_CURRENT_DATE,
+ XACML3.ID_ENVIRONMENT_CURRENT_TIME,
+ XACML3.ID_ENVIRONMENT_CURRENT_DATETIME
+ ));
+ }
+
+ public static final Map<Identifier, Set<Identifier>> MAP_STANDARD_CATEGORIES = new HashMap<Identifier, Set<Identifier>>();
+ static {
+ MAP_STANDARD_CATEGORIES.put(XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT, new HashSet<Identifier>(Arrays.asList(
+ XACML3.ID_SUBJECT_SUBJECT_ID,
+ XACML3.ID_SUBJECT_SUBJECT_ID_QUALIFIER,
+ XACML3.ID_SUBJECT_KEY_INFO,
+ XACML3.ID_SUBJECT_AUTHENTICATION_TIME,
+ XACML3.ID_SUBJECT_AUTHENTICATION_METHOD,
+ XACML3.ID_SUBJECT_REQUEST_TIME,
+ XACML3.ID_SUBJECT_SESSION_START_TIME,
+ XACML3.ID_SUBJECT_AUTHN_LOCALITY_IP_ADDRESS,
+ XACML3.ID_SUBJECT_AUTHN_LOCALITY_DNS_NAME,
+ XACML3.ID_SUBJECT_ROLE
+ )));
+ MAP_STANDARD_CATEGORIES.put(XACML3.ID_SUBJECT_CATEGORY_CODEBASE, new HashSet<Identifier>(Arrays.asList(
+ XACML3.ID_SUBJECT_SUBJECT_ID,
+ XACML3.ID_SUBJECT_SUBJECT_ID_QUALIFIER,
+ XACML3.ID_SUBJECT_KEY_INFO,
+ XACML3.ID_SUBJECT_AUTHENTICATION_TIME,
+ XACML3.ID_SUBJECT_AUTHENTICATION_METHOD,
+ XACML3.ID_SUBJECT_REQUEST_TIME,
+ XACML3.ID_SUBJECT_SESSION_START_TIME,
+ XACML3.ID_SUBJECT_AUTHN_LOCALITY_IP_ADDRESS,
+ XACML3.ID_SUBJECT_AUTHN_LOCALITY_DNS_NAME,
+ XACML3.ID_SUBJECT_ROLE
+ )));
+ MAP_STANDARD_CATEGORIES.put(XACML3.ID_SUBJECT_CATEGORY_INTERMEDIARY_SUBJECT, new HashSet<Identifier>(Arrays.asList(
+ XACML3.ID_SUBJECT_SUBJECT_ID,
+ XACML3.ID_SUBJECT_SUBJECT_ID_QUALIFIER,
+ XACML3.ID_SUBJECT_KEY_INFO,
+ XACML3.ID_SUBJECT_AUTHENTICATION_TIME,
+ XACML3.ID_SUBJECT_AUTHENTICATION_METHOD,
+ XACML3.ID_SUBJECT_REQUEST_TIME,
+ XACML3.ID_SUBJECT_SESSION_START_TIME,
+ XACML3.ID_SUBJECT_AUTHN_LOCALITY_IP_ADDRESS,
+ XACML3.ID_SUBJECT_AUTHN_LOCALITY_DNS_NAME,
+ XACML3.ID_SUBJECT_ROLE
+ )));
+ MAP_STANDARD_CATEGORIES.put(XACML3.ID_SUBJECT_CATEGORY_RECIPIENT_SUBJECT, new HashSet<Identifier>(Arrays.asList(
+ XACML3.ID_SUBJECT_SUBJECT_ID,
+ XACML3.ID_SUBJECT_SUBJECT_ID_QUALIFIER,
+ XACML3.ID_SUBJECT_KEY_INFO,
+ XACML3.ID_SUBJECT_AUTHENTICATION_TIME,
+ XACML3.ID_SUBJECT_AUTHENTICATION_METHOD,
+ XACML3.ID_SUBJECT_REQUEST_TIME,
+ XACML3.ID_SUBJECT_SESSION_START_TIME,
+ XACML3.ID_SUBJECT_AUTHN_LOCALITY_IP_ADDRESS,
+ XACML3.ID_SUBJECT_AUTHN_LOCALITY_DNS_NAME,
+ XACML3.ID_SUBJECT_ROLE
+ )));
+ MAP_STANDARD_CATEGORIES.put(XACML3.ID_SUBJECT_CATEGORY_REQUESTING_MACHINE, new HashSet<Identifier>(Arrays.asList(
+ XACML3.ID_SUBJECT_SUBJECT_ID,
+ XACML3.ID_SUBJECT_SUBJECT_ID_QUALIFIER,
+ XACML3.ID_SUBJECT_KEY_INFO,
+ XACML3.ID_SUBJECT_AUTHENTICATION_TIME,
+ XACML3.ID_SUBJECT_AUTHENTICATION_METHOD,
+ XACML3.ID_SUBJECT_REQUEST_TIME,
+ XACML3.ID_SUBJECT_SESSION_START_TIME,
+ XACML3.ID_SUBJECT_AUTHN_LOCALITY_IP_ADDRESS,
+ XACML3.ID_SUBJECT_AUTHN_LOCALITY_DNS_NAME,
+ XACML3.ID_SUBJECT_ROLE
+ )));
+ MAP_STANDARD_CATEGORIES.put(XACML3.ID_ATTRIBUTE_CATEGORY_ACTION, new HashSet<Identifier>(Arrays.asList(
+ XACML3.ID_ACTION_ACTION_ID,
+ XACML3.ID_ACTION_IMPLIED_ACTION
+ )));
+ MAP_STANDARD_CATEGORIES.put(XACML3.ID_ATTRIBUTE_CATEGORY_RESOURCE, new HashSet<Identifier>(Arrays.asList(
+ XACML3.ID_RESOURCE_RESOURCE_ID,
+ XACML3.ID_RESOURCE_RESOURCE_LOCATION,
+ XACML3.ID_RESOURCE_SIMPLE_FILE_NAME
+ )));
+ MAP_STANDARD_CATEGORIES.put(XACML3.ID_ATTRIBUTE_CATEGORY_ENVIRONMENT, new HashSet<Identifier>(Arrays.asList(
+ XACML3.ID_ENVIRONMENT_CURRENT_DATE,
+ XACML3.ID_ENVIRONMENT_CURRENT_TIME,
+ XACML3.ID_ENVIRONMENT_CURRENT_DATETIME
+ )));
+ }
+
+ public static String extractShortName(String xacmlID) {
+ if (xacmlID == null) {
+ return null;
+ }
+ if (xacmlID.startsWith("http:")) {
+ String [] parts = xacmlID.split("[#]");
+ if (parts != null && parts.length > 0) {
+ return parts[parts.length - 1];
+ }
+ return null;
+ }
+ if (xacmlID.startsWith("urn") || xacmlID.contains(":")) {
+ String[] parts = xacmlID.split("[:]");
+
+ if (parts != null && parts.length > 0) {
+ return parts[parts.length - 1];
+ }
+ }
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/XACMLFunctionValidator.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/XACMLFunctionValidator.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/XACMLFunctionValidator.java
new file mode 100644
index 0000000..7ef7e60
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/XACMLFunctionValidator.java
@@ -0,0 +1,506 @@
+/*
+ * 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.xacml.admin.util;
+
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.jpa.Datatype;
+import org.apache.openaz.xacml.admin.jpa.FunctionArgument;
+import org.apache.openaz.xacml.admin.jpa.FunctionDefinition;
+import org.apache.openaz.xacml.api.XACML3;
+import org.apache.openaz.xacml.std.IdentifierImpl;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeAssignmentExpressionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeSelectorType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ConditionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.FunctionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableDefinitionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableReferenceType;
+
+public class XACMLFunctionValidator {
+ private static Log logger = LogFactory.getLog(XACMLFunctionValidator.class);
+
+ public static boolean validNumberOfArguments(ApplyType apply) {
+ try {
+ //
+ // Sanity check
+ //
+ if (apply == null) {
+ throw new IllegalArgumentException("Must supply a non-null apply object.");
+ }
+ //
+ // Get the function
+ //
+ FunctionDefinition function = JPAUtils.getFunctionIDMap().get(apply.getFunctionId());
+ if (function == null) {
+ throw new Exception("Invalid function id: " + apply.getFunctionId());
+ }
+ //
+ // Now check argument list, do we have the minimum?
+ //
+ List<JAXBElement<?>> applyArgs = apply.getExpression();
+ if (applyArgs.isEmpty()) {
+ //
+ // May not need any args
+ //
+ if (function.getArgLb() > 0) {
+ throw new Exception ("Number of Args mismatch, expecting at least " +
+ function.getArgLb() + " arguments but have zero.");
+ }
+ } else {
+ if (applyArgs.size() < function.getArgLb()) {
+ throw new Exception ("Number of Args mismatch, expecting at least " +
+ function.getArgLb() + " arguments but have " + applyArgs.size());
+ }
+ }
+ //
+ // Is there an upper bound?
+ //
+ if (function.getArgUb() != -1 && applyArgs.size() != function.getArgUb()) {
+ throw new Exception ("Number of Args mismatch, expecting at most " +
+ function.getArgUb() + " arguments but have " + applyArgs.size());
+ }
+ } catch (Exception e) {
+ logger.error("Number of arguments incorrect: " + e);
+ return false;
+ }
+ return true;
+ }
+
+ public static boolean canHaveMoreArguments(ConditionType condition) {
+ if (condition.getExpression() == null || condition.getExpression().getValue() == null) {
+ return true;
+ }
+ Object expression = condition.getExpression().getValue();
+ if (expression instanceof ApplyType) {
+ return XACMLFunctionValidator.canHaveMoreArguments((ApplyType) expression);
+ }
+ return false;
+ }
+
+ public static boolean canHaveMoreArguments(VariableDefinitionType variable) {
+ if (variable.getExpression() == null || variable.getExpression().getValue() == null) {
+ return true;
+ }
+ Object expression = variable.getExpression().getValue();
+ if (expression instanceof ApplyType) {
+ return XACMLFunctionValidator.canHaveMoreArguments((ApplyType) expression);
+ }
+ return false;
+ }
+
+ public static boolean canHaveMoreArguments(AttributeAssignmentExpressionType assignment) {
+ if (assignment.getExpression() == null || assignment.getExpression().getValue() == null) {
+ return true;
+ }
+ Object expression = assignment.getExpression().getValue();
+ if (expression instanceof ApplyType) {
+ return XACMLFunctionValidator.canHaveMoreArguments((ApplyType) expression);
+ }
+ return false;
+ }
+
+ public static boolean canHaveMoreArguments(ApplyType apply) {
+ //
+ // Sanity check
+ //
+ if (apply == null) {
+ throw new IllegalArgumentException("Must supply a non-null apply object.");
+ }
+ //
+ // Get the function
+ //
+ FunctionDefinition function = JPAUtils.getFunctionIDMap().get(apply.getFunctionId());
+ if (function == null) {
+ throw new IllegalArgumentException("Invalid function id: " + apply.getFunctionId());
+ }
+ //
+ // Is there no upper bound?
+ //
+ if (function.getArgUb() == -1) {
+ //
+ // No limit to the number of arguments
+ //
+ return true;
+ }
+ //
+ // There is an upper bound - have we met it?
+ //
+ List<JAXBElement<?>> applyArgs = apply.getExpression();
+ if (applyArgs.size() < function.getArgUb()) {
+ //
+ // We have not met the upper bound, so yes we can
+ // add more arguments.
+ //
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean isFunctionAvailable(FunctionDefinition function, ApplyType apply, FunctionArgument argument) {
+ //
+ // Does it return correct datatype?
+ //
+ if (argument != null) {
+ //
+ // Does it match?
+ //
+ if (function.getDatatypeBean().getXacmlId().equals(argument.getDatatypeBean().getXacmlId())) {
+ return false;
+ }
+ if (function.getIsBagReturn() != argument.getIsBag()) {
+ return false;
+ }
+ }
+ //
+ // Check each argument
+ //
+ int i;
+ for (i = 0; i < apply.getExpression().size(); i++) {
+ //
+ // Get the argument
+ //
+ JAXBElement<?> arg = apply.getExpression().get(i);
+ //
+ // Get what the argument should be
+ //
+ FunctionArgument functionArg = XACMLFunctionValidator.getFunctionArgument(i + 1, function);
+ //
+ // Sanity check
+ //
+ if (arg == null || arg.getValue() == null || functionArg == null) {
+ //
+ // Something screwy with the list, just return not available. They will have
+ // delete items that are bad.
+ //
+ return false;
+ }
+ //
+ // Does it match?
+ //
+ if (XACMLFunctionValidator.isArgumentValid(arg.getValue(), functionArg) == false) {
+ return false;
+ }
+ }
+ //
+ // Done checking, we don't care if there are more args needed. Just want to know if this
+ // function can fit with the existing arguments.
+ //
+ return true;
+ }
+
+ public static FunctionDefinition validateApply(ApplyType apply, FunctionArgument argument) {
+ //
+ // Sanity check
+ //
+ if (apply == null) {
+ throw new IllegalArgumentException("Must supply a non-null apply object.");
+ }
+ try {
+ //
+ // Get the function
+ //
+ FunctionDefinition function = JPAUtils.getFunctionIDMap().get(apply.getFunctionId());
+ if (function == null) {
+ throw new Exception("Invalid function id: " + apply.getFunctionId());
+ }
+ //
+ // Does it return correct datatype?
+ //
+ if (argument != null) {
+ //
+ // Does it match?
+ //
+ if (argument.getDatatypeBean() != null) {
+ if (! function.getDatatypeBean().getXacmlId().equals(argument.getDatatypeBean().getXacmlId())) {
+ throw new Exception("Function return datatype(" + function.getDatatypeBean() +
+ ") does not match expected argument datatype (" + argument.getDatatypeBean());
+ }
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Argument datatype bean is null - any datatype should work.");
+ }
+ }
+ if (function.getIsBagReturn() != argument.getIsBag()) {
+ throw new Exception("Function is bag (" + function.getIsBagReturn() +
+ ") does not match argument isBag(" + argument.getIsBag());
+ }
+ }
+ //
+ // Now check argument list, do we have the minimum?
+ //
+ List<JAXBElement<?>> applyArgs = apply.getExpression();
+ if (applyArgs == null) {
+ //
+ // May not need any args
+ //
+ if (function.getArgLb() > 0) {
+ throw new Exception ("Number of Args mismatch, expecting at least " +
+ function.getArgLb() + " arguments but have zero.");
+ }
+ } else {
+ if (applyArgs.size() < function.getArgLb()) {
+ throw new Exception ("Number of Args mismatch, expecting at least " +
+ function.getArgLb() + " arguments but have " + applyArgs.size());
+ }
+ }
+ //
+ // Is there an upper bound?
+ //
+ if (function.getArgUb() != -1 && applyArgs.size() != function.getArgUb()) {
+ throw new Exception ("Number of Args mismatch, expecting at most " +
+ function.getArgUb() + " arguments but have " + applyArgs.size());
+ }
+ //
+ // Check each argument
+ //
+ int i;
+ for (i = 0; i < applyArgs.size(); i++) {
+ //
+ // Get the argument
+ //
+ JAXBElement<?> arg = applyArgs.get(i);
+ //
+ // Get what the argument should be
+ //
+ FunctionArgument functionArg = XACMLFunctionValidator.getFunctionArgument(i + 1, function);
+ //
+ // Sanity check
+ //
+ if (arg == null || arg.getValue() == null || functionArg == null) {
+ throw new NullPointerException("An argument is null: Element" + arg + " Function Arg: " + functionArg);
+ }
+ //
+ // Does it match?
+ //
+ if (XACMLFunctionValidator.isArgumentValid(arg.getValue(), functionArg) == false) {
+ throw new Exception("Invalid Argument: " + arg.getValue());
+ }
+ }
+ //
+ // Done checking, just return the function which has the datatype
+ // and if it is a bag.
+ //
+ return function;
+ } catch(Exception e) {
+ logger.error("Function is not valid: " + apply.getFunctionId() + " argument: " + argument + " " + e);
+ return null;
+ }
+ }
+
+ private static boolean isArgumentValid(Object value, FunctionArgument functionArg) {
+ if (value instanceof ApplyType) {
+ //
+ // Recursively validate the Apply.
+ //
+ FunctionDefinition function = XACMLFunctionValidator.validateApply((ApplyType) value, functionArg);
+ if (functionArg.getDatatypeBean() == null || function.getDatatypeBean().getId() == functionArg.getDatatypeBean().getId()) {
+ if (function.getIsBagReturn() == functionArg.getIsBag()) {
+ return true;
+ }
+ logger.error("isBag does not match: " + function.getIsBagReturn() + " " + functionArg.getIsBag());
+ }
+ logger.error("Datatypes do not match: " + function.getDatatypeBean().getShortName() + " " + functionArg.getDatatypeBean().getShortName());
+ } else if (value instanceof AttributeValueType) {
+ AttributeValueType val = (AttributeValueType) value;
+ Datatype datatype = JPAUtils.findDatatype(new IdentifierImpl(val.getDataType()));
+ if (functionArg.getDatatypeBean() == null || datatype.getId() == functionArg.getDatatypeBean().getId()) {
+ //
+ // TODO Is bag?
+ //
+ return true;
+ }
+ logger.error("Datatypes do not match: " + datatype.getShortName() + " " + functionArg.getDatatypeBean().getShortName());
+ } else if (value instanceof AttributeDesignatorType) {
+ AttributeDesignatorType designator = (AttributeDesignatorType) value;
+ Datatype datatype = JPAUtils.findDatatype(new IdentifierImpl(designator.getDataType()));
+ if (functionArg.getDatatypeBean() == null || datatype.getId() == functionArg.getDatatypeBean().getId()) {
+ //
+ // TODO Is bag?
+ //
+ return true;
+ }
+ logger.error("Datatypes do not match: " + datatype.getShortName() + " " + functionArg.getDatatypeBean().getShortName());
+ } else if (value instanceof AttributeSelectorType) {
+ AttributeSelectorType selector = (AttributeSelectorType) value;
+ Datatype datatype = JPAUtils.findDatatype(new IdentifierImpl(selector.getDataType()));
+ if (functionArg.getDatatypeBean() == null || datatype.getId() == functionArg.getDatatypeBean().getId()) {
+ //
+ // TODO Is bag?
+ //
+ return true;
+ }
+ logger.error("Datatypes do not match: " + datatype.getShortName() + " " + functionArg.getDatatypeBean().getShortName());
+ } else if (value instanceof VariableReferenceType) {
+ //
+ // We can't verify this at this time.
+ // The user can define variables in other parts of the policy file
+ // or another policy file. This should be flagged if the user performs
+ // simulation and other testing on the policy before deployment.
+ //
+ return true;
+ } else if (value instanceof FunctionType) {
+ //
+ // Does this function exist?
+ //
+ FunctionDefinition function = JPAUtils.findFunction(((FunctionType) value).getFunctionId());
+ if (function == null) {
+ //
+ // Could not find function
+ //
+ logger.warn("Could not find function in our database: " + ((FunctionType) value).getFunctionId());
+ return false;
+ }
+ //
+ // Does this function return the correct data type?
+ //
+ if (functionArg.getDatatypeBean() == null || function.getDatatypeBean().getId() == functionArg.getDatatypeBean().getId()) {
+ return true;
+ }
+ logger.error("Datatypes do not match: " + function.getDatatypeBean().getShortName() + " " + functionArg.getDatatypeBean().getShortName());
+ }
+ return false;
+ }
+
+ public static FunctionArgument getFunctionArgument(int index, FunctionDefinition function) {
+ if (index < 1) {
+ throw new IllegalArgumentException("The index must be 1-based");
+ }
+ //
+ // Setup what the actual lower bound and upper bounds are
+ // within the list.
+ //
+// int lowerBound = function.getArgLb();
+// if (lowerBound == 0) {
+// lowerBound = 1;
+// }
+ int upperBound = function.getArgUb();
+ if (upperBound == -1) {
+ upperBound = function.getFunctionArguments().size();
+ }
+ //
+ // The list may not be sorted, so make sure we find
+ // the actual argument index
+ //
+ int argumentIndex = index;
+ if (index >= upperBound) {
+ argumentIndex = upperBound;
+ }
+ for (FunctionArgument arg : function.getFunctionArguments()) {
+ if (arg.getArgIndex() == argumentIndex) {
+ return arg;
+ }
+ }
+ return null;
+ }
+
+ public static boolean validateCondition(ConditionType condition) {
+ if (condition.getExpression() == null) {
+ return false;
+ }
+ Object expression = condition.getExpression().getValue();
+ if (expression instanceof ApplyType) {
+ FunctionDefinition function = XACMLFunctionValidator.validateApply((ApplyType) expression, null);
+ if (function == null) {
+ return false;
+ }
+ if (function.isBagReturn()) {
+ return false;
+ }
+ if (function.getDatatypeBean() == null) {
+ return false;
+ }
+ return function.getDatatypeBean().getXacmlId().equals(XACML3.ID_DATATYPE_BOOLEAN.stringValue());
+ }
+ if (expression instanceof AttributeDesignatorType) {
+ return ((AttributeDesignatorType) expression).getDataType().equals(XACML3.ID_DATATYPE_BOOLEAN.stringValue());
+ }
+ if (expression instanceof AttributeSelectorType) {
+ return ((AttributeSelectorType) expression).getDataType().equals(XACML3.ID_DATATYPE_BOOLEAN.stringValue());
+ }
+ if (expression instanceof AttributeValueType) {
+ return ((AttributeValueType) expression).getDataType().equals(XACML3.ID_DATATYPE_BOOLEAN.stringValue());
+ }
+ if (expression instanceof VariableReferenceType) {
+ //
+ // Really unknown - the variable may or may not have been defined
+ //
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean validateVariable(VariableDefinitionType variable) {
+ if (variable.getExpression() == null) {
+ return false;
+ }
+ Object expression = variable.getExpression().getValue();
+ if (expression instanceof ApplyType) {
+ FunctionDefinition function = XACMLFunctionValidator.validateApply((ApplyType) expression, null);
+ if (function == null) {
+ return false;
+ }
+ return true;
+ }
+ if (expression instanceof AttributeDesignatorType) {
+ return true;
+ }
+ if (expression instanceof AttributeSelectorType) {
+ return true;
+ }
+ if (expression instanceof AttributeValueType) {
+ return true;
+ }
+ if (expression instanceof VariableReferenceType) {
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean validateAssignment(AttributeAssignmentExpressionType assignmentExpression) {
+ if (assignmentExpression.getExpression() == null) {
+ return false;
+ }
+ Object expression = assignmentExpression.getExpression().getValue();
+ if (expression instanceof ApplyType) {
+ FunctionDefinition function = XACMLFunctionValidator.validateApply((ApplyType) expression, null);
+ if (function == null) {
+ return false;
+ }
+ //
+ // TODO
+ //
+ }
+ //
+ // TODO
+ //
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/XACMLPolicyImporter.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/XACMLPolicyImporter.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/XACMLPolicyImporter.java
new file mode 100644
index 0000000..8a7c714
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/XACMLPolicyImporter.java
@@ -0,0 +1,495 @@
+/*
+ * 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.xacml.admin.util;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.EffectType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObligationExpressionType;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.jpa.Attribute;
+import org.apache.openaz.xacml.admin.jpa.Category;
+import org.apache.openaz.xacml.admin.jpa.ConstraintType;
+import org.apache.openaz.xacml.admin.jpa.ConstraintValue;
+import org.apache.openaz.xacml.admin.jpa.Datatype;
+import org.apache.openaz.xacml.admin.jpa.Obadvice;
+import org.apache.openaz.xacml.api.Advice;
+import org.apache.openaz.xacml.api.AttributeValue;
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.api.Obligation;
+import org.apache.openaz.xacml.api.XACML3;
+import org.apache.openaz.xacml.util.XACMLObjectCopy;
+import org.apache.openaz.xacml.util.XACMLPolicyAggregator;
+import org.apache.openaz.xacml.util.XACMLPolicyScanner.CallbackResult;
+import com.vaadin.addon.jpacontainer.JPAContainer;
+import com.vaadin.addon.jpacontainer.provider.CachingMutableLocalEntityProvider;
+import com.vaadin.data.Buffered.SourceException;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.ui.UI;
+
+public class XACMLPolicyImporter extends XACMLPolicyAggregator {
+ private static Log logger = LogFactory.getLog(XACMLPolicyImporter.class);
+
+ public enum OPTION {
+ /*
+ * Overwrite any existing ID
+ */
+ OVERWRITE_EXISTING,
+ /*
+ * Update an existing ID - only ADDs information
+ */
+ UPDATE_EXISTING,
+ /*
+ * Does not change an existing ID
+ */
+ DONOTCHANGE_EXISTING
+ }
+
+ public boolean importAttributes = true;
+ public boolean ignoreStandardAttributes = true;
+ public boolean addConstraints = true;
+ public OPTION attributeOption = OPTION.OVERWRITE_EXISTING;
+ public boolean importObligations = true;
+ public OPTION obligationOption = OPTION.OVERWRITE_EXISTING;
+ public boolean importAdvice = true;
+ public OPTION adviceOption = OPTION.OVERWRITE_EXISTING;
+
+ public XACMLPolicyImporter() {
+ }
+
+ public boolean isImportAttributes() {
+ return importAttributes;
+ }
+
+ public void setImportAttributes(boolean importAttributes) {
+ this.importAttributes = importAttributes;
+ }
+
+ public boolean isIgnoreStandardAttributes() {
+ return ignoreStandardAttributes;
+ }
+
+ public void setIgnoreStandardAttributes(boolean ignoreStandardAttributes) {
+ this.ignoreStandardAttributes = ignoreStandardAttributes;
+ }
+
+ public boolean isAddConstraints() {
+ return addConstraints;
+ }
+
+ public void setAddConstraints(boolean addConstraints) {
+ this.addConstraints = addConstraints;
+ }
+
+ public OPTION getAttributeOption() {
+ return attributeOption;
+ }
+
+ public void setAttributeOption(OPTION attributeOption) {
+ this.attributeOption = attributeOption;
+ }
+
+ public boolean isImportObligations() {
+ return importObligations;
+ }
+
+ public void setImportObligations(boolean importObligations) {
+ this.importObligations = importObligations;
+ }
+
+ public OPTION getObligationOption() {
+ return obligationOption;
+ }
+
+ public void setObligationOption(OPTION obligationOption) {
+ this.obligationOption = obligationOption;
+ }
+
+ public boolean isImportAdvice() {
+ return importAdvice;
+ }
+
+ public void setImportAdvice(boolean importAdvice) {
+ this.importAdvice = importAdvice;
+ }
+
+ public OPTION getAdviceOption() {
+ return adviceOption;
+ }
+
+ public void setAdviceOption(OPTION adviceOption) {
+ this.adviceOption = adviceOption;
+ }
+ @Override
+ public CallbackResult onObligation(Object parent, ObligationExpressionType expression, Obligation obligation) {
+ if (importObligations) {
+ super.onObligation(parent, expression, obligation);
+ }
+ return CallbackResult.CONTINUE;
+ }
+
+ @Override
+ public CallbackResult onAttribute(Object parent, Object container, org.apache.openaz.xacml.api.Attribute attribute) {
+ if (importAttributes) {
+ super.onAttribute(parent, container, attribute);
+ }
+ return CallbackResult.CONTINUE;
+ }
+
+ @Override
+ public CallbackResult onAdvice(Object parent, AdviceExpressionType expression, Advice advice) {
+ if (importAdvice) {
+ super.onAdvice(parent, expression, advice);
+ }
+ return CallbackResult.CONTINUE;
+ }
+
+ @Override
+ public void onFinishScan(Object root) {
+ if (this.importAttributes && this.doImportAttributes() > 0) {
+ ((XacmlAdminUI)UI.getCurrent()).refreshAttributes();
+ }
+ int changes = 0;
+ if (this.importObligations) {
+ changes += this.doImportObligations();
+ }
+ if (this.importAdvice) {
+ changes += this.doImportAdvice();
+ }
+ //
+ // If changes were made, we need to tell the UI so the
+ // dictionary can refresh.
+ //
+ if (changes > 0) {
+ ((XacmlAdminUI)UI.getCurrent()).refreshObadvice();
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ protected int doImportAttributes() {
+ int changes = 0;
+ //
+ // Get our attributes. This container is modifiable.
+ //
+ JPAContainer<Attribute> attributes = ((XacmlAdminUI)UI.getCurrent()).getAttributes();
+ //
+ // Get mutable entity providers for these.
+ //
+ JPAContainer<Category> categories = new JPAContainer<Category>(Category.class);
+ categories.setEntityProvider(new CachingMutableLocalEntityProvider<Category>(Category.class, ((XacmlAdminUI)UI.getCurrent()).getEntityManager()));
+
+ JPAContainer<Datatype> datatypes = new JPAContainer<Datatype>(Datatype.class);
+ datatypes.setEntityProvider(new CachingMutableLocalEntityProvider<Datatype>(Datatype.class, ((XacmlAdminUI)UI.getCurrent()).getEntityManager()));
+ //
+ // Work the map
+ //
+ for (Identifier cat : this.attributeMap.keySet()) {
+ //
+ // Does category exist?
+ //
+ Category category = JPAUtils.findCategory(cat);
+ if (category == null) {
+ //
+ // This should rarely happen, but is possible since XACML 3.0
+ // you can define your own categories.
+ //
+ logger.warn("New category: " + cat);
+ category = new Category(cat, Category.CUSTOM);
+ String shortName = XACMLConstants.extractShortName(cat.stringValue());
+ if (shortName != null) {
+ category.setShortName(shortName);
+ } else {
+ category.setShortName(category.getXacmlId());
+ }
+ //
+ // Make sure the grouping is ok
+ //
+ if (category.getGrouping() == null) {
+ category.setGrouping(category.getShortName());
+ }
+ //
+ // Add it in
+ //
+ categories.addEntity(category);
+ //
+ // Tell the RO to update itself.
+ //
+ ((XacmlAdminUI)UI.getCurrent()).getCategories().refresh();
+ }
+ Map<Identifier, Map<Identifier, Set<AttributeValue<?>>>> map = this.attributeMap.get(cat);
+ for (Identifier dt : map.keySet()) {
+ //
+ // Does datatype exist?
+ //
+ Datatype datatype = JPAUtils.findDatatype(dt);
+ if (datatype == null) {
+ //
+ // This should rarely happen, but is possible since XACML 3.0
+ // you can define new datatypes.
+ //
+ logger.warn("New datatype: " + dt);
+ datatype = new Datatype(dt, Datatype.CUSTOM);
+ String shortName = XACMLConstants.extractShortName(dt.stringValue());
+ if (shortName != null) {
+ datatype.setShortName(shortName);
+ } else {
+ datatype.setShortName(datatype.getXacmlId());
+ }
+ //
+ // Add it in
+ //
+ datatypes.addEntity(datatype);
+ //
+ // Tell the Read-Only property to update itself.
+ //
+ ((XacmlAdminUI)UI.getCurrent()).getDatatypes().refresh();
+ }
+ //
+ // Iterate the attributes
+ //
+ for (Identifier id : map.get(dt).keySet()) {
+ //
+ // Do we ignore it if its standard?
+ //
+ if (! this.ignoreStandardAttributes ||
+ XACMLConstants.STANDARD_ATTRIBUTES.contains(id) == false) {
+ //
+ // Does it already exist?
+ //
+ Attribute newAttribute = null;
+ Attribute currentAttribute = JPAUtils.findAttribute(category, datatype, id.stringValue());
+ //
+ // Support for an existing attribute
+ //
+ if (currentAttribute != null) {
+ if (this.attributeOption == OPTION.OVERWRITE_EXISTING) {
+ newAttribute = currentAttribute;
+ newAttribute.setConstraintType(null);
+ newAttribute.removeAllConstraintValues();
+ } else if (this.attributeOption == OPTION.DONOTCHANGE_EXISTING) {
+ logger.info("Do not change existing: " + currentAttribute);
+ continue;
+ } else if (this.attributeOption == OPTION.UPDATE_EXISTING) {
+ newAttribute = currentAttribute;
+ }
+ } else {
+ //
+ // Create our new attribute
+ //
+ newAttribute = new Attribute(id.stringValue(), ((XacmlAdminUI)UI.getCurrent()).getUserid());
+ newAttribute.setCategoryBean(category);
+ newAttribute.setDatatypeBean(datatype);
+ }
+ //
+ // Get all the values
+ //
+ Set<AttributeValue<?>> values = map.get(dt).get(id);
+ //
+ // Do we have more than 1? Also, omit boolean datatype which
+ // doesn't make any sense to enumerate.
+ //
+ if (values.size() > 1 && dt.equals(XACML3.ID_DATATYPE_BOOLEAN) == false) {
+ //
+ // We have a lot of possible values, add as an enumeration
+ //
+ newAttribute.setConstraintType(JPAUtils.findConstraintType(ConstraintType.ENUMERATION_TYPE));
+ for (AttributeValue<?> value : values) {
+ Object val = value.getValue();
+ String content;
+ if (val instanceof Collection) {
+ content = XACMLObjectCopy.getContent((List<Object>) value.getValue());
+ } else {
+ content = val.toString();
+ }
+ //
+ // Check if we should add it in
+ //
+ boolean add = true;
+ //
+ // If we are updating an existing, we can really only do this for enumerations,
+ // its impossible to resolve a regular expression or range.
+ //
+ if (currentAttribute != null && this.attributeOption == OPTION.UPDATE_EXISTING &&
+ newAttribute.getConstraintType().getConstraintType().equals(ConstraintType.ENUMERATION_TYPE)) {
+ //
+ // Make sure it isn't there already, no duplicates.
+ //
+ for (ConstraintValue currentConstraintValue : newAttribute.getConstraintValues()) {
+ if (currentConstraintValue.getValue().equals(content)) {
+ add = false;
+ break;
+ }
+ }
+ }
+ if (add && content.isEmpty() == false) {
+ ConstraintValue newValue = new ConstraintValue("Enumeration", content);
+ newValue.setAttribute(newAttribute);
+ newAttribute.addConstraintValue(newValue);
+ }
+ }
+ }
+ //
+ // Add it
+ //
+ if (newAttribute != null) {
+ if (newAttribute.getId() == 0) {
+ logger.info("Adding new attribute");
+ if (attributes.addEntity(newAttribute) == null) {
+ logger.error("Failed to add new attribute: " + newAttribute);
+ } else {
+ changes++;
+ }
+ } else {
+ logger.info("Updating attribute " + newAttribute);
+ try {
+ attributes.commit();
+ changes++;
+ } catch (SourceException | InvalidValueException e) {
+ logger.error("Update failed: " + e.getLocalizedMessage());
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return changes;
+ }
+
+ protected int doImportObligations() {
+ int changes = 0;
+ JPAContainer<Obadvice> oa = ((XacmlAdminUI)UI.getCurrent()).getObadvice();
+ for (Identifier id : this.obligationMap.keySet()) {
+ for (EffectType effect : this.obligationMap.get(id).keySet()) {
+ for (Obligation obligation : this.obligationMap.get(id).get(effect)) {
+ Obadvice newObligation = null;
+ Obadvice currentObligation = JPAUtils.findObligation(obligation.getId(), effect);
+ //
+ // Does it exist?
+ //
+ if (currentObligation != null) {
+ if (this.obligationOption == OPTION.OVERWRITE_EXISTING) {
+ newObligation = currentObligation;
+ newObligation.removeAllExpressions();
+ } else if (this.obligationOption == OPTION.DONOTCHANGE_EXISTING) {
+ continue;
+ } else if (this.obligationOption == OPTION.UPDATE_EXISTING) {
+ newObligation = currentObligation;
+ }
+ } else {
+ //
+ // Create new one
+ //
+ newObligation = new Obadvice(obligation.getId(), ((XacmlAdminUI)UI.getCurrent()).getUserid());
+ newObligation.setFulfillOn((effect == EffectType.PERMIT ? Obadvice.EFFECT_PERMIT : Obadvice.EFFECT_DENY));
+ }
+ //
+ // TODO add the expressions
+ //
+
+ //
+ // Add it in
+ //
+ if (newObligation != null) {
+ if (newObligation.getId() == 0) {
+ logger.info("Adding obligation " + newObligation);
+ oa.addEntity(newObligation);
+ changes++;
+ } else {
+ logger.info("Updating obligation " + newObligation);
+ try {
+ oa.commit();
+ changes++;
+ } catch (SourceException | InvalidValueException e) {
+ logger.error("Update obligation failed " + e.getLocalizedMessage());
+ }
+ }
+ }
+ }
+ }
+ }
+ return changes;
+ }
+
+ protected int doImportAdvice() {
+ int changes = 0;
+ JPAContainer<Obadvice> oa = ((XacmlAdminUI)UI.getCurrent()).getObadvice();
+ for (Identifier id : this.adviceMap.keySet()) {
+ for (EffectType effect : this.adviceMap.get(id).keySet()) {
+ for (Advice advice : this.adviceMap.get(id).get(effect)) {
+ Obadvice newAdvice = null;
+ Obadvice currentAdvice = JPAUtils.findAdvice(advice.getId(), effect);
+ //
+ // Does it exist?
+ //
+ if (currentAdvice != null) {
+ if (this.adviceOption == OPTION.OVERWRITE_EXISTING) {
+ newAdvice = currentAdvice;
+ newAdvice.removeAllExpressions();
+ } else if (this.adviceOption == OPTION.DONOTCHANGE_EXISTING) {
+ continue;
+ } else if (this.adviceOption == OPTION.UPDATE_EXISTING) {
+ newAdvice = currentAdvice;
+ }
+ } else {
+ //
+ // Create new one
+ //
+ newAdvice = new Obadvice(advice.getId(), ((XacmlAdminUI)UI.getCurrent()).getUserid());
+ newAdvice.setType(Obadvice.ADVICE);
+ newAdvice.setFulfillOn((effect == EffectType.PERMIT ? Obadvice.EFFECT_PERMIT : Obadvice.EFFECT_DENY));
+ }
+ //
+ // TODO add the expressions
+ //
+
+ //
+ // Add it in
+ //
+ if (newAdvice != null) {
+ if (newAdvice.getId() == 0) {
+ logger.info("Adding advice " + newAdvice);
+ oa.addEntity(newAdvice);
+ changes++;
+ } else {
+ logger.info("Updating advice " + newAdvice);
+ try {
+ oa.commit();
+ changes++;
+ } catch (SourceException | InvalidValueException e) {
+ logger.error("Update advice failed " + e.getLocalizedMessage());
+ }
+ }
+ }
+ }
+ }
+ }
+ return changes;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/AttributeDictionarySelectorComponent.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/AttributeDictionarySelectorComponent.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/AttributeDictionarySelectorComponent.java
new file mode 100644
index 0000000..0dd7f32
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/AttributeDictionarySelectorComponent.java
@@ -0,0 +1,290 @@
+/*
+ * 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.xacml.admin.view.components;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.components.AttributeDictionary;
+import org.apache.openaz.xacml.admin.jpa.Attribute;
+import org.apache.openaz.xacml.admin.jpa.Category;
+import org.apache.openaz.xacml.admin.jpa.Datatype;
+import org.apache.openaz.xacml.admin.view.events.AttributeChangedEventListener;
+import org.apache.openaz.xacml.admin.view.events.AttributeChangedEventNotifier;
+import com.vaadin.addon.jpacontainer.JPAContainer;
+import com.vaadin.addon.jpacontainer.provider.CachingLocalEntityProvider;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.util.filter.Compare;
+import com.vaadin.ui.AbstractSelect.ItemCaptionMode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.ListSelect;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+
+public class AttributeDictionarySelectorComponent extends CustomComponent implements AttributeChangedEventNotifier {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private ListSelect listSelectAttribute;
+ @AutoGenerated
+ private HorizontalLayout horizontalLayout_2;
+ @AutoGenerated
+ private Button buttonNewAttribute;
+ @AutoGenerated
+ private ComboBox comboBoxCategoryFilter;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private final AttributeDictionarySelectorComponent self = this;
+ private final Datatype datatype;
+ private final Attribute initialAttribute;
+ private final BasicNotifier notifier = new BasicNotifier();
+ private static final JPAContainer<Category> categories = new JPAContainer<Category>(Category.class);
+ private static final JPAContainer<Attribute> attributes = new JPAContainer<Attribute>(Attribute.class);
+ static {
+ attributes.setEntityProvider(new CachingLocalEntityProvider<Attribute>(Attribute.class, ((XacmlAdminUI)UI.getCurrent()).getEntityManager()));
+ categories.setEntityProvider(new CachingLocalEntityProvider<Category>(Category.class, ((XacmlAdminUI)UI.getCurrent()).getEntityManager()));
+ attributes.sort(new String[]{"xacmlId"}, new boolean[]{true});
+ categories.sort(new String[]{"xacmlId"}, new boolean[]{true});
+ }
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public AttributeDictionarySelectorComponent(Datatype datatype, Attribute initialAttribute) {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+ //
+ // Save pointer and finish container initialization
+ //
+ this.datatype = datatype;
+ this.initialAttribute = initialAttribute;
+ //
+ // Initialize
+ //
+ this.initializeCategoryFilter();
+ this.initializeAttributes();
+ this.initializeButtons();
+ //
+ // Set our focus
+ //
+ this.listSelectAttribute.focus();
+ }
+
+ protected void initializeCategoryFilter() {
+ //
+ // Remove any filters
+ //
+ AttributeDictionarySelectorComponent.categories.removeAllContainerFilters();
+ //
+ // Initialize data source and GUI properties
+ //
+ this.comboBoxCategoryFilter.setContainerDataSource(AttributeDictionarySelectorComponent.categories);
+ this.comboBoxCategoryFilter.setItemCaptionMode(ItemCaptionMode.PROPERTY);
+ this.comboBoxCategoryFilter.setItemCaptionPropertyId("xacmlId");
+ this.comboBoxCategoryFilter.setImmediate(true);
+ //
+ // Respond to events
+ //
+ this.comboBoxCategoryFilter.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ //
+ // Clear any existing filters
+ //
+ AttributeDictionarySelectorComponent.attributes.removeAllContainerFilters();
+ //
+ // Get the current selection
+ //
+ Object id = self.comboBoxCategoryFilter.getValue();
+ //
+ // Is anything currently selected?
+ //
+ if (id != null) {
+ //
+ // Yes - add the new filter into the container
+ //
+ AttributeDictionarySelectorComponent.attributes.addContainerFilter(new Compare.Equal("categoryBean", AttributeDictionarySelectorComponent.categories.getItem(id).getEntity()));
+ }
+ }
+ });
+ }
+
+ protected void initializeAttributes() {
+ //
+ // Remove any filters
+ //
+ AttributeDictionarySelectorComponent.attributes.removeAllContainerFilters();
+ //
+ // Initialize data source and GUI properties
+ //
+ this.listSelectAttribute.setContainerDataSource(AttributeDictionarySelectorComponent.attributes);
+ this.listSelectAttribute.setItemCaptionMode(ItemCaptionMode.PROPERTY);
+ this.listSelectAttribute.setItemCaptionPropertyId("xacmlId");
+ this.listSelectAttribute.setImmediate(true);
+ this.listSelectAttribute.setHeight(7, Unit.EM);
+ //
+ // Filter by datatype
+ //
+ if (this.datatype != null) {
+ AttributeDictionarySelectorComponent.attributes.addContainerFilter(new Compare.Equal("datatypeBean", this.datatype));
+ }
+ //
+ // Is there a default selection? Is there an id?
+ //
+ if (this.initialAttribute != null && this.initialAttribute.getId() != 0) {
+ this.listSelectAttribute.select(this.initialAttribute.getId());
+ }
+ //
+ // Respond to events
+ //
+ this.listSelectAttribute.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ self.fireAttributeChanged(self.getAttribute());
+ }
+ });
+ }
+
+ protected void initializeButtons() {
+ this.buttonNewAttribute.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ AttributeDictionary.createNewAttributeWindow();
+ }
+ });
+ }
+
+ @Override
+ public void commit() {
+ this.listSelectAttribute.commit();
+ }
+
+ @Override
+ public Attribute getAttribute() {
+ Object id = this.listSelectAttribute.getValue();
+ if (id == null) {
+ return null;
+ }
+ return AttributeDictionarySelectorComponent.attributes.getItem(id).getEntity();
+ }
+
+ @Override
+ public boolean addListener(AttributeChangedEventListener listener) {
+ return this.notifier.addListener(listener);
+ }
+
+ @Override
+ public boolean removeListener(AttributeChangedEventListener listener) {
+ return this.notifier.removeListener(listener);
+ }
+
+ @Override
+ public void fireAttributeChanged(Attribute attribute) {
+ this.notifier.fireAttributeChanged(attribute);
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // horizontalLayout_2
+ horizontalLayout_2 = buildHorizontalLayout_2();
+ mainLayout.addComponent(horizontalLayout_2);
+
+ // listSelectAttribute
+ listSelectAttribute = new ListSelect();
+ listSelectAttribute.setCaption("Dictionary Attributes");
+ listSelectAttribute.setImmediate(false);
+ listSelectAttribute.setWidth("100.0%");
+ listSelectAttribute.setHeight("-1px");
+ listSelectAttribute.setInvalidAllowed(false);
+ listSelectAttribute.setRequired(true);
+ mainLayout.addComponent(listSelectAttribute);
+ mainLayout.setExpandRatio(listSelectAttribute, 1.0f);
+
+ return mainLayout;
+ }
+
+ @AutoGenerated
+ private HorizontalLayout buildHorizontalLayout_2() {
+ // common part: create layout
+ horizontalLayout_2 = new HorizontalLayout();
+ horizontalLayout_2.setImmediate(false);
+ horizontalLayout_2.setWidth("-1px");
+ horizontalLayout_2.setHeight("-1px");
+ horizontalLayout_2.setMargin(false);
+ horizontalLayout_2.setSpacing(true);
+
+ // comboBoxCategoryFilter
+ comboBoxCategoryFilter = new ComboBox();
+ comboBoxCategoryFilter.setCaption("Filter Category");
+ comboBoxCategoryFilter.setImmediate(false);
+ comboBoxCategoryFilter.setWidth("-1px");
+ comboBoxCategoryFilter.setHeight("-1px");
+ horizontalLayout_2.addComponent(comboBoxCategoryFilter);
+ horizontalLayout_2.setExpandRatio(comboBoxCategoryFilter, 1.0f);
+
+ // buttonNewAttribute
+ buttonNewAttribute = new Button();
+ buttonNewAttribute.setCaption("New Attribute");
+ buttonNewAttribute.setImmediate(true);
+ buttonNewAttribute
+ .setDescription("Click to create a new attribute in the dictionary.");
+ buttonNewAttribute.setWidth("-1px");
+ buttonNewAttribute.setHeight("-1px");
+ horizontalLayout_2.addComponent(buttonNewAttribute);
+ horizontalLayout_2.setComponentAlignment(buttonNewAttribute,
+ new Alignment(10));
+
+ return horizontalLayout_2;
+ }
+
+}
[15/23] incubator-openaz git commit: Ported original att source to
openaz
Posted by pd...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/GitRepositoryContainer.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/GitRepositoryContainer.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/GitRepositoryContainer.java
new file mode 100644
index 0000000..8cecf31
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/GitRepositoryContainer.java
@@ -0,0 +1,1210 @@
+/*
+ * 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.
+ *
+ */
+
+/*
+ * Copyright 2000-2013 Vaadin Ltd.
+ *
+ * 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.
+ */
+
+package org.apache.openaz.xacml.admin.model;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.Serializable;
+import java.lang.reflect.Method;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.Status;
+import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.errors.NoWorkTreeException;
+
+import org.apache.openaz.xacml.util.XACMLPolicyScanner;
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.util.MethodProperty;
+import com.vaadin.server.Resource;
+import com.vaadin.ui.TextArea;
+import com.vaadin.util.FileTypeResolver;
+
+/**
+ * A hierarchical container wrapper for a filesystem.
+ *
+ * @author Vaadin Ltd.
+ * @since 3.0
+ */
+@SuppressWarnings("serial")
+public class GitRepositoryContainer extends ItemSetChangeNotifier implements Container.Hierarchical {
+ private Log logger = LogFactory.getLog(GitRepositoryContainer.class);
+
+ /**
+ * String identifier of a file's "name" property.
+ */
+ public static String PROPERTY_NAME = "Name";
+
+ /**
+ * String identifier of a file's "size" property.
+ */
+ public static String PROPERTY_SIZE = "Size";
+
+ /**
+ * String identifier of a file's "icon" property.
+ */
+ public static String PROPERTY_ICON = "Icon";
+
+ /**
+ * String identifier of a file's "last modified" property.
+ */
+ public static String PROPERTY_LASTMODIFIED = "Last Modified";
+
+ /**
+ * String identifier of a file's "version" property.
+ */
+ public static String PROPERTY_VERSION = "Version";
+
+ /**
+ * String identifier of a file's "status" property.
+ */
+ public static String PROPERTY_STATUS = "Status";
+
+ /**
+ * String identifier of a file's "data" property.
+ */
+ public static String PROPERTY_DATA = "Data";
+
+ /**
+ * List of the string identifiers for the available properties.
+ */
+ public static Collection<String> FILE_PROPERTIES;
+
+ private final static Method FILEITEM_LASTMODIFIED;
+
+ private final static Method FILEITEM_NAME;
+
+ private final static Method FILEITEM_ICON;
+
+ private final static Method FILEITEM_SIZE;
+
+ private final static Method FILEITEM_VERSION;
+
+ private final static Method FILEITEM_STATUS;
+
+ private final static Method FILEITEM_DATA;
+
+ static {
+
+ FILE_PROPERTIES = new ArrayList<String>();
+ FILE_PROPERTIES.add(PROPERTY_NAME);
+ FILE_PROPERTIES.add(PROPERTY_ICON);
+ FILE_PROPERTIES.add(PROPERTY_SIZE);
+ FILE_PROPERTIES.add(PROPERTY_LASTMODIFIED);
+ FILE_PROPERTIES.add(PROPERTY_VERSION);
+ FILE_PROPERTIES.add(PROPERTY_STATUS);
+ FILE_PROPERTIES.add(PROPERTY_DATA);
+ FILE_PROPERTIES = Collections.unmodifiableCollection(FILE_PROPERTIES);
+ try {
+ FILEITEM_VERSION = FileItem.class.getMethod("getVersion", new Class[]{});
+ FILEITEM_LASTMODIFIED = FileItem.class.getMethod("lastModified", new Class[] {});
+ FILEITEM_NAME = FileItem.class.getMethod("getName", new Class[] {});
+ FILEITEM_ICON = FileItem.class.getMethod("getIcon", new Class[] {});
+ FILEITEM_SIZE = FileItem.class.getMethod("getSize", new Class[] {});
+ FILEITEM_STATUS = FileItem.class.getMethod("getStatus", new Class[] {});
+ FILEITEM_DATA = FileItem.class.getMethod("getData", new Class[] {});
+ } catch (final NoSuchMethodException e) {
+ throw new RuntimeException(
+ "Internal error finding methods in FilesystemContainer");
+ }
+ }
+
+ private File[] roots = new File[] {};
+
+ private FilenameFilter filter = null;
+
+ private boolean recursive = true;
+
+ private Path repository = null;
+
+ /**
+ * Constructs a new <code>FileSystemContainer</code> with the specified file
+ * as the root of the filesystem. The files are included recursively.
+ *
+ * @param root
+ * the root file for the new file-system container. Null values
+ * are ignored.
+ */
+ public GitRepositoryContainer(Path repository, File root) {
+ super();
+ this.repository = repository;
+ if (root != null) {
+ roots = new File[] { root };
+ }
+ this.setContainer(this);
+ }
+
+ /**
+ * Constructs a new <code>FileSystemContainer</code> with the specified file
+ * as the root of the filesystem. The files are included recursively.
+ *
+ * @param root
+ * the root file for the new file-system container.
+ * @param recursive
+ * should the container recursively contain subdirectories.
+ */
+ public GitRepositoryContainer(Path repository, File root, boolean recursive) {
+ this(repository, root);
+ setRecursive(recursive);
+ this.setContainer(this);
+ }
+
+ /**
+ * Constructs a new <code>FileSystemContainer</code> with the specified file
+ * as the root of the filesystem.
+ *
+ * @param root
+ * the root file for the new file-system container.
+ * @param extension
+ * the Filename extension (w/o separator) to limit the files in
+ * container.
+ * @param recursive
+ * should the container recursively contain subdirectories.
+ */
+ public GitRepositoryContainer(Path repository, File root, String extension, boolean recursive) {
+ this(repository, root);
+ this.setFilter(extension);
+ setRecursive(recursive);
+ this.setContainer(this);
+ }
+
+ /**
+ * Constructs a new <code>FileSystemContainer</code> with the specified root
+ * and recursivity status.
+ *
+ * @param root
+ * the root file for the new file-system container.
+ * @param filter
+ * the Filename filter to limit the files in container.
+ * @param recursive
+ * should the container recursively contain subdirectories.
+ */
+ public GitRepositoryContainer(Path repository, File root, FilenameFilter filter, boolean recursive) {
+ this(repository, root);
+ this.setFilter(filter);
+ setRecursive(recursive);
+ }
+
+ /**
+ * Adds new root file directory. Adds a file to be included as root file
+ * directory in the <code>FilesystemContainer</code>.
+ *
+ * @param root
+ * the File to be added as root directory. Null values are
+ * ignored.
+ */
+ public void addRoot(File root) {
+ if (root != null) {
+ final File[] newRoots = new File[roots.length + 1];
+ for (int i = 0; i < roots.length; i++) {
+ newRoots[i] = roots[i];
+ }
+ newRoots[roots.length] = root;
+ roots = newRoots;
+ }
+ }
+
+ /**
+ * Tests if the specified Item in the container may have children. Since a
+ * <code>FileSystemContainer</code> contains files and directories, this
+ * method returns <code>true</code> for directory Items only.
+ *
+ * @param itemId
+ * the id of the item.
+ * @return <code>true</code> if the specified Item is a directory,
+ * <code>false</code> otherwise.
+ */
+ @Override
+ public boolean areChildrenAllowed(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("areChildrenAllowed: " + ((File)itemId).hashCode() + " " + ((File)itemId).getName());
+ }
+ return itemId instanceof File && ((File) itemId).canRead()
+ && ((File) itemId).isDirectory();
+ }
+
+ /*
+ * Gets the ID's of all Items who are children of the specified Item. Don't
+ * add a JavaDoc comment here, we use the default documentation from
+ * implemented interface.
+ */
+ @Override
+ public Collection<File> getChildren(Object itemId) {
+
+ if (!(itemId instanceof File)) {
+ return Collections.unmodifiableCollection(new LinkedList<File>());
+ }
+ File[] f;
+ if (filter != null) {
+ f = ((File) itemId).listFiles(filter);
+ } else {
+ f = ((File) itemId).listFiles();
+ }
+
+ if (f == null) {
+ return Collections.unmodifiableCollection(new LinkedList<File>());
+ }
+
+ final List<File> l = Arrays.asList(f);
+ Collections.sort(l);
+
+ return Collections.unmodifiableCollection(l);
+ }
+
+ /*
+ * Gets the parent item of the specified Item. Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
+ */
+ @Override
+ public Object getParent(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getParent: " + ((File)itemId).hashCode() + " " + ((File)itemId).getName());
+ }
+
+ if (!(itemId instanceof File)) {
+ return null;
+ }
+ return ((File) itemId).getParentFile();
+ }
+
+ /*
+ * Tests if the specified Item has any children. Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
+ */
+ @Override
+ public boolean hasChildren(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("hasChildren: " + ((File)itemId).hashCode() + " " + ((File)itemId).getName());
+ }
+
+ if (!(itemId instanceof File)) {
+ return false;
+ }
+ String[] l;
+ if (filter != null) {
+ l = ((File) itemId).list(filter);
+ } else {
+ l = ((File) itemId).list();
+ }
+ return l != null && l.length > 0;
+ }
+
+ /*
+ * Tests if the specified Item is the root of the filesystem. Don't add a
+ * JavaDoc comment here, we use the default documentation from implemented
+ * interface.
+ */
+ @Override
+ public boolean isRoot(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("isRoot: " + ((File)itemId).hashCode() + " " + ((File)itemId).getName());
+ }
+
+ if (!(itemId instanceof File)) {
+ return false;
+ }
+ for (int i = 0; i < roots.length; i++) {
+ if (roots[i].equals(itemId)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /*
+ * Gets the ID's of all root Items in the container. Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
+ */
+ @Override
+ public Collection<File> rootItemIds() {
+
+ File[] f;
+
+ // in single root case we use children
+ if (roots.length == 1) {
+ if (filter != null) {
+ f = roots[0].listFiles(filter);
+ } else {
+ f = roots[0].listFiles();
+ }
+ } else {
+ f = roots;
+ }
+
+ if (f == null) {
+ return Collections.unmodifiableCollection(new LinkedList<File>());
+ }
+
+ final List<File> l = Arrays.asList(f);
+ Collections.sort(l);
+
+ return Collections.unmodifiableCollection(l);
+ }
+
+ /**
+ * Returns <code>false</code> when conversion from files to directories is
+ * not supported.
+ *
+ * @param itemId
+ * the ID of the item.
+ * @param areChildrenAllowed
+ * the boolean value specifying if the Item can have children or
+ * not.
+ * @return <code>true</code> if the operaton is successful otherwise
+ * <code>false</code>.
+ * @throws UnsupportedOperationException
+ * if the setChildrenAllowed is not supported.
+ */
+ @Override
+ public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed)
+ throws UnsupportedOperationException {
+
+ throw new UnsupportedOperationException(
+ "Conversion file to/from directory is not supported");
+ }
+
+ /**
+ * Returns <code>false</code> when moving files around in the filesystem is
+ * not supported.
+ *
+ * @param itemId
+ * the ID of the item.
+ * @param newParentId
+ * the ID of the Item that's to be the new parent of the Item
+ * identified with itemId.
+ * @return <code>true</code> if the operation is successful otherwise
+ * <code>false</code>.
+ * @throws UnsupportedOperationException
+ * if the setParent is not supported.
+ */
+ @Override
+ public boolean setParent(Object itemId, Object newParentId)
+ throws UnsupportedOperationException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("setParent: " +
+ ((File)itemId).hashCode() + " " +
+ ((File)itemId).getName() + " to: " +
+ ((File)newParentId).hashCode() + " " +
+ ((File)newParentId).getName());
+ }
+
+ Path path = Paths.get(((File) itemId).getAbsolutePath());
+ Path parent = Paths.get(((File) newParentId).getAbsolutePath());
+ boolean ok = path.getParent() == parent;
+
+ if (ok) {
+ fireItemSetChange();
+ }
+ return ok;
+ }
+
+ /*
+ * Tests if the filesystem contains the specified Item. Don't add a JavaDoc
+ * comment here, we use the default documentation from implemented
+ * interface.
+ */
+ @Override
+ public boolean containsId(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("containsId: " + ((File)itemId).hashCode() + " " + ((File)itemId).getName());
+ }
+
+ if (!(itemId instanceof File)) {
+ return false;
+ }
+ boolean val = false;
+
+ // Try to match all roots
+ for (int i = 0; i < roots.length; i++) {
+ try {
+ val |= ((File) itemId).getCanonicalPath().startsWith(
+ roots[i].getCanonicalPath());
+ } catch (final IOException e) { //NOPMD
+ // Exception ignored
+ }
+
+ }
+ if (val && filter != null) {
+ val &= filter.accept(((File) itemId).getParentFile(),
+ ((File) itemId).getName());
+ }
+ return val;
+ }
+
+ /*
+ * Gets the specified Item from the filesystem. Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
+ */
+ @Override
+ public Item getItem(Object itemId) {
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("getItem: " + ((File)itemId).hashCode() + " " + ((File)itemId).getName());
+ }
+
+ if (!(itemId instanceof File)) {
+ return null;
+ }
+ return new FileItem((File) itemId);
+ }
+
+ public Item updateItem(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("updateItem: " + ((File)itemId).hashCode() + " " + ((File)itemId).getName());
+ }
+
+ if (!(itemId instanceof File)) {
+ return null;
+ }
+
+ this.fireItemSetChange();
+
+ return new FileItem((File) itemId);
+ }
+
+ /**
+ * Internal recursive method to add the files under the specified directory
+ * to the collection.
+ *
+ * @param col
+ * the collection where the found items are added
+ * @param f
+ * the root file where to start adding files
+ */
+ private void addItemIds(Collection<File> col, File f) {
+ File[] l;
+ if (filter != null) {
+ l = f.listFiles(filter);
+ } else {
+ l = f.listFiles();
+ }
+ if (l == null) {
+ // File.listFiles returns null if File does not exist or if there
+ // was an IO error (permission denied)
+ return;
+ }
+ final List<File> ll = Arrays.asList(l);
+ Collections.sort(ll);
+
+ for (final Iterator<File> i = ll.iterator(); i.hasNext();) {
+ final File lf = i.next();
+ col.add(lf);
+ if (lf.isDirectory()) {
+ addItemIds(col, lf);
+ }
+ }
+ }
+
+ /*
+ * Gets the IDs of Items in the filesystem. Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
+ */
+ @Override
+ public Collection<File> getItemIds() {
+
+ if (recursive) {
+ final Collection<File> col = new ArrayList<File>();
+ for (int i = 0; i < roots.length; i++) {
+ addItemIds(col, roots[i]);
+ }
+ return Collections.unmodifiableCollection(col);
+ } else {
+ File[] f;
+ if (roots.length == 1) {
+ if (filter != null) {
+ f = roots[0].listFiles(filter);
+ } else {
+ f = roots[0].listFiles();
+ }
+ } else {
+ f = roots;
+ }
+
+ if (f == null) {
+ return Collections
+ .unmodifiableCollection(new LinkedList<File>());
+ }
+
+ final List<File> l = Arrays.asList(f);
+ Collections.sort(l);
+ return Collections.unmodifiableCollection(l);
+ }
+
+ }
+
+ /**
+ * Gets the specified property of the specified file Item. The available
+ * file properties are "Name", "Size" and "Last Modified". If propertyId is
+ * not one of those, <code>null</code> is returned.
+ *
+ * @param itemId
+ * the ID of the file whose property is requested.
+ * @param propertyId
+ * the property's ID.
+ * @return the requested property's value, or <code>null</code>
+ */
+ @Override
+ public Property<?> getContainerProperty(Object itemId, Object propertyId) {
+
+ if (!(itemId instanceof File)) {
+ return null;
+ }
+
+ if (propertyId.equals(PROPERTY_NAME)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new FileItem((File) itemId), FILEITEM_NAME, null);
+ }
+
+ if (propertyId.equals(PROPERTY_ICON)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new FileItem((File) itemId), FILEITEM_ICON, null);
+ }
+
+ if (propertyId.equals(PROPERTY_SIZE)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new FileItem((File) itemId), FILEITEM_SIZE, null);
+ }
+
+ if (propertyId.equals(PROPERTY_LASTMODIFIED)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new FileItem((File) itemId), FILEITEM_LASTMODIFIED, null);
+ }
+
+ if (propertyId.equals(PROPERTY_VERSION)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new FileItem((File) itemId), FILEITEM_VERSION, null);
+ }
+
+ if (propertyId.equals(PROPERTY_STATUS)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new FileItem((File) itemId), FILEITEM_STATUS, null);
+ }
+
+ if (propertyId.equals(PROPERTY_DATA)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new FileItem((File) itemId), FILEITEM_DATA, null);
+ }
+
+ return null;
+ }
+
+ /**
+ * Gets the collection of available file properties.
+ *
+ * @return Unmodifiable collection containing all available file properties.
+ */
+ @Override
+ public Collection<String> getContainerPropertyIds() {
+ return FILE_PROPERTIES;
+ }
+
+ /**
+ * Gets the specified property's data type. "Name" is a <code>String</code>,
+ * "Size" is a <code>Long</code>, "Last Modified" is a <code>Date</code>. If
+ * propertyId is not one of those, <code>null</code> is returned.
+ *
+ * @param propertyId
+ * the ID of the property whose type is requested.
+ * @return data type of the requested property, or <code>null</code>
+ */
+ @Override
+ public Class<?> getType(Object propertyId) {
+
+ if (propertyId.equals(PROPERTY_NAME)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_ICON)) {
+ return Resource.class;
+ }
+ if (propertyId.equals(PROPERTY_SIZE)) {
+ return Long.class;
+ }
+ if (propertyId.equals(PROPERTY_LASTMODIFIED)) {
+ return Date.class;
+ }
+ if (propertyId.equals(PROPERTY_VERSION)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_STATUS)) {
+ return TextArea.class;
+ }
+ if (propertyId.equals(PROPERTY_DATA)) {
+ return Object.class;
+ }
+ return null;
+ }
+
+ /**
+ * Internal method to recursively calculate the number of files under a root
+ * directory.
+ *
+ * @param f
+ * the root to start counting from.
+ */
+ private int getFileCounts(File f) {
+ File[] l;
+ if (filter != null) {
+ l = f.listFiles(filter);
+ } else {
+ l = f.listFiles();
+ }
+
+ if (l == null) {
+ return 0;
+ }
+ int ret = l.length;
+ for (int i = 0; i < l.length; i++) {
+ if (l[i].isDirectory()) {
+ ret += getFileCounts(l[i]);
+ }
+ }
+ return ret;
+ }
+
+ /**
+ * Gets the number of Items in the container. In effect, this is the
+ * combined amount of files and directories.
+ *
+ * @return Number of Items in the container.
+ */
+ @Override
+ public int size() {
+
+ if (recursive) {
+ int counts = 0;
+ for (int i = 0; i < roots.length; i++) {
+ counts += getFileCounts(roots[i]);
+ }
+ return counts;
+ } else {
+ File[] f;
+ if (roots.length == 1) {
+ if (filter != null) {
+ f = roots[0].listFiles(filter);
+ } else {
+ f = roots[0].listFiles();
+ }
+ } else {
+ f = roots;
+ }
+
+ if (f == null) {
+ return 0;
+ }
+ return f.length;
+ }
+ }
+
+
+ /**
+ * A Item wrapper for files in a filesystem.
+ *
+ * @author Vaadin Ltd.
+ * @since 3.0
+ */
+ public class FileItem implements Item {
+
+ /**
+ * The wrapped file.
+ */
+ private final File file;
+
+ private Object data = null;
+
+ /**
+ * Constructs a FileItem from a existing file.
+ */
+ private FileItem(File file) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("FileItem constructor: " + file.hashCode() + " " + file.getName());
+ }
+ this.file = file;
+ }
+
+ /*
+ * Gets the specified property of this file. Don't add a JavaDoc comment
+ * here, we use the default documentation from implemented interface.
+ */
+ @Override
+ public Property<?> getItemProperty(Object id) {
+ return getContainerProperty(file, id);
+ }
+
+ /*
+ * Gets the IDs of all properties available for this item Don't add a
+ * JavaDoc comment here, we use the default documentation from
+ * implemented interface.
+ */
+ @Override
+ public Collection<String> getItemPropertyIds() {
+ return getContainerPropertyIds();
+ }
+
+ /**
+ * Calculates a integer hash-code for the Property that's unique inside
+ * the Item containing the Property. Two different Properties inside the
+ * same Item contained in the same list always have different
+ * hash-codes, though Properties in different Items may have identical
+ * hash-codes.
+ *
+ * @return A locally unique hash-code as integer
+ */
+ @Override
+ public int hashCode() {
+ return file.hashCode() ^ GitRepositoryContainer.this.hashCode();
+ }
+
+ /**
+ * Tests if the given object is the same as the this object. Two
+ * Properties got from an Item with the same ID are equal.
+ *
+ * @param obj
+ * an object to compare with this object.
+ * @return <code>true</code> if the given object is the same as this
+ * object, <code>false</code> if not
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null || !(obj instanceof FileItem)) {
+ return false;
+ }
+ final FileItem fi = (FileItem) obj;
+ return fi.getHost() == getHost() && fi.file.equals(file);
+ }
+
+ /**
+ * Gets the host of this file.
+ */
+ private GitRepositoryContainer getHost() {
+ return GitRepositoryContainer.this;
+ }
+
+ /**
+ * Gets the file's version
+ *
+ * @return Integer
+ */
+
+ public String getVersion() {
+ /*
+ * If its a directory, there is no version
+ */
+ if (this.file.isDirectory()) {
+ return null;
+ }
+ try {
+ return XACMLPolicyScanner.getVersion(Paths.get(this.file.getAbsolutePath()));
+ } catch (IOException e) {
+ logger.error("Could not get version: " + e);
+ return "n/a";
+ }
+ }
+
+ /**
+ * Gets the last modified date of this file.
+ *
+ * @return Date
+ */
+ public Date lastModified() {
+ return new Date(file.lastModified());
+ }
+
+ /**
+ * Gets the name of this file.
+ *
+ * @return file name of this file.
+ */
+ public String getName() {
+ return file.getName();
+ }
+
+ public File getFile() {
+ return file;
+ }
+
+ /**
+ * Gets the icon of this file.
+ *
+ * @return the icon of this file.
+ */
+ public Resource getIcon() {
+ return FileTypeResolver.getIcon(file);
+ }
+
+ /**
+ * Gets the size of this file.
+ *
+ * @return size
+ */
+ public Long getSize() {
+ if (file.isDirectory()) {
+ return null;
+ }
+ return file.length();
+ }
+
+ /**
+ * Gets the status of this file.
+ *
+ * @return status of this file.
+ */
+ public TextArea getStatus() {
+ TextArea area = null;
+ try {
+ Path repoPath = this.getHost().repository;
+ Git git = Git.open(repoPath.toFile());
+
+ //
+ // I would like to use absolutePath, but that seems to barf when
+ // we try to relativize this if a full path is not given.
+ //
+ Path relativePath = repoPath.relativize(Paths.get(this.file.getPath()));
+
+ Status status = git.status().addPath(relativePath.toString()).call();
+ if (logger.isDebugEnabled()) {
+ logger.debug(this.file.getAbsolutePath());
+ logger.debug("Added: " + status.getAdded());
+ logger.debug("Changed: " + status.getChanged());
+ logger.debug("Conflicting: " + status.getConflicting());
+ logger.debug("Missing: " + status.getMissing());
+ logger.debug("Modified: " + status.getModified());
+ logger.debug("Removed: " + status.getRemoved());
+ logger.debug("Uncommitted: " + status.getUncommittedChanges());
+ logger.debug("Untracked: " + status.getUntracked());
+ logger.debug("Untracked folders; " + status.getUntrackedFolders());
+ }
+ //
+ // Are we a file or directory?
+ //
+ StringBuffer buffer = new StringBuffer();
+ int length = 0;
+ if (this.file.isFile()) {
+ if (status.getAdded().contains(relativePath.toString())) {
+ buffer.append("Added" + "\n");
+ length++;
+ }
+ if (status.getChanged().contains(relativePath.toString())) {
+ buffer.append("Changed" + "\n");
+ length++;
+ }
+ if (status.getConflicting().contains(relativePath.toString())) {
+ buffer.append("Conflicting" + "\n");
+ length++;
+ }
+ if (status.getMissing().contains(relativePath.toString())) {
+ buffer.append("Missing" + "\n");
+ length++;
+ }
+ if (status.getModified().contains(relativePath.toString())) {
+ buffer.append("Modified" + "\n");
+ length++;
+ }
+ if (status.getRemoved().contains(relativePath.toString())) {
+ buffer.append("Removed" + "\n");
+ length++;
+ }
+ if (status.getUncommittedChanges().contains(relativePath.toString())) {
+ buffer.append("Uncommitted" + "\n");
+ length++;
+ }
+ if (status.getUntracked().contains(relativePath.toString())) {
+ buffer.append("Untracked (New)" + "\n");
+ length++;
+ }
+ if (status.getUntrackedFolders().contains(relativePath.toString())) {
+ buffer.append("Untracked Folders (New)" + "\n");
+ length++;
+ }
+ } else if (this.file.isDirectory()) {
+ if (status.getUntracked().size() > 0) {
+ buffer.append("Untracked (New)" + "\n");
+ length++;
+ }
+ if (status.getUntrackedFolders().size() > 0) {
+ buffer.append("Untracked Folders (New)" + "\n");
+ length++;
+ }
+ }
+ if (length > 0) {
+ area = new TextArea();
+ area.setValue(buffer.toString().trim());
+ area.setWidth("100.0%");
+ area.setRows(length);
+ area.setReadOnly(true);
+ }
+ } catch (IOException | NoWorkTreeException | GitAPIException e) {
+ logger.error(e);
+ }
+ return area;
+ }
+
+ /**
+ * Gets the file's data
+ *
+ * @return file data
+ */
+ public Object getData() {
+ return this.data;
+ }
+ /**
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+// if ("".equals(file.getName())) {
+ // return file.getAbsolutePath();
+ // }
+ return file.getName();
+ }
+
+ /**
+ * Filesystem container does not support adding new properties.
+ *
+ * @see com.vaadin.data.Item#addItemProperty(Object, Property)
+ */
+ @Override
+ public boolean addItemProperty(Object id, @SuppressWarnings("rawtypes") Property property) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Filesystem container does not support adding new properties");
+ }
+
+ /**
+ * Filesystem container does not support removing properties.
+ *
+ * @see com.vaadin.data.Item#removeItemProperty(Object)
+ */
+ @Override
+ public boolean removeItemProperty(Object id) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Filesystem container does not support property removal");
+ }
+ }
+
+ /**
+ * Generic file extension filter for displaying only files having certain
+ * extension.
+ *
+ * @author Vaadin Ltd.
+ * @since 3.0
+ */
+ public class FileExtensionFilter implements FilenameFilter, Serializable {
+
+ private final String filter;
+
+ /**
+ * Constructs a new FileExtensionFilter using given extension.
+ *
+ * @param fileExtension
+ * the File extension without the separator (dot).
+ */
+ public FileExtensionFilter(String fileExtension) {
+ filter = "." + fileExtension;
+ }
+
+ /**
+ * Allows only files with the extension and directories.
+ *
+ * @see java.io.FilenameFilter#accept(File, String)
+ */
+ @Override
+ public boolean accept(File dir, String name) {
+ if (name.endsWith(filter)) {
+ return true;
+ }
+ return new File(dir, name).isDirectory();
+ }
+
+ }
+
+ /**
+ * Returns the file filter used to limit the files in this container.
+ *
+ * @return Used filter instance or null if no filter is assigned.
+ */
+ public FilenameFilter getFilter() {
+ return filter;
+ }
+
+ /**
+ * Sets the file filter used to limit the files in this container.
+ *
+ * @param filter
+ * The filter to set. <code>null</code> disables filtering.
+ */
+ public void setFilter(FilenameFilter filter) {
+ this.filter = filter;
+ }
+
+ /**
+ * Sets the file filter used to limit the files in this container.
+ *
+ * @param extension
+ * the Filename extension (w/o separator) to limit the files in
+ * container.
+ */
+ public void setFilter(String extension) {
+ filter = new FileExtensionFilter(extension);
+ }
+
+ /**
+ * Is this container recursive filesystem.
+ *
+ * @return <code>true</code> if container is recursive, <code>false</code>
+ * otherwise.
+ */
+ public boolean isRecursive() {
+ return recursive;
+ }
+
+ /**
+ * Sets the container recursive property. Set this to false to limit the
+ * files directly under the root file.
+ * <p>
+ * Note : This is meaningful only if the root really is a directory.
+ * </p>
+ *
+ * @param recursive
+ * the New value for recursive property.
+ */
+ public void setRecursive(boolean recursive) {
+ this.recursive = recursive;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.data.Container#addContainerProperty(java.lang.Object,
+ * java.lang.Class, java.lang.Object)
+ */
+ @Override
+ public boolean addContainerProperty(Object propertyId, Class<?> type,
+ Object defaultValue) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException(
+ "File system container does not support this operation");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.data.Container#addItem()
+ */
+ @Override
+ public Object addItem() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException(
+ "Git repository container does not support this operation");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.data.Container#addItem(java.lang.Object)
+ */
+ @Override
+ public Item addItem(Object itemId) throws UnsupportedOperationException {
+ if (! (itemId instanceof File)) {
+ throw new UnsupportedOperationException(
+ "Git repository container does not support this operation for Objects that are not files.");
+ }
+ if (logger.isTraceEnabled()) {
+ logger.trace("addItem: " + ((File)itemId).hashCode() + " " + ((File)itemId).getName());
+ }
+
+ fireItemSetChange();
+
+ return new FileItem((File) itemId);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.data.Container#removeAllItems()
+ */
+ @Override
+ public boolean removeAllItems() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException(
+ "File system container does not support this operation");
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.data.Container#removeItem(java.lang.Object)
+ */
+ @Override
+ public boolean removeItem(Object itemId)
+ throws UnsupportedOperationException {
+
+ if (logger.isTraceEnabled()) {
+ logger.trace("removeItem: " + ((File)itemId).hashCode() + " " + ((File)itemId).getName());
+ }
+
+ fireItemSetChange();
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.data.Container#removeContainerProperty(java.lang.Object )
+ */
+ @Override
+ public boolean removeContainerProperty(Object propertyId)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException(
+ "File system container does not support this operation");
+ }
+
+ public Object getRoot(int index) {
+ if (index >= this.roots.length) {
+ return null;
+ }
+ return this.roots[index];
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/GitStatusContainer.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/GitStatusContainer.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/GitStatusContainer.java
new file mode 100644
index 0000000..fbc5ea2
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/GitStatusContainer.java
@@ -0,0 +1,552 @@
+/*
+ * 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.xacml.admin.model;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.jgit.api.Status;
+import org.eclipse.jgit.lib.IndexDiff;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.util.MethodProperty;
+
+public class GitStatusContainer extends ItemSetChangeNotifier implements Container.Ordered, Container.ItemSetChangeNotifier {
+ private static final long serialVersionUID = 1L;
+ private Log logger = LogFactory.getLog(GitStatusContainer.class);
+
+ /**
+ * String identifier of a git file/directory's "name" property.
+ */
+ public static String PROPERTY_NAME = "Name";
+
+ /**
+ * String identifier of a git file/directory's "status" property.
+ */
+ public static String PROPERTY_STATUS = "Status";
+
+ /**
+ * String identifier of a git file/directory's "entry" property.
+ */
+ public static String PROPERTY_ENTRY = "Entry";
+
+ /**
+ * List of the string identifiers for the available properties.
+ */
+ public static Collection<String> GITSTATUS_PROPERTIES;
+
+ private final static Method GITSTATUSITEM_NAME;
+
+ private final static Method GITSTATUSITEM_STATUS;
+
+ private final static Method GITSTATUSITEM_ENTRY;
+
+ static {
+ GITSTATUS_PROPERTIES = new ArrayList<String>();
+ GITSTATUS_PROPERTIES.add(PROPERTY_NAME);
+ GITSTATUS_PROPERTIES.add(PROPERTY_STATUS);
+ GITSTATUS_PROPERTIES.add(PROPERTY_ENTRY);
+ GITSTATUS_PROPERTIES = Collections.unmodifiableCollection(GITSTATUS_PROPERTIES);
+ try {
+ GITSTATUSITEM_NAME = StatusItem.class.getMethod("getName", new Class[]{});
+ GITSTATUSITEM_STATUS = StatusItem.class.getMethod("getStatus", new Class[]{});
+ GITSTATUSITEM_ENTRY = StatusItem.class.getMethod("getGitEntry", new Class[]{});
+ } catch (final NoSuchMethodException e) {
+ throw new RuntimeException("Internal error finding methods in GitStatusContainer");
+ }
+ }
+
+ public class GitEntry {
+ String name;
+ boolean added = false;
+ boolean changed = false;
+ boolean conflicting = false;
+ boolean ignoredNotInIndex = false;
+ boolean missing = false;
+ boolean modified = false;
+ boolean removed = false;
+ boolean uncommitted = false;
+ boolean untracked = false;
+ boolean untrackedFolders = false;
+
+ public GitEntry(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public boolean isAdded() {
+ return added;
+ }
+
+ public void setAdded(boolean added) {
+ this.added = added;
+ }
+
+ public boolean isChanged() {
+ return changed;
+ }
+
+ public void setChanged(boolean changed) {
+ this.changed = changed;
+ }
+
+ public boolean isConflicting() {
+ return conflicting;
+ }
+
+ public void setConflicting(boolean conflicting) {
+ this.conflicting = conflicting;
+ }
+
+ public boolean isIgnoredNotInIndex() {
+ return ignoredNotInIndex;
+ }
+
+ public void setIgnoredNotInIndex(boolean ignoredNotInIndex) {
+ this.ignoredNotInIndex = ignoredNotInIndex;
+ }
+
+ public boolean isMissing() {
+ return missing;
+ }
+
+ public void setMissing(boolean missing) {
+ this.missing = missing;
+ }
+
+ public boolean isModified() {
+ return modified;
+ }
+
+ public void setModified(boolean modified) {
+ this.modified = modified;
+ }
+
+ public boolean isRemoved() {
+ return removed;
+ }
+
+ public void setRemoved(boolean removed) {
+ this.removed = removed;
+ }
+
+ public boolean isUncommitted() {
+ return uncommitted;
+ }
+
+ public void setUncommitted(boolean uncommitted) {
+ this.uncommitted = uncommitted;
+ }
+
+ public boolean isUntracked() {
+ return untracked;
+ }
+
+ public void setUntracked(boolean untracked) {
+ this.untracked = untracked;
+ }
+
+ public boolean isUntrackedFolders() {
+ return untrackedFolders;
+ }
+
+ public void setUntrackedFolders(boolean untrackedFolders) {
+ this.untrackedFolders = untrackedFolders;
+ }
+
+ public String getStatus() {
+ StringBuilder builder = new StringBuilder();
+ if (this.isAdded()) {
+ builder.append("Added" + System.lineSeparator());
+ }
+ if (this.isChanged()) {
+ builder.append("Changed" + System.lineSeparator());
+ }
+ if (this.isConflicting()) {
+ builder.append("Conflicting" + System.lineSeparator());
+ }
+ if (this.isMissing()) {
+ builder.append("Missing" + System.lineSeparator());
+ }
+ if (this.isModified()) {
+ builder.append("Modified" + System.lineSeparator());
+ }
+ if (this.isRemoved()) {
+ builder.append("Removed" + System.lineSeparator());
+ }
+ if (this.isUncommitted()) {
+ builder.append("Uncommitted" + System.lineSeparator());
+ }
+ if (this.isUntracked()) {
+ builder.append("Untracked" + System.lineSeparator());
+ }
+ if (this.isUntrackedFolders()) {
+ builder.append("Untracked Folders" + System.lineSeparator());
+ }
+ return builder.toString();
+ }
+
+ @Override
+ public String toString() {
+ return "GitEntry [name=" + name + ", added=" + added + ", changed="
+ + changed + ", conflicting=" + conflicting
+ + ", ignoredNotInIndex=" + ignoredNotInIndex + ", missing="
+ + missing + ", modified=" + modified + ", removed="
+ + removed + ", uncommitted=" + uncommitted + ", untracked="
+ + untracked + ", untrackedFolders=" + untrackedFolders
+ + "]";
+ }
+ }
+
+ //
+ // This is our data, a sorted map
+ //
+ private TreeMap<String, GitEntry> map = null;
+ private Map<String, IndexDiff.StageState> conflictingStage = null;
+ int conflictCount = 0;
+
+ public GitStatusContainer(Status status) {
+ super();
+ this.setContainer(this);
+ //
+ // Initialize
+ //
+ this.refreshStatus(status);
+ }
+
+ public void refreshStatus(Status status) {
+ //
+ // Save this
+ //
+ this.conflictingStage = status.getConflictingStageState();
+ if (logger.isDebugEnabled()) {
+ logger.debug("conflictingStage: " + this.conflictingStage.size());
+ }
+ //
+ // Re-create this
+ //
+ this.map = new TreeMap<String, GitEntry>();
+ this.conflictCount = 0;
+ //
+ // Iterate through everything
+ //
+ for (String id : status.getAdded()) {
+ if (id.endsWith(".gitignore") || id.endsWith(".DS_Store")) {
+ continue;
+ }
+ GitEntry entry = this.map.get(id);
+ if (entry == null) {
+ entry = new GitEntry(id);
+ this.map.put(id, entry);
+ }
+ entry.setAdded(true);
+ }
+ for (String id : status.getChanged()) {
+ if (id.endsWith(".gitignore") || id.endsWith(".DS_Store")) {
+ continue;
+ }
+ GitEntry entry = this.map.get(id);
+ if (entry == null) {
+ entry = new GitEntry(id);
+ this.map.put(id, entry);
+ }
+ entry.setChanged(true);
+ }
+ for (String id : status.getConflicting()) {
+ if (id.endsWith(".gitignore") || id.endsWith(".DS_Store")) {
+ continue;
+ }
+ GitEntry entry = this.map.get(id);
+ if (entry == null) {
+ entry = new GitEntry(id);
+ this.map.put(id, entry);
+ }
+ entry.setConflicting(true);
+ //
+ //
+ //
+ conflictCount++;
+ }
+ for (String id : status.getMissing()) {
+ if (id.endsWith(".gitignore") || id.endsWith(".DS_Store")) {
+ continue;
+ }
+ GitEntry entry = this.map.get(id);
+ if (entry == null) {
+ entry = new GitEntry(id);
+ this.map.put(id, entry);
+ }
+ entry.setMissing(true);
+ }
+ for (String id : status.getModified()) {
+ if (id.endsWith(".gitignore") || id.endsWith(".DS_Store")) {
+ continue;
+ }
+ GitEntry entry = this.map.get(id);
+ if (entry == null) {
+ entry = new GitEntry(id);
+ this.map.put(id, entry);
+ }
+ entry.setModified(true);
+ }
+ for (String id : status.getRemoved()) {
+ if (id.endsWith(".gitignore") || id.endsWith(".DS_Store")) {
+ continue;
+ }
+ GitEntry entry = this.map.get(id);
+ if (entry == null) {
+ entry = new GitEntry(id);
+ this.map.put(id, entry);
+ }
+ entry.setRemoved(true);
+ }
+ for (String id : status.getUncommittedChanges()) {
+ if (id.endsWith(".gitignore") || id.endsWith(".DS_Store")) {
+ continue;
+ }
+ GitEntry entry = this.map.get(id);
+ if (entry == null) {
+ entry = new GitEntry(id);
+ this.map.put(id, entry);
+ }
+ entry.setUncommitted(true);
+ }
+ for (String id : status.getUntracked()) {
+ if (id.endsWith(".gitignore") || id.endsWith(".DS_Store")) {
+ continue;
+ }
+ GitEntry entry = this.map.get(id);
+ if (entry == null) {
+ entry = new GitEntry(id);
+ this.map.put(id, entry);
+ }
+ entry.setUntracked(true);
+ }
+ for (String id : status.getUntrackedFolders()) {
+ if (id.endsWith(".gitignore") || id.endsWith(".DS_Store")) {
+ continue;
+ }
+ GitEntry entry = this.map.get(id);
+ if (entry == null) {
+ entry = new GitEntry(id);
+ this.map.put(id, entry);
+ }
+ entry.setUntrackedFolders(true);
+ }
+ }
+
+ public Map<String, IndexDiff.StageState> getConflictingStageState() {
+ return this.conflictingStage;
+ }
+
+ public int getConflictCount() {
+ return this.conflictCount;
+ }
+
+ @Override
+ public Item getItem(Object itemId) {
+ return new StatusItem(map.get(itemId));
+ }
+
+ @Override
+ public Collection<?> getContainerPropertyIds() {
+ return GITSTATUS_PROPERTIES;
+ }
+
+ @Override
+ public Collection<?> getItemIds() {
+ final Collection<String> items = new ArrayList<String>();
+ items.addAll(this.map.keySet());
+ return Collections.unmodifiableCollection(items);
+ }
+
+ @Override
+ public Property<Object> getContainerProperty(Object itemId, Object propertyId) {
+ GitEntry entry = this.map.get(itemId);
+ if (entry == null) {
+// logger.error("unknown itemId: " + itemId);
+ return null;
+ }
+ if (propertyId.equals(PROPERTY_NAME)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new StatusItem(entry), GITSTATUSITEM_NAME, null);
+ }
+ if (propertyId.equals(PROPERTY_STATUS)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new StatusItem(entry), GITSTATUSITEM_STATUS, null);
+ }
+ if (propertyId.equals(PROPERTY_ENTRY)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new StatusItem(entry), GITSTATUSITEM_ENTRY, null);
+ }
+ return null;
+ }
+
+ @Override
+ public Class<?> getType(Object propertyId) {
+ if (propertyId.equals(PROPERTY_NAME)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_STATUS)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_ENTRY)) {
+ return GitEntry.class;
+ }
+ return null;
+ }
+
+ @Override
+ public int size() {
+ return this.map.size();
+ }
+
+ @Override
+ public boolean containsId(Object itemId) {
+ return this.map.containsKey(itemId);
+ }
+
+ @Override
+ public Item addItem(Object itemId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Can't add items.");
+ }
+
+ @Override
+ public Object addItem() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Can't add items.");
+ }
+
+ @Override
+ public boolean removeItem(Object itemId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Can't remove items.");
+ }
+
+ @Override
+ public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Can't add properties.");
+ }
+
+ @Override
+ public boolean removeContainerProperty(Object propertyId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Can't remove properties.");
+ }
+
+ @Override
+ public boolean removeAllItems() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Can't remove items.");
+ }
+
+ @Override
+ public Object nextItemId(Object itemId) {
+ return this.map.higherKey((String) itemId);
+ }
+
+ @Override
+ public Object prevItemId(Object itemId) {
+ return this.map.lowerKey((String) itemId);
+ }
+
+ @Override
+ public Object firstItemId() {
+ return this.map.firstKey();
+ }
+
+ @Override
+ public Object lastItemId() {
+ return this.map.lastKey();
+ }
+
+ @Override
+ public boolean isFirstId(Object itemId) {
+ return itemId.equals(this.map.firstKey());
+ }
+
+ @Override
+ public boolean isLastId(Object itemId) {
+ return itemId.equals(this.map.lastKey());
+ }
+
+ @Override
+ public Object addItemAfter(Object previousItemId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Can't add items.");
+ }
+
+ @Override
+ public Item addItemAfter(Object previousItemId, Object newItemId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Can't add items.");
+ }
+
+ public class StatusItem implements Item {
+ private static final long serialVersionUID = 1L;
+ private final GitEntry entry;
+
+ public StatusItem(GitEntry itemId) {
+ this.entry = itemId;
+ }
+
+ public String getName() {
+ return this.entry.getName();
+ }
+
+ public String getStatus() {
+ return this.entry.getStatus();
+ }
+
+ public GitEntry getGitEntry() {
+ return this.entry;
+ }
+
+ @Override
+ public Property<?> getItemProperty(Object id) {
+ return getContainerProperty(this.entry, id);
+ }
+
+ @Override
+ public Collection<?> getItemPropertyIds() {
+ return getContainerPropertyIds();
+ }
+
+ @Override
+ public boolean addItemProperty(Object id, @SuppressWarnings("rawtypes") Property property) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Container does not support adding new properties");
+ }
+
+ @Override
+ public boolean removeItemProperty(Object id) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Container does not support removing properties");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/ItemSetChangeNotifier.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/ItemSetChangeNotifier.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/ItemSetChangeNotifier.java
new file mode 100644
index 0000000..7ad49ca
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/ItemSetChangeNotifier.java
@@ -0,0 +1,118 @@
+/*
+ * 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.xacml.admin.model;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.EventObject;
+import java.util.LinkedList;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Container.ItemSetChangeEvent;
+import com.vaadin.data.Container.ItemSetChangeListener;
+
+public class ItemSetChangeNotifier implements Container.ItemSetChangeNotifier {
+ private static final long serialVersionUID = 1L;
+ private Collection<Container.ItemSetChangeListener> itemSetChangeListeners = null;
+ private Container container = null;
+
+ public ItemSetChangeNotifier() {
+ }
+
+ protected void setContainer(Container c) {
+ this.container = c;
+ }
+
+ @Override
+ public void addItemSetChangeListener(ItemSetChangeListener listener) {
+ if (getItemSetChangeListeners() == null) {
+ setItemSetChangeListeners(new LinkedList<Container.ItemSetChangeListener>());
+ }
+ getItemSetChangeListeners().add(listener); }
+
+ // TODO - Container.ItemSetChangeNotifier.addListener has been deprecated and replaced with
+ // Container.ItemSetChangeNotifier.addItemSetChangeListener
+ @Override
+ public void addListener(ItemSetChangeListener listener) {
+ addItemSetChangeListener(listener);
+ }
+
+ @Override
+ public void removeItemSetChangeListener(ItemSetChangeListener listener) {
+ if (getItemSetChangeListeners() != null) {
+ getItemSetChangeListeners().remove(listener);
+ }
+ }
+
+ // TODO - Container.ItemSetChangeNotifier.removeListener has been deprecated and replaced with
+ // Container.ItemSetChangeNotifier.removeItemSetChangeListener
+ @Override
+ public void removeListener(ItemSetChangeListener listener) {
+ removeItemSetChangeListener(listener);
+ }
+
+ protected static class BaseItemSetChangeEvent extends EventObject implements
+ Container.ItemSetChangeEvent, Serializable {
+ private static final long serialVersionUID = 1L;
+
+ protected BaseItemSetChangeEvent(Container source) {
+ super(source);
+ }
+
+ @Override
+ public Container getContainer() {
+ return (Container) getSource();
+ }
+ }
+
+ protected void setItemSetChangeListeners(
+ Collection<Container.ItemSetChangeListener> itemSetChangeListeners) {
+ this.itemSetChangeListeners = itemSetChangeListeners;
+ }
+ protected Collection<Container.ItemSetChangeListener> getItemSetChangeListeners() {
+ return itemSetChangeListeners;
+ }
+ /**
+ * Sends a simple Item set change event to all interested listeners,
+ * indicating that anything in the contents may have changed (items added,
+ * removed etc.).
+ */
+ protected void fireItemSetChange() {
+ fireItemSetChange(new BaseItemSetChangeEvent(this.container));
+ }
+
+ /**
+ * Sends an Item set change event to all registered interested listeners.
+ *
+ * @param event
+ * the item set change event to send, optionally with additional
+ * information
+ */
+ protected void fireItemSetChange(ItemSetChangeEvent event) {
+ if (getItemSetChangeListeners() != null) {
+ final Object[] l = getItemSetChangeListeners().toArray();
+ for (int i = 0; i < l.length; i++) {
+ ((Container.ItemSetChangeListener) l[i])
+ .containerItemSetChange(event);
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/MatchFunctionQueryDelegate.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/MatchFunctionQueryDelegate.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/MatchFunctionQueryDelegate.java
new file mode 100644
index 0000000..a187ef7
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/MatchFunctionQueryDelegate.java
@@ -0,0 +1,143 @@
+/*
+ * 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.xacml.admin.model;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.List;
+
+import com.vaadin.data.Container.Filter;
+import com.vaadin.data.util.sqlcontainer.RowItem;
+import com.vaadin.data.util.sqlcontainer.SQLUtil;
+import com.vaadin.data.util.sqlcontainer.query.FreeformStatementDelegate;
+import com.vaadin.data.util.sqlcontainer.query.OrderBy;
+import com.vaadin.data.util.sqlcontainer.query.generator.StatementHelper;
+import com.vaadin.data.util.sqlcontainer.query.generator.filter.QueryBuilder;
+
+public class MatchFunctionQueryDelegate implements FreeformStatementDelegate {
+ private static final long serialVersionUID = 1L;
+ private List<Filter> filters = null;
+ private List<OrderBy> orderBys = null;
+
+ public MatchFunctionQueryDelegate() {
+ }
+
+ @Override
+ public String getQueryString(int offset, int limit)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("use getQueryStatement");
+ }
+
+ @Override
+ public String getCountQuery() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("getCountStatement");
+ }
+
+ @Override
+ public void setFilters(List<Filter> filters)
+ throws UnsupportedOperationException {
+ this.filters = filters;
+ }
+
+ @Override
+ public void setOrderBy(List<OrderBy> orderBys)
+ throws UnsupportedOperationException {
+ this.orderBys = orderBys;
+ }
+
+ @Override
+ public int storeRow(Connection conn, RowItem row)
+ throws UnsupportedOperationException, SQLException {
+ throw new UnsupportedOperationException("Cannot store anything");
+ }
+
+ @Override
+ public boolean removeRow(Connection conn, RowItem row)
+ throws UnsupportedOperationException, SQLException {
+ throw new UnsupportedOperationException("Cannot remove anything");
+ }
+
+ @Override
+ public String getContainsRowQueryString(Object... keys)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("use getContainsRowQueryStatement");
+ }
+
+ @Override
+ public StatementHelper getQueryStatement(int offset, int limit)
+ throws UnsupportedOperationException {
+ StatementHelper sh = new StatementHelper();
+ StringBuffer query = new StringBuffer("SELECT * FROM match_functions ");
+ if (this.filters != null && this.filters.isEmpty() == false) {
+ query.append(QueryBuilder.getWhereStringForFilters(this.filters, sh));
+ }
+ query.append(getOrderByString());
+ if (offset != 0 || limit != 0) {
+ query.append(" LIMIT ").append(limit);
+ query.append(" OFFSET ").append(offset);
+ }
+ sh.setQueryString(query.toString());
+ return sh;
+ }
+
+ @Override
+ public StatementHelper getCountStatement()
+ throws UnsupportedOperationException {
+ StatementHelper sh = new StatementHelper();
+ StringBuffer query = new StringBuffer("SELECT COUNT(*) FROM match_functions ");
+ if (this.filters != null && this.filters.isEmpty() == false) {
+ query.append(QueryBuilder.getWhereStringForFilters(this.filters, sh));
+ }
+ query.append(getOrderByString());
+ sh.setQueryString(query.toString());
+ return sh;
+ }
+
+ @Override
+ public StatementHelper getContainsRowQueryStatement(Object... keys)
+ throws UnsupportedOperationException {
+ StatementHelper sh = new StatementHelper();
+ StringBuffer query = new StringBuffer("SELECT * FROM match_functions WHERE ARGUMENT_ID = ?");
+ sh.addParameterValue(keys[0]);
+ sh.setQueryString(query.toString());
+ return sh;
+ }
+
+ private String getOrderByString() {
+ StringBuffer orderBuffer = new StringBuffer("");
+ if (this.orderBys != null && !this.orderBys.isEmpty()) {
+ orderBuffer.append(" ORDER BY ");
+ OrderBy lastOrderBy = this.orderBys.get(this.orderBys.size() - 1);
+ for (OrderBy orderBy : this.orderBys) {
+ orderBuffer.append(SQLUtil.escapeSQL(orderBy.getColumn()));
+ if (orderBy.isAscending()) {
+ orderBuffer.append(" ASC");
+ } else {
+ orderBuffer.append(" DESC");
+ }
+ if (orderBy != lastOrderBy) {
+ orderBuffer.append(", ");
+ }
+ }
+ }
+ return orderBuffer.toString();
+ }
+}
[07/23] incubator-openaz git commit: Ported original att source to
openaz
Posted by pd...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/RFC822NameValidator.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/RFC822NameValidator.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/RFC822NameValidator.java
new file mode 100644
index 0000000..4211cd7
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/RFC822NameValidator.java
@@ -0,0 +1,45 @@
+/*
+ * 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.xacml.admin.view.validators;
+
+import java.text.ParseException;
+
+import org.apache.openaz.xacml.std.datatypes.RFC822Name;
+import com.vaadin.data.Validator;
+
+public class RFC822NameValidator implements Validator {
+ private static final long serialVersionUID = 1L;
+
+ public RFC822NameValidator() {
+ }
+
+ @Override
+ public void validate(Object value) throws InvalidValueException {
+ if (value instanceof String) {
+ try {
+ RFC822Name.newInstance((String) value);
+ } catch (ParseException e) {
+ throw new InvalidValueException(e.getLocalizedMessage());
+ }
+ } else
+ throw new InvalidValueException("Unrecognized RFC822 Name");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/StringValidator.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/StringValidator.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/StringValidator.java
new file mode 100644
index 0000000..7d03d38
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/StringValidator.java
@@ -0,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.xacml.admin.view.validators;
+
+import com.vaadin.data.Validator;
+
+public class StringValidator implements Validator {
+ private static final long serialVersionUID = 1L;
+
+ public StringValidator() {
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public void validate(Object value) throws InvalidValueException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/TimeValidator.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/TimeValidator.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/TimeValidator.java
new file mode 100644
index 0000000..b93dafe
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/TimeValidator.java
@@ -0,0 +1,45 @@
+/*
+ * 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.xacml.admin.view.validators;
+
+import java.text.ParseException;
+
+import org.apache.openaz.xacml.std.datatypes.ISO8601Time;
+import com.vaadin.data.Validator;
+
+public class TimeValidator implements Validator {
+ private static final long serialVersionUID = 1L;
+
+ public TimeValidator() {
+ }
+
+ @Override
+ public void validate(Object value) throws InvalidValueException {
+ if (value instanceof String) {
+ try {
+ ISO8601Time.fromISO8601TimeString((String) value);
+ } catch (ParseException e) {
+ throw new InvalidValueException(e.getLocalizedMessage());
+ }
+ } else
+ throw new InvalidValueException("Unrecognized Time");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/ValidatorFactory.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/ValidatorFactory.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/ValidatorFactory.java
new file mode 100644
index 0000000..354d662
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/ValidatorFactory.java
@@ -0,0 +1,71 @@
+/*
+ * 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.xacml.admin.view.validators;
+
+import org.apache.openaz.xacml.admin.jpa.Datatype;
+import org.apache.openaz.xacml.api.XACML3;
+import com.vaadin.data.Validator;
+
+public class ValidatorFactory {
+
+ public static Validator newInstance(Datatype datatype) {
+
+ if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_ANYURI)) {
+ return new AnyURIValidator();
+ } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_BASE64BINARY)) {
+ return new Base64BinaryValidator();
+ } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_BOOLEAN)) {
+ return new BooleanValidator();
+ } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_DATE)) {
+ return new DateValidator();
+ } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_DATETIME)) {
+ return new DateTimeValidator();
+ } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_DAYTIMEDURATION)) {
+ return new DayTimeDurationValidator();
+ } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_DNSNAME)) {
+ return new DNSNameValidator();
+ } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_DOUBLE)) {
+ return new DoubleValidator();
+ } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_HEXBINARY)) {
+ return new HexBinaryValidator();
+ } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_INTEGER)) {
+ return new IntegerValidator();
+ } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_IPADDRESS)) {
+ return new IpAddressValidator();
+ } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_RFC822NAME)) {
+ return new RFC822NameValidator();
+ } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_STRING)) {
+ return new StringValidator();
+ } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_TIME)) {
+ return new TimeValidator();
+ } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_X500NAME)) {
+ return new X500NameValidator();
+ /*
+ } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_XPATHEXPRESSION)) {
+
+ */
+ } else if (datatype.getIdentifer().equals(XACML3.ID_DATATYPE_YEARMONTHDURATION)) {
+ return new YearMonthDurationValidator();
+ }
+
+ return null;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/X500NameValidator.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/X500NameValidator.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/X500NameValidator.java
new file mode 100644
index 0000000..977a13d
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/X500NameValidator.java
@@ -0,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.xacml.admin.view.validators;
+
+import javax.security.auth.x500.X500Principal;
+
+import com.vaadin.data.Validator;
+
+public class X500NameValidator implements Validator {
+ private static final long serialVersionUID = 1L;
+
+ public X500NameValidator() {
+ }
+
+ @Override
+ public void validate(Object value) throws InvalidValueException {
+ if (value instanceof String) {
+ try {
+ new X500Principal((String) value);
+ } catch (IllegalArgumentException e) {
+ throw new InvalidValueException(e.getLocalizedMessage());
+ }
+ } else
+ throw new InvalidValueException("Unrecognized X500 Name");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/YearMonthDurationValidator.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/YearMonthDurationValidator.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/YearMonthDurationValidator.java
new file mode 100644
index 0000000..8d53629
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/YearMonthDurationValidator.java
@@ -0,0 +1,45 @@
+/*
+ * 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.xacml.admin.view.validators;
+
+import java.text.ParseException;
+
+import org.apache.openaz.xacml.std.datatypes.XPathYearMonthDuration;
+import com.vaadin.data.Validator;
+
+public class YearMonthDurationValidator implements Validator {
+ private static final long serialVersionUID = 1L;
+
+ public YearMonthDurationValidator() {
+ }
+
+ @Override
+ public void validate(Object value) throws InvalidValueException {
+ if (value instanceof String) {
+ try {
+ XPathYearMonthDuration.newInstance((String) value);
+ } catch (ParseException e) {
+ throw new InvalidValueException(e.getLocalizedMessage());
+ }
+ } else
+ throw new InvalidValueException("Unrecognized YearMonthDuration");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/AdviceEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/AdviceEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/AdviceEditorWindow.java
new file mode 100644
index 0000000..802eb43
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/AdviceEditorWindow.java
@@ -0,0 +1,208 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.EffectType;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Buffered.SourceException;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.OptionGroup;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class AdviceEditorWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSave;
+ @AutoGenerated
+ private OptionGroup optionGroupEffect;
+ @AutoGenerated
+ private TextField textFieldAdviceID;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private final AdviceEditorWindow self = this;
+ private final AdviceExpressionType advice;
+ private boolean isSaved = false;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public AdviceEditorWindow(AdviceExpressionType advice) {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Save
+ //
+ this.advice = advice;
+ //
+ // Set our shortcuts
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ // Initialize GUI
+ //
+ this.initialize();
+ this.initializeButton();
+ //
+ // Focus
+ //
+ this.textFieldAdviceID.focus();
+ }
+
+ protected void initialize() {
+ //
+ // The text field for the advice ID
+ //
+ this.textFieldAdviceID.setNullRepresentation("");
+ if (this.advice.getAdviceId() == null) {
+ this.textFieldAdviceID.setValue(XacmlAdminUI.getDomain());
+ } else {
+ this.textFieldAdviceID.setValue(advice.getAdviceId());
+ }
+ this.textFieldAdviceID.setRequiredError("You must have an ID for the advice");
+ //
+ // The option
+ //
+ this.optionGroupEffect.setRequiredError("You must select Permit or Deny for the advice");
+ this.optionGroupEffect.addItem(EffectType.PERMIT);
+ this.optionGroupEffect.addItem(EffectType.DENY);
+ if (this.advice.getAppliesTo() == null) {
+ this.optionGroupEffect.select(EffectType.PERMIT);
+ } else {
+ if (this.advice.getAppliesTo().equals(EffectType.PERMIT)) {
+ this.optionGroupEffect.select(EffectType.PERMIT);
+ } else {
+ this.optionGroupEffect.select(EffectType.DENY);
+ }
+ }
+ }
+
+ protected void initializeButton() {
+ this.buttonSave.setImmediate(true);
+ this.buttonSave.setClickShortcut(KeyCode.ENTER);
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ try {
+ //
+ // Commit
+ //
+ self.textFieldAdviceID.commit();
+ self.optionGroupEffect.commit();
+ //
+ // all good, save everything
+ //
+ self.advice.setAdviceId(self.textFieldAdviceID.getValue());
+ self.advice.setAppliesTo((EffectType) self.optionGroupEffect.getValue());
+ //
+ // Set ourselves as saved
+ //
+ self.isSaved = true;
+ //
+ // Close the window
+ //
+ self.close();
+ } catch (SourceException | InvalidValueException e) { //NOPMD
+ //
+ // Vaadin displays the error
+ //
+ }
+ }
+ });
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ public AdviceExpressionType getAdvice() {
+ return this.advice;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // textFieldAdviceID
+ textFieldAdviceID = new TextField();
+ textFieldAdviceID.setCaption("Advice ID");
+ textFieldAdviceID.setImmediate(false);
+ textFieldAdviceID.setWidth("-1px");
+ textFieldAdviceID.setHeight("-1px");
+ textFieldAdviceID.setInvalidAllowed(false);
+ textFieldAdviceID.setRequired(true);
+ textFieldAdviceID.setInputPrompt("Eg. urn:com:foo:advice:sample");
+ mainLayout.addComponent(textFieldAdviceID);
+
+ // optionGroupEffect
+ optionGroupEffect = new OptionGroup();
+ optionGroupEffect.setCaption("Applies To");
+ optionGroupEffect.setImmediate(false);
+ optionGroupEffect.setWidth("-1px");
+ optionGroupEffect.setHeight("-1px");
+ optionGroupEffect.setInvalidAllowed(false);
+ optionGroupEffect.setRequired(true);
+ mainLayout.addComponent(optionGroupEffect);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save");
+ buttonSave.setImmediate(true);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ApplyEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ApplyEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ApplyEditorWindow.java
new file mode 100644
index 0000000..e8496e5
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ApplyEditorWindow.java
@@ -0,0 +1,600 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import java.util.List;
+import java.util.Map;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ConditionType;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.jpa.Datatype;
+import org.apache.openaz.xacml.admin.jpa.FunctionArgument;
+import org.apache.openaz.xacml.admin.jpa.FunctionDefinition;
+import org.apache.openaz.xacml.admin.util.JPAUtils;
+import org.apache.openaz.xacml.admin.view.events.ApplyParametersChangedListener;
+import org.apache.openaz.xacml.admin.view.events.ApplyParametersChangedNotifier;
+import org.apache.openaz.xacml.api.XACML3;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Buffered.SourceException;
+import com.vaadin.data.Container;
+import com.vaadin.data.Container.Filter;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.data.util.BeanItemContainer;
+import com.vaadin.data.util.filter.Compare;
+import com.vaadin.data.util.filter.SimpleStringFilter;
+import com.vaadin.event.FieldEvents.TextChangeEvent;
+import com.vaadin.event.FieldEvents.TextChangeListener;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.AbstractSelect.ItemCaptionMode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class ApplyEditorWindow extends Window implements ApplyParametersChangedNotifier {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSelect;
+ @AutoGenerated
+ private Table tableFunction;
+ @AutoGenerated
+ private HorizontalLayout horizontalLayout_1;
+ @AutoGenerated
+ private CheckBox checkBoxFilterIsBag;
+ @AutoGenerated
+ private ComboBox comboBoxDatatypeFilter;
+ @AutoGenerated
+ private TextField textFieldFilter;
+ @AutoGenerated
+ private TextArea textAreaDescription;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static Log logger = LogFactory.getLog(ApplyEditorWindow.class);
+ private final ApplyEditorWindow self = this;
+ private final ApplyParametersChangedNotifier notifier = new ApplyParametersChangedNotifier.BasicNotifier();
+ private final BeanItemContainer<FunctionDefinition> container = new BeanItemContainer<FunctionDefinition>(FunctionDefinition.class);
+ private final ApplyType apply;
+ private final ApplyType applyParent;
+ private final FunctionArgument argument;
+ private final Object parent;
+ private boolean isSaved = false;
+ private FunctionDefinition function = null;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ * @param parent
+ * @param parentApply
+ */
+ public ApplyEditorWindow(ApplyType apply, ApplyType parentApply, FunctionArgument argument, Object parent) {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Save
+ //
+ this.apply = apply;
+ this.applyParent = parentApply;
+ this.argument = argument;
+ this.parent = parent;
+ logger.info(this.apply + " " + this.applyParent + " " + this.argument + " " + this.parent);
+ //
+ // Set our shortcuts
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ // Initialize
+ //
+ this.textAreaDescription.setValue(apply.getDescription());
+ this.textAreaDescription.setNullRepresentation("");
+ this.initializeButton();
+ this.initializeTable();
+ this.initializeFilters();
+ //
+ // focus
+ //
+ this.textFieldFilter.focus();
+ }
+
+ protected void initializeTable() {
+ //
+ // Setup GUI properties
+ //
+ this.tableFunction.setImmediate(true);
+ this.tableFunction.setSelectable(true);
+ this.tableFunction.setNullSelectionAllowed(false);
+ this.tableFunction.setRequired(true);
+ this.tableFunction.setRequiredError("You MUST select a function for the Apply");
+ //
+ // Set its data source
+ //
+ this.tableFunction.setContainerDataSource(this.container);
+ this.tableFunction.setVisibleColumns(new Object[] {"xacmlid", "shortname", "datatypeBean", "isBagReturn"});
+ this.tableFunction.setColumnHeaders(new String[] {"Function Xacml ID", "ID", "Return Data Type", "Return Bag?"});
+ //
+ // Determine appropriate filters
+ //
+ Datatype datatypeId = null;
+ if (this.applyParent == null) {
+ if (this.parent instanceof ConditionType) {
+ //
+ // Only boolean functions allowed
+ //
+ datatypeId = JPAUtils.findDatatype(XACML3.ID_DATATYPE_BOOLEAN);
+ }
+ } else {
+ String parentFunction = this.applyParent.getFunctionId();
+ this.function = JPAUtils.findFunction(parentFunction);
+ if (this.function == null) {
+ throw new IllegalArgumentException("applyParent's function is not found:" + parentFunction);
+ }
+ if (this.argument == null) {
+ throw new IllegalArgumentException("Need to know what argument apply is ");
+ }
+ datatypeId = this.argument.getDatatypeBean();
+ }
+ Map<Datatype, List<FunctionDefinition>> functionMap = JPAUtils.getFunctionDatatypeMap();
+ if (datatypeId == null) {
+ //
+ // All functions are available
+ //
+ for (Datatype id : functionMap.keySet()) {
+ this.addTableEntries(functionMap.get(id));
+ }
+ } else {
+ for (Datatype id : functionMap.keySet()) {
+ if (id == null) {
+ if (datatypeId == null) {
+ this.addTableEntries(functionMap.get(id));
+ break;
+ }
+ continue;
+ }
+ if (id.getId() == datatypeId.getId()) {
+ this.addTableEntries(functionMap.get(id));
+ break;
+ }
+ }
+ }
+ //
+ // Setup double-click
+ //
+ this.tableFunction.addItemClickListener(new ItemClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void itemClick(ItemClickEvent event) {
+ if (event.isDoubleClick()) {
+ self.selected();
+ }
+ }
+ });
+ //
+ // Value change listener
+ //
+ this.tableFunction.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ logger.info("valueChange " + self.tableFunction.getValue());
+ if (self.tableFunction.getValue() != null) {
+ self.buttonSelect.setEnabled(true);
+ } else {
+ self.buttonSelect.setEnabled(false);
+ }
+ }
+ });
+ //
+ // Select current value if possible
+ //
+ if (this.apply != null && this.apply.getFunctionId() != null && this.apply.getFunctionId().isEmpty() == false) {
+ FunctionDefinition current = JPAUtils.findFunction(this.apply.getFunctionId());
+ if (current != null) {
+ this.tableFunction.select(current);
+ this.tableFunction.setCurrentPageFirstItemId(current);
+ } else {
+ logger.warn("Could not find function in table for " + this.apply.getFunctionId());
+ }
+ } else {
+ this.buttonSelect.setEnabled(false);
+ }
+ }
+
+ protected void addTableEntries(List<FunctionDefinition> functions) {
+ if (functions == null) {
+ logger.warn("NULL list of functions, cannot add to table.");
+ return;
+ }
+ for (FunctionDefinition function : functions) {
+ //
+ // Just check if this function is available for this
+ // apply.
+ //
+// if (XACMLFunctionValidator.isFunctionAvailable(function, this.apply, this.argument)) {
+ this.container.addBean(function);
+// } else {
+// if (logger.isDebugEnabled()) {
+// logger.debug("Function not available: " + function);
+// }
+// }
+ }
+ }
+
+ protected void initializeButton() {
+ this.buttonSelect.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ self.selected();
+ }
+ });
+ }
+
+ protected void initializeFilters() {
+ this.textFieldFilter.setImmediate(true);
+ this.textFieldFilter.addTextChangeListener(new TextChangeListener() {
+ private static final long serialVersionUID = 1L;
+ SimpleStringFilter currentFilter = null;
+
+ @Override
+ public void textChange(TextChangeEvent event) {
+ //
+ // Remove current filter
+ //
+ if (this.currentFilter != null) {
+ self.container.removeContainerFilter(this.currentFilter);
+ this.currentFilter = null;
+ }
+ //
+ // Get the text
+ //
+ String value = event.getText();
+ if (value != null && value.length() > 0) {
+ //
+ // Add the new filter
+ //
+ this.currentFilter = new SimpleStringFilter("shortname", value, true, false);
+ self.container.addContainerFilter(this.currentFilter);
+ }
+ }
+ });
+
+ this.comboBoxDatatypeFilter.setContainerDataSource(((XacmlAdminUI) UI.getCurrent()).getDatatypes());
+ this.comboBoxDatatypeFilter.setImmediate(true);
+ this.comboBoxDatatypeFilter.setItemCaptionMode(ItemCaptionMode.PROPERTY);
+ this.comboBoxDatatypeFilter.setItemCaptionPropertyId("xacmlId");
+ this.comboBoxDatatypeFilter.setNullSelectionAllowed(true);
+ this.comboBoxDatatypeFilter.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+ Container.Filter currentFilter = null;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ //
+ // Remove current filter
+ //
+ if (this.currentFilter != null) {
+ self.container.removeContainerFilter(this.currentFilter);
+ this.currentFilter = null;
+ }
+ //
+ // Get the current selection
+ //
+ Object id = self.comboBoxDatatypeFilter.getValue();
+ if (id == null) {
+ return;
+ }
+ //
+ // Setup the filter
+ //
+ final Datatype datatype = ((XacmlAdminUI) UI.getCurrent()).getDatatypes().getItem(id).getEntity();
+ this.currentFilter = new Container.Filter() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public boolean passesFilter(Object itemId, Item item) throws UnsupportedOperationException {
+ if (itemId instanceof FunctionDefinition) {
+ Datatype dt = ((FunctionDefinition) itemId).getDatatypeBean();
+ if (dt == null) {
+ return false;
+ }
+ return dt.getXacmlId().equals(datatype.getXacmlId());
+ }
+ return false;
+ }
+
+ @Override
+ public boolean appliesToProperty(Object propertyId) {
+ if (propertyId != null && propertyId.toString().equals("datatypeBean")) {
+ return true;
+ }
+ return false;
+ }
+ };
+ self.container.addContainerFilter(this.currentFilter);
+ }
+ });
+
+ this.checkBoxFilterIsBag.setImmediate(true);
+ this.checkBoxFilterIsBag.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+ Filter currentFilter = null;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ //
+ // Remove current filter
+ //
+ if (this.currentFilter != null) {
+ self.container.removeContainerFilter(this.currentFilter);
+ this.currentFilter = null;
+ }
+ //
+ // Is it checked?
+ //
+ if (self.checkBoxFilterIsBag.getValue() == false) {
+ //
+ // Nope, get out of here
+ //
+ return;
+ }
+ //
+ // Add the filter
+ //
+ this.currentFilter = new Compare.Equal("isBagReturn", true);
+ self.container.addContainerFilter(this.currentFilter);
+ }
+ });
+ }
+
+ protected void selected() {
+ //
+ // Is there a selected function?
+ //
+ try {
+ //
+ // Run the commit
+ //
+ this.textAreaDescription.commit();
+ this.tableFunction.commit();
+ //
+ // Commit worked, get the selected function
+ //
+ Object id = this.tableFunction.getValue();
+ //
+ // Sanity check, it *should* never be null
+ // unless someone changed the initialization code.
+ //
+ if (id == null || ! (id instanceof FunctionDefinition)) {
+ throw new InvalidValueException(this.tableFunction.getRequiredError());
+ }
+ //
+ // Get the actual function and save it into the apply
+ //
+ this.function = (FunctionDefinition) id;
+ this.apply.setDescription(this.textAreaDescription.getValue());
+ this.apply.setFunctionId(function.getXacmlid());
+ } catch (SourceException | InvalidValueException e) {
+ //
+ // Vaadin GUI will display message
+ //
+ return;
+ }
+ /**
+ //
+ // Make sure the arguments are good
+ //
+ final ApplyType copyApply = XACMLObjectCopy.copy(this.apply);
+ final ApplyArgumentsEditorWindow window = new ApplyArgumentsEditorWindow(copyApply, this.function);
+ window.setCaption("Define Arguments for " + this.function.getShortname());
+ window.setModal(true);
+ window.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Did the user click save?
+ //
+ if (window.isSaved() == false) {
+ return;
+ }
+ //
+ // Save our arguments
+ //
+ self.apply.getExpression().clear();
+ self.apply.getExpression().addAll(copyApply.getExpression());
+ //
+ // We are saved
+ //
+ self.isSaved = true;
+ //
+ // Fire
+ //
+ self.fireEvent(self.apply, self.applyParent, self.argument, self.parent);
+ //
+ // Close the apply editor window
+ //
+ self.close();
+ }
+ });
+ window.center();
+ UI.getCurrent().addWindow(window);
+ **/
+ //
+ // We are saved
+ //
+ self.isSaved = true;
+ //
+ // Fire
+ //
+ self.fireEvent(self.apply, self.applyParent, self.argument, self.parent);
+ //
+ // Close the apply editor window
+ //
+ self.close();
+ }
+
+ @Override
+ public boolean addListener(ApplyParametersChangedListener listener) {
+ return this.notifier.addListener(listener);
+ }
+
+ @Override
+ public boolean removeListener(ApplyParametersChangedListener listener) {
+ return this.notifier.removeListener(listener);
+ }
+
+ @Override
+ public void fireEvent(ApplyType apply, ApplyType parent, FunctionArgument argument, Object container) {
+ this.notifier.fireEvent(apply, parent, argument, container);
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ public FunctionDefinition getSelectedFunction() {
+ return this.function;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // horizontalLayout_1
+ horizontalLayout_1 = buildHorizontalLayout_1();
+ mainLayout.addComponent(horizontalLayout_1);
+
+ // tableFunction
+ tableFunction = new Table();
+ tableFunction.setCaption("Select A Function");
+ tableFunction.setImmediate(false);
+ tableFunction.setWidth("100.0%");
+ tableFunction.setHeight("-1px");
+ tableFunction.setInvalidAllowed(false);
+ tableFunction.setRequired(true);
+ mainLayout.addComponent(tableFunction);
+ mainLayout.setExpandRatio(tableFunction, 1.0f);
+
+ // buttonSelect
+ buttonSelect = new Button();
+ buttonSelect.setCaption("Select and Continue");
+ buttonSelect.setImmediate(true);
+ buttonSelect.setWidth("-1px");
+ buttonSelect.setHeight("-1px");
+ mainLayout.addComponent(buttonSelect);
+ mainLayout.setComponentAlignment(buttonSelect, new Alignment(48));
+
+ return mainLayout;
+ }
+
+ @AutoGenerated
+ private HorizontalLayout buildHorizontalLayout_1() {
+ // common part: create layout
+ horizontalLayout_1 = new HorizontalLayout();
+ horizontalLayout_1.setImmediate(false);
+ horizontalLayout_1.setWidth("-1px");
+ horizontalLayout_1.setHeight("-1px");
+ horizontalLayout_1.setMargin(false);
+ horizontalLayout_1.setSpacing(true);
+
+ // textAreaDescription
+ textAreaDescription = new TextArea();
+ textAreaDescription.setCaption("Enter A Description");
+ textAreaDescription.setImmediate(false);
+ textAreaDescription.setWidth("50.0%");
+ textAreaDescription.setHeight("-1px");
+ horizontalLayout_1.addComponent(textAreaDescription);
+
+ // textFieldFilter
+ textFieldFilter = new TextField();
+ textFieldFilter.setCaption("Filter Function By ID");
+ textFieldFilter.setImmediate(false);
+ textFieldFilter.setWidth("-1px");
+ textFieldFilter.setHeight("-1px");
+ horizontalLayout_1.addComponent(textFieldFilter);
+ horizontalLayout_1.setComponentAlignment(textFieldFilter,
+ new Alignment(9));
+
+ // comboBoxDatatypeFilter
+ comboBoxDatatypeFilter = new ComboBox();
+ comboBoxDatatypeFilter.setCaption("Filter By Data Type");
+ comboBoxDatatypeFilter.setImmediate(false);
+ comboBoxDatatypeFilter.setWidth("-1px");
+ comboBoxDatatypeFilter.setHeight("-1px");
+ horizontalLayout_1.addComponent(comboBoxDatatypeFilter);
+ horizontalLayout_1.setComponentAlignment(comboBoxDatatypeFilter,
+ new Alignment(9));
+
+ // checkBoxFilterIsBag
+ checkBoxFilterIsBag = new CheckBox();
+ checkBoxFilterIsBag.setCaption("Is Bag Filter");
+ checkBoxFilterIsBag.setImmediate(false);
+ checkBoxFilterIsBag.setWidth("-1px");
+ checkBoxFilterIsBag.setHeight("-1px");
+ horizontalLayout_1.addComponent(checkBoxFilterIsBag);
+ horizontalLayout_1.setComponentAlignment(checkBoxFilterIsBag,
+ new Alignment(9));
+
+ return horizontalLayout_1;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/AttributeAssignmentExpressionEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/AttributeAssignmentExpressionEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/AttributeAssignmentExpressionEditorWindow.java
new file mode 100644
index 0000000..a9306fa
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/AttributeAssignmentExpressionEditorWindow.java
@@ -0,0 +1,228 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeAssignmentExpressionType;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.jpa.Category;
+import com.vaadin.addon.jpacontainer.EntityItem;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Buffered.SourceException;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class AttributeAssignmentExpressionEditorWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSave;
+ @AutoGenerated
+ private Table tableCategories;
+ @AutoGenerated
+ private TextField textFieldIssuer;
+ @AutoGenerated
+ private TextField textFieldAttributeID;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private final AttributeAssignmentExpressionEditorWindow self = this;
+ private final AttributeAssignmentExpressionType assignment;
+ private boolean isSaved = false;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public AttributeAssignmentExpressionEditorWindow(AttributeAssignmentExpressionType assignment) {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Save
+ //
+ this.assignment = assignment;
+ //
+ // Set our shortcuts
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ // Initialize GUI
+ //
+ this.initializeText();
+ this.initializeTable();
+ this.initializeButton();
+ //
+ // Focus
+ //
+ this.textFieldAttributeID.focus();
+ }
+
+ protected void initializeText() {
+ //
+ //
+ //
+ this.textFieldAttributeID.setNullRepresentation("");
+ if (this.assignment.getAttributeId() == null) {
+ this.textFieldAttributeID.setValue(XacmlAdminUI.getDomain());
+ } else {
+ this.textFieldAttributeID.setValue(this.assignment.getAttributeId());
+ }
+ this.textFieldAttributeID.setRequiredError("You must have an attribute id for the assignment expression.");
+ //
+ //
+ //
+ this.textFieldIssuer.setNullRepresentation("");
+ this.textFieldIssuer.setValue(this.assignment.getIssuer());
+ }
+
+ protected void initializeTable() {
+ this.tableCategories.setContainerDataSource(((XacmlAdminUI) UI.getCurrent()).getCategories());
+ this.tableCategories.setVisibleColumns(new Object[] {"xacmlId"});
+ this.tableCategories.setColumnHeaders(new String[] {"XACML ID"});
+ this.tableCategories.setSelectable(true);
+ this.tableCategories.setNullSelectionAllowed(true);
+ this.tableCategories.setPageLength(((XacmlAdminUI) UI.getCurrent()).getCategories().size());
+ }
+
+ protected void initializeButton() {
+ this.buttonSave.setClickShortcut(KeyCode.ENTER);
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ try {
+ //
+ // Commit
+ //
+ self.textFieldAttributeID.commit();
+ self.textFieldIssuer.commit();
+ self.tableCategories.commit();
+ //
+ // Save
+ //
+ self.assignment.setAttributeId(self.textFieldAttributeID.getValue());
+ self.assignment.setIssuer(self.textFieldIssuer.getValue());
+ Object cat = self.tableCategories.getValue();
+ if (cat != null) {
+ EntityItem<Category> entity = ((XacmlAdminUI) UI.getCurrent()).getCategories().getItem(cat);
+ if (entity != null && entity.getEntity() != null) {
+ self.assignment.setCategory(entity.getEntity().getXacmlId());
+ } else {
+ self.assignment.setCategory(null);
+ }
+ } else {
+ self.assignment.setCategory(null);
+ }
+ //
+ // Set ourselves as saved
+ //
+ self.isSaved = true;
+ //
+ // close window
+ //
+ self.close();
+ } catch (SourceException e) { //NOPMD
+ //
+ // Vaadin displays error GUI
+ //
+ }
+ }
+ });
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ public AttributeAssignmentExpressionType getAssignment () {
+ return this.assignment;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // textFieldAttributeID
+ textFieldAttributeID = new TextField();
+ textFieldAttributeID.setCaption("Attribute Assignment ID");
+ textFieldAttributeID.setImmediate(false);
+ textFieldAttributeID.setWidth("-1px");
+ textFieldAttributeID.setHeight("-1px");
+ textFieldAttributeID.setInvalidAllowed(false);
+ textFieldAttributeID.setRequired(true);
+ mainLayout.addComponent(textFieldAttributeID);
+
+ // textFieldIssuer
+ textFieldIssuer = new TextField();
+ textFieldIssuer.setCaption("Issuer (Optional)");
+ textFieldIssuer.setImmediate(false);
+ textFieldIssuer.setWidth("-1px");
+ textFieldIssuer.setHeight("-1px");
+ textFieldIssuer.setNullSettingAllowed(true);
+ mainLayout.addComponent(textFieldIssuer);
+
+ // tableCategories
+ tableCategories = new Table();
+ tableCategories.setCaption("Category (Optional)");
+ tableCategories.setImmediate(false);
+ tableCategories.setWidth("100.0%");
+ tableCategories.setHeight("-1px");
+ mainLayout.addComponent(tableCategories);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save");
+ buttonSave.setImmediate(false);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/AttributeEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/AttributeEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/AttributeEditorWindow.java
new file mode 100644
index 0000000..62e9c1a
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/AttributeEditorWindow.java
@@ -0,0 +1,336 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.jpa.Attribute;
+import org.apache.openaz.xacml.admin.jpa.ConstraintType;
+import org.apache.openaz.xacml.admin.jpa.Datatype;
+import org.apache.openaz.xacml.admin.view.fields.ConstraintField;
+import org.apache.openaz.xacml.admin.view.fields.DesignatorSelectorField;
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.api.XACML3;
+import com.vaadin.addon.jpacontainer.EntityItem;
+import com.vaadin.addon.jpacontainer.fieldfactory.SingleSelectConverter;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.fieldgroup.FieldGroup;
+import com.vaadin.data.fieldgroup.FieldGroup.CommitException;
+import com.vaadin.data.fieldgroup.PropertyId;
+import com.vaadin.data.util.filter.Compare;
+import com.vaadin.data.util.filter.Not;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.shared.ui.combobox.FilteringMode;
+import com.vaadin.ui.AbstractSelect.ItemCaptionMode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.FormLayout;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.Window;
+
+public class AttributeEditorWindow extends Window {
+ private static final long serialVersionUID = 1L;
+ private static final Log logger = LogFactory.getLog(AttributeEditorWindow.class);
+ private AttributeEditorWindow self = this;
+
+ private boolean isSaved = false;
+ private Attribute attribute;
+
+ private FormLayout mainLayout = new FormLayout();
+
+ @PropertyId("isDesignator")
+ DesignatorSelectorField selectDesignator;
+
+ @PropertyId("selectorPath")
+ TextField selectorPath = new TextField("Attribute Selector Path");
+
+ @PropertyId("xacmlId")
+ TextField xacmlID = new TextField("XACML ID");
+
+ @PropertyId("categoryBean")
+ ComboBox category = new ComboBox("Category");
+
+ @PropertyId("description")
+ TextArea descriptionField = new TextArea("Description");
+
+ @PropertyId("datatypeBean")
+ ComboBox datatype = new ComboBox("DataType");
+
+ @PropertyId("constraintType")
+ ComboBox constraintTypes = new ComboBox("Constraint Type");
+
+ @PropertyId("constraintValues")
+ ConstraintField constraintValues;
+
+ Button saveButton = new Button("Save");
+
+ FieldGroup fieldGroup = null;
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public AttributeEditorWindow(EntityItem<Attribute> entityItem) {
+ //
+ // Save our attribute
+ //
+ this.attribute = entityItem.getEntity();
+ if (logger.isDebugEnabled()) {
+ logger.debug("Editing attribute: " + entityItem.getEntity().toString());
+ }
+ //
+ // Set our shortcuts
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ // Create our main layout
+ //
+ this.setContent(mainLayout);
+ //
+ // Finish setting up the main layout
+ //
+ this.mainLayout.setSpacing(true);
+ this.mainLayout.setMargin(true);
+ //
+ // Setup option group, binding the
+ // field group doesn't seem to work.
+ //
+ this.selectDesignator = new DesignatorSelectorField(entityItem);
+ this.selectDesignator.setCaption("Select the Attribute Type");
+ this.selectDesignator.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ Object value = self.selectDesignator.getValue();
+ if (value == null || ! (value instanceof Character)) {
+ self.selectorPath.setVisible(false);
+ }
+ if (((Character) value) == '1') {
+ self.selectorPath.setVisible(false);
+ } else {
+ self.selectorPath.setVisible(true);
+ }
+ }
+ });
+ //
+ // Setup selector path
+ //
+ this.selectorPath.setImmediate(true);
+ this.selectorPath.setNullRepresentation("");
+ this.selectorPath.setWidth("100%");
+ //
+ // Setup the Category combo
+ //
+ this.category.setContainerDataSource(((XacmlAdminUI) UI.getCurrent()).getCategories());
+ this.category.setItemCaptionMode(ItemCaptionMode.PROPERTY);
+ this.category.setItemCaptionPropertyId("xacmlId");
+ this.category.setFilteringMode(FilteringMode.CONTAINS);
+ this.category.setImmediate(true);
+ this.category.setNullSelectionAllowed(false);
+ this.category.setConverter(new SingleSelectConverter<Object>(this.category));
+ //
+ // Setup the Datatype combo
+ //
+ this.datatype.setContainerDataSource(((XacmlAdminUI) UI.getCurrent()).getDatatypes());
+ this.datatype.setItemCaptionMode(ItemCaptionMode.PROPERTY);
+ this.datatype.setItemCaptionPropertyId("xacmlId");
+ this.datatype.setFilteringMode(FilteringMode.CONTAINS);
+ this.datatype.setImmediate(true);
+ this.datatype.setNullSelectionAllowed(false);
+ this.datatype.setConverter(new SingleSelectConverter<Object>(this.datatype));
+ //
+ // Setup the constraint type combo
+ //
+ this.constraintTypes.setContainerDataSource(((XacmlAdminUI) UI.getCurrent()).getConstraintTypes());
+ this.constraintTypes.setItemCaptionMode(ItemCaptionMode.PROPERTY);
+ this.constraintTypes.setItemCaptionPropertyId("constraintType");
+ this.constraintTypes.setFilteringMode(FilteringMode.CONTAINS);
+ this.constraintTypes.setImmediate(true);
+ this.constraintTypes.setNullSelectionAllowed(true);
+ this.constraintTypes.setConverter(new SingleSelectConverter<Object>(this.constraintTypes));
+ //
+ // Setup the constraint value custom field
+ //
+ this.constraintValues = new ConstraintField(entityItem);
+ //
+ // Finish laying out the main layout
+ //
+ this.mainLayout.addComponent(this.selectDesignator);
+ this.mainLayout.addComponent(this.selectorPath);
+ this.mainLayout.addComponent(this.xacmlID);
+ this.mainLayout.addComponent(this.category);
+ this.mainLayout.addComponent(this.descriptionField);
+ this.mainLayout.addComponent(this.datatype);
+ this.mainLayout.addComponent(this.constraintTypes);
+ this.mainLayout.addComponent(this.constraintValues);
+ //
+ // Now create our field group and bind our bean items
+ // This will populate the components with the attribute's
+ // current value.
+ //
+ this.fieldGroup = new FieldGroup(entityItem);
+ this.fieldGroup.bindMemberFields(this);
+ //
+ // Finishing setting up after the bind. There are some components
+ // where initializing the bind causes some properties to be reset.
+ //
+ this.xacmlID.setWidth("100%");
+ this.descriptionField.setNullRepresentation("");
+ this.descriptionField.setWidth("100%");
+ this.setupDatatype(this.attribute.getDatatypeBean().getIdentifer());
+ this.datatype.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ Identifier id = self.getCurrentDatatype();
+ if (id != null) {
+ self.setupDatatype(id);
+ }
+ }
+ });
+ //
+ // Listen to when constraint type changes
+ //
+ this.constraintTypes.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ Object value = self.constraintTypes.getValue();
+ if (value == null) {
+ self.constraintValues.resetContent(null, self.getCurrentDatatype());
+ } else {
+ ConstraintType newValue = ((XacmlAdminUI) UI.getCurrent()).getConstraintTypes().getItem(value).getEntity();
+ self.constraintValues.resetContent(newValue, self.getCurrentDatatype());
+ }
+ }
+ });
+ //
+ // Setup our "SAVE" button to commit the fields
+ //
+ this.mainLayout.addComponent(this.saveButton);
+ this.mainLayout.setComponentAlignment(this.saveButton, Alignment.MIDDLE_CENTER);
+ this.saveButton.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ try {
+ //
+ // SAVE the latest values
+ //
+ fieldGroup.commit();
+ //
+ // Set that we did save the attribute
+ //
+ self.isSaved = true;
+ //
+ // Close the window
+ //
+ self.close();
+ } catch (CommitException e) {
+ logger.error("Failed to commit fields", e);
+ }
+ }
+
+ });
+ //
+ // Add our close listener so we can discard anything that was changed.
+ //
+ this.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ if (self.isSaved == false) {
+ logger.info("discarding");
+ //
+ // Discard any changes to the existing JPA container entity
+ //
+ self.fieldGroup.discard();
+ //
+ // Make sure there are no filters on the container
+ //
+ ((XacmlAdminUI) UI.getCurrent()).getConstraintTypes().removeAllContainerFilters();
+ }
+ }
+
+ });
+ //
+ // Set focus
+ //
+ this.xacmlID.focus();
+ }
+
+ private void setupDatatype(Identifier datatype) {
+ if (datatype.equals(XACML3.ID_DATATYPE_INTEGER) ||
+ datatype.equals(XACML3.ID_DATATYPE_DOUBLE)) {
+ ((XacmlAdminUI) UI.getCurrent()).getConstraintTypes().removeAllContainerFilters();
+ this.constraintTypes.setEnabled(true);
+ this.constraintValues.resetDatatype(datatype);
+ return;
+ }
+ if (datatype.equals(XACML3.ID_DATATYPE_STRING)) {
+ ((XacmlAdminUI) UI.getCurrent()).getConstraintTypes().addContainerFilter(new Not(new Compare.Equal("constraintType", ConstraintType.RANGE_TYPE)));
+ if (this.attribute.getConstraintType() != null &&
+ this.attribute.getConstraintType().getConstraintType() != null &&
+ this.attribute.getConstraintType().getConstraintType().equals(ConstraintType.RANGE_TYPE)) {
+ this.attribute.setConstraintType(null);
+ }
+ this.constraintValues.resetDatatype(datatype);
+ return;
+ }
+ //
+ // No constraint for all other datatypes
+ //
+ this.attribute.setConstraintType(null);
+ this.constraintTypes.select(null);
+ this.constraintTypes.setEnabled(false);
+ }
+
+ private Identifier getCurrentDatatype() {
+ Object id = self.datatype.getValue();
+ if (id != null) {
+ EntityItem<Datatype> dt = ((XacmlAdminUI) UI.getCurrent()).getDatatypes().getItem(id);
+ if (dt != null) {
+ return dt.getEntity().getIdentifer();
+ }
+ }
+ return null;
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/AttributeSelectionWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/AttributeSelectionWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/AttributeSelectionWindow.java
new file mode 100644
index 0000000..b1448bf
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/AttributeSelectionWindow.java
@@ -0,0 +1,396 @@
+/*
+ * 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.xacml.admin.view.windows;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeSelectorType;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.jpa.Attribute;
+import org.apache.openaz.xacml.admin.jpa.Datatype;
+import org.apache.openaz.xacml.admin.util.JPAUtils;
+import org.apache.openaz.xacml.admin.view.components.AttributeDictionarySelectorComponent;
+import org.apache.openaz.xacml.admin.view.components.AttributeSimpleCreatorComponent;
+import org.apache.openaz.xacml.admin.view.components.AttributeStandardSelectorComponent;
+import org.apache.openaz.xacml.admin.view.events.AttributeChangedEventListener;
+import org.apache.openaz.xacml.admin.view.events.AttributeChangedEventNotifier;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Buffered.SourceException;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.OptionGroup;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class AttributeSelectionWindow extends Window implements AttributeChangedEventListener {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSave;
+ @AutoGenerated
+ private HorizontalLayout horizontalLayoutAttribute;
+ @AutoGenerated
+ private HorizontalLayout horizontalLayout_1;
+ @AutoGenerated
+ private VerticalLayout verticalLayout_2;
+ @AutoGenerated
+ private CheckBox checkBoxMustBePresent;
+ @AutoGenerated
+ private TextField textFieldIssuer;
+ @AutoGenerated
+ private OptionGroup optionGroupAttribute;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static Log logger = LogFactory.getLog(AttributeSelectionWindow.class);
+ private final AttributeSelectionWindow self = this;
+ private final Datatype datatype;
+ private final Attribute defaultAttribute;
+ private AttributeChangedEventNotifier currentComponent = null;
+ private Attribute attribute = null;
+ private boolean isSaved = false;
+
+ public static final String ATTRIBUTE_OPTION_DICTIONARY = "Use Attribute From Dictionary";
+ public static final String ATTRIBUTE_OPTION_STANDARD = "Use A Standard Attribute";
+ public static final String ATTRIBUTE_OPTION_INPUT = "Input A New Attribute";
+ public static final String[] ATTRIBUTE_OPTIONS = new String[] {ATTRIBUTE_OPTION_DICTIONARY, ATTRIBUTE_OPTION_STANDARD, ATTRIBUTE_OPTION_INPUT};
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public AttributeSelectionWindow(Datatype datatype, Object defaultAttribute) {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Save data
+ //
+ this.datatype = datatype;
+ if (defaultAttribute == null) {
+ this.defaultAttribute = null;
+ } else {
+ //
+ // Given a default attribute
+ //
+ Attribute tempAttribute;
+ if (defaultAttribute instanceof AttributeDesignatorType) {
+ tempAttribute = JPAUtils.createAttribute((AttributeDesignatorType) defaultAttribute);
+ } else if (defaultAttribute instanceof AttributeSelectorType) {
+ tempAttribute = JPAUtils.createAttribute((AttributeSelectorType) defaultAttribute);
+ } else {
+ this.defaultAttribute = null;
+ throw new IllegalArgumentException("Selection window only works with designator or selector objects.");
+ }
+ //
+ // See if the attribute exists in our dictionary
+ //
+ Attribute dictionaryAttribute = JPAUtils.findAttribute(tempAttribute);
+ if (dictionaryAttribute != null) {
+ this.defaultAttribute = dictionaryAttribute;
+ } else {
+ this.defaultAttribute = tempAttribute;
+ }
+ }
+ //
+ // Close shortcut
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ // Initialize GUI
+ //
+ this.initializeOption();
+ this.initializeButtons();
+ this.initializeAttribute();
+ //
+ // Setup attribute
+ //
+ this.resetAttributeOption();
+ //
+ // Focus
+ //
+ }
+
+ protected void initializeOption() {
+ //
+ // Setup datasource and GUI properties
+ //
+ this.optionGroupAttribute.setImmediate(true);
+ this.optionGroupAttribute.addItem(ATTRIBUTE_OPTION_DICTIONARY);
+ this.optionGroupAttribute.addItem(ATTRIBUTE_OPTION_STANDARD);
+ this.optionGroupAttribute.addItem(ATTRIBUTE_OPTION_INPUT);
+ //
+ // Respond to events
+ //
+ this.optionGroupAttribute.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ self.resetAttributeOption();
+ }
+ });
+ }
+
+ protected void initializeButtons() {
+ this.buttonSave.setClickShortcut(KeyCode.ENTER);
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ try {
+ //
+ // Commit everything??
+ //
+ self.textFieldIssuer.commit();
+ self.checkBoxMustBePresent.commit();
+ self.currentComponent.commit();
+ //
+ // Save to the attribute
+ //
+ String issuer = self.textFieldIssuer.getValue();
+ if (issuer == null || issuer.length() == 0) {
+ self.attribute.setIssuer(null);
+ } else {
+ self.attribute.setIssuer(issuer);
+ }
+ self.attribute.setMustBePresent(self.checkBoxMustBePresent.getValue());
+ //
+ // Mark as saved
+ //
+ self.isSaved = true;
+ //
+ // Close the window
+ //
+ self.close();
+ } catch (SourceException | InvalidValueException e) { //NOPMD
+ //
+ // Vaadin displays the error
+ //
+ }
+ }
+ });
+ }
+
+ protected void initializeAttribute() {
+ //
+ // Are we editing something?
+ //
+ if (this.defaultAttribute == null) {
+ //
+ // No, this is a new attribute being created
+ //
+ this.optionGroupAttribute.select(ATTRIBUTE_OPTION_STANDARD);
+ return;
+ }
+ //
+ // Yes, is it in our dictionary?
+ //
+ Attribute attribute = JPAUtils.findAttribute(this.defaultAttribute);
+ if (attribute != null) {
+ //
+ // Yes its in our dictionary
+ //
+ this.attribute = attribute;
+ this.optionGroupAttribute.select(ATTRIBUTE_OPTION_DICTIONARY);
+ return;
+ }
+ //
+ // Is it a standard attribute?
+ //
+ attribute = JPAUtils.isStandardAttribute(this.defaultAttribute);
+ if (attribute == null) {
+ //
+ // No, start editing via custom input attribute
+ //
+ this.attribute = this.defaultAttribute;
+ this.optionGroupAttribute.select(ATTRIBUTE_OPTION_INPUT);
+ return;
+ }
+ //
+ // Yes - its a standard attribute
+ //
+ this.attribute = attribute;
+ this.optionGroupAttribute.select(ATTRIBUTE_OPTION_STANDARD);
+ }
+
+ protected void resetAttributeOption() {
+ //
+ // Remove GUI components from layout
+ //
+ this.horizontalLayoutAttribute.removeAllComponents();
+ this.currentComponent = null;
+ //
+ // Grab our currently selected option value
+ //
+ Object value = self.optionGroupAttribute.getValue();
+ //
+ // What is it set to?
+ //
+ if (value.toString().equals(ATTRIBUTE_OPTION_DICTIONARY)) {
+ this.currentComponent = new AttributeDictionarySelectorComponent(this.datatype, this.defaultAttribute);
+ } else if (value.toString().equals(ATTRIBUTE_OPTION_STANDARD)) {
+ this.currentComponent = new AttributeStandardSelectorComponent(this.datatype, this.defaultAttribute);
+ } else if (value.toString().equals(ATTRIBUTE_OPTION_INPUT)) {
+ this.currentComponent = new AttributeSimpleCreatorComponent(this.datatype, this.defaultAttribute);
+ } else {
+ logger.error("Unknown option" + value);
+ return;
+ }
+ this.currentComponent.addListener(this);
+ this.horizontalLayoutAttribute.addComponent((CustomComponent) this.currentComponent);
+ this.currentComponent.fireAttributeChanged(this.currentComponent.getAttribute());
+ }
+
+ @Override
+ public void attributeChanged(Attribute attribute) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("attributeChanged: " + attribute);
+ }
+ this.attribute = attribute;
+ if (attribute == null) {
+ this.buttonSave.setEnabled(false);
+ } else {
+ this.buttonSave.setEnabled(true);
+ }
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ public Attribute getAttribute() {
+ return this.attribute;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // horizontalLayout_1
+ horizontalLayout_1 = buildHorizontalLayout_1();
+ mainLayout.addComponent(horizontalLayout_1);
+
+ // horizontalLayoutAttribute
+ horizontalLayoutAttribute = new HorizontalLayout();
+ horizontalLayoutAttribute.setImmediate(false);
+ horizontalLayoutAttribute.setWidth("-1px");
+ horizontalLayoutAttribute.setHeight("-1px");
+ horizontalLayoutAttribute.setMargin(false);
+ mainLayout.addComponent(horizontalLayoutAttribute);
+ mainLayout.setExpandRatio(horizontalLayoutAttribute, 1.0f);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Select");
+ buttonSave.setImmediate(true);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
+
+ return mainLayout;
+ }
+
+ @AutoGenerated
+ private HorizontalLayout buildHorizontalLayout_1() {
+ // common part: create layout
+ horizontalLayout_1 = new HorizontalLayout();
+ horizontalLayout_1.setImmediate(false);
+ horizontalLayout_1.setWidth("-1px");
+ horizontalLayout_1.setHeight("-1px");
+ horizontalLayout_1.setMargin(false);
+
+ // optionGroupAttribute
+ optionGroupAttribute = new OptionGroup();
+ optionGroupAttribute.setCaption("Attribute Source");
+ optionGroupAttribute.setImmediate(false);
+ optionGroupAttribute.setWidth("-1px");
+ optionGroupAttribute.setHeight("-1px");
+ optionGroupAttribute.setInvalidAllowed(false);
+ horizontalLayout_1.addComponent(optionGroupAttribute);
+
+ // verticalLayout_2
+ verticalLayout_2 = buildVerticalLayout_2();
+ horizontalLayout_1.addComponent(verticalLayout_2);
+
+ return horizontalLayout_1;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildVerticalLayout_2() {
+ // common part: create layout
+ verticalLayout_2 = new VerticalLayout();
+ verticalLayout_2.setImmediate(false);
+ verticalLayout_2.setWidth("-1px");
+ verticalLayout_2.setHeight("-1px");
+ verticalLayout_2.setMargin(true);
+ verticalLayout_2.setSpacing(true);
+
+ // textFieldIssuer
+ textFieldIssuer = new TextField();
+ textFieldIssuer.setCaption("Issuer");
+ textFieldIssuer.setImmediate(false);
+ textFieldIssuer.setWidth("-1px");
+ textFieldIssuer.setHeight("-1px");
+ verticalLayout_2.addComponent(textFieldIssuer);
+
+ // checkBoxMustBePresent
+ checkBoxMustBePresent = new CheckBox();
+ checkBoxMustBePresent.setCaption("Attribute Must Be Present");
+ checkBoxMustBePresent.setImmediate(false);
+ checkBoxMustBePresent.setWidth("-1px");
+ checkBoxMustBePresent.setHeight("-1px");
+ verticalLayout_2.addComponent(checkBoxMustBePresent);
+
+ return verticalLayout_2;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/AttributeValueEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/AttributeValueEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/AttributeValueEditorWindow.java
new file mode 100644
index 0000000..13ae0b1
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/AttributeValueEditorWindow.java
@@ -0,0 +1,320 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.jpa.Datatype;
+import org.apache.openaz.xacml.admin.util.JPAUtils;
+import org.apache.openaz.xacml.admin.view.validators.ValidatorFactory;
+import com.vaadin.addon.jpacontainer.EntityItem;
+import com.vaadin.addon.jpacontainer.fieldfactory.SingleSelectConverter;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.Validator;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.shared.ui.combobox.FilteringMode;
+import com.vaadin.ui.AbstractSelect.ItemCaptionMode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class AttributeValueEditorWindow extends Window {
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSave;
+ @AutoGenerated
+ private TextField textFieldValue;
+ @AutoGenerated
+ private ComboBox comboBoxDatatype;
+ private static final long serialVersionUID = 1L;
+ private final AttributeValueEditorWindow self = this;
+ private final Datatype datatypeRestriction;
+ private final AttributeValueType value;
+ private boolean isSaved = false;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public AttributeValueEditorWindow(AttributeValueType value, Datatype datatypeRestriction) {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Save
+ //
+ this.value = value;
+ this.datatypeRestriction = datatypeRestriction;
+ //
+ // Make sure the value has the same datatype as the restriction
+ //
+ if (this.datatypeRestriction != null) {
+ this.value.setDataType(this.datatypeRestriction.getXacmlId());
+ }
+ //
+ // Set our shortcuts
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ // Initialize GUI
+ //
+ this.initializeCombo();
+ this.initializeTextField();
+ this.initializeButtons();
+ //
+ // Focus?
+ //
+ if (this.datatypeRestriction == null) {
+ this.comboBoxDatatype.focus();
+ } else {
+ this.textFieldValue.focus();
+ }
+ }
+
+ protected void initializeCombo() {
+ this.comboBoxDatatype.setContainerDataSource(((XacmlAdminUI) UI.getCurrent()).getDatatypes());
+ this.comboBoxDatatype.setItemCaptionMode(ItemCaptionMode.PROPERTY);
+ this.comboBoxDatatype.setItemCaptionPropertyId("xacmlId");
+ this.comboBoxDatatype.setFilteringMode(FilteringMode.CONTAINS);
+ this.comboBoxDatatype.setImmediate(true);
+ this.comboBoxDatatype.setNullSelectionAllowed(false);
+ this.comboBoxDatatype.setConverter(new SingleSelectConverter<Object>(this.comboBoxDatatype));
+ //
+ // Select a value if its defined
+ //
+ if (this.datatypeRestriction != null) {
+ this.comboBoxDatatype.select(this.datatypeRestriction.getId());
+ } else if (this.value.getDataType() != null) {
+ this.comboBoxDatatype.select(JPAUtils.findDatatype(this.value.getDataType()).getId());
+ }
+ //
+ // Can the user change the datatype?
+ //
+ if (this.datatypeRestriction != null) {
+ this.comboBoxDatatype.setEnabled(false);
+ return;
+ }
+ //
+ // Listen to events
+ //
+ this.comboBoxDatatype.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ Object id = self.comboBoxDatatype.getValue();
+ assert id != null;
+ //
+ // Get the entity and save it
+ //
+ EntityItem<Datatype> entity = ((XacmlAdminUI) UI.getCurrent()).getDatatypes().getItem(id);
+ self.value.setDataType(entity.getEntity().getXacmlId());
+ //
+ // Reset the validator
+ //
+ self.textFieldValue.removeAllValidators();
+ Validator validator = ValidatorFactory.newInstance(entity.getEntity());
+ if (validator != null) {
+ self.textFieldValue.addValidator(validator);
+ }
+ }
+ });
+ }
+
+ protected void initializeTextField() {
+ //
+ // GUI properties
+ //
+ this.textFieldValue.setImmediate(true);
+ this.textFieldValue.setNullRepresentation("");
+ //
+ // Setup validator
+ //
+ if (this.datatypeRestriction != null) {
+ Validator validator = ValidatorFactory.newInstance(this.datatypeRestriction);
+ if (validator != null) {
+ this.textFieldValue.addValidator(validator);
+ }
+ }
+ //
+ // Text change or Value Change?
+ //
+ this.textFieldValue.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ //
+ // Save the new value. TODO - assuming position 0 of content list.
+ //
+ self.saveValue(0, self.textFieldValue.getValue());
+ //
+ // Setup the save button
+ //
+ if (self.textFieldValue.getValue() == null || self.textFieldValue.getValue().isEmpty()) {
+ self.buttonSave.setEnabled(false);
+ } else {
+ self.buttonSave.setEnabled(true);
+ }
+ }
+ });
+ //
+ // Initialize the value
+ //
+ if (this.value != null && this.value.getContent().isEmpty() == false) {
+ //
+ // TODO - If there are multiple Content objects...Right now we work with the first one only.
+ //
+ this.textFieldValue.setValue(this.value.getContent().get(0).toString());
+ }
+ }
+
+ protected void saveValue(int i, String value) {
+ //
+ // Get the content - TODO
+ //
+ if (this.value.getContent().isEmpty()) {
+ this.value.getContent().add(value);
+ return;
+ }
+ Object o = this.value.getContent().get(i);
+ if (o == null) {
+ //
+ // Add it into the list - ensure its a
+ //
+ assert this.value.getContent().size() == i;
+ this.value.getContent().add(value);
+ } else {
+ //
+ // Overwrite the previous object
+ //
+ this.value.getContent().set(i, value);
+ }
+ }
+
+ protected void initializeButtons() {
+ this.buttonSave.setClickShortcut(KeyCode.ENTER);
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ try {
+ //
+ // Make sure it validates (i.e. call the Validators)
+ //
+ self.comboBoxDatatype.validate();
+ self.textFieldValue.validate();
+ //
+ // Yes
+ //
+ self.isSaved = true;
+ //
+ // Close
+ //
+ self.close();
+ } catch (InvalidValueException e) { //NOPMD
+ //
+ // Vaadin with update GUI displaying the error
+ //
+ }
+ }
+ });
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ public String getValue() {
+ return this.textFieldValue.getValue();
+ }
+
+ public AttributeValueType getAttribute() {
+ return this.value;
+ }
+
+ public Datatype getDatatype() {
+ return JPAUtils.findDatatype(this.value.getDataType());
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // comboBoxDatatype
+ comboBoxDatatype = new ComboBox();
+ comboBoxDatatype.setCaption("Select Datatype");
+ comboBoxDatatype.setImmediate(false);
+ comboBoxDatatype.setWidth("-1px");
+ comboBoxDatatype.setHeight("-1px");
+ comboBoxDatatype.setInvalidAllowed(false);
+ comboBoxDatatype.setRequired(true);
+ mainLayout.addComponent(comboBoxDatatype);
+
+ // textFieldValue
+ textFieldValue = new TextField();
+ textFieldValue.setCaption("Attribute Value");
+ textFieldValue.setImmediate(false);
+ textFieldValue.setWidth("100.0%");
+ textFieldValue.setHeight("-1px");
+ textFieldValue.setInvalidAllowed(false);
+ textFieldValue.setRequired(true);
+ mainLayout.addComponent(textFieldValue);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save");
+ buttonSave.setImmediate(true);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
+
+ return mainLayout;
+ }
+
+}
[23/23] incubator-openaz git commit: Ported original att source to
openaz
Posted by pd...@apache.org.
Ported original att source to openaz
Project: http://git-wip-us.apache.org/repos/asf/incubator-openaz/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-openaz/commit/a1d93100
Tree: http://git-wip-us.apache.org/repos/asf/incubator-openaz/tree/a1d93100
Diff: http://git-wip-us.apache.org/repos/asf/incubator-openaz/diff/a1d93100
Branch: refs/heads/master
Commit: a1d9310097fcde4f4c5e9a7980e0916cb62a5335
Parents: 54d66c1
Author: Basic <ba...@localhost>
Authored: Wed Jan 13 23:47:49 2016 -0700
Committer: Pamela Dragosh <pd...@apache.org>
Committed: Wed Mar 16 21:03:20 2016 -0400
----------------------------------------------------------------------
openaz-xacml-pap-admin/pom.xml | 280 +++
openaz-xacml-pap-admin/src/META-INF/data.sql | 723 ++++++
openaz-xacml-pap-admin/src/META-INF/drop.sql | 21 +
openaz-xacml-pap-admin/src/META-INF/empty.sql | 0
.../src/META-INF/persistence.xml | 55 +
openaz-xacml-pap-admin/src/META-INF/views.sql | 6 +
.../xacml/admin/PAPNotificationBroadcaster.java | 120 +
.../xacml/admin/XacmlAdminAuthorization.java | 178 ++
.../openaz/xacml/admin/XacmlAdminConsole.java | 253 +++
.../openaz/xacml/admin/XacmlAdminServlet.java | 97 +
.../apache/openaz/xacml/admin/XacmlAdminUI.java | 801 +++++++
.../openaz/xacml/admin/XacmlErrorHandler.java | 106 +
.../xacml/admin/XacmlJDBCConnectionPool.java | 239 ++
.../admin/components/AttributeDictionary.java | 503 +++++
.../admin/components/ObadviceDictionary.java | 347 +++
.../xacml/admin/components/PDPManagement.java | 862 +++++++
.../xacml/admin/components/PIPManagement.java | 538 +++++
.../xacml/admin/components/PolicyEditor.java | 1679 ++++++++++++++
.../xacml/admin/components/PolicyWorkspace.java | 1640 ++++++++++++++
.../xacml/admin/components/Simulator.java | 69 +
.../xacml/admin/components/UserManagement.java | 114 +
.../xacml/admin/components/package-info.java | 28 +
.../admin/converters/CategoryConverter.java | 71 +
.../converters/ConstraintTypeConverter.java | 79 +
.../converters/ConstraintValueConverter.java | 73 +
.../admin/converters/DatatypeConverter.java | 76 +
.../admin/converters/IdentifierConverter.java | 61 +
.../admin/converters/XacmlConverterFactory.java | 83 +
.../openaz/xacml/admin/jpa/Attribute.java | 327 +++
.../xacml/admin/jpa/AttributeAssignment.java | 94 +
.../apache/openaz/xacml/admin/jpa/Category.java | 216 ++
.../openaz/xacml/admin/jpa/ConstraintType.java | 117 +
.../openaz/xacml/admin/jpa/ConstraintValue.java | 116 +
.../apache/openaz/xacml/admin/jpa/Datatype.java | 230 ++
.../xacml/admin/jpa/FunctionArgument.java | 122 +
.../xacml/admin/jpa/FunctionDefinition.java | 217 ++
.../apache/openaz/xacml/admin/jpa/Obadvice.java | 227 ++
.../xacml/admin/jpa/ObadviceExpression.java | 124 ++
.../openaz/xacml/admin/jpa/PIPConfigParam.java | 147 ++
.../xacml/admin/jpa/PIPConfiguration.java | 554 +++++
.../openaz/xacml/admin/jpa/PIPResolver.java | 362 +++
.../xacml/admin/jpa/PIPResolverParam.java | 147 ++
.../apache/openaz/xacml/admin/jpa/PIPType.java | 131 ++
.../xacml/admin/jpa/PolicyAlgorithms.java | 116 +
.../openaz/xacml/admin/jpa/RuleAlgorithms.java | 115 +
.../openaz/xacml/admin/jpa/package-info.java | 28 +
.../xacml/admin/model/AttributeContainer.java | 500 +++++
.../admin/model/AttributeValueContainer.java | 300 +++
.../xacml/admin/model/ExpressionContainer.java | 1215 ++++++++++
.../admin/model/GitRepositoryContainer.java | 1210 ++++++++++
.../xacml/admin/model/GitStatusContainer.java | 552 +++++
.../admin/model/ItemSetChangeNotifier.java | 118 +
.../admin/model/MatchFunctionQueryDelegate.java | 143 ++
.../admin/model/ObligationAdviceContainer.java | 1385 ++++++++++++
.../openaz/xacml/admin/model/PDPContainer.java | 488 ++++
.../xacml/admin/model/PDPGroupContainer.java | 672 ++++++
.../xacml/admin/model/PDPPIPContainer.java | 457 ++++
.../xacml/admin/model/PDPPolicyContainer.java | 469 ++++
.../xacml/admin/model/PolicyContainer.java | 2096 ++++++++++++++++++
.../xacml/admin/util/AdminNotification.java | 56 +
.../openaz/xacml/admin/util/JPAUtils.java | 406 ++++
.../admin/util/OnDemandFileDownloader.java | 65 +
.../xacml/admin/util/RESTfulPAPEngine.java | 495 +++++
.../openaz/xacml/admin/util/XACMLConstants.java | 237 ++
.../admin/util/XACMLFunctionValidator.java | 506 +++++
.../xacml/admin/util/XACMLPolicyImporter.java | 495 +++++
.../AttributeDictionarySelectorComponent.java | 290 +++
.../AttributeSimpleCreatorComponent.java | 372 ++++
.../AttributeStandardSelectorComponent.java | 414 ++++
.../CSVPIPConfigurationComponent.java | 385 ++++
.../CustomPIPConfigurationComponent.java | 200 ++
.../components/EnumerationEditorComponent.java | 386 ++++
.../HyperCSVPIPConfigurationComponent.java | 339 +++
.../LDAPPIPConfigurationComponent.java | 644 ++++++
.../OaExpressionsEditorComponent.java | 186 ++
.../view/components/PIPParameterComponent.java | 453 ++++
.../view/components/PIPResolverComponent.java | 275 +++
.../view/components/RangeEditorComponent.java | 599 +++++
.../view/components/RegexpEditorComponent.java | 246 ++
.../SQLPIPConfigurationComponent.java | 763 +++++++
.../events/ApplyParametersChangedListener.java | 31 +
.../events/ApplyParametersChangedNotifier.java | 69 +
.../events/AttributeChangedEventListener.java | 27 +
.../events/AttributeChangedEventNotifier.java | 78 +
.../view/events/FormChangedEventListener.java | 25 +
.../view/events/FormChangedEventNotifier.java | 61 +
.../admin/view/fields/ConfigParamField.java | 158 ++
.../admin/view/fields/ConstraintField.java | 111 +
.../view/fields/DesignatorSelectorField.java | 74 +
.../admin/view/fields/ExpressionField.java | 47 +
.../admin/view/fields/OaExpressionsField.java | 51 +
.../admin/view/fields/ResolverParamField.java | 123 +
.../admin/view/validators/AnyURIValidator.java | 45 +
.../view/validators/Base64BinaryValidator.java | 56 +
.../admin/view/validators/BooleanValidator.java | 45 +
.../admin/view/validators/DNSNameValidator.java | 45 +
.../view/validators/DateTimeValidator.java | 45 +
.../admin/view/validators/DateValidator.java | 45 +
.../validators/DayTimeDurationValidator.java | 45 +
.../admin/view/validators/DoubleValidator.java | 43 +
.../view/validators/HexBinaryValidator.java | 45 +
.../admin/view/validators/IntegerValidator.java | 42 +
.../view/validators/IpAddressValidator.java | 45 +
.../view/validators/RFC822NameValidator.java | 45 +
.../admin/view/validators/StringValidator.java | 38 +
.../admin/view/validators/TimeValidator.java | 45 +
.../admin/view/validators/ValidatorFactory.java | 71 +
.../view/validators/X500NameValidator.java | 44 +
.../validators/YearMonthDurationValidator.java | 45 +
.../admin/view/windows/AdviceEditorWindow.java | 208 ++
.../admin/view/windows/ApplyEditorWindow.java | 600 +++++
...tributeAssignmentExpressionEditorWindow.java | 228 ++
.../view/windows/AttributeEditorWindow.java | 336 +++
.../view/windows/AttributeSelectionWindow.java | 396 ++++
.../windows/AttributeValueEditorWindow.java | 320 +++
.../view/windows/ColumnSelectionWindow.java | 192 ++
.../admin/view/windows/EditPDPGroupWindow.java | 521 +++++
.../xacml/admin/view/windows/EditPDPWindow.java | 309 +++
.../windows/ExpressionBuilderComponent.java | 1078 +++++++++
.../view/windows/ExpressionEditorWindow.java | 90 +
.../view/windows/ExpressionSelectionWindow.java | 170 ++
.../view/windows/FunctionSelectionWindow.java | 314 +++
.../admin/view/windows/GitConflictResolver.java | 67 +
.../xacml/admin/view/windows/GitPushWindow.java | 356 +++
.../view/windows/GitSynchronizeWindow.java | 158 ++
.../admin/view/windows/MatchEditorWindow.java | 304 +++
.../view/windows/ObadviceEditorWindow.java | 184 ++
.../windows/ObligationAdviceEditorWindow.java | 817 +++++++
.../view/windows/ObligationEditorWindow.java | 208 ++
.../admin/view/windows/PDPStatusWindow.java | 264 +++
.../windows/PIPConfigurationEditorWindow.java | 364 +++
.../windows/PIPCustomResolverEditorWindow.java | 65 +
.../admin/view/windows/PIPImportWindow.java | 116 +
.../view/windows/PIPParamEditorWindow.java | 261 +++
.../view/windows/PIPResolverEditorWindow.java | 226 ++
.../windows/PIPSQLResolverEditorWindow.java | 1199 ++++++++++
.../admin/view/windows/PolicyEditorWindow.java | 252 +++
.../view/windows/PolicyNameEditorWindow.java | 369 +++
.../view/windows/PolicySetEditorWindow.java | 252 +++
.../admin/view/windows/PolicyUploadWindow.java | 238 ++
.../view/windows/RenamePolicyFileWindow.java | 147 ++
.../admin/view/windows/RuleEditorWindow.java | 219 ++
.../view/windows/SelectPDPGroupWindow.java | 207 ++
.../windows/SelectPIPConfigurationWindow.java | 217 ++
.../windows/SelectWorkspacePoliciesWindow.java | 331 +++
.../view/windows/SubDomainEditorWindow.java | 204 ++
.../windows/VariableDefinitionEditorWindow.java | 202 ++
.../windows/VariableReferenceEditorWindow.java | 242 ++
.../src/main/resources/META-INF/data.sql | 723 ++++++
.../src/main/resources/META-INF/drop.sql | 21 +
.../src/main/resources/META-INF/empty.sql | 0
.../src/main/resources/META-INF/persistence.xml | 55 +
.../src/main/resources/META-INF/views.sql | 6 +
.../VAADIN/themes/xacml_pap_admin/addons.scss | 7 +
.../VAADIN/themes/xacml_pap_admin/favicon.ico | Bin 0 -> 1406 bytes
.../xacml_pap_admin/icons/MenuSeparator.png | Bin 0 -> 3261 bytes
.../VAADIN/themes/xacml_pap_admin/icons/add.png | Bin 0 -> 217 bytes
.../themes/xacml_pap_admin/icons/advice-16.png | Bin 0 -> 696 bytes
.../themes/xacml_pap_admin/icons/advice-32.png | Bin 0 -> 5065 bytes
.../icons/att_approval_icon_blu_rgb.png | Bin 0 -> 16959 bytes
.../icons/att_approval_icon_dkblu_rgb.png | Bin 0 -> 16830 bytes
.../icons/att_approval_icon_grn_rgb.png | Bin 0 -> 17524 bytes
.../icons/att_approval_icon_mag_rgb.png | Bin 0 -> 17107 bytes
.../icons/att_approval_icon_org_rgb.png | Bin 0 -> 14923 bytes
.../icons/att_lock_icon_blu_rgb.png | Bin 0 -> 9361 bytes
.../icons/att_lock_icon_dkblu_rgb.png | Bin 0 -> 735663 bytes
.../icons/att_lock_icon_grn_rgb.png | Bin 0 -> 9964 bytes
.../icons/att_lock_icon_mag_rgb.png | Bin 0 -> 9780 bytes
.../icons/att_lock_icon_org_rgb.png | Bin 0 -> 9294 bytes
.../icons/att_protect_icon_blu_rgb.png | Bin 0 -> 19179 bytes
.../icons/att_protect_icon_dkblu_rgb.png | Bin 0 -> 18661 bytes
.../icons/att_protect_icon_grn_rgb.png | Bin 0 -> 19548 bytes
.../icons/att_protect_icon_mag_rgb.png | Bin 0 -> 16935 bytes
.../icons/att_protect_icon_org_rgb.png | Bin 0 -> 15730 bytes
.../icons/att_support_icon_blu_rgb.png | Bin 0 -> 16936 bytes
.../icons/att_support_icon_dkblu_rgb.png | Bin 0 -> 17075 bytes
.../icons/att_support_icon_grn_rgb.png | Bin 0 -> 16836 bytes
.../icons/att_support_icon_mag_rgb.png | Bin 0 -> 12441 bytes
.../icons/att_support_icon_org_rgb.png | Bin 0 -> 16285 bytes
.../themes/xacml_pap_admin/icons/combine.png | Bin 0 -> 412 bytes
.../xacml_pap_admin/icons/condition-16.png | Bin 0 -> 3441 bytes
.../xacml_pap_admin/icons/condition-32.png | Bin 0 -> 998 bytes
.../themes/xacml_pap_admin/icons/deny-16.png | Bin 0 -> 829 bytes
.../themes/xacml_pap_admin/icons/deny-32.png | Bin 0 -> 2244 bytes
.../VAADIN/themes/xacml_pap_admin/icons/key.png | Bin 0 -> 624 bytes
.../themes/xacml_pap_admin/icons/link.png | Bin 0 -> 742 bytes
.../xacml_pap_admin/icons/obligation-16.png | Bin 0 -> 3406 bytes
.../xacml_pap_admin/icons/obligation-32.png | Bin 0 -> 4332 bytes
.../themes/xacml_pap_admin/icons/permit-16.png | Bin 0 -> 682 bytes
.../themes/xacml_pap_admin/icons/permit-32.png | Bin 0 -> 1757 bytes
.../themes/xacml_pap_admin/icons/policy.png | Bin 0 -> 406 bytes
.../themes/xacml_pap_admin/icons/policyset.png | Bin 0 -> 540 bytes
.../themes/xacml_pap_admin/icons/refresh.png | Bin 0 -> 1001 bytes
.../themes/xacml_pap_admin/icons/remove.png | Bin 0 -> 3311 bytes
.../themes/xacml_pap_admin/icons/rule.png | Bin 0 -> 578 bytes
.../xacml_pap_admin/icons/target-green-16.png | Bin 0 -> 3628 bytes
.../xacml_pap_admin/icons/target-green-32.png | Bin 0 -> 5778 bytes
.../themes/xacml_pap_admin/icons/target.png | Bin 0 -> 727 bytes
.../xacml_pap_admin/icons/variable-16.png | Bin 0 -> 574 bytes
.../xacml_pap_admin/icons/variable-32.png | Bin 0 -> 1098 bytes
.../VAADIN/themes/xacml_pap_admin/img/att.png | Bin 0 -> 8144 bytes
.../img/att_globe_rgb_grd_pos.png | Bin 0 -> 41871 bytes
.../VAADIN/themes/xacml_pap_admin/styles.scss | 9 +
.../themes/xacml_pap_admin/xacml_pap_admin.scss | 42 +
.../src/main/resources/log4j.properties | 13 +
.../src/main/webapp/WEB-INF/web.xml | 63 +
206 files changed, 44723 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/pom.xml
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/pom.xml b/openaz-xacml-pap-admin/pom.xml
index b027045..c494f77 100644
--- a/openaz-xacml-pap-admin/pom.xml
+++ b/openaz-xacml-pap-admin/pom.xml
@@ -23,4 +23,284 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>openaz-xacml-pap-admin</artifactId>
+ <packaging>war</packaging>
+
+ <repositories>
+ <repository>
+ <id>vaadin-addons</id>
+ <url>http://maven.vaadin.com/vaadin-addons</url>
+ </repository>
+ <repository>
+ <id>vaadin-snapshots</id>
+ <url>http://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
+ <!--
+ <pluginRepositories>
+ <pluginRepository>
+ <id>vaadin-snapshots</id>
+ <url>http://oss.sonatype.org/content/repositories/vaadin-snapshots/</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+ -->
+
+ <properties>
+ <vaadin.version>7.1.11</vaadin.version>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openaz</groupId>
+ <artifactId>openaz-xacml</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openaz</groupId>
+ <artifactId>openaz-xacml-pdp</artifactId>
+ </dependency>
+
+
+ <!-- The core server part of Vaadin -->
+ <dependency>
+ <groupId>com.vaadin</groupId>
+ <artifactId>vaadin-server</artifactId>
+ <version>${vaadin.version}</version>
+ </dependency>
+
+ <!-- Vaadin themes -->
+ <dependency>
+ <groupId>com.vaadin</groupId>
+ <artifactId>vaadin-themes</artifactId>
+ <version>${vaadin.version}</version>
+ </dependency>
+
+ <!-- Push support -->
+ <dependency>
+ <groupId>com.vaadin</groupId>
+ <artifactId>vaadin-push</artifactId>
+ <version>${vaadin.version}</version>
+ </dependency>
+
+ <!--
+ Use the appropriate javax.servlet version for your
+ version of Jetty and other considerations.
+
+ Jetty 6 - Servlet API 2.4
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope>
+ </dependency>
+
+ Jetty 7 - Servlet API 2.5 / Standard Location
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.5</version>
+ <scope>provided</scope>
+ </dependency>
+
+ Jetty 7 - Servlet API 2.5 / OSGi bundle ready
+
+ <dependency>
+ <groupId>org.eclipse.jetty.orbit</groupId>
+ <artifactId>javax.servlet</artifactId>
+ <version>2.5.0.v201103041518</version>
+ <scope>provided</scope>
+ </dependency>
+
+ Jetty 8 - Servlet API 3.0 / Standard Location / OSGi bundle ready
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.0.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ Jetty 9 - Servlet API 3.1 / Standard Location / OSGi bundle ready
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.1.0</version>
+ <scope>provided</scope>
+ </dependency>
+ -->
+
+ <!-- Jetty 8 - Servlet API 3.0 / Standard Location / OSGi bundle ready -->
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.0.1</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Precompiled DefaultWidgetSet -->
+ <dependency>
+ <groupId>com.vaadin</groupId>
+ <artifactId>vaadin-client-compiled</artifactId>
+ <version>${vaadin.version}</version>
+ </dependency>
+
+ <!-- Vaadin client side, needed for widget set compilation -->
+ <dependency>
+ <groupId>com.vaadin</groupId>
+ <artifactId>vaadin-client</artifactId>
+ <scope>provided</scope>
+ <version>${vaadin.version}</version>
+ </dependency>
+
+ <!-- Compiler for custom widget sets. Should not be deployed -->
+ <dependency>
+ <groupId>com.vaadin</groupId>
+ <artifactId>vaadin-client-compiler</artifactId>
+ <scope>provided</scope>
+ <version>${vaadin.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.vaadin.addon</groupId>
+ <artifactId>jpacontainer</artifactId>
+ <version>3.1.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.vaadin.addon</groupId>
+ <artifactId>confirmdialog</artifactId>
+ <version>2.0.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.openaz</groupId>
+ <artifactId>openaz-xacml</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openaz</groupId>
+ <artifactId>openaz-xacml-rest</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <version>1.2.17</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.3</version>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-continuation</artifactId>
+ <version>9.0.0.v20130308</version>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>apache-log4j-extras</artifactId>
+ <version>1.2.17</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-compress</artifactId>
+ <version>1.8</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>2.3.0-rc1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>14.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jgit</groupId>
+ <artifactId>org.eclipse.jgit</artifactId>
+ <version>3.2.0.201312181205-r</version>
+ </dependency>
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>1.3.174</version>
+ </dependency>
+ <dependency>
+ <groupId>mysql</groupId>
+ <artifactId>mysql-connector-java</artifactId>
+ <version>5.1.30</version>
+ </dependency>
+ <dependency>
+ <groupId>postgresql</groupId>
+ <artifactId>postgresql</artifactId>
+ <version>9.1-901.jdbc4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>2.3.2</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>eclipselink</artifactId>
+ <version>2.5.2</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <configuration>
+ <webXml>src\main\webapp\WEB-INF\web.xml</webXml>
+ <resource>
+ <directory>src/META-INF</directory>
+ <targetPath>META-INF</targetPath>
+ <includes>
+ <include>persistence.xml</include>
+ <include>data.sql</include>
+ <include>drop.sql</include>
+ <include>empty.sql</include>
+ <include>views.sql</include>
+ </includes>
+ </resource>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
</project>
[06/23] incubator-openaz git commit: Ported original att source to
openaz
Posted by pd...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ColumnSelectionWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ColumnSelectionWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ColumnSelectionWindow.java
new file mode 100644
index 0000000..b961a78
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ColumnSelectionWindow.java
@@ -0,0 +1,192 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Buffered.SourceException;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.data.validator.IntegerRangeValidator;
+import com.vaadin.event.FieldEvents.TextChangeEvent;
+import com.vaadin.event.FieldEvents.TextChangeListener;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+// import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class ColumnSelectionWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSave;
+ @AutoGenerated
+ private TextField textFieldColumn;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private boolean isSaved = false;
+ private ColumnSelectionWindow self = this;
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public ColumnSelectionWindow(Integer value) {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Initialize
+ //
+ this.initialize();
+ //
+ // Set the value
+ //
+ if (value != null) {
+ this.textFieldColumn.setValue(value.toString());
+ } else {
+ this.textFieldColumn.setValue(Integer.toString(0));
+ }
+ //
+ // Shortcuts
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ this.buttonSave.setClickShortcut(KeyCode.ENTER);
+ //
+ // Focus
+ //
+ this.textFieldColumn.focus();
+ }
+
+ protected void initialize() {
+ this.initializeText();
+ this.initializeButton();
+ }
+
+ protected void initializeText() {
+ //
+ // Add a validator
+ //
+ this.textFieldColumn.addValidator(new IntegerRangeValidator("Please enter an integer greater than or equal to 0.", 0, null));
+ //
+ // Respond to text changing to setup the button
+ //
+ this.textFieldColumn.addTextChangeListener(new TextChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void textChange(TextChangeEvent event) {
+ if (event.getText() != null && event.getText().isEmpty() == false) {
+ self.buttonSave.setEnabled(true);
+ } else {
+ self.buttonSave.setEnabled(false);
+ }
+ }
+ });
+ }
+
+ protected void initializeButton() {
+ self.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ try {
+ //
+ // Commit
+ //
+ self.textFieldColumn.commit();
+ //
+ // If we get here, the value is valid.
+ // Mark ourselves as saved and close the window
+ //
+ self.isSaved = true;
+ self.close();
+ } catch (SourceException | InvalidValueException e) { //NOPMD
+ //
+ // Vaadin will display error
+ //
+ }
+ }
+ });
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ public Integer getColumn() {
+ try {
+ return Integer.parseInt(this.textFieldColumn.getValue());
+ } catch (NumberFormatException e) {
+ return null;
+ }
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // textFieldColumn
+ textFieldColumn = new TextField();
+ textFieldColumn.setCaption("Column");
+ textFieldColumn.setImmediate(false);
+ textFieldColumn.setDescription("0-based index into CSV line");
+ textFieldColumn.setWidth("-1px");
+ textFieldColumn.setHeight("-1px");
+ textFieldColumn.setRequired(true);
+ textFieldColumn.setInputPrompt("Eg. ‘0'");
+ mainLayout.addComponent(textFieldColumn);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save");
+ buttonSave.setImmediate(false);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/EditPDPGroupWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/EditPDPGroupWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/EditPDPGroupWindow.java
new file mode 100644
index 0000000..468634c
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/EditPDPGroupWindow.java
@@ -0,0 +1,521 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.openaz.xacml.admin.model.PDPPIPContainer;
+import org.apache.openaz.xacml.admin.model.PDPPolicyContainer;
+import org.apache.openaz.xacml.admin.util.AdminNotification;
+import org.apache.openaz.xacml.api.pap.PAPEngine;
+import org.apache.openaz.xacml.api.pap.PAPException;
+import org.apache.openaz.xacml.api.pap.PDPGroup;
+import org.apache.openaz.xacml.api.pap.PDPPIPConfig;
+import org.apache.openaz.xacml.api.pap.PDPPolicy;
+import org.apache.openaz.xacml.std.pap.StdPDPGroup;
+import org.apache.openaz.xacml.std.pap.StdPDPPolicy;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Validator;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.event.Action;
+import com.vaadin.event.Action.Handler;
+import com.vaadin.event.FieldEvents.TextChangeEvent;
+import com.vaadin.event.FieldEvents.TextChangeListener;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class EditPDPGroupWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSave;
+ @AutoGenerated
+ private Table tablePIP;
+ @AutoGenerated
+ private Table tablePolicies;
+ @AutoGenerated
+ private TextArea textDescription;
+ @AutoGenerated
+ private TextField textName;
+
+
+ private static final Action ADD_POLICY = new Action ("Add New Policy");
+ private static final Action REMOVE_POLICY = new Action ("Remove Policy");
+ private static final Action MAKE_ROOT = new Action ("Make Root");
+ private static final Action MAKE_REFERENCED = new Action ("Make Referenced");
+
+ private static final Action EDIT_CONFIG = new Action("Edit Configurations");
+
+ //
+ // ?? Why is this static?
+ //
+ private static PDPPolicyContainer policyContainer;
+ private PDPPIPContainer pipContainer;
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private final EditPDPGroupWindow self = this;
+ private final StdPDPGroup group;
+ private boolean isSaved = false;
+
+ // this is the version that contains all of the edits made by the user.
+ // it may be a copy of the original object (edited) or a new one.
+ private StdPDPGroup updatedObject;
+
+ private PAPEngine papEngine;
+ private List<PDPGroup> groups;
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public EditPDPGroupWindow(StdPDPGroup group, List<PDPGroup> list, PAPEngine engine) {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Save pointers
+ //
+ this.group = group;
+ this.groups = list;
+ this.papEngine = engine;
+ //
+ // Initialize
+ //
+ this.initialize();
+ //
+ // Shortcuts
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ this.buttonSave.setClickShortcut(KeyCode.ENTER);
+ //
+ // Focus
+ //
+ this.textName.focus();
+ }
+
+ protected void initialize() {
+ this.initializeText();
+ this.initializeButton();
+ this.initializeTables();
+ }
+
+ protected void initializeText() {
+ this.textName.setNullRepresentation("");
+ this.textDescription.setNullRepresentation("");
+ if (this.group != null) {
+ this.textName.setValue(this.group.getName());
+ this.textDescription.setValue(this.group.getDescription());
+ }
+ //
+ // Validation
+ //
+ this.textName.addValidator(new Validator() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void validate(Object value) throws InvalidValueException {
+ assert value instanceof String;
+ if (value == null) {
+ throw new InvalidValueException("The name cannot be blank.");
+ }
+ // Group names must be unique so that user can distinguish between them (and we can create unique IDs from them)
+ for (PDPGroup g : self.groups) {
+ if (group != null && g.getId().equals(group.getId())) {
+ // ignore this group - we may or may not be changing the name
+ continue;
+ }
+ if (g.getName().equals(value.toString())) {
+ throw new InvalidValueException("Name must be unique");
+ }
+ }
+ }
+ });
+ this.textName.addTextChangeListener(new TextChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void textChange(TextChangeEvent event) {
+ if (event.getText() == null || event.getText().isEmpty()) {
+ self.buttonSave.setEnabled(false);
+ } else {
+ self.buttonSave.setEnabled(true);
+ }
+ }
+ });
+ }
+
+ protected void initializeTables() {
+ this.initializePolicyTable();
+ this.initializePIPTable();
+ }
+
+ protected void initializePolicyTable() {
+ if (this.group == null) {
+ this.tablePolicies.setVisible(false);
+ return;
+ }
+ //
+ // GUI properties
+ //
+ EditPDPGroupWindow.policyContainer = new PDPPolicyContainer(group);
+ this.tablePolicies.setContainerDataSource(EditPDPGroupWindow.policyContainer);
+ this.tablePolicies.setVisibleColumns("Root", "Name", "Version", "Id");//, "Description");
+ this.tablePolicies.setPageLength(EditPDPGroupWindow.policyContainer.size() + 1);
+ this.tablePolicies.setSelectable(true);
+ this.tablePolicies.setSizeFull();
+ /*
+ * Not in this release.
+ *
+ this.tablePolicies.setColumnCollapsingAllowed(true);
+ this.tablePolicies.setColumnCollapsed("Description", true);
+ //
+ // Generated columns
+ //
+ this.tablePolicies.addGeneratedColumn("Description", new ColumnGenerator() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Object generateCell(Table source, Object itemId, Object columnId) {
+ TextArea area = new TextArea();
+ if (itemId != null && itemId instanceof PDPPolicy) {
+ area.setValue(((PDPPolicy)itemId).getDescription());
+ }
+ area.setNullRepresentation("");
+ area.setWidth("100.0%");
+ return area;
+ }
+ });
+ */
+ //
+ // Actions
+ //
+ this.tablePolicies.addActionHandler(new Handler() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Action[] getActions(Object target, Object sender) {
+ if (target == null) {
+ return new Action[] {ADD_POLICY};
+ }
+ return new Action[] {ADD_POLICY, REMOVE_POLICY, MAKE_ROOT, MAKE_REFERENCED};
+ }
+
+ @Override
+ public void handleAction(Action action, Object sender, Object target) {
+ if (action == ADD_POLICY) {
+
+ final SelectWorkspacePoliciesWindow policiesWindow = new SelectWorkspacePoliciesWindow();
+ policiesWindow.setCaption("Select Policy to Add");
+ policiesWindow.setModal(true);
+ policiesWindow.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent event) {
+ //
+ // Did the user hit save?
+ //
+ if (policiesWindow.isSaved() == false) {
+ return;
+ }
+ //
+ // Get the selected policy
+ //
+ StdPDPPolicy selectedPolicy = policiesWindow.getSelectedPolicy();
+ if (selectedPolicy != null) {
+
+ // do not allow multiple copies of same policy
+ for (Object existingPolicy : EditPDPGroupWindow.policyContainer.getItemIds()) {
+ if (selectedPolicy.getId().equals(((PDPPolicy)existingPolicy).getId())) {
+ AdminNotification.warn("Cannot re-add Policy with the same ID (i.e. same Name, source Sub-Domain and Version)");
+ return;
+ }
+ }
+ // copy policy to PAP
+ try {
+ papEngine.copyPolicy(selectedPolicy, self.group);
+ } catch (PAPException e) {
+ AdminNotification.warn("Unable to copy Policy '" + selectedPolicy.getPolicyId() + "' to PAP: " + e.getMessage());
+ return;
+ }
+
+ // add Policy to group
+ EditPDPGroupWindow.policyContainer.addItem(selectedPolicy);
+ self.markAsDirtyRecursive();
+ }
+ }
+ });
+ policiesWindow.center();
+ UI.getCurrent().addWindow(policiesWindow);
+ return;
+ }
+ if (action == REMOVE_POLICY) {
+ assert target != null;
+ PDPPolicy policy = (PDPPolicy)target;
+ EditPDPGroupWindow.policyContainer.removeItem(policy);
+ self.markAsDirtyRecursive();
+ return;
+ }
+ if (action == MAKE_ROOT) {
+ assert target != null;
+ assert target instanceof StdPDPPolicy;
+ StdPDPPolicy policy = (StdPDPPolicy)target;
+ EditPDPGroupWindow.policyContainer.getItem(policy).getItemProperty("Root").setValue(true);
+ self.markAsDirtyRecursive();
+ return;
+ }
+ if (action == MAKE_REFERENCED) {
+ assert target != null;
+ assert target instanceof StdPDPPolicy;
+ StdPDPPolicy policy = (StdPDPPolicy)target;
+ EditPDPGroupWindow.policyContainer.getItem(policy).getItemProperty("Root").setValue(false);
+ self.markAsDirtyRecursive();
+ return;
+ }
+
+ AdminNotification.error("Unrecognized action '" + action + "' on target '" + target + "'");
+ }
+ });
+ }
+
+ protected void initializePIPTable() {
+ if (this.group == null) {
+ this.tablePIP.setVisible(false);
+ return;
+ }
+ //
+ // Setup data source and GUI properties
+ //
+ this.pipContainer = new PDPPIPContainer(group);
+ this.tablePIP.setContainerDataSource(this.pipContainer);
+ this.tablePIP.setPageLength(this.pipContainer.size() + 2);
+ this.tablePIP.setSelectable(true);
+ this.tablePIP.setSizeFull();
+ //
+ // Add the action handler
+ //
+ this.tablePIP.addActionHandler(new Handler() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Action[] getActions(Object target, Object sender) {
+ return new Action[] {EDIT_CONFIG};
+ }
+
+ @Override
+ public void handleAction(Action action, Object sender, Object target) {
+ if (action == EDIT_CONFIG) {
+ self.editPIPConfiguration();
+ return;
+ }
+ }
+ });
+ }
+
+ protected void editPIPConfiguration() {
+ final SelectPIPConfigurationWindow window = new SelectPIPConfigurationWindow(this.group);
+ window.setCaption("Select PIP Configurations");
+ window.setModal(true);
+ window.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Did the user click save button?
+ //
+ if (window.isSaved() == false) {
+ return;
+ }
+ //
+ // Yes - save the PIP configuration
+ //
+ Set<PDPPIPConfig> configs = window.getSelectedConfigs();
+ assert configs != null;
+ self.group.setPipConfigs(configs);
+ //
+ // Update the container
+ //
+ self.pipContainer.refresh();
+ }
+ });
+ window.center();
+ UI.getCurrent().addWindow(window);
+ }
+
+ protected void initializeButton() {
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ try {
+ //
+ // Validate
+ //
+ self.textName.commit();
+ //
+ // All good save everything
+ //
+ self.doSave();
+ //
+ // mark ourselves as saved
+ //
+ self.isSaved = true;
+ //
+ // Close the window
+ //
+ self.close();
+ } catch (InvalidValueException e) { //NOPMD
+ //
+ // Ignore, Vaadin will display our message
+ //
+ }
+ }
+ });
+ }
+
+ protected void doSave() {
+ if (this.group == null) {
+ return;
+ }
+ StdPDPGroup updatedGroupObject = new StdPDPGroup(
+ this.group.getId(),
+ this.group.isDefaultGroup(),
+ this.textName.getValue(),
+ this.textDescription.getValue(),
+ null);
+ // replace the original set of Policies with the set from the container (possibly modified by the user)
+ Set<PDPPolicy> changedPolicies = new HashSet<PDPPolicy>();
+ changedPolicies.addAll((Collection<PDPPolicy>) EditPDPGroupWindow.policyContainer.getItemIds());
+ updatedGroupObject.setPolicies(changedPolicies);
+ updatedGroupObject.setPdps(this.group.getPdps());
+ // replace the original set of PIP Configs with the set from the container
+//TODO - get PIP Configs from a container used to support editing
+// selfPDPObject.getPipConfigs().clear();
+// selfPDPObject.getPipConfigs().addAll(containerGroup.getPipConfigs());
+ updatedGroupObject.setPipConfigs(this.group.getPipConfigs());
+ // copy those things that the user cannot change from the original to the new object
+ updatedGroupObject.setStatus(this.group.getStatus());
+ this.updatedObject = updatedGroupObject;
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ public String getGroupName() {
+ return this.textName.getValue();
+ }
+
+ public String getGroupDescription() {
+ return this.textDescription.getValue();
+ }
+
+ public PDPGroup getUpdatedObject() {
+ return this.updatedObject;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("100.0%");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // textName
+ textName = new TextField();
+ textName.setCaption("Group Name");
+ textName.setImmediate(false);
+ textName.setWidth("-1px");
+ textName.setHeight("-1px");
+ textName.setRequired(true);
+ mainLayout.addComponent(textName);
+
+ // textDescription
+ textDescription = new TextArea();
+ textDescription.setCaption("Group Description");
+ textDescription.setImmediate(false);
+ textDescription.setWidth("100.0%");
+ textDescription.setHeight("-1px");
+ textDescription.setNullSettingAllowed(true);
+ mainLayout.addComponent(textDescription);
+ mainLayout.setExpandRatio(textDescription, 1.0f);
+
+ // tablePolicies
+ tablePolicies = new Table();
+ tablePolicies.setCaption("Policies");
+ tablePolicies.setImmediate(false);
+ tablePolicies.setWidth("-1px");
+ tablePolicies.setHeight("-1px");
+ mainLayout.addComponent(tablePolicies);
+ mainLayout.setExpandRatio(tablePolicies, 1.0f);
+
+ // tablePIP
+ tablePIP = new Table();
+ tablePIP.setCaption("PIP Configurations");
+ tablePIP.setImmediate(false);
+ tablePIP.setWidth("-1px");
+ tablePIP.setHeight("-1px");
+ mainLayout.addComponent(tablePIP);
+ mainLayout.setExpandRatio(tablePIP, 1.0f);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save");
+ buttonSave.setImmediate(true);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
+
+ return mainLayout;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/EditPDPWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/EditPDPWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/EditPDPWindow.java
new file mode 100644
index 0000000..d2c40e9
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/EditPDPWindow.java
@@ -0,0 +1,309 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+
+import org.apache.openaz.xacml.admin.util.AdminNotification;
+import org.apache.openaz.xacml.api.pap.PDP;
+import org.apache.openaz.xacml.api.pap.PDPGroup;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Buffered.SourceException;
+import com.vaadin.data.Validator;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.data.validator.RegexpValidator;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+import elemental.events.KeyboardEvent.KeyCode;
+
+public class EditPDPWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSave;
+ @AutoGenerated
+ private TextArea textDescription;
+ @AutoGenerated
+ private TextField textName;
+ @AutoGenerated
+ private TextField textId;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private final EditPDPWindow self = this;
+ private final PDP pdp;
+ private final List<PDPGroup> groups;
+ private boolean isSaved = false;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ * @param pdp
+ */
+ public EditPDPWindow(PDP pdp, List<PDPGroup> list) {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Save data
+ //
+ this.pdp = pdp;
+ this.groups = list;
+ //
+ // Initialize
+ //
+ this.initializeText();
+ this.initializeButton();
+ //
+ // Keyboard short
+ //
+ this.setCloseShortcut(KeyCode.ESC);
+ this.buttonSave.setClickShortcut(KeyCode.ENTER);
+ //
+ // Focus
+ //
+ this.textId.focus();
+ }
+
+ protected void initializeText() {
+ //
+ // Initialize values
+ //
+ if (this.pdp != null) {
+ this.textId.setValue(this.pdp.getId());
+ this.textName.setValue(this.pdp.getName());
+ this.textDescription.setValue(this.pdp.getDescription());
+ }
+ //
+ //
+ //
+ this.textId.setRequiredError("You must enter a valid id for the PDP.");
+ this.textId.setNullRepresentation("");
+ this.textId.addValidator(new RegexpValidator("[\\w=,]", false, "Please enter a valid URL with no whitespace or \"=\" or \",\" characters."));
+ this.textId.addValidator(new Validator() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void validate(Object value) throws InvalidValueException {
+ //
+ // Cannot be null
+ //
+ if (value == null || value.toString().length() == 0) {
+ throw new InvalidValueException("ID cannot be null.");
+ }
+ //
+ // Make sure its a valid URL
+ //
+ try {
+ new URL(value.toString());
+ } catch (MalformedURLException e) {
+ throw new InvalidValueException("The PDP URL '" + value.toString() + "' is not a valid URL: '" + e.getMessage() +"'");
+ }
+ }
+ });
+ //
+ //
+ //
+ this.textName.setNullRepresentation("");
+ this.textName.addValidator(new Validator() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void validate(Object value) throws InvalidValueException {
+ //
+ // If the value is null, set it to the id
+ //
+ if (value == null || value.toString().length() == 0) {
+ return;
+ }
+ }
+ });
+ //
+ //
+ //
+ this.textDescription.setNullRepresentation("");
+ }
+
+ protected void initializeButton() {
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ try {
+ //
+ // Do a commit
+ //
+ self.textName.commit();
+ self.textId.commit();
+ self.textDescription.commit();
+ //
+ // Should be a string, but to be safe
+ //
+ String id = self.textId.getValue();
+ String name = self.textName.getValue();
+ if (name == null || name.isEmpty()) {
+ self.textName.setValue(id);
+ name = id;
+ }
+ //
+ // ID must be unique.
+ // Also the Name must be unique AND not match any existing IDs
+ // because user uses the NAME to identify this PDP on the browser window, not the ID.
+ //
+ for (PDPGroup g : self.groups) {
+ for (PDP p : g.getPdps()) {
+ if (p.getId().equals(id)) {
+ if (self.pdp != null) {
+ //
+ // we are editing this pdp
+ //
+ continue;
+ }
+ throw new InvalidValueException("URL must be unique - the PDP '" + id + "' already exists in group '" + g.getName() + "'");
+ }
+ if (id.equals(p.getName())) {
+ throw new InvalidValueException("A previous PDP with URL '" + p.getId() + "' has been given the name '" + id +
+ "'. Please edit that PDP to change the name before creating a nwe PDP with this URL.");
+ }
+ if (name != null && name.length() > 0 && self.pdp == null && (p.getId().equals(name) || name.equals(p.getName()))) {
+ throw new InvalidValueException("Name must not be the same as another PDP's name OR another PDP's URL.");
+ }
+ }
+ }
+ //
+ // make sure name is NOT a URL, unless it is identical to the ID.
+ // (If it is a URL, then a later PDP might be created with that URL as it's ID, which would be confusing.)
+ //
+ if ( ! id.equals(name)) {
+ try {
+ new URL(name);
+ // if we get here the name is a URL but not identical to the id, which is not good
+ AdminNotification.warn("The Name must not be a URL unless it is the same as the PDP URL");
+ return;
+ } catch (Exception e) { //NOPMD
+ // ignore - we want to get here
+ }
+ }
+ //
+ // If we get here the inputs are ok
+ //
+ self.isSaved = true;
+ //
+ //
+ //
+ self.close();
+ } catch (SourceException | InvalidValueException e1) { //NOPMD
+ //
+ // Vaadin will display error
+ //
+ }
+ }
+ });
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ public String getPDPId() {
+ return this.textId.getValue();
+ }
+
+ public String getPDPName() {
+ return this.textName.getValue();
+ }
+
+ public String getPDPDescription() {
+ return this.textDescription.getValue();
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // textId
+ textId = new TextField();
+ textId.setCaption("PDP URL");
+ textId.setImmediate(false);
+ textId.setDescription("The URL is the ID of the PDP");
+ textId.setWidth("-1px");
+ textId.setHeight("-1px");
+ textId.setRequired(true);
+ textId.setInputPrompt("Eg. http://localhost:8080/pdp");
+ mainLayout.addComponent(textId);
+
+ // textName
+ textName = new TextField();
+ textName.setCaption("PDP Name");
+ textName.setImmediate(false);
+ textName.setWidth("-1px");
+ textName.setHeight("-1px");
+ mainLayout.addComponent(textName);
+
+ // textDescription
+ textDescription = new TextArea();
+ textDescription.setCaption("PDP Description");
+ textDescription.setImmediate(false);
+ textDescription.setWidth("100.0%");
+ textDescription.setHeight("-1px");
+ textDescription.setNullSettingAllowed(true);
+ mainLayout.addComponent(textDescription);
+ mainLayout.setExpandRatio(textDescription, 1.0f);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save");
+ buttonSave.setImmediate(true);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ExpressionBuilderComponent.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ExpressionBuilderComponent.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ExpressionBuilderComponent.java
new file mode 100644
index 0000000..b231d70
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ExpressionBuilderComponent.java
@@ -0,0 +1,1078 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import java.util.Map;
+
+import javax.xml.bind.JAXBElement;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeAssignmentExpressionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeSelectorType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ConditionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.FunctionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObjectFactory;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableDefinitionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableReferenceType;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.jpa.Attribute;
+import org.apache.openaz.xacml.admin.jpa.Datatype;
+import org.apache.openaz.xacml.admin.jpa.FunctionArgument;
+import org.apache.openaz.xacml.admin.jpa.FunctionDefinition;
+import org.apache.openaz.xacml.admin.model.ExpressionContainer;
+import org.apache.openaz.xacml.admin.util.AdminNotification;
+import org.apache.openaz.xacml.admin.util.JPAUtils;
+import org.apache.openaz.xacml.admin.util.XACMLFunctionValidator;
+import org.apache.openaz.xacml.admin.view.events.ApplyParametersChangedListener;
+import org.apache.openaz.xacml.util.XACMLObjectCopy;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Container.ItemSetChangeEvent;
+import com.vaadin.data.Container.ItemSetChangeListener;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.event.Action;
+import com.vaadin.event.Action.Handler;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.AbstractSelect.ItemCaptionMode;
+import com.vaadin.ui.AbstractSelect.ItemDescriptionGenerator;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.TreeTable;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class ExpressionBuilderComponent extends Window implements ApplyParametersChangedListener {
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSave;
+ @AutoGenerated
+ private TreeTable treeExpressions;
+ @AutoGenerated
+ private HorizontalLayout horizontalLayout_1;
+ @AutoGenerated
+ private CheckBox checkBoxShortName;
+ @AutoGenerated
+ private Button buttonClearAll;
+ @AutoGenerated
+ private Button buttonDeleteExpression;
+ @AutoGenerated
+ private Button buttonAddExpression;
+ /*
+ *
+ *
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static Log logger = LogFactory.getLog(ExpressionBuilderComponent.class);
+
+ private static final Action ADD_EXPRESSION = new Action ("Add Expression");
+ private static final Action EDIT_EXPRESSION = new Action ("Edit Expression");
+ private static final Action DELETE_EXPRESSION = new Action ("Delete Expression");
+ private static final Action ADD_ARGUMENT = new Action ("Add Argument");
+ private static final Action EDIT_ARGUMENT = new Action ("Edit Argument");
+ private static final Action DELETE_ARGUMENT = new Action ("Delete Argument");
+
+ private final Object[] visibleColumns = new Object[] {ExpressionContainer.PROPERTY_NAME, ExpressionContainer.PROPERTY_ID, ExpressionContainer.PROPERTY_ID_SHORT, ExpressionContainer.PROPERTY_DATATYPE, ExpressionContainer.PROPERTY_DATATYPE_SHORT};
+ private final String[] columnHeaders = new String[] {"Name", "XCAML ID or Value", "XCAML ID or Value", "Data Type ID", "Data Type ID"};
+
+ private final ExpressionBuilderComponent self = this;
+ private final Object parent;
+ private final Map<VariableDefinitionType, PolicyType> variables;
+ private final ExpressionContainer container;
+ private boolean isSaved = false;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public ExpressionBuilderComponent(Object parent, Object root, FunctionArgument argument, Map<VariableDefinitionType, PolicyType> variables) {
+ buildMainLayout();
+// setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Save our data
+ //
+ this.parent = parent;
+ this.variables = variables;
+ this.container = new ExpressionContainer(parent, root, argument);
+ //
+ // Make sure we support the parent object
+ //
+ if (this.isSupported() == false) {
+ throw new IllegalArgumentException("Unsupported object type");
+ }
+ //
+ // Set our shortcuts
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ // Finish our GUI initialization
+ //
+ this.initializeTree();
+ this.initializeButtons();
+ this.initializeCheckbox();
+ //
+ // Setup the buttons
+ //
+ this.setupButtons();
+ }
+
+ private boolean isSupported() {
+ return this.isParentACondition() ||
+ this.isParentAVariable() ||
+ this.isParentAAssignment();
+ }
+
+ private boolean isParentACondition() {
+ return this.parent instanceof ConditionType;
+ }
+
+ private boolean isParentAVariable() {
+ return this.parent instanceof VariableDefinitionType;
+ }
+
+ private boolean isParentAAssignment() {
+ return this.parent instanceof AttributeAssignmentExpressionType;
+ }
+
+ private void initializeTree() {
+ //
+ // Initialize GUI properties
+ //
+ this.treeExpressions.setImmediate(true);
+ this.treeExpressions.setSelectable(true);
+ //
+ // Initialize the data source
+ //
+ this.treeExpressions.setContainerDataSource(this.container);
+ this.treeExpressions.setItemCaptionMode(ItemCaptionMode.PROPERTY);
+ this.treeExpressions.setVisibleColumns(this.visibleColumns);
+ this.treeExpressions.setColumnHeaders(this.columnHeaders);
+ this.treeExpressions.setColumnCollapsingAllowed(true);
+ this.treeExpressions.setColumnCollapsed(ExpressionContainer.PROPERTY_ID, true);
+ this.treeExpressions.setColumnCollapsed(ExpressionContainer.PROPERTY_DATATYPE, true);
+ //
+ // Add our action handler
+ //
+ this.treeExpressions.addActionHandler(new Handler() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Action[] getActions(Object target, Object sender) {
+ if (target == null) {
+ if (self.container.size() == 0) {
+ return new Action[] {ADD_EXPRESSION};
+ }
+ return null;
+ }
+ if (target instanceof ApplyType && XACMLFunctionValidator.canHaveMoreArguments((ApplyType) target)) {
+ return new Action[] {ADD_ARGUMENT, EDIT_EXPRESSION, DELETE_EXPRESSION};
+ }
+ return new Action[] {EDIT_ARGUMENT, DELETE_ARGUMENT};
+ }
+
+ @Override
+ public void handleAction(Action action, Object sender, Object target) {
+ if (action == ADD_EXPRESSION && target == null) {
+ self.addExpression(null, null);
+ }
+ if (action == EDIT_EXPRESSION && target != null) {
+ self.editExpression(target, (ApplyType) self.container.getParent(target), (FunctionArgument) self.container.getArgument(target));
+ }
+ if (action == DELETE_EXPRESSION && target != null) {
+ self.deleteExpression(target);
+ }
+ if (action == ADD_ARGUMENT && target != null && target instanceof ApplyType) {
+ self.addArgument((ApplyType) target);
+ }
+ if (action == EDIT_ARGUMENT && target != null) {
+ self.editExpression(target, (ApplyType) self.container.getParent(target), (FunctionArgument) self.container.getArgument(target));
+ }
+ if (action == DELETE_ARGUMENT && target != null) {
+ self.deleteExpression(target);
+ }
+ }
+ });
+ //
+ // Listen to double-click item selections
+ //
+ this.treeExpressions.addItemClickListener(new ItemClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void itemClick(ItemClickEvent event) {
+ if (event.isDoubleClick()) {
+ Object target = event.getItemId();//self.treeExpressions.getValue();
+ if (target == null) {
+ return;
+ }
+ self.editExpression(target, (ApplyType) self.container.getParent(target), (FunctionArgument) self.container.getArgument(target));
+ }
+ }
+ });
+ //
+ // Listen when the user selects a row
+ //
+ this.treeExpressions.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ self.setupButtons();
+ }
+ });
+ //
+ // Listen to when the table contents change
+ //
+ this.treeExpressions.addItemSetChangeListener(new ItemSetChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void containerItemSetChange(ItemSetChangeEvent event) {
+ self.validateExpression();
+ }
+ });
+ //
+ // Expand columns automatically
+ //
+ this.treeExpressions.setColumnExpandRatio(ExpressionContainer.PROPERTY_NAME, 1.0f);
+ this.treeExpressions.setColumnExpandRatio(ExpressionContainer.PROPERTY_ID, 1.0f);
+ this.treeExpressions.setColumnExpandRatio(ExpressionContainer.PROPERTY_DATATYPE, 1.0f);
+ //
+ // Expand all the children
+ //
+ for (Object id : this.treeExpressions.getItemIds()) {
+ this.treeExpressions.setCollapsed(id, false);
+ }
+ //
+ // Have a description generator
+ //
+ this.treeExpressions.setItemDescriptionGenerator(new ItemDescriptionGenerator() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String generateDescription(Component source, Object itemId, Object propertyId) {
+ if (propertyId != null && propertyId.equals(ExpressionContainer.PROPERTY_NAME) && itemId instanceof ApplyType) {
+ return ((ApplyType) itemId).getDescription();
+ }
+ return null;
+ }
+ });
+ }
+
+ private void initializeButtons() {
+ this.buttonClearAll.setImmediate(true);
+ this.buttonClearAll.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ self.clearAllExpressions();
+ }
+
+ });
+
+ this.buttonAddExpression.setImmediate(true);
+ this.buttonAddExpression.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ Object selected = self.treeExpressions.getValue();
+ if (selected == null) {
+ //
+ // Adding a root expression
+ //
+ self.addExpression(null, null);
+ } else {
+ //
+ // Adding an argument
+ //
+ if (selected instanceof ApplyType) {
+ //
+ // Get the function
+ //
+ self.addArgument((ApplyType) selected);
+ }
+ }
+ }
+ });
+
+ this.buttonDeleteExpression.setImmediate(true);
+ this.buttonDeleteExpression.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ Object id = self.treeExpressions.getValue();
+ if (id == null) {
+ logger.error("Delete button clicked on null selection");
+ return;
+ }
+ self.deleteExpression(id);
+ }
+
+ });
+
+ this.buttonSave.setImmediate(true);
+ this.buttonSave.setClickShortcut(KeyCode.ENTER);
+ this.buttonSave.setEnabled(false);
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ //
+ // TODO validate
+ //
+ //
+ // Mark that we are saved
+ //
+ self.isSaved = true;
+ //
+ // Close the window
+ //
+ self.close();
+ }
+ });
+ }
+
+ protected void initializeCheckbox() {
+ this.checkBoxShortName.setValue(true);
+ this.checkBoxShortName.setImmediate(true);
+ this.checkBoxShortName.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ self.treeExpressions.setColumnCollapsed(ExpressionContainer.PROPERTY_ID, self.checkBoxShortName.getValue());
+ self.treeExpressions.setColumnCollapsed(ExpressionContainer.PROPERTY_DATATYPE, self.checkBoxShortName.getValue());
+ self.treeExpressions.setColumnCollapsed(ExpressionContainer.PROPERTY_ID_SHORT, ! self.checkBoxShortName.getValue());
+ self.treeExpressions.setColumnCollapsed(ExpressionContainer.PROPERTY_DATATYPE_SHORT, ! self.checkBoxShortName.getValue());
+ }
+ });
+ }
+
+ protected void setupButtons() {
+ if (this.treeExpressions.size() == 0) {
+ this.buttonAddExpression.setEnabled(true);
+ this.buttonClearAll.setEnabled(false);
+ this.buttonSave.setEnabled(false);
+ } else {
+ this.validateExpression();
+ this.buttonAddExpression.setEnabled(false);
+ this.buttonClearAll.setEnabled(true);
+ }
+ Object value = this.treeExpressions.getValue();
+ if (value == null) {
+ this.buttonDeleteExpression.setEnabled(false);
+ } else {
+ this.buttonDeleteExpression.setEnabled(true);
+ }
+ }
+
+ protected void validateExpression() {
+ boolean valid = false;
+ boolean canHaveMore = false;
+ if (this.isParentACondition()) {
+ valid = XACMLFunctionValidator.validateCondition((ConditionType) this.parent);
+ canHaveMore = XACMLFunctionValidator.canHaveMoreArguments((ConditionType) this.parent);
+ } else if (this.isParentAVariable()) {
+ valid = XACMLFunctionValidator.validateVariable((VariableDefinitionType) this.parent);
+ canHaveMore = XACMLFunctionValidator.canHaveMoreArguments((VariableDefinitionType) this.parent);
+ } else if (this.isParentAAssignment()) {
+ valid = XACMLFunctionValidator.validateAssignment((AttributeAssignmentExpressionType)this.parent);
+ canHaveMore = XACMLFunctionValidator.canHaveMoreArguments((AttributeAssignmentExpressionType) this.parent);
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("valid: " + valid + " canHaveMore: " + canHaveMore);
+ }
+// this.buttonAddExpression.setEnabled(canHaveMore);
+ this.buttonSave.setEnabled(valid);
+ }
+
+ protected void addArgument(final ApplyType parentApply) {
+ //
+ // Get the function
+ //
+ FunctionDefinition function = JPAUtils.findFunction(parentApply.getFunctionId());
+ if (function != null) {
+ FunctionArgument argument = XACMLFunctionValidator.getFunctionArgument(parentApply.getExpression().size() + 1, function);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Add Argument: " + argument);
+ }
+ assert argument != null;
+ //
+ // Is this a high order bag function? And it's data type not defined? (most likely)
+ //
+ if (function.isHigherOrder() && argument.getDatatypeBean() == null) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("isHighOrder and a null datatype bean");
+ }
+ //
+ // Get what the data type restriction should be
+ //
+ try {
+ assert parentApply.getExpression().size() > 0;
+ JAXBElement<?> element = parentApply.getExpression().get(0);
+ assert element != null && element.getValue() != null;
+ Object declaredFunction = element.getValue();
+ assert declaredFunction instanceof FunctionType;
+ FunctionDefinition declaredFunctionDefinition = JPAUtils.findFunction(((FunctionType) declaredFunction).getFunctionId());
+ assert declaredFunctionDefinition != null;
+ if (logger.isDebugEnabled()) {
+ logger.debug("declaredFunction is: " + declaredFunctionDefinition);
+ }
+ FunctionArgument declaredFunctionArgument = XACMLFunctionValidator.getFunctionArgument(parentApply.getExpression().size(), declaredFunctionDefinition);
+ assert declaredFunctionArgument != null;
+ if (logger.isDebugEnabled()) {
+ logger.debug("declaredFunctionArgument is: " + declaredFunctionArgument);
+ }
+ //
+ // Copy the argument
+ //
+ argument = new FunctionArgument(argument);
+ argument.setDatatypeBean(declaredFunctionArgument.getDatatypeBean());
+ } catch (Exception e) {
+ logger.error("Exception while determining parent apply's FunctionType argument datatype.");
+ }
+
+ }
+ self.addExpression(parentApply, argument);
+ } else {
+ AdminNotification.error("ApplyType does not have a function defined. Please define that first.");
+ }
+
+ }
+
+ protected void addExpression(final ApplyType parentApply, final FunctionArgument argument) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Adding Expression: " + parentApply + " arg: " + argument);
+ }
+ //
+ // First we need to select what Expression They want
+ //
+ final ExpressionSelectionWindow selector = new ExpressionSelectionWindow(parentApply,
+ this.isParentAAssignment(),
+ (argument != null ? argument.isBag() : false),
+ (argument != null ? ! argument.isBag() : false));
+ selector.setCaption("Select the Expression Type");
+ selector.setModal(true);
+ selector.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Was something selected?
+ //
+ String selection = selector.getSelection();
+ if (selection == null) {
+ return;
+ }
+ //
+ // What did the user select?
+ //
+ if (selection.equals(ExpressionSelectionWindow.OPTION_APPLY)) {
+ //
+ self.editApply(new ApplyType(), parentApply, argument);
+ //
+ } else if (selection.equals(ExpressionSelectionWindow.OPTION_DESIGNATOR)) {
+ //
+ self.editAttribute(new AttributeDesignatorType(), parentApply, argument);
+ //
+ } else if (selection.equals(ExpressionSelectionWindow.OPTION_SELECTOR) ) {
+ //
+ self.editAttribute(new AttributeSelectorType(), parentApply, argument);
+ //
+ } else if (selection.equals(ExpressionSelectionWindow.OPTION_VALUE)) {
+ //
+ self.editValue(new AttributeValueType(), parentApply, argument);
+ //
+ } else if (selection.equals(ExpressionSelectionWindow.OPTION_VARIABLE)) {
+ //
+ self.editVariable(new VariableReferenceType(), parentApply, argument);
+ //
+ }
+ }
+ });
+ selector.center();
+ UI.getCurrent().addWindow(selector);
+ }
+
+ protected void editApply(final ApplyType apply, final ApplyType parent, final FunctionArgument argument) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("editApply: " + apply + " parent: " + parent + " :" + argument);
+ }
+ //
+ // Copy the apply and create its window
+ //
+ final ApplyType copyApply = XACMLObjectCopy.copy(apply);
+ final ApplyEditorWindow window = new ApplyEditorWindow(copyApply, parent, argument, self.parent);
+ window.setCaption("Edit The Apply Expression");
+ window.setModal(true);
+ //
+ // Set ourselves as an ApplyParametersChanged listener
+ //
+ window.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Did the user save?
+ //
+ if (window.isSaved() == false) {
+ return;
+ }
+ //
+ // Copy back the apply
+ //
+ apply.setDescription(copyApply.getDescription());
+ apply.setFunctionId(copyApply.getFunctionId());
+ //
+ // Get the function information
+ //
+ FunctionDefinition function = JPAUtils.findFunction(apply.getFunctionId());
+ assert function != null;
+ //
+ // Is this a new Apply?
+ //
+ if (self.container.containsId(apply)) {
+ //
+ // No - we are updating
+ //
+ self.container.updateItem(apply);
+ } else {
+ //
+ // Is this a higher-order bag function?
+ //
+ if (function.isHigherOrder()) {
+ //
+ // Have the user select a function for it
+ //
+ final FunctionSelectionWindow functionSelection = new FunctionSelectionWindow(null);
+ functionSelection.setCaption("Select Function");
+ functionSelection.setModal(true);
+ functionSelection.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Did the user save?
+ //
+ if (functionSelection.isSaved() == false) {
+ return;
+ }
+ //
+ // Get the function
+ //
+ String function = functionSelection.getSelectedFunction();
+ if (function == null || function.isEmpty()) {
+ logger.error("Function window said it was saved, but there was no function.");
+ return;
+ }
+ //
+ // Create the function object
+ //
+ FunctionType hoFunction = new FunctionType();
+ hoFunction.setFunctionId(function);
+ //
+ // Add it into the apply
+ //
+ apply.getExpression().add(new ObjectFactory().createFunction(hoFunction));
+ //
+ // New Item
+ //
+ Item item = self.container.addItem(apply, parent, argument);
+ assert item != null;
+ self.treeExpressions.setCollapsed(apply, false);
+ self.treeExpressions.select(apply);
+ }
+ });
+ functionSelection.center();
+ UI.getCurrent().addWindow(functionSelection);
+ } else {
+ //
+ // New Item
+ //
+ Item item = self.container.addItem(apply, parent, argument);
+ assert item != null;
+ self.treeExpressions.setCollapsed(apply, false);
+ self.treeExpressions.select(apply);
+ }
+ }
+ }
+ });
+ window.center();
+ UI.getCurrent().addWindow(window);
+ }
+
+ protected void editAttribute(final Object target, final ApplyType parent, final FunctionArgument argument) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("editAttribute: " + target + " parent: " + parent + " :" + argument);
+ }
+ //
+ // Determine what the data type needs to be
+ //
+ Datatype datatype = null;
+ if (parent == null && this.isParentACondition()) {
+ datatype = JPAUtils.getBooleanDatatype();
+ } else {
+ if (argument != null) {
+ datatype = argument.getDatatypeBean();
+ }
+ }
+ //
+ // Copy the attribute
+ //
+ final Object copyAttribute = XACMLObjectCopy.deepCopy(target);
+ //
+ // Create the window
+ //
+ final AttributeSelectionWindow window = new AttributeSelectionWindow(datatype, copyAttribute);
+ if (target instanceof AttributeDesignatorType) {
+ window.setCaption("Edit Designator " + (((AttributeDesignatorType) target).getAttributeId() != null ? ((AttributeDesignatorType) target).getAttributeId() : ""));
+ } else {
+ window.setCaption("Edit Selector " + (((AttributeSelectorType) target).getContextSelectorId() != null ? ((AttributeSelectorType) target).getContextSelectorId() : ""));
+ }
+ window.setModal(true);
+ window.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Did the user hit save?
+ //
+ if (window.isSaved() == false) {
+ return;
+ }
+ //
+ // Grab the attribute
+ //
+ Attribute attribute = window.getAttribute();
+ if (attribute == null) {
+ return;
+ }
+ //
+ // Save it back into the original
+ //
+ if (target instanceof AttributeDesignatorType) {
+ ((AttributeDesignatorType)target).setAttributeId(attribute.getXacmlId());
+ ((AttributeDesignatorType)target).setCategory(attribute.getCategoryBean().getXacmlId());
+ ((AttributeDesignatorType)target).setDataType(attribute.getDatatypeBean().getXacmlId());
+ ((AttributeDesignatorType)target).setIssuer(attribute.getIssuer());
+ ((AttributeDesignatorType)target).setMustBePresent(attribute.isMustBePresent());
+ } else {
+ ((AttributeSelectorType)target).setContextSelectorId(attribute.getXacmlId());
+ ((AttributeSelectorType)target).setCategory(attribute.getCategoryBean().getXacmlId());
+ ((AttributeSelectorType)target).setDataType(attribute.getDatatypeBean().getXacmlId());
+ ((AttributeSelectorType)target).setPath(attribute.getSelectorPath());
+ ((AttributeSelectorType)target).setMustBePresent(attribute.isMustBePresent());
+ }
+ //
+ // Is this a new item?
+ //
+ if (self.container.containsId(target)) {
+ //
+ // No, just update the container
+ //
+ self.container.updateItem(target);
+ } else {
+ //
+ // Yes a new item, add it in
+ //
+ //assert(self.container.addItem(JPAUtils.createDesignator(attribute), parent, argument) != null);
+ Item item = self.container.addItem(target, parent, argument);
+ assert item != null;
+ self.treeExpressions.select(target);
+ }
+ }
+ });
+ window.center();
+ UI.getCurrent().addWindow(window);
+ }
+
+ protected void editValue(final AttributeValueType value, final ApplyType parent, final FunctionArgument argument) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("editvalue: " + value + " parent: " + parent + " :" + argument);
+ }
+ //
+ // Copy the attribute value
+ //
+ final AttributeValueType copyValue = XACMLObjectCopy.copy(value);
+ //
+ // Get what the datatype should be
+ //
+ Datatype datatypeRestriction = null;
+ //
+ // Is this a root?
+ //
+ if (parent == null) {
+ //
+ // Check if our parent container is a condition
+ //
+ if (self.isParentACondition()) {
+ //
+ // We are only allowed to return boolean's
+ //
+ datatypeRestriction = JPAUtils.getBooleanDatatype();
+ }
+ } else {
+ //
+ // Are we an argument?
+ //
+ if (argument != null) {
+ //
+ // Yes - we are restricted to that argument's datatype
+ //
+ datatypeRestriction = argument.getDatatypeBean();
+ }
+ }
+ //
+ // Create the window
+ //
+ final AttributeValueEditorWindow window = new AttributeValueEditorWindow(copyValue, datatypeRestriction);
+ window.setCaption("Edit Attribute Value");
+ window.setModal(true);
+ window.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Did the user click save?
+ //
+ if (window.isSaved() == false) {
+ return;
+ }
+ //
+ // Yes - get the value
+ //
+ value.getContent().clear();
+ for (Object o : copyValue.getContent()) {
+ value.getContent().add(o);
+ }
+ value.setDataType(copyValue.getDataType());
+ //
+ // Was this a new value?
+ //
+ if (self.container.containsId(value)) {
+ //
+ // No - update it
+ //
+ self.container.updateItem(value);
+ } else {
+ //
+ // Yes - add it in
+ //
+ Item item = self.container.addItem(value, parent, argument);
+ assert item != null;
+ }
+ }
+ });
+ window.center();
+ UI.getCurrent().addWindow(window);
+ }
+
+ protected void editVariable(final VariableReferenceType variable, final ApplyType parent, final FunctionArgument argument) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("editVariable: " + variable + " parent: " + parent + " :" + argument);
+ }
+ //
+ // Copy the variable
+ //
+ final VariableReferenceType copyVariable = XACMLObjectCopy.copy(variable);
+ //
+ // Create the window
+ //
+ final VariableReferenceEditorWindow window = new VariableReferenceEditorWindow(copyVariable, this.variables);
+ window.setCaption("Edit Variable Reference");
+ window.setModal(true);
+ window.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Did the user click save?
+ //
+ if (window.isSaved() == false) {
+ return;
+ }
+ //
+ // Copy the variable changes back
+ //
+ variable.setVariableId(copyVariable.getVariableId());
+ //
+ // Is this a new one?
+ //
+ if (self.container.containsId(variable)) {
+ //
+ // No - update it
+ //
+ self.container.updateItem(variable);
+ } else {
+ //
+ // Yes - add it
+ //
+ Item item = self.container.addItem(variable, parent, argument);
+ assert item != null;
+ }
+ }
+ });
+ window.center();
+ UI.getCurrent().addWindow(window);
+ }
+
+ protected void editFunction(final FunctionType func, final ApplyType parent, final FunctionArgument argument) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("editFunction: " + func + " parent: " + parent + " :" + argument);
+ }
+
+ final FunctionSelectionWindow functionSelection = new FunctionSelectionWindow((func != null ? func.getFunctionId() : null));
+ functionSelection.setCaption("Edit Function");
+ functionSelection.setModal(true);
+ functionSelection.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Did the user save?
+ //
+ if (functionSelection.isSaved() == false) {
+ return;
+ }
+ //
+ // Get the function
+ //
+ String function = functionSelection.getSelectedFunction();
+ if (function == null || function.isEmpty()) {
+ logger.error("Function window said it was saved, but there was no function.");
+ return;
+ }
+ //
+ // New one?
+ //
+ if (func == null) {
+ //
+ // Create the function object
+ //
+ FunctionType hoFunction = new FunctionType();
+ hoFunction.setFunctionId(function);
+ //
+ // Add it into the apply
+ //
+ assert parent.getExpression().size() == 0;
+ parent.getExpression().add(new ObjectFactory().createFunction(hoFunction));
+ //
+ // New Item
+ //
+ Item item = self.container.addItem(func, parent, argument);
+ assert item != null;
+ self.treeExpressions.setCollapsed(parent, false);
+ self.treeExpressions.select(func);
+ } else {
+ //
+ // Editing an existing
+ //
+ func.setFunctionId(function);
+ self.container.updateItem(func);
+ //
+ // Warn user
+ //
+ if (parent.getExpression().size() > 1) {
+ AdminNotification.warn("You have updated the function ID. The rest of the arguments may be invalid for the function. Please verify the other arguments.");
+ }
+ }
+ }
+ });
+ functionSelection.center();
+ UI.getCurrent().addWindow(functionSelection);
+ }
+
+ protected void editExpression(final Object target, final ApplyType parent, final FunctionArgument argument) {
+ if (target instanceof ApplyType) {
+ //
+ this.editApply((ApplyType) target, parent, argument);
+ //
+ } else if (target instanceof AttributeValueType) {
+ //
+ this.editValue((AttributeValueType) target,parent, argument);
+ //
+ } else if (target instanceof AttributeDesignatorType || target instanceof AttributeSelectorType) {
+ //
+ this.editAttribute(target, parent, argument);
+ //
+ } else if (target instanceof VariableReferenceType) {
+ //
+ this.editVariable((VariableReferenceType) target, parent, argument);
+ //
+ } else if (target instanceof FunctionType) {
+ //
+ this.editFunction((FunctionType) target, parent, argument);
+ //
+ }
+ }
+
+ protected void deleteExpression(Object target) {
+ if (this.container.isRoot(target)) {
+ if (this.treeExpressions.removeAllItems() == false) {
+ logger.error("Failed to remove everything.");
+ }
+ } else {
+ if (this.treeExpressions.removeItem(target) == false) {
+ logger.error("Failed to remove " + target);
+ }
+ }
+ this.setupButtons();
+ }
+
+ protected void clearAllExpressions() {
+ if (this.treeExpressions.removeAllItems() == false) {
+ logger.error("Failed to remove everything.");
+ }
+ this.setupButtons();
+ }
+
+ @Override
+ public void applyParameterChanged(ApplyType apply, ApplyType parent, FunctionArgument argument, Object container) {
+ logger.info("applyParameterChanged: " + apply + " " + parent + " " + argument + " " + container);
+ //
+ // TODO - figure out if this something being edited, or a new one
+ //
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("100%");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // horizontalLayout_1
+ horizontalLayout_1 = buildHorizontalLayout_1();
+ mainLayout.addComponent(horizontalLayout_1);
+ mainLayout.setExpandRatio(horizontalLayout_1, 1.0f);
+
+ // treeExpressions
+ treeExpressions = new TreeTable();
+ treeExpressions.setImmediate(false);
+ treeExpressions.setWidth("100.0%");
+ treeExpressions.setHeight("-1px");
+ mainLayout.addComponent(treeExpressions);
+ mainLayout.setExpandRatio(treeExpressions, 1.0f);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save");
+ buttonSave.setImmediate(true);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
+
+ return mainLayout;
+ }
+
+ @AutoGenerated
+ private HorizontalLayout buildHorizontalLayout_1() {
+ // common part: create layout
+ horizontalLayout_1 = new HorizontalLayout();
+ horizontalLayout_1.setImmediate(false);
+ horizontalLayout_1.setWidth("-1px");
+ horizontalLayout_1.setHeight("-1px");
+ horizontalLayout_1.setMargin(false);
+ horizontalLayout_1.setSpacing(true);
+
+ // buttonAddExpression
+ buttonAddExpression = new Button();
+ buttonAddExpression.setCaption("Add Expression");
+ buttonAddExpression.setImmediate(true);
+ buttonAddExpression.setWidth("-1px");
+ buttonAddExpression.setHeight("-1px");
+ horizontalLayout_1.addComponent(buttonAddExpression);
+
+ // buttonDeleteExpression
+ buttonDeleteExpression = new Button();
+ buttonDeleteExpression.setCaption("Delete Expression");
+ buttonDeleteExpression.setImmediate(true);
+ buttonDeleteExpression.setWidth("-1px");
+ buttonDeleteExpression.setHeight("-1px");
+ horizontalLayout_1.addComponent(buttonDeleteExpression);
+
+ // buttonClearAll
+ buttonClearAll = new Button();
+ buttonClearAll.setCaption("Clear All");
+ buttonClearAll.setImmediate(true);
+ buttonClearAll.setDescription("Clears all the expressions.");
+ buttonClearAll.setWidth("-1px");
+ buttonClearAll.setHeight("-1px");
+ horizontalLayout_1.addComponent(buttonClearAll);
+
+ // checkBoxShortName
+ checkBoxShortName = new CheckBox();
+ checkBoxShortName.setCaption("Display Short XACML ID's");
+ checkBoxShortName.setImmediate(false);
+ checkBoxShortName
+ .setDescription("If checked, the right-most string of the function and datatype URI's will only be displayed.");
+ checkBoxShortName.setWidth("-1px");
+ checkBoxShortName.setHeight("-1px");
+ horizontalLayout_1.addComponent(checkBoxShortName);
+
+ return horizontalLayout_1;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ExpressionEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ExpressionEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ExpressionEditorWindow.java
new file mode 100644
index 0000000..0ee6eea
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ExpressionEditorWindow.java
@@ -0,0 +1,90 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.Tree;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class ExpressionEditorWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Tree treeExpression;
+ @AutoGenerated
+ private ComboBox comboBox;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public ExpressionEditorWindow() {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+
+ // TODO add user code here
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // comboBox
+ comboBox = new ComboBox();
+ comboBox.setImmediate(false);
+ comboBox.setWidth("-1px");
+ comboBox.setHeight("-1px");
+ mainLayout.addComponent(comboBox);
+
+ // treeExpression
+ treeExpression = new Tree();
+ treeExpression.setImmediate(false);
+ treeExpression.setWidth("100.0%");
+ treeExpression.setHeight("-1px");
+ mainLayout.addComponent(treeExpression);
+ mainLayout.setExpandRatio(treeExpression, 1.0f);
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ExpressionSelectionWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ExpressionSelectionWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ExpressionSelectionWindow.java
new file mode 100644
index 0000000..d7bfeb0
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ExpressionSelectionWindow.java
@@ -0,0 +1,170 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType;
+
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.OptionGroup;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class ExpressionSelectionWindow extends Window {
+
+ public static String OPTION_APPLY = "Apply";
+ public static String OPTION_VALUE = "Attribute Value";
+ public static String OPTION_DESIGNATOR = "Attribute Designator";
+ public static String OPTION_SELECTOR = "Attribute Selector";
+ public static String OPTION_VARIABLE = "Variable Reference";
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSave;
+ @AutoGenerated
+ private OptionGroup optionGroupExpression;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private final ExpressionSelectionWindow self = this;
+ boolean isSaved = false;
+ String selection = null;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ * @param parentApply
+ */
+ // TODO - Refactor. Unused formal parameter parentApply. Either determine
+ // whether this is unnecessary and remove it (including removing it from all
+ // constructor consumers), or use it.
+ // NOTE: parentApply was originally used by passing to private initializeOption method.
+ // However, the parameter was unused by that method also.
+ // Setting to NOPMD for now.
+ public ExpressionSelectionWindow(ApplyType parentApply, boolean isAttributeAssignment, boolean mustBeBag, boolean mustBeValue) { //NOPMD
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Set our shortcuts
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ // Finish GUI initialization
+ //
+ // this.initializeOption(parentApply, isAttributeAssignment, mustBeBag, mustBeValue);
+ this.initializeOption(isAttributeAssignment, mustBeBag, mustBeValue);
+ this.initializeButtons();
+ }
+
+ // private void initializeOption(ApplyType parentApply, boolean isAttributeAssignment, boolean mustBeBag, boolean mustBeValue) {
+ private void initializeOption(boolean isAttributeAssignment, boolean mustBeBag, boolean mustBeValue) {
+// if (!isAttributeAssignment) {
+ this.optionGroupExpression.addItem(OPTION_APPLY);
+// }
+ if (!mustBeBag || mustBeValue) {
+ this.optionGroupExpression.addItem(OPTION_VALUE);
+ }
+ if (mustBeBag || !mustBeValue) {
+ this.optionGroupExpression.addItem(OPTION_DESIGNATOR);
+ this.optionGroupExpression.addItem(OPTION_SELECTOR);
+ }
+ this.optionGroupExpression.addItem(OPTION_VARIABLE);
+ //
+ // Default Selection
+ //
+ if (!isAttributeAssignment) {
+ this.optionGroupExpression.select(OPTION_APPLY);
+ } else {
+ if (!mustBeBag || mustBeValue) {
+ this.optionGroupExpression.select(OPTION_VALUE);
+ } else {
+ this.optionGroupExpression.select(OPTION_DESIGNATOR);
+ }
+ }
+ }
+
+ private void initializeButtons() {
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ self.isSaved = true;
+ self.selection = self.optionGroupExpression.getValue().toString();
+ self.close();
+ }
+ });
+ }
+
+ public String getSelection() {
+ if (this.isSaved == false) {
+ return null;
+ }
+ return this.selection;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // optionGroupExpression
+ optionGroupExpression = new OptionGroup();
+ optionGroupExpression
+ .setCaption("Select One Of The Following Types of Expressions");
+ optionGroupExpression.setImmediate(false);
+ optionGroupExpression.setWidth("-1px");
+ optionGroupExpression.setHeight("-1px");
+ mainLayout.addComponent(optionGroupExpression);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Select");
+ buttonSave.setImmediate(false);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(24));
+
+ return mainLayout;
+ }
+
+}
[10/23] incubator-openaz git commit: Ported original att source to
openaz
Posted by pd...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/AttributeSimpleCreatorComponent.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/AttributeSimpleCreatorComponent.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/AttributeSimpleCreatorComponent.java
new file mode 100644
index 0000000..c1568b9
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/AttributeSimpleCreatorComponent.java
@@ -0,0 +1,372 @@
+/*
+ * 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.xacml.admin.view.components;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.jpa.Attribute;
+import org.apache.openaz.xacml.admin.jpa.Category;
+import org.apache.openaz.xacml.admin.jpa.Datatype;
+import org.apache.openaz.xacml.admin.util.JPAUtils;
+import org.apache.openaz.xacml.admin.view.events.AttributeChangedEventListener;
+import org.apache.openaz.xacml.admin.view.events.AttributeChangedEventNotifier;
+import org.apache.openaz.xacml.api.XACML3;
+import com.vaadin.addon.jpacontainer.JPAContainer;
+import com.vaadin.addon.jpacontainer.provider.CachingLocalEntityProvider;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+
+public class AttributeSimpleCreatorComponent extends CustomComponent implements AttributeChangedEventNotifier {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private HorizontalLayout horizontalLayout_1;
+ @AutoGenerated
+ private Table tableDatatype;
+ @AutoGenerated
+ private Table tableCategory;
+ @AutoGenerated
+ private TextField textFieldContextPath;
+ @AutoGenerated
+ private TextField textFieldAttributeId;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private final AttributeSimpleCreatorComponent self = this;
+ private final Datatype datatype;
+ private final Attribute attribute;
+ private final BasicNotifier notifier = new BasicNotifier();
+ private static final JPAContainer<Category> categories = new JPAContainer<Category>(Category.class);
+ private static final JPAContainer<Datatype> datatypes = new JPAContainer<Datatype>(Datatype.class);
+ static {
+ categories.setEntityProvider(new CachingLocalEntityProvider<Category>(Category.class, ((XacmlAdminUI)UI.getCurrent()).getEntityManager()));
+ datatypes.setEntityProvider(new CachingLocalEntityProvider<Datatype>(Datatype.class, ((XacmlAdminUI)UI.getCurrent()).getEntityManager()));
+ categories.sort(new String[]{"xacmlId"}, new boolean[]{true});
+ datatypes.sort(new String[]{"xacmlId"}, new boolean[]{true});
+ }
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public AttributeSimpleCreatorComponent(Datatype datatype, Attribute initialAttribute) {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+ //
+ // Save
+ //
+ this.datatype = datatype;
+ this.attribute = initialAttribute;
+ //
+ // Initialize GUI
+ //
+ this.initializeCategories();
+ this.initializeDatatypes();
+ this.initializeAttributeId();
+ //
+ // Focus
+ //
+ this.textFieldAttributeId.focus();
+ }
+
+ private void initializeCategories() {
+ //
+ // Remove any filters
+ //
+ AttributeSimpleCreatorComponent.categories.removeAllContainerFilters();
+ //
+ // Initialize data source & GUI properties
+ //
+ this.tableCategory.setContainerDataSource(AttributeSimpleCreatorComponent.categories);
+ this.tableCategory.setVisibleColumns(new Object[] {"xacmlId"});
+ this.tableCategory.setColumnHeaders(new String[] {"XACML ID"});
+ this.tableCategory.setImmediate(true);
+ this.tableCategory.setNullSelectionAllowed(false);
+ this.tableCategory.setPageLength(10);
+ this.tableCategory.setSelectable(true);
+ //
+ // Default selection
+ //
+ Category defaultCategory;
+ if (this.attribute == null || this.attribute.getCategoryBean() == null || this.attribute.getCategoryBean().getIdentifer() == null) {
+ defaultCategory = JPAUtils.findCategory(XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT);
+ assert defaultCategory != null;
+ } else {
+ defaultCategory = JPAUtils.findCategory(this.attribute.getCategoryBean().getIdentifer());
+ }
+ if (defaultCategory != null) {
+ this.tableCategory.select(defaultCategory.getId());
+ }
+ //
+ // Respond to changes
+ //
+ this.tableCategory.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ self.fireAttributeChanged(self.getAttribute());
+ }
+ });
+ }
+
+ private void initializeDatatypes() {
+ //
+ // Remove any filters
+ //
+ AttributeSimpleCreatorComponent.datatypes.removeAllContainerFilters();
+ //
+ // Initialize data source & GUI properties
+ //
+ this.tableDatatype.setContainerDataSource(AttributeSimpleCreatorComponent.datatypes);
+ this.tableDatatype.setVisibleColumns(new Object[] {"xacmlId", "shortName"});
+ this.tableDatatype.setColumnHeaders(new String[] {"Data Type ID", "Data Type"});
+ this.tableDatatype.setNullSelectionAllowed(false);
+ this.tableDatatype.setImmediate(true);
+ this.tableDatatype.setPageLength(10);
+ //
+ // Are we restricted to a certain datatype?
+ //
+ if (this.datatype != null) {
+ //
+ // Datatype restricted
+ //
+ this.tableDatatype.select(this.datatype.getId());
+ this.tableDatatype.setEnabled(false);
+ return;
+ }
+ this.tableDatatype.setSelectable(true);
+ //
+ // Do we have a default value?
+ //
+ Datatype defaultDatatype;
+ if (this.attribute != null && this.attribute.getDatatypeBean() != null) {
+ defaultDatatype = this.attribute.getDatatypeBean();
+ } else {
+ defaultDatatype = JPAUtils.findDatatype(XACML3.ID_DATATYPE_STRING);
+ }
+ if (defaultDatatype != null) {
+ this.tableDatatype.select(defaultDatatype.getId());
+ }
+ //
+ // Respond to changes
+ //
+ this.tableDatatype.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ self.fireAttributeChanged(self.getAttribute());
+ }
+ });
+ }
+
+ private void initializeAttributeId() {
+ this.textFieldAttributeId.setImmediate(true);
+ this.textFieldAttributeId.setNullRepresentation("");
+ if (this.attribute == null) {
+ this.textFieldAttributeId.setValue(XacmlAdminUI.getDomain());
+ } else {
+ //
+ // Set the ID
+ //
+ this.textFieldAttributeId.setValue(this.attribute.getXacmlId());
+ //
+ // Is it an attribute selector?
+ //
+ if (this.attribute.isDesignator()) {
+ this.textFieldContextPath.setVisible(false);
+ this.textFieldContextPath.setRequired(false);
+ } else {
+ this.textFieldAttributeId.setCaption("Context Selector Id");
+ this.textFieldAttributeId.setRequired(false);
+ this.textFieldContextPath.setVisible(true);
+ this.textFieldContextPath.setValue(this.attribute.getSelectorPath());
+ this.textFieldContextPath.setRequired(true);
+ this.textFieldContextPath.setRequiredError("You must have a context path for a selector.");
+ this.textFieldContextPath.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ self.fireAttributeChanged(self.getAttribute());
+ }
+ });
+ }
+ }
+ //
+ // Respond to changes
+ //
+ this.textFieldAttributeId.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ self.fireAttributeChanged(self.getAttribute());
+ }
+ });
+ }
+
+ @Override
+ public Attribute getAttribute() {
+ try {
+ this.textFieldAttributeId.commit();
+ } catch (Exception e) { //NOPMD
+ // TODO - Handle, Log or NOPMD
+ // TODO - Will vaadin display error?
+ }
+ Attribute attribute = new Attribute(this.textFieldAttributeId.getValue());
+ attribute.setSelectorPath(this.textFieldContextPath.getValue());
+ Object categoryId = this.tableCategory.getValue();
+ if (categoryId != null) {
+ attribute.setCategoryBean(AttributeSimpleCreatorComponent.categories.getItem(categoryId).getEntity());
+ }
+ if (this.datatype != null) {
+ attribute.setDatatypeBean(this.datatype);
+ } else {
+ Object datatypeId = this.tableDatatype.getValue();
+ if (datatypeId == null) {
+ return null;
+ }
+ attribute.setDatatypeBean(AttributeSimpleCreatorComponent.datatypes.getItem(datatypeId).getEntity());
+ }
+ return attribute;
+ }
+
+ @Override
+ public boolean addListener(AttributeChangedEventListener listener) {
+ return this.notifier.addListener(listener);
+ }
+
+ @Override
+ public boolean removeListener(AttributeChangedEventListener listener) {
+ return this.notifier.removeListener(listener);
+ }
+
+ @Override
+ public void commit() {
+ try {
+ this.textFieldAttributeId.commit();
+ this.textFieldContextPath.commit();
+ this.tableCategory.commit();
+ this.tableDatatype.commit();
+ } catch (Exception e) { //NOPMD
+ // TODO - Handle, Log or NOPMD
+ // TODO - Will vaadin display error?
+ }
+ }
+
+ @Override
+ public void fireAttributeChanged(Attribute attribute) {
+ this.notifier.fireAttributeChanged(attribute);
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // textFieldAttributeId
+ textFieldAttributeId = new TextField();
+ textFieldAttributeId.setCaption("Attribute Id");
+ textFieldAttributeId.setImmediate(false);
+ textFieldAttributeId.setWidth("100.0%");
+ textFieldAttributeId.setHeight("-1px");
+ textFieldAttributeId.setInvalidAllowed(false);
+ textFieldAttributeId.setRequired(true);
+ mainLayout.addComponent(textFieldAttributeId);
+ mainLayout.setExpandRatio(textFieldAttributeId, 1.0f);
+
+ // textFieldContextPath
+ textFieldContextPath = new TextField();
+ textFieldContextPath.setCaption("Context Path");
+ textFieldContextPath.setImmediate(false);
+ textFieldContextPath.setDescription("The Selector's Context Path.");
+ textFieldContextPath.setWidth("100.0%");
+ textFieldContextPath.setHeight("-1px");
+ textFieldContextPath
+ .setInputPrompt("eg. md:record/md:patient/md:patient-number/text()");
+ mainLayout.addComponent(textFieldContextPath);
+ mainLayout.setExpandRatio(textFieldContextPath, 1.0f);
+
+ // horizontalLayout_1
+ horizontalLayout_1 = buildHorizontalLayout_1();
+ mainLayout.addComponent(horizontalLayout_1);
+ mainLayout.setExpandRatio(horizontalLayout_1, 1.0f);
+
+ return mainLayout;
+ }
+
+ @AutoGenerated
+ private HorizontalLayout buildHorizontalLayout_1() {
+ // common part: create layout
+ horizontalLayout_1 = new HorizontalLayout();
+ horizontalLayout_1.setImmediate(false);
+ horizontalLayout_1.setWidth("-1px");
+ horizontalLayout_1.setHeight("-1px");
+ horizontalLayout_1.setMargin(false);
+ horizontalLayout_1.setSpacing(true);
+
+ // tableCategory
+ tableCategory = new Table();
+ tableCategory.setCaption("Choose Category");
+ tableCategory.setImmediate(false);
+ tableCategory.setWidth("-1px");
+ tableCategory.setHeight("-1px");
+ tableCategory.setInvalidAllowed(false);
+ tableCategory.setRequired(true);
+ horizontalLayout_1.addComponent(tableCategory);
+
+ // tableDatatype
+ tableDatatype = new Table();
+ tableDatatype.setCaption("Choose Data Type");
+ tableDatatype.setImmediate(false);
+ tableDatatype.setWidth("-1px");
+ tableDatatype.setHeight("-1px");
+ tableDatatype.setInvalidAllowed(false);
+ tableDatatype.setRequired(true);
+ horizontalLayout_1.addComponent(tableDatatype);
+
+ return horizontalLayout_1;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/AttributeStandardSelectorComponent.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/AttributeStandardSelectorComponent.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/AttributeStandardSelectorComponent.java
new file mode 100644
index 0000000..a3fded5
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/AttributeStandardSelectorComponent.java
@@ -0,0 +1,414 @@
+/*
+ * 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.xacml.admin.view.components;
+
+import java.io.Serializable;
+import java.util.Set;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.jpa.Attribute;
+import org.apache.openaz.xacml.admin.jpa.Category;
+import org.apache.openaz.xacml.admin.jpa.Datatype;
+import org.apache.openaz.xacml.admin.util.JPAUtils;
+import org.apache.openaz.xacml.admin.util.XACMLConstants;
+import org.apache.openaz.xacml.admin.view.events.AttributeChangedEventListener;
+import org.apache.openaz.xacml.admin.view.events.AttributeChangedEventNotifier;
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.api.XACML3;
+import com.vaadin.addon.jpacontainer.JPAContainer;
+import com.vaadin.addon.jpacontainer.provider.CachingLocalEntityProvider;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.util.BeanItem;
+import com.vaadin.data.util.BeanItemContainer;
+import com.vaadin.ui.AbstractSelect.ItemCaptionMode;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+
+public class AttributeStandardSelectorComponent extends CustomComponent implements AttributeChangedEventNotifier {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private HorizontalLayout horizontalLayout_2;
+ @AutoGenerated
+ private Table tableDatatypes;
+ @AutoGenerated
+ private Table tableAttributes;
+ @AutoGenerated
+ private ComboBox comboBoxCategories;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public class AttributeBean implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private Identifier attributeId;
+ private Identifier categoryId;
+
+ public AttributeBean(Identifier category, Identifier id) {
+ this.categoryId = category;
+ this.attributeId = id;
+ }
+ public Identifier getAttributeId() {
+ return attributeId;
+ }
+ public void setAttributeId(Identifier attributeId) {
+ this.attributeId = attributeId;
+ }
+ public Identifier getCategoryId() {
+ return categoryId;
+ }
+ public void setCategoryId(Identifier categoryId) {
+ this.categoryId = categoryId;
+ }
+ @Override
+ public String toString() {
+ return this.attributeId.stringValue();
+ }
+
+ }
+ private final AttributeStandardSelectorComponent self = this;
+ private final Datatype datatype;
+ private final Attribute attribute;
+ private final BasicNotifier notifier = new BasicNotifier();
+ private static final JPAContainer<Category> categories = new JPAContainer<Category>(Category.class);
+ private static final JPAContainer<Datatype> datatypes = new JPAContainer<Datatype>(Datatype.class);
+ static {
+ categories.setEntityProvider(new CachingLocalEntityProvider<Category>(Category.class, ((XacmlAdminUI)UI.getCurrent()).getEntityManager()));
+ datatypes.setEntityProvider(new CachingLocalEntityProvider<Datatype>(Datatype.class, ((XacmlAdminUI)UI.getCurrent()).getEntityManager()));
+ categories.sort(new String[]{"xacmlId"}, new boolean[]{true});
+ datatypes.sort(new String[]{"xacmlId"}, new boolean[]{true});
+ }
+ private BeanItemContainer<AttributeBean> container = new BeanItemContainer<AttributeBean>(AttributeBean.class);
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public AttributeStandardSelectorComponent(Datatype datatype, Attribute initialAttribute) {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+ //
+ // Save
+ //
+ this.datatype = datatype;
+ this.attribute = initialAttribute;
+ //
+ // Initialize GUI
+ //
+ this.initializeCategories();
+ this.initializeAttributes();
+ this.initializeDatatypes();
+ //
+ // Initialize focus
+ //
+ this.tableAttributes.focus();
+ }
+
+ private void initializeCategories() {
+ //
+ // Remove any filters
+ //
+ AttributeStandardSelectorComponent.categories.removeAllContainerFilters();
+ //
+ // Initialize data source & GUI properties
+ //
+ this.comboBoxCategories.setContainerDataSource(AttributeStandardSelectorComponent.categories);
+ this.comboBoxCategories.setItemCaptionMode(ItemCaptionMode.PROPERTY);
+ this.comboBoxCategories.setItemCaptionPropertyId("xacmlId");
+ this.comboBoxCategories.setImmediate(true);
+ this.comboBoxCategories.setNullSelectionAllowed(false);
+ //
+ // Set default selection
+ //
+ Category defaultCategory;
+ if (this.attribute == null || this.attribute.getCategoryBean() == null) {
+ defaultCategory = JPAUtils.findCategory(XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT);
+ } else {
+ defaultCategory = this.attribute.getCategoryBean();
+ }
+ if (defaultCategory != null) {
+ this.comboBoxCategories.select(defaultCategory.getId());
+ }
+ //
+ // Respond to events
+ //
+ this.comboBoxCategories.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ self.setupAttributeIDs();
+ self.fireAttributeChanged(self.getAttribute());
+ }
+ });
+ }
+
+ private void initializeAttributes() {
+ //
+ // Initialize GUI properties
+ //
+ this.tableAttributes.setImmediate(true);
+ this.tableAttributes.setNullSelectionAllowed(false);
+ this.tableAttributes.setPageLength(10);
+ //
+ // Setup
+ //
+ this.tableAttributes.setContainerDataSource(this.container);
+ this.tableAttributes.setVisibleColumns(new Object[] {"attributeId"});
+ this.tableAttributes.setColumnHeaders(new String[] {"Attribute Id"});
+ this.tableAttributes.setSelectable(true);
+ this.setupAttributeIDs();
+ //
+ // Respond
+ //
+ this.tableAttributes.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ self.fireAttributeChanged(self.getAttribute());
+ }
+ });
+ }
+
+ private void initializeDatatypes() {
+ //
+ // Remove any filters
+ //
+ AttributeStandardSelectorComponent.datatypes.removeAllContainerFilters();
+ //
+ // Initialize data source & GUI properties
+ //
+ this.tableDatatypes.setContainerDataSource(AttributeStandardSelectorComponent.datatypes);
+ this.tableDatatypes.setVisibleColumns(new Object[] {"shortName", "xacmlId"});
+ this.tableDatatypes.setColumnHeaders(new String[] {"Short Name", "XACML Data Type ID"});
+ this.tableDatatypes.setImmediate(true);
+ this.tableDatatypes.setNullSelectionAllowed(false);
+ this.tableDatatypes.setPageLength(10);
+ //
+ // Are we restricted to a certain datatype?
+ //
+ if (this.datatype != null) {
+ //
+ // Datatype restricted
+ //
+ this.tableDatatypes.select(this.datatype.getId());
+ this.tableDatatypes.setEnabled(false);
+ return;
+ }
+ this.tableDatatypes.setSelectable(true);
+ //
+ // Select a default
+ //
+ Datatype defaultDatatype;
+ if (this.attribute == null || this.attribute.getDatatypeBean() == null) {
+ defaultDatatype = JPAUtils.findDatatype(XACML3.ID_DATATYPE_STRING);
+ } else {
+ defaultDatatype = this.attribute.getDatatypeBean();
+ }
+ if (defaultDatatype != null) {
+ this.tableDatatypes.select(defaultDatatype.getId());
+ }
+ //
+ // Respond to events
+ //
+ this.tableDatatypes.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ self.fireAttributeChanged(self.getAttribute());
+ }
+ });
+ }
+
+ private void setupAttributeIDs() {
+ //
+ // Get the current selection (should NOT be null)
+ //
+ Object id = this.comboBoxCategories.getValue();
+ Category category = AttributeStandardSelectorComponent.categories.getItem(id).getEntity();
+ Set<Identifier> attributeIDs = null;
+ if (category.isStandard()) {
+ //
+ // Get the subset of attribute ID's specific to this standard
+ // category.
+ //
+ attributeIDs = XACMLConstants.MAP_STANDARD_CATEGORIES.get(category.getIdentifer());
+ }
+ if (attributeIDs == null) {
+ //
+ // A custom category, there are no default attribute IDs
+ // that we can determine.
+ //
+ attributeIDs = XACMLConstants.STANDARD_ATTRIBUTES;
+ }
+ //
+ // Reset attribute IDs. Based on the category, add only acceptable
+ // attribute ID's for the category.
+ //
+ Object defaultBean = null;
+ this.tableAttributes.removeAllItems();
+ for (Identifier attributeId : attributeIDs) {
+ BeanItem<AttributeBean> newItem = this.container.addItem(new AttributeBean(category.getIdentifer(), attributeId));
+ if (this.attribute == null) {
+ if (attributeId.equals(XACML3.ID_SUBJECT_SUBJECT_ID) ||
+ attributeId.equals(XACML3.ID_ACTION_ACTION_ID) ||
+ attributeId.equals(XACML3.ID_RESOURCE_RESOURCE_ID) ||
+ attributeId.equals(XACML3.ID_ENVIRONMENT_CURRENT_DATE)) {
+ defaultBean = newItem.getBean();
+ }
+ } else {
+ if (newItem.getBean().getAttributeId().stringValue().equals(this.attribute.getXacmlId())) {
+ defaultBean = newItem.getBean();
+ }
+ }
+ }
+ //
+ // Set the default selection
+ //
+ if (defaultBean != null) {
+ this.tableAttributes.select(defaultBean);
+ }
+ }
+
+ @Override
+ public void commit() {
+ this.comboBoxCategories.commit();
+ this.tableAttributes.commit();
+ this.tableDatatypes.commit();
+ }
+
+ @Override
+ public Attribute getAttribute() {
+ Object categoryId = this.comboBoxCategories.getValue();
+ Object attributeId = this.tableAttributes.getValue();
+ Object datatypeId = this.tableDatatypes.getValue();
+ if (attributeId == null || datatypeId == null || categoryId == null) {
+ return null;
+ }
+ AttributeBean attributeBean = this.container.getItem(attributeId).getBean();
+ Datatype datatype = AttributeStandardSelectorComponent.datatypes.getItem(datatypeId).getEntity();
+ Category category = AttributeStandardSelectorComponent.categories.getItem(categoryId).getEntity();
+ if (datatype == null || category == null) {
+ return null;
+ }
+ Attribute attribute = new Attribute(attributeBean.getAttributeId().stringValue());
+ attribute.setCategoryBean(category);
+ attribute.setDatatypeBean(datatype);
+
+ return attribute;
+ }
+
+ @Override
+ public boolean addListener(AttributeChangedEventListener listener) {
+ return this.notifier.addListener(listener);
+ }
+
+ @Override
+ public boolean removeListener(AttributeChangedEventListener listener) {
+ return this.notifier.removeListener(listener);
+ }
+
+ @Override
+ public void fireAttributeChanged(Attribute attribute) {
+ this.notifier.fireAttributeChanged(attribute);
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(false);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // comboBoxCategories
+ comboBoxCategories = new ComboBox();
+ comboBoxCategories.setCaption("Select A Category");
+ comboBoxCategories.setImmediate(false);
+ comboBoxCategories.setWidth("-1px");
+ comboBoxCategories.setHeight("-1px");
+ comboBoxCategories.setInvalidAllowed(false);
+ comboBoxCategories.setRequired(true);
+ mainLayout.addComponent(comboBoxCategories);
+ mainLayout.setExpandRatio(comboBoxCategories, 1.0f);
+
+ // horizontalLayout_2
+ horizontalLayout_2 = buildHorizontalLayout_2();
+ mainLayout.addComponent(horizontalLayout_2);
+ mainLayout.setExpandRatio(horizontalLayout_2, 1.0f);
+
+ return mainLayout;
+ }
+
+ @AutoGenerated
+ private HorizontalLayout buildHorizontalLayout_2() {
+ // common part: create layout
+ horizontalLayout_2 = new HorizontalLayout();
+ horizontalLayout_2.setImmediate(false);
+ horizontalLayout_2.setWidth("-1px");
+ horizontalLayout_2.setHeight("-1px");
+ horizontalLayout_2.setMargin(false);
+ horizontalLayout_2.setSpacing(true);
+
+ // tableAttributes
+ tableAttributes = new Table();
+ tableAttributes.setCaption("Standard Attributes");
+ tableAttributes.setImmediate(false);
+ tableAttributes.setWidth("-1px");
+ tableAttributes.setHeight("-1px");
+ tableAttributes.setInvalidAllowed(false);
+ tableAttributes.setRequired(true);
+ horizontalLayout_2.addComponent(tableAttributes);
+
+ // tableDatatypes
+ tableDatatypes = new Table();
+ tableDatatypes.setCaption("Standard Data Types");
+ tableDatatypes.setImmediate(false);
+ tableDatatypes.setWidth("-1px");
+ tableDatatypes.setHeight("-1px");
+ tableDatatypes.setInvalidAllowed(false);
+ tableDatatypes.setRequired(true);
+ horizontalLayout_2.addComponent(tableDatatypes);
+
+ return horizontalLayout_2;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/CSVPIPConfigurationComponent.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/CSVPIPConfigurationComponent.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/CSVPIPConfigurationComponent.java
new file mode 100644
index 0000000..ab466b0
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/CSVPIPConfigurationComponent.java
@@ -0,0 +1,385 @@
+/*
+ * 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.xacml.admin.view.components;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.jpa.PIPConfigParam;
+import org.apache.openaz.xacml.admin.jpa.PIPConfiguration;
+import org.apache.openaz.xacml.admin.view.events.FormChangedEventListener;
+import org.apache.openaz.xacml.admin.view.events.FormChangedEventNotifier;
+import org.apache.openaz.xacml.std.pip.engines.csv.CSVEngine;
+import com.vaadin.addon.jpacontainer.EntityItem;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Buffered.SourceException;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.data.util.converter.StringToIntegerConverter;
+import com.vaadin.event.FieldEvents.TextChangeEvent;
+import com.vaadin.event.FieldEvents.TextChangeListener;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+public class CSVPIPConfigurationComponent extends CustomComponent implements FormChangedEventNotifier {
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+
+ @AutoGenerated
+ private TextField textFieldSkip;
+
+ @AutoGenerated
+ private TextField textFieldQuote;
+
+ @AutoGenerated
+ private TextField textFieldDelimiter;
+
+ @AutoGenerated
+ private TextField textFieldFile;
+
+ public static String CLASSNAME = "org.apache.openaz.xacml.std.pip.engines.csv.CSVEngine";
+
+
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static final Log logger = LogFactory.getLog(CSVPIPConfigurationComponent.class);
+ private final CSVPIPConfigurationComponent self = this;
+ private final BasicNotifier notifier = new BasicNotifier();
+ private final EntityItem<PIPConfiguration> entity;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ * @param entityConfig
+ * @param configParamField
+ */
+ public CSVPIPConfigurationComponent(EntityItem<PIPConfiguration> entityConfig) {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+ //
+ // Save
+ //
+ this.entity = entityConfig;
+ //
+ // initialize
+ //
+ this.initialize();
+ //
+ // Focus
+ //
+ this.textFieldFile.focus();
+ }
+
+ protected void initialize() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("initializing " + this.entity.getEntity().toString());
+ }
+ //
+ // What are our current values?
+ //
+ Set<PIPConfigParam> unneeded = new HashSet<PIPConfigParam>();
+ for (PIPConfigParam param : this.entity.getEntity().getPipconfigParams()) {
+ if (param.getParamName().equals(CSVEngine.PROP_SOURCE)) {
+ this.textFieldFile.setData(param);
+ } else if (param.getParamName().equals(CSVEngine.PROP_DELIMITER)) {
+ this.textFieldDelimiter.setData(param);
+ } else if (param.getParamName().equals(CSVEngine.PROP_QUOTE)) {
+ this.textFieldQuote.setData(param);
+ } else if (param.getParamName().equals(CSVEngine.PROP_SKIP)) {
+ this.textFieldSkip.setData(param);
+ } else {
+ unneeded.add(param);
+ }
+ }
+ if (unneeded.isEmpty() == false) {
+ this.entity.getEntity().getPipconfigParams().removeAll(unneeded);
+ }
+ //
+ //
+ //
+ this.initializeEntity();
+ this.initializeText();
+ }
+
+ protected void initializeEntity() {
+ //
+ // Initialize the entity
+ //
+ this.entity.getEntity().setClassname(CLASSNAME);
+ this.entity.getEntity().setRequiresResolvers(true);
+ }
+
+ protected void initializeText() {
+ //
+ //
+ //
+ this.textFieldFile.setRequired(true);
+ this.textFieldFile.setRequiredError("You need to specify a path to the CSV file on the server.");
+ this.textFieldFile.setImmediate(true);
+ this.textFieldFile.setNullRepresentation("");
+ //
+ //
+ //
+ PIPConfigParam param = (PIPConfigParam) this.textFieldFile.getData();
+ if (param != null) {
+ this.textFieldFile.setValue(param.getParamValue());
+ }
+ this.textFieldFile.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldFile.getData();
+ if (param == null) {
+ param = new PIPConfigParam(CSVEngine.PROP_SOURCE);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldFile.setData(param);
+ }
+ param.setParamValue(self.textFieldFile.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ this.textFieldFile.addTextChangeListener(new TextChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void textChange(TextChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldFile.getData();
+ if (param == null) {
+ param = new PIPConfigParam(CSVEngine.PROP_SOURCE);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldFile.setData(param);
+ }
+ param.setParamValue(self.textFieldFile.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ //
+ //
+ //
+ this.textFieldDelimiter.setNullRepresentation("");
+ param = (PIPConfigParam) this.textFieldDelimiter.getData();
+ if (param != null) {
+ this.textFieldDelimiter.setValue(param.getParamValue());
+ }
+ this.textFieldDelimiter.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldDelimiter.getData();
+ if (param == null) {
+ param = new PIPConfigParam(CSVEngine.PROP_DELIMITER);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldDelimiter.setData(param);
+ }
+ param.setParamValue(self.textFieldDelimiter.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ //
+ //
+ //
+ this.textFieldQuote.setNullRepresentation("");
+ param = (PIPConfigParam) this.textFieldQuote.getData();
+ if (param != null) {
+ this.textFieldQuote.setValue(param.getParamValue());
+ }
+ this.textFieldQuote.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldQuote.getData();
+ if (param == null) {
+ param = new PIPConfigParam(CSVEngine.PROP_QUOTE);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldQuote.setData(param);
+ }
+ param.setParamValue(self.textFieldQuote.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ //
+ //
+ //
+ this.textFieldSkip.setNullRepresentation("");
+ param = (PIPConfigParam) this.textFieldSkip.getData();
+ if (param != null) {
+ this.textFieldSkip.setValue(param.getParamValue());
+ }
+ this.textFieldSkip.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldSkip.getData();
+ if (param == null) {
+ param = new PIPConfigParam(CSVEngine.PROP_SKIP);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldSkip.setData(param);
+ }
+ param.setParamValue(self.textFieldSkip.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ this.textFieldSkip.setConverter(new StringToIntegerConverter());
+ }
+
+ public void validate() throws InvalidValueException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("validate");
+ }
+ this.textFieldFile.validate();
+ this.textFieldDelimiter.validate();
+ this.textFieldQuote.validate();
+ this.textFieldSkip.validate();
+ }
+
+ public void commit() throws SourceException, InvalidValueException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("commit");
+ }
+ this.textFieldFile.commit();
+ this.textFieldDelimiter.commit();
+ this.textFieldQuote.commit();
+
+ if (this.textFieldSkip.getValue() == null || this.textFieldSkip.getValue().isEmpty()) {
+ this.entity.getEntity().removePipconfigParam((PIPConfigParam) this.textFieldSkip.getData());
+ this.textFieldSkip.setData(null);
+ }
+ this.textFieldSkip.commit();
+ }
+
+ public void discard() throws SourceException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("discard");
+ }
+ this.textFieldFile.discard();
+ this.textFieldDelimiter.discard();
+ this.textFieldQuote.discard();
+ this.textFieldSkip.discard();
+
+ this.entity.getEntity().getPipconfigParams().remove(CSVEngine.PROP_SOURCE);
+ this.entity.getEntity().getPipconfigParams().remove(CSVEngine.PROP_DELIMITER);
+ this.entity.getEntity().getPipconfigParams().remove(CSVEngine.PROP_QUOTE);
+ this.entity.getEntity().getPipconfigParams().remove(CSVEngine.PROP_SKIP);
+ this.entity.getEntity().getPipconfigParams().remove(CSVEngine.PROP_MAXSIZE);
+ }
+
+ @Override
+ public boolean addListener(FormChangedEventListener listener) {
+ return this.notifier.addListener(listener);
+ }
+
+ @Override
+ public boolean removeListener(FormChangedEventListener listener) {
+ return this.notifier.removeListener(listener);
+ }
+
+ @Override
+ public void fireFormChangedEvent() {
+ this.notifier.fireFormChangedEvent();
+ }
+
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // textFieldFile
+ textFieldFile = new TextField();
+ textFieldFile.setCaption("Path to CSV File");
+ textFieldFile.setImmediate(false);
+ textFieldFile
+ .setDescription("This is the path to CSV file on the PDP node.");
+ textFieldFile.setWidth("-1px");
+ textFieldFile.setHeight("-1px");
+ textFieldFile.setInvalidAllowed(false);
+ textFieldFile.setRequired(true);
+ textFieldFile
+ .setInputPrompt("Eg. \"c:\\data.csv\" \"http://foo.com/data.csv\"");
+ mainLayout.addComponent(textFieldFile);
+ mainLayout.setExpandRatio(textFieldFile, 1.0f);
+
+ // textFieldDelimiter
+ textFieldDelimiter = new TextField();
+ textFieldDelimiter.setCaption("Delimiter");
+ textFieldDelimiter.setImmediate(false);
+ textFieldDelimiter
+ .setDescription("Enter a separator character or string that delineates columns in each row.");
+ textFieldDelimiter.setWidth("-1px");
+ textFieldDelimiter.setHeight("-1px");
+ textFieldDelimiter.setInputPrompt("Eg. \",\" or \"|\"");
+ textFieldDelimiter.setNullSettingAllowed(true);
+ mainLayout.addComponent(textFieldDelimiter);
+ mainLayout.setExpandRatio(textFieldDelimiter, 1.0f);
+
+ // textFieldQuote
+ textFieldQuote = new TextField();
+ textFieldQuote.setCaption("Quote");
+ textFieldQuote.setImmediate(false);
+ textFieldQuote
+ .setDescription("Enter character used for quoted elements.");
+ textFieldQuote.setWidth("-1px");
+ textFieldQuote.setHeight("-1px");
+ textFieldQuote.setInputPrompt("Eg. \" or '");
+ textFieldQuote.setNullSettingAllowed(true);
+ mainLayout.addComponent(textFieldQuote);
+
+ // textFieldSkip
+ textFieldSkip = new TextField();
+ textFieldSkip.setCaption("Skip Lines");
+ textFieldSkip.setImmediate(false);
+ textFieldSkip
+ .setDescription("Skips the number of lines at the beginning of the file.");
+ textFieldSkip.setWidth("-1px");
+ textFieldSkip.setHeight("-1px");
+ textFieldSkip.setInputPrompt("Eg. 1 or 2");
+ mainLayout.addComponent(textFieldSkip);
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/CustomPIPConfigurationComponent.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/CustomPIPConfigurationComponent.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/CustomPIPConfigurationComponent.java
new file mode 100644
index 0000000..043cba7
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/CustomPIPConfigurationComponent.java
@@ -0,0 +1,200 @@
+/*
+ * 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.xacml.admin.view.components;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.jpa.PIPConfiguration;
+import org.apache.openaz.xacml.admin.jpa.PIPResolver;
+import org.apache.openaz.xacml.admin.view.events.FormChangedEventListener;
+import org.apache.openaz.xacml.admin.view.events.FormChangedEventNotifier;
+import com.vaadin.addon.jpacontainer.EntityItem;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Buffered.SourceException;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+public class CustomPIPConfigurationComponent extends CustomComponent implements FormChangedEventNotifier {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private PIPParameterComponent pipParameterComponent;
+ @AutoGenerated
+ private TextField textFieldClassname;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private final EntityItem<?> entity;
+ private static final Log logger = LogFactory.getLog(CustomPIPConfigurationComponent.class);
+ private final CustomPIPConfigurationComponent self = this;
+ private final BasicNotifier notifier = new BasicNotifier();
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ * @param configParamField
+ */
+ public CustomPIPConfigurationComponent(EntityItem<PIPConfiguration> entityConfig) {
+ //
+ // Save
+ //
+ this.entity = entityConfig;
+
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+ //
+ // InitializeGUI
+ //
+ this.initialize();
+ }
+
+ protected void initialize() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("initializing " + this.entity.getEntity().toString());
+ }
+ this.initializeEntity();
+ this.initializeText();
+ }
+
+ protected void initializeEntity() {
+ //
+ // If the entity is persisted, then we are editing
+ // it. So don't remove anything.
+ //
+ if (this.entity.isPersistent()) {
+ return;
+ }
+ //
+ // Not sure if we really should remove stuff. To be
+ // determined later.
+ //
+ }
+
+ protected void initializeText() {
+ this.textFieldClassname.setRequired(true);
+ this.textFieldClassname.setRequiredError("You must declare the Java classname for the PIP Factory Loader");
+ this.textFieldClassname.setImmediate(true);
+ final Object entity = this.entity.getEntity();
+ if (entity instanceof PIPConfiguration) {
+ this.textFieldClassname.setValue(((PIPConfiguration)entity).getClassname());
+ } else if (entity instanceof PIPResolver) {
+ this.textFieldClassname.setValue(((PIPResolver)entity).getClassname());
+ }
+ //
+ // Respond to events
+ //
+ this.textFieldClassname.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ if (entity instanceof PIPConfiguration) {
+ ((PIPConfiguration) entity).setClassname(self.textFieldClassname.getValue());
+ } else if (entity instanceof PIPResolver) {
+ ((PIPResolver) entity).setClassname(self.textFieldClassname.getValue());
+ }
+ self.fireFormChangedEvent();
+ }
+ });
+ }
+
+ public void validate() throws InvalidValueException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("validate");
+ }
+ this.textFieldClassname.validate();
+ }
+
+ public void commit() throws SourceException, InvalidValueException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("commit");
+ }
+ this.textFieldClassname.commit();
+ }
+
+ public void discard() throws SourceException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("discard");
+ }
+ }
+
+ @Override
+ public boolean addListener(FormChangedEventListener listener) {
+ return this.notifier.addListener(listener);
+ }
+
+ @Override
+ public boolean removeListener(FormChangedEventListener listener) {
+ return this.notifier.removeListener(listener);
+ }
+
+ @Override
+ public void fireFormChangedEvent() {
+ this.notifier.fireFormChangedEvent();
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(false);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // textFieldClassname
+ textFieldClassname = new TextField();
+ textFieldClassname.setCaption("Java Classname");
+ textFieldClassname.setImmediate(false);
+ textFieldClassname
+ .setDescription("Java classname of the code implementing the custom PIP.");
+ textFieldClassname.setWidth("-1px");
+ textFieldClassname.setHeight("-1px");
+ textFieldClassname.setInputPrompt("Eg. com.foo.MyPIP");
+ mainLayout.addComponent(textFieldClassname);
+ mainLayout.setExpandRatio(textFieldClassname, 1.0f);
+
+ // pipParameterComponent
+ pipParameterComponent = new PIPParameterComponent(this.entity.getEntity());
+ pipParameterComponent.setImmediate(false);
+ pipParameterComponent.setWidth("-1px");
+ pipParameterComponent.setHeight("-1px");
+ mainLayout.addComponent(pipParameterComponent);
+
+ return mainLayout;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/EnumerationEditorComponent.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/EnumerationEditorComponent.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/EnumerationEditorComponent.java
new file mode 100644
index 0000000..eafbcad
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/EnumerationEditorComponent.java
@@ -0,0 +1,386 @@
+/*
+ * 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.xacml.admin.view.components;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.jpa.Attribute;
+import org.apache.openaz.xacml.admin.jpa.ConstraintValue;
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.api.XACML3;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.Validator;
+import com.vaadin.data.util.BeanItemContainer;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Field;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TableFieldFactory;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+public class EnumerationEditorComponent extends CustomComponent implements Validator {
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+
+ @AutoGenerated
+ private HorizontalLayout horizontalLayout_1;
+
+ @AutoGenerated
+ private Button buttonClearAll;
+
+ @AutoGenerated
+ private Button buttonRemove;
+
+ @AutoGenerated
+ private Button buttonAdd;
+
+ @AutoGenerated
+ private Table tableEnumerations;
+
+ private static final long serialVersionUID = -1L;
+ private static final Log logger = LogFactory.getLog(EnumerationEditorComponent.class);
+ private final EnumerationEditorComponent self = this;
+ private final Attribute attribute;
+ private Identifier datatype;
+ private final BeanItemContainer<ConstraintValue> beanContainer;
+
+ public EnumerationEditorComponent(Attribute attribute, Identifier datatype) {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+ //
+ // Save our attribute
+ //
+ this.attribute = attribute;
+ this.datatype = datatype;
+ //
+ // Construct a bean container that the
+ // table uses to manage the values.
+ //
+ this.beanContainer = new BeanItemContainer<ConstraintValue>(ConstraintValue.class);
+ //
+ // Initialize our components
+ //
+ this.initializeTable();
+ this.initializeButtons();
+ }
+
+ private void initializeTable() {
+ //
+ // Add the current enumeration values into the
+ // bean container.
+ //
+ for (ConstraintValue value : this.attribute.getConstraintValues()) {
+ if (value.getProperty().equals("Enumeration")) {
+ this.beanContainer.addBean(value);
+ }
+ }
+ //
+ // Now hook the bean container to the table
+ //
+ this.tableEnumerations.setContainerDataSource(beanContainer);
+ //
+ // We have to manually create the text field because we need
+ // to set a validator.
+ //
+ this.tableEnumerations.setTableFieldFactory(new TableFieldFactory() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Field<?> createField(Container container, Object itemId,
+ Object propertyId, Component uiContext) {
+ if (propertyId.toString().equals("value")) {
+ final TextField text = new TextField();
+ text.setImmediate(true);
+ text.setNullRepresentation("");
+ text.setNullSettingAllowed(false);
+ text.setRequired(true);
+ text.setRequiredError("Cannot have empty enumeration values.");
+ text.addValidator(self);
+ return text;
+ }
+ return null;
+ }
+ });
+ //
+ // Finish setting up the table.
+ //
+ this.tableEnumerations.setVisibleColumns(new Object[] {"value"});
+ this.tableEnumerations.setColumnHeaders(new String[] {"Enumeration Value"});
+ this.tableEnumerations.setSelectable(true);
+ this.tableEnumerations.setEditable(true);
+ this.tableEnumerations.setImmediate(true);
+ if (this.tableEnumerations.size() == 0) {
+ this.tableEnumerations.setPageLength(3);
+ } else {
+ this.tableEnumerations.setPageLength(this.tableEnumerations.size() + 1);
+ }
+ //
+ // As the user select items, enable/disable buttons
+ //
+ this.tableEnumerations.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ self.buttonRemove.setEnabled(self.tableEnumerations.getValue() != null);
+ }
+
+ });
+ }
+
+ private void initializeButtons() {
+ //
+ // Adding new values
+ //
+ this.buttonAdd.setImmediate(true);
+ this.buttonAdd.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ //
+ // Create a new value object
+ //
+ ConstraintValue newValue = new ConstraintValue("Enumeration", "");
+ //
+ // Associate it with the attribute
+ //
+ newValue.setAttribute(self.attribute);
+ //
+ // Add it into the attribute's internal list
+ //
+ self.attribute.addConstraintValue(newValue);
+ //
+ // Now we can add it to the GUI
+ //
+ Item item = self.tableEnumerations.addItem(newValue);
+ if (item != null) {
+ self.tableEnumerations.select(newValue);
+ self.tableEnumerations.focus();
+ }
+ //
+ // Make sure this button is now enabled
+ //
+ self.buttonClearAll.setEnabled(true);
+ }
+ });
+ //
+ // Removing values - nothing is selected to begin with so
+ // disable the button.
+ //
+ this.buttonRemove.setEnabled(false);
+ this.buttonRemove.setImmediate(true);
+ this.buttonRemove.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ //
+ // Get the selected value
+ //
+ Object value = self.tableEnumerations.getValue();
+ //
+ // Was it selected or unselected (i.e. null)? If so, remove it
+ // from the table
+ //
+ if (value != null && self.tableEnumerations.removeItem(value)) {
+ //
+ // Dis-associate it with the attribute
+ //
+ ((ConstraintValue) value).setAttribute(null);
+ //
+ // Now remove it from the attribute's internal list
+ //
+ self.attribute.removeConstraintValue((ConstraintValue) value);
+ //
+ // If there are no items, then disable this button
+ //
+ if (self.tableEnumerations.size() == 0) {
+ self.buttonClearAll.setEnabled(false);
+ }
+ }
+ }
+
+ });
+ //
+ // Clearing all the values, set it enabled if we have anything
+ //
+ this.buttonClearAll.setImmediate(true);
+ this.buttonClearAll.setEnabled(this.tableEnumerations.size() > 0);
+ this.buttonClearAll.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ //
+ // Iterate all the values
+ //
+ for (Object id : self.tableEnumerations.getItemIds()) {
+ //
+ // Get the value object (it is the id)
+ //
+ ConstraintValue value = (ConstraintValue) id;
+ //
+ // Dis-associate it with the attribute
+ //
+ value.setAttribute(null);
+ //
+ // Now remove it from the attribute's internal list
+ //
+ self.attribute.removeConstraintValue(value);
+ }
+ //
+ // Remove everything from the table
+ //
+ self.tableEnumerations.removeAllItems();
+ //
+ // Now disable this button
+ //
+ self.buttonClearAll.setEnabled(false);
+ }
+ });
+ }
+
+ public void setupDatatype(Identifier id) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("setupDatatype: " + datatype);
+ }
+ this.datatype = id;
+ //
+ // Initiate a validate
+ //
+ this.tableEnumerations.validate();
+ }
+
+ @Override
+ public void validate(Object value) throws InvalidValueException {
+ if (value == null || value.toString().length() == 0) {
+ return;
+ }
+ if (datatype.equals(XACML3.ID_DATATYPE_INTEGER)) {
+ try {
+ Integer.parseInt(value.toString());
+ } catch(NumberFormatException e) {
+ throw new InvalidValueException(e.getLocalizedMessage());
+ }
+ return;
+ }
+ if (datatype.equals(XACML3.ID_DATATYPE_DOUBLE)) {
+ try {
+ Double.parseDouble(value.toString());
+ } catch(NumberFormatException e) {
+ throw new InvalidValueException(e.getLocalizedMessage());
+ }
+ return;
+ }
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // tableEnumerations
+ tableEnumerations = new Table();
+ tableEnumerations.setCaption("Enumeration Values");
+ tableEnumerations.setImmediate(true);
+ tableEnumerations
+ .setDescription("Enter possible values for the attribute.");
+ tableEnumerations.setWidth("100.0%");
+ tableEnumerations.setHeight("-1px");
+ tableEnumerations.setInvalidAllowed(false);
+ mainLayout.addComponent(tableEnumerations);
+ mainLayout.setExpandRatio(tableEnumerations, 1.0f);
+
+ // horizontalLayout_1
+ horizontalLayout_1 = buildHorizontalLayout_1();
+ mainLayout.addComponent(horizontalLayout_1);
+ mainLayout.setExpandRatio(horizontalLayout_1, 1.0f);
+
+ return mainLayout;
+ }
+
+ @AutoGenerated
+ private HorizontalLayout buildHorizontalLayout_1() {
+ // common part: create layout
+ horizontalLayout_1 = new HorizontalLayout();
+ horizontalLayout_1.setImmediate(false);
+ horizontalLayout_1.setWidth("-1px");
+ horizontalLayout_1.setHeight("-1px");
+ horizontalLayout_1.setMargin(false);
+ horizontalLayout_1.setSpacing(true);
+
+ // buttonAdd
+ buttonAdd = new Button();
+ buttonAdd.setCaption("Add");
+ buttonAdd.setImmediate(true);
+ buttonAdd.setDescription("Add a new enumeration value.");
+ buttonAdd.setWidth("-1px");
+ buttonAdd.setHeight("-1px");
+ horizontalLayout_1.addComponent(buttonAdd);
+ horizontalLayout_1.setComponentAlignment(buttonAdd, new Alignment(9));
+
+ // buttonRemove
+ buttonRemove = new Button();
+ buttonRemove.setCaption("Remove");
+ buttonRemove.setImmediate(true);
+ buttonRemove.setDescription("Remove the selected enumeration value.");
+ buttonRemove.setWidth("-1px");
+ buttonRemove.setHeight("-1px");
+ horizontalLayout_1.addComponent(buttonRemove);
+ horizontalLayout_1.setComponentAlignment(buttonRemove,
+ new Alignment(10));
+
+ // buttonClearAll
+ buttonClearAll = new Button();
+ buttonClearAll.setCaption("Clear All");
+ buttonClearAll.setImmediate(false);
+ buttonClearAll.setDescription("Clears all the values out.");
+ buttonClearAll.setWidth("-1px");
+ buttonClearAll.setHeight("-1px");
+ horizontalLayout_1.addComponent(buttonClearAll);
+
+ return horizontalLayout_1;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/HyperCSVPIPConfigurationComponent.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/HyperCSVPIPConfigurationComponent.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/HyperCSVPIPConfigurationComponent.java
new file mode 100644
index 0000000..67f7faf
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/HyperCSVPIPConfigurationComponent.java
@@ -0,0 +1,339 @@
+/*
+ * 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.xacml.admin.view.components;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.jpa.PIPConfigParam;
+import org.apache.openaz.xacml.admin.jpa.PIPConfiguration;
+import org.apache.openaz.xacml.admin.view.events.FormChangedEventListener;
+import org.apache.openaz.xacml.admin.view.events.FormChangedEventNotifier;
+import org.apache.openaz.xacml.std.pip.engines.csv.HyperCSVEngine;
+import com.vaadin.addon.jpacontainer.EntityItem;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Buffered.SourceException;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.event.FieldEvents.TextChangeEvent;
+import com.vaadin.event.FieldEvents.TextChangeListener;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+public class HyperCSVPIPConfigurationComponent extends CustomComponent implements FormChangedEventNotifier {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private TextField textFieldDefinition;
+ @AutoGenerated
+ private TextField textFieldTarget;
+ @AutoGenerated
+ private TextField textFieldSource;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ public static final String CLASSNAME = "org.apache.openaz.xacml.std.pip.engines.csv.HyperCSVEngine";
+
+ private final EntityItem<PIPConfiguration> entity;
+ private static final Log logger = LogFactory.getLog(CustomPIPConfigurationComponent.class);
+ private final HyperCSVPIPConfigurationComponent self = this;
+ private final BasicNotifier notifier = new BasicNotifier();
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public HyperCSVPIPConfigurationComponent(EntityItem<PIPConfiguration> entityConfig) {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+ //
+ // Save
+ //
+ this.entity = entityConfig;
+ //
+ // Initialize
+ //
+ this.initialize();
+ }
+
+ protected void initialize() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("initializing " + this.entity.getEntity().toString());
+ }
+ //
+ // What are our current values?
+ //
+ Set<PIPConfigParam> unneeded = new HashSet<PIPConfigParam>();
+ for (PIPConfigParam param : this.entity.getEntity().getPipconfigParams()) {
+ if (param.getParamName().equals(HyperCSVEngine.PROP_SOURCE)) {
+ this.textFieldSource.setData(param);
+ } else if (param.getParamName().equals(HyperCSVEngine.PROP_TARGET)) {
+ this.textFieldTarget.setData(param);
+ } else if (param.getParamName().equals(HyperCSVEngine.PROP_DEFINITION)) {
+ this.textFieldDefinition.setData(param);
+ } else {
+ unneeded.add(param);
+ }
+ }
+ if (unneeded.isEmpty() == false) {
+ this.entity.getEntity().getPipconfigParams().removeAll(unneeded);
+ }
+ //
+ //
+ //
+ this.initializeEntity();
+ this.initializeText();
+ }
+
+ protected void initializeEntity() {
+ //
+ // Initialize the entity
+ //
+ this.entity.getEntity().setClassname(CLASSNAME);
+ this.entity.getEntity().setRequiresResolvers(true);
+ }
+
+ protected void initializeText() {
+ //
+ //
+ //
+ this.textFieldSource.setNullRepresentation("");
+ PIPConfigParam param = (PIPConfigParam) this.textFieldSource.getData();
+ if (param != null) {
+ this.textFieldSource.setValue(param.getParamValue());
+ }
+ this.textFieldSource.addTextChangeListener(new TextChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void textChange(TextChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldSource.getData();
+ if (param == null) {
+ param = new PIPConfigParam(HyperCSVEngine.PROP_SOURCE);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldSource.setData(param);
+ }
+ param.setParamValue(self.textFieldSource.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ this.textFieldSource.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldSource.getData();
+ if (param == null) {
+ param = new PIPConfigParam(HyperCSVEngine.PROP_SOURCE);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldSource.setData(param);
+ }
+ param.setParamValue(self.textFieldSource.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ //
+ //
+ //
+ this.textFieldTarget.setNullRepresentation("");
+ param = (PIPConfigParam) this.textFieldTarget.getData();
+ if (param != null) {
+ this.textFieldTarget.setValue(param.getParamValue());
+ }
+ this.textFieldTarget.addTextChangeListener(new TextChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void textChange(TextChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldTarget.getData();
+ if (param == null) {
+ param = new PIPConfigParam(HyperCSVEngine.PROP_TARGET);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldTarget.setData(param);
+ }
+ param.setParamValue(self.textFieldTarget.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ this.textFieldTarget.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldTarget.getData();
+ if (param == null) {
+ param = new PIPConfigParam(HyperCSVEngine.PROP_TARGET);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldTarget.setData(param);
+ }
+ param.setParamValue(self.textFieldTarget.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ //
+ //
+ //
+ this.textFieldDefinition.setNullRepresentation("");
+ param = (PIPConfigParam) this.textFieldDefinition.getData();
+ if (param != null) {
+ this.textFieldDefinition.setValue(param.getParamValue());
+ }
+ this.textFieldDefinition.addTextChangeListener(new TextChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void textChange(TextChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldDefinition.getData();
+ if (param == null) {
+ param = new PIPConfigParam(HyperCSVEngine.PROP_DEFINITION);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldDefinition.setData(param);
+ }
+ param.setParamValue(self.textFieldDefinition.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ this.textFieldDefinition.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldDefinition.getData();
+ if (param == null) {
+ param = new PIPConfigParam(HyperCSVEngine.PROP_DEFINITION);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldDefinition.setData(param);
+ }
+ param.setParamValue(self.textFieldDefinition.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ }
+
+ public void validate() throws InvalidValueException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("validate");
+ }
+ this.textFieldSource.validate();
+ this.textFieldTarget.validate();
+ this.textFieldDefinition.validate();
+ }
+
+ public void commit() throws SourceException, InvalidValueException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("commit");
+ }
+ this.textFieldSource.commit();
+ this.textFieldTarget.commit();
+ this.textFieldDefinition.commit();
+ }
+
+ public void discard() throws SourceException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("discard");
+ }
+ this.textFieldSource.discard();
+ this.textFieldTarget.discard();
+ this.textFieldDefinition.discard();
+ //??
+ this.entity.getEntity().getPipconfigParams().remove(HyperCSVEngine.PROP_SOURCE);
+ this.entity.getEntity().getPipconfigParams().remove(HyperCSVEngine.PROP_TARGET);
+ this.entity.getEntity().getPipconfigParams().remove(HyperCSVEngine.PROP_DEFINITION);
+ }
+
+ @Override
+ public boolean addListener(FormChangedEventListener listener) {
+ return this.notifier.addListener(listener);
+ }
+
+ @Override
+ public boolean removeListener(FormChangedEventListener listener) {
+ return this.notifier.removeListener(listener);
+ }
+
+ @Override
+ public void fireFormChangedEvent() {
+ this.notifier.fireFormChangedEvent();
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(false);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // textFieldSource
+ textFieldSource = new TextField();
+ textFieldSource.setCaption("CSV Source File");
+ textFieldSource.setImmediate(false);
+ textFieldSource.setDescription("Path to CSV file");
+ textFieldSource.setWidth("-1px");
+ textFieldSource.setHeight("-1px");
+ textFieldSource.setInvalidAllowed(false);
+ textFieldSource.setRequired(true);
+ textFieldSource.setInputPrompt("Eg. /opt/app/data.csv");
+ mainLayout.addComponent(textFieldSource);
+
+ // textFieldTarget
+ textFieldTarget = new TextField();
+ textFieldTarget.setCaption("Table");
+ textFieldTarget.setImmediate(false);
+ textFieldTarget.setDescription("Name of database table to be created.");
+ textFieldTarget.setWidth("-1px");
+ textFieldTarget.setHeight("-1px");
+ textFieldTarget.setInvalidAllowed(false);
+ textFieldTarget.setRequired(true);
+ mainLayout.addComponent(textFieldTarget);
+
+ // textFieldDefinition
+ textFieldDefinition = new TextField();
+ textFieldDefinition.setCaption("Table Definition");
+ textFieldDefinition.setImmediate(false);
+ textFieldDefinition.setDescription("SQL Table Definition");
+ textFieldDefinition.setWidth("-1px");
+ textFieldDefinition.setHeight("-1px");
+ textFieldDefinition.setInvalidAllowed(false);
+ textFieldDefinition.setRequired(true);
+ mainLayout.addComponent(textFieldDefinition);
+
+ return mainLayout;
+ }
+
+}
[05/23] incubator-openaz git commit: Ported original att source to
openaz
Posted by pd...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/FunctionSelectionWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/FunctionSelectionWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/FunctionSelectionWindow.java
new file mode 100644
index 0000000..80d33b8
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/FunctionSelectionWindow.java
@@ -0,0 +1,314 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Buffered.SourceException;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.data.util.filter.SimpleStringFilter;
+import com.vaadin.data.util.sqlcontainer.SQLContainer;
+import com.vaadin.event.FieldEvents.TextChangeEvent;
+import com.vaadin.event.FieldEvents.TextChangeListener;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class FunctionSelectionWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSave;
+ @AutoGenerated
+ private Table tableFunctions;
+ @AutoGenerated
+ private TextField textFieldFilter;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static Log logger = LogFactory.getLog(FunctionSelectionWindow.class);
+ private final FunctionSelectionWindow self = this;
+ private final String defaultFunctionID;
+ private String selectedFunction = null;
+ private boolean isSaved = false;
+ private static SQLContainer highOrderFunctions = ((XacmlAdminUI) UI.getCurrent()).getHigherOrderBagContainer();
+ /*
+ * Seems that when this view is created it may or may not be upper case.
+ */
+ private static String PROPERTY_SHORTNAME = "shortname";
+ private static String PROPERTY_XACMLID = "xacmlid";
+
+ static {
+ for (Object prop : FunctionSelectionWindow.highOrderFunctions.getContainerPropertyIds()) {
+ logger.info("SQL Container Property Id: " + prop.toString());
+ if (prop.toString().equalsIgnoreCase(PROPERTY_SHORTNAME)) {
+ PROPERTY_SHORTNAME = prop.toString();
+ } else if (prop.toString().equalsIgnoreCase(PROPERTY_XACMLID)) {
+ PROPERTY_XACMLID = prop.toString();
+ }
+ }
+
+ }
+
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public FunctionSelectionWindow(String defaultFunction) {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Save
+ //
+ this.defaultFunctionID = defaultFunction;
+ //
+ // Close shortcut
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ // Initialize GUI
+ //
+ this.initializeTextField();
+ this.initializeFunctions();
+ this.initializeButtons();
+ //
+ // Set our focus
+ //
+ this.tableFunctions.focus();
+ }
+
+ protected void initializeTextField() {
+ //
+ // Initialize GUI settings
+ //
+ this.textFieldFilter.setImmediate(true);
+ //
+ // Respond to the text change events
+ //
+ this.textFieldFilter.addTextChangeListener(new TextChangeListener() {
+ private static final long serialVersionUID = 1L;
+ SimpleStringFilter currentFilter = null;
+
+ @Override
+ public void textChange(TextChangeEvent event) {
+ //
+ // Remove current filter
+ //
+ if (this.currentFilter != null) {
+ FunctionSelectionWindow.highOrderFunctions.removeContainerFilter(this.currentFilter);
+ this.currentFilter = null;
+ }
+ //
+ // Get the text
+ //
+ String value = event.getText();
+ if (value != null && value.length() > 0) {
+ //
+ // Add the new filter
+ //
+ this.currentFilter = new SimpleStringFilter(PROPERTY_SHORTNAME, value, true, false);
+ FunctionSelectionWindow.highOrderFunctions.addContainerFilter(this.currentFilter);
+ }
+ }
+ });
+ }
+ protected void initializeFunctions() {
+ //
+ // Setup data source. Make sure there are no current filters
+ //
+ FunctionSelectionWindow.highOrderFunctions.removeAllContainerFilters();
+ this.tableFunctions.setContainerDataSource(FunctionSelectionWindow.highOrderFunctions);
+ //
+ // Initialize GUI properties
+ //
+ this.tableFunctions.setImmediate(true);
+ this.tableFunctions.setNullSelectionAllowed(false);
+ this.tableFunctions.setRequired(true);
+ this.tableFunctions.setRequiredError("Please select a function.");
+ this.tableFunctions.setSelectable(true);
+ this.tableFunctions.setPageLength(15);
+ this.tableFunctions.setVisibleColumns(new Object[] {PROPERTY_SHORTNAME, PROPERTY_XACMLID});
+ this.tableFunctions.setColumnHeaders(new String[] {"Short Function Name", "Xacml ID"});
+ //
+ // Respond to selection events
+ //
+ this.tableFunctions.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ Object id = self.tableFunctions.getValue();
+ if (id != null) {
+ Item item = FunctionSelectionWindow.highOrderFunctions.getItem(id);
+ if (item == null) {
+ return;
+ }
+ Property<?> property = item.getItemProperty(PROPERTY_XACMLID);
+ if (property == null) {
+ return;
+ }
+ selectedFunction = property.getValue().toString();
+ self.buttonSave.setEnabled(true);
+ } else {
+ self.buttonSave.setEnabled(false);
+ }
+ }
+ });
+ //
+ // Respond to double-click events
+ //
+ this.tableFunctions.addItemClickListener(new ItemClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void itemClick(ItemClickEvent event) {
+ if (event.isDoubleClick()) {
+ self.doSave();
+ }
+ }
+ });
+ //
+ // Setup the default selection
+ //
+ this.buttonSave.setEnabled(false);
+ if (this.defaultFunctionID != null) {
+ for (Object id : FunctionSelectionWindow.highOrderFunctions.getItemIds()) {
+ Item item = FunctionSelectionWindow.highOrderFunctions.getItem(id);
+ if (item != null) {
+ Property<?> property = item.getItemProperty(PROPERTY_XACMLID);
+ if (property != null && property.getValue().toString().equals(this.defaultFunctionID)) {
+ this.tableFunctions.select(id);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ protected void initializeButtons() {
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ self.doSave();
+ }
+ });
+ }
+
+ protected void doSave() {
+ try {
+ //
+ // Commit changes
+ //
+ self.tableFunctions.commit();
+ //
+ // We are saved
+ //
+ self.isSaved = true;
+ //
+ // Close the window
+ //
+ self.close();
+ } catch (SourceException | InvalidValueException e) { //NOPMD
+ //
+ // Nothing to do, Vaadin highlights
+ //
+ }
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ public String getSelectedFunction() {
+ return this.selectedFunction;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // textFieldFilter
+ textFieldFilter = new TextField();
+ textFieldFilter.setCaption("Filter");
+ textFieldFilter.setImmediate(false);
+ textFieldFilter.setWidth("-1px");
+ textFieldFilter.setHeight("-1px");
+ mainLayout.addComponent(textFieldFilter);
+
+ // tableFunctions
+ tableFunctions = new Table();
+ tableFunctions.setImmediate(false);
+ tableFunctions.setDescription("Functions To Select From");
+ tableFunctions.setWidth("100.0%");
+ tableFunctions.setHeight("-1px");
+ mainLayout.addComponent(tableFunctions);
+ mainLayout.setExpandRatio(tableFunctions, 1.0f);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save");
+ buttonSave.setImmediate(true);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitConflictResolver.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitConflictResolver.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitConflictResolver.java
new file mode 100644
index 0000000..cd75c07
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitConflictResolver.java
@@ -0,0 +1,67 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.VerticalLayout;
+
+public class GitConflictResolver extends CustomComponent {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public GitConflictResolver() {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+
+ // TODO add user code here
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(false);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitPushWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitPushWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitPushWindow.java
new file mode 100644
index 0000000..492d8b9
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitPushWindow.java
@@ -0,0 +1,356 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.Status;
+import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.dircache.DirCache;
+import org.eclipse.jgit.dircache.DirCacheEntry;
+import org.eclipse.jgit.errors.NoWorkTreeException;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.model.GitStatusContainer;
+import org.apache.openaz.xacml.admin.model.GitStatusContainer.GitEntry;
+import org.apache.openaz.xacml.admin.model.GitStatusContainer.StatusItem;
+import org.apache.openaz.xacml.admin.util.AdminNotification;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Buffered.SourceException;
+import com.vaadin.data.Item;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.event.FieldEvents.TextChangeEvent;
+import com.vaadin.event.FieldEvents.TextChangeListener;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Table.ColumnGenerator;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class GitPushWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonPush;
+ @AutoGenerated
+ private Table tableChanges;
+ @AutoGenerated
+ private TextArea textAreaComments;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static final Log logger = LogFactory.getLog(GitPushWindow.class);
+ private final GitPushWindow self = this;
+ private final GitStatusContainer container;
+ private final Git git;
+ private final File target;
+ private boolean isSaved = false;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ * @param git
+ * @param status
+ */
+ public GitPushWindow(Git git, File target, Status status) {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Save data
+ //
+ this.git = git;
+ this.target = target;
+ this.container = new GitStatusContainer(status);
+ //
+ // Set our shortcuts
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ // Initialize GUI
+ //
+ this.initializeText();
+ this.initializeTable(status);
+ this.initializeButtons();
+ //
+ // Focus
+ //
+ this.textAreaComments.focus();
+ }
+
+ protected void initializeText() {
+ this.textAreaComments.setImmediate(true);
+ this.textAreaComments.addTextChangeListener(new TextChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void textChange(TextChangeEvent event) {
+ if (event.getText().isEmpty()) {
+ self.buttonPush.setEnabled(false);
+ } else {
+ if (self.container.getConflictCount() == 0) {
+ self.buttonPush.setEnabled(true);
+ } else {
+ self.buttonPush.setEnabled(false);
+ }
+ }
+ }
+ });
+ }
+
+ protected void initializeTable(Status status) {
+ //
+ // Setup the table
+ //
+ this.tableChanges.setContainerDataSource(this.container);
+ this.tableChanges.setPageLength(this.container.size());
+ this.tableChanges.setImmediate(true);
+ //
+ // Generate column
+ //
+ this.tableChanges.addGeneratedColumn("Entry", new ColumnGenerator() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Object generateCell(Table source, Object itemId, Object columnId) {
+ Item item = self.container.getItem(itemId);
+ assert item != null;
+ if (item instanceof StatusItem) {
+ return self.generateGitEntryComponent(((StatusItem) item).getGitEntry());
+ }
+ assert item instanceof StatusItem;
+ return null;
+ }
+ });
+ }
+
+ protected Object generateGitEntryComponent(final GitEntry entry) {
+ //
+ // If its conflicting, take care of it
+ //
+ if (entry.isConflicting()) {
+ return this.generateConflictingEntry(entry);
+ }
+ if (entry.isUntracked()) {
+ return this.generateUntrackedEntry(entry);
+ }
+ /*
+ if (entry.isChanged() ||
+ entry.isModified() ||
+ entry.isUncommitted()) {
+ return this.generateUncommittedEntry(entry);
+ }
+ */
+ return null;
+ }
+
+ protected Object generateConflictingEntry(final GitEntry entry) {
+ Button resolve = new Button("Resolve");
+ resolve.setImmediate(true);
+ resolve.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+
+ }
+ });
+ return resolve;
+ }
+
+ protected Object generateUntrackedEntry(final GitEntry entry) {
+ Button add = new Button("Add");
+ add.setImmediate(true);
+ add.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ try {
+ DirCache cache = self.git.add().addFilepattern(entry.getName()).call();
+ DirCacheEntry cacheEntry = cache.getEntry(entry.getName());
+ assert cacheEntry != null;
+ if (cacheEntry == null) {
+ return;
+ }
+ if (cacheEntry.isMerged()) {
+ self.refreshStatus();
+ }
+ } catch (GitAPIException e) {
+ String error = "Failed to add: " + e.getLocalizedMessage();
+ logger.error(error);
+ AdminNotification.error(error);
+ }
+ }
+ });
+ return add;
+ }
+
+ protected Object generateUncommittedEntry(final GitEntry entry) {
+ Button commit = new Button("Commit");
+ commit.setImmediate(true);
+ commit.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ }
+ });
+ return commit;
+ }
+
+ protected void initializeButtons() {
+ this.buttonPush.setEnabled(false);
+ this.buttonPush.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ try {
+ //
+ // Commit
+ //
+ self.textAreaComments.commit();
+ //
+ // Mark as saved
+ //
+ self.isSaved = true;
+ //
+ // Close the window
+ //
+ self.close();
+ } catch(SourceException | InvalidValueException idontcare) { //NOPMD
+ //
+ // Vaadin will highlight the failed requirement or validation
+ //
+ }
+ }
+ });
+ }
+
+ protected void refreshStatus() {
+ try {
+ //
+ // Grab our working repository
+ //
+ Path repoPath = ((XacmlAdminUI)getUI()).getUserGitPath();
+ final Git git = Git.open(repoPath.toFile());
+ //
+ // Get our status
+ //
+ final String base;
+ Status status;
+ if (target == null) {
+ base = ".";
+ } else {
+ Path relativePath = repoPath.relativize(Paths.get(target.getPath()));
+ base = relativePath.toString();
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("Status on base: " + base);
+ }
+ status = git.status().addPath(base).call();
+ //
+ // Pass it to our container
+ //
+ this.container.refreshStatus(status);
+ this.tableChanges.refreshRowCache();
+ } catch (NoWorkTreeException | IOException | GitAPIException e) {
+ String error = "Failed to refresh status: " + e.getLocalizedMessage();
+ logger.error(error);
+ }
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ public String getComment() {
+ return this.textAreaComments.getValue();
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // textAreaComments
+ textAreaComments = new TextArea();
+ textAreaComments.setCaption("Add Comments");
+ textAreaComments.setImmediate(false);
+ textAreaComments
+ .setDescription("Enter comments that reflect the changes you have made to the repository domains and/or policy files.");
+ textAreaComments.setWidth("400px");
+ textAreaComments.setHeight("-1px");
+ textAreaComments.setInvalidAllowed(false);
+ textAreaComments.setRequired(true);
+ textAreaComments
+ .setInputPrompt("Eg. Add new rule for employees in marketing department.");
+ mainLayout.addComponent(textAreaComments);
+
+ // tableChanges
+ tableChanges = new Table();
+ tableChanges.setCaption("Changes To Be Pushed");
+ tableChanges.setImmediate(false);
+ tableChanges.setWidth("100.0%");
+ tableChanges.setHeight("-1px");
+ mainLayout.addComponent(tableChanges);
+ mainLayout.setExpandRatio(tableChanges, 1.0f);
+
+ // buttonPush
+ buttonPush = new Button();
+ buttonPush.setCaption("Push Changes");
+ buttonPush.setImmediate(true);
+ buttonPush.setWidth("-1px");
+ buttonPush.setHeight("-1px");
+ mainLayout.addComponent(buttonPush);
+ mainLayout.setComponentAlignment(buttonPush, new Alignment(48));
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitSynchronizeWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitSynchronizeWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitSynchronizeWindow.java
new file mode 100644
index 0000000..da2edf7
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/GitSynchronizeWindow.java
@@ -0,0 +1,158 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import java.io.IOException;
+import java.nio.file.Path;
+
+import org.eclipse.jgit.api.Git;
+// import org.eclipse.jgit.api.MergeResult;
+import org.eclipse.jgit.api.PullResult;
+// import org.eclipse.jgit.api.RebaseResult;
+import org.eclipse.jgit.api.errors.GitAPIException;
+// import org.eclipse.jgit.transport.FetchResult;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class GitSynchronizeWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSynchronize;
+ @AutoGenerated
+ private TextArea textAreaResults;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private final GitSynchronizeWindow self = this;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public GitSynchronizeWindow() {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Set our shortcuts
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ //
+ //
+ this.initializeButtons();
+ }
+
+ protected void initializeButtons() {
+ this.buttonSynchronize.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ if (self.buttonSynchronize.getCaption().equals("Synchronize")) {
+ self.synchronize();
+ } else {
+ self.close();
+ }
+ }
+ });
+ }
+
+ protected void synchronize() {
+ //
+ // Grab our working repository
+ //
+ Path repoPath = ((XacmlAdminUI)getUI()).getUserGitPath();
+ try {
+ final Git git = Git.open(repoPath.toFile());
+
+ PullResult result = git.pull().call();
+ // FetchResult fetch = result.getFetchResult();
+ // MergeResult merge = result.getMergeResult();
+ // RebaseResult rebase = result.getRebaseResult();
+ if (result.isSuccessful()) {
+ //
+ // TODO add more notification
+ //
+ this.textAreaResults.setValue("Successful!");
+ } else {
+ //
+ // TODO
+ //
+ this.textAreaResults.setValue("Failed.");
+ }
+ } catch (IOException | GitAPIException e) {
+ e.printStackTrace();
+ }
+ this.buttonSynchronize.setCaption("Ok");
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // textAreaResults
+ textAreaResults = new TextArea();
+ textAreaResults.setCaption("Synch Results");
+ textAreaResults.setImmediate(false);
+ textAreaResults.setWidth("462px");
+ textAreaResults.setHeight("222px");
+ mainLayout.addComponent(textAreaResults);
+
+ // buttonSynchronize
+ buttonSynchronize = new Button();
+ buttonSynchronize.setCaption("Synchronize");
+ buttonSynchronize.setImmediate(true);
+ buttonSynchronize.setWidth("-1px");
+ buttonSynchronize.setHeight("-1px");
+ mainLayout.addComponent(buttonSynchronize);
+ mainLayout.setComponentAlignment(buttonSynchronize, new Alignment(24));
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/MatchEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/MatchEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/MatchEditorWindow.java
new file mode 100644
index 0000000..eafb7e0
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/MatchEditorWindow.java
@@ -0,0 +1,304 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.jpa.Attribute;
+import org.apache.openaz.xacml.admin.jpa.Datatype;
+import org.apache.openaz.xacml.admin.view.events.AttributeChangedEventListener;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Buffered.SourceException;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.data.util.filter.Compare;
+import com.vaadin.data.util.sqlcontainer.SQLContainer;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class MatchEditorWindow extends Window implements AttributeChangedEventListener {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSave;
+ @AutoGenerated
+ private Table tableFunctions;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static Log logger = LogFactory.getLog(MatchEditorWindow.class);
+ private final MatchEditorWindow self = this;
+ private final MatchType match;
+ private final Datatype datatype;
+ private boolean isSaved = false;
+ private static SQLContainer matchFunctions = ((XacmlAdminUI) UI.getCurrent()).getMatchFunctionContainer();
+
+ private static String PROPERTY_SHORTNAME = "shortname";
+ private static String PROPERTY_XACMLID = "xacmlid";
+ private static String PROPERTY_ARG2_DATATYPE = "arg2_datatype";
+
+ static {
+ //
+ // H2 seems to insist on capitalizing, even with the no uppercase switch.
+ //
+ for (Object prop : MatchEditorWindow.matchFunctions.getContainerPropertyIds()) {
+ logger.info("SQL Container Property Id: " + prop.toString());
+ if (prop.toString().equalsIgnoreCase(PROPERTY_SHORTNAME)) {
+ PROPERTY_SHORTNAME = prop.toString();
+ } else if (prop.toString().equalsIgnoreCase(PROPERTY_XACMLID)) {
+ PROPERTY_XACMLID = prop.toString();
+ } else if (prop.toString().equalsIgnoreCase(PROPERTY_ARG2_DATATYPE)) {
+ PROPERTY_ARG2_DATATYPE = prop.toString();
+ }
+ }
+
+ }
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public MatchEditorWindow(MatchType match, Datatype datatype) {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Save our data
+ //
+ this.match = match;
+ this.datatype = datatype;
+ //
+ // Close shortcut
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ // Initialize GUI
+ //
+ this.initializeFunctions();
+ this.initializeButtons();
+ //
+ // Set our focus
+ //
+ this.tableFunctions.focus();
+ }
+
+ protected void initializeFunctions() {
+ //
+ // Setup datasource and GUI properties
+ //
+ this.tableFunctions.setContainerDataSource(MatchEditorWindow.matchFunctions);
+ this.tableFunctions.setImmediate(true);
+ this.tableFunctions.setNullSelectionAllowed(false);
+ this.tableFunctions.setRequired(true);
+ this.tableFunctions.setRequiredError("Please select a function.");
+ this.tableFunctions.setSelectable(true);
+ this.tableFunctions.setPageLength(15);
+ this.tableFunctions.setVisibleColumns(PROPERTY_SHORTNAME, PROPERTY_XACMLID);
+ this.tableFunctions.setColumnHeaders(new String[] {"Short Function Name", "Xacml ID"});
+ //
+ // Filter out functions where ARG2 is the given datatype. NOTE: The
+ // AttributeDesignator/AttributeSelector is the 2nd argument.
+ //
+ MatchEditorWindow.matchFunctions.removeAllContainerFilters();
+ MatchEditorWindow.matchFunctions.addContainerFilter(new Compare.Equal(PROPERTY_ARG2_DATATYPE, this.datatype.getId()));
+ //
+ // Respond to selection events
+ //
+ this.tableFunctions.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ Object id = self.tableFunctions.getValue();
+ if (id != null) {
+ Item item = MatchEditorWindow.matchFunctions.getItem(id);
+ if (item == null) {
+ return;
+ }
+ Property<?> property = item.getItemProperty(PROPERTY_XACMLID);
+ if (property == null) {
+ return;
+ }
+ self.match.setMatchId(property.getValue().toString());
+ self.buttonSave.setEnabled(true);
+ } else {
+ self.buttonSave.setEnabled(false);
+ }
+ }
+ });
+ //
+ // Respond to double-click events
+ //
+ this.tableFunctions.addItemClickListener(new ItemClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void itemClick(ItemClickEvent event) {
+ if (event.isDoubleClick()) {
+ self.doSave();
+ }
+ }
+ });
+ //
+ // Default selection
+ //
+ this.buttonSave.setEnabled(false);
+ if (this.match.getMatchId() != null) {
+ for (Object id : MatchEditorWindow.matchFunctions.getItemIds()) {
+ Item item = MatchEditorWindow.matchFunctions.getItem(id);
+ if (item != null) {
+ Property<?> property = item.getItemProperty(PROPERTY_XACMLID);
+ if (property != null && property.getValue().toString().equals(this.match.getMatchId())) {
+ this.tableFunctions.select(id);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ protected void initializeButtons() {
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ self.doSave();
+ }
+ });
+ }
+
+ protected void doSave() {
+ try {
+ //
+ // Commit changes
+ //
+ self.tableFunctions.commit();
+ //
+ // We are saved
+ //
+ self.isSaved = true;
+ //
+ // Close the window
+ //
+ self.close();
+ } catch (SourceException | InvalidValueException e) {
+ return;
+ }
+ }
+
+ @Override
+ public void attributeChanged(Attribute attribute) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("attributeChanged: " + attribute);
+ }
+ //
+ // Remove all filters.
+ //
+ MatchEditorWindow.matchFunctions.removeAllContainerFilters();
+ if (attribute == null) {
+ return;
+ }
+ //
+ // Get the datatype for the attribute
+ //
+ Datatype datatype = attribute.getDatatypeBean();
+ if (logger.isDebugEnabled()) {
+ logger.debug("datatype: " + datatype.getId());
+ }
+ //
+ // Filter out functions where ARG2 is the datatype. The
+ // AttributeDesignator/AttributeSelector is the 2nd arg.
+ //
+ MatchEditorWindow.matchFunctions.addContainerFilter(new Compare.Equal(PROPERTY_ARG2_DATATYPE, datatype.getId()));
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ public MatchType getMatch() {
+ return this.match;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // tableFunctions
+ tableFunctions = new Table();
+ tableFunctions.setCaption("Function");
+ tableFunctions.setImmediate(true);
+ tableFunctions
+ .setDescription("Select a function for matching the attribute.");
+ tableFunctions.setWidth("100.0%");
+ tableFunctions.setHeight("-1px");
+ tableFunctions.setInvalidAllowed(false);
+ tableFunctions.setRequired(true);
+ mainLayout.addComponent(tableFunctions);
+ mainLayout.setExpandRatio(tableFunctions, 1.0f);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save");
+ buttonSave.setImmediate(true);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObadviceEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObadviceEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObadviceEditorWindow.java
new file mode 100644
index 0000000..960a2b7
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObadviceEditorWindow.java
@@ -0,0 +1,184 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import org.apache.openaz.xacml.admin.jpa.Obadvice;
+import org.apache.openaz.xacml.admin.view.fields.OaExpressionsField;
+import com.vaadin.addon.jpacontainer.EntityItem;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.fieldgroup.FieldGroup;
+import com.vaadin.data.fieldgroup.FieldGroup.CommitException;
+import com.vaadin.data.fieldgroup.PropertyId;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.FormLayout;
+import com.vaadin.ui.OptionGroup;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Window;
+
+public class ObadviceEditorWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ private static final long serialVersionUID = 1L;
+ private ObadviceEditorWindow self = this;
+
+ private FormLayout mainLayout = new FormLayout();
+
+ @PropertyId("type")
+ OptionGroup typeOption = new OptionGroup("Type");
+
+ @PropertyId("xacmlId")
+ TextField xacmlID = new TextField("Obligation Id");
+
+ @PropertyId("description")
+ TextArea descriptionField = new TextArea("Description");
+
+ @PropertyId("fulfillOn")
+ OptionGroup fulfillOption = new OptionGroup("Fullfill On");
+
+ @PropertyId("obadviceExpressions")
+ OaExpressionsField expressionsField;
+ //Table tableExpressions = new Table("Attribute Assignments");
+
+ Button saveButton = new Button("Save");
+
+ private FieldGroup fieldGroup = null;
+ private final EntityItem<Obadvice> obad;
+ private boolean isSaved = false;
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ * @param caption
+ */
+ public ObadviceEditorWindow(EntityItem<Obadvice> obad) {
+ this.setContent(mainLayout);
+ //
+ // Save
+ //
+ this.obad = obad;
+ //
+ // Initialize main layout
+ //
+ this.mainLayout.setMargin(true);
+ this.mainLayout.setWidth("-1px");
+ //
+ // Initialize components
+ //
+ this.typeOption.setNullSelectionAllowed(false);
+ this.typeOption.setImmediate(true);
+ this.typeOption.setDescription("Select whether this is an obligation or advice");
+ this.typeOption.addItem("Obligation");
+ this.typeOption.addItem("Advice");
+
+ this.fulfillOption.setNullSelectionAllowed(true);
+ this.fulfillOption.setDescription("Optionally restrict the use of the obligation/advice to a Permit or a Deny");
+ this.fulfillOption.addItem("Permit");
+ this.fulfillOption.addItem("Deny");
+
+ this.descriptionField.setNullRepresentation("");
+
+ this.expressionsField = new OaExpressionsField(this.obad);
+ //
+ // Add our form components
+ //
+ this.mainLayout.addComponent(this.typeOption);
+ this.mainLayout.addComponent(this.fulfillOption);
+ this.mainLayout.addComponent(this.xacmlID);
+ this.mainLayout.addComponent(this.descriptionField);
+ this.mainLayout.addComponent(this.expressionsField);
+// this.mainLayout.addComponent(this.tableExpressions);
+ this.mainLayout.addComponent(this.saveButton);
+ //
+ // Now bind those fields to the data
+ //
+ this.fieldGroup = new FieldGroup(obad);
+ this.fieldGroup.bindMemberFields(this);
+ //
+ // Finish setting up
+ //
+ this.initializeButtons();
+ this.initializeOptions();
+ //
+ // Set focus
+ //
+ this.xacmlID.focus();
+ }
+
+ private void initializeButtons() {
+ this.saveButton.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ try {
+ fieldGroup.commit();
+ self.isSaved = true;
+ self.close();
+ } catch (CommitException e) {
+ e.printStackTrace();
+ }
+ }
+
+ });
+ }
+
+ private void initializeOptions() {
+ self.setIDCaption();
+ this.typeOption.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ self.setIDCaption();
+ }
+
+ });
+ }
+
+ private void setIDCaption() {
+ String value = (String) self.typeOption.getValue();
+ if (value.equals("Obligation")) {
+ self.xacmlID.setCaption("Obligation Id");
+ } else {
+ self.xacmlID.setCaption("Advice Id");
+ }
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ public void discard() {
+ //
+ // May be discarded automatically??
+ //
+ this.fieldGroup.discard();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObligationAdviceEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObligationAdviceEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObligationAdviceEditorWindow.java
new file mode 100644
index 0000000..21c2d45
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObligationAdviceEditorWindow.java
@@ -0,0 +1,817 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import java.util.Map;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionsType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeAssignmentExpressionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeSelectorType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObligationExpressionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObligationExpressionsType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableDefinitionType;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.model.ObligationAdviceContainer;
+import org.apache.openaz.xacml.util.XACMLObjectCopy;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.event.Action;
+import com.vaadin.event.Action.Handler;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.AbstractSelect.ItemDescriptionGenerator;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.TreeTable;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class ObligationAdviceEditorWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSave;
+ @AutoGenerated
+ private TreeTable tableExpressions;
+ @AutoGenerated
+ private HorizontalLayout horizontalLayout_1;
+ @AutoGenerated
+ private Button buttonClear;
+ @AutoGenerated
+ private Button buttonRemove;
+ @AutoGenerated
+ private Button buttonAdd;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static Log logger = LogFactory.getLog(ObligationAdviceEditorWindow.class);
+ private final ObligationAdviceEditorWindow self = this;
+ private final Object root;
+ private final Map<VariableDefinitionType, PolicyType> variables;
+ private ObligationAdviceContainer container;
+ private boolean isSaved = false;
+
+ private static final Action ADD_OBLIGATION = new Action ("Add Obligation");
+ private static final Action ADD_ADVICE = new Action ("Add Advice");
+ private static final Action ADD_EXPRESSION = new Action ("Add Expression");
+ private static final Action ADD_ATTRIBUTE = new Action ("Add Attribute");
+ private static final Action EDIT_OBLIGATION = new Action ("Edit Obligation");
+ private static final Action EDIT_ADVICE = new Action ("Edit Advice");
+ private static final Action EDIT_EXPRESSION = new Action ("Edit Expression");
+ private static final Action EDIT_ATTRIBUTE = new Action ("Edit Attribute");
+ private static final Action REMOVE_OBLIGATION = new Action ("Remove Obligation");
+ private static final Action REMOVE_ADVICE = new Action ("Remove Advice");
+ private static final Action REMOVE_EXPRESSION = new Action ("Remove Expression");
+ private static final Action REMOVE_ATTRIBUTE = new Action ("Remove Attribute");
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public ObligationAdviceEditorWindow(Object root, Map<VariableDefinitionType, PolicyType> variables) {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Save
+ //
+ if (! (root instanceof ObligationExpressionsType) &&
+ ! (root instanceof AdviceExpressionsType) ) {
+ throw new IllegalArgumentException("This window supports Obligation or Advice Expressions only.");
+ }
+ this.root = root;
+ this.variables = variables;
+ this.container = new ObligationAdviceContainer(this.root);
+ //
+ // Set our shortcuts
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ // Initialize GUI
+ //
+ this.initializeTable();
+ this.initializeButtons();
+ this.setupButtons();
+ //
+ // Focus
+ //
+ this.tableExpressions.focus();
+ }
+
+ protected void initializeTable() {
+ //
+ // GUI properties
+ //
+ this.tableExpressions.setImmediate(true);
+ //
+ // Set the container
+ //
+ this.tableExpressions.setContainerDataSource(this.container);
+ this.tableExpressions.setVisibleColumns(new Object[] {ObligationAdviceContainer.PROPERTY_NAME,
+ ObligationAdviceContainer.PROPERTY_ID_SHORT,
+ ObligationAdviceContainer.PROPERTY_EFFECT,
+ ObligationAdviceContainer.PROPERTY_CATEGORY_SHORT,
+ ObligationAdviceContainer.PROPERTY_DATATYPE_SHORT});
+ this.tableExpressions.setColumnHeaders(new String[] {"Name", "ID or Value", (this.root instanceof ObligationExpressionsType ? "Effect" : "Applies"), "Category", "Data Type"});
+ //this.tableExpressions.setColumnExpandRatio(ObligationAdviceContainer.PROPERTY_NAME, 1.0f);
+ //this.tableExpressions.setColumnExpandRatio(ObligationAdviceContainer.PROPERTY_ID_SHORT, 1.0f);
+ //this.tableExpressions.setColumnWi
+ this.tableExpressions.setSelectable(true);
+ //
+ // Expand it out
+ //
+ for (Object item : this.tableExpressions.getItemIds()) {
+ this.tableExpressions.setCollapsed(item, false);
+ for (Object child : this.tableExpressions.getChildren(item)) {
+ this.tableExpressions.setCollapsed(child, false);
+ }
+ }
+ this.tableExpressions.setPageLength(this.container.size() + 3);
+ //
+ // Respond to events
+ //
+ this.tableExpressions.addActionHandler(new Handler() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Action[] getActions(Object target, Object sender) {
+ if (target == null) {
+ if (self.root instanceof ObligationExpressionsType) {
+ return new Action[] {ADD_OBLIGATION};
+ }
+ if (self.root instanceof AdviceExpressionsType) {
+ return new Action[] {ADD_ADVICE};
+ }
+ }
+ if (target instanceof ObligationExpressionType) {
+ return new Action[] {EDIT_OBLIGATION, REMOVE_OBLIGATION, ADD_EXPRESSION};
+ }
+ if (target instanceof AdviceExpressionType) {
+ return new Action[] {EDIT_ADVICE, REMOVE_ADVICE, ADD_EXPRESSION};
+ }
+ if (target instanceof AttributeAssignmentExpressionType) {
+ return new Action[] {EDIT_EXPRESSION, REMOVE_EXPRESSION, ADD_ATTRIBUTE};
+ }
+ if (target instanceof AttributeValueType ||
+ target instanceof AttributeDesignatorType ||
+ target instanceof AttributeSelectorType ||
+ target instanceof ApplyType) {
+ return new Action[] {EDIT_ATTRIBUTE, REMOVE_ATTRIBUTE};
+ }
+ return null;
+ }
+
+ @Override
+ public void handleAction(Action action, Object sender, Object target) {
+ if (action == ADD_OBLIGATION) {
+ self.editObligation(null);
+ return;
+ }
+ if (action == EDIT_OBLIGATION) {
+ assert target instanceof ObligationExpressionType;
+ self.editObligation((ObligationExpressionType) target);
+ return;
+ }
+ if (action == REMOVE_OBLIGATION) {
+ assert target instanceof ObligationExpressionType;
+ if (self.container.removeItem(target) == false) {
+ logger.error("Failed to remove obligation");
+ assert false;
+ }
+ return;
+ }
+ if (action == ADD_ADVICE) {
+ self.editAdvice(null);
+ return;
+ }
+ if (action == EDIT_ADVICE) {
+ assert target instanceof AdviceExpressionType;
+ self.editAdvice((AdviceExpressionType) target);
+ return;
+ }
+ if (action == REMOVE_ADVICE) {
+ assert target instanceof AdviceExpressionType;
+ if (self.container.removeItem(target) == false) {
+ logger.error("Failed to remove advice");
+ assert false;
+ }
+ return;
+ }
+ if (action == ADD_EXPRESSION) {
+ assert target instanceof ObligationExpressionType || target instanceof AdviceExpressionType;
+ self.editExpression(null, target);
+ return;
+ }
+ if (action == EDIT_EXPRESSION) {
+ assert target instanceof AttributeAssignmentExpressionType;
+ self.editExpression((AttributeAssignmentExpressionType) target, self.container.getParent(target));
+ return;
+ }
+ if (action == REMOVE_EXPRESSION) {
+ assert target instanceof AttributeAssignmentExpressionType;
+ if (self.container.removeItem(target) == false) {
+ logger.error("Failed to remove expression");
+ assert false;
+ }
+ return;
+ }
+ if (action == ADD_ATTRIBUTE) {
+ assert target instanceof AttributeAssignmentExpressionType;
+ self.editAttribute(null, (AttributeAssignmentExpressionType) target);
+ return;
+ }
+ if (action == EDIT_ATTRIBUTE) {
+ assert target instanceof AttributeValueType ||
+ target instanceof AttributeDesignatorType ||
+ target instanceof AttributeSelectorType ||
+ target instanceof ApplyType;
+ self.editAttribute(target, (AttributeAssignmentExpressionType) self.container.getParent(target));
+ return;
+ }
+ if (action == REMOVE_ATTRIBUTE) {
+ assert target instanceof AttributeValueType ||
+ target instanceof AttributeDesignatorType ||
+ target instanceof AttributeSelectorType ||
+ target instanceof ApplyType;
+ if (self.container.removeItem(target) == false) {
+ logger.error("Failed to remove attribute");
+ assert false;
+ }
+ return;
+ }
+ }
+ });
+ //
+ // Respond to selections
+ //
+ this.tableExpressions.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ self.setupButtons();
+ }
+ });
+ this.tableExpressions.addItemClickListener(new ItemClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void itemClick(ItemClickEvent event) {
+ if (event.isDoubleClick()) {
+ if (event.getSource() instanceof AdviceExpressionType) {
+ self.editAdvice((AdviceExpressionType) event.getSource());
+ } else if (event.getSource() instanceof ObligationExpressionType) {
+ self.editObligation((ObligationExpressionType) event.getSource());
+ } else if (event.getSource() instanceof AttributeAssignmentExpressionType) {
+ self.editExpression((AttributeAssignmentExpressionType) event.getSource(), self.container.getParent(event.getSource()));
+ } else {
+ self.editAttribute(event.getSource(), (AttributeAssignmentExpressionType) self.container.getParent(event.getSource()));
+ }
+ }
+ }
+ });
+ //
+ // Implement a description generator, to display the full XACML ID.
+ //
+ this.tableExpressions.setItemDescriptionGenerator(new ItemDescriptionGenerator() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String generateDescription(Component source, Object itemId, Object propertyId) {
+ if (propertyId == ObligationAdviceContainer.PROPERTY_ID_SHORT) {
+ if (itemId instanceof AdviceExpressionType) {
+ return ((AdviceExpressionType) itemId).getAdviceId();
+ }
+ if (itemId instanceof ObligationExpressionType) {
+ return ((ObligationExpressionType) itemId).getObligationId();
+ }
+ if (itemId instanceof AttributeAssignmentExpressionType) {
+ return ((AttributeAssignmentExpressionType) itemId).getAttributeId();
+ }
+ if (itemId instanceof AttributeDesignatorType) {
+ return ((AttributeDesignatorType) itemId).getAttributeId();
+ }
+ if (itemId instanceof AttributeSelectorType) {
+ return ((AttributeSelectorType) itemId).getContextSelectorId();
+ }
+ if (itemId instanceof ApplyType) {
+ return ((ApplyType) itemId).getDescription();
+ }
+ }
+ if (propertyId == ObligationAdviceContainer.PROPERTY_CATEGORY_SHORT) {
+ if (itemId instanceof AttributeAssignmentExpressionType) {
+ return ((AttributeAssignmentExpressionType) itemId).getCategory();
+ }
+ if (itemId instanceof AttributeDesignatorType) {
+ return ((AttributeDesignatorType) itemId).getCategory();
+ }
+ if (itemId instanceof AttributeSelectorType) {
+ return ((AttributeSelectorType) itemId).getCategory();
+ }
+ if (itemId instanceof ApplyType) {
+ return null;
+ }
+ }
+ if (propertyId == ObligationAdviceContainer.PROPERTY_DATATYPE_SHORT) {
+ if (itemId instanceof AttributeValueType) {
+ return ((AttributeValueType) itemId).getDataType();
+ }
+ if (itemId instanceof AttributeDesignatorType) {
+ return ((AttributeDesignatorType) itemId).getDataType();
+ }
+ if (itemId instanceof AttributeSelectorType) {
+ return ((AttributeSelectorType) itemId).getDataType();
+ }
+ /*
+ if (itemId instanceof ApplyType) {
+ //
+ // TODO - get the datatype for the function
+ //
+ }
+ */
+ }
+ return null;
+ }
+ });
+ }
+
+ protected void initializeButtons() {
+ this.buttonAdd.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ if (self.tableExpressions.getValue() == null) {
+ //
+ // Add new root advice or obligation
+ //
+ if (self.root instanceof AdviceExpressionsType) {
+ self.editAdvice(null);
+ } else {
+ self.editObligation(null);
+ }
+ } else {
+ //
+ // Add new assignment expression
+ //
+ self.editExpression(null, self.tableExpressions.getValue());
+ }
+ }
+ });
+
+ this.buttonRemove.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ Object object = self.tableExpressions.getValue();
+ if (object != null) {
+ if (object instanceof AttributeValueType ||
+ object instanceof AttributeDesignatorType ||
+ object instanceof AttributeSelectorType ||
+ object instanceof ApplyType) {
+ if (self.container.removeItem(self.container.getParent(object)) == false) {
+ logger.error("Failed to remove attribute value/des/sel/apply");
+ assert false;
+ }
+ } else {
+ if (self.container.removeItem(object) == false) {
+ logger.error("Failed to remove object");
+ assert false;
+ }
+ }
+ } else {
+ logger.error("This code should never get executed if the button was properly disabled.");
+ }
+ }
+ });
+
+ this.buttonClear.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ Object object = self.tableExpressions.getValue();
+ if (object == null) {
+ if (self.container.removeAllItems() == false) {
+ logger.error("Failed to remove all items");
+ assert false;
+ }
+ } else {
+ if (self.container.removeAllAssignments() == false) {
+ logger.error("Failed to remove all assignments");
+ assert false;
+ }
+ }
+ }
+ });
+
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ //
+ // Mark ourselves as saved
+ //
+ self.isSaved = true;
+ //
+ // Close the window
+ //
+ self.close();
+ }
+ });
+ }
+
+ protected void setupButtons() {
+ Object target = this.tableExpressions.getValue();
+ if (target == null) {
+ if (this.root instanceof AdviceExpressionsType) {
+ this.buttonAdd.setVisible(true);
+ this.buttonAdd.setCaption("Add Advice");
+ this.buttonRemove.setCaption("Remove Advice");
+ this.buttonClear.setCaption("Clear All Advice");
+ this.buttonClear.setVisible(true);
+ } else {
+ this.buttonAdd.setVisible(true);
+ this.buttonAdd.setCaption("Add Obligation");
+ this.buttonRemove.setCaption("Remove Obligation");
+ this.buttonClear.setCaption("Clear All Obligations");
+ this.buttonClear.setVisible(true);
+ }
+ this.buttonRemove.setEnabled(false);
+ } else {
+ if (target instanceof AdviceExpressionType ||
+ target instanceof ObligationExpressionType) {
+ this.buttonAdd.setVisible(true);
+ this.buttonAdd.setCaption("Add Assignment");
+ if (target instanceof AdviceExpressionType) {
+ this.buttonRemove.setCaption("Remove Advice");
+ } else {
+ this.buttonRemove.setCaption("Remove Obligation");
+ }
+ this.buttonClear.setCaption("Clear All Assignments");
+ this.buttonClear.setVisible(true);
+ } else {
+ this.buttonAdd.setVisible(false);
+ this.buttonRemove.setCaption("Remove Assignment");
+ this.buttonClear.setVisible(false);
+ }
+ this.buttonRemove.setEnabled(true);
+ }
+ if (this.tableExpressions.size() == 0) {
+ this.buttonClear.setEnabled(false);
+ } else {
+ this.buttonClear.setEnabled(true);
+ }
+ }
+
+ protected void editAttribute(Object target, final AttributeAssignmentExpressionType parent) {
+ //
+ // Make a copy
+ //
+ final AttributeAssignmentExpressionType copyAssignment = (parent == null ? new AttributeAssignmentExpressionType() : XACMLObjectCopy.copy(parent));
+ //
+ // Prompt user for attribute right away
+ //
+ final ExpressionBuilderComponent builder = new ExpressionBuilderComponent(copyAssignment, copyAssignment.getExpression() != null ? copyAssignment.getExpression().getValue() : null, null, self.variables);
+ builder.setCaption("Define Assignment Attribute");
+ builder.setModal(true);
+ builder.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Did the user save?
+ //
+ if (builder.isSaved() == false) {
+ return;
+ }
+ //
+ // Yes - update it
+ //
+ parent.setExpression(copyAssignment.getExpression());
+ if (parent.getExpression() != null) {
+ self.container.removeItem(parent.getExpression().getValue());
+ }
+ self.container.addItem(copyAssignment.getExpression().getValue(), parent);
+ //
+ // Set the table size
+ //
+ self.tableExpressions.setPageLength(self.container.size() + 1);
+ }
+ });
+ builder.center();
+ UI.getCurrent().addWindow(builder);
+ }
+
+ protected void editExpression(final AttributeAssignmentExpressionType assignment, final Object parent) {
+ //
+ // Copy
+ //
+ final AttributeAssignmentExpressionType copyAssignment = (assignment == null ? new AttributeAssignmentExpressionType() : XACMLObjectCopy.copy(assignment));
+ //
+ // Create the window
+ //
+ final AttributeAssignmentExpressionEditorWindow window = new AttributeAssignmentExpressionEditorWindow(copyAssignment);
+ window.setCaption(assignment == null ? "Create Attribute Assignment" : "Edit Attribute Assignment");
+ window.setModal(true);
+ window.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Did the user click save?
+ //
+ if (window.isSaved() == false) {
+ return;
+ }
+ //
+ // Was this a new assignment?
+ //
+ if (assignment == null) {
+ //
+ // Prompt user for attribute right away
+ //
+ final ExpressionBuilderComponent builder = new ExpressionBuilderComponent(copyAssignment, null, null, self.variables);
+ builder.setCaption("Define Assignment Attribute");
+ builder.setModal(true);
+ builder.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Did the user save?
+ //
+ if (builder.isSaved() == false) {
+ return;
+ }
+ //
+ // Yes - add it to the container
+ //
+ if (self.container.addItem(copyAssignment, parent) == null) {
+ logger.error("Failed to add copy assignment");
+ assert false;
+ }
+ //
+ // Set the table size
+ //
+ self.tableExpressions.setPageLength(self.container.size() + 1);
+ }
+ });
+ builder.center();
+ UI.getCurrent().addWindow(builder);
+ } else {
+ //
+ // No - copy back the data
+ //
+ assignment.setAttributeId(copyAssignment.getAttributeId());
+ assignment.setIssuer(assignment.getIssuer());
+ assignment.setCategory(copyAssignment.getCategory());
+ //
+ // Update the container
+ //
+ self.container.updateItem(assignment);
+ }
+ }
+ });
+ window.center();
+ UI.getCurrent().addWindow(window);
+ }
+
+ protected void editAdvice(final AdviceExpressionType advice) {
+ //
+ // Copy the advice
+ //
+ final AdviceExpressionType copyAdvice = (advice == null ? new AdviceExpressionType() : XACMLObjectCopy.copy(advice));
+ //
+ // Setup the window
+ //
+ final AdviceEditorWindow window = new AdviceEditorWindow(copyAdvice);
+ window.setCaption("Edit Advice");
+ window.setModal(true);
+ window.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Is it saved?
+ //
+ if (window.isSaved() == false) {
+ return;
+ }
+ //
+ // Was this a new object?
+ //
+ if (advice == null) {
+ //
+ // New - add it to the container
+ //
+ if (self.container.addItem(copyAdvice) == null) {
+ logger.error("failed to add advice");
+ assert false;
+ }
+ //
+ // Set the table size
+ //
+ self.tableExpressions.setPageLength(self.container.size() + 1);
+ } else {
+ //
+ // No - copy it back
+ //
+ advice.setAdviceId(copyAdvice.getAdviceId());
+ advice.setAppliesTo(copyAdvice.getAppliesTo());
+ //
+ // Update
+ //
+ self.container.updateItem(advice);
+ }
+ }
+ });
+ window.center();
+ UI.getCurrent().addWindow(window);
+ }
+
+ protected void editObligation(final ObligationExpressionType obligation) {
+ //
+ // Copy the advice
+ //
+ final ObligationExpressionType copyObligation = (obligation == null ? new ObligationExpressionType() : XACMLObjectCopy.copy(obligation));
+ //
+ // Setup the window
+ //
+ final ObligationEditorWindow window = new ObligationEditorWindow(copyObligation);
+ window.setCaption("Edit Obligation");
+ window.setModal(true);
+ window.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Is it saved?
+ //
+ if (window.isSaved() == false) {
+ return;
+ }
+ //
+ // Was this a new object?
+ //
+ if (obligation == null) {
+ //
+ // New - add it to the container
+ //
+ if (self.container.addItem(copyObligation) == null) {
+ logger.error("Failed to add obligation");
+ assert false;
+ }
+ //
+ // Set the table size
+ //
+ self.tableExpressions.setPageLength(self.container.size() + 1);
+ } else {
+ //
+ // No - copy it back
+ //
+ obligation.setObligationId(copyObligation.getObligationId());
+ obligation.setFulfillOn(copyObligation.getFulfillOn());
+ //
+ // Update
+ //
+ self.container.updateItem(obligation);
+ }
+ }
+ });
+ window.center();
+ UI.getCurrent().addWindow(window);
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ public Object getRootObject() {
+ return this.root;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("100%");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // horizontalLayout_1
+ horizontalLayout_1 = buildHorizontalLayout_1();
+ mainLayout.addComponent(horizontalLayout_1);
+
+ // tableExpressions
+ tableExpressions = new TreeTable();
+ tableExpressions.setCaption("Expressions");
+ tableExpressions.setImmediate(false);
+ tableExpressions.setWidth("100%");
+ tableExpressions.setHeight("-1px");
+ mainLayout.addComponent(tableExpressions);
+ mainLayout.setExpandRatio(tableExpressions, 1.0f);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save");
+ buttonSave.setImmediate(false);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
+
+ return mainLayout;
+ }
+
+ @AutoGenerated
+ private HorizontalLayout buildHorizontalLayout_1() {
+ // common part: create layout
+ horizontalLayout_1 = new HorizontalLayout();
+ horizontalLayout_1.setImmediate(false);
+ horizontalLayout_1.setWidth("-1px");
+ horizontalLayout_1.setHeight("-1px");
+ horizontalLayout_1.setMargin(false);
+ horizontalLayout_1.setSpacing(true);
+
+ // buttonAdd
+ buttonAdd = new Button();
+ buttonAdd.setCaption("Add Expression");
+ buttonAdd.setImmediate(false);
+ buttonAdd.setWidth("-1px");
+ buttonAdd.setHeight("-1px");
+ horizontalLayout_1.addComponent(buttonAdd);
+
+ // buttonRemove
+ buttonRemove = new Button();
+ buttonRemove.setCaption("Remove Expression");
+ buttonRemove.setImmediate(false);
+ buttonRemove.setWidth("-1px");
+ buttonRemove.setHeight("-1px");
+ horizontalLayout_1.addComponent(buttonRemove);
+
+ // buttonClear
+ buttonClear = new Button();
+ buttonClear.setCaption("Clear Expressions");
+ buttonClear.setImmediate(false);
+ buttonClear.setWidth("-1px");
+ buttonClear.setHeight("-1px");
+ horizontalLayout_1.addComponent(buttonClear);
+
+ return horizontalLayout_1;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObligationEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObligationEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObligationEditorWindow.java
new file mode 100644
index 0000000..dac4eda
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/ObligationEditorWindow.java
@@ -0,0 +1,208 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.EffectType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObligationExpressionType;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Buffered.SourceException;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.OptionGroup;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class ObligationEditorWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSave;
+ @AutoGenerated
+ private OptionGroup optionGroupFullfillOn;
+ @AutoGenerated
+ private TextField textFieldObligationID;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private final ObligationEditorWindow self = this;
+ private final ObligationExpressionType obligation;
+ private boolean isSaved = false;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public ObligationEditorWindow(ObligationExpressionType obligation) {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Save
+ //
+ this.obligation = obligation;
+ //
+ // Set our shortcuts
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ // Initialize GUI
+ //
+ this.initialize();
+ this.initializeButton();
+ //
+ // Focus
+ //
+ this.textFieldObligationID.focus();
+ }
+
+ protected void initialize() {
+ //
+ // The text field for the advice ID
+ //
+ this.textFieldObligationID.setNullRepresentation("");
+ if (this.obligation.getObligationId() == null) {
+ this.textFieldObligationID.setValue(XacmlAdminUI.getDomain());
+ } else {
+ this.textFieldObligationID.setValue(obligation.getObligationId());
+ }
+ this.textFieldObligationID.setRequiredError("You must have an ID for the obligation");
+ //
+ // The option
+ //
+ this.optionGroupFullfillOn.setRequiredError("You must select Permit or Deny for the obligation");
+ this.optionGroupFullfillOn.addItem(EffectType.PERMIT);
+ this.optionGroupFullfillOn.addItem(EffectType.DENY);
+ if (this.obligation.getFulfillOn() == null) {
+ this.optionGroupFullfillOn.select(EffectType.PERMIT);
+ } else {
+ if (this.obligation.getFulfillOn().equals(EffectType.PERMIT)) {
+ this.optionGroupFullfillOn.select(EffectType.PERMIT);
+ } else {
+ this.optionGroupFullfillOn.select(EffectType.DENY);
+ }
+ }
+ }
+
+ protected void initializeButton() {
+ this.buttonSave.setImmediate(true);
+ this.buttonSave.setClickShortcut(KeyCode.ENTER);
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ try {
+ //
+ // Commit
+ //
+ self.textFieldObligationID.commit();
+ self.optionGroupFullfillOn.commit();
+ //
+ // all good, save everything
+ //
+ self.obligation.setObligationId(self.textFieldObligationID.getValue());
+ self.obligation.setFulfillOn((EffectType) self.optionGroupFullfillOn.getValue());
+ //
+ // Set ourselves as saved
+ //
+ self.isSaved = true;
+ //
+ // Close the window
+ //
+ self.close();
+ } catch (SourceException | InvalidValueException e) { //NOPMD
+ //
+ // Vaadin displays the error
+ //
+ }
+ }
+ });
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ public ObligationExpressionType getAdvice() {
+ return this.obligation;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // textFieldObligationID
+ textFieldObligationID = new TextField();
+ textFieldObligationID.setCaption("Obligation ID");
+ textFieldObligationID.setImmediate(false);
+ textFieldObligationID.setWidth("-1px");
+ textFieldObligationID.setHeight("-1px");
+ textFieldObligationID.setInvalidAllowed(false);
+ textFieldObligationID.setRequired(true);
+ textFieldObligationID.setInputPrompt("Eg. urn:com:foo:obligation:sample");
+ mainLayout.addComponent(textFieldObligationID);
+
+ // optionGroupFullfillOn
+ optionGroupFullfillOn = new OptionGroup();
+ optionGroupFullfillOn.setCaption("Fulfill On");
+ optionGroupFullfillOn.setImmediate(false);
+ optionGroupFullfillOn.setWidth("-1px");
+ optionGroupFullfillOn.setHeight("-1px");
+ optionGroupFullfillOn.setInvalidAllowed(false);
+ optionGroupFullfillOn.setRequired(true);
+ mainLayout.addComponent(optionGroupFullfillOn);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save");
+ buttonSave.setImmediate(true);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PDPStatusWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PDPStatusWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PDPStatusWindow.java
new file mode 100644
index 0000000..de279a3
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PDPStatusWindow.java
@@ -0,0 +1,264 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.api.pap.PDPPIPConfig;
+import org.apache.openaz.xacml.api.pap.PDPPolicy;
+import org.apache.openaz.xacml.api.pap.PDPStatus;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class PDPStatusWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+
+
+ @AutoGenerated
+ private Button buttonOK;
+
+
+ @AutoGenerated
+ private Table table;
+
+
+ private PDPStatus status;
+
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static final Log logger = LogFactory.getLog(PDPStatusWindow.class);
+ private final PDPStatusWindow self = this;
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public PDPStatusWindow(PDPStatus status) {
+ buildMainLayout();
+ setContent(mainLayout);
+ //setCompositionRoot(mainLayout);
+ //
+ // Save
+ //
+ this.status = status;
+ //
+ // Setup shortcuts
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ this.buttonOK.setClickShortcut(KeyCode.ENTER);
+ //
+ // Initialize
+ //
+ try {
+ this.initialize();
+ this.initializeButton();
+ } catch (Exception e) {
+ logger.error("Initialize exception: " + e);
+ }
+ //
+ // Focus
+ //
+ this.buttonOK.focus();
+ }
+
+ protected void initialize() {
+ //
+ // Setup the table - real simple
+ //
+ this.table.addContainerProperty("Property", Label.class, null);
+ this.table.addContainerProperty("Value", TextArea.class, null);
+ //
+ // Set the status
+ //
+ StringBuilder builder;
+ int rows;
+ Integer id = 1;
+ this.table.addItem(new Object[] {new Label("Status"), this.createTextArea(this.status.getStatus().toString(), 1)}, id++);
+ //
+ // Setup Errors
+ //
+ builder = new StringBuilder();
+ rows = 0;
+ for (String error : this.status.getLoadErrors()) {
+ builder.append(error);
+ builder.append(System.lineSeparator());
+ rows++;
+ }
+ if (rows == 0) {
+ rows = 1;
+ }
+ this.table.addItem(new Object[] {new Label("Errors"), this.createTextArea(builder.toString(), rows)}, id++);
+ //
+ // Setup Errors
+ //
+ builder = new StringBuilder();
+ rows = 0;
+ for (String error : this.status.getLoadWarnings()) {
+ builder.append(error);
+ builder.append(System.lineSeparator());
+ rows++;
+ }
+ if (rows == 0) {
+ rows = 1;
+ }
+ this.table.addItem(new Object[] {new Label("Warnings"), this.createTextArea(builder.toString(), rows)}, id++);
+ //
+ // Setup the loaded policy table
+ //
+ builder = new StringBuilder();
+ rows = 0;
+ for (PDPPolicy policy : this.status.getLoadedPolicies()) {
+ builder.append(policy.getName());
+ builder.append(System.lineSeparator());
+ rows++;
+ }
+ if (rows == 0) {
+ rows = 1;
+ }
+ this.table.addItem(new Object[] {new Label("Policies Loaded"), this.createTextArea(builder.toString(), rows)}, id++);
+ //
+ // Setup the Failed policy table
+ //
+ builder = new StringBuilder();
+ rows = 0;
+ for (PDPPolicy policy : this.status.getFailedPolicies()) {
+ builder.append(policy.getName());
+ builder.append(System.lineSeparator());
+ rows++;
+ }
+ if (rows == 0) {
+ rows = 1;
+ }
+ this.table.addItem(new Object[] {new Label("Policies Failed To Load"), this.createTextArea(builder.toString(), rows)}, id++);
+ //
+ // Setup the Loaded PIP configuration table
+ //
+ builder = new StringBuilder();
+ rows = 0;
+ for (PDPPIPConfig config : this.status.getLoadedPipConfigs()) {
+ builder.append(config.getName());
+ builder.append(System.lineSeparator());
+ rows++;
+ }
+ if (rows == 0) {
+ rows = 1;
+ }
+ this.table.addItem(new Object[] {new Label("Loaded PIP Configurations"), this.createTextArea(builder.toString(), rows)}, id++);
+ //
+ // Setup the Failed PIP configuration table
+ //
+ builder = new StringBuilder();
+ rows = 0;
+ for (PDPPIPConfig config : this.status.getFailedPipConfigs()) {
+ builder.append(config.getName());
+ builder.append(System.lineSeparator());
+ rows++;
+ }
+ if (rows == 0) {
+ rows = 1;
+ }
+ this.table.addItem(new Object[] {new Label("Failed PIP Configurations"), this.createTextArea(builder.toString(), rows)}, id++);
+ //
+ // Set the length
+ //
+ table.setPageLength(id - 1);
+ table.setReadOnly(true);
+ table.setSizeFull();
+ }
+
+ protected TextArea createTextArea(String value, int lines) {
+ TextArea area = new TextArea();
+ area.setValue(value);
+ area.setNullRepresentation("");
+ area.setSizeFull();
+ area.setReadOnly(true);
+ area.setRows(lines);
+ return area;
+ }
+
+ protected void initializeButton() {
+ this.buttonOK.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ self.close();
+ }
+ });
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("100.0%");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // table
+ table = new Table();
+ table.setCaption("Status");
+ table.setImmediate(false);
+ table.setWidth("100.0%");
+ table.setHeight("-1px");
+ mainLayout.addComponent(table);
+
+ // buttonOK
+ buttonOK = new Button();
+ buttonOK.setCaption("Ok");
+ buttonOK.setImmediate(true);
+ buttonOK.setWidth("-1px");
+ buttonOK.setHeight("-1px");
+ mainLayout.addComponent(buttonOK);
+ mainLayout.setComponentAlignment(buttonOK, new Alignment(48));
+
+ return mainLayout;
+ }
+
+
+
+}
[12/23] incubator-openaz git commit: Ported original att source to
openaz
Posted by pd...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/PolicyContainer.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/PolicyContainer.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/PolicyContainer.java
new file mode 100644
index 0000000..247dcdd
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/PolicyContainer.java
@@ -0,0 +1,2096 @@
+/*
+ * 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.xacml.admin.model;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.JAXBElement;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionsType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AllOfType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AnyOfType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeSelectorType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ConditionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.EffectType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.FunctionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.MatchType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObjectFactory;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObligationExpressionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObligationExpressionsType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicySetType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.RuleType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.TargetType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableDefinitionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.VariableReferenceType;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.util.XACMLPolicyScanner;
+import org.apache.openaz.xacml.util.XACMLPolicyScanner.CallbackResult;
+import com.google.gwt.thirdparty.guava.common.base.Splitter;
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.util.MethodProperty;
+import com.vaadin.server.Resource;
+import com.vaadin.server.ThemeResource;
+import com.vaadin.ui.Table;
+
+public class PolicyContainer extends ItemSetChangeNotifier implements Container.Hierarchical, Container.Ordered, Container.ItemSetChangeNotifier {
+ private static final long serialVersionUID = 1L;
+ private static Log logger = LogFactory.getLog(PolicyContainer.class);
+ private final PolicyContainer self = this;
+
+ /**
+ * String identifier of a file's "name" property.
+ */
+ public static String PROPERTY_NAME = "Name";
+
+ /**
+ * String identifier of a file's "id" property.
+ */
+ public static String PROPERTY_ID = "Id";
+
+ /**
+ * String identifier of a file's "short ID" property.
+ */
+ public static String PROPERTY_SHORTID = "ShortId";
+
+ /**
+ * String identifier of a file's "Algorithm" property.
+ */
+ public static String PROPERTY_ALGORITHM = "Algorithm";
+
+ /**
+ * String identifier of a file's "ShortAlgorithm" property.
+ */
+ public static String PROPERTY_SHORTALGORITHM = "ShortAlgorithm";
+
+ /**
+ * String identifier of a file's "Description" property.
+ */
+ public static String PROPERTY_DESCRIPTION = "Description";
+
+ /**
+ * String identifier of a file's "icon" property.
+ */
+ public static String PROPERTY_ICON = "Icon";
+
+ /**
+ * String identifier of a file's "Status" property.
+ */
+ public static String PROPERTY_STATUS = "Status";
+
+ /**
+ * String identifier of a file's "Attributes" property.
+ */
+ public static String PROPERTY_ATTRIBUTES = "Attributes";
+
+ /**
+ * List of the string identifiers for the available properties.
+ */
+ public static Collection<String> POLICY_PROPERTIES;
+
+ private final static Method POLICYITEM_NAME;
+
+ private final static Method POLICYITEM_ID;
+
+ private final static Method POLICYITEM_SHORTID;
+
+ private final static Method POLICYITEM_ALGORITHM;
+
+ private final static Method POLICYITEM_SHORTALGORITHM;
+
+ private final static Method POLICYITEM_DESCRIPTION;
+
+ private final static Method POLICYITEM_ICON;
+
+ private final static Method POLICYITEM_STATUS;
+
+ private final static Method POLICYITEM_ATTRIBUTES;
+
+ static {
+
+ POLICY_PROPERTIES = new ArrayList<String>();
+ POLICY_PROPERTIES.add(PROPERTY_NAME);
+ POLICY_PROPERTIES.add(PROPERTY_ID);
+ POLICY_PROPERTIES.add(PROPERTY_SHORTID);
+ POLICY_PROPERTIES.add(PROPERTY_ALGORITHM);
+ POLICY_PROPERTIES.add(PROPERTY_SHORTALGORITHM);
+ POLICY_PROPERTIES.add(PROPERTY_DESCRIPTION);
+ POLICY_PROPERTIES.add(PROPERTY_ICON);
+ POLICY_PROPERTIES.add(PROPERTY_STATUS);
+ POLICY_PROPERTIES.add(PROPERTY_ATTRIBUTES);
+ POLICY_PROPERTIES = Collections.unmodifiableCollection(POLICY_PROPERTIES);
+ try {
+ POLICYITEM_NAME = PolicyItem.class.getMethod("getName", new Class[]{});
+ POLICYITEM_ID = PolicyItem.class.getMethod("getId", new Class[]{});
+ POLICYITEM_SHORTID = PolicyItem.class.getMethod("getShortId", new Class[]{});
+ POLICYITEM_ALGORITHM = PolicyItem.class.getMethod("getAlgorithm", new Class[] {});
+ POLICYITEM_SHORTALGORITHM = PolicyItem.class.getMethod("getShortAlgorithm", new Class[] {});
+ POLICYITEM_DESCRIPTION = PolicyItem.class.getMethod("getDescription", new Class[] {});
+ POLICYITEM_ICON = PolicyItem.class.getMethod("getIcon", new Class[] {});
+ POLICYITEM_STATUS = PolicyItem.class.getMethod("getStatus", new Class[] {});
+ POLICYITEM_ATTRIBUTES = PolicyItem.class.getMethod("getAttributes", new Class[] {});
+ } catch (final NoSuchMethodException e) {
+ throw new RuntimeException(
+ "Internal error finding methods in PolicyContainer");
+ }
+ }
+
+ private final File file;
+ private Object root;
+
+ private Map<PolicySetType, PolicySetType> policySets = new HashMap<PolicySetType, PolicySetType>();
+ private Map<PolicyType, PolicySetType> policies = new HashMap<PolicyType, PolicySetType>();
+ private Map<RuleType, PolicyType> rules = new HashMap<RuleType, PolicyType>();
+ private Map<TargetType, Object> targets = new HashMap<TargetType, Object>();
+ private Map<AnyOfType, TargetType> anyofs = new HashMap<AnyOfType, TargetType>();
+ private Map<AllOfType, AnyOfType> allofs = new HashMap<AllOfType, AnyOfType>();
+ private Map<MatchType, AllOfType> matches = new HashMap<MatchType, AllOfType>();
+ private Map<ObligationExpressionType, Object> obligations = new HashMap<ObligationExpressionType, Object>();
+ private Map<AdviceExpressionType, Object> advice = new HashMap<AdviceExpressionType, Object>();
+ private Map<ConditionType, RuleType> conditions = new HashMap<ConditionType, RuleType>();
+ private Map<VariableDefinitionType, PolicyType> variables = new HashMap<VariableDefinitionType, PolicyType>();
+
+ public PolicyContainer(File file) throws IOException {
+ super();
+ this.setContainer(this);
+ this.file = file;
+ this.readData();
+ if (logger.isTraceEnabled()) {
+ logger.trace("New Policy Container: " + this.file.getName());
+ }
+ }
+
+ private void readData() throws IOException {
+ Object data = null;
+ try (InputStream is = Files.newInputStream(Paths.get(this.file.getAbsolutePath()))) {
+ data = XACMLPolicyScanner.readPolicy(is);
+ } catch (IOException e) {
+ logger.error("Failed to load policy.");
+ }
+ XACMLPolicyScanner scanner = null;
+ if (data instanceof PolicySetType) {
+ this.root = data;
+ scanner = new XACMLPolicyScanner((PolicySetType) this.root);
+ } else if (data instanceof PolicyType) {
+ this.root = data;
+ scanner = new XACMLPolicyScanner((PolicyType) this.root);
+ } else {
+ if (data != null) {
+ logger.error("invalid root object: " + data.getClass().getCanonicalName());
+ } else {
+ logger.error("could not parse the file");
+ }
+ throw new IOException("Invalid Xacml Policy File");
+ }
+ scanner.scan(new XACMLPolicyScanner.SimpleCallback() {
+
+ @Override
+ public CallbackResult onPreVisitRule(PolicyType parent, RuleType rule) {
+ self.addRule(parent, rule, false);
+ return CallbackResult.CONTINUE;
+ }
+
+ @Override
+ public CallbackResult onPreVisitPolicySet(PolicySetType parent,
+ PolicySetType policySet) {
+ self.addPolicySet(parent, policySet, false);
+ return CallbackResult.CONTINUE;
+ }
+
+ @Override
+ public CallbackResult onPreVisitPolicy(PolicySetType parent,
+ PolicyType policy) {
+ self.addPolicy(parent, policy, false);
+ return CallbackResult.CONTINUE;
+ }
+
+ });
+ }
+
+ private boolean isObjectSupported(Object itemId) {
+ if (!(itemId instanceof PolicySetType) &&
+ !(itemId instanceof PolicyType) &&
+ !(itemId instanceof RuleType) &&
+ !(itemId instanceof TargetType) &&
+ !(itemId instanceof ObligationExpressionType) &&
+ !(itemId instanceof AdviceExpressionType) &&
+ !(itemId instanceof AnyOfType) &&
+ !(itemId instanceof AllOfType) &&
+ !(itemId instanceof MatchType) &&
+ !(itemId instanceof ConditionType) &&
+ !(itemId instanceof VariableDefinitionType)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public Item getItem(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getItem: " + itemId);
+ }
+ if (this.isObjectSupported(itemId) == false) {
+ return null;
+ }
+ return new PolicyItem(itemId);
+ }
+
+ public Item updateItem(Object itemId) {
+ if (this.isObjectSupported(itemId) == false) {
+ return null;
+ }
+
+ this.fireItemSetChange();
+
+ return new PolicyItem(itemId);
+ }
+
+ public Map<VariableDefinitionType, PolicyType> getVariables() {
+ return Collections.unmodifiableMap(this.variables);
+ }
+
+ @Override
+ public Collection<?> getContainerPropertyIds() {
+ return POLICY_PROPERTIES;
+ }
+
+ @Override
+ public Collection<?> getItemIds() {
+ XACMLPolicyScanner scanner = null;
+ final Collection<Object> items = new ArrayList<Object>();
+ if (this.root instanceof PolicyType) {
+ scanner = new XACMLPolicyScanner((PolicyType) this.root);
+ } else if (this.root instanceof PolicySetType) {
+ scanner = new XACMLPolicyScanner((PolicySetType) this.root);
+ } else {
+ return Collections.unmodifiableCollection(items);
+ }
+
+ scanner.scan(new XACMLPolicyScanner.SimpleCallback() {
+
+ @Override
+ public CallbackResult onPreVisitRule(PolicyType parent, RuleType rule) {
+ items.add(rule);
+ if (rule.getTarget() != null) {
+ items.add(rule.getTarget());
+ }
+ if (rule.getCondition() != null) {
+ items.add(rule.getCondition());
+ }
+ if (rule.getObligationExpressions() != null) {
+ items.addAll(rule.getObligationExpressions().getObligationExpression());
+ }
+ if (rule.getAdviceExpressions() != null) {
+ items.addAll(rule.getAdviceExpressions().getAdviceExpression());
+ }
+ return CallbackResult.CONTINUE;
+ }
+
+ @Override
+ public CallbackResult onPreVisitPolicySet(PolicySetType parent, PolicySetType policySet) {
+ items.add(policySet);
+ if (policySet.getTarget() != null) {
+ items.add(policySet.getTarget());
+ }
+ if (policySet.getObligationExpressions() != null) {
+ items.addAll(policySet.getObligationExpressions().getObligationExpression());
+ }
+ if (policySet.getAdviceExpressions() != null) {
+ items.addAll(policySet.getAdviceExpressions().getAdviceExpression());
+ }
+ return CallbackResult.CONTINUE;
+ }
+
+ @Override
+ public CallbackResult onPreVisitPolicy(PolicySetType parent, PolicyType policy) {
+ items.add(policy);
+ if (policy.getTarget() != null) {
+ items.add(policy.getTarget());
+ }
+ if (policy.getObligationExpressions() != null) {
+ items.addAll(policy.getObligationExpressions().getObligationExpression());
+ }
+ if (policy.getAdviceExpressions() != null) {
+ items.addAll(policy.getAdviceExpressions().getAdviceExpression());
+ }
+ return CallbackResult.CONTINUE;
+ }
+
+ });
+ if (logger.isTraceEnabled()) {
+ logger.trace("getItemIds: (" + items.size() + "):" + items);
+ }
+ return Collections.unmodifiableCollection(items);
+ }
+
+ @Override
+ public Property<?> getContainerProperty(Object itemId, Object propertyId) {
+ if (this.isObjectSupported(itemId) == false) {
+ return null;
+ }
+
+ if (propertyId.equals(PROPERTY_NAME)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PolicyItem(itemId), POLICYITEM_NAME, null);
+ }
+
+ if (propertyId.equals(PROPERTY_ID)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PolicyItem(itemId), POLICYITEM_ID, null);
+ }
+
+ if (propertyId.equals(PROPERTY_SHORTID)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PolicyItem(itemId), POLICYITEM_SHORTID, null);
+ }
+
+ if (propertyId.equals(PROPERTY_ICON)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PolicyItem(itemId), POLICYITEM_ICON, null);
+ }
+
+ if (propertyId.equals(PROPERTY_ALGORITHM)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PolicyItem(itemId), POLICYITEM_ALGORITHM, null);
+ }
+
+ if (propertyId.equals(PROPERTY_SHORTALGORITHM)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PolicyItem(itemId), POLICYITEM_SHORTALGORITHM, null);
+ }
+
+ if (propertyId.equals(PROPERTY_DESCRIPTION)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PolicyItem(itemId), POLICYITEM_DESCRIPTION, null);
+ }
+
+ if (propertyId.equals(PROPERTY_STATUS)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PolicyItem(itemId), POLICYITEM_STATUS, null);
+ }
+
+ if (propertyId.equals(PROPERTY_ATTRIBUTES)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PolicyItem(itemId), POLICYITEM_ATTRIBUTES, null);
+ }
+
+ return null;
+ }
+
+ @Override
+ public Class<?> getType(Object propertyId) {
+
+ if (propertyId.equals(PROPERTY_NAME)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_ID)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_SHORTID)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_ICON)) {
+ return Resource.class;
+ }
+ if (propertyId.equals(PROPERTY_DESCRIPTION)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_ALGORITHM)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_SHORTALGORITHM)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_STATUS)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_ATTRIBUTES)) {
+ return Table.class;
+ }
+ return null;
+ }
+
+ @Override
+ public int size() {
+ int size = 0;
+ size += this.policySets.size();
+ size += this.policies.size();
+ size += this.rules.size();
+ size += this.targets.size();
+ size += this.obligations.size();
+ size += this.advice.size();
+ size += this.anyofs.size();
+ size += this.allofs.size();
+ size += this.matches.size();
+ size += this.conditions.size();
+ size += this.variables.size();
+
+ return size;
+ }
+
+ @Override
+ public boolean containsId(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("containsId: " + itemId);
+ }
+ if (itemId instanceof PolicySetType) {
+ if (this.root instanceof PolicySetType && ((PolicySetType) itemId).getPolicySetId().equals(((PolicySetType) this.root).getPolicySetId())) {
+ return true;
+ }
+ return this.policySets.containsKey(itemId);
+ }
+ if (itemId instanceof PolicyType) {
+ if (this.root instanceof PolicyType && ((PolicyType) itemId).getPolicyId().equals(((PolicyType) this.root).getPolicyId())) {
+ return true;
+ }
+ return this.policies.containsKey(itemId);
+ }
+ if (itemId instanceof RuleType) {
+ return this.rules.containsKey(itemId);
+ }
+ if (itemId instanceof TargetType) {
+ return this.targets.containsKey(itemId);
+ }
+ if (itemId instanceof ObligationExpressionType) {
+ return this.obligations.containsKey(itemId);
+ }
+ if (itemId instanceof AdviceExpressionType) {
+ return this.advice.containsKey(itemId);
+ }
+ if (itemId instanceof AnyOfType) {
+ return this.anyofs.containsKey(itemId);
+ }
+ if (itemId instanceof AllOfType) {
+ return this.allofs.containsKey(itemId);
+ }
+ if (itemId instanceof MatchType) {
+ return this.matches.containsKey(itemId);
+ }
+ if (itemId instanceof ConditionType) {
+ return this.conditions.containsKey(itemId);
+ }
+ if (itemId instanceof VariableDefinitionType) {
+ return this.variables.containsKey(itemId);
+ }
+ return false;
+ }
+
+ @Override
+ public Item addItem(Object itemId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Please use the addItem(Object, Object) method instead.");
+ }
+
+ /**
+ * Add's the new Policy object under the parent. This method appends the item to the end
+ * of the parent's list if applicable. If you want to add an item within a list, use the
+ * addItemAfter() method instead.
+ *
+ * @param itemId
+ * @param parent
+ * @return
+ * @throws UnsupportedOperationException
+ */
+ public Item addItem(Object itemId, Object parent) throws UnsupportedOperationException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("addItem: " + itemId);
+ }
+ if (itemId instanceof PolicySetType && parent instanceof PolicySetType) {
+ this.addPolicySet((PolicySetType) parent, (PolicySetType) itemId, true);
+ } else if (itemId instanceof PolicyType && parent instanceof PolicySetType) {
+ this.addPolicy((PolicySetType) parent, (PolicyType) itemId, true);
+ } else if (itemId instanceof RuleType && parent instanceof PolicyType) {
+ this.addRule((PolicyType) parent, (RuleType) itemId, true);
+ } else if (itemId instanceof TargetType &&
+ (parent instanceof PolicyType ||
+ parent instanceof PolicySetType ||
+ parent instanceof RuleType)) {
+ this.addTarget(parent, (TargetType) itemId, true);
+ } else if (itemId instanceof ObligationExpressionType ||
+ itemId instanceof ObligationExpressionsType) {
+ if (parent instanceof PolicyType ||
+ parent instanceof PolicySetType ||
+ parent instanceof RuleType ||
+ parent instanceof ObligationExpressionsType) {
+ if (itemId instanceof ObligationExpressionType) {
+ this.addObligation(parent, (ObligationExpressionType) itemId, true);
+ } else {
+ this.addObligations(parent, (ObligationExpressionsType) itemId, true);
+ }
+ }
+ } else if (itemId instanceof AdviceExpressionType ||
+ itemId instanceof AdviceExpressionsType) {
+ if (parent instanceof PolicyType ||
+ parent instanceof PolicySetType ||
+ parent instanceof RuleType ||
+ parent instanceof AdviceExpressionsType) {
+ if (itemId instanceof AdviceExpressionType) {
+ this.addAdvice(parent, (AdviceExpressionType) itemId, true);
+ } else {
+ this.addAdvice(parent, (AdviceExpressionsType) itemId, true);
+ }
+ }
+ } else if (itemId instanceof AnyOfType && parent instanceof TargetType) {
+ this.addAnyOf((TargetType) parent, (AnyOfType) itemId, true);
+ } else if (itemId instanceof AllOfType && parent instanceof AnyOfType) {
+ this.addAllOf((AnyOfType) parent, (AllOfType) itemId, true);
+ } else if (itemId instanceof MatchType && parent instanceof AllOfType) {
+ this.addMatch((AllOfType) parent, (MatchType) itemId, true);
+ } else if (itemId instanceof ConditionType && parent instanceof RuleType) {
+ this.addCondition((RuleType) parent, (ConditionType) itemId, true);
+ } else if (itemId instanceof VariableDefinitionType && parent instanceof PolicyType) {
+ this.addVariable((PolicyType) parent, (VariableDefinitionType) itemId, true);
+ } else {
+ throw new UnsupportedOperationException("Unknown itemid or parent type: " + itemId.getClass().getCanonicalName() + " " + parent.getClass().getCanonicalName());
+ }
+ //
+ // Fire update event
+ //
+ this.fireItemSetChange();
+ //
+ // Create a new item
+ //
+ return new PolicyItem(itemId);
+ }
+
+ private void addVariable(PolicyType policy, VariableDefinitionType variable, boolean add) {
+ if (add) {
+ if (policy == null) {
+ throw new NullPointerException();
+ }
+ policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().add(variable);
+ }
+ this.variables.put(variable, policy);
+ }
+
+ private void addCondition(RuleType rule, ConditionType condition, boolean add) {
+ if (add) {
+ if (rule == null) {
+ throw new NullPointerException();
+ }
+ rule.setCondition(condition);
+ }
+ this.conditions.put(condition, rule);
+ }
+
+ private void addPolicySet(PolicySetType parent, PolicySetType policySet, boolean add) {
+ if (policySet == null) {
+ throw new NullPointerException();
+ }
+ if (parent == null && this.isRoot(policySet) == false) {
+ logger.warn("adding a non-root policy set with no parent");
+ return;
+ }
+ if (add) {
+ if (parent == null) {
+ throw new NullPointerException();
+ }
+ parent.getPolicySetOrPolicyOrPolicySetIdReference().add(new ObjectFactory().createPolicySet(policySet));
+ }
+ this.policySets.put(policySet, parent);
+ this.addTarget(policySet, policySet.getTarget(), false);
+ this.addObligations(policySet, policySet.getObligationExpressions(), false);
+ this.addAdvice(policySet, policySet.getAdviceExpressions(), false);
+ }
+
+ private void addPolicy(PolicySetType parent, PolicyType policy, boolean add) {
+ if (policy == null) {
+ throw new NullPointerException();
+ }
+ if (parent == null && this.isRoot(policy) == false) {
+ logger.warn("adding a non-root policy with no parent");
+ return;
+ }
+ if (add) {
+ if (parent == null) {
+ throw new NullPointerException();
+ }
+ parent.getPolicySetOrPolicyOrPolicySetIdReference().add(new ObjectFactory().createPolicy(policy));
+ }
+ this.policies.put(policy, parent);
+ this.addTarget(policy, policy.getTarget(), false);
+ this.addObligations(policy, policy.getObligationExpressions(), false);
+ this.addAdvice(policy, policy.getAdviceExpressions(), false);
+ for (Object obj : policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition()) {
+ if (obj instanceof VariableDefinitionType) {
+ this.addVariable(policy, (VariableDefinitionType) obj, false);
+ }
+ }
+ }
+
+ private void addRule(PolicyType parent, RuleType rule, boolean add) {
+ if (rule == null) {
+ throw new NullPointerException("Rule can't be null");
+ }
+ if (parent == null) {
+ throw new NullPointerException("Parent policy can't be null");
+ }
+ if (this.isRoot(parent) == false && this.policies.get(parent) == null) {
+ logger.warn("Could NOT find parent as root or in map: " + parent);
+ return;
+ }
+ if (add) {
+ parent.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().add(rule);
+ }
+ this.rules.put(rule, parent);
+ this.addTarget(rule, rule.getTarget(), false);
+ this.addObligations(rule, rule.getObligationExpressions(), false);
+ this.addAdvice(rule, rule.getAdviceExpressions(), false);
+ this.addCondition(rule, rule.getCondition(), add);
+ }
+
+ private void addTarget(Object parent, TargetType target, boolean add) {
+ if (target == null) {
+ logger.error("TargetType is NULL");
+ return;
+ }
+ if (add) {
+ if (parent == null) {
+ throw new NullPointerException();
+ }
+ if (parent instanceof PolicySetType) {
+ ((PolicySetType) parent).setTarget(target);
+ } else if (parent instanceof PolicyType) {
+ ((PolicyType) parent).setTarget(target);
+ } else if (parent instanceof RuleType) {
+ ((RuleType) parent).setTarget(target);
+ } else {
+ logger.error("Adding target to unknown class: " + parent.getClass().getCanonicalName());
+ }
+ }
+ this.targets.put(target, parent);
+ this.addAnyOfs(target);
+ }
+
+ private void addAnyOfs(TargetType target) {
+ for (AnyOfType anyof : target.getAnyOf()) {
+ this.anyofs.put(anyof, target);
+ this.addAllOfs(anyof);
+ }
+ }
+
+ private void addAnyOf(TargetType target, AnyOfType anyof, boolean add) {
+ if (add) {
+ target.getAnyOf().add(anyof);
+ }
+ this.anyofs.put(anyof, target);
+ }
+
+ private void addAllOfs(AnyOfType anyof) {
+ for (AllOfType allof : anyof.getAllOf()) {
+ this.allofs.put(allof, anyof);
+ this.addMatches(allof);
+ }
+ }
+
+ private void addAllOf(AnyOfType anyof, AllOfType allof, boolean add) {
+ if (add) {
+ anyof.getAllOf().add(allof);
+ }
+ this.allofs.put(allof, anyof);
+ }
+
+ private void addMatches(AllOfType allofs) {
+ for (MatchType match : allofs.getMatch()) {
+ this.matches.put(match, allofs);
+ }
+ }
+
+ private void addMatch(AllOfType allofs, MatchType match, boolean add) {
+ if (add) {
+ allofs.getMatch().add(match);
+ }
+ this.matches.put(match, allofs);
+ }
+
+ private void addObligations(Object parent, ObligationExpressionsType expressions, boolean bAdd) {
+ if (expressions == null || expressions.getObligationExpression() == null) {
+ return;
+ }
+ if (bAdd) {
+ if (parent instanceof PolicySetType) {
+ ((PolicySetType) parent).setObligationExpressions(expressions);
+ } else if (parent instanceof PolicyType) {
+ ((PolicyType) parent).setObligationExpressions(expressions);
+ } else if (parent instanceof RuleType) {
+ ((RuleType) parent).setObligationExpressions(expressions);
+ }
+ }
+ for (ObligationExpressionType expression : expressions.getObligationExpression()) {
+ this.obligations.put(expression, parent);
+ }
+ }
+
+ private void addObligation(Object parent, ObligationExpressionType expression, boolean bAdd) {
+ ObligationExpressionsType expressions = null;
+ if (parent instanceof PolicySetType) {
+ expressions = ((PolicySetType) parent).getObligationExpressions();
+ if (expressions == null) {
+ expressions = new ObligationExpressionsType();
+ ((PolicySetType) parent).setObligationExpressions(expressions);
+ }
+ } else if (parent instanceof PolicyType) {
+ expressions = ((PolicyType) parent).getObligationExpressions();
+ if (expressions == null) {
+ expressions = new ObligationExpressionsType();
+ ((PolicyType) parent).setObligationExpressions(expressions);
+ }
+ } else if (parent instanceof RuleType) {
+ expressions = ((RuleType) parent).getObligationExpressions();
+ if (expressions == null) {
+ expressions = new ObligationExpressionsType();
+ ((RuleType) parent).setObligationExpressions(expressions);
+ }
+ } else if (parent instanceof ObligationExpressionsType) {
+ expressions = (ObligationExpressionsType) parent;
+ if (bAdd) {
+ expressions.getObligationExpression().add(expression);
+ }
+ parent = this.getParent(expressions);
+ this.obligations.put(expression, parent);
+ return;
+ }
+ if (bAdd) {
+ expressions.getObligationExpression().add(expression);
+ }
+ this.obligations.put(expression, parent);
+ }
+
+ private void addAdvice(Object parent, AdviceExpressionsType expressions, boolean bAdd) {
+ if (expressions == null || expressions.getAdviceExpression() == null) {
+ return;
+ }
+ if (bAdd) {
+ if (parent instanceof PolicySetType) {
+ ((PolicySetType) parent).setAdviceExpressions(expressions);
+ } else if (parent instanceof PolicyType) {
+ ((PolicyType) parent).setAdviceExpressions(expressions);
+ } else if (parent instanceof RuleType) {
+ ((RuleType) parent).setAdviceExpressions(expressions);
+ }
+ }
+ for (AdviceExpressionType expression : expressions.getAdviceExpression()) {
+ this.advice.put(expression, parent);
+ }
+ }
+
+ private void addAdvice(Object parent, AdviceExpressionType expression, boolean bAdd) {
+ AdviceExpressionsType expressions = null;
+ if (parent instanceof PolicySetType) {
+ expressions = ((PolicySetType) parent).getAdviceExpressions();
+ if (expressions == null) {
+ expressions = new AdviceExpressionsType();
+ ((PolicySetType) parent).setAdviceExpressions(expressions);
+ }
+ } else if (parent instanceof PolicyType) {
+ expressions = ((PolicyType) parent).getAdviceExpressions();
+ if (expressions == null) {
+ expressions = new AdviceExpressionsType();
+ ((PolicyType) parent).setAdviceExpressions(expressions);
+ }
+ } else if (parent instanceof RuleType) {
+ expressions = ((RuleType) parent).getAdviceExpressions();
+ if (expressions == null) {
+ expressions = new AdviceExpressionsType();
+ ((RuleType) parent).setAdviceExpressions(expressions);
+ }
+ } else if (parent instanceof AdviceExpressionsType) {
+ expressions = (AdviceExpressionsType) parent;
+ if (bAdd) {
+ expressions.getAdviceExpression().add(expression);
+ }
+ parent = this.getParent(expressions);
+ this.advice.put(expression, parent);
+ return;
+ }
+ if (bAdd) {
+ expressions.getAdviceExpression().add(expression);
+ }
+ this.advice.put(expression, parent);
+ }
+
+ @Override
+ public Object addItem() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Policy Container cannot add an unknown item.");
+ }
+
+ @Override
+ public boolean addContainerProperty(Object propertyId, Class<?> type,
+ Object defaultValue) throws UnsupportedOperationException {
+ return false;
+ }
+
+ @Override
+ public boolean removeContainerProperty(Object propertyId)
+ throws UnsupportedOperationException {
+ return false;
+ }
+
+ @Override
+ public boolean removeAllItems() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Policy Container cannot remove all items. You must have a base Policy or Policy Set.");
+ }
+
+ @Override
+ public Collection<?> getChildren(Object itemId) {
+ final Collection<Object> items = new ArrayList<Object>();
+
+ if (itemId instanceof PolicySetType) {
+ PolicySetType policySet = (PolicySetType) itemId;
+ if (policySet.getTarget() != null) {
+ items.add(policySet.getTarget());
+ }
+ if (policySet.getObligationExpressions() != null) {
+ items.addAll(policySet.getObligationExpressions().getObligationExpression());
+ }
+ if (policySet.getAdviceExpressions() != null) {
+ items.addAll(policySet.getAdviceExpressions().getAdviceExpression());
+ }
+ List<JAXBElement<?>> children = policySet.getPolicySetOrPolicyOrPolicySetIdReference();
+ for (JAXBElement<?> element : children) {
+ if (element.getName().getLocalPart().equals("PolicySet")) {
+ items.add(element.getValue());
+ } else if (element.getName().getLocalPart().equals("Policy")) {
+ items.add(element.getValue());
+ }
+ }
+ } else if (itemId instanceof PolicyType) {
+ PolicyType policy = (PolicyType) itemId;
+ if (policy.getTarget() != null) {
+ items.add(policy.getTarget());
+ }
+ List<Object> objs = policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition();
+ for (Object obj : objs) {
+ if (obj instanceof VariableDefinitionType) {
+ items.add(obj);
+ } else if (obj instanceof RuleType) {
+ items.add(obj);
+ }
+ }
+ if (policy.getObligationExpressions() != null) {
+ items.addAll(policy.getObligationExpressions().getObligationExpression());
+ }
+ if (policy.getAdviceExpressions() != null) {
+ items.addAll(policy.getAdviceExpressions().getAdviceExpression());
+ }
+ } else if (itemId instanceof RuleType) {
+ RuleType rule = (RuleType) itemId;
+ if (rule.getTarget() != null) {
+ items.add(rule.getTarget());
+ }
+ if (rule.getCondition() != null) {
+ items.add(rule.getCondition());
+ }
+ if (rule.getObligationExpressions() != null) {
+ items.addAll(((RuleType) itemId).getObligationExpressions().getObligationExpression());
+ }
+ if (rule.getAdviceExpressions() != null) {
+ items.addAll(rule.getAdviceExpressions().getAdviceExpression());
+ }
+ } else if (itemId instanceof TargetType) {
+ for (AnyOfType anyof : ((TargetType) itemId).getAnyOf()) {
+ items.add(anyof);
+ }
+ } else if (itemId instanceof AnyOfType) {
+ for (AllOfType allof : ((AnyOfType) itemId).getAllOf()) {
+ items.add(allof);
+ }
+ } else if (itemId instanceof AllOfType) {
+ for (MatchType match : ((AllOfType) itemId).getMatch()) {
+ items.add(match);
+ }
+ }
+ if (logger.isTraceEnabled()) {
+ logger.trace("getChildren: " + itemId + "(" + items.size() + ") " + items);
+ }
+ return Collections.unmodifiableCollection(items);
+ }
+
+ @Override
+ public Object getParent(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getParent: " + itemId);
+ }
+ assert itemId != null;
+ if (itemId == null) {
+ logger.fatal("getParent called with NULL object");
+ return null;
+ }
+ if (itemId.equals(this.root)) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getParent is the root");
+ }
+ return null;
+ }
+ if (itemId instanceof PolicySetType) {
+ return this.policySets.get(itemId);
+ }
+ if (itemId instanceof PolicyType) {
+ return this.policies.get(itemId);
+ }
+ if (itemId instanceof RuleType) {
+ return this.rules.get(itemId);
+ }
+ if (itemId instanceof TargetType) {
+ return this.targets.get(itemId);
+ }
+ if (itemId instanceof ObligationExpressionType) {
+ return this.obligations.get(itemId);
+ }
+ if (itemId instanceof AdviceExpressionType) {
+ return this.advice.get(itemId);
+ }
+ if (itemId instanceof AllOfType) {
+ return this.allofs.get(itemId);
+ }
+ if (itemId instanceof AnyOfType) {
+ return this.anyofs.get(itemId);
+ }
+ if (itemId instanceof MatchType) {
+ return this.matches.get(itemId);
+ }
+ if (itemId instanceof ConditionType) {
+ return this.conditions.get(itemId);
+ }
+ if (itemId instanceof VariableDefinitionType) {
+ return this.variables.get(itemId);
+ }
+ return null;
+ }
+
+ @Override
+ public Collection<?> rootItemIds() {
+ final Collection<Object> items = new ArrayList<Object>();
+ items.add(this.root);
+ if (logger.isTraceEnabled()) {
+ logger.trace("rootItemIds: " + items);
+ }
+ return Collections.unmodifiableCollection(items);
+ }
+
+ @Override
+ public boolean setParent(Object itemId, Object newParentId) throws UnsupportedOperationException {
+ boolean result = this.setItemParent(itemId, newParentId);
+ if (result == true) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("setParent: " + itemId + " " + newParentId + " succeeded.");
+ }
+ this.fireItemSetChange();
+ }
+ return result;
+ }
+
+ protected boolean setItemParent(Object itemId, Object newParentId) throws UnsupportedOperationException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("setItemParent: " + itemId + " " + newParentId);
+ }
+ if (newParentId instanceof PolicySetType) {
+ return this.moveItemToPolicySet(itemId, (PolicySetType) newParentId);
+ }
+ if (newParentId instanceof PolicyType) {
+ return this.moveItemToPolicy(itemId, (PolicyType) newParentId);
+ }
+ if (newParentId instanceof RuleType) {
+ return this.moveItemToRule(itemId, (RuleType) newParentId);
+ }
+ if (newParentId instanceof TargetType) {
+ return this.moveItemToTarget(itemId, (TargetType) newParentId);
+ }
+ if (newParentId instanceof AnyOfType) {
+ return this.moveItemToAnyOf(itemId, (AnyOfType) newParentId);
+ }
+ if (newParentId instanceof AllOfType) {
+ return this.moveItemToAllOf(itemId, (AllOfType) newParentId);
+ }
+ return false;
+ }
+
+ protected boolean moveItemToPolicySet(Object itemId, PolicySetType policySet) {
+ if (itemId instanceof PolicySetType) {
+
+ if (this.doRemoveItem(itemId)) {
+ this.addPolicySet(policySet, (PolicySetType) itemId, true);
+ return true;
+ }
+ return false;
+ } else if (itemId instanceof PolicyType) {
+ if (this.doRemoveItem(itemId)) {
+ this.addPolicy(policySet, (PolicyType) itemId, true);
+ return true;
+ }
+ return false;
+ } else if (itemId instanceof TargetType) {
+ if (this.doRemoveItem(itemId)) {
+ this.addTarget(policySet, (TargetType) itemId, true);
+ return true;
+ }
+ return false;
+ } else if (itemId instanceof ObligationExpressionType) {
+ if (this.doRemoveItem(itemId)) {
+ this.addObligation(policySet, (ObligationExpressionType) itemId, true);
+ return true;
+ }
+ return false;
+ } else if (itemId instanceof AdviceExpressionType) {
+ if (this.doRemoveItem(itemId)) {
+ this.addAdvice(policySet, (AdviceExpressionType) itemId, true);
+ return true;
+ }
+ return false;
+ }
+ logger.warn("Can't move this item to Policy Set: " + itemId.getClass().getCanonicalName());
+ return false;
+ }
+
+ protected boolean moveItemToPolicy(Object itemId, PolicyType policy) {
+ if (itemId instanceof RuleType) {
+ if (this.doRemoveItem(itemId)) {
+ this.addRule(policy, (RuleType) itemId, true);
+ return true;
+ }
+ return false;
+ } else if (itemId instanceof TargetType) {
+ if (this.doRemoveItem(itemId)) {
+ this.addTarget(policy, (TargetType) itemId, true);
+ return true;
+ }
+ return false;
+ } else if (itemId instanceof ObligationExpressionType) {
+ if (this.doRemoveItem(itemId)) {
+ this.addObligation(policy, (ObligationExpressionType) itemId, true);
+ return true;
+ }
+ return false;
+ } else if (itemId instanceof AdviceExpressionType) {
+ if (this.doRemoveItem(itemId)) {
+ this.addAdvice(policy, (AdviceExpressionType) itemId, true);
+ return true;
+ }
+ return false;
+ } else if (itemId instanceof VariableDefinitionType) {
+ if (this.doRemoveItem(itemId)) {
+ this.addVariable(policy, (VariableDefinitionType) itemId, true);
+ return true;
+ }
+ return false;
+ }
+ logger.warn("Can't move this item to Policy: " + itemId.getClass().getCanonicalName());
+ return false;
+ }
+
+ protected boolean moveItemToRule(Object itemId, RuleType rule) {
+ if (itemId instanceof TargetType) {
+ if (this.doRemoveItem(itemId)) {
+ this.addTarget(rule, (TargetType) itemId, true);
+ return true;
+ }
+ return false;
+ } else if (itemId instanceof ObligationExpressionType) {
+ if (this.doRemoveItem(itemId)) {
+ this.addObligation(rule, (ObligationExpressionType) itemId, true);
+ return true;
+ }
+ return false;
+ } else if (itemId instanceof AdviceExpressionType) {
+ if (this.doRemoveItem(itemId)) {
+ this.addAdvice(rule, (AdviceExpressionsType) itemId, true);
+ return true;
+ }
+ return false;
+ } else if (itemId instanceof ConditionType) {
+ if (this.doRemoveItem(itemId)) {
+ this.addCondition(rule, (ConditionType) itemId, true);
+ return true;
+ }
+ return false;
+ }
+ logger.warn("Can't move this item to Rule: " + itemId.getClass().getCanonicalName());
+ return false;
+ }
+
+ protected boolean moveItemToTarget(Object itemId, TargetType target) {
+ if (itemId instanceof AnyOfType) {
+ if (this.doRemoveItem(itemId)) {
+ this.addAnyOf(target, (AnyOfType) itemId, true);
+ return true;
+ }
+ return false;
+ }
+ logger.warn("Can't move this item to target: " + itemId.getClass().getCanonicalName());
+ return false;
+ }
+
+ protected boolean moveItemToAnyOf(Object itemId, AnyOfType anyOf) {
+ if (itemId instanceof AllOfType) {
+ if (this.doRemoveItem(itemId)) {
+ this.addAllOf(anyOf, (AllOfType) itemId, true);
+ return true;
+ }
+ return false;
+ }
+ logger.warn("Can't move this item to anyOf: " + itemId.getClass().getCanonicalName());
+ return false;
+ }
+
+ protected boolean moveItemToAllOf(Object itemId, AllOfType allOf) {
+ if (itemId instanceof MatchType) {
+ if (this.doRemoveItem(itemId)) {
+ this.addMatch(allOf, (MatchType) itemId, true);
+ return true;
+ }
+ return false;
+ }
+ logger.warn("Can't move this item to allOf: " + itemId.getClass().getCanonicalName());
+ return false;
+ }
+
+ @Override
+ public boolean areChildrenAllowed(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("areChildrenAllowed: " + itemId);
+ }
+ if (itemId instanceof MatchType ||
+ itemId instanceof ObligationExpressionType ||
+ itemId instanceof AdviceExpressionType ||
+ itemId instanceof ConditionType ||
+ itemId instanceof VariableDefinitionType) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed)
+ throws UnsupportedOperationException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("setChildrenAllowed: " + itemId + " " + areChildrenAllowed);
+ }
+ if (itemId instanceof MatchType ||
+ itemId instanceof ObligationExpressionType ||
+ itemId instanceof AdviceExpressionType ||
+ itemId instanceof ConditionType ||
+ itemId instanceof VariableDefinitionType) {
+ if (areChildrenAllowed == true) {
+ return false;
+ }
+ return true;
+ }
+ if (areChildrenAllowed == false) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean isRoot(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("isRoot: " + itemId);
+ }
+ assert itemId != null;
+ if (itemId == null) {
+ //
+ // This usually means the container's map's are screwed up.
+ //
+ logger.error("NULL isRoot item");
+ return false;
+ }
+ if (itemId instanceof PolicyType && this.root instanceof PolicyType && itemId.equals(this.root)) {
+ return true;
+ } else if (itemId instanceof PolicySetType && this.root instanceof PolicySetType && itemId.equals(this.root)) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean hasChildren(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("hasChildren: " + itemId);
+ }
+ if (itemId instanceof MatchType ||
+ itemId instanceof ObligationExpressionType ||
+ itemId instanceof AdviceExpressionType ||
+ itemId instanceof ConditionType ||
+ itemId instanceof VariableDefinitionType) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public boolean removeItem(Object itemId) throws UnsupportedOperationException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("removeItem: " + itemId);
+ }
+ boolean result = this.doRemoveItem(itemId);
+ if (result) {
+ this.fireItemSetChange();
+ }
+ return result;
+ }
+
+ protected boolean doRemoveItem(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("doRemoveItem: " + itemId);
+ }
+ if (itemId instanceof PolicySetType) {
+ PolicySetType parent = this.policySets.get(itemId);
+ if (parent == null) {
+ logger.error("policy set not found in map");
+ assert false;
+ return false;
+ }
+ return this.removePolicySetFromPolicySet(parent, (PolicySetType) itemId);
+ } else if (itemId instanceof PolicyType) {
+ PolicySetType parent = this.policies.get(itemId);
+ if (parent == null) {
+ logger.error("policy not found in map");
+ assert false;
+ return false;
+ }
+ return this.removePolicyFromPolicySet(parent, (PolicyType) itemId);
+ } else if (itemId instanceof RuleType) {
+ PolicyType parent = this.rules.get(itemId);
+ if (parent == null) {
+ logger.error("rule not found in map");
+ assert false;
+ return false;
+ }
+ if (parent.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().remove(itemId)) {
+ this.removeRule((RuleType) itemId);
+ return true;
+ }
+ logger.error("Failed to remove rule from parent policy");
+ assert false;
+ return false;
+ } else if (itemId instanceof TargetType) {
+ throw new UnsupportedOperationException("Cannot remove TargetType directly - please remove it via PolicySet/Policy/Rule");
+ } else if (itemId instanceof ObligationExpressionType) {
+ Object parent = this.obligations.get(itemId);
+ if (parent == null) {
+ logger.error("obligation not found in map");
+ assert false;
+ return false;
+ }
+ if (parent instanceof PolicySetType) {
+ if (((PolicySetType) parent).getObligationExpressions() != null) {
+ if (((PolicySetType) parent).getObligationExpressions().getObligationExpression().remove(itemId) == false) {
+ logger.error("Failed to remove obligation expression from policy set");
+ assert false;
+ return false;
+ }
+ } else {
+ logger.error("policy set does not contain obligation expressions, cannot remove");
+ assert false;
+ return false;
+ }
+ } else if (parent instanceof PolicyType) {
+ if (((PolicyType) parent).getObligationExpressions() != null) {
+ if (((PolicyType) parent).getObligationExpressions().getObligationExpression().remove(itemId) == false) {
+ logger.error("Failed to remove obligation expression from policy");
+ assert false;
+ return false;
+ }
+ } else {
+ logger.error("policy does not contain obligation expressions, cannot remove");
+ assert false;
+ return false;
+ }
+ } else if (parent instanceof RuleType) {
+ if (((RuleType) parent).getObligationExpressions() != null) {
+ if (((RuleType) parent).getObligationExpressions().getObligationExpression().remove(itemId) == false) {
+ logger.error("Failed to remove obligation expression from policy set");
+ assert false;
+ return false;
+ }
+ } else {
+ logger.error("rule does not contain obligation expressions, cannot remove");
+ assert false;
+ return false;
+ }
+ } else {
+ logger.error("Unknown parent for obligation: " + parent.getClass().getCanonicalName());
+ assert false;
+ return false;
+ }
+ if (this.obligations.remove(itemId) == null) {
+ logger.error("obligation map does not contain itemId");
+ assert false;
+ }
+ return true;
+ } else if (itemId instanceof AdviceExpressionType) {
+ Object parent = this.advice.get(itemId);
+ if (parent == null) {
+ logger.error("advice not found in map");
+ assert false;
+ return false;
+ }
+ if (parent instanceof PolicySetType) {
+ if (((PolicySetType) parent).getAdviceExpressions() != null) {
+ if (((PolicySetType) parent).getAdviceExpressions().getAdviceExpression().remove(itemId) == false) {
+ logger.error("Failed to remove advice expression from policy set");
+ assert false;
+ return false;
+ }
+ } else {
+ logger.error("policy set does not contain advice expressions, cannot remove");
+ assert false;
+ return false;
+ }
+ } else if (parent instanceof PolicyType) {
+ if (((PolicyType) parent).getAdviceExpressions() != null) {
+ if (((PolicyType) parent).getAdviceExpressions().getAdviceExpression().remove(itemId) == false) {
+ logger.error("Failed to remove advice expression from policy");
+ assert false;
+ return false;
+ }
+ } else {
+ logger.error("policy does not contain advice expressions, cannot remove");
+ assert false;
+ return false;
+ }
+ } else if (parent instanceof RuleType) {
+ if (((RuleType) parent).getAdviceExpressions() != null) {
+ if (((RuleType) parent).getAdviceExpressions().getAdviceExpression().remove(itemId) == false) {
+ logger.error("Failed to remove advice expression from rule");
+ assert false;
+ return false;
+ }
+ } else {
+ logger.error("rule does not contain advice expressions, cannot remove");
+ assert false;
+ return false;
+ }
+ } else {
+ logger.error("Unknown parent for advice: " + parent.getClass().getCanonicalName());
+ assert false;
+ return false;
+ }
+ if (this.advice.remove((AdviceExpressionType) itemId) == null) {
+ logger.error("obligation map does not contain itemId");
+ assert false;
+ }
+ return true;
+ } else if (itemId instanceof AnyOfType) {
+ TargetType parent = this.anyofs.get(itemId);
+ if (parent == null) {
+ logger.error("anyof not found in map");
+ assert false;
+ return false;
+ }
+ if (parent.getAnyOf().remove(itemId)) {
+ this.removeAnyOf((AnyOfType) itemId);
+ return true;
+ } else {
+ logger.error("Failed to remove itemId from target");
+ assert false;
+ return false;
+ }
+ } else if (itemId instanceof AllOfType) {
+ AnyOfType parent = this.allofs.get(itemId);
+ if (parent == null) {
+ logger.error("allof not found in map");
+ assert false;
+ return false;
+ }
+ if (parent.getAllOf().remove(itemId)) {
+ this.removeAllOf((AllOfType) itemId);
+ return true;
+ } else {
+ logger.error("Failed to remove itemId from anyOf");
+ assert false;
+ return false;
+ }
+ } else if (itemId instanceof MatchType) {
+ AllOfType parent = this.matches.get(itemId);
+ if (parent == null) {
+ logger.error("match not found in map");
+ assert false;
+ return false;
+ }
+ if (parent.getMatch().remove(itemId)) {
+ this.removeMatch((MatchType) itemId);
+ return true;
+ } else {
+ logger.error("Failed to remove itemId from allOf");
+ assert false;
+ return false;
+ }
+ } else if (itemId instanceof ConditionType) {
+ RuleType rule = this.conditions.get(itemId);
+ if (rule != null) {
+ rule.setCondition(null);
+ if (this.conditions.remove(itemId) == null) {
+ logger.error("Failed to remove condition from map");
+ assert false;
+ return false;
+ }
+ return true;
+ } else {
+ logger.error("condition not found in map");
+ assert false;
+ return false;
+ }
+ } else if (itemId instanceof VariableDefinitionType) {
+ PolicyType policy = this.variables.get(itemId);
+ if (policy != null) {
+ if (policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().remove(itemId)) {
+ if (this.variables.remove(itemId) == null) {
+ logger.error("failed to remove variable from map");
+ assert false;
+ return false;
+ }
+ return true;
+ } else {
+ logger.error("failed to remove variable from policy");
+ assert false;
+ return false;
+ }
+ } else {
+ logger.error("variable not found in map");
+ assert false;
+ return false;
+ }
+ }
+ logger.error("Failed to remove policy set from policy set, not found.");
+ return false;
+ }
+
+ protected boolean removePolicyFromPolicySet(PolicySetType parent, PolicyType policy) {
+ for (JAXBElement<?> element : parent.getPolicySetOrPolicyOrPolicySetIdReference()) {
+ if (PolicyType.class.isAssignableFrom(element.getDeclaredType()) &&
+ ((PolicyType) element.getValue()).getPolicyId().equals(policy.getPolicyId())) {
+ if (parent.getPolicySetOrPolicyOrPolicySetIdReference().remove(element)) {
+ this.removePolicy(policy);
+ return true;
+ }
+ logger.error("Failed to remove policy from parent policy set");
+ assert false;
+ return false;
+ }
+ }
+ logger.error("Failed to remove policy from policy set, not found.");
+ return false;
+ }
+
+ protected boolean removePolicySetFromPolicySet(PolicySetType parent, PolicySetType policySet) {
+ for (JAXBElement<?> element : parent.getPolicySetOrPolicyOrPolicySetIdReference()) {
+ if (PolicySetType.class.isAssignableFrom(element.getDeclaredType())) {
+ logger.info(element);
+ if (((PolicySetType) element.getValue()).getPolicySetId().equals(policySet.getPolicySetId())) {
+ if (parent.getPolicySetOrPolicyOrPolicySetIdReference().remove(element)) {
+ this.removePolicySet(policySet);
+ return true;
+ }
+ logger.error("Failed to remove policy set from parent policy set");
+ assert false;
+ return false;
+ }
+ }
+ }
+ return false;
+ }
+
+ protected void removePolicySet(PolicySetType policySet) {
+ if (this.policySets.remove(policySet) == null) {
+ logger.warn("Failed to remove policy set from map: " + policySet);
+ return;
+ }
+ //
+ // Remove its objects from the other maps
+ //
+ this.removeTarget(policySet.getTarget());
+ this.removeObligations(policySet.getObligationExpressions());
+ this.removeAdvice(policySet.getAdviceExpressions());
+ }
+
+ protected void removePolicy(PolicyType policy) {
+ if (this.policies.remove(policy) == null) {
+ logger.warn("Failed to remove policy from map: " + policy);
+ return;
+ }
+ //
+ // Remove its objects from the other maps
+ //
+ this.removeTarget(policy.getTarget());
+ this.removeObligations(policy.getObligationExpressions());
+ this.removeAdvice(policy.getAdviceExpressions());
+ this.removeVariables(policy.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition());
+ }
+
+ protected void removeVariables(List<Object> combinerParametersOrRuleCombinerParametersOrVariableDefinition) {
+ for (Object object : combinerParametersOrRuleCombinerParametersOrVariableDefinition) {
+ if (object instanceof VariableDefinitionType) {
+ this.variables.remove(object);
+ }
+ }
+ }
+
+ protected void removeRule(RuleType rule) {
+ if (this.rules.remove(rule) == null) {
+ logger.warn("Failed to remove rule from map: " + rule);
+ return;
+ }
+ //
+ // Remove its objects from the other maps
+ //
+ this.removeTarget(rule.getTarget());
+ this.removeObligations(rule.getObligationExpressions());
+ this.removeAdvice(rule.getAdviceExpressions());
+ if (rule.getCondition() != null) {
+ this.conditions.remove(rule.getCondition());
+ }
+ }
+
+ protected void removeObligations(ObligationExpressionsType expressions) {
+ if (expressions == null) {
+ return;
+ }
+ for (ObligationExpressionType expression : expressions.getObligationExpression()) {
+ if (this.obligations.remove(expression) == null) {
+ logger.warn("Failed to remove obligation expression: " + expression);
+ }
+ }
+ }
+
+ protected void removeAdvice(AdviceExpressionsType expressions) {
+ if (expressions == null) {
+ return;
+ }
+ for (AdviceExpressionType expression : expressions.getAdviceExpression()) {
+ if (this.advice.remove(expression) == null) {
+ logger.warn("Failed to remove advice expression: " + expression);
+ }
+ }
+ }
+
+ protected void removeTarget(TargetType target) {
+ if (this.targets.remove(target) == null) {
+ logger.warn("Failed to remove target from map: " + target);
+ return;
+ }
+ for (AnyOfType anyof : target.getAnyOf()) {
+ this.removeAnyOf(anyof);
+ }
+ }
+
+ protected void removeAnyOf(AnyOfType anyof) {
+ if (this.anyofs.remove(anyof) == null) {
+ logger.warn("failed to remove anyof from map: " + anyof);
+ return;
+ }
+ for (AllOfType allof : anyof.getAllOf()) {
+ this.removeAllOf(allof);
+ }
+ }
+
+ protected void removeAllOf(AllOfType allof) {
+ if (this.allofs.remove(allof) == null) {
+ logger.warn("failed to remove allof from map: " + allof);
+ return;
+ }
+ for (MatchType match : allof.getMatch()) {
+ this.removeMatch(match);
+ }
+ }
+
+ protected void removeMatch(MatchType match) {
+ if (this.matches.remove(match) == null) {
+ logger.warn("failed to remove match from map: " + match);
+ return;
+ }
+ }
+
+ @Override
+ public Object nextItemId(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("nextItemId: " + itemId);
+ }
+ return null;
+ }
+
+ @Override
+ public Object prevItemId(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("prevItemId: " + itemId);
+ }
+ return null;
+ }
+
+ @Override
+ public Object firstItemId() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("firstItemId: ");
+ }
+ return this.root;
+ }
+
+ @Override
+ public Object lastItemId() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("lastItemId: ");
+ }
+ return null;
+ }
+
+ @Override
+ public boolean isFirstId(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("isFirstId: " + itemId);
+ }
+ //
+ // The Oasis classes do not have equals implemented. So I am
+ // not too sure that using equals works.
+ //
+ if (this.root != null && itemId != null) {
+ return this.root.equals(itemId);
+ }
+ if (logger.isTraceEnabled()) {
+ logger.trace("item is NOT the first ID" + itemId);
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isLastId(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("isLastId: " + itemId);
+ }
+ return false;
+ }
+
+ @Override
+ public Object addItemAfter(Object previousItemId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Need to know what you want added. Please use addItemAfter(Object, Object) instead.");
+ }
+
+ @Override
+ public Item addItemAfter(Object previousItemId, Object newItemId) throws UnsupportedOperationException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("addItemAfter: " + previousItemId + " new " + newItemId);
+ }
+ /*
+ if (newItemId instanceof PolicySetType) {
+
+ }
+ //
+ // Get our parents
+ //
+ Object parentPreviousItem = this.getParent(previousItemId);
+ */
+ return null;
+ }
+
+ public Item moveAfterSibling(Object itemId, Object siblingId) throws UnsupportedOperationException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("moveAfterSibling: " + itemId + " sibling " + siblingId);
+ }
+ //
+ // Get the parents, which should be the same
+ //
+ /*
+ Object itemParent = this.getParent(itemId);
+ Object siblingParent = this.getParent(siblingId);
+ if (itemParent == null) {
+ logger.error("can't move the root element");
+ return null;
+ }
+ if (itemParent != siblingParent) {
+ logger.error("parents are not the same");
+ return null;
+ }
+ if (itemId instanceof PolicySetType) {
+ assert(itemParent instanceof PolicySetType);
+ if (itemParent instanceof PolicySetType) {
+ if (siblingId instanceof PolicySetType || siblingId instanceof PolicyType) {
+ int index = ((PolicySetType) itemParent).getPolicySetOrPolicyOrPolicySetIdReference().indexOf(siblingId);
+
+ }
+ }
+ }
+ */
+ return null;
+ }
+
+ /**
+ * This class is returned to caller's to display the properties
+ * for each policy object.
+ *
+ * @author pameladragosh
+ *
+ */
+ public class PolicyItem implements Item {
+ private static final long serialVersionUID = 1L;
+ private final Object data;
+
+ public PolicyItem(Object data) {
+ this.data = data;
+ }
+
+ public String getName() {
+ if (this.data instanceof RuleType) {
+ return "Rule";
+ }
+ if (this.data instanceof PolicyType) {
+ return "Policy";
+ }
+ if (this.data instanceof PolicySetType) {
+ return "Policy Set";
+ }
+ if (this.data instanceof TargetType) {
+ return "Target";
+ }
+ if (this.data instanceof AnyOfType) {
+ return "Any Of";
+ }
+ if (this.data instanceof AllOfType) {
+ return "All Of";
+ }
+ if (this.data instanceof MatchType) {
+ return "Match";
+ }
+ if (this.data instanceof ObligationExpressionType) {
+ return "Obligation";
+ }
+ if (this.data instanceof AdviceExpressionType) {
+ return "Advice";
+ }
+ if (this.data instanceof ConditionType) {
+ return "Condition";
+ }
+ if (this.data instanceof VariableDefinitionType) {
+ return "Variable";
+ }
+ return null;
+ }
+
+ public String getId() {
+ if (this.data instanceof RuleType) {
+ return ((RuleType) this.data).getRuleId();
+ }
+ if (this.data instanceof PolicyType) {
+ return ((PolicyType) this.data).getPolicyId();
+ }
+ if (this.data instanceof PolicySetType) {
+ return ((PolicySetType) this.data).getPolicySetId();
+ }
+ if (this.data instanceof ObligationExpressionType) {
+ return ((ObligationExpressionType) this.data).getObligationId();
+ }
+ if (this.data instanceof AdviceExpressionType) {
+ return ((AdviceExpressionType) this.data).getAdviceId();
+ }
+ /*
+ if (this.data instanceof TargetType) {
+ return this.data.toString();
+ }
+ if (this.data instanceof AnyOfType) {
+ return this.data.toString();
+ }
+ if (this.data instanceof AllOfType) {
+ return this.data.toString();
+ }
+ if (this.data instanceof MatchType) {
+ ((MatchType) this.data).getMatchId();
+ }
+ */
+ if (this.data instanceof VariableDefinitionType) {
+ ((VariableDefinitionType) this.data).getVariableId();
+ }
+ return null;
+ }
+
+ public String getShortId() {
+ String id = this.getId();
+ if (id == null) {
+ return null;
+ }
+ String[] parts = id.split("[:]");
+
+ if (parts != null && parts.length > 0) {
+ return parts[parts.length - 1];
+ }
+
+ return null;
+ }
+
+ public String getDescription() {
+ if (this.data instanceof RuleType) {
+ return ((RuleType) this.data).getDescription();
+ } else if (this.data instanceof PolicyType) {
+ return ((PolicyType) this.data).getDescription();
+ } else if (this.data instanceof PolicySetType) {
+ return ((PolicySetType) this.data).getDescription();
+ } else if (this.data instanceof MatchType) {
+ StringBuilder builder = new StringBuilder();
+ AttributeValueType value = ((MatchType) this.data).getAttributeValue();
+ if (value != null) {
+ builder.append(value.getContent());
+ builder.append(" ");
+ }
+ String alg = this.getShortAlgorithm();
+ if (alg != null && alg.length() > 0) {
+ builder.append(alg);
+ builder.append(" ");
+ }
+ if (((MatchType) this.data).getAttributeDesignator() != null) {
+ builder.append(((MatchType) this.data).getAttributeDesignator().getAttributeId());
+ } else if (((MatchType) this.data).getAttributeSelector() != null) {
+ builder.append(((MatchType) this.data).getAttributeSelector().getContextSelectorId());
+ }
+ return builder.toString();
+ }
+ return null;
+ }
+
+ public String getAlgorithm() {
+ if (this.data instanceof PolicyType) {
+ return ((PolicyType) this.data).getRuleCombiningAlgId();
+ }
+ if (this.data instanceof PolicySetType) {
+ return ((PolicySetType) this.data).getPolicyCombiningAlgId();
+ }
+ if (this.data instanceof RuleType) {
+ return ((RuleType) this.data).getEffect().toString();
+ }
+ if (this.data instanceof MatchType) {
+ return ((MatchType) this.data).getMatchId();
+ }
+ if (this.data instanceof ObligationExpressionType) {
+ return ((ObligationExpressionType) this.data).getFulfillOn().toString();
+ }
+ if (this.data instanceof AdviceExpressionType) {
+ return ((AdviceExpressionType) this.data).getAppliesTo().toString();
+ }
+ if (this.data instanceof ConditionType) {
+ return this.getRootExpressionFunction(((ConditionType) this.data).getExpression());
+ }
+ if (this.data instanceof VariableDefinitionType) {
+ //return this.getRootExpressionFunction(((VariableDefinitionType) this.data).getExpression());
+ return ((VariableDefinitionType) this.data).getVariableId();
+ }
+ return null;
+ }
+
+ public String getShortAlgorithm() {
+ String algorithm = null;
+ if (this.data instanceof PolicyType) {
+ algorithm = ((PolicyType) this.data).getRuleCombiningAlgId();
+ }
+ if (this.data instanceof PolicySetType) {
+ algorithm = ((PolicySetType) this.data).getPolicyCombiningAlgId();
+ }
+ if (this.data instanceof RuleType) {
+ return ((RuleType) this.data).getEffect().toString();
+ }
+ if (this.data instanceof ObligationExpressionType) {
+ return ((ObligationExpressionType) this.data).getFulfillOn().toString();
+ }
+ if (this.data instanceof AdviceExpressionType) {
+ return ((AdviceExpressionType) this.data).getAppliesTo().toString();
+ }
+ if (this.data instanceof MatchType) {
+ algorithm = ((MatchType) this.data).getMatchId();
+ }
+ if (this.data instanceof ConditionType) {
+ algorithm = this.getRootExpressionFunction(((ConditionType) this.data).getExpression());
+ if (algorithm.startsWith("http")) {
+ return algorithm;
+ }
+ }
+ if (this.data instanceof VariableDefinitionType) {
+ //algorithm = this.getRootExpressionFunction(((VariableDefinitionType) this.data).getExpression());
+ return ((VariableDefinitionType) this.data).getVariableId();
+ }
+ if (algorithm != null) {
+ Iterable<String> fields = Splitter.on(':').trimResults().omitEmptyStrings().split(algorithm);
+ if (fields != null) {
+ String lastId = null;
+ for (String id : fields) {
+ lastId = id;
+ }
+ return lastId;
+ }
+ }
+ return null;
+ }
+
+ public Resource getIcon() {
+ if (this.data instanceof PolicySetType) {
+ return new ThemeResource("../runo/icons/16/folder.png");
+ }
+ if (this.data instanceof RuleType) {
+ if (((RuleType) this.data).getEffect() == null) {
+ logger.warn("Rule has a null Effect");
+ return new ThemeResource("icons/deny-16.png");
+ }
+ if (((RuleType) this.data).getEffect() == EffectType.DENY) {
+ return new ThemeResource("icons/deny-16.png");
+ }
+ return new ThemeResource("icons/permit-16.png");
+ }
+ if (this.data instanceof PolicyType) {
+ return new ThemeResource("../runo/icons/16/document-txt.png");
+ }
+ if (this.data instanceof TargetType) {
+ return new ThemeResource("icons/target-green-16.png");
+ }
+ if (this.data instanceof ObligationExpressionType) {
+ return new ThemeResource("icons/obligation-16.png");
+ }
+ if (this.data instanceof AdviceExpressionType) {
+ return new ThemeResource("icons/advice-16.png");
+ }
+ if (this.data instanceof ConditionType) {
+ return new ThemeResource("icons/condition-16.png");
+ }
+ if (this.data instanceof VariableDefinitionType) {
+ return new ThemeResource("icons/variable-16.png");
+ }
+ return null;
+ }
+
+ public String getStatus() {
+ StringBuffer buffer = new StringBuffer();
+ String a = this.getAlgorithm();
+ //String id = this.getId();
+ if (this.data instanceof RuleType) {
+ RuleType rule = ((RuleType) this.data);
+ buffer.append("Rule");
+ EffectType effect = rule.getEffect();
+ if (effect == null) {
+ rule.setEffect(EffectType.PERMIT);
+ }
+ if (rule.getEffect() == EffectType.PERMIT) {
+ buffer.append(" (PERMIT)");
+ } else if (rule.getEffect() == EffectType.DENY) {
+ buffer.append(" (DENY)");
+ }
+ } else if (this.data instanceof PolicyType) {
+ buffer.append("Policy");
+ } else if (this.data instanceof PolicySetType) {
+ buffer.append("Policy Set");
+ }
+ /*
+ if (id != null) {
+ String[] ids = id.split("[:]");
+ if (ids.length > 0) {
+ buffer.append(" " + ids[ids.length - 1]);
+ }
+ }
+ */
+ if (a != null) {
+ String[] algs = a.split("[:]");
+ if (algs.length > 0) {
+ buffer.append(" (" + algs[algs.length - 1] + ")");
+ }
+ }
+ /*
+ String d = this.getDescription();
+ if (d != null) {
+ buffer.append(" " + d);
+ }
+ */
+ return buffer.toString();
+ }
+
+ public Table getAttributes() {
+ /*
+ if (this.data instanceof MatchType) {
+
+ }
+ */
+ return null;
+ }
+
+ protected String getRootExpressionFunction(JAXBElement<?> element) {
+ if (element == null || element.getValue() == null) {
+ return null;
+ }
+ Object value = element.getValue();
+ if (value instanceof ApplyType) {
+ return ((ApplyType) value).getFunctionId();
+ }
+ if (value instanceof AttributeValueType) {
+ return ((AttributeValueType) value).getDataType();
+ }
+ if (value instanceof AttributeDesignatorType) {
+ return ((AttributeDesignatorType) value).getAttributeId();
+ }
+ if (value instanceof AttributeSelectorType) {
+ return ((AttributeSelectorType) value).getContextSelectorId();
+ }
+ if (value instanceof VariableReferenceType) {
+ return "Variable=" + ((VariableReferenceType) value).getVariableId();
+ }
+ if (value instanceof FunctionType) {
+ return ((FunctionType) value).getFunctionId();
+ }
+ return null;
+ }
+
+ @Override
+ public Property<?> getItemProperty(Object id) {
+ return getContainerProperty(data, id);
+ }
+
+ @Override
+ public Collection<?> getItemPropertyIds() {
+ return getContainerPropertyIds();
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public boolean addItemProperty(Object id, Property property) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Policy container does not support adding new properties");
+ }
+
+ @Override
+ public boolean removeItemProperty(Object id) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Policy container does not support property removal");
+ }
+
+ @Override
+ public String toString() {
+ return this.getName();
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/AdminNotification.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/AdminNotification.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/AdminNotification.java
new file mode 100644
index 0000000..944c3c8
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/AdminNotification.java
@@ -0,0 +1,56 @@
+/*
+ * 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.xacml.admin.util;
+
+import com.vaadin.ui.Notification;
+
+/**
+ * A simple mechanism for displaying messages to the user.
+ *
+ * At the moment this is a very thin layer on top of the Vaadin Notification class.
+ * There are two reasons for this class existing:
+ * - simplifying (slightly) the code, in that the type is in the method call just like logging
+ * - this is a central point where all messages are done, which allows us to globally change how they are displayed if we wish.
+ *
+ * @author glenngriffin
+ *
+ */
+public class AdminNotification {
+ //
+ // PUBLIC STATIC METHODS
+ //
+
+ public static void info(String caption) {
+ Notification.show(caption, Notification.Type.HUMANIZED_MESSAGE);
+ }
+
+ public static void warn(String caption) {
+ Notification.show(caption, Notification.Type.WARNING_MESSAGE);
+ }
+
+ public static void error(String caption) {
+ Notification.show(caption, Notification.Type.ERROR_MESSAGE);
+ }
+
+
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/JPAUtils.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/JPAUtils.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/JPAUtils.java
new file mode 100644
index 0000000..72c8a85
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/util/JPAUtils.java
@@ -0,0 +1,406 @@
+/*
+ * 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.xacml.admin.util;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeSelectorType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.EffectType;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.jpa.Attribute;
+import org.apache.openaz.xacml.admin.jpa.Category;
+import org.apache.openaz.xacml.admin.jpa.ConstraintType;
+import org.apache.openaz.xacml.admin.jpa.Datatype;
+import org.apache.openaz.xacml.admin.jpa.FunctionDefinition;
+import org.apache.openaz.xacml.admin.jpa.Obadvice;
+import org.apache.openaz.xacml.admin.jpa.PIPType;
+import org.apache.openaz.xacml.admin.jpa.PolicyAlgorithms;
+import org.apache.openaz.xacml.admin.jpa.RuleAlgorithms;
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.api.XACML3;
+import com.vaadin.addon.jpacontainer.JPAContainer;
+import com.vaadin.ui.UI;
+
+public class JPAUtils {
+ private static Log logger = LogFactory.getLog(JPAUtils.class);
+
+ private static final Object mapAccess = new Object();
+ private static Map<Datatype, List<FunctionDefinition>> mapDatatype2Function = null;
+ private static Map<String, FunctionDefinition> mapID2Function = null;
+ private static final Object booleanAccess = new Object();
+ private static Datatype booleanDatatype = null;
+
+ public static Datatype getBooleanDatatype() {
+ synchronized(booleanAccess) {
+ if (booleanDatatype == null) {
+ booleanDatatype = JPAUtils.findDatatype(XACML3.ID_DATATYPE_BOOLEAN);
+ }
+ return booleanDatatype;
+ }
+ }
+
+ public static AttributeDesignatorType createDesignator(Attribute attribute) {
+ AttributeDesignatorType designator = new AttributeDesignatorType();
+ designator.setAttributeId(attribute.getXacmlId());
+ if (attribute.getCategoryBean() != null) {
+ designator.setCategory(attribute.getCategoryBean().getXacmlId());
+ } else {
+ logger.warn("No category bean");
+ }
+ if (attribute.getDatatypeBean() != null) {
+ designator.setDataType(attribute.getDatatypeBean().getXacmlId());
+ } else {
+ logger.warn("No datatype bean");
+ }
+ designator.setIssuer(attribute.getIssuer());
+ designator.setMustBePresent(attribute.isMustBePresent());
+ return designator;
+ }
+
+ public static AttributeSelectorType createSelector(Attribute attribute) {
+ AttributeSelectorType selector = new AttributeSelectorType();
+ selector.setContextSelectorId(attribute.getXacmlId());
+ selector.setPath(attribute.getSelectorPath());
+ if (attribute.getCategoryBean() != null) {
+ selector.setCategory(attribute.getCategoryBean().getXacmlId());
+ } else {
+ logger.warn("No category bean");
+ }
+ if (attribute.getDatatypeBean() != null) {
+ selector.setDataType(attribute.getDatatypeBean().getXacmlId());
+ } else {
+ logger.warn("No datatype bean");
+ }
+ selector.setMustBePresent(attribute.isMustBePresent());
+ return selector;
+ }
+
+ public static Attribute createAttribute(AttributeDesignatorType designator) {
+ Attribute attribute = new Attribute();
+ attribute.setCategoryBean(JPAUtils.findCategory(designator.getCategory()));
+ attribute.setDatatypeBean(JPAUtils.findDatatype(designator.getDataType()));
+ attribute.setXacmlId(designator.getAttributeId());
+ attribute.setIssuer(designator.getIssuer());
+ attribute.setIsDesignator(true);
+ return attribute;
+ }
+
+ public static Attribute createAttribute(AttributeSelectorType selector) {
+ Attribute attribute = new Attribute();
+ attribute.setCategoryBean(JPAUtils.findCategory(selector.getCategory()));
+ attribute.setDatatypeBean(JPAUtils.findDatatype(selector.getDataType()));
+ attribute.setXacmlId(selector.getContextSelectorId());
+ attribute.setSelectorPath(selector.getPath());
+ attribute.setIsDesignator(false);
+ return attribute;
+ }
+
+ public static Attribute findAttribute(Attribute attribute) {
+ return JPAUtils.findAttribute(attribute.getCategoryBean(), attribute.getDatatypeBean(), attribute.getXacmlId());
+ }
+
+ public static Attribute findAttribute(Category category, Datatype datatype, String attributeID) {
+ if (category == null || datatype == null | attributeID == null) {
+ return null;
+ }
+ return JPAUtils.findAttribute(category.getXacmlId(), datatype.getXacmlId(), attributeID);
+ }
+
+ public static Attribute findAttribute(String category, String dataType, String attributeId) {
+ if (category == null || dataType == null | attributeId == null) {
+ return null;
+ }
+ JPAContainer<Attribute> attributes = ((XacmlAdminUI)UI.getCurrent()).getAttributes();
+ for (Object id : attributes.getItemIds()) {
+ Attribute a = attributes.getItem(id).getEntity();
+ if (a.getCategoryBean().getXacmlId().equals(category) &&
+ a.getDatatypeBean().getXacmlId().equals(dataType) &&
+ a.getXacmlId().equals(attributeId)) {
+ return a;
+ }
+ }
+ return null;
+ }
+
+ public static Category findCategory(Identifier cat) {
+ JPAContainer<Category> categories = ((XacmlAdminUI)UI.getCurrent()).getCategories();
+ for (Object id : categories.getItemIds()) {
+ Category c = categories.getItem(id).getEntity();
+ if (c.getIdentifer().equals(cat)) {
+ return c;
+ }
+ }
+ return null;
+ }
+
+ public static Category findCategory(String cat) {
+ JPAContainer<Category> categories = ((XacmlAdminUI)UI.getCurrent()).getCategories();
+ for (Object id : categories.getItemIds()) {
+ Category c = categories.getItem(id).getEntity();
+ if (c.getIdentifer().stringValue().equals(cat)) {
+ return c;
+ }
+ }
+ return null;
+ }
+
+ public static Datatype findDatatype(Identifier dt) {
+ JPAContainer<Datatype> datatypes = ((XacmlAdminUI)UI.getCurrent()).getDatatypes();
+
+ for (Object id : datatypes.getItemIds()) {
+ Datatype d = datatypes.getItem(id).getEntity();
+ if (d.getIdentifer().equals(dt)) {
+ return d;
+ }
+ }
+ return null;
+ }
+
+ public static Datatype findDatatype(String dt) {
+ JPAContainer<Datatype> datatypes = ((XacmlAdminUI)UI.getCurrent()).getDatatypes();
+
+ for (Object id : datatypes.getItemIds()) {
+ Datatype d = datatypes.getItem(id).getEntity();
+ if (d.getIdentifer().stringValue().equals(dt)) {
+ return d;
+ }
+ }
+ return null;
+ }
+
+ public static Datatype findDatatype(int datatypeId) {
+ JPAContainer<Datatype> datatypes = ((XacmlAdminUI)UI.getCurrent()).getDatatypes();
+
+ for (Object id : datatypes.getItemIds()) {
+ Datatype d = datatypes.getItem(id).getEntity();
+ if (d.getId() == datatypeId) {
+ return d;
+ }
+ }
+ return null;
+ }
+
+ public static ConstraintType findConstraintType(String type) {
+ JPAContainer<ConstraintType> types = ((XacmlAdminUI)UI.getCurrent()).getConstraintTypes();
+ for (Object id : types.getItemIds()) {
+ ConstraintType value = types.getItem(id).getEntity();
+ if (value.getConstraintType().equals(type)) {
+ return value;
+ }
+ }
+ return null;
+ }
+
+ public static FunctionDefinition findFunction(String functionId) {
+ if (functionId == null) {
+ throw new IllegalArgumentException("Cannot find a null function id");
+ }
+ JPAContainer<FunctionDefinition> functions = ((XacmlAdminUI)UI.getCurrent()).getFunctionDefinitions();
+ for (Object id : functions.getItemIds()) {
+ FunctionDefinition value = functions.getItem(id).getEntity();
+ if (value.getXacmlid().equals(functionId)) {
+ return value;
+ }
+ }
+ return null;
+ }
+
+ public static PolicyAlgorithms findPolicyAlgorithm(String algorithm) {
+ if (algorithm == null) {
+ throw new IllegalArgumentException("Cannot find a null algorithm");
+ }
+ JPAContainer<PolicyAlgorithms> algorithms = ((XacmlAdminUI)UI.getCurrent()).getPolicyAlgorithms();
+ for (Object id : algorithms.getItemIds()) {
+ PolicyAlgorithms alg = algorithms.getItem(id).getEntity();
+ if (alg.getXacmlId().equals(algorithm)) {
+ return alg;
+ }
+ }
+ return null;
+ }
+
+ public static RuleAlgorithms findRuleAlgorithm(String algorithm) {
+ if (algorithm == null) {
+ throw new IllegalArgumentException("Cannot find a null algorithm");
+ }
+ JPAContainer<RuleAlgorithms> algorithms = ((XacmlAdminUI)UI.getCurrent()).getRuleAlgorithms();
+ for (Object id : algorithms.getItemIds()) {
+ RuleAlgorithms alg = algorithms.getItem(id).getEntity();
+ if (alg.getXacmlId().equals(algorithm)) {
+ return alg;
+ }
+ }
+ return null;
+ }
+
+ public static Obadvice findObligation(Identifier id, EffectType effect) {
+ if (id == null) {
+ return null;
+ }
+ return JPAUtils.findObligation(id.stringValue(), effect);
+ }
+
+ public static Obadvice findObligation(String id, EffectType effect) {
+ JPAContainer<Obadvice> oa = ((XacmlAdminUI)UI.getCurrent()).getObadvice();
+ for (Object oaID : oa.getItemIds()) {
+ Obadvice obligation = oa.getItem(oaID).getEntity();
+ if (obligation.getType().equals(Obadvice.OBLIGATION) &&
+ obligation.getXacmlId().equals(id) &&
+ obligation.getFulfillOn().equals((effect == EffectType.PERMIT ? Obadvice.EFFECT_PERMIT : Obadvice.EFFECT_DENY))) {
+ return obligation;
+ }
+ }
+ return null;
+ }
+
+ public static Obadvice findAdvice(Identifier id, EffectType effect) {
+ if (id == null) {
+ return null;
+ }
+ return JPAUtils.findAdvice(id.stringValue(), effect);
+ }
+
+ public static Obadvice findAdvice(String id, EffectType effect) {
+ JPAContainer<Obadvice> oa = ((XacmlAdminUI)UI.getCurrent()).getObadvice();
+ for (Object oaID : oa.getItemIds()) {
+ Obadvice advice = oa.getItem(oaID).getEntity();
+ if (advice.getType().equals(Obadvice.ADVICE) &&
+ advice.getXacmlId().equals(id) &&
+ advice.getFulfillOn().equals((effect == EffectType.PERMIT ? Obadvice.EFFECT_PERMIT : Obadvice.EFFECT_DENY))) {
+ return advice;
+ }
+ }
+ return null;
+ }
+
+ public static Attribute isStandardAttribute(Attribute attribute) {
+ return JPAUtils.isStandardAttribute(attribute.getCategoryBean(), attribute.getDatatypeBean(), attribute.getXacmlId());
+ }
+
+ public static Attribute isStandardAttribute(Category categoryBean, Datatype datatypeBean, String xacmlId) {
+ if (categoryBean == null || datatypeBean == null || xacmlId == null) {
+ return null;
+ }
+ return JPAUtils.isStandardAttribute(categoryBean.getXacmlId(), datatypeBean.getXacmlId(), xacmlId);
+ }
+
+ public static Attribute isStandardAttribute(String category, String datatype, String id) {
+ if (category == null || datatype == null || id == null) {
+ return null;
+ }
+ Category cat = JPAUtils.findCategory(category);
+ if (cat == null) {
+ return null;
+ }
+ Datatype dt = JPAUtils.findDatatype(datatype);
+ if (dt == null) {
+ return null;
+ }
+ Identifier identifier = null;
+ Iterator<Identifier> iter = XACMLConstants.STANDARD_ATTRIBUTES.iterator();
+ while (iter.hasNext()) {
+ Identifier i = iter.next();
+ if (i.stringValue().equals(id)) {
+ identifier = i;
+ break;
+ }
+ }
+ if (identifier == null) {
+ return null;
+ }
+ Attribute attribute = new Attribute();
+ attribute.setCategoryBean(cat);
+ attribute.setDatatypeBean(dt);
+ attribute.setXacmlId(identifier.stringValue());
+ return attribute;
+ }
+
+ /**
+ * Builds a map in memory of a functions return datatype to function definition. Useful in limiting the number
+ * of SQL calls to DB especially when we don't expect these to change much.
+ *
+ * @return - A HashMap of Datatype JPA Container ID's to FunctionDefinition objects
+ */
+ public static Map<Datatype, List<FunctionDefinition>> getFunctionDatatypeMap() {
+
+ synchronized(mapAccess) {
+ if (mapDatatype2Function == null) {
+ buildFunctionMaps();
+ }
+ }
+ return mapDatatype2Function;
+ }
+
+ public static Map<String, FunctionDefinition> getFunctionIDMap() {
+ synchronized(mapAccess) {
+ if (mapID2Function == null) {
+ buildFunctionMaps();
+ }
+ }
+ return mapID2Function;
+ }
+
+ private static void buildFunctionMaps() {
+ mapDatatype2Function = new HashMap<Datatype, List<FunctionDefinition>>();
+ mapID2Function = new HashMap<String, FunctionDefinition>();
+ JPAContainer<FunctionDefinition> functions = ((XacmlAdminUI)UI.getCurrent()).getFunctionDefinitions();
+ for (Object id : functions.getItemIds()) {
+ FunctionDefinition value = functions.getItem(id).getEntity();
+ mapID2Function.put(value.getXacmlid(), value);
+ if (mapDatatype2Function.containsKey(value.getDatatypeBean()) == false) {
+ mapDatatype2Function.put(value.getDatatypeBean(), new ArrayList<FunctionDefinition>());
+ }
+ mapDatatype2Function.get(value.getDatatypeBean()).add(value);
+ }
+ }
+
+ public static void dumpDatatype2FunctionMap() {
+ if (logger.isDebugEnabled() == false) {
+ return;
+ }
+ Map<Datatype, List<FunctionDefinition>> map = getFunctionDatatypeMap();
+ for (Datatype dt : map.keySet()) {
+ for (FunctionDefinition function: map.get(dt)) {
+ logger.debug("Datatype: " + (dt != null ? dt.getId() : "null") + " " + function.getXacmlid() + " (" + (function.getDatatypeBean() != null ? function.getDatatypeBean().getId() : "null") + ")");
+ }
+ }
+ }
+
+ public static PIPType getPIPType(String typeName) {
+ for (Object id : ((XacmlAdminUI) UI.getCurrent()).getPIPTypes().getItemIds()) {
+ PIPType type = ((XacmlAdminUI) UI.getCurrent()).getPIPTypes().getItem(id).getEntity();
+ if (type.getType().equals(typeName)) {
+ return type;
+ }
+ }
+ return null;
+ }
+
+}
[13/23] incubator-openaz git commit: Ported original att source to
openaz
Posted by pd...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/PDPPIPContainer.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/PDPPIPContainer.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/PDPPIPContainer.java
new file mode 100644
index 0000000..aa2fb87
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/PDPPIPContainer.java
@@ -0,0 +1,457 @@
+/*
+ * 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.xacml.admin.model;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.jpa.PIPConfiguration;
+import org.apache.openaz.xacml.admin.jpa.PIPResolver;
+import org.apache.openaz.xacml.api.pap.PDP;
+import org.apache.openaz.xacml.api.pap.PDPGroup;
+import org.apache.openaz.xacml.api.pap.PDPPIPConfig;
+import org.apache.openaz.xacml.api.pip.PIPException;
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.util.MethodProperty;
+
+public class PDPPIPContainer extends ItemSetChangeNotifier implements Container.Hierarchical, Container.ItemSetChangeNotifier {
+ private static final long serialVersionUID = 1L;
+ private static Log logger = LogFactory.getLog(PDPPIPContainer.class);
+
+ /**
+ * String identifier of a file's "Id" property.
+ */
+ public static String PROPERTY_ID = "Id";
+
+ /**
+ * String identifier of a file's "name" property.
+ */
+ public static String PROPERTY_NAME = "Name";
+
+ /**
+ * String identifier of a file's "Description" property.
+ */
+ public static String PROPERTY_DESCRIPTION = "Description";
+
+ /**
+ * List of the string identifiers for the available properties.
+ */
+ public static Collection<String> PDPPIP_PROPERTIES;
+
+ private final static Method PDPPIPITEM_ID;
+
+ private final static Method PDPPIPITEM_NAME;
+
+ private final static Method PDPPIPITEM_DESCRIPTION;
+
+ static {
+ PDPPIP_PROPERTIES = new ArrayList<String>();
+ PDPPIP_PROPERTIES.add(PROPERTY_ID);
+ PDPPIP_PROPERTIES.add(PROPERTY_NAME);
+ PDPPIP_PROPERTIES.add(PROPERTY_DESCRIPTION);
+ PDPPIP_PROPERTIES = Collections.unmodifiableCollection(PDPPIP_PROPERTIES);
+ try {
+ PDPPIPITEM_ID = PDPPIPItem.class.getMethod("getId", new Class[]{});
+ PDPPIPITEM_NAME = PDPPIPItem.class.getMethod("getName", new Class[]{});
+ PDPPIPITEM_DESCRIPTION = PDPPIPItem.class.getMethod("getDescription", new Class[] {});
+ } catch (final NoSuchMethodException e) {
+ throw new RuntimeException(
+ "Internal error finding methods in PDPPIPContainer");
+ }
+ }
+
+ private final Object data;
+
+ List<PIPConfiguration> configurations = new ArrayList<PIPConfiguration>();
+
+ public PDPPIPContainer(Object data) {
+ super();
+ setContainer(this);
+ //
+ // Save our object
+ //
+ this.data = data;
+ //
+ // Is it supported?
+ //
+ if (this.isPDPGroup() == false && this.isPDP() == false) {
+ throw new IllegalArgumentException("This container only supported PDPGroup and PDP objects.");
+ }
+ //
+ // Initialize our internal structures
+ //
+ initialize();
+ }
+
+ private boolean isSupported(Object itemId) {
+ if (this.isConfiguration(itemId) ||
+ this.isResolver(itemId) ) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean isPDPGroup() {
+ return this.data instanceof PDPGroup;
+ }
+
+ private boolean isPDP() {
+ return this.data instanceof PDP;
+ }
+
+ private boolean isConfiguration(Object itemId) {
+ return itemId instanceof PIPConfiguration;
+ }
+
+ private boolean isResolver(Object itemId) {
+ return itemId instanceof PIPResolver;
+ }
+
+ private void initialize() {
+ assert this.data != null;
+ //
+ // Get the list of configurations
+ //
+ Set<PDPPIPConfig> configs = null;
+ if (this.isPDPGroup()) {
+ configs = ((PDPGroup) this.data).getPipConfigs();
+ } else if (this.isPDP()) {
+ configs = ((PDP) this.data).getPipConfigs();
+ } else {
+ throw new IllegalArgumentException("This container only supported PDPGroup and PDP objects.");
+ }
+ //
+ // Map these to a list of PIPConfiguration objects. That
+ // way we can match them up to the database.
+ //
+ for (PDPPIPConfig config : configs) {
+ Properties properties = new Properties();
+ properties.putAll(config.getConfiguration());
+ try {
+ PIPConfiguration pipConfig = new PIPConfiguration(config.getId(), properties);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Found config: " + pipConfig);
+ }
+ this.configurations.add(pipConfig);
+ } catch (PIPException e) {
+ logger.error("Failed to create PIPConfiguration: " + e.getLocalizedMessage());
+ }
+ }
+ }
+
+
+ public void refresh() {
+ this.configurations.clear();
+ this.initialize();
+ this.fireItemSetChange();
+ }
+
+ @Override
+ public Item getItem(Object itemId) {
+ if (this.isSupported(itemId)) {
+ return new PDPPIPItem(itemId);
+ }
+ return null;
+ }
+
+ @Override
+ public Collection<?> getContainerPropertyIds() {
+ return PDPPIP_PROPERTIES;
+ }
+
+ @Override
+ public Collection<?> getItemIds() {
+ final Collection<Object> items = new ArrayList<Object>();
+ for (PIPConfiguration config : this.configurations) {
+ items.add(config);
+ /*
+ for (PIPResolver resolver : config.getPipresolvers()) {
+ items.add(resolver);
+ }
+ */
+ }
+ return Collections.unmodifiableCollection(items);
+ }
+
+ @Override
+ public Property<?> getContainerProperty(Object itemId, Object propertyId) {
+ if (this.isSupported(itemId) == false) {
+ return null;
+ }
+
+ if (propertyId.equals(PROPERTY_ID)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPPIPItem(itemId), PDPPIPITEM_ID, null);
+ }
+
+ if (propertyId.equals(PROPERTY_NAME)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPPIPItem(itemId), PDPPIPITEM_NAME, null);
+ }
+
+ if (propertyId.equals(PROPERTY_DESCRIPTION)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPPIPItem(itemId), PDPPIPITEM_DESCRIPTION, null);
+ }
+
+ return null;
+ }
+
+ @Override
+ public Class<?> getType(Object propertyId) {
+ if (propertyId.equals(PROPERTY_ID)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_NAME)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_DESCRIPTION)) {
+ return String.class;
+ }
+ return null;
+ }
+
+ @Override
+ public int size() {
+ /*
+ int size = 0;
+ for (PIPConfiguration config : this.configurations) {
+ size++;
+ size += config.getPipresolvers().size();
+ }
+ return size;
+ */
+ return this.configurations.size();
+ }
+
+ @Override
+ public boolean containsId(Object itemId) {
+ //
+ // Let's try this by using the Id
+ //
+ for (PIPConfiguration config : this.configurations) {
+ if (this.isConfiguration(itemId)) {
+ if (((PIPConfiguration) itemId).getId() == config.getId()) {
+ return true;
+ }
+ } else if (this.isResolver(itemId)) {
+ for (PIPResolver resolver : config.getPipresolvers()) {
+ if (((PIPResolver) itemId).getId() == resolver.getId()) {
+ return true;
+ }
+ }
+ } else {
+ throw new IllegalArgumentException("This container only supports pip configuration and resolvers objects.");
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public Item addItem(Object itemId) throws UnsupportedOperationException {
+ if (this.isConfiguration(itemId)) {
+ this.configurations.add((PIPConfiguration) itemId);
+ // } else if (this.isResolver(itemId)) {
+ }
+ throw new UnsupportedOperationException("Cannot add unsupported object.");
+ }
+
+ @Override
+ public Object addItem() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot add unknown object.");
+ }
+
+ @Override
+ public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Adding properties not supported.");
+ }
+
+ @Override
+ public boolean removeContainerProperty(Object propertyId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Removing properties not supported.");
+ }
+
+ @Override
+ public boolean removeAllItems() throws UnsupportedOperationException {
+ //
+ // Remove everything
+ //
+ this.configurations.clear();
+ return true;
+ }
+
+ @Override
+ public Collection<?> getChildren(Object itemId) {
+ if (this.isConfiguration(itemId)) {
+ Collection<Object> children = new ArrayList<Object>();
+ for (PIPConfiguration config : this.configurations) {
+ if (config.getId() == ((PIPConfiguration) itemId).getId()) {
+ /*
+ * Not for this release
+ *
+ children.addAll(config.getPipresolvers());
+ */
+ break;
+ }
+ }
+ return Collections.unmodifiableCollection(children);
+ }
+ return Collections.emptyList();
+ }
+
+ @Override
+ public Object getParent(Object itemId) {
+ if (this.isResolver(itemId)) {
+ return ((PIPResolver) itemId).getPipconfiguration();
+ }
+ return null;
+ }
+
+ @Override
+ public Collection<?> rootItemIds() {
+ Collection<Object> roots = new ArrayList<Object>();
+ roots.addAll(this.configurations);
+ return Collections.unmodifiableCollection(roots);
+ }
+
+ @Override
+ public boolean setParent(Object itemId, Object newParentId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Not allowed in this implementation.");
+ }
+
+ @Override
+ public boolean areChildrenAllowed(Object itemId) {
+ if (this.isConfiguration(itemId)) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot change which objects can or cannot have children.");
+ }
+
+ @Override
+ public boolean isRoot(Object itemId) {
+ if (this.isConfiguration(itemId)) {
+ return this.containsId(itemId);
+ }
+ return false;
+ }
+
+ @Override
+ public boolean hasChildren(Object itemId) {
+ if (this.isConfiguration(itemId)) {
+ //return ((PIPConfiguration) itemId).getPipresolvers().size() > 0;
+ //
+ // Not this implementation
+ return false;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean removeItem(Object itemId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Not allowed in this implementation.");
+ /*
+ if (this.isConfiguration(itemId)) {
+ return this.configurations.remove(itemId);
+ }
+ if (this.isResolver(itemId)) {
+ ((PIPResolver) itemId).getPipconfiguration().removePipresolver((PIPResolver) itemId);
+ }
+ throw new UnsupportedOperationException("Object not supported by this container.");
+ */
+ }
+
+ public class PDPPIPItem implements Item {
+ private static final long serialVersionUID = 1L;
+
+ private final Object config;
+
+ public PDPPIPItem(Object config) {
+ this.config = config;
+ }
+
+ public String getId() {
+ if (this.config instanceof PIPConfiguration) {
+ return Integer.toString(((PIPConfiguration) this.config).getId());
+ }
+ if (this.config instanceof PIPResolver) {
+ return Integer.toString(((PIPResolver) this.config).getId());
+ }
+ return null;
+ }
+
+ public String getName() {
+ if (this.config instanceof PIPConfiguration) {
+ return ((PIPConfiguration) this.config).getName();
+ }
+ if (this.config instanceof PIPResolver) {
+ return ((PIPResolver) this.config).getName();
+ }
+ return null;
+ }
+
+ public String getDescription() {
+ if (this.config instanceof PIPConfiguration) {
+ return ((PIPConfiguration) this.config).getDescription();
+ }
+ if (this.config instanceof PIPResolver) {
+ return ((PIPResolver) this.config).getDescription();
+ }
+ return null;
+ }
+
+ @Override
+ public Property<?> getItemProperty(Object id) {
+ return getContainerProperty(config, id);
+ }
+
+ @Override
+ public Collection<?> getItemPropertyIds() {
+ return getContainerPropertyIds();
+ }
+
+ @Override
+ public boolean addItemProperty(Object id, @SuppressWarnings("rawtypes") Property property)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot add property.");
+ }
+
+ @Override
+ public boolean removeItemProperty(Object id)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot remove property.");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/PDPPolicyContainer.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/PDPPolicyContainer.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/PDPPolicyContainer.java
new file mode 100644
index 0000000..bb015c1
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/PDPPolicyContainer.java
@@ -0,0 +1,469 @@
+/*
+ * 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.xacml.admin.model;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.api.pap.PDP;
+import org.apache.openaz.xacml.api.pap.PDPGroup;
+import org.apache.openaz.xacml.api.pap.PDPPolicy;
+import org.apache.openaz.xacml.std.pap.StdPDPPolicy;
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.util.MethodProperty;
+
+public class PDPPolicyContainer extends ItemSetChangeNotifier implements Container.Indexed {
+ private static final long serialVersionUID = 1L;
+ private static Log logger = LogFactory.getLog(PDPPolicyContainer.class);
+
+ /**
+ * String identifier of a file's "Id" property.
+ */
+ public static String PROPERTY_ID = "Id";
+
+ /**
+ * String identifier of a file's "name" property.
+ */
+ public static String PROPERTY_NAME = "Name";
+
+ /**
+ * String identifier of a file's "name" property.
+ */
+ public static String PROPERTY_VERSION = "Version";
+
+ /**
+ * String identifier of a file's "Description" property.
+ */
+ public static String PROPERTY_DESCRIPTION = "Description";
+
+ /**
+ * String identifier of a file's "IsRoot" property.
+ */
+ public static String PROPERTY_ISROOT = "Root";
+
+ /**
+ * List of the string identifiers for the available properties.
+ */
+ public static Collection<String> PDPPOLICY_PROPERTIES;
+
+ private final static Method PDPPOLICYITEM_ID;
+
+ private final static Method PDPPOLICYITEM_NAME;
+
+ private final static Method PDPPOLICYITEM_VERSION;
+
+ private final static Method PDPPOLICYITEM_DESCRIPTION;
+
+ private final static Method PDPPOLICYITEM_ISROOT;
+
+ private final static Method PDPPOLICYITEM_SETISROOT;
+
+ static {
+ PDPPOLICY_PROPERTIES = new ArrayList<String>();
+ PDPPOLICY_PROPERTIES.add(PROPERTY_ID);
+ PDPPOLICY_PROPERTIES.add(PROPERTY_NAME);
+ PDPPOLICY_PROPERTIES.add(PROPERTY_VERSION);
+ PDPPOLICY_PROPERTIES.add(PROPERTY_DESCRIPTION);
+ PDPPOLICY_PROPERTIES.add(PROPERTY_ISROOT);
+ PDPPOLICY_PROPERTIES = Collections.unmodifiableCollection(PDPPOLICY_PROPERTIES);
+ try {
+ PDPPOLICYITEM_ID = PDPPolicyItem.class.getMethod("getId", new Class[]{});
+ PDPPOLICYITEM_NAME = PDPPolicyItem.class.getMethod("getName", new Class[]{});
+ PDPPOLICYITEM_VERSION = PDPPolicyItem.class.getMethod("getVersion", new Class[]{});
+ PDPPOLICYITEM_DESCRIPTION = PDPPolicyItem.class.getMethod("getDescription", new Class[] {});
+ PDPPOLICYITEM_ISROOT = PDPPolicyItem.class.getMethod("getRoot", new Class[] {});
+ PDPPOLICYITEM_SETISROOT = PDPPolicyItem.class.getMethod("setRoot", new Class[] {Boolean.class});
+ } catch (final NoSuchMethodException e) {
+ throw new RuntimeException(
+ "Internal error finding methods in PDPContainer");
+ }
+ }
+
+ private final Object data;
+ private List<PDPPolicy> policies;
+
+ public PDPPolicyContainer(Object data) {
+ super();
+ this.data = data;
+ if (this.data instanceof PDPGroup) {
+ policies = new ArrayList<PDPPolicy> (((PDPGroup) this.data).getPolicies());
+ }
+ if (this.data instanceof PDP) {
+ policies = new ArrayList<PDPPolicy> (((PDP) this.data).getPolicies());
+ }
+ if (this.data instanceof Set) {
+ policies = new ArrayList<PDPPolicy> ((Set<PDPPolicy>)data);
+ }
+ if (this.policies == null) {
+ logger.info("NULL policies");
+ throw new NullPointerException("PDPPolicyContainer created with unexpected Object type '" + data.getClass().getName() + "'");
+ }
+ this.setContainer(this);
+ }
+
+ @Override
+ public Object nextItemId(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("nextItemId: " + itemId);
+ }
+ int index = this.policies.indexOf(itemId);
+ if (index == -1 || (index + 1) >= this.policies.size()) {
+ return null;
+ }
+ return new PDPPolicyItem(this.policies.get(index + 1));
+ }
+
+ @Override
+ public Object prevItemId(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("prevItemId: " + itemId);
+ }
+ int index = this.policies.indexOf(itemId);
+ if (index <= 0) {
+ return null;
+ }
+ return new PDPPolicyItem(this.policies.get(index - 1));
+ }
+
+ @Override
+ public Object firstItemId() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("firstItemId: ");
+ }
+ if (this.policies.isEmpty()) {
+ return null;
+ }
+ return new PDPPolicyItem(this.policies.get(0));
+ }
+
+ @Override
+ public Object lastItemId() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("lastItemid: ");
+ }
+ if (this.policies.isEmpty()) {
+ return null;
+ }
+ return new PDPPolicyItem(this.policies.get(this.policies.size() - 1));
+ }
+
+ @Override
+ public boolean isFirstId(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("isFirstId: " + itemId);
+ }
+ if (this.policies.isEmpty()) {
+ return false;
+ }
+ return itemId.equals(this.policies.get(0));
+ }
+
+ @Override
+ public boolean isLastId(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("isLastId: " + itemId);
+ }
+ if (this.policies.isEmpty()) {
+ return false;
+ }
+ return itemId.equals(this.policies.get(this.policies.size() - 1));
+ }
+
+ @Override
+ public Object addItemAfter(Object previousItemId)
+ throws UnsupportedOperationException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Item addItemAfter(Object previousItemId, Object newItemId)
+ throws UnsupportedOperationException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Item getItem(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getItem: " + itemId);
+ }
+ if (itemId instanceof PDPPolicy) {
+ return new PDPPolicyItem((PDPPolicy) itemId);
+ }
+ return null;
+ }
+
+ @Override
+ public Collection<?> getContainerPropertyIds() {
+ return PDPPOLICY_PROPERTIES;
+ }
+
+ @Override
+ public Collection<?> getItemIds() {
+ final Collection<Object> items = new ArrayList<Object>();
+ items.addAll(this.policies);
+ return Collections.unmodifiableCollection(items);
+ }
+
+ @Override
+ public Property<?> getContainerProperty(Object itemId, Object propertyId) {
+ if (itemId instanceof PDPPolicy == false) {
+ return null;
+ }
+
+ if (propertyId.equals(PROPERTY_ID)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPPolicyItem((PDPPolicy) itemId), PDPPOLICYITEM_ID, null);
+ }
+
+ if (propertyId.equals(PROPERTY_NAME)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPPolicyItem((PDPPolicy) itemId), PDPPOLICYITEM_NAME, null);
+ }
+
+ if (propertyId.equals(PROPERTY_VERSION)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPPolicyItem((PDPPolicy) itemId), PDPPOLICYITEM_VERSION, null);
+ }
+
+ if (propertyId.equals(PROPERTY_DESCRIPTION)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPPolicyItem((PDPPolicy) itemId), PDPPOLICYITEM_DESCRIPTION, null);
+ }
+
+ if (propertyId.equals(PROPERTY_ISROOT)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPPolicyItem((PDPPolicy) itemId), PDPPOLICYITEM_ISROOT, PDPPOLICYITEM_SETISROOT);
+ }
+
+ return null;
+ }
+
+ @Override
+ public Class<?> getType(Object propertyId) {
+ if (propertyId.equals(PROPERTY_ID)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_NAME)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_VERSION)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_DESCRIPTION)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_ISROOT)) {
+ return Boolean.class;
+ }
+ return null;
+ }
+
+ @Override
+ public int size() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("size: " + this.policies.size());
+ }
+ return this.policies.size();
+ }
+
+ @Override
+ public boolean containsId(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("containsId: " + itemId);
+ }
+ return this.policies.contains(itemId);
+ }
+
+ @Override
+ public Item addItem(Object itemId) throws UnsupportedOperationException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("addItem: " + itemId);
+ }
+ if (itemId instanceof PDPPolicy) {
+ this.policies.add((PDPPolicy) itemId);
+ return new PDPPolicyItem((PDPPolicy)itemId);
+ }
+ return null;
+ }
+
+ @Override
+ public Object addItem() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot add an empty policy.");
+ }
+
+ @Override
+ public boolean removeItem(Object itemId)
+ throws UnsupportedOperationException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("removeItem: " + itemId);
+ }
+ return this.policies.remove(itemId);
+ }
+
+ @Override
+ public boolean addContainerProperty(Object propertyId, Class<?> type,
+ Object defaultValue) throws UnsupportedOperationException {
+ return false;
+ }
+
+ @Override
+ public boolean removeContainerProperty(Object propertyId)
+ throws UnsupportedOperationException {
+ return false;
+ }
+
+ @Override
+ public boolean removeAllItems() throws UnsupportedOperationException {
+ //this.policies = new ArrayList<PDPPolicy>();
+ //return true;
+ return false;
+ }
+
+ @Override
+ public int indexOfId(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("indexOfId: " + itemId);
+ }
+ return this.policies.indexOf(itemId);
+ }
+
+ @Override
+ public Object getIdByIndex(int index) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getIdByIndex: " + index);
+ }
+ return this.policies.get(index);
+ }
+
+ @Override
+ public List<?> getItemIds(int startIndex, int numberOfItems) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getItemIds: " + startIndex + " " + numberOfItems);
+ }
+ if (numberOfItems < 0) {
+ throw new IllegalArgumentException();
+ }
+ return this.policies.subList(startIndex, startIndex + numberOfItems);
+ }
+
+ @Override
+ public Object addItemAt(int index) throws UnsupportedOperationException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("addItemAt: " + index);
+ }
+ return null;
+ }
+
+ @Override
+ public Item addItemAt(int index, Object newItemId)
+ throws UnsupportedOperationException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("addItemAt: " + index + " " + newItemId);
+ }
+ return null;
+ }
+
+ public class PDPPolicyItem implements Item {
+ private static final long serialVersionUID = 1L;
+
+ private final PDPPolicy policy;
+
+ public PDPPolicyItem(PDPPolicy itemId) {
+ this.policy = itemId;
+ }
+
+ public String getId() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getId: " + this.policy);
+ }
+ return this.policy.getId();
+ }
+
+ public String getName() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getName: " + this.policy);
+ }
+ return this.policy.getName();
+ }
+
+ public String getVersion() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getVersion: " + this.policy);
+ }
+ return this.policy.getVersion();
+ }
+
+ public String getDescription() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getDescription: " + this.policy);
+ }
+ return this.policy.getDescription();
+ }
+
+ public boolean getRoot() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("isRoot: " + this.policy);
+ }
+ return this.policy.isRoot();
+ }
+
+ public void setRoot(Boolean root) {
+ ((StdPDPPolicy)this.policy).setRoot(root);
+ }
+
+ @Override
+ public Property<?> getItemProperty(Object id) {
+ return getContainerProperty(policy, id);
+ }
+
+ @Override
+ public Collection<?> getItemPropertyIds() {
+ return getContainerPropertyIds();
+ }
+
+ @Override
+ public boolean addItemProperty(Object id, @SuppressWarnings("rawtypes") Property property)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("PDP Policy container "
+ + "does not support adding new properties");
+ }
+
+ @Override
+ public boolean removeItemProperty(Object id)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException(
+ "PDP Policy container does not support property removal");
+ }
+
+ }
+}
+
[20/23] incubator-openaz git commit: Ported original att source to
openaz
Posted by pd...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/ObadviceDictionary.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/ObadviceDictionary.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/ObadviceDictionary.java
new file mode 100644
index 0000000..1b1edd4
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/ObadviceDictionary.java
@@ -0,0 +1,347 @@
+/*
+ * 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.xacml.admin.components;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.XacmlAdminAuthorization;
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.jpa.Obadvice;
+import org.apache.openaz.xacml.admin.view.windows.ObadviceEditorWindow;
+import com.vaadin.addon.jpacontainer.EntityItem;
+import com.vaadin.addon.jpacontainer.JPAContainer;
+import com.vaadin.addon.jpacontainer.provider.CachingLocalEntityProvider;
+import com.vaadin.addon.jpacontainer.provider.CachingMutableLocalEntityProvider;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.util.filter.Compare;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window.CloseEvent;
+import com.vaadin.ui.Window.CloseListener;
+
+public class ObadviceDictionary extends CustomComponent {
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Table table;
+ @AutoGenerated
+ private HorizontalLayout horizontalLayoutToolbar;
+ @AutoGenerated
+ private ComboBox comboBoxFilter;
+ @AutoGenerated
+ private Button buttonClone;
+ @AutoGenerated
+ private Button buttonRemove;
+ @AutoGenerated
+ private Button buttonNew;
+ private static final long serialVersionUID = 1L;
+ private static final Log logger = LogFactory.getLog(ObadviceDictionary.class);
+ private final ObadviceDictionary self = this;
+
+ private static final Object[] visibleColumns = new Object[] { "type", "xacmlId", "description", "fulfillOn", "modifiedBy", "modifiedDate", "createdBy", "createdDate"};
+ private static final String[] columnHeaders = new String[] { "Type", "Attribute ID", "Description", "FulFill/Apply", "Modified By", "Modified Date", "Created By", "Created Date"};
+
+ private final JPAContainer<Obadvice> obadvice = new JPAContainer<Obadvice>(Obadvice.class);
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ * @param jpaContainer
+ */
+ public ObadviceDictionary() {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+ //
+ // Setup container
+ //
+ boolean isReadOnly;
+ if (((XacmlAdminUI)UI.getCurrent()).isAuthorized(
+ XacmlAdminAuthorization.AdminAction.ACTION_WRITE,
+ XacmlAdminAuthorization.AdminResource.RESOURCE_DICTIONARIES)) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("write access");
+ }
+ isReadOnly = false;
+ this.obadvice.setEntityProvider(new CachingMutableLocalEntityProvider<Obadvice>(Obadvice.class, ((XacmlAdminUI)UI.getCurrent()).getEntityManager()));
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("read only access");
+ }
+ isReadOnly = true;
+ this.obadvice.setEntityProvider(new CachingLocalEntityProvider<Obadvice>(Obadvice.class, ((XacmlAdminUI)UI.getCurrent()).getEntityManager()));
+ }
+ //
+ // initialize
+ //
+ this.initializeTable(isReadOnly);
+ this.initializeButtons(isReadOnly);
+ this.initializeCombo();
+ }
+
+ protected void initializeTable(boolean isReadOnly) {
+ //
+ // Set our container
+ //
+ this.table.setContainerDataSource(this.obadvice);
+ //
+ // Initialize GUI properties
+ //
+ this.table.setVisibleColumns(visibleColumns);
+ this.table.setColumnHeaders(columnHeaders);
+ this.table.setImmediate(true);
+ this.table.setColumnCollapsingAllowed(true);
+ //
+ // Is read only
+ //
+ if (isReadOnly) {
+ return;
+ }
+ this.table.setSelectable(true);
+ //
+ // Respond to selections
+ //
+ this.table.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ self.buttonRemove.setEnabled(self.table.getValue() != null);
+ self.buttonClone.setEnabled(self.table.getValue() != null);
+ }
+ });
+ }
+
+ protected void initializeButtons(boolean isReadOnly) {
+ if (isReadOnly) {
+ this.buttonNew.setVisible(false);
+ this.buttonRemove.setVisible(false);
+ this.buttonClone.setVisible(false);
+ return;
+ }
+ //
+ // NEW button
+ //
+ this.buttonNew.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ //
+ // Create window
+ //
+ String domain = XacmlAdminUI.getDomain();
+ String userid = ((XacmlAdminUI)UI.getCurrent()).getUserid();
+ final Obadvice oa = new Obadvice(domain, userid);
+ final EntityItem<Obadvice> entity = self.obadvice.createEntityItem(oa);
+ final ObadviceEditorWindow editor = new ObadviceEditorWindow(entity);
+ editor.setCaption("Add New Obligation/Advice");
+ editor.setCloseShortcut(KeyCode.ESCAPE);
+ editor.setModal(true);
+ editor.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ if (editor.isSaved()) {
+ self.obadvice.addEntity(oa);
+ logger.info("Added new obligation/advice: " + oa);
+ }
+ }
+ });
+ editor.center();
+ UI.getCurrent().addWindow(editor);
+ }
+ });
+ //
+ // Disable remove/clone buttons to start
+ //
+ this.buttonRemove.setEnabled(false);
+ this.buttonClone.setEnabled(false);
+ //
+ // REMOVE button
+ //
+ this.buttonRemove.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ self.obadvice.removeItem(self.table.getValue());
+ }
+ });
+ //
+ // CLONE button
+ //
+ this.buttonClone.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ // TODO
+ }
+ });
+ }
+
+ protected void initializeCombo() {
+ //
+ // Add filter values
+ //
+ this.comboBoxFilter.addItem(Obadvice.OBLIGATION);
+ this.comboBoxFilter.addItem(Obadvice.ADVICE);
+ //
+ // Initialize GUI properties
+ //
+ this.comboBoxFilter.setImmediate(true);
+ this.comboBoxFilter.setNullSelectionAllowed(true);
+ //
+ //
+ this.comboBoxFilter.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ //
+ // Remove filters
+ //
+ self.obadvice.removeAllContainerFilters();
+ //
+ // What was selected?
+ //
+ Object id = self.comboBoxFilter.getValue();
+ if (id != null) {
+ //
+ // Add filter
+ //
+ if (id.equals(Obadvice.OBLIGATION)) {
+ self.obadvice.addContainerFilter(new Compare.Equal("type", Obadvice.OBLIGATION));
+ } else if (id.equals(Obadvice.ADVICE)) {
+ self.obadvice.addContainerFilter(new Compare.Equal("type", Obadvice.ADVICE));
+ }
+ }
+ }
+ });
+ }
+
+ public void refreshContainer() {
+ this.obadvice.refresh();
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("100%");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("100.0%");
+ setHeight("-1px");
+
+ // horizontalLayoutToolbar
+ horizontalLayoutToolbar = buildHorizontalLayoutToolbar();
+ mainLayout.addComponent(horizontalLayoutToolbar);
+
+ // table
+ table = new Table();
+ table.setImmediate(true);
+ table.setWidth("-1px");
+ table.setHeight("-1px");
+ mainLayout.addComponent(table);
+
+ return mainLayout;
+ }
+
+ @AutoGenerated
+ private HorizontalLayout buildHorizontalLayoutToolbar() {
+ // common part: create layout
+ horizontalLayoutToolbar = new HorizontalLayout();
+ horizontalLayoutToolbar.setImmediate(false);
+ horizontalLayoutToolbar.setWidth("-1px");
+ horizontalLayoutToolbar.setHeight("-1px");
+ horizontalLayoutToolbar.setMargin(false);
+ horizontalLayoutToolbar.setSpacing(true);
+
+ // buttonNew
+ buttonNew = new Button();
+ buttonNew.setCaption("New");
+ buttonNew.setImmediate(true);
+ buttonNew
+ .setDescription("Add a new advice or obligation to the dictionary.");
+ buttonNew.setWidth("-1px");
+ buttonNew.setHeight("-1px");
+ horizontalLayoutToolbar.addComponent(buttonNew);
+ horizontalLayoutToolbar.setComponentAlignment(buttonNew, new Alignment(
+ 24));
+
+ // buttonRemove
+ buttonRemove = new Button();
+ buttonRemove.setCaption("Remove");
+ buttonRemove.setImmediate(true);
+ buttonRemove
+ .setDescription("Remove the selected advice or obligation from the dictionary.");
+ buttonRemove.setWidth("-1px");
+ buttonRemove.setHeight("-1px");
+ horizontalLayoutToolbar.addComponent(buttonRemove);
+ horizontalLayoutToolbar.setComponentAlignment(buttonRemove,
+ new Alignment(24));
+
+ // buttonClone
+ buttonClone = new Button();
+ buttonClone.setCaption("Clone");
+ buttonClone.setImmediate(true);
+ buttonClone.setDescription("Clone the selected obligation/advice.");
+ buttonClone.setWidth("-1px");
+ buttonClone.setHeight("-1px");
+ horizontalLayoutToolbar.addComponent(buttonClone);
+ horizontalLayoutToolbar.setComponentAlignment(buttonClone,
+ new Alignment(24));
+
+ // comboBoxFilter
+ comboBoxFilter = new ComboBox();
+ comboBoxFilter.setCaption("Filter By Type");
+ comboBoxFilter.setImmediate(false);
+ comboBoxFilter.setWidth("-1px");
+ comboBoxFilter.setHeight("-1px");
+ horizontalLayoutToolbar.addComponent(comboBoxFilter);
+
+ return horizontalLayoutToolbar;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/PDPManagement.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/PDPManagement.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/PDPManagement.java
new file mode 100644
index 0000000..56fd9cd
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/PDPManagement.java
@@ -0,0 +1,862 @@
+/*
+ * 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.xacml.admin.components;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.vaadin.dialogs.ConfirmDialog;
+import org.vaadin.dialogs.ConfirmDialog.ContentMode;
+
+import org.apache.openaz.xacml.admin.XacmlAdminAuthorization;
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.model.PDPContainer;
+import org.apache.openaz.xacml.admin.model.PDPGroupContainer;
+import org.apache.openaz.xacml.admin.model.PDPPIPContainer;
+import org.apache.openaz.xacml.admin.model.PDPPolicyContainer;
+import org.apache.openaz.xacml.admin.util.AdminNotification;
+import org.apache.openaz.xacml.admin.view.windows.EditPDPGroupWindow;
+import org.apache.openaz.xacml.admin.view.windows.EditPDPWindow;
+import org.apache.openaz.xacml.admin.view.windows.PDPStatusWindow;
+import org.apache.openaz.xacml.admin.view.windows.SelectPDPGroupWindow;
+import org.apache.openaz.xacml.api.pap.PAPEngine;
+import org.apache.openaz.xacml.api.pap.PAPException;
+import org.apache.openaz.xacml.api.pap.PDP;
+import org.apache.openaz.xacml.api.pap.PDPGroup;
+import org.apache.openaz.xacml.api.pap.PDPGroupStatus;
+import org.apache.openaz.xacml.api.pap.PDPStatus;
+import org.apache.openaz.xacml.std.pap.StdPDPGroup;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.event.Action;
+import com.vaadin.event.Action.Handler;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Table.ColumnGenerator;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window.CloseEvent;
+import com.vaadin.ui.Window.CloseListener;
+
+
+public class PDPManagement extends CustomComponent {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+
+ @AutoGenerated
+ private Table table;
+
+ @AutoGenerated
+ private HorizontalLayout horizontalLayoutToolbar;
+
+ @AutoGenerated
+ private Button buttonRemove;
+
+ @AutoGenerated
+ private Button buttonCreate;
+
+ private static final long serialVersionUID = 1L;
+ private final PDPManagement self = this;
+ private static final Log logger = LogFactory.getLog(PDPManagement.class);
+
+ private PDPGroupContainer container;
+
+ private static final Action CREATE_GROUP = new Action ("Create Group");
+ private static final Action REPAIR_GROUP = new Action ("Repair Group");
+ private static final Action EDIT_GROUP = new Action ("Edit Group");
+ private static final Action DELETE_GROUP = new Action ("Delete Group");
+ private static final Action SYNCHRONIZE = new Action ("Synchronize");
+ private static final Action MAKE_DEFAULT = new Action ("Make Default");
+ private static final Action CREATE_PDP = new Action ("Create PDP");
+ private static final Action EDIT_PDP = new Action ("Edit PDP");
+ private static final Action DELETE_PDP = new Action ("Delete PDP");
+ private static final Action MOVE_PDP = new Action ("Move PDP");
+ private static final Action GET_PDP_STATUS = new Action ("View Status");
+
+ private PAPEngine papEngine;
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public PDPManagement(PAPEngine engine) {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+ //
+ // Initialize
+ //
+ this.papEngine = engine;
+ //
+ // Initialize
+ //
+ this.initialize();
+ //
+ // setup the buttons
+ //
+ this.setupButtons();
+ }
+
+ protected void initialize() {
+ //
+ // Don't create a container if the engine doesn't exist
+ //
+ if (this.papEngine == null) {
+ //
+ // remove all the components
+ //
+ this.mainLayout.removeAllComponents();
+ //
+ // Add a label
+ //
+ this.mainLayout.addComponent(new Label("PDP Management unavailable - PAP servlet unavailable."));
+ //
+ // done
+ //
+ return;
+ }
+ //
+ // Create our container
+ //
+ this.container = new PDPGroupContainer(this.papEngine);
+ //
+ // Determine authorization level
+ //
+ boolean isAdmin = ((XacmlAdminUI)UI.getCurrent()).isAuthorized(
+ XacmlAdminAuthorization.AdminAction.ACTION_ADMIN,
+ XacmlAdminAuthorization.AdminResource.RESOURCE_PDP_ADMIN);
+ try {
+ this.initializeTree(isAdmin);
+ this.initializeButtons(isAdmin);
+ } catch (Exception e) {
+ logger.error("UNABLE TO START PDPManagement: " + e, e);
+ // check if PAP servlet is up
+ try {
+ Set<PDPGroup> groups = this.papEngine.getPDPGroups();
+ if (groups == null) {
+ throw new PAPException("PAP not running");
+ }
+ } catch (PAPException | NullPointerException e1) {
+ setCompositionRoot(new Label("Cannot use PDP Management because the PAP servlet was not running when Admin Console Servlet first initialized."));
+ return;
+ }
+ setCompositionRoot(new Label("Cannot use PDP Management because of error during initialization: " + e.getMessage()));
+ }
+ }
+
+ protected void initializeTree(final boolean isAdmin) {
+ //
+ // Set the data source
+ //
+ this.table.setContainerDataSource(this.container);
+ //
+ // Setup the GUI properties
+ //
+ this.table.setVisibleColumns("Name", "Description", "Status", "Default", "PDPs", "Policies", "PIP Configurations");
+ this.table.setColumnHeaders("Name", "Description", "Status", "Default", "PDP's", "Policies", "PIP Configurations");
+ //
+ // The description should be a text area
+ //
+ this.table.addGeneratedColumn("Description", new ColumnGenerator() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Object generateCell(Table source, Object itemId, Object columnId) {
+ TextArea area = new TextArea();
+ area.setValue(((PDPGroup) itemId).getDescription());
+ area.setReadOnly(true);
+ return area;
+ }
+
+ });
+ //
+ // Generate a GUI element for the PDP's
+ //
+ this.table.addGeneratedColumn("PDPs", new ColumnGenerator() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Object generateCell(Table source, Object itemId, Object columnId) {
+ final Table table = new Table();
+ final PDPContainer container = new PDPContainer((PDPGroup) itemId);
+ //
+ // Setup the container data
+ //
+ table.setContainerDataSource(container);
+ //
+ // Save the group for easy access
+ //
+ table.setData(itemId);
+ //
+ // GUI properties
+ //
+ table.setPageLength(table.getContainerDataSource().size() + 2);
+ table.setVisibleColumns("Name", "Status", "Description");
+ table.setColumnCollapsingAllowed(true);
+ table.setColumnCollapsed("Description", true);
+ table.setWidth("100%");
+ //
+ // If an admin, then it is editable
+ //
+ if (isAdmin) {
+ //
+ // Set it as selectable
+ //
+ table.setSelectable(true);
+ //
+ // Add actions
+ //
+ table.addActionHandler(new Handler() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Action[] getActions(Object target, Object sender) {
+ if (target == null) {
+ return new Action[] {CREATE_PDP};
+ }
+ if (target instanceof PDP) {
+ if (self.container.size() > 1) {
+ return new Action[] {EDIT_PDP, GET_PDP_STATUS, MOVE_PDP, DELETE_PDP};
+ } else {
+ return new Action[] {EDIT_PDP, GET_PDP_STATUS, DELETE_PDP};
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void handleAction(Action action, Object sender, Object target) {
+ if (action == CREATE_PDP) {
+ self.editPDP(null, (PDPGroup) table.getData());
+ return;
+ }
+ if (action == EDIT_PDP) {
+ assert target instanceof PDP;
+ self.editPDP((PDP) target, (PDPGroup) table.getData());
+ return;
+ }
+ if (action == MOVE_PDP) {
+ assert target instanceof PDP;
+ self.movePDP((PDP) target, (PDPGroup) table.getData());
+ return;
+ }
+ if (action == DELETE_PDP) {
+ assert target instanceof PDP;
+ self.deletePDP((PDP) target, (PDPGroup) table.getData());
+ return;
+ }
+ if (action == GET_PDP_STATUS) {
+ assert target instanceof PDP;
+ self.getPDPStatus((PDP) target, (PDPGroup) table.getData());
+ }
+ }
+ });
+ //
+ // Respond to events
+ //
+ table.addItemClickListener(new ItemClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void itemClick(ItemClickEvent event) {
+ if (event.isDoubleClick()) {
+ self.editPDP((PDP) event.getItemId(), (PDPGroup) table.getData());
+ }
+ }
+ });
+ }
+ return table;
+ }
+ });
+ //
+ // Generate a GUI element for the policies
+ //
+ this.table.addGeneratedColumn("Policies", new ColumnGenerator() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Object generateCell(Table source, Object itemId, Object columnId) {
+ Table table = new Table();
+ table.setContainerDataSource(new PDPPolicyContainer((PDPGroup) itemId));
+ table.setPageLength(table.getContainerDataSource().size() + 2);
+
+ table.setVisibleColumns("Root", "Name", "Version", "Description");
+ table.setColumnCollapsingAllowed(true);
+ table.setColumnCollapsed("Description", true);
+
+ table.setWidth("100%");
+
+ return table;
+ }
+ });
+ //
+ // Generate a GUI element for the PIP configurations
+ //
+ this.table.addGeneratedColumn("PIP Configurations", new ColumnGenerator() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Object generateCell(Table source, Object itemId, Object columnId) {
+ Table table = new Table();
+ if (itemId instanceof PDPGroup) {
+ table.setContainerDataSource(new PDPPIPContainer((PDPGroup) itemId));
+ table.setPageLength(table.getContainerDataSource().size() + 2);
+ }
+ if (itemId instanceof PDP) {
+ table.setContainerDataSource(new PDPPIPContainer((PDP) itemId));
+ table.setVisible(false);
+ table.setPageLength(0);
+ }
+ table.setVisibleColumns("Name", "Description");
+ table.setColumnCollapsingAllowed(true);
+ table.setColumnCollapsed("Description", true);
+
+ table.setWidth("100%");
+
+ return table;
+ }
+ });
+ //
+ // Check the user's authorization level
+ //
+ if (((XacmlAdminUI)UI.getCurrent()).isAuthorized(
+ XacmlAdminAuthorization.AdminAction.ACTION_ADMIN,
+ XacmlAdminAuthorization.AdminResource.RESOURCE_PDP_ADMIN)) {
+ this.table.setSelectable(true);
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("No admin access to pdp management");
+ }
+ return;
+ }
+ //
+ // Setup Action Handlers
+ //
+ this.table.addActionHandler(new Handler() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Action[] getActions(Object target, Object sender) {
+ if (target == null) {
+ //
+ // Nothing is selected, they right-clicked empty space.
+ // Only one action.
+ //
+ return new Action[] {CREATE_GROUP};
+ }
+ if (target instanceof PDPGroup) {
+ List<Action> actions = new ArrayList<Action>();
+ PDPGroupStatus.Status status = ((PDPGroup)target).getStatus().getStatus();
+ if (status == PDPGroupStatus.Status.LOAD_ERRORS) {
+ actions.add(REPAIR_GROUP);
+ }
+ if (((PDPGroup)target).isDefaultGroup() == false) {
+ actions.add(MAKE_DEFAULT);
+ }
+ actions.add(EDIT_GROUP);
+ if (status == PDPGroupStatus.Status.OUT_OF_SYNCH) {
+ actions.add(SYNCHRONIZE);
+ }
+ if (((PDPGroup)target).isDefaultGroup() == false) {
+ actions.add(DELETE_GROUP);
+ }
+ actions.add(CREATE_PDP);
+ // Throws a class cast exception
+// return (Action[]) actions.toArray();
+ Action[] actions2 = new Action[actions.size()];
+ int index = 0;
+ for (Action a : actions) {
+ actions2[index++] = a;
+ }
+ return actions2;
+ }
+ return null;
+ }
+
+ @Override
+ public void handleAction(Action action, Object sender, Object target) {
+ if (action == CREATE_GROUP) {
+ self.editPDPGroup(null);
+ return;
+ }
+ if (action == EDIT_GROUP) {
+ assert target instanceof PDPGroup;
+ self.editPDPGroup((PDPGroup) target);
+ return;
+ }
+ if (action == DELETE_GROUP) {
+ self.deleteGroup((PDPGroup) target);
+ return;
+ }
+ if (action == REPAIR_GROUP) {
+ if (target instanceof PDPGroup) {
+ ((PDPGroup) target).repair();
+ } else {
+ String message = "Action '" + REPAIR_GROUP.getCaption() + "' called on non-group target '" + target + "'";
+ logger.error(message);
+ AdminNotification.error(message);
+ }
+ return;
+ }
+ if (action == MAKE_DEFAULT) {
+ if (target instanceof PDPGroup) {
+ try {
+ self.container.makeDefault((PDPGroup) target);
+ } catch (Exception e) {
+ AdminNotification.error("Make Default failed. Reason:\n" + e.getMessage());
+ }
+ } else {
+ String message = "Action '" + MAKE_DEFAULT.getCaption() + "' called on non-group target '" + target + "'";
+ logger.error(message);
+ AdminNotification.error(message);
+ }
+ return;
+ }
+ if (action == SYNCHRONIZE) {
+ if (target instanceof PDPGroup) {
+logger.error("SYNCHRONIZE NOT YET IMPLMENTED");
+AdminNotification.error("Synchronize not yet implemented");
+ } else {
+ String message = "Action '" + SYNCHRONIZE.getCaption() + "' called on non-group target '" + target + "'";
+ logger.error(message);
+ AdminNotification.error(message);
+ }
+ return;
+ }
+ if (action == CREATE_PDP) {
+ if (target instanceof PDPGroup) {
+ self.editPDP(null, ((PDPGroup)target));
+ } else {
+ String message = "Action '" + CREATE_PDP.getCaption() + "' called on non-group target '" + target + "'";
+ logger.error(message);
+ AdminNotification.error(message);
+ }
+ return;
+ }
+ }
+ });
+ //
+ // Listen for item change notifications
+ //
+ this.table.addItemClickListener(new ItemClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void itemClick(ItemClickEvent event) {
+ if (event.isDoubleClick()) {
+ assert event.getItemId() instanceof PDPGroup;
+ self.editPDPGroup((PDPGroup) event.getItemId());
+ }
+ }
+ });
+ //
+ // Respond to selection events
+ //
+ this.table.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ Object id = self.table.getValue();
+ if (id == null) {
+ self.buttonRemove.setEnabled(false);
+ } else {
+ //
+ // Make sure its not the default group
+ //
+ if (((PDPGroup) id).isDefaultGroup()) {
+ self.buttonRemove.setEnabled(false);
+ } else {
+ self.buttonRemove.setEnabled(true);
+ }
+ }
+ }
+ });
+ //
+ // Maximize the table
+ //
+ this.table.setSizeFull();
+ }
+
+ protected void initializeButtons(final boolean isAdmin) {
+ if (isAdmin == false) {
+ return;
+ }
+ this.buttonCreate.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ self.editPDPGroup(null);
+ }
+ });
+ this.buttonRemove.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ Object id = self.table.getValue();
+ assert id != null;
+ assert id instanceof PDPGroup;
+ self.deleteGroup((PDPGroup) id);
+ self.table.select(self.table.getNullSelectionItemId());
+ }
+ });
+ }
+
+ protected void setupButtons() {
+ if (this.table.getValue() == null) {
+ this.buttonRemove.setEnabled(false);
+ } else {
+ this.buttonRemove.setEnabled(true);
+ }
+ }
+
+ protected void editPDP(final PDP pdp, final PDPGroup group) {
+ final EditPDPWindow editor = new EditPDPWindow(pdp, this.container.getGroups());
+ if (pdp == null) {
+ editor.setCaption("Create New PDP");
+ } else {
+ editor.setCaption("Edit PDP " + pdp.getId());
+ }
+ editor.setModal(true);
+ editor.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent event) {
+ if (editor.isSaved() == false) {
+ return;
+ }
+ try {
+ //
+ // Adding a new PDP?
+ //
+ if (pdp == null) {
+ //
+ // Yes tell the container to add it
+ //
+ self.container.addNewPDP(editor.getPDPId(), group, editor.getPDPName(), editor.getPDPDescription());
+ } else {
+ //
+ // No tell the container to update it
+ //
+ pdp.setName(editor.getPDPName());
+ pdp.setDescription(editor.getPDPDescription());
+ self.container.updatePDP(pdp);
+ }
+ } catch (Exception e) {
+ String message = "Unable to create PDP. Reason:\n" + e.getMessage();
+ logger.error(message);
+ AdminNotification.error(message);
+ }
+ }
+ });
+ editor.center();
+ UI.getCurrent().addWindow(editor);
+ }
+
+ protected void editPDPGroup(final PDPGroup group) {
+ //
+ // copy the group
+ //
+ final StdPDPGroup copyGroup = (group == null ? null : new StdPDPGroup(group));
+ //
+ //
+ //
+ final EditPDPGroupWindow editor = new EditPDPGroupWindow(copyGroup, this.container.getGroups(), papEngine);
+ if (group == null) {
+ editor.setCaption("Create PDP Group");
+ } else {
+ editor.setCaption("Edit PDP Group " + ((PDPGroup) group).getName());
+ }
+ editor.setModal(true);
+ editor.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent event) {
+ if (editor.isSaved() == false) {
+ return;
+ }
+ if (group == null) {
+ //
+ // Creating a new group
+ //
+ try {
+ self.container.addNewGroup(editor.getGroupName(), editor.getGroupDescription());
+ } catch (Exception e) {
+ String message = "Unable to create Group. Reason:\n" + e.getMessage();
+ logger.error(message);
+ AdminNotification.error(message);
+ }
+ } else {
+ //
+ // Update group
+ //
+ self.container.updateGroup(editor.getUpdatedObject());
+ }
+ }
+ });
+ editor.center();
+ UI.getCurrent().addWindow(editor);
+ }
+
+ protected void deletePDP(final PDP pdp, final PDPGroup pdpGroup) {
+ String message = "Are you sure you want to delete <B>" + (pdp.getName() == null ? "" : pdp.getName()) + "</B> group?";
+ ConfirmDialog dialog = ConfirmDialog.getFactory().create("Confirm PDP Deletion", message, "Delete", "Cancel");
+ dialog.setContentMode(ContentMode.HTML);
+ dialog.show(getUI(), new ConfirmDialog.Listener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void onClose(ConfirmDialog dialog) {
+ if (dialog.isConfirmed()) {
+ try {
+ self.container.removePDP(pdp, pdpGroup);
+ } catch (PAPException e) {
+ logger.warn("Failed to remove pdp");
+ AdminNotification.warn("Failed to remove PDP");
+ }
+ }
+ }
+ }, true);
+ }
+
+ protected void movePDP(final PDP pdp, final PDPGroup currentGroup) {
+ List<PDPGroup> currentGroups = this.container.getGroups();
+ Set<PDPGroup> otherGroups = new HashSet<PDPGroup>(currentGroups);
+ if (otherGroups.remove(currentGroup) == false) {
+ logger.warn("Group list inconsistency - failed to move pdp to selected group");
+ return;
+ }
+ final SelectPDPGroupWindow editor = new SelectPDPGroupWindow(otherGroups, "What was this?");
+ editor.setCaption("Move PDP to group");
+ editor.setModal(true);
+ editor.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent event) {
+ if (editor.isSaved()) {
+ self.container.movePDP((PDP) pdp, editor.selectedGroup());
+ }
+ }
+ });
+ editor.center();
+ UI.getCurrent().addWindow(editor);
+ }
+
+ protected void getPDPStatus(final PDP pdp, final PDPGroup group) {
+ PDPStatus status;
+ try {
+ status = papEngine.getStatus(pdp);
+ } catch (Exception e) {
+ AdminNotification.error("Unable to get details for pdp '" + pdp.getId() + "' with summary status: " + pdp.getStatus().getStatus());
+ return;
+ }
+ logger.info(status);
+ PDPStatusWindow window = new PDPStatusWindow(status);
+ window.setCaption("Status for PDP " + pdp.getName());
+ window.setModal(true);
+ window.center();
+ UI.getCurrent().addWindow(window);
+ }
+
+ private void deleteGroup(final PDPGroup group) {
+ //
+ // Cannot be the default group
+ //
+ if (group.isDefaultGroup()) {
+ logger.error("Cannot delete the Default group");
+ return;
+ }
+ //
+ // Any PDPs in the group?
+ //
+ Set<PDP> pdps = group.getPdps();
+ if (pdps.isEmpty()) {
+ //
+ // There are no PDP's, so just prompt to remove it
+ //
+ String message = "Are you sure you want to delete <B>" + (group.getName() == null ? "" : group.getName()) + "</B> group?";
+ ConfirmDialog dialog = ConfirmDialog.getFactory().create("Confirm Group Deletion", message, "Delete", "Cancel");
+ dialog.setContentMode(ContentMode.HTML);
+ dialog.show(getUI(), new ConfirmDialog.Listener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void onClose(ConfirmDialog dialog) {
+ if (dialog.isConfirmed()) {
+ try {
+ self.container.removeGroup(group, null);
+ } catch (Exception e1) {
+ logger.warn("Container failed to remove group");
+ AdminNotification.error("Unable to delete group '" + group.getId() + "'. Reason:\n" + e1.getMessage());
+ }
+ return;
+ }
+ }
+ }, true);
+ return;
+ }
+ //
+ // Get our set of groups
+ //
+ List<PDPGroup> currentGroups = this.container.getGroups();
+ Set<PDPGroup> otherGroups = new HashSet<PDPGroup>(currentGroups);
+ if (otherGroups.remove(group) == false) {
+ logger.warn("Group list inconsistency - failed to remove group we are attempting to delete");
+ return;
+ }
+ //
+ // We should have at least one group
+ //
+ if (otherGroups.isEmpty()) {
+ logger.error("Group list inconsistency - no other groups to choose from.");
+ return;
+ }
+ //
+ // If there is only one group, it SHOULD be the default group
+ //
+ if (otherGroups.size() == 1) {
+ PDPGroup loneGroup = otherGroups.iterator().next();
+ if (loneGroup.isDefaultGroup() == false) {
+ logger.error("Group list inconsistency - lone group is NOT default.");
+ return;
+ }
+ }
+ //
+ // Create our confirmation window
+ //
+ final SelectPDPGroupWindow window = new SelectPDPGroupWindow(otherGroups, "Select New Group for PDPs");
+ window.setCaption("Confirm Group " + group.getName() + " Deletion");
+ window.setCloseShortcut(KeyCode.ESCAPE);
+ window.setModal(true);
+ window.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ if (window.isSaved()) {
+ PDPGroup newGroup = window.selectedGroup();
+ if (newGroup == null) {
+ logger.warn("No group selected for moving PDPs into");
+ AdminNotification.warn("No group selected for moving PDPs into. Group '" + group.getId() + "' not deleted");
+ return;
+ }
+ try {
+ self.container.removeGroup(group, newGroup);
+ } catch (Exception e1) {
+ logger.warn("Container failed to remove group: " + e1, e1);
+ AdminNotification.error("Unable to delete group '" + group.getId() + "'. Reason:\n" + e1.getMessage());
+ }
+ }
+ }
+
+ });
+ getUI().addWindow(window);
+ }
+
+ public void refreshContainer() {
+ if (this.container != null) {
+ this.container.refreshGroups();
+ }
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("100%");
+ mainLayout.setHeight("100%");
+ mainLayout.setMargin(false);
+
+ // top-level component properties
+ setWidth("100.0%");
+ setHeight("100.0%");
+
+ // horizontalLayoutToolbar
+ horizontalLayoutToolbar = buildHorizontalLayoutToolbar();
+ mainLayout.addComponent(horizontalLayoutToolbar);
+
+ // tree
+ table = new Table();
+ table.setImmediate(false);
+ table.setWidth("-1px");
+ table.setHeight("-1px");
+ mainLayout.addComponent(table);
+ mainLayout.setExpandRatio(table, 1.0f);
+
+ return mainLayout;
+ }
+
+ @AutoGenerated
+ private HorizontalLayout buildHorizontalLayoutToolbar() {
+ // common part: create layout
+ horizontalLayoutToolbar = new HorizontalLayout();
+ horizontalLayoutToolbar.setImmediate(false);
+ horizontalLayoutToolbar.setWidth("-1px");
+ horizontalLayoutToolbar.setHeight("-1px");
+ horizontalLayoutToolbar.setMargin(true);
+ horizontalLayoutToolbar.setSpacing(true);
+
+ // buttonCreate
+ buttonCreate = new Button();
+ buttonCreate.setCaption("Create Group");
+ buttonCreate.setImmediate(false);
+ buttonCreate.setWidth("-1px");
+ buttonCreate.setHeight("-1px");
+ horizontalLayoutToolbar.addComponent(buttonCreate);
+
+ // buttonRemove
+ buttonRemove = new Button();
+ buttonRemove.setCaption("Remove Group");
+ buttonRemove.setImmediate(false);
+ buttonRemove.setWidth("-1px");
+ buttonRemove.setHeight("-1px");
+ horizontalLayoutToolbar.addComponent(buttonRemove);
+
+ return horizontalLayoutToolbar;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/PIPManagement.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/PIPManagement.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/PIPManagement.java
new file mode 100644
index 0000000..c25f018
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/PIPManagement.java
@@ -0,0 +1,538 @@
+/*
+ * 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.xacml.admin.components;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.vaadin.dialogs.ConfirmDialog;
+import org.vaadin.dialogs.ConfirmDialog.ContentMode;
+
+import org.apache.openaz.xacml.admin.XacmlAdminAuthorization;
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.jpa.PIPConfiguration;
+import org.apache.openaz.xacml.admin.util.AdminNotification;
+import org.apache.openaz.xacml.admin.view.components.PIPResolverComponent;
+import org.apache.openaz.xacml.admin.view.windows.PIPConfigurationEditorWindow;
+import org.apache.openaz.xacml.admin.view.windows.PIPImportWindow;
+import com.vaadin.addon.jpacontainer.EntityItem;
+import com.vaadin.addon.jpacontainer.JPAContainer;
+import com.vaadin.addon.jpacontainer.provider.CachingLocalEntityProvider;
+import com.vaadin.addon.jpacontainer.provider.CachingMutableLocalEntityProvider;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.event.Action;
+import com.vaadin.event.Action.Handler;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.ui.AbstractSelect.ItemCaptionMode;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.Table.ColumnGenerator;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window.CloseEvent;
+import com.vaadin.ui.Window.CloseListener;
+
+public class PIPManagement extends CustomComponent {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Table tablePIP;
+ @AutoGenerated
+ private HorizontalLayout horizontalLayoutToolbar;
+ @AutoGenerated
+ private Button buttonImport;
+ @AutoGenerated
+ private Button buttonRemove;
+ @AutoGenerated
+ private Button buttonClone;
+ @AutoGenerated
+ private Button buttonAdd;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static final Log logger = LogFactory.getLog(PIPManagement.class);
+ private static final Object[] visibleColumns = new Object[] { "name", "description", "piptype", "issuer"};
+ private static final String[] columnHeaders = new String[] { "Name", "Description", "Type", "Issuer"};
+
+ private final Action ADD_CONFIGURATION = new Action("Add Configuration");
+ private final Action EDIT_CONFIGURATION = new Action("Edit Configuration");
+ private final Action CLONE_CONFIGURATION = new Action("Clone Configuration");
+ private final Action REMOVE_CONFIGURATION = new Action("Remove Configuration");
+ private final Action ADD_RESOLVER = new Action("Add Resolver");
+ private final Action PUBLISH_CONFIGURATION = new Action("Publish Configuration");
+
+ private final PIPManagement self = this;
+ private final JPAContainer<PIPConfiguration> container = new JPAContainer<PIPConfiguration>(PIPConfiguration.class);
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public PIPManagement() {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+ //
+ // Setup containers
+ //
+ boolean isReadOnly;
+ if (((XacmlAdminUI)UI.getCurrent()).isAuthorized(
+ XacmlAdminAuthorization.AdminAction.ACTION_WRITE,
+ XacmlAdminAuthorization.AdminResource.RESOURCE_PIP_ADMIN)) {
+ //
+ // Writable container
+ //
+ container.setEntityProvider(new CachingMutableLocalEntityProvider<PIPConfiguration>(PIPConfiguration.class, ((XacmlAdminUI)UI.getCurrent()).getEntityManager()));
+ isReadOnly = false;
+ } else {
+ //
+ // Read only container
+ //
+ container.setEntityProvider(new CachingLocalEntityProvider<PIPConfiguration>(PIPConfiguration.class, ((XacmlAdminUI)UI.getCurrent()).getEntityManager()));
+ isReadOnly = true;
+ }
+ //
+ // Finish initialization
+ //
+ this.initializeTree(isReadOnly);
+ this.initializeButtons(isReadOnly);
+ //
+ // Setup
+ //
+ this.setupButtons();
+ }
+
+ protected void initializeTree(boolean isReadOnly) {
+ //
+ // Initialize GUI properties
+ //
+ this.tablePIP.setImmediate(true);
+ this.tablePIP.setContainerDataSource(this.container);
+ this.tablePIP.setItemCaptionMode(ItemCaptionMode.PROPERTY);
+ this.tablePIP.setItemCaptionPropertyId("name");
+ this.tablePIP.setVisibleColumns(visibleColumns);
+ this.tablePIP.setColumnHeaders(columnHeaders);
+ this.tablePIP.setSizeFull();
+ //
+ // Access?
+ //
+ if (isReadOnly) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("read only pip access");
+ }
+ return;
+ }
+ this.tablePIP.setSelectable(true);
+ //
+ // Setup click handler
+ //
+ this.tablePIP.addItemClickListener(new ItemClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void itemClick(ItemClickEvent event) {
+ if (event.isDoubleClick()) {
+ PIPManagement.editConfiguration(self.container.getItem(event.getItemId()));
+ }
+ }
+ });
+ //
+ // Setup action handler
+ //
+ this.tablePIP.addActionHandler(new Handler() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Action[] getActions(Object target, Object sender) {
+ if (target == null) {
+ return new Action[] {ADD_CONFIGURATION};
+ }
+ //
+ // Target is an Object ID
+ //
+ EntityItem<PIPConfiguration> config = self.container.getItem(target);
+ if (config != null && config.getEntity().isReadOnly() == false) {
+ if (config.getEntity().requiresResolvers()) {
+ return new Action[] {EDIT_CONFIGURATION, CLONE_CONFIGURATION, REMOVE_CONFIGURATION, PUBLISH_CONFIGURATION, ADD_RESOLVER};
+ } else {
+ return new Action[] {EDIT_CONFIGURATION, CLONE_CONFIGURATION, REMOVE_CONFIGURATION, PUBLISH_CONFIGURATION};
+ }
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("Could not find item: " + target);
+ }
+ return null;
+ }
+
+ @Override
+ public void handleAction(Action action, Object sender, Object target) {
+ EntityItem<PIPConfiguration> config = self.container.getItem(target);
+ if (config == null) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Could not find item: " + target);
+ }
+ return;
+ }
+ if (action == ADD_CONFIGURATION) {
+ PIPManagement.editConfiguration(self.container.createEntityItem(new PIPConfiguration()));
+ return;
+ }
+ if (action == EDIT_CONFIGURATION) {
+ PIPManagement.editConfiguration(config);
+ return;
+ }
+ if (action == CLONE_CONFIGURATION) {
+ self.cloneConfiguration(config);
+ return;
+ }
+ if (action == REMOVE_CONFIGURATION) {
+ self.removeConfiguration(config);
+ return;
+ }
+ if (action == ADD_RESOLVER) {
+ PIPResolverComponent.addResolver(config.getEntity(), null);
+ return;
+ }
+ if (action == PUBLISH_CONFIGURATION) {
+ PIPResolverComponent.publishConfiguration(config);
+ return;
+ }
+ }
+ });
+ //
+ // When a selection changes listener
+ //
+ this.tablePIP.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ self.setupButtons();
+ }
+ });
+ this.tablePIP.addGeneratedColumn("description", new ColumnGenerator() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Object generateCell(Table source, Object itemId, Object columnId) {
+ EntityItem<PIPConfiguration> entity = self.container.getItem(itemId);
+ if (entity != null && entity.getEntity() != null) {
+ TextArea area = new TextArea();
+ area.setValue(entity.getEntity().getDescription());
+ area.setNullRepresentation("");
+ area.setSizeFull();
+ area.setReadOnly(true);
+ return area;
+ }
+ return null;
+ }
+ });
+ this.tablePIP.addGeneratedColumn("piptype", new ColumnGenerator() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Object generateCell(Table source, Object itemId, Object columnId) {
+ EntityItem<PIPConfiguration> entity = self.container.getItem(itemId);
+ if (entity != null && entity.getEntity() != null) {
+ return entity.getEntity().getPiptype().getType();
+ }
+ return null;
+ }
+ });
+ //
+ // Customize the resolver column
+ //
+ this.tablePIP.addGeneratedColumn("Resolvers", new ColumnGenerator() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Object generateCell(Table source, Object itemId, Object columnId) {
+ EntityItem<PIPConfiguration> entity = self.container.getItem(itemId);
+ if (entity != null && entity.getEntity() != null && entity.getEntity().requiresResolvers()) {
+ PIPResolverComponent component = new PIPResolverComponent(entity.getEntity());
+ return component;
+ }
+ return null;
+ }
+ });
+ }
+
+ protected void initializeButtons(boolean isReadOnly) {
+ if (isReadOnly) {
+ this.buttonAdd.setVisible(false);
+ this.buttonRemove.setVisible(false);
+ this.buttonClone.setVisible(false);
+ return;
+ }
+ this.buttonAdd.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ PIPManagement.editConfiguration(self.container.createEntityItem(new PIPConfiguration()));
+ }
+
+ });
+ this.buttonRemove.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ self.removeConfiguration(self.container.getItem(self.tablePIP.getValue()));
+ }
+
+ });
+ this.buttonClone.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ self.cloneConfiguration(self.container.getItem(self.tablePIP.getValue()));
+ }
+ });
+ this.buttonImport.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ final PIPImportWindow window = new PIPImportWindow();
+ window.setCaption("Import PIP Configuration");
+ window.setModal(true);
+ window.center();
+ window.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ String file = window.getUploadedFile();
+ if (file == null) {
+ return;
+ }
+ self.importConfiguration(file);
+ }
+ });
+ UI.getCurrent().addWindow(window);
+ }
+ });
+ }
+
+ protected void importConfiguration(String file) {
+ Properties properties = new Properties();
+ try {
+ properties.load(new FileInputStream(file));
+ Collection<PIPConfiguration> configs = PIPConfiguration.importPIPConfigurations(properties);
+ if (configs == null || configs.isEmpty()) {
+ AdminNotification.warn("There were no PIP Engine configurations found.");
+ } else {
+ for (PIPConfiguration config : configs) {
+ this.container.addEntity(config);
+ }
+ }
+ } catch (IOException e) {
+ String message = "Failed to load properties: " + e.getLocalizedMessage();
+ logger.error(message);
+ AdminNotification.error(message);
+ }
+ }
+
+ public static void editConfiguration(final EntityItem<PIPConfiguration> entity) {
+ final PIPConfigurationEditorWindow editor = new PIPConfigurationEditorWindow(entity);
+ if (entity.isPersistent()) {
+ editor.setCaption("Edit PIP Configuration " + entity.getEntity().getName());
+ } else {
+ editor.setCaption("Create New PIP Configuration");
+ }
+ editor.setModal(true);
+ editor.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent event) {
+ if (editor.isSaved()) {
+ if (entity.isPersistent() == false) {
+ ((XacmlAdminUI)UI.getCurrent()).getPIPConfigurations().addEntity(entity.getEntity());
+ }
+ ((XacmlAdminUI)UI.getCurrent()).refreshPIPConfiguration();
+ }
+ }
+ });
+ editor.center();
+ UI.getCurrent().addWindow(editor);
+ }
+
+ protected void removeConfiguration(final EntityItem<PIPConfiguration> entity) {
+ //
+ // Sanity checks
+ //
+ if (entity == null || entity.getEntity() == null) {
+ logger.error("Removing a null entity");
+ return;
+ }
+ String message = "Are you sure you want to remove the " + entity.getEntity().getName() + " configuration?";
+ ConfirmDialog dialog = ConfirmDialog.getFactory().create("Confirm PIP Configuration Deletion", message, "Remove", "Cancel");
+ dialog.setContentMode(ContentMode.HTML);
+ dialog.show(getUI(), new ConfirmDialog.Listener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void onClose(ConfirmDialog dialog) {
+ if (dialog.isConfirmed()) {
+ if (self.container.removeItem(entity.getItemId()) == false) {
+ logger.warn("Failed to remove PIP configuration");
+ AdminNotification.warn("Failed to remove PIP configuration.");
+ } else {
+ self.setupButtons();
+ }
+ }
+ }
+ }, true);
+ }
+
+ protected void cloneConfiguration(final EntityItem<PIPConfiguration> entity) {
+ //
+ // Sanity checks
+ //
+ if (entity == null || entity.getEntity() == null) {
+ logger.warn("Cloning a null entity, the buttons were not reset. Resetting them.");
+ this.setupButtons();
+ return;
+ }
+ //
+ // Clone it
+ //
+ PIPManagement.editConfiguration(this.container.createEntityItem(new PIPConfiguration(entity.getEntity(), ((XacmlAdminUI)UI.getCurrent()).getUserid())));
+ }
+
+ protected void setupButtons() {
+ if (this.tablePIP.getValue() != null) {
+ Object id = this.tablePIP.getValue();
+ EntityItem<PIPConfiguration> entity = this.container.getItem(id);
+ if (entity == null || entity.getEntity().isReadOnly()) {
+ this.buttonRemove.setEnabled(false);
+ this.buttonClone.setEnabled(false);
+ } else {
+ this.buttonRemove.setEnabled(true);
+ this.buttonClone.setEnabled(true);
+ }
+ } else {
+ this.buttonRemove.setEnabled(false);
+ this.buttonClone.setEnabled(false);
+ }
+ }
+
+ public void refreshContainer() {
+ this.container.refresh();
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("100%");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("100.0%");
+ setHeight("-1px");
+
+ // horizontalLayoutToolbar
+ horizontalLayoutToolbar = buildHorizontalLayoutToolbar();
+ mainLayout.addComponent(horizontalLayoutToolbar);
+
+ // tablePIP
+ tablePIP = new Table();
+ tablePIP.setCaption("PIP Configurations");
+ tablePIP.setImmediate(false);
+ tablePIP.setWidth("100.0%");
+ tablePIP.setHeight("-1px");
+ mainLayout.addComponent(tablePIP);
+
+ return mainLayout;
+ }
+
+ @AutoGenerated
+ private HorizontalLayout buildHorizontalLayoutToolbar() {
+ // common part: create layout
+ horizontalLayoutToolbar = new HorizontalLayout();
+ horizontalLayoutToolbar.setImmediate(false);
+ horizontalLayoutToolbar.setWidth("-1px");
+ horizontalLayoutToolbar.setHeight("-1px");
+ horizontalLayoutToolbar.setMargin(false);
+ horizontalLayoutToolbar.setSpacing(true);
+
+ // buttonAdd
+ buttonAdd = new Button();
+ buttonAdd.setCaption("Add Configuration");
+ buttonAdd.setImmediate(true);
+ buttonAdd.setWidth("-1px");
+ buttonAdd.setHeight("-1px");
+ horizontalLayoutToolbar.addComponent(buttonAdd);
+
+ // buttonClone
+ buttonClone = new Button();
+ buttonClone.setCaption("Clone Configuration");
+ buttonClone.setImmediate(true);
+ buttonClone.setWidth("-1px");
+ buttonClone.setHeight("-1px");
+ horizontalLayoutToolbar.addComponent(buttonClone);
+
+ // buttonRemove
+ buttonRemove = new Button();
+ buttonRemove.setCaption("Remove Configuration");
+ buttonRemove.setImmediate(true);
+ buttonRemove.setWidth("-1px");
+ buttonRemove.setHeight("-1px");
+ horizontalLayoutToolbar.addComponent(buttonRemove);
+
+ // buttonImport
+ buttonImport = new Button();
+ buttonImport.setCaption("Import Configuration");
+ buttonImport.setImmediate(false);
+ buttonImport
+ .setDescription("Imports a configuration from a properties file.");
+ buttonImport.setWidth("-1px");
+ buttonImport.setHeight("-1px");
+ horizontalLayoutToolbar.addComponent(buttonImport);
+
+ return horizontalLayoutToolbar;
+ }
+
+}
[02/23] incubator-openaz git commit: Ported original att source to
openaz
Posted by pd...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/resources/META-INF/data.sql
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/resources/META-INF/data.sql b/openaz-xacml-pap-admin/src/main/resources/META-INF/data.sql
new file mode 100644
index 0000000..a679b4d
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/resources/META-INF/data.sql
@@ -0,0 +1,723 @@
+INSERT INTO ConstraintType (id, constraint_type, description) VALUES (1,'Range','Set a range of min and/or max integer/double values the attribute can be set to during policy creation.');
+INSERT INTO ConstraintType (id, constraint_type, description) VALUES (2,'Regular Expression','Define a regular expression the attribute must match against during policy creation.');
+INSERT INTO ConstraintType (id, constraint_type, description) VALUES (3,'Enumeration','Enumerate a set of values that the attribute may be set to during policy creation.');
+
+INSERT INTO Category (id, grouping, is_standard, xacml_id, short_name) VALUES (4,'subject','S','urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject','intermediary-subject');
+INSERT INTO Category (id, grouping, is_standard, xacml_id, short_name) VALUES (5,'resource','S','urn:oasis:names:tc:xacml:3.0:attribute-category:resource','resource');
+INSERT INTO Category (id, grouping, is_standard, xacml_id, short_name) VALUES (6,'subject','S','urn:oasis:names:tc:xacml:1.0:subject-category:codebase','codebase');
+INSERT INTO Category (id, grouping, is_standard, xacml_id, short_name) VALUES (7,'action','S','urn:oasis:names:tc:xacml:3.0:attribute-category:action','action');
+INSERT INTO Category (id, grouping, is_standard, xacml_id, short_name) VALUES (8,'subject','S','urn:oasis:names:tc:xacml:1.0:subject-category:access-subject','access-subject');
+INSERT INTO Category (id, grouping, is_standard, xacml_id, short_name) VALUES (9,'environment','S','urn:oasis:names:tc:xacml:3.0:attribute-category:environment','environment');
+INSERT INTO Category (id, grouping, is_standard, xacml_id, short_name) VALUES (10,'subject','S','urn:oasis:names:tc:xacml:1.0:subject-category:requesting-machine','requesting-machine');
+INSERT INTO Category (id, grouping, is_standard, xacml_id, short_name) VALUES (11,'subject','S','urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject','recipient-subject');
+
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (12,'S','integer','http://www.w3.org/2001/XMLSchema#integer');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (13,'S','base64Binary','http://www.w3.org/2001/XMLSchema#base64Binary');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (14,'S','x500Name','urn:oasis:names:tc:xacml:1.0:data-type:x500Name');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (15,'S','dayTimeDuration','http://www.w3.org/2001/XMLSchema#dayTimeDuration');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (16,'S','time','http://www.w3.org/2001/XMLSchema#time');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (17,'S','dnsName','urn:oasis:names:tc:xacml:2.0:data-type:dnsName');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (18,'S','boolean','http://www.w3.org/2001/XMLSchema#boolean');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (19,'S','dateTime','http://www.w3.org/2001/XMLSchema#dateTime');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (20,'S','rfc822Name','urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (21,'S','date','http://www.w3.org/2001/XMLSchema#date');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (22,'S','ipAddress','urn:oasis:names:tc:xacml:2.0:data-type:ipAddress');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (23,'S','yearMonthDuration','http://www.w3.org/2001/XMLSchema#yearMonthDuration');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (24,'S','hexBinary','http://www.w3.org/2001/XMLSchema#hexBinary');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (25,'S','double','http://www.w3.org/2001/XMLSchema#double');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (26,'S','string','http://www.w3.org/2001/XMLSchema#string');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (27,'S','anyURI','http://www.w3.org/2001/XMLSchema#anyURI');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (28,'S','xpathExpression','urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression');
+
+INSERT INTO PolicyAlgorithms (id, is_standard, short_name, xacml_id) VALUES (29,'S','ordered-deny-overrides','urn:oasis:names:tc:xacml:3.0:policy-combining-algorithm:ordered-deny-overrides');
+INSERT INTO PolicyAlgorithms (id, is_standard, short_name, xacml_id) VALUES (30,'S','on-permit-apply-second','urn:oasis:names:tc:xacml:3.0:policy-combining-algorithm:on-permit-apply-second');
+INSERT INTO PolicyAlgorithms (id, is_standard, short_name, xacml_id) VALUES (31,'S','deny-overrides','urn:oasis:names:tc:xacml:3.0:policy-combining-algorithm:deny-overrides');
+INSERT INTO PolicyAlgorithms (id, is_standard, short_name, xacml_id) VALUES (32,'S','permit-unless-deny','urn:oasis:names:tc:xacml:3.0:policy-combining-algorithm:permit-unless-deny');
+INSERT INTO PolicyAlgorithms (id, is_standard, short_name, xacml_id) VALUES (33,'S','deny-unless-permit','urn:oasis:names:tc:xacml:3.0:policy-combining-algorithm:deny-unless-permit');
+INSERT INTO PolicyAlgorithms (id, is_standard, short_name, xacml_id) VALUES (34,'S','permit-overrides','urn:oasis:names:tc:xacml:3.0:policy-combining-algorithm:permit-overrides');
+INSERT INTO PolicyAlgorithms (id, is_standard, short_name, xacml_id) VALUES (35,'S','only-one-applicable','urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:only-one-applicable');
+INSERT INTO PolicyAlgorithms (id, is_standard, short_name, xacml_id) VALUES (36,'S','first-applicable','urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:first-applicable');
+INSERT INTO PolicyAlgorithms (id, is_standard, short_name, xacml_id) VALUES (37,'S','ordered-permit-overrides','urn:oasis:names:tc:xacml:3.0:policy-combining-algorithm:ordered-permit-overrides');
+
+INSERT INTO RuleAlgorithms (id, is_standard, short_name, xacml_id) VALUES (38,'S','permit-unless-deny','urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-unless-deny');
+INSERT INTO RuleAlgorithms (id, is_standard, short_name, xacml_id) VALUES (39,'S','permit-overrides','urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides');
+INSERT INTO RuleAlgorithms (id, is_standard, short_name, xacml_id) VALUES (40,'S','deny-overrides','urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-overrides');
+INSERT INTO RuleAlgorithms (id, is_standard, short_name, xacml_id) VALUES (41,'S','ordered-permit-overrides','urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:ordered-permit-overrides');
+INSERT INTO RuleAlgorithms (id, is_standard, short_name, xacml_id) VALUES (42,'S','deny-unless-permit','urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-unless-permit');
+INSERT INTO RuleAlgorithms (id, is_standard, short_name, xacml_id) VALUES (43,'S','ordered-deny-overrides','urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:ordered-deny-overrides');
+INSERT INTO RuleAlgorithms (id, is_standard, short_name, xacml_id) VALUES (44,'S','only-one-applicable','urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:only-one-applicable');
+INSERT INTO RuleAlgorithms (id, is_standard, short_name, xacml_id) VALUES (45,'S','first-applicable','urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable');
+
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (1,'integer-greater-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:integer-greater-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (2,'integer-subtract','urn:oasis:names:tc:xacml:1.0:function:integer-subtract',12,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (3,'double-to-integer','urn:oasis:names:tc:xacml:1.0:function:double-to-integer',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (4,'integer-one-and-only','urn:oasis:names:tc:xacml:1.0:function:integer-one-and-only',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (5,'double-one-and-only','urn:oasis:names:tc:xacml:1.0:function:double-one-and-only',25,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (6,'string-equal','urn:oasis:names:tc:xacml:1.0:function:string-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (7,'string-equal-ignore-case','urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (8,'string-starts-with','urn:oasis:names:tc:xacml:3.0:function:string-starts-with',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (9,'string-ends-with','urn:oasis:names:tc:xacml:3.0:function: string-ends-with',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (10,'string-concatenate','urn:oasis:names:tc:xacml:2.0:function:string-concatenate',26,0,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (11,'boolean-from-string','urn:oasis:names:tc:xacml:3.0:function:boolean-from-string',18,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (12,'string-from-boolean','urn:oasis:names:tc:xacml:3.0:function:string-from-boolean',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (13,'integer-from-string','urn:oasis:names:tc:xacml:3.0:function:integer-from-string',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (14,'string-from-integer','urn:oasis:names:tc:xacml:3.0:function:string-from-integer',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (15,'double-from-string','urn:oasis:names:tc:xacml:3.0:function:double-from-string',25,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (16,'string-from-double','urn:oasis:names:tc:xacml:3.0:function:string-from-double',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (17,'time-from-string','urn:oasis:names:tc:xacml:3.0:function:time-from-string',16,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (18,'string-from-time','urn:oasis:names:tc:xacml:3.0:function:string-from-time',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (19,'date-from-string','urn:oasis:names:tc:xacml:3.0:function:date-from-string',21,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (20,'string-from-date','urn:oasis:names:tc:xacml:3.0:function:string-from-date',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (21,'dateTime-from-string','urn:oasis:names:tc:xacml:3.0:function:dateTime-from-string',19,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (22,'string-from-dateTime','urn:oasis:names:tc:xacml:3.0:function:string-from-dateTime',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (23,'anyURI-from-string','urn:oasis:names:tc:xacml:3.0:function:anyURI-from-string',27,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (24,'string-from-anyURI','urn:oasis:names:tc:xacml:3.0:function:string-from-anyURI',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (25,'dayTimeDuration-from-string','urn:oasis:names:tc:xacml:3.0:function:dayTimeDuration-from-string',15,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (26,'string-from-dayTimeDuration','urn:oasis:names:tc:xacml:3.0:function:string-from-dayTimeDuration',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (27,'yearMonthDuration-from-string','urn:oasis:names:tc:xacml:3.0:function:yearMonthDuration-from-string',23,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (28,'string-from-yearMonthDuration','urn:oasis:names:tc:xacml:3.0:function:string-from-yearMonthDuration',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (29,'x500Name-from-string','urn:oasis:names:tc:xacml:3.0:function:x500Name-from-string',14,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (30,'string-from-x500Name','urn:oasis:names:tc:xacml:3.0:function:string-from-x500Name',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (31,'rfc822Name-from-string','urn:oasis:names:tc:xacml:3.0:function:rfc822Name-from-string',20,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (32,'string-from-rfc822Name','urn:oasis:names:tc:xacml:3.0:function:string-from-rfc822Name',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (33,'ipAddress-from-string','urn:oasis:names:tc:xacml:3.0:function:ipAddress-from-string',22,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (34,'string-from-ipAddress','urn:oasis:names:tc:xacml:3.0:function:string-from-ipAddress',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (35,'dnsName-from-string','urn:oasis:names:tc:xacml:3.0:function:dnsName-from-string',17,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (36,'string-from-dnsName','urn:oasis:names:tc:xacml:3.0:function:string-from-dnsName',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (37,'anyURI-starts-with','urn:oasis:names:tc:xacml:3.0:function:anyURI-starts-with',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (38,'anyURI-ends-with','urn:oasis:names:tc:xacml:3.0:function:anyURI-ends-with',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (39,'string-contains','urn:oasis:names:tc:xacml:3.0:function:string-contains',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (40,'anyURI-contains','urn:oasis:names:tc:xacml:3.0:function:anyURI-contains',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (41,'string-substring','urn:oasis:names:tc:xacml:3.0:function:string-substring',26,0,0,3,3,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (42,'anyURI-substring','urn:oasis:names:tc:xacml:3.0:function:anyURI-substring',26,0,0,3,3,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (43,'boolean-equal','urn:oasis:names:tc:xacml:1.0:function:boolean-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (44,'integer-equal','urn:oasis:names:tc:xacml:1.0:function:integer-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (45,'double-equal','urn:oasis:names:tc:xacml:1.0:function:double-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (46,'date-equal','urn:oasis:names:tc:xacml:1.0:function:date-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (47,'time-equal','urn:oasis:names:tc:xacml:1.0:function:time-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (48,'dateTime-equal','urn:oasis:names:tc:xacml:1.0:function:dateTime-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (49,'dayTimeDuration-equal','urn:oasis:names:tc:xacml:3.0:function:dayTimeDuration-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (50,'yearMonthDuration-equal','urn:oasis:names:tc:xacml:3.0:function:yearMonthDuration-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (51,'anyURI-equal','urn:oasis:names:tc:xacml:1.0:function:anyURI-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (52,'x500Name-equal','urn:oasis:names:tc:xacml:1.0:function:x500Name-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (53,'rfc822Name-equal','urn:oasis:names:tc:xacml:1.0:function:rfc822Name-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (54,'hexBinary-equal','urn:oasis:names:tc:xacml:1.0:function:hexBinary-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (55,'base64Binary-equal','urn:oasis:names:tc:xacml:1.0:function:base64Binary-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (56,'integer-add','urn:oasis:names:tc:xacml:1.0:function:integer-add',12,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (57,'double-add','urn:oasis:names:tc:xacml:1.0:function:double-add',25,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (58,'double-subtract','urn:oasis:names:tc:xacml:1.0:function:double-subtract',25,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (59,'integer-multiply','urn:oasis:names:tc:xacml:1.0:function:integer-multiply',12,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (60,'double-multiply','urn:oasis:names:tc:xacml:1.0:function:double-multiply',25,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (61,'integer-divide','urn:oasis:names:tc:xacml:1.0:function:integer-divide',12,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (62,'double-divide','urn:oasis:names:tc:xacml:1.0:function:double-divide',25,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (63,'integer-mod','urn:oasis:names:tc:xacml:1.0:function:integer-mod',12,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (64,'integer-abs','urn:oasis:names:tc:xacml:1.0:function:integer-abs',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (65,'double-abs','urn:oasis:names:tc:xacml:1.0:function:double-abs',25,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (66,'round','urn:oasis:names:tc:xacml:1.0:function:round',25,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (67,'floor','urn:oasis:names:tc:xacml:1.0:function:floor',25,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (68,'string-normalize-space','urn:oasis:names:tc:xacml:1.0:function:string-normalize-space',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (69,'string-normalize-to-lower-case','urn:oasis:names:tc:xacml:1.0:function:string-normalize-to-lower-case',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (70,'integer-to-double','urn:oasis:names:tc:xacml:1.0:function:integer-to-double',25,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (71,'integer-greater-than','urn:oasis:names:tc:xacml:1.0:function:integer-greater-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (72,'integer-less-than','urn:oasis:names:tc:xacml:1.0:function:integer-less-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (73,'integer-less-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:integer-less-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (74,'double-greater-than','urn:oasis:names:tc:xacml:1.0:function:double-greater-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (75,'double-greater-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:double-greater-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (76,'double-less-than','urn:oasis:names:tc:xacml:1.0:function:double-less-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (77,'double-less-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:double-less-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (78,'dateTime-add-dayTimeDuration','urn:oasis:names:tc:xacml:3.0:function:dateTime-add-dayTimeDuration',19,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (79,'dateTime-add-yearMonthDuration','urn:oasis:names:tc:xacml:3.0:function:dateTime-add-yearMonthDuration',19,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (80,'dateTime-subtract-dayTimeDuration','urn:oasis:names:tc:xacml:3.0:function:dateTime-subtract-dayTimeDuration',19,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (81,'dateTime-subtract-yearMonthDuration','urn:oasis:names:tc:xacml:3.0:function:dateTime-subtract-yearMonthDuration',19,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (82,'date-add-yearMonthDuration','urn:oasis:names:tc:xacml:3.0:function:date-add-yearMonthDuration',21,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (83,'date-subtract-yearMonthDuration','urn:oasis:names:tc:xacml:3.0:function:date-subtract-yearMonthDuration',21,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (84,'string-greater-than','urn:oasis:names:tc:xacml:1.0:function:string-greater-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (85,'string-greater-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:string-greater-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (86,'string-less-than','urn:oasis:names:tc:xacml:1.0:function:string-less-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (87,'string-less-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:string-less-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (88,'time-greater-than','urn:oasis:names:tc:xacml:1.0:function:time-greater-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (89,'time-greater-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:time-greater-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (90,'time-less-than','urn:oasis:names:tc:xacml:1.0:function:time-less-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (91,'time-less-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:time-less-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (92,'time-in-range','urn:oasis:names:tc:xacml:2.0:function:time-in-range',18,0,0,3,3,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (93,'dateTime-greater-than','urn:oasis:names:tc:xacml:1.0:function:dateTime-greater-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (94,'dateTime-greater-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:dateTime-greater-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (95,'dateTime-less-than','urn:oasis:names:tc:xacml:1.0:function:dateTime-less-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (96,'dateTime-less-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:dateTime-less-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (97,'date-greater-than','urn:oasis:names:tc:xacml:1.0:function:date-greater-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (98,'date-greater-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:date-greater-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (99,'date-less-than','urn:oasis:names:tc:xacml:1.0:function:date-less-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (100,'date-less-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:date-less-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (101,'string-one-and-only','urn:oasis:names:tc:xacml:1.0:function:string-one-and-only',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (102,'string-bag-size','urn:oasis:names:tc:xacml:1.0:function:string-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (103,'string-is-in','urn:oasis:names:tc:xacml:1.0:function:string-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (104,'string-bag','urn:oasis:names:tc:xacml:1.0:function:string-bag',26,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (105,'integer-bag-size','urn:oasis:names:tc:xacml:1.0:function:integer-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (106,'integer-is-in','urn:oasis:names:tc:xacml:1.0:function:integer-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (107,'integer-bag','urn:oasis:names:tc:xacml:1.0:function:integer-bag',12,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (108,'double-bag-size','urn:oasis:names:tc:xacml:1.0:function:double-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (109,'double-is-in','urn:oasis:names:tc:xacml:1.0:function:double-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (110,'double-bag','urn:oasis:names:tc:xacml:1.0:function:double-bag',25,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (111,'boolean-one-and-only','urn:oasis:names:tc:xacml:1.0:function:boolean-one-and-only',18,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (112,'boolean-bag-size','urn:oasis:names:tc:xacml:1.0:function:boolean-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (113,'boolean-is-in','urn:oasis:names:tc:xacml:1.0:function:boolean-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (114,'boolean-bag','urn:oasis:names:tc:xacml:1.0:function:boolean-bag',18,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (115,'time-one-and-only','urn:oasis:names:tc:xacml:1.0:function:time-one-and-only',16,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (116,'time-bag-size','urn:oasis:names:tc:xacml:1.0:function:time-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (117,'time-is-in','urn:oasis:names:tc:xacml:1.0:function:time-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (118,'time-bag','urn:oasis:names:tc:xacml:1.0:function:time-bag',16,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (119,'date-one-and-only','urn:oasis:names:tc:xacml:1.0:function:date-one-and-only',21,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (120,'date-bag-size','urn:oasis:names:tc:xacml:1.0:function:date-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (121,'date-is-in','urn:oasis:names:tc:xacml:1.0:function:date-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (122,'date-bag','urn:oasis:names:tc:xacml:1.0:function:date-bag',21,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (123,'dateTime-one-and-only','urn:oasis:names:tc:xacml:1.0:function:dateTime-one-and-only',19,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (124,'dateTime-bag-size','urn:oasis:names:tc:xacml:1.0:function:dateTime-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (125,'dateTime-is-in','urn:oasis:names:tc:xacml:1.0:function:dateTime-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (126,'dateTime-bag','urn:oasis:names:tc:xacml:1.0:function:dateTime-bag',19,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (127,'anyURI-one-and-only','urn:oasis:names:tc:xacml:1.0:function:anyURI-one-and-only',27,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (128,'anyURI-bag-size','urn:oasis:names:tc:xacml:1.0:function:anyURI-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (129,'anyURI-is-in','urn:oasis:names:tc:xacml:1.0:function:anyURI-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (130,'anyURI-bag','urn:oasis:names:tc:xacml:1.0:function:anyURI-bag',27,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (131,'hexBinary-one-and-only','urn:oasis:names:tc:xacml:1.0:function:hexBinary-one-and-only',24,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (132,'hexBinary-bag-size','urn:oasis:names:tc:xacml:1.0:function:hexBinary-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (133,'hexBinary-is-in','urn:oasis:names:tc:xacml:1.0:function:hexBinary-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (134,'hexBinary-bag','urn:oasis:names:tc:xacml:1.0:function:hexBinary-bag',24,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (135,'base64Binary-one-and-only','urn:oasis:names:tc:xacml:1.0:function:base64Binary-one-and-only',13,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (136,'base64Binary-bag-size','urn:oasis:names:tc:xacml:1.0:function:base64Binary-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (137,'base64Binary-is-in','urn:oasis:names:tc:xacml:1.0:function:base64Binary-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (138,'base64Binary-bag','urn:oasis:names:tc:xacml:1.0:function:base64Binary-bag',13,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (139,'dayTimeDuration-one-and-only','urn:oasis:names:tc:xacml:3.0:function:dayTimeDuration-one-and-only',15,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (140,'dayTimeDuration-bag-size','urn:oasis:names:tc:xacml:3.0:function:dayTimeDuration-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (141,'dayTimeDuration-is-in','urn:oasis:names:tc:xacml:3.0:function:dayTimeDuration-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (142,'dayTimeDuration-bag','urn:oasis:names:tc:xacml:3.0:function:dayTimeDuration-bag',15,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (143,'yearMonthDuration-one-and-only','urn:oasis:names:tc:xacml:3.0:function:yearMonthDuration-one-and-only',23,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (144,'yearMonthDuration-bag-size','urn:oasis:names:tc:xacml:3.0:function:yearMonthDuration-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (145,'yearMonthDuration-is-in','urn:oasis:names:tc:xacml:3.0:function:yearMonthDuration-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (146,'yearMonthDuration-bag','urn:oasis:names:tc:xacml:3.0:function:yearMonthDuration-bag',23,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (147,'x500Name-one-and-only','urn:oasis:names:tc:xacml:1.0:function:x500Name-one-and-only',14,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (148,'x500Name-bag-size','urn:oasis:names:tc:xacml:1.0:function:x500Name-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (149,'x500Name-is-in','urn:oasis:names:tc:xacml:1.0:function:x500Name-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (150,'x500Name-bag','urn:oasis:names:tc:xacml:1.0:function:x500Name-bag',14,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (151,'rfc822Name-one-and-only','urn:oasis:names:tc:xacml:1.0:function:rfc822Name-one-and-only',20,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (152,'rfc822Name-bag-size','urn:oasis:names:tc:xacml:1.0:function:rfc822Name-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (153,'rfc822Name-is-in','urn:oasis:names:tc:xacml:1.0:function:rfc822Name-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (154,'rfc822Name-bag','urn:oasis:names:tc:xacml:1.0:function:rfc822Name-bag',20,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (155,'ipAddress-one-and-only','urn:oasis:names:tc:xacml:2.0:function:ipAddress-one-and-only',22,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (156,'ipAddress-bag-size','urn:oasis:names:tc:xacml:2.0:function:ipAddress-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (157,'ipAddress-is-in','urn:oasis:names:tc:xacml:2.0:function:ipAddress-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (158,'ipAddress-bag','urn:oasis:names:tc:xacml:2.0:function:ipAddress-bag',22,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (159,'dnsName-one-and-only','urn:oasis:names:tc:xacml:2.0:function:dnsName-one-and-only',17,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (160,'dnsName-bag-size','urn:oasis:names:tc:xacml:2.0:function:dnsName-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (161,'dnsName-is-in','urn:oasis:names:tc:xacml:2.0:function:dnsName-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (162,'dnsName-bag','urn:oasis:names:tc:xacml:2.0:function:dnsName-bag',17,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (163,'string-regexp-match','urn:oasis:names:tc:xacml:1.0:function:string-regexp-match',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (164,'anyURI-regexp-match','urn:oasis:names:tc:xacml:2.0:function:anyURI-regexp-match',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (165,'ipAddress-regexp-match','urn:oasis:names:tc:xacml:2.0:function:ipAddress-regexp-match',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (166,'dnsName-regexp-match','urn:oasis:names:tc:xacml:2.0:function:dnsName-regexp-match',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (167,'rfc822Name-regexp-match','urn:oasis:names:tc:xacml:2.0:function:rfc822Name-regexp-match',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (168,'x500Name-regexp-match','urn:oasis:names:tc:xacml:2.0:function:x500Name-regexp-match',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (169,'string-intersection','urn:oasis:names:tc:xacml:1.0:function:string-intersection',26,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (170,'string-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:string-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (171,'string-union','urn:oasis:names:tc:xacml:1.0:function:string-union',26,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (172,'string-subset','urn:oasis:names:tc:xacml:1.0:function:string-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (173,'string-set-equals','urn:oasis:names:tc:xacml:1.0:function:string-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (174,'integer-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:integer-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (175,'integer-union','urn:oasis:names:tc:xacml:1.0:function:integer-union',12,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (176,'integer-subset','urn:oasis:names:tc:xacml:1.0:function:integer-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (177,'integer-set-equals','urn:oasis:names:tc:xacml:1.0:function:integer-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (178,'double-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:double-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (179,'double-union','urn:oasis:names:tc:xacml:1.0:function:double-union',25,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (180,'double-subset','urn:oasis:names:tc:xacml:1.0:function:double-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (181,'double-set-equals','urn:oasis:names:tc:xacml:1.0:function:double-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (182,'boolean-intersection','urn:oasis:names:tc:xacml:1.0:function:boolean-intersection',18,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (183,'boolean-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:boolean-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (184,'boolean-union','urn:oasis:names:tc:xacml:1.0:function:boolean-union',18,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (185,'boolean-subset','urn:oasis:names:tc:xacml:1.0:function:boolean-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (186,'boolean-set-equals','urn:oasis:names:tc:xacml:1.0:function:boolean-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (187,'time-intersection','urn:oasis:names:tc:xacml:1.0:function:time-intersection',16,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (188,'time-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:time-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (189,'time-union','urn:oasis:names:tc:xacml:1.0:function:time-union',16,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (190,'time-subset','urn:oasis:names:tc:xacml:1.0:function:time-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (191,'time-set-equals','urn:oasis:names:tc:xacml:1.0:function:time-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (192,'date-intersection','urn:oasis:names:tc:xacml:1.0:function:date-intersection',21,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (193,'date-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:date-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (194,'date-union','urn:oasis:names:tc:xacml:1.0:function:date-union',21,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (195,'date-subset','urn:oasis:names:tc:xacml:1.0:function:date-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (196,'date-set-equals','urn:oasis:names:tc:xacml:1.0:function:date-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (197,'dateTime-intersection','urn:oasis:names:tc:xacml:1.0:function:dateTime-intersection',19,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (198,'dateTime-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:dateTime-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (199,'dateTime-union','urn:oasis:names:tc:xacml:1.0:function:dateTime-union',19,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (200,'dateTime-subset','urn:oasis:names:tc:xacml:1.0:function:dateTime-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (201,'dateTime-set-equals','urn:oasis:names:tc:xacml:1.0:function:dateTime-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (202,'anyURI-intersection','urn:oasis:names:tc:xacml:1.0:function:anyURI-intersection',27,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (203,'anyURI-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:anyURI-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (204,'anyURI-union','urn:oasis:names:tc:xacml:1.0:function:anyURI-union',27,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (205,'anyURI-subset','urn:oasis:names:tc:xacml:1.0:function:anyURI-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (206,'anyURI-set-equals','urn:oasis:names:tc:xacml:1.0:function:anyURI-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (207,'hexBinary-intersection','urn:oasis:names:tc:xacml:1.0:function:hexBinary-intersection',24,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (208,'hexBinary-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:hexBinary-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (209,'hexBinary-union','urn:oasis:names:tc:xacml:1.0:function:hexBinary-union',24,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (210,'hexBinary-subset','urn:oasis:names:tc:xacml:1.0:function:hexBinary-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (211,'hexBinary-set-equals','urn:oasis:names:tc:xacml:1.0:function:hexBinary-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (212,'base64Binary-intersection','urn:oasis:names:tc:xacml:1.0:function:base64Binary-intersection',13,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (213,'base64Binary-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:base64Binary-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (214,'base64Binary-union','urn:oasis:names:tc:xacml:1.0:function:base64Binary-union',13,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (215,'base64Binary-subset','urn:oasis:names:tc:xacml:1.0:function:base64Binary-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (216,'base64Binary-set-equals','urn:oasis:names:tc:xacml:1.0:function:base64Binary-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (217,'dayTimeDuration-intersection','urn:oasis:names:tc:xacml:3.0:function:dayTimeDuration-intersection',15,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (218,'dayTimeDuration-at-least-one-member-of','urn:oasis:names:tc:xacml:3.0:function:dayTimeDuration-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (219,'dayTimeDuration-union','urn:oasis:names:tc:xacml:3.0:function:dayTimeDuration-union',15,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (220,'dayTimeDuration-subset','urn:oasis:names:tc:xacml:3.0:function:dayTimeDuration-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (221,'dayTimeDuration-set-equals','urn:oasis:names:tc:xacml:3.0:function:dayTimeDuration-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (222,'yearMonthDuration-intersection','urn:oasis:names:tc:xacml:3.0:function:yearMonthDuration-intersection',23,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (223,'yearMonthDuration-at-least-one-member-of','urn:oasis:names:tc:xacml:3.0:function:yearMonthDuration-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (224,'yearMonthDuration-union','urn:oasis:names:tc:xacml:3.0:function:yearMonthDuration-union',23,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (225,'yearMonthDuration-subset','urn:oasis:names:tc:xacml:3.0:function:yearMonthDuration-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (226,'yearMonthDuration-set-equals','urn:oasis:names:tc:xacml:3.0:function:yearMonthDuration-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (227,'x500Name-intersection','urn:oasis:names:tc:xacml:1.0:function:x500Name-intersection',14,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (228,'x500Name-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:x500Name-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (229,'x500Name-union','urn:oasis:names:tc:xacml:1.0:function:x500Name-union',14,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (230,'x500Name-subset','urn:oasis:names:tc:xacml:1.0:function:x500Name-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (231,'x500Name-set-equals','urn:oasis:names:tc:xacml:1.0:function:x500Name-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (232,'rfc822Name-intersection','urn:oasis:names:tc:xacml:1.0:function:rfc822Name-intersection',20,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (233,'rfc822Name-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:rfc822Name-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (234,'rfc822Name-union','urn:oasis:names:tc:xacml:1.0:function:rfc822Name-union',20,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (235,'rfc822Name-subset','urn:oasis:names:tc:xacml:1.0:function:rfc822Name-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (236,'rfc822Name-set-equals','urn:oasis:names:tc:xacml:1.0:function:rfc822Name-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (237,'x500Name-match','urn:oasis:names:tc:xacml:1.0:function:x500Name-match',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (238,'rfc822Name-match','urn:oasis:names:tc:xacml:1.0:function:rfc822Name-match',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (239,'integer-intersection','urn:oasis:names:tc:xacml:1.0:function:integer-intersection',12,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (240,'double-intersection','urn:oasis:names:tc:xacml:1.0:function:double-intersection',25,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (241,'or','urn:oasis:names:tc:xacml:1.0:function:or',18,0,0,0,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (242,'and','urn:oasis:names:tc:xacml:1.0:function:and',18,0,0,0,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (243,'n-of','urn:oasis:names:tc:xacml:1.0:function:n-of',18,0,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (244,'not','urn:oasis:names:tc:xacml:1.0:function:not',18,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (245,'any-of','urn:oasis:names:tc:xacml:3.0:function:any-of',18,0,1,2,-1,1,-1,1);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (246,'all-of','urn:oasis:names:tc:xacml:3.0:function:all-of',18,0,1,2,-1,1,-1,1);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (247,'any-of-any','urn:oasis:names:tc:xacml:3.0:function:any-of-any',18,0,1,2,-1,1,-1,0);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (248,'all-of-any','urn:oasis:names:tc:xacml:1.0:function:all-of-any',18,0,1,3,3,2,2,1);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (249,'any-of-all','urn:oasis:names:tc:xacml:1.0:function:any-of-all',18,0,1,3,3,2,2,1);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (250,'all-of-all','urn:oasis:names:tc:xacml:1.0:function:all-of-all',18,0,1,3,3,2,2,1);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (251,'map','urn:oasis:names:tc:xacml:3.0:function:map',NULL,1,1,2,-1,1,-1,1);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (252,'xpath-node-count','urn:oasis:names:tc:xacml:3.0:function:xpath-node-count',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (253,'xpath-node-equal','urn:oasis:names:tc:xacml:3.0:function:xpath-node-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (254,'xpath-node-match','urn:oasis:names:tc:xacml:3.0:function:xpath-node-match',18,0,0,2,2,NULL,NULL,NULL);
+
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (1,0,1,1,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (2,0,1,2,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (3,0,2,1,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (4,0,2,2,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (5,0,3,1,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (6,1,4,1,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (7,1,5,1,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (8,0,6,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (9,0,6,2,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (10,0,7,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (11,0,7,2,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (12,0,8,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (13,0,8,2,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (14,0,9,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (15,0,9,2,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (16,0,10,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (17,0,11,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (18,0,12,1,18);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (19,0,13,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (20,0,14,1,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (21,0,15,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (22,0,16,1,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (23,0,17,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (24,0,18,1,16);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (25,0,19,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (26,0,20,1,21);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (27,0,21,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (28,0,22,1,19);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (29,0,23,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (30,0,24,1,27);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (31,0,25,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (32,0,26,1,15);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (33,0,27,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (34,0,28,1,23);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (35,0,29,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (36,0,30,1,14);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (37,0,31,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (38,0,32,1,20);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (39,0,33,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (40,0,34,1,22);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (41,0,35,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (42,0,36,1,17);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (43,0,37,2,27);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (44,0,37,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (45,0,38,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (46,0,38,2,27);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (47,0,39,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (48,0,39,2,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (49,0,40,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (50,0,40,2,27);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (51,0,41,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (52,0,41,2,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (53,0,41,3,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (54,0,42,1,27);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (55,0,42,2,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (56,0,42,3,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (57,0,43,1,18);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (58,0,43,2,18);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (59,0,44,1,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (60,0,44,2,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (61,0,45,1,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (62,0,45,2,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (63,0,46,1,21);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (64,0,46,2,21);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (65,0,47,1,16);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (66,0,47,2,16);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (67,0,48,1,19);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (68,0,48,2,19);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (69,0,49,1,15);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (70,0,49,2,15);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (71,0,50,1,23);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (72,0,50,2,23);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (73,0,51,1,27);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (74,0,51,2,27);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (75,0,52,1,14);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (76,0,52,2,14);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (77,0,53,1,20);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (78,0,53,2,20);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (79,0,54,1,24);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (80,0,54,2,24);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (81,0,55,1,13);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (82,0,55,2,13);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (83,0,56,1,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (84,0,56,2,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (85,0,57,1,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (86,0,57,2,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (89,0,58,1,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (90,0,58,2,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (91,0,59,1,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (92,0,59,2,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (93,0,60,1,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (94,0,60,2,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (95,0,61,1,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (96,0,61,2,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (97,0,62,1,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (98,0,62,2,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (99,0,63,1,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (100,0,63,2,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (101,0,64,1,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (102,0,65,1,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (103,0,66,1,25);
<TRUNCATED>
[18/23] incubator-openaz git commit: Ported original att source to
openaz
Posted by pd...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/PolicyWorkspace.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/PolicyWorkspace.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/PolicyWorkspace.java
new file mode 100644
index 0000000..8e006d1
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/PolicyWorkspace.java
@@ -0,0 +1,1640 @@
+/*
+ * 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.xacml.admin.components;
+
+import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.file.FileVisitResult;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.SimpleFileVisitor;
+import java.nio.file.attribute.BasicFileAttributes;
+import java.util.Collection;
+import java.util.Iterator;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicySetType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.RuleType;
+
+import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
+import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
+import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
+import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.Status;
+import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.dircache.DirCache;
+import org.eclipse.jgit.dircache.DirCacheEntry;
+import org.eclipse.jgit.errors.NoWorkTreeException;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.transport.PushResult;
+import org.vaadin.dialogs.ConfirmDialog;
+import org.vaadin.dialogs.ConfirmDialog.ContentMode;
+
+import org.apache.openaz.xacml.admin.XacmlAdminAuthorization;
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.model.GitRepositoryContainer;
+import org.apache.openaz.xacml.admin.util.AdminNotification;
+import org.apache.openaz.xacml.admin.util.OnDemandFileDownloader;
+import org.apache.openaz.xacml.admin.util.OnDemandFileDownloader.OnDemandStreamResource;
+import org.apache.openaz.xacml.admin.util.XACMLPolicyImporter;
+import org.apache.openaz.xacml.admin.view.windows.GitPushWindow;
+import org.apache.openaz.xacml.admin.view.windows.GitSynchronizeWindow;
+import org.apache.openaz.xacml.admin.view.windows.PolicyNameEditorWindow;
+import org.apache.openaz.xacml.admin.view.windows.PolicyUploadWindow;
+import org.apache.openaz.xacml.admin.view.windows.RenamePolicyFileWindow;
+import org.apache.openaz.xacml.admin.view.windows.SubDomainEditorWindow;
+import org.apache.openaz.xacml.std.pap.StdPDPPolicy;
+import org.apache.openaz.xacml.util.XACMLPolicyScanner;
+import org.apache.openaz.xacml.util.XACMLPolicyScanner.CallbackResult;
+import org.apache.openaz.xacml.util.XACMLPolicyWriter;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Item;
+import com.vaadin.event.Action;
+import com.vaadin.event.Action.Handler;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.event.Transferable;
+import com.vaadin.event.dd.DragAndDropEvent;
+import com.vaadin.event.dd.DropHandler;
+import com.vaadin.event.dd.acceptcriteria.AcceptAll;
+import com.vaadin.event.dd.acceptcriteria.AcceptCriterion;
+import com.vaadin.ui.AbstractSelect.AbstractSelectTargetDetails;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.HorizontalSplitPanel;
+import com.vaadin.ui.Notification;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.TabSheet.CloseHandler;
+import com.vaadin.ui.TabSheet.Tab;
+import com.vaadin.ui.Table.TableDragMode;
+import com.vaadin.ui.Table.TableTransferable;
+import com.vaadin.ui.TreeTable;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window.CloseEvent;
+import com.vaadin.ui.Window.CloseListener;
+
+/**
+ * The class represents Policy Editor in Policy Authoring Tool
+ */
+public class PolicyWorkspace extends CustomComponent implements DropHandler, OnDemandStreamResource {
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+
+ @AutoGenerated
+ private HorizontalSplitPanel horizontalSplitPanel;
+
+ @AutoGenerated
+ private VerticalLayout verticalLayoutRightPanel;
+
+ @AutoGenerated
+ private TabSheet tabSheet;
+
+ @AutoGenerated
+ private HorizontalLayout horizontalLayoutRightToolbar;
+
+ @AutoGenerated
+ private Button buttonRight;
+
+ @AutoGenerated
+ private VerticalLayout verticalLayoutLeftPanel;
+
+ @AutoGenerated
+ private TreeTable treeWorkspace;
+
+ @AutoGenerated
+ private HorizontalLayout horizontalLayoutLeftToolbar;
+
+ @AutoGenerated
+ private Button buttonLeft;
+
+ @AutoGenerated
+ private HorizontalLayout horizontalLayoutLeftToolbarLeft;
+
+ @AutoGenerated
+ private Button buttonExport;
+
+ @AutoGenerated
+ private Button buttonSynchronize;
+
+ private static final long serialVersionUID = 1L;
+ private static final Log logger = LogFactory.getLog(PolicyWorkspace.class);
+ private final PolicyWorkspace self = this;
+ private final OnDemandFileDownloader downloader = new OnDemandFileDownloader(this);
+
+ private GitRepositoryContainer treeContainer;
+
+ private static final Action EXPORT_REPOSITORY = new Action ("Export Repository");
+ private static final Action SYNCHRONIZE_REPOSITORY =new Action ("Synchronize");
+ private static final Action PUSH_CHANGES = new Action ("Push Changes");
+ private static final Action CREATE_SUBDOMAIN = new Action("Create Sub Domain");
+ private static final Action RENAME_SUBDOMAIN = new Action("Rename Sub Domain");
+ private static final Action CREATE_NEWPOLICY = new Action ("Create New Policy");
+ private static final Action RENAME_POLICY = new Action ("Rename Policy");
+ private static final Action IMPORT_POLICY = new Action ("Import Policy");
+ private static final Action DELETE_SUBDOMAIN = new Action ("Delete Sub Domain");
+ private static final Action CLONE_POLICY = new Action ("Clone Policy");
+ private static final Action VIEW_POLICY = new Action ("View Policy");
+ private static final Action EDIT_POLICY = new Action ("Edit Policy");
+ private static final Action EXPORT_POLICY = new Action ("Export Policy");
+ private static final Action DELETE_POLICY = new Action ("Delete Policy");
+
+ public static final String VIEWNAME = PolicyWorkspace.class.getCanonicalName();
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public PolicyWorkspace() {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+ //
+ // Initialize GUI
+ //
+ this.initializeTree();
+ this.initializeButtons();
+ }
+
+ protected void initializeButtons() {
+ buttonLeft.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ if (horizontalSplitPanel.getSplitPosition() == 100.0)
+ horizontalSplitPanel.setSplitPosition(36, Unit.PERCENTAGE);
+ else
+ horizontalSplitPanel.setSplitPosition(0);
+ }
+ });
+ buttonRight.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ if (horizontalSplitPanel.getSplitPosition() == 0.0)
+ horizontalSplitPanel.setSplitPosition(36, Unit.PERCENTAGE);
+ else
+ horizontalSplitPanel.setSplitPosition(100, Unit.PERCENTAGE);
+ }
+ });
+ //
+ // Check user write-access
+ //
+ if (((XacmlAdminUI)UI.getCurrent()).isAuthorized(
+ XacmlAdminAuthorization.AdminAction.ACTION_WRITE,
+ XacmlAdminAuthorization.AdminResource.RESOURCE_POLICY_WORKSPACE)) {
+ this.buttonSynchronize.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ self.synchronizeRepository();
+ }
+ });
+ } else {
+ logger.info("user not authorized to write, removing synchronize button.");
+ this.buttonSynchronize.setVisible(false);
+ }
+ //
+ // The export button is attached to dynamic downloader
+ //
+ downloader.extend(this.buttonExport);
+ }
+
+ protected void initializeTree() {
+ //
+ // This is where the user's Git repository is located
+ //
+ final Path gitPath = ((XacmlAdminUI)UI.getCurrent()).getUserGitPath();
+ //
+ // Create our Git file system container
+ //
+ this.treeContainer = new GitRepositoryContainer(gitPath, gitPath.toFile());
+ //
+ // Create our own filter to filter out File extensions and
+ // also the Git directory.
+ //
+ this.treeContainer.setFilter(new FilenameFilter() {
+
+ @Override
+ public boolean accept(File dir, String name) {
+ //
+ // We don't want any of the hidden files
+ //
+ if (name.startsWith(".git") || name.equals(".DS_Store")) {
+ return false;
+ }
+ //
+ // We definitely want xml files
+ //
+ if (name.endsWith(".xml")) {
+ return true;
+ }
+ //
+ // We should test if its a directory, we want those
+ // included.
+ //
+ Path path = Paths.get(dir.getAbsolutePath(), name);
+ if (Files.isDirectory(path)) {
+ return true;
+ }
+ logger.warn("Filtering out: " + path.toString());
+ return false;
+ }
+
+ });
+ //
+ // Set TreeTables datasource as our git container
+ //
+ this.treeWorkspace.setContainerDataSource(this.treeContainer);
+ //
+ // Setup other properties etc.
+ //
+ this.treeWorkspace.setItemIconPropertyId("Icon");
+ this.treeWorkspace.setVisibleColumns(new Object[]{"Name", "Version", "Size", "Last Modified", "Status"});
+ this.treeWorkspace.setSizeFull();
+ this.treeWorkspace.setSelectable(true);
+ this.treeWorkspace.setEditable(false);
+ //
+ // Expand the first couple of directories
+ //
+ for (Object id : this.treeWorkspace.getItemIds()) {
+ this.treeWorkspace.setCollapsed(id, false);
+ for (Object child : this.treeWorkspace.getChildren(id)) {
+ this.treeWorkspace.setCollapsed(child, false);
+ }
+ }
+ //
+ // Respond to table selections
+ //
+ /*
+ this.treeWorkspace.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ File selection = (File) self.treeWorkspace.getValue();
+ if (selection != null) {
+ self.buttonImport.setEnabled(selection.isDirectory());
+ self.buttonExport.setEnabled(selection.isFile());
+ } else {
+
+ }
+ }
+
+ });
+ */
+ this.treeWorkspace.addItemClickListener(new ItemClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void itemClick(ItemClickEvent event) {
+ if (event.isDoubleClick() &&
+ event.getItemId() instanceof File &&
+ ((File) event.getItemId()).isFile()) {
+ self.openPolicyTab((File) event.getItemId(), true);
+ }
+ }
+ });
+ //
+ // Setup our action handlers
+ //
+ this.treeWorkspace.addActionHandler(new Handler() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Action[] getActions(Object target, Object sender) {
+ if (target == null) {
+ //
+ // Nothing is selected, they right-clicked empty space
+ //
+ return new Action[] {SYNCHRONIZE_REPOSITORY, EXPORT_REPOSITORY, CREATE_SUBDOMAIN};
+ }
+ if (! (target instanceof File)) {
+ return null;
+ }
+ if (((File)target).isDirectory()) {
+ //
+ // Selected a directory
+ //
+ return new Action[] {CREATE_SUBDOMAIN, RENAME_SUBDOMAIN, DELETE_SUBDOMAIN, CREATE_NEWPOLICY, IMPORT_POLICY, PUSH_CHANGES};
+ }
+ if (((File)target).isFile()) {
+ //
+ // Selected a policy file
+ //
+ return new Action[] {VIEW_POLICY, EDIT_POLICY, CLONE_POLICY, EXPORT_POLICY, RENAME_POLICY, DELETE_POLICY, PUSH_CHANGES};
+ }
+ return null;
+ }
+
+ @Override
+ public void handleAction(Action action, Object sender, Object target) {
+ if (action == SYNCHRONIZE_REPOSITORY) {
+ self.synchronizeRepository();
+ return;
+ }
+ if (action == EXPORT_REPOSITORY) {
+ self.exportRepository();
+ return;
+ }
+ if (action == PUSH_CHANGES) {
+ self.pushChanges((File) target);
+ return;
+ }
+ if (action == CREATE_SUBDOMAIN) {
+ self.editSubDomain((File) target, null);
+ return;
+ }
+ if (action == RENAME_SUBDOMAIN) {
+ self.editSubDomain((File) self.treeWorkspace.getParent(target), ((File)target).getName());
+ return;
+ }
+ if (action == CREATE_NEWPOLICY) {
+ self.createPolicy((File) target);
+ return;
+ }
+ if (action == RENAME_POLICY) {
+ self.renamePolicy((File) target);
+ return;
+
+ }
+ if (action == IMPORT_POLICY) {
+ self.importPolicy((File) target);
+ return;
+ }
+ if (action == DELETE_SUBDOMAIN) {
+ self.deleteSubDomain((File) target);
+ return;
+ }
+ if (action == CLONE_POLICY) {
+ self.clonePolicy((File) target);
+ return;
+ }
+ if (action == VIEW_POLICY) {
+ self.openPolicyTab((File) target, true);
+ return;
+ }
+ if (action == EDIT_POLICY) {
+ self.openPolicyTab((File) target, false);
+ return;
+ }
+ if (action == EXPORT_POLICY) {
+ return;
+
+ }
+ if (action == DELETE_POLICY) {
+ self.deletePolicy((File) target);
+ return;
+ }
+ }
+ });
+ //
+ // Set the drop handler
+ //
+ this.treeWorkspace.setDragMode(TableDragMode.ROW);
+ this.treeWorkspace.setDropHandler(this);
+ //
+ // Detect when a tab closes and remove it from the
+ // tab sheet.
+ //
+ this.tabSheet.setCloseHandler(new CloseHandler() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void onTabClose(TabSheet tabsheet, Component tabContent) {
+ logger.info("tabsheet closing: " + tabsheet.getCaption());
+ tabsheet.removeTab(tabsheet.getTab(tabContent));
+ }
+
+ });
+ }
+
+ protected void editSubDomain(final File parent, final String subdomain) {
+ final SubDomainEditorWindow editor = new SubDomainEditorWindow(null);
+ editor.setCaption((subdomain == null ? "Create New SubDomain" : "Edit SubDomain"));
+ editor.setCloseShortcut(KeyCode.ESCAPE);
+ editor.setModal(true);
+ editor.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent event) {
+ //
+ // Did the user save it
+ //
+ if (editor.isSaved() == false) {
+ return;
+ }
+ String newSubDomain = editor.getSubDomain();
+ if (newSubDomain == null) {
+ logger.warn("Shouldn't have a null subdomain if the user clicked save button");
+ return;
+ }
+ //
+ // New subdomain?
+ //
+ if (subdomain == null) {
+ //
+ // Create new one
+ //
+ Path createDir;
+ if (parent == null) {
+ //
+ // New Root domain
+ //
+ createDir = Paths.get(((XacmlAdminUI)UI.getCurrent()).getUserGitPath().toAbsolutePath().toString(), newSubDomain);
+ } else {
+ //
+ // New subdomain
+ //
+ createDir = Paths.get(parent.getAbsolutePath(), newSubDomain);
+ }
+ try {
+ //
+ // Does the new subdomain exist?
+ //
+ Path newDir;
+ if (Files.exists(createDir)) {
+ //
+ // It already exists
+ //
+ newDir = createDir;
+ } else {
+ //
+ // Create it
+ //
+ newDir = Files.createDirectory(createDir);
+ //
+ // Create empty .gitignore file
+ //
+ Files.createFile(Paths.get(newDir.toString(), ".gitignore"));
+ }
+ //
+ // Setup the TreeTable
+ //
+ File file = newDir.toFile();
+ if (parent == null) {
+ Item item = self.treeWorkspace.addItem(file);
+ if (item != null) {
+ self.treeWorkspace.setCollapsed(file, false);
+ self.treeWorkspace.select(file);
+ }
+ } else {
+ Item item = self.treeWorkspace.addItem(file);
+ if (item != null) {
+ self.treeWorkspace.setParent(file, parent);
+ self.treeWorkspace.setCollapsed(parent, false);
+ self.treeWorkspace.select(file);
+ }
+ }
+ } catch (IOException e) {
+ logger.error("Failed to create subdomain: " + createDir.toString(), e);
+ }
+ } else {
+ //
+ // Get our paths
+ //
+ Path oldDir = Paths.get(parent.getAbsolutePath(), subdomain);
+ Path newDir = Paths.get(parent.getAbsolutePath(), newSubDomain);
+ try {
+ //
+ // Rename the subdomain
+ //
+ Files.move(oldDir, newDir);
+ //
+ // Add to the TreeTable
+ //
+ File newFile = newDir.toFile();
+ File oldFile = oldDir.toFile();
+ Item item = self.treeWorkspace.addItem(newFile);
+ if (item != null) {
+ self.treeWorkspace.setChildrenAllowed(newFile, true);
+ //
+ // Make sure its parent is the same as the old one, unless they
+ // renamed the top-level.
+ //
+ Object parent = self.treeWorkspace.getParent(oldFile);
+ if (parent != null) {
+ self.treeWorkspace.setParent(newFile, parent);
+ }
+ //
+ // Make any children of the old subdomain now children
+ // of the new subdomain.
+ //
+ Collection<?> children = self.treeWorkspace.getChildren(oldFile);
+ Iterator<?> iter = children.iterator();
+ while (iter.hasNext()) {
+ Object child = iter.next();
+ self.treeWorkspace.setParent(child, newFile);
+ }
+ //
+ // Finally remove the old subdomain
+ //
+ self.treeWorkspace.removeItem(oldFile);
+ }
+ } catch (IOException e) {
+ logger.error("Failed to rename subdomain: " + oldDir.toString() + " to: " + newDir.toString(), e);
+ }
+ }
+ }
+ });
+ editor.center();
+ UI.getCurrent().addWindow(editor);
+ }
+
+ protected void deleteSubDomain(final File subdomain) {
+ String message = "Are you sure you want to delete subdomain\n" + subdomain.getName() + "\nThis will remove <B>ALL</B> of its subdomains and policy files.";
+ ConfirmDialog dialog = ConfirmDialog.getFactory().create("Confirm SubDomain Deletion", message, "Delete", "Cancel");
+ dialog.setContentMode(ContentMode.HTML);
+ dialog.show(getUI(), new ConfirmDialog.Listener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void onClose(ConfirmDialog dialog) {
+ if (dialog.isConfirmed()) {
+ //
+ // Iterate the subdomain
+ //
+ try {
+ Files.walkFileTree(Paths.get(subdomain.getAbsolutePath()), new SimpleFileVisitor<Path>() {
+ @Override
+ public FileVisitResult visitFile(Path deleteFile, BasicFileAttributes attrs)
+ throws IOException {
+ try {
+ boolean removeFromTree = deleteFile.getFileName().toString().endsWith(".xml");
+ Files.delete(deleteFile);
+ if (removeFromTree) {
+ self.treeWorkspace.removeItem(deleteFile.toFile());
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("Deleted file: " + deleteFile.toString());
+ }
+ } catch (IOException e) {
+ logger.error("Failed to delete file: " + deleteFile.toString(), e);
+ return FileVisitResult.TERMINATE;
+ }
+ return super.visitFile(deleteFile, attrs);
+ }
+
+ @Override
+ public FileVisitResult postVisitDirectory(Path dir, IOException exc)
+ throws IOException {
+ try {
+ Files.delete(dir);
+ self.treeWorkspace.removeItem(dir.toFile());
+ if (logger.isDebugEnabled()) {
+ logger.debug("Deleted dir: " + dir.toString());
+ }
+ } catch (IOException e) {
+ logger.error("Failed to delete directory: " + dir.toString(), e);
+ return FileVisitResult.TERMINATE;
+ }
+ return super.postVisitDirectory(dir, exc);
+ }
+
+ });
+ } catch (IOException e) {
+ logger.error("Failed to walk subdomain: " + subdomain.getAbsolutePath(), e);
+ }
+ }
+ }
+
+ }, true);
+
+ }
+
+ protected void createPolicy(final File parentDirectory) {
+ //
+ // Construct our parameters
+ //
+ Path parent = Paths.get(parentDirectory.getAbsolutePath());
+ Path newFile = this.getNextFilename(parent, "Policy");
+ //
+ // Run the window
+ //
+ this.runPolicyWindow("Create New Policy", parent, newFile, null, null);
+ }
+
+ protected void renamePolicy(final File policy) {
+ //
+ // Run the rename window
+ //
+ final RenamePolicyFileWindow window = new RenamePolicyFileWindow(policy.getName());
+ window.setCaption("Rename Policy");
+ window.setModal(true);
+ window.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent event) {
+ String newFilename = window.getNewFilename();
+ if (newFilename == null) {
+ //
+ // User cancelled
+ //
+ return;
+ }
+ Path newPolicy = Paths.get(policy.getParent(), newFilename);
+ if (Files.exists(newPolicy)) {
+ Notification.show("Cannot rename to an existing file", Notification.Type.ERROR_MESSAGE);
+ return;
+ }
+ try {
+ if (policy.renameTo(newPolicy.toFile()) == false) {
+ throw new Exception("No known error, rename failed");
+ }
+ self.treeContainer.updateItem(newPolicy.getParent().toFile());
+ } catch (Exception e) {
+ Notification.show("Failed to rename file: " + e.getLocalizedMessage());
+ }
+ }
+ });
+ window.center();
+ UI.getCurrent().addWindow(window);
+ }
+
+ protected void clonePolicy(final File policy) {
+ //
+ // Figure out a new name for the cloned policy
+ //
+ Path policyClone = Paths.get(policy.getAbsolutePath());
+ Path newFile = this.getNextFilename(policyClone.getParent(), policy.getName());
+ if (newFile == null) {
+ return;
+ }
+ //
+ // Scan the policy in, replace policy ID's and rule ID's
+ //
+ Object policyData = new XACMLPolicyScanner(policyClone, new XACMLPolicyScanner.SimpleCallback() {
+
+ @Override
+ public CallbackResult onPreVisitRule(PolicyType parent, RuleType rule) {
+ rule.setRuleId(((XacmlAdminUI)getUI()).newRuleID());
+ return CallbackResult.CONTINUE;
+ }
+
+ @Override
+ public CallbackResult onPreVisitPolicySet(PolicySetType parent, PolicySetType policySet) {
+ policySet.setPolicySetId(((XacmlAdminUI)getUI()).newPolicyID());
+ policySet.setVersion("1");
+ return CallbackResult.CONTINUE;
+ }
+
+ @Override
+ public CallbackResult onPreVisitPolicy(PolicySetType parent, PolicyType policy) {
+ policy.setPolicyId(((XacmlAdminUI)getUI()).newPolicyID());
+ policy.setVersion("1");
+ return CallbackResult.CONTINUE;
+ }
+
+ }).scan();
+ //
+ // Run the window
+ //
+ this.runPolicyWindow("Clone Policy", newFile.getParent(), newFile.getFileName(), policyData, null);
+ }
+
+ protected void runPolicyWindow(String caption, final Path parentPath, final Path policyPath, final Object policyData, final Path oldPolicyFile) {
+ //
+ // Create our editor window
+ //
+ final PolicyNameEditorWindow editor = new PolicyNameEditorWindow((policyPath != null ? policyPath.getFileName().toString() : null),
+ policyData,
+ ((XacmlAdminUI)getUI()).getPolicyAlgorithms(),
+ ((XacmlAdminUI)getUI()).getRuleAlgorithms());
+ editor.setCaption(caption);
+ editor.setCloseShortcut(KeyCode.ESCAPE);
+ editor.setModal(true);
+ editor.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent event) {
+ //
+ // Did the user hit save button or esc?
+ //
+ if (editor.isSaved() == false) {
+ return;
+ }
+ final Object data = editor.getPolicyData();
+ String filename = editor.getPolicyFilename();
+ if (filename == null || data == null) {
+ logger.warn("Editor said is was saved but filename/data is null.");
+ return;
+ }
+ //
+ // Determine new path
+ //
+ final Path newPolicyPath = Paths.get(parentPath.toString(), filename);
+ //
+ // Is it ok to overwrite the new file?
+ //
+ try {
+ //
+ // Handle if we are not replacing an old file and we are overwriting
+ // an existing file.
+ //
+ if (self.isOverwritingAPolicy(newPolicyPath, oldPolicyFile) == false && Files.exists(newPolicyPath)) {
+ //
+ // Confirm they wanted to do this, and figure out
+ // new version number.
+ //
+ String message = "You are overwriting a file: " + newPolicyPath.getFileName().toString();
+ ConfirmDialog dialog = ConfirmDialog.getFactory().create("Confirm Policy File Overwriting", message, "Overwrite", "Cancel");
+ dialog.setData(false);
+ dialog.setContentMode(ContentMode.HTML);
+ dialog.setModal(true);
+ dialog.show(getUI(), new ConfirmDialog.Listener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void onClose(ConfirmDialog dialog) {
+ if (dialog.isConfirmed()) {
+ //
+ // Yep the user wants to overwrite it
+ //
+ self.savePolicy(newPolicyPath, data, oldPolicyFile);
+ //
+ // Open it for editing
+ //
+ self.openPolicyTab(newPolicyPath.toFile(), false);
+ }
+ }
+
+ }, true);
+ //
+ // Exit out of this thread
+ //
+ return;
+ }
+ } catch (Exception e) {
+ logger.error(e);
+ return;
+ }
+ //
+ // Save it off
+ //
+ self.savePolicy(newPolicyPath, data, oldPolicyFile);
+ //
+ // Open it for editing
+ //
+ self.openPolicyTab(newPolicyPath.toFile(), false);
+ }
+ });
+ editor.center();
+ UI.getCurrent().addWindow(editor);
+ }
+
+ protected Path getNextFilename(Path parent, String filename) {
+ filename = FilenameUtils.removeExtension(filename);
+ Path newFile = null;
+ int i = 0;
+ while (true) {
+ newFile = Paths.get(parent.toString(), String.format("%s(%02d)", filename, i++) + ".xml");
+ if (Files.notExists(newFile)) {
+ return newFile;
+ }
+ if (i == 100) {
+ logger.error("Could not construct a new name for cloned policy.");
+ return null;
+ }
+ }
+
+ }
+
+ protected boolean isOverwritingAPolicy(Path newPolicyPath, Path oldPolicyPath) throws Exception {
+ //
+ // Check to see if we were editing an existing file. Then check if the
+ // new file actually exists. Then check if we are overwriting the original old file
+ //
+ if (oldPolicyPath != null && Files.exists(newPolicyPath) && Files.isSameFile(newPolicyPath, oldPolicyPath)) {
+ //
+ // Yes its the same, overwriting it is expected.
+ //
+ logger.info("isOverwritingAPolicy");
+ return true;
+ }
+ return false;
+ }
+
+ protected void savePolicy(final Path newPolicyPath, final Object policyData, Path oldPolicyPath) {
+ //
+ // Are they overwriting another policy?
+ //
+ String version = "1.0";
+ boolean delete = false;
+ if (oldPolicyPath != null) {
+ //
+ // This policy name was being edited. Is it still the same?
+ //
+ try {
+ delete = true;
+ if (Files.exists(newPolicyPath) && Files.isSameFile(newPolicyPath, oldPolicyPath)) {
+ delete = false;
+ }
+ } catch (Exception e) {
+ logger.error("Could not determine if same file", e);
+ return;
+ }
+ logger.info("Deleting old file: " + delete);
+ }
+ //
+ // Are we now overwriting another file?
+ //
+ if (Files.exists(newPolicyPath)) {
+ //
+ // Yes
+ //
+ logger.info("Overwriting file");
+ //
+ // Overwrite is happening. Bump the version (IF WE CAN)
+ //
+//TODO - What if user wants to change something other than the last number? For example, changing 1.5.23 to 2.0.0.
+//TODO We need a mechanism that allows the user to specify the new policy version (disallowing backtracking) if they desire
+//TODO and get that new number (if any) passed down to here. This code then becomes the "then" branch of "If new version has been specified..."
+ try {
+ int[] versionArray = StdPDPPolicy.versionStringToArray(XACMLPolicyScanner.getVersion(newPolicyPath));
+ // increment the right-most digit
+ versionArray[versionArray.length - 1]++;
+ version = StdPDPPolicy.versionArrayToString(versionArray);
+ } catch (NumberFormatException | IOException e) {
+ try {
+ logger.warn("Previous version '" + XACMLPolicyScanner.getVersion(newPolicyPath) + "' not a series of itegers");
+ } catch (IOException e1) {
+ logger.error("could not get previous version");
+ }
+//TODO - This may not be wise since the intent is to increase the version number. Perhaps we should abort this an go back to the user?
+ version = "1.0";
+ }
+ if (policyData instanceof PolicySetType) {
+ ((PolicySetType) policyData).setVersion(version);
+ } else if (policyData instanceof PolicyType) {
+ ((PolicyType) policyData).setVersion(version);
+ }
+ } else {
+ //
+ // Nope, a completely new file
+ //
+ logger.info("New file");
+ }
+ //
+ // Is the root a PolicySet or Policy?
+ //
+ Path finalPolicyPath;
+ if (policyData instanceof PolicySetType) {
+ //
+ // Write it out
+ //
+ finalPolicyPath = XACMLPolicyWriter.writePolicyFile(newPolicyPath, (PolicySetType) policyData);
+ } else if (policyData instanceof PolicyType) {
+ //
+ // Write it out
+ //
+ finalPolicyPath = XACMLPolicyWriter.writePolicyFile(newPolicyPath, (PolicyType) policyData);
+ } else {
+ logger.error("Unknown data type sent back.");
+ return;
+ }
+ //
+ // Did it get written?
+ //
+ if (finalPolicyPath == null || ! Files.exists(finalPolicyPath)) {
+ logger.error("Failed to write policy file.");
+ return;
+ }
+ //
+ // Add it into our tree
+ //
+ this.addPolicyFileToTree(finalPolicyPath.getParent().toFile(), finalPolicyPath.toFile());
+ //
+ // Do we need to delete the old file?
+ //
+ if (oldPolicyPath != null && delete) {
+ try {
+ Files.delete(oldPolicyPath);
+ } catch (Exception e) {
+ logger.error("Failed to delete old policy", e);
+ }
+ if (self.treeWorkspace.removeItem(oldPolicyPath.toFile()) == false) {
+ logger.warn("Failed to remove old policy path");
+ }
+ }
+ }
+
+ protected void deletePolicy(final File policy) {
+ String message = "Are you sure you want to delete policy: " + policy.getName();
+ ConfirmDialog dialog = ConfirmDialog.getFactory().create("Confirm Policy File Deletion", message, "Delete", "Cancel");
+ dialog.setContentMode(ContentMode.HTML);
+ dialog.show(getUI(), new ConfirmDialog.Listener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void onClose(ConfirmDialog dialog) {
+ if (dialog.isConfirmed() && policy.delete()) {
+ self.treeWorkspace.removeItem(policy);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Deleted file: " + policy.toString());
+ }
+ }
+ }
+
+ }, true);
+
+ }
+
+ protected void importPolicy(final File domain) {
+ //
+ // Get the current domain
+ //
+ if (! domain.isDirectory()) {
+ logger.error("Table must have a directory selected to import the file.");
+ return;
+ }
+ //
+ // Create the upload window
+ //
+ final PolicyUploadWindow upload = new PolicyUploadWindow(Paths.get(domain.toURI()));
+ upload.setCaption("Import Xacml 3.0 Policy File");
+ upload.setCloseShortcut(KeyCode.ESCAPE);
+ upload.setModal(true);
+ upload.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Was it successful?
+ //
+ Path newFile = upload.getUploadedFile();
+ if (newFile == null) {
+ return;
+ }
+ //
+ // Add it
+ //
+ self.addPolicyFileToTree(domain, newFile.toFile());
+ //
+ // Are we importing anything in the policy file?
+ //
+ boolean importAttributes = upload.importAttributes();
+ boolean importObligations = upload.importObligations();
+ boolean importAdvice = upload.importAdvice();
+ if (importAttributes || importObligations || importAdvice) {
+ //
+ // Create our importer
+ //
+ XACMLPolicyImporter importer = new XACMLPolicyImporter();
+ importer.setImportAttributes(importAttributes);
+ importer.setImportObligations(importObligations);
+ importer.setImportAdvice(importAdvice);
+ importer.setIgnoreStandardAttributes(upload.ignoreStandard());
+ //
+ // Yes load and scan the policy
+ //
+ new XACMLPolicyScanner(newFile, importer).scan();
+ }
+ }
+ });
+ upload.center();
+ UI.getCurrent().addWindow(upload);
+ }
+
+ protected void addPolicyFileToTree(File domain, File file) {
+ //
+ // Add it into our tree
+ //
+ if (this.treeWorkspace.addItem(file) != null) {
+ //
+ // Make sure it has the right parent
+ //
+ this.treeWorkspace.setParent(file, domain);
+ //
+ // Select our new policy
+ //
+ self.treeWorkspace.select(file);
+ } else {
+ logger.error("Failed to add policy to workspace tree");
+ }
+ }
+
+ /*
+ protected void publishPolicy(final File policy) {
+ //
+ // Get its ID
+ //
+ Item item = this.treeContainer.getItem(policy);
+ if (item == null) {
+ logger.error("Failed to get the item");
+ return;
+ }
+ Object policyData = item.getItemProperty("Data");
+ if (policyData == null) {
+ logger.error("Failed to get item data property.");
+ return;
+ }
+ String fullId = XACMLPolicyScanner.getID(policyData);
+ String version = XACMLPolicyScanner.getVersion(policyData);
+ if (fullId == null || version == null) {
+ logger.error("Failed to get policy Id");
+ return;
+ }
+ List<String> ids = Lists.newArrayList(Splitter.on(':').split(fullId));
+ if (ids.isEmpty()) {
+ logger.error("Couldn't parse policy Id");
+ return;
+ }
+ final String id = ids.get(ids.size() - 1) + "." + version;
+ //
+ // Is there only one group?
+ //
+ PAPEngine engine = ((XacmlAdminUI)getUI()).getPAPEngine();
+ Set<PDPGroup> groups;
+ PDPGroup defaultGroup;
+ try {
+ groups = engine.getPDPGroups();
+ } catch (PAPException e) {
+ String message = "Unable to retrieve Groups from server: " + e;
+ logger.error(message, e);
+ throw new RuntimeException(message);
+ }
+ try {
+ defaultGroup = engine.getDefaultGroup();
+ } catch (PAPException e) {
+ String message = "Unable to retrieve Default Group from server: " + e;
+ logger.error(message, e);
+ throw new RuntimeException(message);
+ }
+ if (groups.size() == 1) {
+ this.doPublish(id, policy, defaultGroup);
+ return;
+ }
+ //
+ // Have user select a group
+ //
+ final SelectPDPGroupWindow window = new SelectPDPGroupWindow(groups, "Select PDP Group to publish in");
+ window.setCaption("Select PDP Group");
+ window.setCloseShortcut(KeyCode.ESCAPE);
+ window.setModal(true);
+ window.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent event) {
+ PDPGroup group = window.selectedGroup();
+ if (group != null) {
+ self.doPublish(id, policy, group);
+ }
+ }
+ });
+ window.center();
+ UI.getCurrent().addWindow(window);
+
+ }
+
+ protected void doPublish(String id, File policy, PDPGroup group) {
+ //
+ // The policy status must be up-to-date
+ //
+ // TODO
+
+ //
+ // TODO - get list of referenced policies and publish
+ // them first.
+ //
+
+ //
+ // Publish the policy
+ //
+
+ PAPEngine engine = ((XacmlAdminUI)getUI()).getPAPEngine();
+ try (InputStream is = new FileInputStream(policy)) {
+ engine.publishPolicy(id, policy.getName(), true, is, group);
+ } catch (PAPException | IOException e) {
+ logger.error("Failed to publish policy: ", e);
+ }
+ }
+ */
+
+ protected void pushChanges(final File target) {
+ try {
+ //
+ // Grab our working repository
+ //
+ Path repoPath = ((XacmlAdminUI)getUI()).getUserGitPath();
+ final Git git = Git.open(repoPath.toFile());
+ //
+ // Get our status
+ //
+ final String base;
+ Status status;
+ if (target == null) {
+ base = ".";
+ } else {
+ Path relativePath = repoPath.relativize(Paths.get(target.getPath()));
+ base = relativePath.toString();
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("Status on base: " + base);
+ }
+ status = git.status().addPath(base).call();
+ //
+ // Check if its clean
+ //
+ if (status.isClean()) {
+ //
+ // Its clean
+ //
+ AdminNotification.warn(target.getName() + " is clean!");
+ return;
+ }
+ //
+ // Create the window
+ //
+ final GitPushWindow window = new GitPushWindow(git, target, status);
+ window.setCaption("Push Changes");
+ window.setModal(true);
+ window.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ if (window.isSaved() == false) {
+ return;
+ }
+ try {
+ //
+ // Needs to be added first
+ //
+ DirCache cache = git.add().addFilepattern(base).call();
+ for (int i = 0; i < cache.getEntryCount(); i++) {
+ DirCacheEntry entry = cache.getEntry(i);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Entry: " + entry);
+ }
+ }
+ //
+ // Next they need to be committed
+ //
+ RevCommit rev = git.commit().setMessage(window.getComment()).call();
+ if (logger.isDebugEnabled()) {
+ logger.debug("RevCommit: " + rev);
+ }
+ //
+ // Now we can push changes to the Git repository
+ //
+ Iterable<PushResult> results = git.push().call();
+ for (PushResult result : results) {
+ logger.info(result);
+ }
+ //
+ // Have the container fire an item set change notification
+ //
+ self.treeContainer.updateItem(target);
+ } catch (NoWorkTreeException | GitAPIException e1) {
+ logger.error(e);
+ AdminNotification.error("Exception occurred while trying to push: " + e1);
+ }
+ }
+
+ });
+ window.center();
+ UI.getCurrent().addWindow(window);
+ } catch (IOException | GitAPIException e) {
+ logger.error(e);
+ AdminNotification.error("Exception occurred while trying to get status: " + e);
+ }
+ }
+
+ protected void synchronizeRepository() {
+ final GitSynchronizeWindow window = new GitSynchronizeWindow();
+ window.setCaption("Synchronize with server repository?");
+ window.setModal(true);
+ window.center();
+ UI.getCurrent().addWindow(window);
+ }
+
+ protected void exportRepository() {
+ this.buttonExport.click();
+ }
+
+ @Override
+ public String getFilename() {
+ return "Repository.tgz";
+ }
+
+ @Override
+ public InputStream getStream() {
+ //
+ // Grab our working repository
+ //
+ final Path repoPath = ((XacmlAdminUI)getUI()).getUserGitPath();
+ Path workspacePath = ((XacmlAdminUI)getUI()).getUserWorkspace();
+ final Path tarFile = Paths.get(workspacePath.toString(), "Repository.tgz");
+
+ try (OutputStream os = Files.newOutputStream(tarFile)) {
+ try (GzipCompressorOutputStream gzOut = new GzipCompressorOutputStream(os)) {
+ try (TarArchiveOutputStream tarOut = new TarArchiveOutputStream(gzOut)) {
+
+ tarOut.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
+
+ Files.walkFileTree(repoPath, new SimpleFileVisitor<Path>() {
+
+ @Override
+ public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
+ if (dir.getFileName().toString().startsWith(".git")) {
+ return FileVisitResult.SKIP_SUBTREE;
+ }
+ Path relative = repoPath.relativize(dir);
+ if (relative.toString().isEmpty()) {
+ return super.preVisitDirectory(dir, attrs);
+ }
+ TarArchiveEntry entry = new TarArchiveEntry(relative.toFile());
+ tarOut.putArchiveEntry(entry);
+ tarOut.closeArchiveEntry();
+ return super.preVisitDirectory(dir, attrs);
+ }
+
+ @Override
+ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
+ if (file.getFileName().toString().endsWith(".xml") == false) {
+ return super.visitFile(file, attrs);
+ }
+ Path relative = repoPath.relativize(file);
+ TarArchiveEntry entry = new TarArchiveEntry(relative.toFile());
+ entry.setSize(Files.size(file));
+ tarOut.putArchiveEntry(entry);
+ try {
+ IOUtils.copy(Files.newInputStream(file), tarOut);
+ } catch (IOException e) {
+ logger.error(e);
+ }
+ tarOut.closeArchiveEntry();
+ return super.visitFile(file, attrs);
+ }
+
+ });
+ tarOut.finish();
+ }
+ }
+ } catch (IOException e) {
+ logger.error(e);
+ }
+ try {
+ return Files.newInputStream(tarFile);
+ } catch (IOException e) {
+ logger.error(e);
+ }
+ return null;
+ }
+
+ protected void openPolicyTab(File policy, boolean readOnly) {
+ //
+ // Sanity check
+ //
+ assert policy != null;
+ assert policy.isFile();
+ if (policy == null || ! policy.isFile()) {
+ throw new IllegalArgumentException("You must specify a file.");
+ }
+ Status status;
+ Path relativePath;
+ String base;
+ try {
+ //
+ // Grab our working repository
+ //
+ Path repoPath = ((XacmlAdminUI)getUI()).getUserGitPath();
+ final Git git = Git.open(repoPath.toFile());
+ //
+ // Get our status
+ //
+ relativePath = repoPath.relativize(Paths.get(policy.getPath()));
+ base = relativePath.toString();
+ if (logger.isDebugEnabled()) {
+ logger.debug("Status on base: " + base);
+ }
+ status = git.status().addPath(base).call();
+ } catch (NoWorkTreeException | IOException | GitAPIException e) {
+ logger.error("Failed to get status on " + policy + " " + e);
+ AdminNotification.error("Could not get Git status on the file.");
+ return;
+ }
+ //
+ // Check if its clean
+ //
+ if (status.isClean() == false) {
+ //
+ // Check if its conflicting
+ //
+ for (String conflict : status.getConflicting()) {
+ if (conflict.equals(base)) {
+ //
+ // Yes - we won't be able to edit it
+ //
+ AdminNotification.error("Policy has conflicts with master, please synchronize the repository.");
+ return;
+ }
+ }
+ }
+ //
+ // Check to see if there already is a tab open
+ //
+ Iterator<Component> iter = self.tabSheet.iterator();
+ while (iter.hasNext()) {
+ Component c = iter.next();
+ if (c instanceof PolicyEditor) {
+ Object data = ((PolicyEditor) c).getData();
+ if (data != null && data instanceof File && ((File)data).equals(policy)) {
+ self.tabSheet.setSelectedTab(c);
+ return;
+ }
+ }
+ }
+ //
+ // No tab is open, create a new one
+ //
+ PolicyEditor editor = null;
+ try {
+ editor = new PolicyEditor(policy, this.treeContainer, readOnly);
+ } catch (IOException e) {
+ logger.error("Failed to open policy");
+ editor = null;
+ }
+ if (editor != null) {
+ editor.setWidth("100%");
+ Tab tab = self.tabSheet.addTab(editor);
+ editor.setTab(tab);
+ tab.setClosable(true);
+
+ self.tabSheet.setSelectedTab(editor);
+ } else {
+ AdminNotification.error("The Policy File is not a Xacml 3.0 policy.");
+ }
+ }
+
+ @Override
+ public void drop(DragAndDropEvent event) {
+ Transferable t = event.getTransferable();
+ Component source = t.getSourceComponent();
+ if (source != this.treeWorkspace) {
+ assert false;
+ throw new IllegalArgumentException();
+ }
+ TableTransferable tt = (TableTransferable) t;
+ File sourceFile = (File) tt.getItemId();
+
+ AbstractSelectTargetDetails target = (AbstractSelectTargetDetails)event.getTargetDetails();
+ File targetFile = (File) target.getItemIdOver();
+
+ if (sourceFile.isFile() && targetFile != null && targetFile.isDirectory()) {
+ //
+ // Construct destination filename
+ //
+ Path dest = targetFile.toPath().resolve(sourceFile.getName());
+ //
+ // Check if the target domain exists
+ //
+ if (Files.exists(dest)) {
+ //
+ // Prompt the user
+ //
+ Notification.show("A policy file with that name already exists in that directory.", Notification.Type.ERROR_MESSAGE);
+ } else {
+ //
+ // Go ahead and rename it
+ //
+ this.renamePolicyFile(sourceFile, dest.toFile(), targetFile);
+ }
+ }
+ }
+
+ protected void renamePolicyFile(File sourceFile, File dest, File parent) {
+ try {
+ if (sourceFile.renameTo(dest)) {
+ this.treeContainer.setParent(sourceFile, parent);
+ this.treeContainer.updateItem(parent);
+ }
+ } catch (Exception e) {
+ String error = "Failed to rename " + sourceFile + " to: " + dest + System.lineSeparator() + e.getLocalizedMessage();
+ logger.error(error);
+ AdminNotification.error(error);
+ }
+ }
+
+ @Override
+ public AcceptCriterion getAcceptCriterion() {
+ return AcceptAll.get();
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("100%");
+ mainLayout.setHeight("100%");
+ mainLayout.setMargin(false);
+
+ // top-level component properties
+ setWidth("100.0%");
+ setHeight("100.0%");
+
+ // horizontalSplitPanel
+ horizontalSplitPanel = buildHorizontalSplitPanel();
+ mainLayout.addComponent(horizontalSplitPanel);
+ mainLayout.setExpandRatio(horizontalSplitPanel, 1.0f);
+
+ return mainLayout;
+ }
+
+ @AutoGenerated
+ private HorizontalSplitPanel buildHorizontalSplitPanel() {
+ // common part: create layout
+ horizontalSplitPanel = new HorizontalSplitPanel();
+ horizontalSplitPanel.setImmediate(false);
+ horizontalSplitPanel.setWidth("100.0%");
+ horizontalSplitPanel.setHeight("100.0%");
+
+ // verticalLayoutLeftPanel
+ verticalLayoutLeftPanel = buildVerticalLayoutLeftPanel();
+ horizontalSplitPanel.addComponent(verticalLayoutLeftPanel);
+
+ // verticalLayoutRightPanel
+ verticalLayoutRightPanel = buildVerticalLayoutRightPanel();
+ horizontalSplitPanel.addComponent(verticalLayoutRightPanel);
+
+ return horizontalSplitPanel;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildVerticalLayoutLeftPanel() {
+ // common part: create layout
+ verticalLayoutLeftPanel = new VerticalLayout();
+ verticalLayoutLeftPanel.setImmediate(false);
+ verticalLayoutLeftPanel.setWidth("100.0%");
+ verticalLayoutLeftPanel.setHeight("100.0%");
+ verticalLayoutLeftPanel.setMargin(true);
+ verticalLayoutLeftPanel.setSpacing(true);
+
+ // horizontalLayoutLeftToolbar
+ horizontalLayoutLeftToolbar = buildHorizontalLayoutLeftToolbar();
+ verticalLayoutLeftPanel.addComponent(horizontalLayoutLeftToolbar);
+
+ // treeWorkspace
+ treeWorkspace = new TreeTable();
+ treeWorkspace.setImmediate(true);
+ treeWorkspace.setWidth("100.0%");
+ treeWorkspace.setHeight("100.0%");
+ verticalLayoutLeftPanel.addComponent(treeWorkspace);
+ verticalLayoutLeftPanel.setExpandRatio(treeWorkspace, 1.0f);
+
+ return verticalLayoutLeftPanel;
+ }
+
+ @AutoGenerated
+ private HorizontalLayout buildHorizontalLayoutLeftToolbar() {
+ // common part: create layout
+ horizontalLayoutLeftToolbar = new HorizontalLayout();
+ horizontalLayoutLeftToolbar.setImmediate(false);
+ horizontalLayoutLeftToolbar.setWidth("100.0%");
+ horizontalLayoutLeftToolbar.setHeight("-1px");
+ horizontalLayoutLeftToolbar.setMargin(false);
+ horizontalLayoutLeftToolbar.setSpacing(true);
+
+ // horizontalLayoutLeftToolbarLeft
+ horizontalLayoutLeftToolbarLeft = buildHorizontalLayoutLeftToolbarLeft();
+ horizontalLayoutLeftToolbar
+ .addComponent(horizontalLayoutLeftToolbarLeft);
+
+ // buttonLeft
+ buttonLeft = new Button();
+ buttonLeft.setCaption("<<");
+ buttonLeft.setImmediate(true);
+ buttonLeft.setDescription("Minimize left panel.");
+ buttonLeft.setWidth("-1px");
+ buttonLeft.setHeight("-1px");
+ horizontalLayoutLeftToolbar.addComponent(buttonLeft);
+ horizontalLayoutLeftToolbar.setComponentAlignment(buttonLeft,
+ new Alignment(34));
+
+ return horizontalLayoutLeftToolbar;
+ }
+
+ @AutoGenerated
+ private HorizontalLayout buildHorizontalLayoutLeftToolbarLeft() {
+ // common part: create layout
+ horizontalLayoutLeftToolbarLeft = new HorizontalLayout();
+ horizontalLayoutLeftToolbarLeft.setImmediate(false);
+ horizontalLayoutLeftToolbarLeft.setWidth("-1px");
+ horizontalLayoutLeftToolbarLeft.setHeight("-1px");
+ horizontalLayoutLeftToolbarLeft.setMargin(false);
+ horizontalLayoutLeftToolbarLeft.setSpacing(true);
+
+ // buttonSynchronize
+ buttonSynchronize = new Button();
+ buttonSynchronize.setCaption("Synchronize Repository");
+ buttonSynchronize.setImmediate(true);
+ buttonSynchronize
+ .setDescription("Synchronize local repository with main branch.");
+ buttonSynchronize.setWidth("-1px");
+ buttonSynchronize.setHeight("-1px");
+ horizontalLayoutLeftToolbarLeft.addComponent(buttonSynchronize);
+
+ // buttonExport
+ buttonExport = new Button();
+ buttonExport.setCaption("Export Workspace");
+ buttonExport.setImmediate(true);
+ buttonExport.setDescription("Export your workspace to your local drive.");
+ buttonExport.setWidth("-1px");
+ buttonExport.setHeight("-1px");
+ horizontalLayoutLeftToolbarLeft.addComponent(buttonExport);
+
+ return horizontalLayoutLeftToolbarLeft;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildVerticalLayoutRightPanel() {
+ // common part: create layout
+ verticalLayoutRightPanel = new VerticalLayout();
+ verticalLayoutRightPanel.setImmediate(false);
+ verticalLayoutRightPanel.setWidth("100.0%");
+ verticalLayoutRightPanel.setHeight("-1px");
+ verticalLayoutRightPanel.setMargin(true);
+ verticalLayoutRightPanel.setSpacing(true);
+
+ // horizontalLayoutRightToolbar
+ horizontalLayoutRightToolbar = buildHorizontalLayoutRightToolbar();
+ verticalLayoutRightPanel.addComponent(horizontalLayoutRightToolbar);
+
+ // tabSheet
+ tabSheet = new TabSheet();
+ tabSheet.setImmediate(true);
+ tabSheet.setWidth("100.0%");
+ tabSheet.setHeight("-1px");
+ verticalLayoutRightPanel.addComponent(tabSheet);
+ verticalLayoutRightPanel.setExpandRatio(tabSheet, 1.0f);
+
+ return verticalLayoutRightPanel;
+ }
+
+ @AutoGenerated
+ private HorizontalLayout buildHorizontalLayoutRightToolbar() {
+ // common part: create layout
+ horizontalLayoutRightToolbar = new HorizontalLayout();
+ horizontalLayoutRightToolbar.setImmediate(false);
+ horizontalLayoutRightToolbar.setWidth("100.0%");
+ horizontalLayoutRightToolbar.setHeight("-1px");
+ horizontalLayoutRightToolbar.setMargin(false);
+ horizontalLayoutRightToolbar.setSpacing(true);
+
+ // buttonRight
+ buttonRight = new Button();
+ buttonRight.setCaption(">>");
+ buttonRight.setImmediate(true);
+ buttonRight.setDescription("Restore left panel.");
+ buttonRight.setWidth("-1px");
+ buttonRight.setHeight("-1px");
+ horizontalLayoutRightToolbar.addComponent(buttonRight);
+
+ return horizontalLayoutRightToolbar;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/Simulator.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/Simulator.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/Simulator.java
new file mode 100644
index 0000000..c554568
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/Simulator.java
@@ -0,0 +1,69 @@
+/*
+ * 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.xacml.admin.components;
+
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.annotations.Theme;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.ui.AbsoluteLayout;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.UI;
+
+public class Simulator extends CustomComponent {
+
+ @AutoGenerated
+ private AbsoluteLayout mainLayout;
+
+ private static final long serialVersionUID = 1L;
+
+ @Theme("xacml_pap_admin")
+ public static class SimulatorUI extends UI {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void init(VaadinRequest request) {
+ // TODO Auto-generated method stub
+
+ }
+
+ }
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public Simulator() {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+
+ // TODO add user code here
+ }
+
+ @AutoGenerated
+ private void buildMainLayout() {
+ // the main layout and components will be created here
+ mainLayout = new AbsoluteLayout();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/UserManagement.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/UserManagement.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/UserManagement.java
new file mode 100644
index 0000000..a883dec
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/UserManagement.java
@@ -0,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.xacml.admin.components;
+
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.VerticalLayout;
+
+public class UserManagement extends CustomComponent {
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Table tableUsers;
+ @AutoGenerated
+ private HorizontalLayout horizontalLayoutToolbar;
+ @AutoGenerated
+ private Button buttonRemove;
+ @AutoGenerated
+ private Button buttonAdd;
+ private static final long serialVersionUID = 1L;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public UserManagement() {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+
+ // TODO add user code here
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("100%");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(false);
+
+ // top-level component properties
+ setWidth("100.0%");
+ setHeight("-1px");
+
+ // horizontalLayoutToolbar
+ horizontalLayoutToolbar = buildHorizontalLayoutToolbar();
+ mainLayout.addComponent(horizontalLayoutToolbar);
+
+ // tableUsers
+ tableUsers = new Table();
+ tableUsers.setImmediate(false);
+ tableUsers.setWidth("100.0%");
+ tableUsers.setHeight("-1px");
+ mainLayout.addComponent(tableUsers);
+
+ return mainLayout;
+ }
+
+ @AutoGenerated
+ private HorizontalLayout buildHorizontalLayoutToolbar() {
+ // common part: create layout
+ horizontalLayoutToolbar = new HorizontalLayout();
+ horizontalLayoutToolbar.setImmediate(false);
+ horizontalLayoutToolbar.setWidth("-1px");
+ horizontalLayoutToolbar.setHeight("-1px");
+ horizontalLayoutToolbar.setMargin(true);
+ horizontalLayoutToolbar.setSpacing(true);
+
+ // buttonAdd
+ buttonAdd = new Button();
+ buttonAdd.setCaption("Add User");
+ buttonAdd.setImmediate(false);
+ buttonAdd.setWidth("-1px");
+ buttonAdd.setHeight("-1px");
+ horizontalLayoutToolbar.addComponent(buttonAdd);
+
+ // buttonRemove
+ buttonRemove = new Button();
+ buttonRemove.setCaption("Remove User");
+ buttonRemove.setImmediate(false);
+ buttonRemove.setWidth("-1px");
+ buttonRemove.setHeight("-1px");
+ horizontalLayoutToolbar.addComponent(buttonRemove);
+
+ return horizontalLayoutToolbar;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/package-info.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/package-info.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/package-info.java
new file mode 100644
index 0000000..947702e
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/package-info.java
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ *
+ */
+
+/**
+ *
+ */
+/**
+ * @author pameladragosh
+ *
+ */
+package org.apache.openaz.xacml.admin.components;
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/CategoryConverter.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/CategoryConverter.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/CategoryConverter.java
new file mode 100644
index 0000000..4229a4e
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/CategoryConverter.java
@@ -0,0 +1,71 @@
+/*
+ * 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.xacml.admin.converters;
+
+import java.util.Locale;
+
+import org.apache.openaz.xacml.admin.jpa.Category;
+import org.apache.openaz.xacml.api.Identifier;
+import com.vaadin.data.util.converter.Converter;
+
+public class CategoryConverter implements Converter<Object, Category> {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Category convertToModel(Object value,
+ Class<? extends Category> targetType, Locale locale)
+ throws Converter.ConversionException {
+ Category category = new Category();
+ if (value == null) {
+ return category;
+ }
+ if (value instanceof Identifier) {
+ category.setXacmlId(((Identifier)value).stringValue());
+ } else {
+ category.setXacmlId(value.toString());
+ }
+ return category;
+ }
+
+ @Override
+ public Object convertToPresentation(Category value,
+ Class<? extends Object> targetType, Locale locale)
+ throws Converter.ConversionException {
+ if (targetType.getName().equals(String.class.getName())) {
+ return value.getXacmlId();
+ }
+ if (targetType.getName().equals(Identifier.class.getName())) {
+ return value.getIdentifer();
+ }
+ return value.getIdentifer();
+ }
+
+ @Override
+ public Class<Category> getModelType() {
+ return Category.class;
+ }
+
+ @Override
+ public Class<Object> getPresentationType() {
+ return Object.class;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/ConstraintTypeConverter.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/ConstraintTypeConverter.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/ConstraintTypeConverter.java
new file mode 100644
index 0000000..c6705ca
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/ConstraintTypeConverter.java
@@ -0,0 +1,79 @@
+/*
+ * 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.xacml.admin.converters;
+
+import java.util.Locale;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.jpa.ConstraintType;
+import com.vaadin.data.util.converter.Converter;
+
+public class ConstraintTypeConverter implements Converter<Object, ConstraintType> {
+ private static final long serialVersionUID = 1L;
+ private static final Log logger = LogFactory.getLog(ConstraintTypeConverter.class);
+
+ @Override
+ public ConstraintType convertToModel(Object value,
+ Class<? extends ConstraintType> targetType, Locale locale)
+ throws Converter.ConversionException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("convertToModel:" + value + " target " + targetType);
+ }
+ ConstraintType constraintValue = new ConstraintType();
+ if (value == null) {
+ return constraintValue;
+ }
+ // PLD TODO??
+ return constraintValue;
+ }
+
+ @Override
+ public Object convertToPresentation(ConstraintType value,
+ Class<? extends Object> targetType, Locale locale)
+ throws Converter.ConversionException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("convertToPresentation:" + value + " target " + targetType);
+ }
+ if (value == null) {
+ return null;
+ }
+ if (targetType.isAssignableFrom(String.class)) {
+ return value.getConstraintType();
+ }
+ if (targetType.isInstance(Integer.class)) {
+ return value.getId();
+ }
+ return null;
+ }
+
+ @Override
+ public Class<ConstraintType> getModelType() {
+ return ConstraintType.class;
+ }
+
+ @Override
+ public Class<Object> getPresentationType() {
+ return Object.class;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/ConstraintValueConverter.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/ConstraintValueConverter.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/ConstraintValueConverter.java
new file mode 100644
index 0000000..03c76be
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/ConstraintValueConverter.java
@@ -0,0 +1,73 @@
+/*
+ * 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.xacml.admin.converters;
+
+import java.util.Locale;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.jpa.ConstraintValue;
+import com.vaadin.data.util.converter.Converter;
+
+public class ConstraintValueConverter implements Converter<Object, ConstraintValue> {
+ private static final long serialVersionUID = 1L;
+ private static final Log logger = LogFactory.getLog(ConstraintValueConverter.class);
+
+ @Override
+ public ConstraintValue convertToModel(Object value,
+ Class<? extends ConstraintValue> targetType, Locale locale)
+ throws Converter.ConversionException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("convertToModel:" + value + " target " + targetType);
+ }
+ ConstraintValue newValue = new ConstraintValue();
+ if (value == null) {
+ return newValue;
+ }
+ // PLD TODO?
+ return newValue;
+ }
+
+ @Override
+ public Object convertToPresentation(ConstraintValue value,
+ Class<? extends Object> targetType, Locale locale)
+ throws Converter.ConversionException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("convertToPresentation:" + value + " target " + targetType);
+ }
+ if (value == null) {
+ return null;
+ }
+ return value.getProperty();
+ }
+
+ @Override
+ public Class<ConstraintValue> getModelType() {
+ return ConstraintValue.class;
+ }
+
+ @Override
+ public Class<Object> getPresentationType() {
+ return Object.class;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/DatatypeConverter.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/DatatypeConverter.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/DatatypeConverter.java
new file mode 100644
index 0000000..8817428
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/DatatypeConverter.java
@@ -0,0 +1,76 @@
+/*
+ * 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.xacml.admin.converters;
+
+import java.util.Locale;
+
+import org.apache.openaz.xacml.admin.jpa.Datatype;
+import org.apache.openaz.xacml.api.Identifier;
+import com.vaadin.data.util.converter.Converter;
+
+public class DatatypeConverter implements Converter<Object, Datatype> {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Datatype convertToModel(Object value,
+ Class<? extends Datatype> targetType, Locale locale)
+ throws Converter.ConversionException {
+ Datatype datatype = new Datatype();
+ if (value == null) {
+ return datatype;
+ }
+ if (value instanceof Identifier) {
+ datatype.setXacmlId(((Identifier)value).stringValue());
+ } else {
+ datatype.setXacmlId(value.toString());
+ }
+ return datatype;
+ }
+
+ @Override
+ public Object convertToPresentation(Datatype value,
+ Class<? extends Object> targetType, Locale locale)
+ throws Converter.ConversionException {
+ if (value == null) {
+ return null;
+ }
+ if (targetType.isInstance(String.class) ||
+ targetType.getName().equals(String.class.getName())) {
+ return value.getXacmlId();
+ }
+ if (targetType.isInstance(Identifier.class) ||
+ targetType.getName().equals(Identifier.class.getName())) {
+ return value.getIdentifer();
+ }
+ return value.getIdentifer();
+ }
+
+ @Override
+ public Class<Datatype> getModelType() {
+ return Datatype.class;
+ }
+
+ @Override
+ public Class<Object> getPresentationType() {
+ return Object.class;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/IdentifierConverter.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/IdentifierConverter.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/IdentifierConverter.java
new file mode 100644
index 0000000..07b810d
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/IdentifierConverter.java
@@ -0,0 +1,61 @@
+/*
+ * 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.xacml.admin.converters;
+
+import java.util.Locale;
+
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.std.IdentifierImpl;
+import com.vaadin.data.util.converter.Converter;
+
+
+public class IdentifierConverter implements Converter<Object, Identifier> {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Identifier convertToModel(Object value,
+ Class<? extends Identifier> targetType, Locale locale)
+ throws Converter.ConversionException {
+ return new IdentifierImpl(value.toString());
+ }
+
+ @Override
+ public Object convertToPresentation(Identifier value,
+ Class<? extends Object> targetType, Locale locale)
+ throws Converter.ConversionException {
+ if (targetType.isInstance(String.class) ||
+ targetType.getName().equals(String.class.getName())) {
+ return value.stringValue();
+ }
+ return null;
+ }
+
+ @Override
+ public Class<Identifier> getModelType() {
+ return Identifier.class;
+ }
+
+ @Override
+ public Class<Object> getPresentationType() {
+ return Object.class;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/XacmlConverterFactory.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/XacmlConverterFactory.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/XacmlConverterFactory.java
new file mode 100644
index 0000000..32fb8bf
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/converters/XacmlConverterFactory.java
@@ -0,0 +1,83 @@
+/*
+ * 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.xacml.admin.converters;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.jpa.Category;
+import org.apache.openaz.xacml.admin.jpa.ConstraintType;
+import org.apache.openaz.xacml.admin.jpa.ConstraintValue;
+import org.apache.openaz.xacml.admin.jpa.Datatype;
+import org.apache.openaz.xacml.api.Identifier;
+import com.vaadin.data.util.converter.Converter;
+import com.vaadin.data.util.converter.DefaultConverterFactory;
+
+public class XacmlConverterFactory extends DefaultConverterFactory {
+ private static final long serialVersionUID = 1L;
+ private static final Log logger = LogFactory.getLog(XacmlConverterFactory.class);
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <PRESENTATION, MODEL> Converter<PRESENTATION, MODEL>
+ createConverter(Class<PRESENTATION> presentationType,
+ Class<MODEL> modelType) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("createConverter: " + presentationType + " from model " + modelType);
+ }
+ //
+ // Handle one particular type conversion for Categories
+ //
+ if (Category.class == modelType) {
+ return (Converter<PRESENTATION, MODEL>) new CategoryConverter();
+ }
+ //
+ // Handle one particular type conversion for Datatypes
+ //
+ if (Datatype.class == modelType) {
+ return (Converter<PRESENTATION, MODEL>) new DatatypeConverter();
+ }
+ //
+ // Handle one particular type conversion for ConstraintType
+ //
+ if (ConstraintType.class == modelType) {
+ return (Converter<PRESENTATION, MODEL>) new ConstraintTypeConverter();
+ }
+ //
+ // Handle one particular type conversion for ConstraintType
+ //
+ if (ConstraintValue.class == modelType) {
+ return (Converter<PRESENTATION, MODEL>) new ConstraintValueConverter();
+ }
+ //
+ // Handle one particular type conversion for Identifiers
+ //
+ if (Identifier.class == modelType) {
+ return (Converter<PRESENTATION, MODEL>) new IdentifierConverter();
+ }
+ //
+ // Default to the supertype
+ //
+ return super.createConverter(presentationType,
+ modelType);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/Attribute.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/Attribute.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/Attribute.java
new file mode 100644
index 0000000..84ec82a
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/Attribute.java
@@ -0,0 +1,327 @@
+/*
+ * 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.xacml.admin.jpa;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.PrePersist;
+import javax.persistence.PreUpdate;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.std.IdentifierImpl;
+
+
+/**
+ * The persistent class for the Attribute database table.
+ *
+ */
+@Entity
+@Table(name="Attribute")
+@NamedQuery(name="Attribute.findAll", query="SELECT a FROM Attribute a")
+public class Attribute implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static String ATTRIBUTE_DESIGNATOR = "Attribute Designator";
+ public static String ATTRIBUTE_SELECTOR = "Attribute Selector";
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name="id")
+ private int id;
+
+ //bi-directional many-to-one association to Category
+ @ManyToOne
+ @JoinColumn(name="constraint_type", nullable=true)
+ private ConstraintType constraintType;
+
+ @Column(name="created_by", nullable=false, length=255)
+ private String createdBy = "guest";
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name="created_date", updatable=false)
+ private Date createdDate;
+
+ @Column(name="description", nullable=true, length=2048)
+ private String description;
+
+ @Column(name="modified_by", nullable=false, length=255)
+ private String modifiedBy = "guest";
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name="modified_date", nullable=false)
+ private Date modifiedDate;
+
+ @Column(name="xacml_id", nullable=false)
+ private String xacmlId = "urn";
+
+ //bi-directional many-to-one association to ConstraintValue
+ @OneToMany(mappedBy="attribute", orphanRemoval=true, cascade=CascadeType.REMOVE)
+ private Set<ConstraintValue> constraintValues = new HashSet<ConstraintValue>();
+
+ //bi-directional many-to-one association to Category
+ @ManyToOne
+ @JoinColumn(name="category")
+ private Category categoryBean;
+
+ //bi-directional many-to-one association to Datatype
+ @ManyToOne
+ @JoinColumn(name="datatype")
+ private Datatype datatypeBean;
+
+ @Column(name="is_designator", nullable=false)
+ private char isDesignator = '1';
+
+ @Column(name="selector_path", nullable=true, length=2048)
+ private String selectorPath;
+
+ @Transient
+ private String issuer = null;
+
+ @Transient
+ private boolean mustBePresent = false;
+
+ public Attribute() {
+ }
+
+ public Attribute(String domain) {
+ this.xacmlId = domain;
+ }
+
+ public Attribute(String domain, String user) {
+ this(domain);
+ this.createdBy = user;
+ this.modifiedBy = user;
+ }
+ public Attribute(Attribute copy, String user) {
+ this(copy.getXacmlId() + ":(0)", user);
+ this.constraintType = copy.getConstraintType();
+ this.categoryBean = copy.getCategoryBean();
+ this.datatypeBean = copy.getDatatypeBean();
+ this.description = copy.getDescription();
+ for (ConstraintValue value : copy.getConstraintValues()) {
+ ConstraintValue newValue = new ConstraintValue(value);
+ newValue.setAttribute(this);
+ this.addConstraintValue(newValue);
+ }
+ }
+
+ @PrePersist
+ public void prePersist() {
+ Date date = new Date();
+ this.createdDate = date;
+ this.modifiedDate = date;
+ }
+
+ @PreUpdate
+ public void preUpdate() {
+ this.modifiedDate = new Date();
+ }
+
+ public int getId() {
+ return this.id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public ConstraintType getConstraintType() {
+ return this.constraintType;
+ }
+
+ public void setConstraintType(ConstraintType constraintType) {
+ this.constraintType = constraintType;
+ }
+
+ public String getCreatedBy() {
+ return this.createdBy;
+ }
+
+ public void setCreatedBy(String createdBy) {
+ this.createdBy = createdBy;
+ }
+
+ public Date getCreatedDate() {
+ return this.createdDate;
+ }
+
+ public void setCreatedDate(Date createdDate) {
+ this.createdDate = createdDate;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getModifiedBy() {
+ return this.modifiedBy;
+ }
+
+ public void setModifiedBy(String modifiedBy) {
+ this.modifiedBy = modifiedBy;
+ }
+
+ public Date getModifiedDate() {
+ return this.modifiedDate;
+ }
+
+ public void setModifiedDate(Date modifiedDate) {
+ this.modifiedDate = modifiedDate;
+ }
+
+ public String getXacmlId() {
+ return this.xacmlId;
+ }
+
+ @Transient
+ public Identifier getXacmlIdentifier() {
+ return new IdentifierImpl(this.xacmlId);
+ }
+
+ public void setXacmlId(String xacmlId) {
+ this.xacmlId = xacmlId;
+ }
+
+ public Set<ConstraintValue> getConstraintValues() {
+ return this.constraintValues;
+ }
+
+ public void setConstraintValues(Set<ConstraintValue> constraintValues) {
+ for (ConstraintValue value : this.constraintValues) {
+ value.setAttribute(this);
+ }
+ this.constraintValues = constraintValues;
+ }
+
+ public ConstraintValue addConstraintValue(ConstraintValue constraintValue) {
+ if (this.constraintValues == null) {
+ this.constraintValues = new HashSet<ConstraintValue>();
+ }
+ this.constraintValues.add(constraintValue);
+ constraintValue.setAttribute(this);
+
+ return constraintValue;
+ }
+
+ public ConstraintValue removeConstraintValue(ConstraintValue constraintValue) {
+ this.constraintValues.remove(constraintValue);
+ constraintValue.setAttribute(null);
+
+ return constraintValue;
+ }
+
+ public void removeAllConstraintValues() {
+ if (this.constraintValues == null) {
+ return;
+ }
+ for (ConstraintValue value : this.constraintValues) {
+ value.setAttribute(null);
+ }
+ this.constraintValues.clear();
+ }
+
+ public Category getCategoryBean() {
+ return this.categoryBean;
+ }
+
+ public void setCategoryBean(Category categoryBean) {
+ this.categoryBean = categoryBean;
+ }
+
+ public Datatype getDatatypeBean() {
+ return this.datatypeBean;
+ }
+
+ public void setDatatypeBean(Datatype datatypeBean) {
+ this.datatypeBean = datatypeBean;
+ }
+
+ public char getIsDesignator() {
+ return this.isDesignator;
+ }
+
+ public void setIsDesignator(char is) {
+ this.isDesignator = is;
+ }
+
+ public String getSelectorPath() {
+ return this.selectorPath;
+ }
+
+ public void setSelectorPath(String path) {
+ this.selectorPath = path;
+ }
+
+ @Transient
+ public String getIssuer() {
+ return issuer;
+ }
+
+ @Transient
+ public void setIssuer(String issuer) {
+ this.issuer = issuer;
+ }
+
+ @Transient
+ public boolean isMustBePresent() {
+ return mustBePresent;
+ }
+
+ @Transient
+ public void setMustBePresent(boolean mustBePresent) {
+ this.mustBePresent = mustBePresent;
+ }
+
+ @Transient
+ public boolean isDesignator() {
+ return this.isDesignator == '1';
+ }
+
+ @Transient
+ public void setIsDesignator(boolean is) {
+ if (is) {
+ this.isDesignator = '1';
+ } else {
+ this.isDesignator = '0';
+ }
+ }
+}
[17/23] incubator-openaz git commit: Ported original att source to
openaz
Posted by pd...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/AttributeAssignment.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/AttributeAssignment.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/AttributeAssignment.java
new file mode 100644
index 0000000..344b7f8
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/AttributeAssignment.java
@@ -0,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.xacml.admin.jpa;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+
+
+/**
+ * The persistent class for the ObadviceExpressions database table.
+ *
+ */
+@Entity
+@Table(name="AttributeAssignment")
+@NamedQuery(name="AttributeAssignment.findAll", query="SELECT a FROM AttributeAssignment a")
+public class AttributeAssignment implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final String EXPRESSION_APPLY = "Apply";
+ public static final String EXPRESSION_SELECTOR = "AttributeSelector";
+ public static final String EXPRESSION_VALUE = "AttributeValue";
+ public static final String EXPRESSION_FUNCTION = "Function";
+ public static final String EXPRESSION_REFERENCE = "VarableReference";
+ public static final String EXPRESSION_DESIGNATOR = "AttributeDesignator";
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name="id")
+ private int id;
+
+ @Column(name="attribute_id")
+ private int attributeId;
+
+ //bi-directional many-to-one association to Obadvice
+ @Column(name="expression", nullable=false)
+ private String expression;
+
+ //bi-directional many-to-one association to Obadvice
+ @ManyToOne
+ private Obadvice obadvice; //NOPMD
+
+ public AttributeAssignment() {
+ }
+
+ public int getId() {
+ return this.id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public int getAttributeId() {
+ return this.attributeId;
+ }
+
+ public void setAttributeId(int attributeId) {
+ this.attributeId = attributeId;
+ }
+
+ public String getExpression() {
+ return expression;
+ }
+
+ public void setExpression(String expression) {
+ this.expression = expression;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/Category.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/Category.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/Category.java
new file mode 100644
index 0000000..fdcbd3d
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/Category.java
@@ -0,0 +1,216 @@
+/*
+ * 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.xacml.admin.jpa;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.api.XACML3;
+import org.apache.openaz.xacml.std.IdentifierImpl;
+
+
+/**
+ * The persistent class for the Categories database table.
+ *
+ */
+@Entity
+@Table(name="Category")
+@NamedQuery(name="Category.findAll", query="SELECT c FROM Category c")
+public class Category implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final char STANDARD = 'S';
+ public static final char CUSTOM = 'C';
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name="id")
+ private int id;
+
+ @Column(name="grouping", nullable=false, length=64)
+ private String grouping;
+
+ @Column(name="is_standard", nullable=false)
+ private char isStandard;
+
+ @Column(name="xacml_id", nullable=false, unique=true, length=255)
+ private String xacmlId;
+
+ @Column(name="short_name", nullable=false, length=64)
+ private String shortName;
+
+ //bi-directional many-to-one association to Attribute
+ @OneToMany(mappedBy="categoryBean")
+ private Set<Attribute> attributes = new HashSet<>();
+
+ public Category() {
+ this.xacmlId = XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT.stringValue();
+ this.grouping = "subject";
+ this.isStandard = Category.STANDARD;
+ this.shortName = "subject";
+ }
+
+ public Category(Identifier cat, String grouping, char isStandard) {
+ if (cat != null) {
+ this.xacmlId = cat.stringValue();
+ }
+ this.isStandard = isStandard;
+ if (grouping != null) {
+ this.grouping = grouping;
+ } else {
+ this.grouping = Category.extractGrouping(this.xacmlId);
+ }
+ }
+
+ public Category(Identifier cat, String grouping) {
+ this(cat, grouping, Category.STANDARD);
+ }
+
+ public Category(Identifier cat, char standard) {
+ this(cat, null, standard);
+ }
+
+ public Category(Identifier cat) {
+ this(cat, Category.STANDARD);
+ }
+
+ public int getId() {
+ return this.id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getGrouping() {
+ return this.grouping;
+ }
+
+ public void setGrouping(String grouping) {
+ this.grouping = grouping;
+ }
+
+ public char getIsStandard() {
+ return this.isStandard;
+ }
+
+ public void setIsStandard(char isStandard) {
+ this.isStandard = isStandard;
+ }
+
+ public String getXacmlId() {
+ return this.xacmlId;
+ }
+
+ public void setXacmlId(String xacmlId) {
+ this.xacmlId = xacmlId;
+ }
+
+ public String getShortName() {
+ return this.shortName;
+ }
+
+ public void setShortName(String shortName) {
+ this.shortName = shortName;
+ }
+
+ public Set<Attribute> getAttributes() {
+ return this.attributes;
+ }
+
+ public void setAttributes(Set<Attribute> attributes) {
+ this.attributes = attributes;
+ }
+
+ public Attribute addAttribute(Attribute attribute) {
+ getAttributes().add(attribute);
+ attribute.setCategoryBean(this);
+
+ return attribute;
+ }
+
+ public Attribute removeAttribute(Attribute attribute) {
+ getAttributes().remove(attribute);
+ attribute.setCategoryBean(null);
+
+ return attribute;
+ }
+
+ @Transient
+ public boolean isStandard() {
+ return this.isStandard == Category.STANDARD;
+ }
+
+ @Transient
+ public boolean isCustom() {
+ return this.isStandard == Category.CUSTOM;
+ }
+
+ @Transient
+ public static String extractGrouping(String xacmlId) {
+ if (xacmlId == null) {
+ return null;
+ }
+ if (xacmlId.matches(".*:attribute\\-category:.*")) {
+ String[] parts = xacmlId.split("[:]");
+ if (parts != null && parts.length > 0) {
+ return parts[parts.length - 1];
+ }
+ } else if (xacmlId.matches(".*:[a-zA-Z]+[\\-]category:.*")) {
+ String[] parts = xacmlId.split("[:]");
+ if (parts != null && parts.length > 0) {
+ for (String part : parts) {
+ int index = part.indexOf("-category");
+ if (index > 0) {
+ return part.substring(0, index);
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+ @Transient
+ public Identifier getIdentifer() {
+ return new IdentifierImpl(this.xacmlId);
+ }
+
+ @Transient
+ @Override
+ public String toString() {
+ return "Category [id=" + id + ", grouping=" + grouping
+ + ", isStandard=" + isStandard + ", xacmlId=" + xacmlId
+ + ", attributes=" + attributes + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/ConstraintType.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/ConstraintType.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/ConstraintType.java
new file mode 100644
index 0000000..14b9008
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/ConstraintType.java
@@ -0,0 +1,117 @@
+/*
+ * 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.xacml.admin.jpa;
+
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+
+@Entity
+@Table(name="ConstraintType")
+@NamedQuery(name="ConstraintType.findAll", query="SELECT a FROM ConstraintType a")
+public class ConstraintType implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static String ENUMERATION_TYPE = "Enumeration";
+ public static String RANGE_TYPE = "Range";
+ public static String REGEXP_TYPE = "Regular Expression";
+
+ public static Map<String, String> defaults = new HashMap<String, String>();
+ static {
+ defaults.put(ENUMERATION_TYPE, "Enumerate a set of values that the attribute may be set to during policy creation.");
+ defaults.put(RANGE_TYPE, "Set a range of min and/or max integer/double values the attribute can be set to during policy creation.");
+ defaults.put(REGEXP_TYPE, "Define a regular expression the attribute must match against during policy creation.");
+ }
+ public static final String[] RANGE_TYPES = {"minExclusive", "minInclusive", "maxExclusive", "maxInclusive"};
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name="id")
+ private int id;
+
+ @Column(name="constraint_type", nullable=false, length=64)
+ private String constraintType;
+
+ @Column(name="description", nullable=false, length=255)
+ private String description;
+
+ //bi-directional many-to-one association to Attribute
+ @OneToMany(mappedBy="constraintType")
+ private Set<Attribute> attributes = new HashSet<>();
+
+ public ConstraintType() {
+
+ }
+
+ public ConstraintType(String constraintType) {
+ this();
+ this.constraintType = constraintType;
+ }
+
+ public ConstraintType(String constraintType, String description) {
+ this(constraintType);
+ this.description = description;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getConstraintType() {
+ return constraintType;
+ }
+
+ public void setConstraintType(String constraintType) {
+ this.constraintType = constraintType;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public Set<Attribute> getAttributes() {
+ return attributes;
+ }
+
+ public void setAttributes(Set<Attribute> attributes) {
+ this.attributes = attributes;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/ConstraintValue.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/ConstraintValue.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/ConstraintValue.java
new file mode 100644
index 0000000..e1f66d4
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/ConstraintValue.java
@@ -0,0 +1,116 @@
+/*
+ * 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.xacml.admin.jpa;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+
+
+/**
+ * The persistent class for the ConstraintValues database table.
+ *
+ */
+@Entity
+@Table(name="ConstraintValues")
+@NamedQuery(name="ConstraintValue.findAll", query="SELECT c FROM ConstraintValue c")
+public class ConstraintValue implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name="id")
+ private int id;
+
+ @Column(name="property")
+ private String property;
+
+ @Column(name="value")
+ private String value;
+
+ //bi-directional many-to-one association to Attribute
+ @ManyToOne
+ @JoinColumn(name="attribute_id")
+ private Attribute attribute;
+
+ public ConstraintValue() {
+ }
+
+ public ConstraintValue(String property, String value) {
+ this.property = property;
+ this.value = value;
+ }
+
+ public ConstraintValue(ConstraintValue value) {
+ this.property = value.getProperty();
+ this.value = value.getValue();
+ }
+
+ public int getId() {
+ return this.id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getProperty() {
+ return this.property;
+ }
+
+ public void setProperty(String property) {
+ this.property = property;
+ }
+
+ public String getValue() {
+ return this.value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public Attribute getAttribute() {
+ return this.attribute;
+ }
+
+ public void setAttribute(Attribute attribute) {
+ this.attribute = attribute;
+ }
+
+ public ConstraintValue clone() {
+ ConstraintValue constraint = new ConstraintValue();
+
+ constraint.property = this.property;
+ constraint.value = this.value;
+ constraint.attribute = this.attribute;
+
+ return constraint;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/Datatype.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/Datatype.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/Datatype.java
new file mode 100644
index 0000000..50d4488
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/Datatype.java
@@ -0,0 +1,230 @@
+/*
+ * 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.xacml.admin.jpa;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.api.XACML3;
+import org.apache.openaz.xacml.std.IdentifierImpl;
+
+
+/**
+ * The persistent class for the Datatype database table.
+ *
+ */
+@Entity
+@Table(name="Datatype")
+@NamedQuery(name="Datatype.findAll", query="SELECT d FROM Datatype d")
+public class Datatype implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final char STANDARD = 'S';
+ public static final char CUSTOM = 'C';
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name="id")
+ private int id;
+
+ @Column(name="is_standard", nullable=false)
+ private char isStandard;
+
+ @Column(name="xacml_id", nullable=false, unique=true, length=255)
+ private String xacmlId;
+
+ @Column(name="short_name", nullable=false, length=64)
+ private String shortName;
+
+ //bi-directional many-to-one association to Attribute
+ @OneToMany(mappedBy="datatypeBean")
+ private Set<Attribute> attributes = new HashSet<>();
+
+ //bi-directional many-to-one association to Attribute
+ @OneToMany(mappedBy="datatypeBean")
+ private Set<FunctionDefinition> functions = new HashSet<>();
+
+ //bi-directional many-to-one association to Attribute
+ @OneToMany(mappedBy="datatypeBean")
+ private Set<FunctionArgument> arguments = new HashSet<>();
+
+ public Datatype() {
+ this.xacmlId = XACML3.ID_DATATYPE_STRING.stringValue();
+ this.isStandard = Datatype.STANDARD;
+ }
+
+ public Datatype(int id, Datatype dt) {
+ this.id = id;
+ this.isStandard = dt.isStandard;
+ this.xacmlId = dt.xacmlId;
+ this.shortName = dt.shortName;
+ //
+ // Make a copy?
+ //
+ this.attributes = new HashSet<>();
+ }
+
+ public Datatype(Identifier identifier, char standard) {
+ if (identifier != null) {
+ this.xacmlId = identifier.stringValue();
+ }
+ this.isStandard = standard;
+ }
+
+ public Datatype(Identifier identifier) {
+ this(identifier, Datatype.STANDARD);
+ }
+
+ public int getId() {
+ return this.id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public char getIsStandard() {
+ return this.isStandard;
+ }
+
+ public void setIsStandard(char isStandard) {
+ this.isStandard = isStandard;
+ }
+
+ public String getXacmlId() {
+ return this.xacmlId;
+ }
+
+ public void setXacmlId(String xacmlId) {
+ this.xacmlId = xacmlId;
+ }
+
+ public String getShortName() {
+ return shortName;
+ }
+
+ public void setShortName(String shortName) {
+ this.shortName = shortName;
+ }
+
+ public Set<Attribute> getAttributes() {
+ return this.attributes;
+ }
+
+ public void setAttributes(Set<Attribute> attributes) {
+ this.attributes = attributes;
+ }
+
+ public Attribute addAttribute(Attribute attribute) {
+ getAttributes().add(attribute);
+ attribute.setDatatypeBean(this);
+
+ return attribute;
+ }
+
+ public Attribute removeAttribute(Attribute attribute) {
+ getAttributes().remove(attribute);
+ attribute.setDatatypeBean(null);
+
+ return attribute;
+ }
+
+ public Set<FunctionDefinition> getFunctions() {
+ return this.functions;
+ }
+
+ public void setFunctions(Set<FunctionDefinition> functions) {
+ this.functions = functions;
+ }
+
+ public FunctionDefinition addFunction(FunctionDefinition function) {
+ getFunctions().add(function);
+ function.setDatatypeBean(this);
+
+ return function;
+ }
+
+ public FunctionDefinition removeAttribute(FunctionDefinition function) {
+ getFunctions().remove(function);
+ function.setDatatypeBean(null);
+
+ return function;
+ }
+
+ public Set<FunctionArgument> getArguments() {
+ return this.arguments;
+ }
+
+ public void setArguments(Set<FunctionArgument> argument) {
+ this.arguments = argument;
+ }
+
+ public FunctionArgument addArgument(FunctionArgument argument) {
+ getArguments().add(argument);
+ argument.setDatatypeBean(this);
+
+ return argument;
+ }
+
+ public FunctionArgument removeArgument(FunctionArgument argument) {
+ getArguments().remove(argument);
+ argument.setDatatypeBean(null);
+
+ return argument;
+ }
+
+ @Transient
+ public Identifier getIdentifer() {
+ return new IdentifierImpl(this.xacmlId);
+ }
+
+ @Transient
+ public boolean isStandard() {
+ return this.isStandard == Datatype.STANDARD;
+ }
+
+ @Transient
+ public boolean isCustom() {
+ return this.isStandard == Datatype.CUSTOM;
+ }
+
+ @Transient
+ @Override
+ public String toString() {
+ return "Datatype [id=" + id + ", isStandard=" + isStandard
+ + ", xacmlId=" + xacmlId + ", shortName=" + shortName
+ + ", attributes=" + attributes + ", functions=" + functions
+ + ", arguments=" + arguments + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/FunctionArgument.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/FunctionArgument.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/FunctionArgument.java
new file mode 100644
index 0000000..109e26d
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/FunctionArgument.java
@@ -0,0 +1,122 @@
+/*
+ * 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.xacml.admin.jpa;
+
+import java.io.Serializable;
+
+import javax.persistence.*;
+
+
+/**
+ * The persistent class for the FunctionArguments database table.
+ *
+ */
+@Entity
+@Table(name="FunctionArguments")
+@NamedQuery(name="FunctionArgument.findAll", query="SELECT f FROM FunctionArgument f")
+public class FunctionArgument implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ @Column(name="id")
+ private int id;
+
+ @Column(name="is_bag", nullable=false)
+ private int isBag;
+
+ //bi-directional many-to-one association to FunctionDefinition
+ @ManyToOne
+ @JoinColumn(name="function_id")
+ private FunctionDefinition functionDefinition;
+
+ @Column(name="arg_index", nullable=false)
+ private int argIndex;
+
+ //bi-directional many-to-one association to Datatype
+ @ManyToOne
+ @JoinColumn(name="datatype_id")
+ private Datatype datatypeBean;
+
+ public FunctionArgument() {
+ }
+
+ public FunctionArgument(final FunctionArgument argument) {
+ this.argIndex = argument.argIndex;
+ this.datatypeBean = argument.datatypeBean;
+ this.isBag = argument.isBag;
+ this.functionDefinition = argument.functionDefinition;
+ }
+
+ public int getId() {
+ return this.id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public int getArgIndex() {
+ return this.argIndex;
+ }
+
+ public void setArgIndex(int argIndex) {
+ this.argIndex = argIndex;
+ }
+
+ public Datatype getDatatypeBean() {
+ return this.datatypeBean;
+ }
+
+ public void setDatatypeBean(Datatype datatypeBean) {
+ this.datatypeBean = datatypeBean;
+ }
+
+ public FunctionDefinition getFunctionDefinition() {
+ return this.functionDefinition;
+ }
+
+ public int getIsBag() {
+ return isBag;
+ }
+
+ public void setIsBag(int isBag) {
+ this.isBag = isBag;
+ }
+
+ public void setFunctionDefinition(FunctionDefinition functionDefinition) {
+ this.functionDefinition = functionDefinition;
+ }
+
+ @Transient
+ @Override
+ public String toString() {
+ return "FunctionArgument [id=" + id + ", argIndex=" + argIndex
+ + ", datatypeBean=" + datatypeBean + ", isBag=" + isBag
+ + ", functionDefinition=" + functionDefinition + "]";
+ }
+
+ @Transient
+ public boolean isBag() {
+ return this.isBag == 1;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/FunctionDefinition.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/FunctionDefinition.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/FunctionDefinition.java
new file mode 100644
index 0000000..fc0cc91
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/FunctionDefinition.java
@@ -0,0 +1,217 @@
+/*
+ * 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.xacml.admin.jpa;
+
+import java.io.Serializable;
+
+import javax.persistence.*;
+
+import java.util.List;
+
+
+/**
+ * The persistent class for the FunctionDefinition database table.
+ *
+ */
+@Entity
+@Table(name="FunctionDefinition")
+@NamedQuery(name="FunctionDefinition.findAll", query="SELECT f FROM FunctionDefinition f")
+public class FunctionDefinition implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ @Column(name="id")
+ private int id;
+
+ @Column(name="short_name", nullable=false, length=64)
+ private String shortname;
+
+ @Column(name="xacml_id", nullable=false, length=255)
+ private String xacmlid;
+
+ //bi-directional many-to-one association to Datatype
+ @ManyToOne
+ @JoinColumn(name="return_datatype", nullable=true)
+ private Datatype datatypeBean;
+
+ @Column(name="is_bag_return", nullable=false)
+ private int isBagReturn;
+
+ @Column(name="is_higher_order", nullable=false)
+ private int isHigherOrder;
+
+ @Column(name="arg_lb", nullable=false)
+ private int argLb;
+
+ @Column(name="arg_ub", nullable=false)
+ private int argUb;
+
+ @Column(name="ho_arg_lb", nullable=true)
+ private int higherOrderArg_LB;
+
+ @Column(name="ho_arg_ub", nullable=true)
+ private int higherOrderArg_UB;
+
+ @Column(name="ho_primitive", nullable=true)
+ private char higherOrderIsPrimitive;
+
+ //bi-directional many-to-one association to FunctionArgument
+ @OneToMany(mappedBy="functionDefinition")
+ private List<FunctionArgument> functionArguments;
+
+ public FunctionDefinition() {
+ }
+
+ public int getId() {
+ return this.id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public int getArgLb() {
+ return this.argLb;
+ }
+
+ public void setArgLb(int argLb) {
+ this.argLb = argLb;
+ }
+
+ public int getArgUb() {
+ return this.argUb;
+ }
+
+ public void setArgUb(int argUb) {
+ this.argUb = argUb;
+ }
+
+ public int getIsBagReturn() {
+ return isBagReturn;
+ }
+
+ public void setIsBagReturn(int isBagReturn) {
+ this.isBagReturn = isBagReturn;
+ }
+
+ public int getIsHigherOrder() {
+ return isHigherOrder;
+ }
+
+ public void setIsHigherOrder(int isHigherOrder) {
+ this.isHigherOrder = isHigherOrder;
+ }
+
+ public Datatype getDatatypeBean() {
+ return this.datatypeBean;
+ }
+
+ public void setDatatypeBean(Datatype datatypeBean) {
+ this.datatypeBean = datatypeBean;
+ }
+
+ public String getShortname() {
+ return this.shortname;
+ }
+
+ public void setShortname(String shortname) {
+ this.shortname = shortname;
+ }
+
+ public String getXacmlid() {
+ return this.xacmlid;
+ }
+
+ public void setXacmlid(String xacmlid) {
+ this.xacmlid = xacmlid;
+ }
+
+ public int getHigherOrderArg_LB() {
+ return higherOrderArg_LB;
+ }
+
+ public void setHigherOrderArg_LB(int higherOrderArg_LB) {
+ this.higherOrderArg_LB = higherOrderArg_LB;
+ }
+
+ public int getHigherOrderArg_UB() {
+ return higherOrderArg_UB;
+ }
+
+ public void setHigherOrderArg_UB(int higherOrderArg_UB) {
+ this.higherOrderArg_UB = higherOrderArg_UB;
+ }
+
+ public char getHigherOrderIsPrimitive() {
+ return higherOrderIsPrimitive;
+ }
+
+ public void setHigherOrderIsPrimitive(char higherOrderIsPrimitive) {
+ this.higherOrderIsPrimitive = higherOrderIsPrimitive;
+ }
+
+ public List<FunctionArgument> getFunctionArguments() {
+ return this.functionArguments;
+ }
+
+ public void setFunctionArguments(List<FunctionArgument> functionArguments) {
+ this.functionArguments = functionArguments;
+ }
+
+ public FunctionArgument addFunctionArgument(FunctionArgument functionArgument) {
+ getFunctionArguments().add(functionArgument);
+ functionArgument.setFunctionDefinition(this);
+
+ return functionArgument;
+ }
+
+ public FunctionArgument removeFunctionArgument(FunctionArgument functionArgument) {
+ getFunctionArguments().remove(functionArgument);
+ functionArgument.setFunctionDefinition(null);
+
+ return functionArgument;
+ }
+
+ @Transient
+ @Override
+ public String toString() {
+ return "FunctionDefinition [id=" + id + ", argLb=" + argLb + ", argUb="
+ + argUb + ", isBagReturn=" + isBagReturn + ", isHigherOrder="
+ + isHigherOrder + ", datatypeBean=" + datatypeBean
+ + ", shortname=" + shortname + ", xacmlid=" + xacmlid
+ + ", higherOrderArg_LB=" + higherOrderArg_LB
+ + ", higherOrderArg_UB=" + higherOrderArg_UB
+ + ", higherOrderIsPrimitive=" + higherOrderIsPrimitive
+ + ", functionArguments=" + functionArguments + "]";
+ }
+
+ @Transient
+ public boolean isBagReturn() {
+ return this.isBagReturn == 1;
+ }
+
+ @Transient
+ public boolean isHigherOrder() {
+ return this.isHigherOrder == 1;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/Obadvice.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/Obadvice.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/Obadvice.java
new file mode 100644
index 0000000..cda5802
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/Obadvice.java
@@ -0,0 +1,227 @@
+/*
+ * 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.xacml.admin.jpa;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.PrePersist;
+import javax.persistence.PreUpdate;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+
+import org.apache.openaz.xacml.api.Identifier;
+
+/**
+ * The persistent class for the Obadvice database table.
+ *
+ */
+@Entity
+@Table(name="Obadvice")
+@NamedQuery(name="Obadvice.findAll", query="SELECT o FROM Obadvice o")
+public class Obadvice implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final String OBLIGATION = "Obligation";
+ public static final String ADVICE = "Advice";
+ public static final String EFFECT_PERMIT = "Permit";
+ public static final String EFFECT_DENY = "Deny";
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name="id")
+ private int id;
+
+ @Column(name="type", nullable=false)
+ private String type;
+
+ @Column(name="xacml_id", nullable=false, length=255)
+ private String xacmlId;
+
+ @Column(name="fulfill_on", nullable=true, length=32)
+ private String fulfillOn;
+
+ @Column(name="description", nullable=true, length=2048)
+ private String description;
+
+ //bi-directional one-to-many association to Attribute Assignment
+ @OneToMany(mappedBy="obadvice", orphanRemoval=true, cascade=CascadeType.REMOVE)
+ private Set<ObadviceExpression> obadviceExpressions = new HashSet<ObadviceExpression>(2);
+
+ @Column(name="created_by", nullable=false, length=255)
+ private String createdBy;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name="created_date", nullable=false, updatable=false)
+ private Date createdDate; //NOPMD
+
+ @Column(name="modified_by", nullable=false, length=255)
+ private String modifiedBy;
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name="modified_date", nullable=false)
+ private Date modifiedDate; //NOPMD
+
+ public Obadvice() {
+ this.type = Obadvice.OBLIGATION;
+ this.fulfillOn = Obadvice.EFFECT_PERMIT;
+ }
+
+ public Obadvice(String domain, String userid) {
+ this.xacmlId = domain;
+ this.type = Obadvice.OBLIGATION;
+ this.fulfillOn = Obadvice.EFFECT_PERMIT;
+ this.createdBy = userid;
+ this.modifiedBy = userid;
+ }
+
+ public Obadvice(Identifier id, String userid) {
+ this(id.stringValue(), userid);
+ }
+
+ @PrePersist
+ public void prePersist() {
+ Date date = new Date();
+ this.createdDate = date;
+ this.modifiedDate = date;
+ }
+
+ @PreUpdate
+ public void preUpdate() {
+ this.modifiedDate = new Date();
+ }
+
+ public int getId() {
+ return this.id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getCreatedBy() {
+ return this.createdBy;
+ }
+
+ public void setCreatedBy(String createdBy) {
+ this.createdBy = createdBy;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getFulfillOn() {
+ return this.fulfillOn;
+ }
+
+ public void setFulfillOn(String fulfillOn) {
+ this.fulfillOn = fulfillOn;
+ }
+
+ public String getModifiedBy() {
+ return this.modifiedBy;
+ }
+
+ public void setModifiedBy(String modifiedBy) {
+ this.modifiedBy = modifiedBy;
+ }
+
+ public String getType() {
+ return this.type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getXacmlId() {
+ return this.xacmlId;
+ }
+
+ public void setXacmlId(String xacmlId) {
+ this.xacmlId = xacmlId;
+ }
+
+ public Set<ObadviceExpression> getObadviceExpressions() {
+ return this.obadviceExpressions;
+ }
+
+ public void setObadviceExpressions(Set<ObadviceExpression> obadviceExpressions) {
+ this.obadviceExpressions = obadviceExpressions;
+ }
+
+ public ObadviceExpression addObadviceExpression(ObadviceExpression obadviceExpression) {
+ this.obadviceExpressions.add(obadviceExpression);
+ obadviceExpression.setObadvice(this);
+
+ return obadviceExpression;
+ }
+
+ public ObadviceExpression removeObadviceExpression(ObadviceExpression obadviceExpression) {
+ this.obadviceExpressions.remove(obadviceExpression);
+ obadviceExpression.setObadvice(null);
+
+ return obadviceExpression;
+ }
+
+ public void removeAllExpressions() {
+ if (this.obadviceExpressions == null) {
+ return;
+ }
+ for (ObadviceExpression expression : this.obadviceExpressions) {
+ expression.setObadvice(null);
+ }
+ this.obadviceExpressions.clear();
+ }
+
+ @Transient
+ public Obadvice clone() {
+ Obadvice obadvice = new Obadvice();
+
+ obadvice.type = this.type;
+ obadvice.xacmlId = this.xacmlId;
+ obadvice.fulfillOn = this.fulfillOn;
+ obadvice.description = this.description;
+ obadvice.createdBy = this.createdBy;
+ obadvice.modifiedBy = this.modifiedBy;
+ for (ObadviceExpression exp: this.obadviceExpressions) {
+ obadvice.addObadviceExpression(exp.clone());
+ }
+
+ return obadvice;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/ObadviceExpression.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/ObadviceExpression.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/ObadviceExpression.java
new file mode 100644
index 0000000..2a79639
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/ObadviceExpression.java
@@ -0,0 +1,124 @@
+/*
+ * 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.xacml.admin.jpa;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+// import javax.persistence.Lob;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToOne;
+import javax.persistence.Table;
+
+
+/**
+ * The persistent class for the ObadviceExpressions database table.
+ *
+ */
+@Entity
+@Table(name="ObadviceExpressions")
+@NamedQuery(name="ObadviceExpression.findAll", query="SELECT o FROM ObadviceExpression o")
+public class ObadviceExpression implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final String EXPRESSION_APPLY = "Apply";
+ public static final String EXPRESSION_SELECTOR = "Attribute Selector";
+ public static final String EXPRESSION_VALUE = "Attribute Value";
+ public static final String EXPRESSION_FUNCTION = "Function";
+ public static final String EXPRESSION_REFERENCE = "Varable Reference";
+ public static final String EXPRESSION_DESIGNATOR = "Attribute Designator";
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name="id")
+ private int id;
+
+ //unidirectional one-to-one association to Attribute
+ @OneToOne
+ @JoinColumn(name="attribute_id")
+ private Attribute attribute;
+
+ @Column(name="type", nullable=false)
+ private String type;
+
+ /*
+ @Lob
+ @Column(name="expression", nullable=false)
+ private byte[] expression;
+ */
+
+ //bi-directional many-to-one association to Obadvice
+ @ManyToOne
+ @JoinColumn(name="obadvice_id")
+ private Obadvice obadvice;
+
+ public ObadviceExpression() {
+ type = EXPRESSION_VALUE;
+ }
+
+ public int getId() {
+ return this.id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public Attribute getAttribute() {
+ return this.attribute;
+ }
+
+ public void setAttribute(Attribute attribute) {
+ this.attribute = attribute;
+ }
+
+ public String getType() {
+ return this.type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public Obadvice getObadvice() {
+ return this.obadvice;
+ }
+
+ public void setObadvice(Obadvice obadvice) {
+ this.obadvice = obadvice;
+ }
+
+ public ObadviceExpression clone() {
+ ObadviceExpression expression = new ObadviceExpression();
+
+ expression.attribute = this.attribute;
+ expression.type = this.type;
+ expression.obadvice = this.obadvice;
+
+ return expression;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PIPConfigParam.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PIPConfigParam.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PIPConfigParam.java
new file mode 100644
index 0000000..a4c4a16
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PIPConfigParam.java
@@ -0,0 +1,147 @@
+/*
+ * 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.xacml.admin.jpa;
+
+import java.io.Serializable;
+
+import javax.persistence.*;
+
+
+/**
+ * The persistent class for the PIPConfigParams database table.
+ *
+ */
+@Entity
+@Table(name="PIPConfigParams")
+@NamedQuery(name="PIPConfigParam.findAll", query="SELECT p FROM PIPConfigParam p")
+public class PIPConfigParam implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ @Column(name="id")
+ private int id;
+
+ @Column(name="PARAM_NAME", nullable=false, length=1024)
+ private String paramName;
+
+ @Column(name="PARAM_VALUE", nullable=false, length=2048)
+ private String paramValue;
+
+ @Column(name="PARAM_DEFAULT", nullable=true, length=2048)
+ private String paramDefault = null;
+
+ @Column(name="REQUIRED", nullable=false)
+ private char required = '0';
+
+ //bi-directional many-to-one association to PIPConfiguration
+ @ManyToOne
+ @JoinColumn(name="PIP_ID")
+ private PIPConfiguration pipconfiguration;
+
+ public PIPConfigParam() {
+ }
+
+ public PIPConfigParam(String param) {
+ this.paramName = param;
+ }
+
+ public PIPConfigParam(String param, String value) {
+ this(param);
+ this.paramValue = value;
+ }
+
+ public PIPConfigParam(PIPConfigParam param) {
+ this(param.getParamName(), param.getParamValue());
+ this.paramDefault = param.getParamDefault();
+ this.required = param.required;
+ }
+
+ public int getId() {
+ return this.id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getParamName() {
+ return this.paramName;
+ }
+
+ public void setParamName(String paramName) {
+ this.paramName = paramName;
+ }
+
+ public String getParamValue() {
+ return this.paramValue;
+ }
+
+ public void setParamValue(String paramValue) {
+ this.paramValue = paramValue;
+ }
+
+ public String getParamDefault() {
+ return paramDefault;
+ }
+
+ public void setParamDefault(String paramDefault) {
+ this.paramDefault = paramDefault;
+ }
+
+ public char getRequired() {
+ return required;
+ }
+
+ public void setRequired(char required) {
+ this.required = required;
+ }
+
+ public PIPConfiguration getPipconfiguration() {
+ return this.pipconfiguration;
+ }
+
+ public void setPipconfiguration(PIPConfiguration pipconfiguration) {
+ this.pipconfiguration = pipconfiguration;
+ }
+
+ @Transient
+ public boolean isRequired() {
+ return this.required == '1';
+ }
+
+ @Transient
+ public void setRequired(boolean required) {
+ if (required) {
+ this.setRequired('1');
+ } else {
+ this.setRequired('0');
+ }
+ }
+
+ @Transient
+ @Override
+ public String toString() {
+ return "PIPConfigParam [id=" + id + ", paramName=" + paramName
+ + ", paramValue=" + paramValue + ", required=" + required + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PIPConfiguration.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PIPConfiguration.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PIPConfiguration.java
new file mode 100644
index 0000000..d540e2b
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PIPConfiguration.java
@@ -0,0 +1,554 @@
+/*
+ * 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.xacml.admin.jpa;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.PrePersist;
+import javax.persistence.PreUpdate;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.util.JPAUtils;
+import org.apache.openaz.xacml.api.pip.PIPException;
+import org.apache.openaz.xacml.std.pip.engines.StdConfigurableEngine;
+import org.apache.openaz.xacml.std.pip.engines.csv.CSVEngine;
+import org.apache.openaz.xacml.std.pip.engines.csv.HyperCSVEngine;
+import org.apache.openaz.xacml.std.pip.engines.jdbc.JDBCEngine;
+import org.apache.openaz.xacml.std.pip.engines.ldap.LDAPEngine;
+import org.apache.openaz.xacml.util.XACMLProperties;
+import com.google.common.base.Joiner;
+import com.google.common.base.Splitter;
+import com.vaadin.ui.UI;
+
+
+/**
+ * The persistent class for the PIPConfiguration database table.
+ *
+ */
+@Entity
+@Table(name="PIPConfiguration")
+@NamedQuery(name="PIPConfiguration.findAll", query="SELECT p FROM PIPConfiguration p")
+public class PIPConfiguration implements Serializable {
+ private static final long serialVersionUID = 1L;
+ private static final Log logger = LogFactory.getLog(PIPConfiguration.class);
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ @Column(name="id")
+ private int id;
+
+ @Column(name="DESCRIPTION", nullable=true, length=2048)
+ private String description;
+
+ @Column(name="NAME", nullable=false, length=255)
+ private String name;
+
+ @Column(name="CLASSNAME", nullable=false, length=2048)
+ private String classname;
+
+ @Column(name="ISSUER", nullable=true, length=1024)
+ private String issuer;
+
+ @Column(name="READ_ONLY", nullable=false)
+ private char readOnly = '0';
+
+ @Column(name="REQUIRES_RESOLVER", nullable=false)
+ private char requiresResolvers;
+
+ @Column(name="CREATED_BY", nullable=false, length=255)
+ private String createdBy = "guest";
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name="CREATED_DATE", nullable=false, updatable=false)
+ private Date createdDate;
+
+ @Column(name="MODIFIED_BY", nullable=false, length=255)
+ private String modifiedBy = "guest";
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name="MODIFIED_DATE", nullable=false)
+ private Date modifiedDate;
+
+ //bi-directional many-to-one association to PIPConfigParam
+ @OneToMany(mappedBy="pipconfiguration", orphanRemoval=true, cascade=CascadeType.REMOVE)
+ private Set<PIPConfigParam> pipconfigParams = new HashSet<PIPConfigParam>();
+
+ //bi-directional many-to-one association to PIPType
+ @ManyToOne
+ @JoinColumn(name="TYPE")
+ private PIPType piptype;
+
+ //bi-directional many-to-one association to PIPResolver
+ @OneToMany(mappedBy="pipconfiguration", orphanRemoval=true, cascade=CascadeType.REMOVE)
+ private Set<PIPResolver> pipresolvers = new HashSet<PIPResolver>();
+
+ public PIPConfiguration() {
+ }
+
+ public PIPConfiguration(PIPConfiguration config, String user) { //NOPMD
+ this.description = config.description;
+ this.name = config.name;
+ this.classname = config.classname;
+ this.issuer = config.issuer;
+ this.requiresResolvers = config.requiresResolvers;
+ this.readOnly = config.readOnly;
+ this.piptype = config.piptype;
+ for (PIPConfigParam param : config.pipconfigParams) {
+ this.addPipconfigParam(new PIPConfigParam(param));
+ }
+ for (PIPResolver resolver : config.pipresolvers) {
+ this.addPipresolver(new PIPResolver(resolver));
+ }
+ }
+
+ public PIPConfiguration(String id, Properties properties) throws PIPException {
+ this.readProperties(id, properties);
+ }
+
+ public PIPConfiguration(String id, Properties properties, String user) throws PIPException {
+ this.createdBy = user;
+ this.modifiedBy = user;
+ this.readProperties(id, properties);
+ }
+
+ @PrePersist
+ public void prePersist() {
+ Date date = new Date();
+ this.createdDate = date;
+ this.modifiedDate = date;
+ }
+
+ @PreUpdate
+ public void preUpdate() {
+ this.modifiedDate = new Date();
+ }
+
+ public int getId() {
+ return this.id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getClassname() {
+ return classname;
+ }
+
+ public void setClassname(String classname) {
+ this.classname = classname;
+ }
+
+ public String getIssuer() {
+ return issuer;
+ }
+
+ public void setIssuer(String issuer) {
+ this.issuer = issuer;
+ }
+
+ public char getReadOnly() {
+ return readOnly;
+ }
+
+ public void setReadOnly(char readOnly) {
+ this.readOnly = readOnly;
+ }
+
+ public char getRequiresResolvers() {
+ return requiresResolvers;
+ }
+
+ public void setRequiresResolvers(char requireResolvers) {
+ this.requiresResolvers = requireResolvers;
+ }
+
+ public Set<PIPConfigParam> getPipconfigParams() {
+ return this.pipconfigParams;
+ }
+
+ public void setPipconfigParams(Set<PIPConfigParam> pipconfigParams) {
+ this.pipconfigParams = pipconfigParams;
+ }
+
+ public PIPConfigParam addPipconfigParam(PIPConfigParam pipconfigParam) {
+ getPipconfigParams().add(pipconfigParam);
+ pipconfigParam.setPipconfiguration(this);
+
+ return pipconfigParam;
+ }
+
+ public PIPConfigParam removePipconfigParam(PIPConfigParam pipconfigParam) {
+ if (pipconfigParam == null) {
+ return pipconfigParam;
+ }
+ getPipconfigParams().remove(pipconfigParam);
+ pipconfigParam.setPipconfiguration(null);
+
+ return pipconfigParam;
+ }
+
+ @Transient
+ public void clearConfigParams() {
+ while (this.pipconfigParams.isEmpty() == false) {
+ this.removePipconfigParam(this.pipconfigParams.iterator().next());
+ }
+ }
+
+ public PIPType getPiptype() {
+ return this.piptype;
+ }
+
+ public void setPiptype(PIPType piptype) {
+ this.piptype = piptype;
+ }
+
+ public Set<PIPResolver> getPipresolvers() {
+ return this.pipresolvers;
+ }
+
+ public void setPipresolvers(Set<PIPResolver> pipresolvers) {
+ this.pipresolvers = pipresolvers;
+ }
+
+ public PIPResolver addPipresolver(PIPResolver pipresolver) {
+ getPipresolvers().add(pipresolver);
+ pipresolver.setPipconfiguration(this);
+
+ return pipresolver;
+ }
+
+ public PIPResolver removePipresolver(PIPResolver pipresolver) {
+ getPipresolvers().remove(pipresolver);
+ pipresolver.setPipconfiguration(null);
+
+ return pipresolver;
+ }
+
+ public String getCreatedBy() {
+ return createdBy;
+ }
+
+ public void setCreatedBy(String createdBy) {
+ this.createdBy = createdBy;
+ }
+
+ public Date getCreatedDate() {
+ return createdDate;
+ }
+
+ public void setCreatedDate(Date createdDate) {
+ this.createdDate = createdDate;
+ }
+
+ public String getModifiedBy() {
+ return modifiedBy;
+ }
+
+ public void setModifiedBy(String modifiedBy) {
+ this.modifiedBy = modifiedBy;
+ }
+
+ public Date getModifiedDate() {
+ return modifiedDate;
+ }
+
+ public void setModifiedDate(Date modifiedDate) {
+ this.modifiedDate = modifiedDate;
+ }
+
+ @Transient
+ public boolean isReadOnly() {
+ return this.readOnly == '1';
+ }
+
+ @Transient
+ public void setReadOnly(boolean readOnly) {
+ if (readOnly) {
+ this.readOnly = '1';
+ } else {
+ this.readOnly = '0';
+ }
+ }
+
+ @Transient
+ public boolean requiresResolvers() {
+ return this.requiresResolvers == '1';
+ }
+
+ @Transient
+ public void setRequiresResolvers(boolean requires) {
+ if (requires) {
+ this.requiresResolvers = '1';
+ } else {
+ this.requiresResolvers = '0';
+ }
+ }
+
+ @Transient
+ public static Collection<PIPConfiguration> importPIPConfigurations(Properties properties) {
+ Collection<PIPConfiguration> configurations = new ArrayList<PIPConfiguration>();
+ String engines = properties.getProperty(XACMLProperties.PROP_PIP_ENGINES);
+ if (engines == null || engines.isEmpty()) {
+ return configurations;
+ }
+ for (String id : Splitter.on(',').trimResults().omitEmptyStrings().split(engines)) {
+ PIPConfiguration configuration;
+ try {
+ String user = ((XacmlAdminUI)UI.getCurrent()).getUserid();
+ configuration = new PIPConfiguration(id, properties, user);
+ configuration.setCreatedBy(user);
+ configuration.setModifiedBy(user);
+ configurations.add(configuration);
+ } catch (PIPException e) {
+ logger.error("Import failed: " + e.getLocalizedMessage());
+ }
+ }
+
+ return configurations;
+ }
+
+ @Transient
+ protected void readProperties(String id, Properties properties) throws PIPException {
+ //
+ // Save the id if we don't have one already
+ //
+ if (this.id == 0) {
+ try {
+ this.id = Integer.parseInt(id);
+ } catch (NumberFormatException e) {
+ logger.error("Convert id to integer failed: " + id);
+ }
+ }
+ //
+ // Get its classname, this MUST exist.
+ //
+ this.classname = properties.getProperty(id + ".classname");
+ if (this.classname == null) {
+ throw new PIPException("PIP Engine defined without a classname");
+ }
+ //
+ // These classes we know for sure require resolvers.
+ //
+ if (this.classname.equals(JDBCEngine.class.getCanonicalName())) {
+ this.setRequiresResolvers(true);
+ this.setPiptype(JPAUtils.getPIPType(PIPType.TYPE_SQL));
+ } else if (this.classname.equals(LDAPEngine.class.getCanonicalName())) {
+ this.setRequiresResolvers(true);
+ this.setPiptype(JPAUtils.getPIPType(PIPType.TYPE_LDAP));
+ } else if (this.classname.equals(HyperCSVEngine.class.getCanonicalName())) {
+ this.setRequiresResolvers(true);
+ this.setPiptype(JPAUtils.getPIPType(PIPType.TYPE_HYPERCSV));
+ } else if (this.classname.equals(CSVEngine.class.getCanonicalName())) {
+ this.setRequiresResolvers(true);
+ this.setPiptype(JPAUtils.getPIPType(PIPType.TYPE_CSV));
+ } else {
+ //
+ // Assume it does not require resolvers for now, if we encounter
+ // one then we will change it. The user can always change it via the gui.
+ //
+ this.setRequiresResolvers(false);
+ this.setPiptype(JPAUtils.getPIPType(PIPType.TYPE_CUSTOM));
+ }
+ //
+ // Go through each property
+ //
+ for (Object name : properties.keySet()) {
+ if (name.toString().startsWith(id) == false || name.equals(id + ".classname")) {
+ continue;
+ }
+ if (name.equals(id + "." + StdConfigurableEngine.PROP_NAME)) {
+ this.name = properties.getProperty(name.toString());
+ } else if (name.equals(id + "." + StdConfigurableEngine.PROP_DESCRIPTION)) {
+ this.description = properties.getProperty(name.toString());
+ } else if (name.equals(id + "." + StdConfigurableEngine.PROP_ISSUER)) {
+ this.issuer = properties.getProperty(name.toString());
+ } else if (name.equals(id + ".resolvers")) {
+ //
+ // It has resolvers, make sure this is set to true if
+ // it has been already.
+ //
+ this.setRequiresResolvers(true);
+ //
+ // Parse the resolvers
+ //
+ Collection<PIPResolver> resolvers = PIPResolver.importResolvers(id + ".resolver",
+ properties.getProperty(name.toString()),
+ properties,
+ ((XacmlAdminUI)UI.getCurrent()).getUserid());
+ for (PIPResolver resolver : resolvers) {
+ this.addPipresolver(resolver);
+ }
+ // Ignore {id}.resolver: the PIPResolver will parse these values
+ } else if (! name.toString().startsWith(id + ".resolver")) {
+ //
+ // Config Parameter
+ //
+ this.addPipconfigParam(new PIPConfigParam(name.toString().substring(id.length() + 1),
+ properties.getProperty(name.toString())));
+ }
+ }
+ //
+ // Make sure we have a name at least
+ //
+ if (this.name == null) {
+ this.name = id;
+ }
+ }
+
+
+ @Transient
+ public Map<String, String> getConfiguration(String name) {
+ String prefix;
+ if (name == null) {
+ prefix = Integer.toString(this.id);
+ } else {
+ prefix = name;
+ }
+ if (prefix.endsWith(".") == false) {
+ prefix = prefix + ".";
+ }
+ Map<String, String> map = new HashMap<String, String>();
+ map.put(prefix + "classname", this.classname);
+ map.put(prefix + "name", this.name);
+ if (this.description != null) {
+ map.put(prefix + "description", this.description);
+ }
+ if (this.issuer != null) {
+ map.put(prefix + "issuer", this.issuer);
+ }
+
+ for (PIPConfigParam param : this.pipconfigParams) {
+ map.put(prefix + param.getParamName(), param.getParamValue());
+ }
+
+ List<String> ids = new ArrayList<String>();
+ Iterator<PIPResolver> iter = this.pipresolvers.iterator();
+ while (iter.hasNext()) {
+ PIPResolver resolver = iter.next();
+ String id = Integer.toString(resolver.getId());
+ Map<String, String> resolverMap = resolver.getConfiguration(prefix + "resolver." + id);
+ map.putAll(resolverMap);
+ ids.add(id);
+ }
+ if (ids.size() > 0) {
+ map.put(prefix + "resolvers", Joiner.on(',').join(ids));
+ }
+ return map;
+ }
+
+ @Transient
+ public Properties generateProperties(String name) {
+ String prefix;
+ if (name == null) {
+ prefix = Integer.toString(this.id);
+ } else {
+ if (name.endsWith(".")) {
+ prefix = name;
+ } else {
+ prefix = name + ".";
+ }
+ }
+ Properties props = new Properties();
+ props.setProperty("xacml.pip.engines", name);
+ props.setProperty(prefix + "classname", this.classname);
+ props.setProperty(prefix + "name", this.name);
+ if (this.description != null) {
+ props.setProperty(prefix + "description", this.description);
+ }
+ if (this.issuer != null && this.issuer.isEmpty() == false) {
+ props.setProperty(prefix + "issuer", this.issuer);
+ }
+
+ for (PIPConfigParam param : this.pipconfigParams) {
+ props.setProperty(prefix + param.getParamName(), param.getParamValue());
+ }
+
+ List<String> ids = new ArrayList<String>();
+ Iterator<PIPResolver> iter = this.pipresolvers.iterator();
+ while (iter.hasNext()) {
+ PIPResolver resolver = iter.next();
+ String id = Integer.toString(resolver.getId());
+ resolver.generateProperties(props, prefix + "resolver." + id);
+ ids.add(id);
+ }
+ if (ids.size() > 0) {
+ props.setProperty(prefix + "resolvers", Joiner.on(',').join(ids));
+ }
+ return props;
+ }
+
+ @Transient
+ @Override
+ public String toString() {
+ return "PIPConfiguration [id=" + id + ", piptype=" + piptype
+ + ", classname=" + classname + ", name=" + name
+ + ", description=" + description + ", issuer=" + issuer
+ + ", readOnly=" + readOnly + ", requiresResolvers="
+ + requiresResolvers + ", createdBy=" + createdBy
+ + ", createdDate=" + createdDate + ", modifiedBy=" + modifiedBy
+ + ", modifiedDate=" + modifiedDate + ", pipconfigParams="
+ + pipconfigParams + ", pipresolvers=" + pipresolvers + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PIPResolver.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PIPResolver.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PIPResolver.java
new file mode 100644
index 0000000..59c9307
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PIPResolver.java
@@ -0,0 +1,362 @@
+/*
+ * 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.xacml.admin.jpa;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.PrePersist;
+import javax.persistence.PreUpdate;
+import javax.persistence.Table;
+import javax.persistence.Temporal;
+import javax.persistence.TemporalType;
+import javax.persistence.Transient;
+
+import org.apache.openaz.xacml.api.pip.PIPException;
+import org.apache.openaz.xacml.std.pip.engines.StdConfigurableEngine;
+import com.google.common.base.Splitter;
+
+
+/**
+ * The persistent class for the PIPResolver database table.
+ *
+ */
+@Entity
+@Table(name="PIPResolver")
+@NamedQuery(name="PIPResolver.findAll", query="SELECT p FROM PIPResolver p")
+public class PIPResolver implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ @Column(name="id")
+ private int id;
+
+ @Column(name="DESCRIPTION", nullable=true, length=2048)
+ private String description;
+
+ @Column(name="NAME", nullable=false, length=255)
+ private String name;
+
+ @Column(name="ISSUER", nullable=true, length=1024)
+ private String issuer;
+
+ @Column(name="CLASSNAME", nullable=false, length=2048)
+ private String classname;
+
+ @Column(name="READ_ONLY", nullable=false)
+ private char readOnly = '0';
+
+ @Column(name="CREATED_BY", nullable=false, length=255)
+ private String createdBy = "guest";
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name="CREATED_DATE", nullable=false, updatable=false)
+ private Date createdDate;
+
+ @Column(name="MODIFIED_BY", nullable=false, length=255)
+ private String modifiedBy = "guest";
+
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name="MODIFIED_DATE", nullable=false)
+ private Date modifiedDate;
+
+ //bi-directional many-to-one association to PIPConfiguration
+ @ManyToOne
+ @JoinColumn(name="PIP_ID")
+ private PIPConfiguration pipconfiguration;
+
+ //bi-directional many-to-one association to PIPResolverParam
+ @OneToMany(mappedBy="pipresolver", orphanRemoval=true, cascade=CascadeType.REMOVE)
+ private Set<PIPResolverParam> pipresolverParams = new HashSet<PIPResolverParam>();
+
+ public PIPResolver() {
+ }
+
+ public PIPResolver(String prefix, Properties properties, String user) throws PIPException {
+ this.createdBy = user;
+ this.modifiedBy = user;
+ this.readOnly = '0';
+ this.readProperties(prefix, properties);
+ }
+
+ public PIPResolver(PIPResolver resolver) {
+ this.name = resolver.name;
+ this.description = resolver.description;
+ this.issuer = resolver.issuer;
+ this.classname = resolver.classname;
+ this.readOnly = resolver.readOnly;
+ for (PIPResolverParam param : this.pipresolverParams) {
+ this.addPipresolverParam(new PIPResolverParam(param));
+ }
+ }
+
+ @PrePersist
+ public void prePersist() {
+ Date date = new Date();
+ this.createdDate = date;
+ this.modifiedDate = date;
+ }
+
+ @PreUpdate
+ public void preUpdate() {
+ this.modifiedDate = new Date();
+ }
+
+ public int getId() {
+ return this.id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getDescription() {
+ return this.description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getIssuer() {
+ return issuer;
+ }
+
+ public void setIssuer(String issuer) {
+ this.issuer = issuer;
+ }
+
+ public String getClassname() {
+ return classname;
+ }
+
+ public void setClassname(String classname) {
+ this.classname = classname;
+ }
+
+ public char getReadOnly() {
+ return readOnly;
+ }
+
+ public void setReadOnly(char readOnly) {
+ this.readOnly = readOnly;
+ }
+
+ public String getCreatedBy() {
+ return createdBy;
+ }
+
+ public void setCreatedBy(String createdBy) {
+ this.createdBy = createdBy;
+ }
+
+ public Date getCreatedDate() {
+ return createdDate;
+ }
+
+ public void setCreatedDate(Date createdDate) {
+ this.createdDate = createdDate;
+ }
+
+ public String getModifiedBy() {
+ return modifiedBy;
+ }
+
+ public void setModifiedBy(String modifiedBy) {
+ this.modifiedBy = modifiedBy;
+ }
+
+ public Date getModifiedDate() {
+ return modifiedDate;
+ }
+
+ public void setModifiedDate(Date modifiedDate) {
+ this.modifiedDate = modifiedDate;
+ }
+
+ public PIPConfiguration getPipconfiguration() {
+ return this.pipconfiguration;
+ }
+
+ public void setPipconfiguration(PIPConfiguration pipconfiguration) {
+ this.pipconfiguration = pipconfiguration;
+ }
+
+ public Set<PIPResolverParam> getPipresolverParams() {
+ return this.pipresolverParams;
+ }
+
+ public void setPipresolverParams(Set<PIPResolverParam> pipresolverParams) {
+ this.pipresolverParams = pipresolverParams;
+ }
+
+ public PIPResolverParam addPipresolverParam(PIPResolverParam pipresolverParam) {
+ getPipresolverParams().add(pipresolverParam);
+ pipresolverParam.setPipresolver(this);
+
+ return pipresolverParam;
+ }
+
+ public PIPResolverParam removePipresolverParam(PIPResolverParam pipresolverParam) {
+ if (pipresolverParam == null) {
+ return pipresolverParam;
+ }
+ getPipresolverParams().remove(pipresolverParam);
+ pipresolverParam.setPipresolver(null);
+
+ return pipresolverParam;
+ }
+
+ @Transient
+ public void clearParams() {
+ while (this.pipresolverParams.isEmpty() == false) {
+ this.removePipresolverParam(this.pipresolverParams.iterator().next());
+ }
+ }
+
+ @Transient
+ public boolean isReadOnly() {
+ return this.readOnly == '1';
+ }
+
+ @Transient
+ public void setReadOnly(boolean readOnly) {
+ if (readOnly) {
+ this.readOnly = '1';
+ } else {
+ this.readOnly = '0';
+ }
+ }
+
+ @Transient
+ public static Collection<PIPResolver> importResolvers(String prefix, String list, Properties properties, String user) throws PIPException {
+ Collection<PIPResolver> resolvers = new ArrayList<PIPResolver>();
+ for (String id : Splitter.on(',').trimResults().omitEmptyStrings().split(list)) {
+ resolvers.add(new PIPResolver(prefix + "." + id, properties, user));
+ }
+ return resolvers;
+ }
+
+ @Transient
+ protected void readProperties(String prefix, Properties properties) throws PIPException {
+ //
+ // Get its classname, this MUST exist.
+ //
+ this.classname = properties.getProperty(prefix + ".classname");
+ if (this.classname == null) {
+ throw new PIPException("PIP Engine defined without a classname");
+ }
+ //
+ // Go through each property
+ //
+ for (Object name : properties.keySet()) {
+ if (name.toString().startsWith(prefix) == false || name.equals(prefix + ".classname")) {
+ continue;
+ }
+
+ if (name.equals(prefix + "." + StdConfigurableEngine.PROP_NAME)) {
+ this.name = properties.getProperty(name.toString());
+ } else if (name.equals(prefix + "." + StdConfigurableEngine.PROP_DESCRIPTION)) {
+ this.description = properties.getProperty(name.toString());
+ } else if (name.equals(prefix + "." + StdConfigurableEngine.PROP_ISSUER)) {
+ this.issuer = properties.getProperty(name.toString());
+ } else {
+ this.addPipresolverParam(new PIPResolverParam(name.toString().substring(prefix.length() + 1),
+ properties.getProperty(name.toString())));
+ }
+ }
+ }
+
+ @Transient
+ public Map<String, String> getConfiguration(String prefix) {
+ Map<String, String> map = new HashMap<String, String>();
+ if (prefix.endsWith(".") == false) {
+ prefix = prefix + ".";
+ }
+ map.put(prefix + "classname", this.classname);
+ map.put(prefix + "name", this.name);
+ if (this.description != null) {
+ map.put(prefix + "description", this.description);
+ }
+ if (this.issuer != null && this.issuer.isEmpty() != false) {
+ map.put(prefix + "issuer", this.issuer);
+ }
+ for (PIPResolverParam param : this.pipresolverParams) {
+ map.put(prefix + param.getParamName(), param.getParamValue());
+ }
+ return map;
+ }
+
+ @Transient
+ public void generateProperties(Properties props, String prefix) {
+ if (prefix.endsWith(".") == false) {
+ prefix = prefix + ".";
+ }
+ props.setProperty(prefix + "classname", this.classname);
+ props.setProperty(prefix + "name", this.name);
+ if (this.description != null) {
+ props.setProperty(prefix + "description", this.description);
+ }
+ if (this.issuer != null && this.issuer.isEmpty() != false) {
+ props.setProperty(prefix + "issuer", this.issuer);
+ }
+ for (PIPResolverParam param : this.pipresolverParams) {
+ props.setProperty(prefix + param.getParamName(), param.getParamValue());
+ }
+ }
+
+ @Transient
+ @Override
+ public String toString() {
+ return "PIPResolver [id=" + id + ", classname=" + classname + ", name="
+ + name + ", description=" + description + ", issuer=" + issuer
+ + ", readOnly=" + readOnly + ", createdBy=" + createdBy
+ + ", createdDate=" + createdDate + ", modifiedBy=" + modifiedBy
+ + ", modifiedDate=" + modifiedDate + ", pipresolverParams="
+ + pipresolverParams + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PIPResolverParam.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PIPResolverParam.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PIPResolverParam.java
new file mode 100644
index 0000000..917ce5b
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PIPResolverParam.java
@@ -0,0 +1,147 @@
+/*
+ * 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.xacml.admin.jpa;
+
+import java.io.Serializable;
+
+import javax.persistence.*;
+
+
+/**
+ * The persistent class for the PIPResolverParams database table.
+ *
+ */
+@Entity
+@Table(name="PIPResolverParams")
+@NamedQuery(name="PIPResolverParam.findAll", query="SELECT p FROM PIPResolverParam p")
+public class PIPResolverParam implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ @Column(name="id")
+ private int id;
+
+ @Column(name="PARAM_NAME", nullable=false, length=1024)
+ private String paramName;
+
+ @Column(name="PARAM_VALUE", nullable=false, length=2048)
+ private String paramValue;
+
+ @Column(name="PARAM_DEFAULT", nullable=true, length=2048)
+ private String paramDefault;
+
+ @Column(name="REQUIRED", nullable=false)
+ private char required = '0';
+
+ //bi-directional many-to-one association to PIPResolver
+ @ManyToOne
+ @JoinColumn(name="ID_RESOLVER")
+ private PIPResolver pipresolver;
+
+ public PIPResolverParam() {
+ }
+
+ public PIPResolverParam(String name) {
+ this.paramName = name;
+ }
+
+ public PIPResolverParam(String name, String value) {
+ this(name);
+ this.paramValue = value;
+ }
+
+ public PIPResolverParam(PIPResolverParam param) {
+ this(param.getParamName(), param.getParamValue());
+ this.paramDefault = param.getParamDefault();
+ this.required = param.required;
+ }
+
+ public int getId() {
+ return this.id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getParamName() {
+ return this.paramName;
+ }
+
+ public void setParamName(String paramName) {
+ this.paramName = paramName;
+ }
+
+ public String getParamValue() {
+ return this.paramValue;
+ }
+
+ public void setParamValue(String paramValue) {
+ this.paramValue = paramValue;
+ }
+
+ public String getParamDefault() {
+ return paramDefault;
+ }
+
+ public void setParamDefault(String paramDefault) {
+ this.paramDefault = paramDefault;
+ }
+
+ public char getRequired() {
+ return required;
+ }
+
+ public void setRequired(char required) {
+ this.required = required;
+ }
+
+ public PIPResolver getPipresolver() {
+ return this.pipresolver;
+ }
+
+ public void setPipresolver(PIPResolver pipresolver) {
+ this.pipresolver = pipresolver;
+ }
+
+ @Transient
+ public boolean isRequired() {
+ return this.required == '1';
+ }
+
+ @Transient
+ public void setRequired(boolean required) {
+ if (required) {
+ this.required = '1';
+ } else {
+ this.required = '0';
+ }
+ }
+
+ @Transient
+ @Override
+ public String toString() {
+ return "PIPResolverParam [id=" + id + ", paramName=" + paramName
+ + ", paramValue=" + paramValue + ", required=" + required + "]";
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PIPType.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PIPType.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PIPType.java
new file mode 100644
index 0000000..7208b76
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PIPType.java
@@ -0,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.xacml.admin.jpa;
+
+import java.io.Serializable;
+import java.util.Set;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.NamedQuery;
+import javax.persistence.OneToMany;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+
+/**
+ * The persistent class for the PIPType database table.
+ *
+ */
+@Entity
+@Table(name="PIPType")
+@NamedQuery(name="PIPType.findAll", query="SELECT p FROM PIPType p")
+public class PIPType implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final String TYPE_SQL = "SQL";
+ public static final String TYPE_LDAP = "LDAP";
+ public static final String TYPE_CSV = "CSV";
+ public static final String TYPE_HYPERCSV = "Hyper-CSV";
+ public static final String TYPE_CUSTOM = "Custom";
+
+ @Id
+ @GeneratedValue(strategy=GenerationType.AUTO)
+ @Column(name="id")
+ private int id;
+
+ @Column(name="type", nullable=false, length=45)
+ private String type;
+
+ //bi-directional many-to-one association to PIPConfiguration
+ @OneToMany(mappedBy="piptype")
+ private Set<PIPConfiguration> pipconfigurations;
+
+ public PIPType() {
+ }
+
+ public int getId() {
+ return this.id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getType() {
+ return this.type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public Set<PIPConfiguration> getPipconfigurations() {
+ return this.pipconfigurations;
+ }
+
+ public void setPipconfigurations(Set<PIPConfiguration> pipconfigurations) {
+ this.pipconfigurations = pipconfigurations;
+ }
+
+ public PIPConfiguration addPipconfiguration(PIPConfiguration pipconfiguration) {
+ getPipconfigurations().add(pipconfiguration);
+ pipconfiguration.setPiptype(this);
+
+ return pipconfiguration;
+ }
+
+ public PIPConfiguration removePipconfiguration(PIPConfiguration pipconfiguration) {
+ getPipconfigurations().remove(pipconfiguration);
+ pipconfiguration.setPiptype(null);
+
+ return pipconfiguration;
+ }
+
+ @Transient
+ public boolean isSQL() {
+ return this.type.equals(TYPE_SQL);
+ }
+
+ @Transient
+ public boolean isLDAP() {
+ return this.type.equals(TYPE_LDAP);
+ }
+
+ @Transient
+ public boolean isCSV() {
+ return this.type.equals(TYPE_CSV);
+ }
+
+ @Transient
+ public boolean isHyperCSV() {
+ return this.type.equals(TYPE_HYPERCSV);
+ }
+
+ @Transient
+ public boolean isCustom() {
+ return this.type.equals(TYPE_CUSTOM);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PolicyAlgorithms.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PolicyAlgorithms.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PolicyAlgorithms.java
new file mode 100644
index 0000000..d91e221
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/jpa/PolicyAlgorithms.java
@@ -0,0 +1,116 @@
+/*
+ * 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.xacml.admin.jpa;
+
+import java.io.Serializable;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.NamedQuery;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import org.apache.openaz.xacml.api.Identifier;
+
+@Entity
+@Table(name="PolicyAlgorithms")
+@NamedQuery(name="PolicyAlgorithms.findAll", query="SELECT d FROM PolicyAlgorithms d")
+public class PolicyAlgorithms implements Serializable {
+ private static final long serialVersionUID = 1L;
+
+ public static final char STANDARD = 'S';
+ public static final char CUSTOM = 'C';
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ @Column(name="id")
+ private int id;
+
+ @Column(name="is_standard", nullable=false)
+ private char isStandard;
+
+ @Column(name="xacml_id", nullable=false, unique=true, length=255)
+ private String xacmlId;
+
+ @Column(name="short_name", nullable=false, length=64)
+ private String shortName;
+
+ public PolicyAlgorithms(Identifier identifier, char standard) {
+ this.isStandard = standard;
+ if (identifier != null) {
+ this.xacmlId = identifier.stringValue();
+ }
+ }
+
+ public PolicyAlgorithms(Identifier identifier) {
+ this(identifier, PolicyAlgorithms.STANDARD);
+ }
+
+ public PolicyAlgorithms() {
+ this(null, PolicyAlgorithms.STANDARD);
+ }
+
+ public int getId() {
+ return this.id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public char getIsStandard() {
+ return this.isStandard;
+ }
+
+ public void setIsStandard(char isStandard) {
+ this.isStandard = isStandard;
+ }
+
+ @Transient
+ public boolean isStandard() {
+ return this.isStandard == PolicyAlgorithms.STANDARD;
+ }
+
+ @Transient
+ public boolean isCustom() {
+ return this.isStandard == PolicyAlgorithms.CUSTOM;
+ }
+
+ public String getXacmlId() {
+ return this.xacmlId;
+ }
+
+ public void setXacmlId(String xacmlId) {
+ this.xacmlId = xacmlId;
+ }
+
+ public String getShortName() {
+ return shortName;
+ }
+
+ public void setShortName(String shortName) {
+ this.shortName = shortName;
+ }
+
+}
[21/23] incubator-openaz git commit: Ported original att source to
openaz
Posted by pd...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/META-INF/drop.sql
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/META-INF/drop.sql b/openaz-xacml-pap-admin/src/META-INF/drop.sql
new file mode 100644
index 0000000..8aee7ee
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/META-INF/drop.sql
@@ -0,0 +1,21 @@
+DROP TABLE IF EXISTS AttributeAssignment;
+DROP TABLE IF EXISTS ConstraintValues;
+DROP TABLE IF EXISTS ObadviceExpressions;
+DROP TABLE IF EXISTS Attribute;
+DROP TABLE IF EXISTS Category;
+DROP TABLE IF EXISTS ConstraintType;
+DROP VIEW IF EXISTS match_functions;
+DROP VIEW IF EXISTS higherorder_bag_functions;
+DROP VIEW IF EXISTS function_flattener;
+DROP TABLE IF EXISTS FunctionArguments;
+DROP TABLE IF EXISTS FunctionDefinition;
+DROP TABLE IF EXISTS Datatype;
+DROP TABLE IF EXISTS Obadvice;
+DROP TABLE IF EXISTS PIPConfigParams;
+DROP TABLE IF EXISTS PIPResolverParams;
+DROP TABLE IF EXISTS PIPResolver;
+DROP TABLE IF EXISTS PIPConfiguration;
+DROP TABLE IF EXISTS PIPType;
+DROP TABLE IF EXISTS PolicyAlgorithms;
+DROP TABLE IF EXISTS RuleAlgorithms;
+DROP TABLE IF EXISTS SEQUENCE;
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/META-INF/empty.sql
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/META-INF/empty.sql b/openaz-xacml-pap-admin/src/META-INF/empty.sql
new file mode 100644
index 0000000..e69de29
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/META-INF/persistence.xml
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/META-INF/persistence.xml b/openaz-xacml-pap-admin/src/META-INF/persistence.xml
new file mode 100644
index 0000000..79594a9
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/META-INF/persistence.xml
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
+ <persistence-unit name="XACML-PAP-ADMIN">
+ <class>org.apache.openaz.xacml.admin.jpa.Attribute</class>
+ <class>org.apache.openaz.xacml.admin.jpa.AttributeAssignment</class>
+ <class>org.apache.openaz.xacml.admin.jpa.Category</class>
+ <class>org.apache.openaz.xacml.admin.jpa.ConstraintType</class>
+ <class>org.apache.openaz.xacml.admin.jpa.ConstraintValue</class>
+ <class>org.apache.openaz.xacml.admin.jpa.Datatype</class>
+ <class>org.apache.openaz.xacml.admin.jpa.Obadvice</class>
+ <class>org.apache.openaz.xacml.admin.jpa.ObadviceExpression</class>
+ <class>org.apache.openaz.xacml.admin.jpa.PolicyAlgorithms</class>
+ <class>org.apache.openaz.xacml.admin.jpa.RuleAlgorithms</class>
+ <class>org.apache.openaz.xacml.admin.jpa.FunctionArgument</class>
+ <class>org.apache.openaz.xacml.admin.jpa.FunctionDefinition</class>
+ <class>org.apache.openaz.xacml.admin.jpa.PIPConfigParam</class>
+ <class>org.apache.openaz.xacml.admin.jpa.PIPConfiguration</class>
+ <class>org.apache.openaz.xacml.admin.jpa.PIPResolver</class>
+ <class>org.apache.openaz.xacml.admin.jpa.PIPResolverParam</class>
+ <class>org.apache.openaz.xacml.admin.jpa.PIPType</class>
+ <properties>
+ <!--
+ The properties defined below are the default settings to be used when someone initially
+ wants to start working with the XACML-PAP-ADMIN web gui. They are not intended for production
+ use.
+
+ They are setup to drop and create the tables and then load an initial set of data into the database
+ every time the application is deployed. So if you add anything to the dictionaries or PIP
+ configuration, they will get lost upon each deployment. It uses an H2 database engine configured
+ for a local file so you don't have to setup you're own SQL database environment to start.
+
+ Instead of modifying this file directly, please refer to the xacml.admin.properties file for
+ customizing the application settings.
+
+ -->
+ <property name="javax.persistence.schema-generation.database.action" value="drop-and-create"/>
+ <property name="javax.persistence.schema-generation.create-source" value="metadata-then-script"/>
+ <property name="javax.persistence.schema-generation.create-script-source" value="META-INF/views.sql" />
+ <property name="javax.persistence.schema-generation.drop-source" value="script"/>
+ <property name="javax.persistence.schema-generation.drop-script-source" value="META-INF/drop.sql" />
+ <property name="javax.persistence.sql-load-script-source" value="META-INF/data.sql" />
+
+ <!--
+
+ These properties should be set in the xacml.admin.properties file, so they can be re-used by non-JPA
+ database functionality.
+
+ <property name="javax.persistence.jdbc.driver" value="org.h2.Driver"/>
+ <property name="javax.persistence.jdbc.url" value="jdbc:h2:file:sql/xacml"/>
+ <property name="javax.persistence.jdbc.user" value="sa"/>
+ <property name="javax.persistence.jdbc.password" value=""/>
+ -->
+ </properties>
+ </persistence-unit>
+</persistence>
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/META-INF/views.sql
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/META-INF/views.sql b/openaz-xacml-pap-admin/src/META-INF/views.sql
new file mode 100644
index 0000000..7c4a820
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/META-INF/views.sql
@@ -0,0 +1,6 @@
+
+CREATE VIEW match_functions AS SELECT D.ID AS id, D.SHORT_NAME AS shortname, D.XACML_ID AS xacmlid, D.RETURN_DATATYPE AS return_datatype, D.IS_BAG_RETURN AS is_bag_return, D.ARG_LB AS arg_lb, D.ARG_UB AS arg_ub, A1.IS_BAG AS arg1_isbag, A1.DATATYPE_ID AS arg1_datatype, A2.IS_BAG AS arg2_isbag, A2.DATATYPE_ID AS arg2_datatype FROM (FunctionDefinition D left join FunctionArguments A1 on (A1.FUNCTION_ID = D.ID and A1.ARG_INDEX = 1) left join FunctionArguments A2 on (A2.FUNCTION_ID = D.ID and A2.ARG_INDEX = 2)) where (D.ARG_LB = 2 and D.ARG_UB = 2 and D.RETURN_DATATYPE = 18 and A1.IS_BAG = 0) order by D.SHORT_NAME;
+
+CREATE VIEW function_flattener AS SELECT D.ID AS id, D.SHORT_NAME AS shortname, D.RETURN_DATATYPE AS return_datatype, D.IS_BAG_RETURN AS is_bag_return, D.IS_HIGHER_ORDER AS is_higher_order, D.ARG_LB AS arg_lb, D.ARG_UB AS arg_ub, A1.IS_BAG AS arg1_isbag, A1.DATATYPE_ID AS arg1_datatype, A2.IS_BAG AS arg2_isbag, A2.DATATYPE_ID AS arg2_datatype, A3.IS_BAG AS arg3_isbag, A3.DATATYPE_ID AS arg3_datatype FROM (FunctionDefinition D left join FunctionArguments A1 ON (A1.FUNCTION_ID = D.ID and A1.ARG_INDEX = 1) left join FunctionArguments A2 ON (A2.FUNCTION_ID = D.ID and A2.ARG_INDEX = 2) LEFT JOIN FunctionArguments A3 ON (A3.FUNCTION_ID = D.ID and A3.ARG_INDEX = 3)) ORDER BY D.ID;
+
+CREATE VIEW higherorder_bag_functions AS SELECT * FROM function_flattener WHERE is_higher_order = 1 AND is_bag_return = 1 AND return_datatype=18 AND arg_lb=2 AND arg_ub=2 AND arg1_isbag = 1 AND (arg2_isbag = 1 OR arg2_isbag IS NULL);
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/PAPNotificationBroadcaster.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/PAPNotificationBroadcaster.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/PAPNotificationBroadcaster.java
new file mode 100644
index 0000000..b2deda7
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/PAPNotificationBroadcaster.java
@@ -0,0 +1,120 @@
+/*
+ * 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.xacml.admin;
+
+import java.io.Serializable;
+import java.util.LinkedList;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Handle Notifications from the PAP that the PDP Groups have been changed.
+ * We need a Server Push Broadcaster because there may be multiple Vaadin instances (i.e. Users) that need to be told when a change occurs.
+ *
+ * Initially we only update the entire set of PDPGroups in one shot.
+ *
+ * (Code copied from Book of Vaadin chapter on Server Push
+ * @author glenngriffin
+ *
+ */
+public class PAPNotificationBroadcaster implements Serializable {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -2539940306348821754L;
+
+
+ private static Log logger = LogFactory.getLog(PAPNotificationBroadcaster.class);
+
+
+ static ExecutorService executorService = Executors.newSingleThreadExecutor();
+
+ /**
+ * Interface used by all classes that need to be notified when PAP sends an update message.
+ *
+ * @author glenngriffin
+ *
+ */
+ public interface PAPNotificationBroadcastListener {
+ void updateAllGroups();
+ }
+
+
+
+ /*
+ * list of registered listeners
+ */
+ private static LinkedList<PAPNotificationBroadcastListener> listeners =
+ new LinkedList<PAPNotificationBroadcastListener>();
+
+ /**
+ * Listener registers to hear about updates.
+ * @param listener
+ */
+ public static synchronized void register(
+ PAPNotificationBroadcastListener listener) {
+ listeners.add(listener);
+ }
+
+
+ /**
+ * Listener is going away.
+ *
+ * @param listener
+ */
+ public static synchronized void unregister(
+ PAPNotificationBroadcastListener listener) {
+ listeners.remove(listener);
+ }
+
+
+
+ /**
+ * Tell all listeners about an update.
+ *
+ * @param message
+ */
+ public static synchronized void updateAllGroups() {
+ for (final PAPNotificationBroadcastListener listener: listeners) {
+ // Original code copied from example:
+ // executorService.execute(new Runnable() {
+ // @Override
+ // public void run() {
+ // The problem with this is that the execute starts a new Thread, but the thing we are calling (the listener.updateAllGroups)
+ // happens in this case to ALSO create a new thread, and it locks up because the shared threadpool queue is already locked by this method.
+ // On application shutdown that left us with a blocked thread, so the process never goes away.
+ // Since the listener.updateAllGroups does ALL of its work inside a new Runnable thread, there should be no need for this method to also create a thread.
+
+ /*
+ * IMPORTANT:
+ * All listeners MUST either execute with no possibility of blocking
+ * OR must start their own threads to handle blocking and concurrent operations.
+ */
+ if (logger.isDebugEnabled()) {
+ logger.debug("updateAllGroups");
+ }
+ listener.updateAllGroups();
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlAdminAuthorization.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlAdminAuthorization.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlAdminAuthorization.java
new file mode 100644
index 0000000..2a065d5
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlAdminAuthorization.java
@@ -0,0 +1,178 @@
+/*
+ * 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.xacml.admin;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.std.annotations.XACMLRequest;
+import org.apache.openaz.xacml.std.annotations.RequestParser;
+import org.apache.openaz.xacml.std.annotations.XACMLSubject;
+import org.apache.openaz.xacml.std.annotations.XACMLAction;
+import org.apache.openaz.xacml.std.annotations.XACMLResource;
+import org.apache.openaz.xacml.api.DataTypeException;
+import org.apache.openaz.xacml.api.Decision;
+import org.apache.openaz.xacml.api.Request;
+import org.apache.openaz.xacml.api.Response;
+import org.apache.openaz.xacml.api.Result;
+import org.apache.openaz.xacml.api.pdp.PDPEngine;
+import org.apache.openaz.xacml.api.pdp.PDPEngineFactory;
+import org.apache.openaz.xacml.api.pdp.PDPException;
+import org.apache.openaz.xacml.util.FactoryException;
+
+public class XacmlAdminAuthorization {
+ private static Log logger = LogFactory.getLog(XacmlAdminAuthorization.class);
+
+ public enum AdminAction {
+ ACTION_ACCESS("access"),
+ ACTION_READ("read"),
+ ACTION_WRITE("write"),
+ ACTION_ADMIN("admin");
+
+ String action;
+ AdminAction(String a) {
+ this.action = a;
+ }
+ public String toString() {
+ return this.action;
+ }
+ }
+
+ public enum AdminResource {
+ RESOURCE_APPLICATION("application"),
+ RESOURCE_POLICY_WORKSPACE("workspace"),
+ RESOURCE_POLICY_EDITOR("editor"),
+ RESOURCE_DICTIONARIES("dictionaries"),
+ RESOURCE_PDP_ADMIN("pdp_admin"),
+ RESOURCE_PIP_ADMIN("pip_admin");
+
+ String resource;
+ AdminResource(String r) {
+ this.resource = r;
+ }
+ public String toString() {
+ return this.resource;
+ }
+ }
+
+ @XACMLRequest(ReturnPolicyIdList=true)
+ public class AuthorizationRequest {
+
+ @XACMLSubject(includeInResults=true)
+ String userID;
+
+ @XACMLAction()
+ String action;
+
+ @XACMLResource()
+ String resource;
+
+ public AuthorizationRequest(String userId, String action, String resource) {
+ this.userID = userId;
+ this.action = action;
+ this.resource = resource;
+ }
+
+ public String getUserID() {
+ return userID;
+ }
+
+ public void setUserID(String userID) {
+ this.userID = userID;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ public String getResource() {
+ return resource;
+ }
+
+ public void setResource(String resource) {
+ this.resource = resource;
+ }
+ }
+
+ //
+ // The PDP Engine
+ //
+ protected PDPEngine pdpEngine;
+
+ public XacmlAdminAuthorization() {
+ PDPEngineFactory pdpEngineFactory = null;
+ try {
+ pdpEngineFactory = PDPEngineFactory.newInstance();
+ if (pdpEngineFactory == null) {
+ logger.error("Failed to create PDP Engine Factory");
+ }
+ this.pdpEngine = pdpEngineFactory.newEngine();
+ } catch (FactoryException e) {
+ logger.error("Exception create PDP Engine: " + e.getLocalizedMessage());
+ }
+ }
+
+ public boolean isAuthorized(String userid, AdminAction action, AdminResource resource) {
+ logger.info("authorize: " + userid + " to " + action + " with " + resource);
+ if (this.pdpEngine == null) {
+ logger.warn("no pdp engine available to authorize");
+ return false;
+ }
+ Request request;
+ try {
+ request = RequestParser.parseRequest(new AuthorizationRequest(userid, action.toString(), resource.toString()));
+ } catch (IllegalArgumentException | IllegalAccessException | DataTypeException e) {
+ logger.error("Failed to create request: " + e.getLocalizedMessage());
+ return false;
+ }
+ if (request == null) {
+ logger.error("Failed to parse request.");
+ return false;
+ }
+ logger.info("Request: " + request);
+ //
+ // Ask the engine
+ //
+ try {
+ Response response = this.pdpEngine.decide(request);
+ if (response == null) {
+ logger.error("Null response from PDP decide");
+ }
+ //
+ // Should only be one result
+ //
+ for (Result result : response.getResults()) {
+ Decision decision = result.getDecision();
+ logger.info("Decision: " + decision);
+ if (decision.equals(Decision.PERMIT)) {
+ return true;
+ }
+ }
+ } catch (PDPException e) {
+ logger.error("PDP Decide failed: " + e.getLocalizedMessage());
+ }
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlAdminConsole.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlAdminConsole.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlAdminConsole.java
new file mode 100644
index 0000000..91e831b
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlAdminConsole.java
@@ -0,0 +1,253 @@
+/*
+ * 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.xacml.admin;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.components.AttributeDictionary;
+import org.apache.openaz.xacml.admin.components.ObadviceDictionary;
+import org.apache.openaz.xacml.admin.components.PDPManagement;
+import org.apache.openaz.xacml.admin.components.PIPManagement;
+import org.apache.openaz.xacml.admin.components.PolicyWorkspace;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.navigator.View;
+import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
+import com.vaadin.server.ThemeResource;
+import com.vaadin.shared.ui.label.ContentMode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Embedded;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.TabSheet;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+
+public class XacmlAdminConsole extends CustomComponent implements View {
+ private static final long serialVersionUID = 1L;
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Label labelCopyright;
+ @AutoGenerated
+ private TabSheet tabSheet;
+ @AutoGenerated
+ private HorizontalLayout horizontalLayout_1;
+ @AutoGenerated
+ private Label labelWelcome;
+ @AutoGenerated
+ private Label caption;
+ @AutoGenerated
+ private Embedded embedded_1;
+
+ private static Log logger = LogFactory.getLog(XacmlAdminConsole.class);
+
+ private final PolicyWorkspace policyWorkspace;
+ private final AttributeDictionary attributeDictionary;
+ private final ObadviceDictionary obadvice;
+ private final PDPManagement pdp;
+ private final PIPManagement pip;
+// private final UserManagement user;
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public XacmlAdminConsole() {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Creating tabs...");
+ }
+
+ this.labelWelcome.setValue("Welcome " + ((XacmlAdminUI)UI.getCurrent()).getUserName());
+ this.labelCopyright.setContentMode(ContentMode.HTML);
+
+ if (((XacmlAdminUI)UI.getCurrent()).isAuthorized(
+ XacmlAdminAuthorization.AdminAction.ACTION_READ,
+ XacmlAdminAuthorization.AdminResource.RESOURCE_POLICY_WORKSPACE)) {
+ this.policyWorkspace = new PolicyWorkspace();
+ this.tabSheet.addComponent(this.policyWorkspace);
+ this.tabSheet.getTab(this.policyWorkspace).setCaption("Policy Workspace");
+ } else {
+ this.policyWorkspace = null;
+ }
+
+ if (((XacmlAdminUI)UI.getCurrent()).isAuthorized(
+ XacmlAdminAuthorization.AdminAction.ACTION_READ,
+ XacmlAdminAuthorization.AdminResource.RESOURCE_DICTIONARIES)) {
+ this.attributeDictionary = new AttributeDictionary();
+ this.tabSheet.addComponent(this.attributeDictionary);
+ this.tabSheet.getTab(this.attributeDictionary).setCaption("Attribute Dictionary");
+
+ this.obadvice = new ObadviceDictionary();
+ this.tabSheet.addComponent(this.obadvice);
+ this.tabSheet.getTab(this.obadvice).setCaption("Obligation/Advice Dictionary");
+ } else {
+ this.attributeDictionary = null;
+ this.obadvice = null;
+ }
+ if (((XacmlAdminUI)UI.getCurrent()).isAuthorized(
+ XacmlAdminAuthorization.AdminAction.ACTION_READ,
+ XacmlAdminAuthorization.AdminResource.RESOURCE_PDP_ADMIN)) {
+ this.pdp = new PDPManagement(((XacmlAdminUI)UI.getCurrent()).getPAPEngine());
+ this.tabSheet.addComponent(this.pdp);
+ this.tabSheet.getTab(this.pdp).setCaption("PDP Management");
+ } else {
+ this.pdp = null;
+ }
+
+ if (((XacmlAdminUI)UI.getCurrent()).isAuthorized(
+ XacmlAdminAuthorization.AdminAction.ACTION_READ,
+ XacmlAdminAuthorization.AdminResource.RESOURCE_PIP_ADMIN)) {
+ this.pip = new PIPManagement();
+ this.tabSheet.addComponent(this.pip);
+ this.tabSheet.getTab(this.pip).setCaption("PIP Management");
+ } else {
+ this.pip = null;
+ }
+ /*
+ * TODO - figure out how to add this in
+ *
+ if (((XacmlAdminUI)UI.getCurrent()).isAuthorized(
+ XacmlAdminAuthorization.AdminAction.ACTION_READ,
+ XacmlAdminAuthorization.AdminResource.RESOURCE_POLICY_WORKSPACE)) {
+ this.user = new UserManagement();
+ this.tabSheet.addComponent(this.user);
+ this.tabSheet.getTab(this.user).setCaption("User Management");
+ }
+ */
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Done creating tabs.");
+ }
+ }
+
+ public void refreshAttributes() {
+ this.attributeDictionary.refreshContainer();
+ }
+ public void refreshObadvice() {
+ this.obadvice.refreshContainer();
+ }
+
+ public void refreshPIPConfiguration() {
+ this.pip.refreshContainer();
+ }
+
+ public void refreshPDPGroups() {
+ this.pdp.refreshContainer();
+ }
+
+ public TabSheet getTabSheet() { return tabSheet;}
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("100%");
+ mainLayout.setHeight("100%");
+ mainLayout.setMargin(true);
+
+ // top-level component properties
+ setWidth("100.0%");
+ setHeight("100.0%");
+
+ // horizontalLayout_1
+ horizontalLayout_1 = buildHorizontalLayout_1();
+ mainLayout.addComponent(horizontalLayout_1);
+
+ // tabSheet
+ tabSheet = new TabSheet();
+ tabSheet.setImmediate(false);
+ tabSheet.setWidth("100.0%");
+ tabSheet.setHeight("100.0%");
+ mainLayout.addComponent(tabSheet);
+ mainLayout.setExpandRatio(tabSheet, 1.0f);
+
+ // labelCopyright
+ labelCopyright = new Label();
+ labelCopyright.setImmediate(false);
+ labelCopyright.setWidth("-1px");
+ labelCopyright.setHeight("40px");
+ labelCopyright
+ .setValue("<center>Copyright © 2015 The Apache Software Foundation, Licensed under the Apache License, Version 2.0.</center>");
+ mainLayout.addComponent(labelCopyright);
+ mainLayout.setComponentAlignment(labelCopyright, new Alignment(48));
+
+ return mainLayout;
+ }
+
+ @AutoGenerated
+ private HorizontalLayout buildHorizontalLayout_1() {
+ // common part: create layout
+ horizontalLayout_1 = new HorizontalLayout();
+ horizontalLayout_1.setImmediate(false);
+ horizontalLayout_1.setWidth("100.0%");
+ horizontalLayout_1.setHeight("40px");
+ horizontalLayout_1.setMargin(false);
+
+ // embedded_1
+ embedded_1 = new Embedded();
+ embedded_1.setImmediate(false);
+ embedded_1.setWidth("30px");
+ embedded_1.setHeight("30px");
+ embedded_1.setSource(new ThemeResource("img/att.png"));
+ embedded_1.setType(1);
+ embedded_1.setMimeType("image/png");
+ horizontalLayout_1.addComponent(embedded_1);
+ horizontalLayout_1.setComponentAlignment(embedded_1, new Alignment(33));
+
+ // caption
+ caption = new Label();
+ caption.setImmediate(false);
+ caption.setWidth("-1px");
+ caption.setHeight("-1px");
+ caption.setValue("Apache OpenAZ Admin Console");
+ horizontalLayout_1.addComponent(caption);
+ horizontalLayout_1.setExpandRatio(caption, 1.0f);
+ horizontalLayout_1.setComponentAlignment(caption, new Alignment(33));
+
+ // labelWelcome
+ labelWelcome = new Label();
+ labelWelcome.setImmediate(false);
+ labelWelcome.setWidth("-1px");
+ labelWelcome.setHeight("40px");
+ labelWelcome.setValue("Label");
+ horizontalLayout_1.addComponent(labelWelcome);
+ horizontalLayout_1.setComponentAlignment(labelWelcome,
+ new Alignment(34));
+
+ return horizontalLayout_1;
+ }
+
+ @Override
+ public void enter(ViewChangeEvent event) {
+ //
+ // This needs to be implemented
+ //
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlAdminServlet.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlAdminServlet.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlAdminServlet.java
new file mode 100644
index 0000000..fa48543
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlAdminServlet.java
@@ -0,0 +1,97 @@
+/*
+ * 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.xacml.admin;
+
+import java.io.IOException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.annotation.WebInitParam;
+import javax.servlet.annotation.WebServlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.vaadin.annotations.Push;
+import com.vaadin.annotations.VaadinServletConfiguration;
+import com.vaadin.server.VaadinServlet;
+
+import org.apache.openaz.xacml.rest.XACMLRest;
+
+
+//
+// The Servlet underlying the Vaadin Servlet
+//
+@Push
+@WebServlet(
+ value = "/*",
+ description = "XACML Admin Console",
+ asyncSupported = true,
+ loadOnStartup=1,
+ initParams = {
+ @WebInitParam(name = "XACML_PROPERTIES_NAME", value = "xacml.admin.properties", description = "The location of the properties file holding configuration information.")
+})
+@VaadinServletConfiguration(productionMode = false, ui = XacmlAdminUI.class)
+public class XacmlAdminServlet extends VaadinServlet {
+ //
+ // All static declarations
+ //
+ private static Log logger = LogFactory.getLog(XacmlAdminServlet.class); //NOPMD
+
+ @Override
+ public void init(ServletConfig servletConfig) throws ServletException {
+ super.init(servletConfig);
+ //
+ // Common initialization
+ //
+ XACMLRest.xacmlInit(servletConfig);
+
+ // Initialization
+ XacmlAdminUI.servletInit();
+ }
+
+ @Override
+ public void destroy() {
+ XacmlAdminUI.servletDestroy();
+ super.destroy();
+ }
+
+ /**
+ *
+ * Called by:
+ * - PAP to notify Vaadin GUIs that something has changed
+ *
+ * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
+ */
+ @Override
+ protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ // watch for notifications from the PAP
+ if (request.getMethod().equals("PUT") && request.getParameter("PAPNotification") != null) {
+ XacmlAdminUI.doPAPNotification(request, response);
+ return;
+ }
+
+ // not a PAP notification, so let Vaadin handle normally
+ super.service(request,response);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlAdminUI.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlAdminUI.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlAdminUI.java
new file mode 100644
index 0000000..e553749
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlAdminUI.java
@@ -0,0 +1,801 @@
+/*
+ * 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.xacml.admin;
+
+import java.io.IOException;
+import java.net.URI;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.sql.SQLException;
+import java.util.Properties;
+import java.util.UUID;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityManagerFactory;
+import javax.persistence.Persistence;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.api.errors.InvalidRemoteException;
+import org.eclipse.jgit.api.errors.TransportException;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.lib.StoredConfig;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.persistence.config.PersistenceUnitProperties;
+
+import org.apache.openaz.xacml.admin.XacmlAdminAuthorization.AdminAction;
+import org.apache.openaz.xacml.admin.XacmlAdminAuthorization.AdminResource;
+import org.apache.openaz.xacml.admin.converters.XacmlConverterFactory;
+import org.apache.openaz.xacml.admin.jpa.Attribute;
+import org.apache.openaz.xacml.admin.jpa.Category;
+import org.apache.openaz.xacml.admin.jpa.ConstraintType;
+import org.apache.openaz.xacml.admin.jpa.Datatype;
+import org.apache.openaz.xacml.admin.jpa.FunctionArgument;
+import org.apache.openaz.xacml.admin.jpa.FunctionDefinition;
+import org.apache.openaz.xacml.admin.jpa.Obadvice;
+import org.apache.openaz.xacml.admin.jpa.ObadviceExpression;
+import org.apache.openaz.xacml.admin.jpa.PIPConfiguration;
+import org.apache.openaz.xacml.admin.jpa.PIPResolver;
+import org.apache.openaz.xacml.admin.jpa.PIPType;
+import org.apache.openaz.xacml.admin.jpa.PolicyAlgorithms;
+import org.apache.openaz.xacml.admin.jpa.RuleAlgorithms;
+import org.apache.openaz.xacml.admin.model.MatchFunctionQueryDelegate;
+import org.apache.openaz.xacml.admin.util.RESTfulPAPEngine;
+import org.apache.openaz.xacml.api.XACML3;
+import org.apache.openaz.xacml.api.pap.PAPEngine;
+import org.apache.openaz.xacml.api.pap.PAPException;
+import org.apache.openaz.xacml.rest.XACMLRestProperties;
+import org.apache.openaz.xacml.util.XACMLProperties;
+import com.google.gwt.thirdparty.guava.common.base.Joiner;
+import com.google.gwt.thirdparty.guava.common.base.Splitter;
+import com.vaadin.addon.jpacontainer.JPAContainer;
+import com.vaadin.addon.jpacontainer.provider.CachingLocalEntityProvider;
+import com.vaadin.addon.jpacontainer.provider.CachingMutableLocalEntityProvider;
+import com.vaadin.annotations.Push;
+import com.vaadin.annotations.Theme;
+import com.vaadin.data.util.sqlcontainer.SQLContainer;
+import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool;
+import com.vaadin.data.util.sqlcontainer.query.FreeformQuery;
+import com.vaadin.navigator.Navigator;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.server.VaadinServletService;
+import com.vaadin.ui.UI;
+
+@Push
+@SuppressWarnings("serial")
+@Theme("xacml_pap_admin")
+public class XacmlAdminUI extends UI implements PAPNotificationBroadcaster.PAPNotificationBroadcastListener {
+ //
+ // All static declarations
+ //
+ public static final String PERSISTENCE_UNIT = "XACML-PAP-ADMIN";
+ private static Log logger = LogFactory.getLog(XacmlAdminUI.class); //NOPMD
+
+ /*
+ * These objects are shared amongst sessions.
+ */
+ private static Path repositoryPath;
+ private static Repository repository;
+ private static EntityManagerFactory emf;
+ private static JDBCConnectionPool pool;
+
+ /*
+ * These objects are created each session.
+ */
+ private Path workspacePath;
+ private Path gitPath;
+ //
+ // Our Persistence Fields. For general use. NOTE: Be careful applying
+ // filters to these container objects. If one window applies a filter, then
+ // when another window uses the object, that filter will show up and cause confusion.
+ // If filters are needed within a window, then create another instance instead of
+ // using one of these pointers.
+ //
+ private EntityManager em;
+ private JPAContainer<Attribute> attributes;
+ private JPAContainer<ConstraintType> constraintTypes;
+ private JPAContainer<Obadvice> obadvice;
+ private JPAContainer<ObadviceExpression> obadviceExpressions;
+ private JPAContainer<Category> categories;
+ private JPAContainer<Datatype> datatypes;
+ private JPAContainer<PolicyAlgorithms> policyAlgorithms;
+ private JPAContainer<RuleAlgorithms> ruleAlgorithms;
+ private JPAContainer<PIPConfiguration> pipConfigurations;
+ private JPAContainer<PIPResolver> pipResolvers;
+ private JPAContainer<PIPType> pipTypes;
+ private JPAContainer<FunctionDefinition> functionDefinitions;
+ private JPAContainer<FunctionArgument> functionArguments;
+ private SQLContainer matchFunctionContainer;
+ private SQLContainer higherorderBagContainer;
+ //
+ // Our authorization object
+ //
+ XacmlAdminAuthorization authorizer = new XacmlAdminAuthorization();
+ //
+ // The PAP Engine
+ //
+ private PAPEngine papEngine;
+ //
+ // GUI navigation
+ //
+ private Navigator navigator = null;
+ private XacmlAdminConsole console = null;
+ //
+ // Vaadin Init
+ //
+ @Override
+ protected void init(VaadinRequest request) {
+ //
+ // Set our title
+ //
+ this.getPage().setTitle("Apache OpenAZ Admin Console");
+ //
+ // Create our authorization object
+ //
+ this.authorizer = new XacmlAdminAuthorization();
+ //
+ // Is the user authorized to use the application?
+ //
+ if (this.authorizer.isAuthorized(this.getUserid(),
+ XacmlAdminAuthorization.AdminAction.ACTION_ACCESS,
+ XacmlAdminAuthorization.AdminResource.RESOURCE_APPLICATION) == false) {
+ logger.error("user " + this.getUserid() + " is not authorized.");
+ //
+ // Create a navigator to manage all our views
+ //
+ this.navigator = new Navigator(this, this);
+ //
+ // Redirect to an error page
+ //
+ this.navigator.addView(XacmlErrorHandler.VIEWNAME, new XacmlErrorHandler("User " + this.getUserid() + " is not authorized to access application", null));
+ this.navigator.navigateTo(XacmlErrorHandler.VIEWNAME);
+ return;
+ }
+ try {
+ //
+ // Initialize user's Git repository
+ //
+ this.workspacePath = Paths.get(XACMLProperties.getProperty(XACMLRestProperties.PROP_ADMIN_WORKSPACE), this.getUserid());
+ this.gitPath = XacmlAdminUI.initializeUserRepository(this.workspacePath, this.getUserid(), this.getUserEmail());
+ } catch (Exception e) {
+ logger.error("Git Setup failure", e);
+ //
+ // Create a navigator to manage all our views
+ //
+ this.navigator = new Navigator(this, this);
+ //
+ // Redirect to an error page
+ //
+ this.navigator.addView(XacmlErrorHandler.VIEWNAME, new XacmlErrorHandler(e.getMessage(), null));
+ this.navigator.navigateTo(XacmlErrorHandler.VIEWNAME);
+ return;
+ }
+ //
+ // Create a navigator to manage all our views
+ //
+ this.navigator = new Navigator(this, this);
+ //
+ // Set our converter factory
+ //
+ this.getSession().setConverterFactory(new XacmlConverterFactory());
+ //
+ // Initialize our data objects
+ //
+ try {
+ //
+ // Initialize JPA and SQL. Create our custom entity manager.
+ //
+ logger.info("Creating Persistence Entity Manager");
+ //
+ // Now create the entity manager. This is used throughout the application to create JPA
+ // containers of the entities located in the database.
+ //
+ this.em = XacmlAdminUI.emf.createEntityManager();
+ //
+ // Our Read-Only containers
+ //
+ logger.info("Creating JPA read-only containers");
+ this.constraintTypes = new JPAContainer<ConstraintType>(ConstraintType.class);
+ this.constraintTypes.setEntityProvider(new CachingLocalEntityProvider<ConstraintType>(ConstraintType.class, this.em));
+
+ this.categories = new JPAContainer<Category>(Category.class);
+ this.categories.setEntityProvider(new CachingLocalEntityProvider<Category>(Category.class, this.em));
+
+ this.datatypes = new JPAContainer<Datatype>(Datatype.class);
+ this.datatypes.setEntityProvider(new CachingLocalEntityProvider<Datatype>(Datatype.class, this.em));
+
+ this.policyAlgorithms = new JPAContainer<PolicyAlgorithms>(PolicyAlgorithms.class);
+ this.policyAlgorithms.setEntityProvider(new CachingLocalEntityProvider<PolicyAlgorithms>(PolicyAlgorithms.class, this.em));
+
+ this.ruleAlgorithms = new JPAContainer<RuleAlgorithms>(RuleAlgorithms.class);
+ this.ruleAlgorithms.setEntityProvider(new CachingLocalEntityProvider<RuleAlgorithms>(RuleAlgorithms.class, this.em));
+
+ this.pipTypes = new JPAContainer<PIPType>(PIPType.class);
+ this.pipTypes.setEntityProvider(new CachingLocalEntityProvider<PIPType>(PIPType.class, this.em));
+
+ this.functionDefinitions = new JPAContainer<FunctionDefinition>(FunctionDefinition.class);
+ this.functionDefinitions.setEntityProvider(new CachingLocalEntityProvider<FunctionDefinition>(FunctionDefinition.class, this.em));
+
+ this.functionArguments = new JPAContainer<FunctionArgument>(FunctionArgument.class);
+ this.functionArguments.setEntityProvider(new CachingLocalEntityProvider<FunctionArgument>(FunctionArgument.class, this.em));
+ //
+ // Our writable containers. NOTE: The dictionaries have their own JPA instance since they can
+ // apply filters to their table views. If you update these, then refresh the dictionary containers
+ // by calling the appropriate refresh method defined in XacmlAdminUI.
+ //
+ logger.info("Creating JPA writable containers");
+ this.attributes = new JPAContainer<Attribute>(Attribute.class);
+ this.attributes.setEntityProvider(new CachingMutableLocalEntityProvider<Attribute>(Attribute.class, this.em));
+
+ this.obadvice = new JPAContainer<Obadvice>(Obadvice.class);
+ this.obadvice.setEntityProvider(new CachingMutableLocalEntityProvider<Obadvice>(Obadvice.class, this.em));
+
+ this.obadviceExpressions = new JPAContainer<ObadviceExpression>(ObadviceExpression.class);
+ this.obadviceExpressions.setEntityProvider(new CachingMutableLocalEntityProvider<ObadviceExpression>(ObadviceExpression.class, this.em));
+
+ this.pipConfigurations = new JPAContainer<PIPConfiguration>(PIPConfiguration.class);
+ this.pipConfigurations.setEntityProvider(new CachingMutableLocalEntityProvider<PIPConfiguration>(PIPConfiguration.class, this.em));
+
+ this.pipResolvers = new JPAContainer<PIPResolver>(PIPResolver.class);
+ this.pipResolvers.setEntityProvider(new CachingMutableLocalEntityProvider<PIPResolver>(PIPResolver.class, this.em));
+ //
+ // Sort our persistence data
+ //
+ logger.info("Sorting containers");
+ this.categories.sort(new String[]{"xacmlId"}, new boolean[]{true});
+ this.datatypes.sort(new String[]{"xacmlId"}, new boolean[]{true});
+ this.policyAlgorithms.sort(new String[]{"xacmlId"}, new boolean[]{true});
+ this.ruleAlgorithms.sort(new String[]{"xacmlId"}, new boolean[]{true});
+ this.functionDefinitions.sort(new String[]{"xacmlid"}, new boolean[]{true});
+ //this.functionArguments.sort(new String[]{"datatypeBean"}, new boolean[]{true});
+ //
+ // Create our special query for MatchType functions. We need a custom
+ // QueryDelegate because these functions are accessible via a View (vs a Table).
+ // The basic FreeformQuery does not work with filters on a View (via Vaadin).
+ //
+ // TODO: Consider putting this into a couple of Map's. Doing so would speed up
+ // access. However, if we want to support custom functions, then there needs to
+ // be a way for those custom functions to get into the Map. This is why a database
+ // is being used to store ALL the functions, both standard and custom.
+ //
+ logger.info("Creating SQL Queries");
+ MatchFunctionQueryDelegate delegate = new MatchFunctionQueryDelegate();
+ FreeformQuery query = new FreeformQuery("SELECT * FROM match_functions", XacmlAdminUI.pool, new String[] {});
+ query.setDelegate(delegate);
+ this.matchFunctionContainer = new SQLContainer(query);
+ //
+ // Same for this one
+ //
+ delegate = new MatchFunctionQueryDelegate();
+ query = new FreeformQuery("SELECT * FROM higherorder_bag_functions", XacmlAdminUI.pool, new String[] {});
+ query.setDelegate(delegate);
+ this.higherorderBagContainer = new SQLContainer(query);
+ //
+ // Load our PAP engine
+ //
+ logger.info("Creating PAP engine");
+ String myRequestURL = VaadinServletService.getCurrentServletRequest().getRequestURL().toString();
+ try {
+ //
+ // Set the URL for the RESTful PAP Engine
+ //
+ papEngine = new RESTfulPAPEngine(myRequestURL);
+ } catch (PAPException e ) {
+ logger.error("Failed to create PAP engine", e);
+ } catch (Exception e) {
+ logger.error("Failed to create PAP engine", e);
+ }
+ logger.info("done creating connections");
+ } catch(Exception e) {
+ //
+ // Redirect to an error page
+ //
+ logger.error(e);
+ e.printStackTrace();
+ this.navigator.addView("", new XacmlErrorHandler(e.getMessage(), null));
+ this.navigator.navigateTo("");
+ return;
+ }
+ logger.info("Creating main layout");
+ //
+ // Create our main component layout
+ //
+ this.console = new XacmlAdminConsole();
+ this.navigator.addView("", console);
+ this.navigator.setErrorView(new XacmlErrorHandler(null, null));
+ //
+ // Navigate to our view
+ //
+ this.navigator.navigateTo("");
+ //
+ // Register to receive PAP change notifications broadcasts
+ //
+ PAPNotificationBroadcaster.register(this);
+ }
+
+ public static void servletInit() throws ServletException {
+ //
+ // Initialize GIT repository.
+ //
+ XacmlAdminUI.initializeGitRepository();
+ //
+ // Initialize Entity Factory
+ //
+ XacmlAdminUI.initializeEntityFactory();
+ //
+ // If we get here, then the configuration information
+ // seems ok.
+ //
+ }
+
+ public static void servletDestroy() {
+ if (XacmlAdminUI.repository != null) {
+ XacmlAdminUI.repository.close();
+ }
+ }
+
+ /**
+ * An Update Notification has arrived from the PAP.
+ * Tell the Vaadin users to change their data.
+ *
+ * @param request
+ * @param response
+ * @throws ServletException
+ * @throws IOException
+ */
+ public static void doPAPNotification(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+ try {
+ //
+ // Notify all user instances to update groups
+ //
+ PAPNotificationBroadcaster.updateAllGroups();
+ } catch (Exception e) {
+ logger.error("Unable to process PAP request: "+e, e);
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
+ }
+ response.setStatus(HttpServletResponse.SC_NO_CONTENT);
+ }
+
+ // Must unregister when the UI expires
+ @Override
+ public void detach() {
+ PAPNotificationBroadcaster.unregister(this);
+ super.detach();
+ }
+
+ /**
+ * This will initialize the JPA Entity Manager Factory. This will determine if
+ * the database connection settings are correct.
+ *
+ * @throws ServletException
+ */
+ private static void initializeEntityFactory() throws ServletException {
+ logger.info("intializing Persistence Entity Factory");
+ //
+ // Pull custom persistence settings
+ //
+ Properties properties;
+ try {
+ properties = XACMLProperties.getProperties();
+ } catch (IOException e) {
+ throw new ServletException(e.getMessage(), e.getCause());
+ }
+ //
+ // Create the factory
+ //
+ emf = Persistence.createEntityManagerFactory(XacmlAdminUI.PERSISTENCE_UNIT, properties);
+ //
+ // Did it get created?
+ //
+ if (emf == null) {
+ throw new ServletException("Unable to create Entity Manager Factory");
+ }
+ //
+ // Create our JDBC connection pool
+ //
+ try {
+ logger.info("intializing JDBC Connection Pool");
+ XacmlAdminUI.pool = new XacmlJDBCConnectionPool(
+ properties.getProperty(PersistenceUnitProperties.JDBC_DRIVER),
+ properties.getProperty(PersistenceUnitProperties.JDBC_URL),
+ properties.getProperty(PersistenceUnitProperties.JDBC_USER),
+ properties.getProperty(PersistenceUnitProperties.JDBC_PASSWORD));
+ } catch (SQLException e) {
+ throw new ServletException(e.getMessage(), e.getCause());
+ }
+ }
+
+ private static void initializeGitRepository() throws ServletException {
+ XacmlAdminUI.repositoryPath = Paths.get(XACMLProperties.getProperty(XACMLRestProperties.PROP_ADMIN_REPOSITORY));
+ FileRepositoryBuilder builder = new FileRepositoryBuilder();
+ try {
+ XacmlAdminUI.repository = builder.setGitDir(XacmlAdminUI.repositoryPath.toFile()).readEnvironment().findGitDir().setBare().build();
+ if (Files.notExists(XacmlAdminUI.repositoryPath) || Files.notExists(Paths.get(XacmlAdminUI.repositoryPath.toString(), "HEAD"))) {
+ //
+ // Create it if it doesn't exist. As a bare repository
+ //
+ logger.info("Creating bare git repository: " + XacmlAdminUI.repositoryPath.toString());
+ XacmlAdminUI.repository.create();
+ //
+ // Add the magic file so remote works.
+ //
+ Path daemon = Paths.get(XacmlAdminUI.repositoryPath.toString(), "git-daemon-export-ok");
+ Files.createFile(daemon);
+ }
+ } catch (IOException e) {
+ logger.error("Failed to build repository: " + repository, e);
+ throw new ServletException(e.getMessage(), e.getCause());
+ }
+ //
+ // Make sure the workspace directory is created
+ //
+ Path workspace = Paths.get(XACMLProperties.getProperty(XACMLRestProperties.PROP_ADMIN_WORKSPACE));
+ workspace = workspace.toAbsolutePath();
+ if (Files.notExists(workspace)) {
+ try {
+ Files.createDirectory(workspace);
+ } catch (IOException e) {
+ logger.error("Failed to build workspace: " + workspace, e);
+ throw new ServletException(e.getMessage(), e.getCause());
+ }
+ }
+ //
+ // Create the user workspace directory
+ //
+ workspace = Paths.get(workspace.toString(), "pe");
+ if (Files.notExists(workspace)) {
+ try {
+ Files.createDirectory(workspace);
+ } catch (IOException e) {
+ logger.error("Failed to create directory: " + workspace, e);
+ throw new ServletException(e.getMessage(), e.getCause());
+ }
+ }
+ //
+ // Get the path to where the repository is going to be
+ //
+ Path gitPath = Paths.get(workspace.toString(), XacmlAdminUI.repositoryPath.getFileName().toString());
+ if (Files.notExists(gitPath)) {
+ try {
+ Files.createDirectory(gitPath);
+ } catch (IOException e) {
+ logger.error("Failed to create directory: " + gitPath, e);
+ throw new ServletException(e.getMessage(), e.getCause());
+ }
+ }
+ //
+ // Initialize the domain structure
+ //
+ String base = null;
+ String domain = XacmlAdminUI.getDomain();
+ if (domain != null) {
+ for (String part : Splitter.on(':').trimResults().split(domain)) {
+ if (base == null) {
+ base = part;
+ }
+ Path subdir = Paths.get(gitPath.toString(), part);
+ if (Files.notExists(subdir)) {
+ try {
+ Files.createDirectory(subdir);
+ Files.createFile(Paths.get(subdir.toString(), ".svnignore"));
+ } catch (IOException e) {
+ logger.error("Failed to create: " + subdir, e);
+ throw new ServletException(e.getMessage(), e.getCause());
+ }
+ }
+ }
+ } else {
+ try {
+ Files.createFile(Paths.get(workspace.toString(), ".svnignore"));
+ base = ".svnignore";
+ } catch (IOException e) {
+ logger.error("Failed to create file", e);
+ throw new ServletException(e.getMessage(), e.getCause());
+ }
+ }
+ try {
+ //
+ // These are the sequence of commands that must be done initially to
+ // finish setting up the remote bare repository.
+ //
+ Git git = Git.init().setDirectory(gitPath.toFile()).setBare(false).call();
+ git.add().addFilepattern(base).call();
+ git.commit().setMessage("Initialize Bare Repository").call();
+ StoredConfig config = git.getRepository().getConfig();
+ config.setString("remote", "origin", "url", XacmlAdminUI.repositoryPath.toAbsolutePath().toString());
+ config.setString("remote", "origin", "fetch", "+refs/heads/*:refs/remotes/origin/*");
+ config.save();
+ git.push().setRemote("origin").add("master").call();
+ /*
+ * This will not work unless git.push().setRemote("origin").add("master").call();
+ * is called first. Otherwise it throws an exception. However, if the push() is
+ * called then calling this function seems to add nothing.
+ *
+ git.branchCreate().setName("master")
+ .setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM)
+ .setStartPoint("origin/master").setForce(true).call();
+ */
+ } catch (GitAPIException | IOException e) {
+ logger.error(e);
+ throw new ServletException(e.getMessage(), e.getCause());
+ }
+ }
+
+ /**
+ * Initializes a user's git repository.
+ *
+ *
+ * @param workspacePath
+ * @param userId
+ * @param email
+ * @return
+ * @throws IOException
+ * @throws InvalidRemoteException
+ * @throws TransportException
+ * @throws GitAPIException
+ */
+ private static Path initializeUserRepository(Path workspacePath, String userId, URI email) throws IOException, InvalidRemoteException, TransportException, GitAPIException {
+ Path gitPath = null;
+ //
+ // Initialize the User's Git repository
+ //
+ if (Files.notExists(workspacePath)) {
+ logger.info("Creating user workspace: " + workspacePath.toAbsolutePath().toString());
+ //
+ // Create our user's directory
+ //
+ Files.createDirectory(workspacePath);
+ }
+ gitPath = Paths.get(workspacePath.toString(), XacmlAdminUI.repositoryPath.getFileName().toString());
+ if (Files.notExists(gitPath)) {
+ //
+ // It doesn't exist yet, so Clone it and check it out
+ //
+ logger.info("Cloning user git directory: " + gitPath.toAbsolutePath().toString());
+ Git.cloneRepository().setURI(XacmlAdminUI.repositoryPath.toUri().toString())
+ .setDirectory(gitPath.toFile())
+ .setNoCheckout(false)
+ .call();
+ //
+ // Set userid
+ //
+ Git git = Git.open(gitPath.toFile());
+ StoredConfig config = git.getRepository().getConfig();
+ config.setString("user", null, "name", userId);
+ if (email != null && email.getPath() != null) {
+ config.setString("user", null, "email", email.toString());
+ }
+ config.save();
+ }
+ return gitPath;
+ }
+
+
+ public static String getDomain() {
+ return XACMLProperties.getProperty(XACMLRestProperties.PROP_ADMIN_DOMAIN, "urn");
+ }
+
+ public static JDBCConnectionPool getConnectionPool() {
+ return pool;
+ }
+
+ public SQLContainer getMatchFunctionContainer() {
+ return this.matchFunctionContainer;
+ }
+
+ public SQLContainer getHigherOrderBagContainer() {
+ return this.higherorderBagContainer;
+ }
+
+ public EntityManager getEntityManager() {
+ return this.em;
+ }
+
+ public JPAContainer<Attribute> getAttributes() {
+ return this.attributes;
+ }
+
+ public void refreshAttributes() {
+ this.attributes.refresh();
+ this.console.refreshAttributes();
+ }
+
+ public JPAContainer<ConstraintType> getConstraintTypes() {
+ return this.constraintTypes;
+ }
+
+ public JPAContainer<Category> getCategories() {
+ return this.categories;
+ }
+
+ public JPAContainer<Datatype> getDatatypes() {
+ return this.datatypes;
+ }
+
+ public JPAContainer<PolicyAlgorithms> getPolicyAlgorithms() {
+ return this.policyAlgorithms;
+ }
+
+ public JPAContainer<RuleAlgorithms> getRuleAlgorithms() {
+ return this.ruleAlgorithms;
+ }
+
+ public JPAContainer<Obadvice> getObadvice() {
+ return this.obadvice;
+ }
+
+ public JPAContainer<ObadviceExpression> getObadviceExpressions() {
+ return this.obadviceExpressions;
+ }
+
+ public void refreshObadvice() {
+ this.obadvice.refresh();
+ this.obadviceExpressions.refresh();
+ this.console.refreshObadvice();
+ }
+
+ public JPAContainer<FunctionDefinition> getFunctionDefinitions() {
+ return this.functionDefinitions;
+ }
+
+ public JPAContainer<FunctionArgument> getFunctionArguments() {
+ return this.functionArguments;
+ }
+
+ public JPAContainer<PIPConfiguration> getPIPConfigurations() {
+ return this.pipConfigurations;
+ }
+
+ public JPAContainer<PIPResolver> getPIPResolvers() {
+ return this.pipResolvers;
+ }
+
+ public JPAContainer<PIPType> getPIPTypes() {
+ return this.pipTypes;
+ }
+
+ public void refreshPIPConfiguration() {
+ this.pipConfigurations.refresh();
+ this.console.refreshPIPConfiguration();
+ }
+
+ public Category getDefaultCategory() throws Exception {
+ for (Object id : categories.getItemIds()) {
+ Category cat = categories.getItem(id).getEntity();
+ if (cat.getIdentifer().equals(XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT)) {
+ return cat;
+ }
+ }
+ throw new Exception("There is no default category.");
+ }
+
+ public Datatype getDefaultDatatype() throws Exception {
+ for (Object id: this.datatypes.getItemIds()) {
+ Datatype dt = this.datatypes.getItem(id).getEntity();
+ if (dt.getIdentifer().equals(XACML3.ID_DATATYPE_STRING)) {
+ return dt;
+ }
+ }
+ throw new Exception("There is no default datatype.");
+ }
+
+ public XacmlAdminAuthorization getAuthorizer() {
+ return this.authorizer;
+ }
+
+ public boolean isAuthorized(AdminAction action, AdminResource resource) {
+ return this.authorizer.isAuthorized(this.getUserid(), action, resource);
+ }
+
+ public String getUserid() {
+ Object id = this.getSession().getSession().getAttribute("xacml.rest.admin.user.id");
+ if (id == null) {
+ return XACMLProperties.getProperty("xacml.rest.admin.user.id", "guest");
+ }
+ String str = id.toString();
+ if (str == null || str.isEmpty()) {
+ return "guest";
+ }
+ return str;
+ }
+
+ public String getUserName() {
+ Object id = this.getSession().getSession().getAttribute("xacml.rest.admin.user.name");
+ if (id == null) {
+ return XACMLProperties.getProperty("xacml.rest.admin.user.name", "guest");
+ }
+ String str = id.toString();
+ if (str == null || str.isEmpty()) {
+ return "guest";
+ }
+ return str;
+ }
+
+ public URI getUserEmail() {
+ Object id = this.getSession().getSession().getAttribute("xacml.rest.admin.user.email");
+ if (id == null) {
+ return URI.create(XACMLProperties.getProperty("xacml.rest.admin.user.email", "guest"));
+ }
+ String str = id.toString();
+ if (str == null || str.isEmpty()) {
+ return null;
+ }
+ return URI.create(str);
+ }
+
+ public Path getUserWorkspace() {
+ return this.workspacePath;
+ }
+
+ public Path getUserGitPath() {
+ return this.gitPath;
+ }
+
+ public PAPEngine getPAPEngine() {
+ return this.papEngine;
+ }
+
+ public String newPolicyID() {
+ return Joiner.on(':').skipNulls().join((XacmlAdminUI.getDomain().startsWith("urn") ? null : "urn"),
+ XacmlAdminUI.getDomain().replaceAll("[/\\\\.]", ":"),
+ "xacml", "policy", "id", UUID.randomUUID());
+ }
+
+ public String newRuleID() {
+ return Joiner.on(':').skipNulls().join((XacmlAdminUI.getDomain().startsWith("urn") ? null : "urn"),
+ XacmlAdminUI.getDomain().replaceAll("[/\\\\.]", ":"),
+ "xacml", "rule", "id", UUID.randomUUID());
+ }
+ //
+ // PAPNotificationBroadcaster Interface implementation
+ //
+ /**
+ * Got a notification that the PAP has changed the PDP data,
+ * so update ALL PDPGroups.
+ * This is called once for each Vaadin instance for each PAP change Notification.
+ */
+ public void updateAllGroups() {
+ access(new Runnable() {
+ @Override
+ public void run() {
+ //
+ // locking is needed to avoid race conditions.
+ // Shows up as Exception: "A connector should not be marked as dirty while a response is being written."
+ //
+ getUI().getSession().lock();
+ try {
+ //
+ // Tell the console to refresh its PDP group information
+ //
+ console.refreshPDPGroups();
+ } finally {
+ getUI().getSession().unlock();
+ }
+ }
+ });
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlErrorHandler.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlErrorHandler.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlErrorHandler.java
new file mode 100644
index 0000000..dd014dd
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlErrorHandler.java
@@ -0,0 +1,106 @@
+/*
+ * 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.xacml.admin;
+
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.navigator.View;
+import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.VerticalLayout;
+
+public class XacmlErrorHandler extends CustomComponent implements View {
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+
+ @AutoGenerated
+ private Button buttonGo;
+
+ @AutoGenerated
+ private Label labelError;
+
+ public static String VIEWNAME="ErrorHandler.View";
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ private static final long serialVersionUID = 1L;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public XacmlErrorHandler(String message, String button) {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+ this.labelError.setValue(message);
+ if (button != null) {
+ this.buttonGo.setCaption(button);
+ } else {
+ this.buttonGo.setVisible(false);
+ }
+ }
+
+ @Override
+ public void enter(ViewChangeEvent event) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("100%");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("100.0%");
+ setHeight("-1px");
+
+ // labelError
+ labelError = new Label();
+ labelError.setImmediate(false);
+ labelError.setWidth("100.0%");
+ labelError.setHeight("80px");
+ labelError.setValue("This holds error messages.");
+ mainLayout.addComponent(labelError);
+
+ // buttonGo
+ buttonGo = new Button();
+ buttonGo.setCaption("Ok");
+ buttonGo.setImmediate(true);
+ buttonGo.setWidth("-1px");
+ buttonGo.setHeight("-1px");
+ mainLayout.addComponent(buttonGo);
+ mainLayout.setComponentAlignment(buttonGo, new Alignment(48));
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlJDBCConnectionPool.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlJDBCConnectionPool.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlJDBCConnectionPool.java
new file mode 100644
index 0000000..a11707d
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/XacmlJDBCConnectionPool.java
@@ -0,0 +1,239 @@
+/*
+ * 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.xacml.admin;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.vaadin.data.util.sqlcontainer.connection.JDBCConnectionPool;
+
+public class XacmlJDBCConnectionPool implements JDBCConnectionPool {
+ private static final long serialVersionUID = 1L;
+ private static Log logger = LogFactory.getLog(XacmlJDBCConnectionPool.class);
+
+ private int initialConnections = 5;
+ private int maxConnections = 300;
+
+ private String driverName;
+ private String connectionUri;
+ private String userName;
+ private String password;
+
+ private transient Set<Connection> availableConnections;
+ private transient Set<Connection> reservedConnections;
+
+ private boolean initialized;
+
+ public XacmlJDBCConnectionPool(String driverName, String connectionUri, String userName, String password) throws SQLException {
+ if (driverName == null) {
+ throw new IllegalArgumentException(
+ "JDBC driver class name must be given.");
+ }
+ if (connectionUri == null) {
+ throw new IllegalArgumentException(
+ "Database connection URI must be given.");
+ }
+ if (userName == null) {
+ throw new IllegalArgumentException(
+ "Database username must be given.");
+ }
+ if (password == null) {
+ throw new IllegalArgumentException(
+ "Database password must be given.");
+ }
+ this.driverName = driverName;
+ this.connectionUri = connectionUri;
+ this.userName = userName;
+ this.password = password;
+
+ /* Initialize JDBC driver */
+ try {
+ Class.forName(driverName).newInstance();
+ } catch (Exception ex) {
+ throw new RuntimeException("Specified JDBC Driver: " + driverName
+ + " - initialization failed.", ex);
+ }
+ }
+
+ public XacmlJDBCConnectionPool(String driverName, String connectionUri,
+ String userName, String password, int initialConnections,
+ int maxConnections) throws SQLException {
+ this(driverName, connectionUri, userName, password);
+ this.initialConnections = initialConnections;
+ this.maxConnections = maxConnections;
+ }
+
+ private void initializeConnections() throws SQLException {
+ availableConnections = new HashSet<Connection>(initialConnections);
+ reservedConnections = new HashSet<Connection>(initialConnections);
+ for (int i = 0; i < initialConnections; i++) {
+ availableConnections.add(createConnection());
+ }
+ initialized = true;
+ }
+
+ @Override
+ public synchronized Connection reserveConnection() throws SQLException {
+ if (!initialized) {
+ initializeConnections();
+ }
+ Connection c = null;
+ do {
+ if (availableConnections.isEmpty()) {
+ if (reservedConnections.size() < maxConnections) {
+ logger.info("creating new connection");
+ availableConnections.add(createConnection());
+ } else {
+ throw new SQLException("Connection limit has been reached.");
+ }
+ }
+ //
+ // Get first available
+ //
+ c = availableConnections.iterator().next();
+ //
+ // It is still valid?
+ //
+ if (!this.isValid(c)) {
+ try {
+ logger.warn("Removing invalid connection.");
+ //
+ // No close it
+ //
+ c.close();
+ //
+ // Remove from our list
+ //
+ this.availableConnections.remove(c);
+ //
+ // Try again
+ //
+ c = null;
+ } catch (SQLException e) { // NOPMD
+ // If removing the connection fails, ignore
+ }
+ } else {
+ //
+ // Yes
+ //
+ availableConnections.remove(c);
+ break;
+ }
+ } while (c == null);
+ //
+ // Add it to our reserved list
+ //
+ reservedConnections.add(c);
+ return c;
+ }
+
+ @Override
+ public synchronized void releaseConnection(Connection conn) {
+ if (conn == null || !initialized) {
+ return;
+ }
+ /* Try to roll back if necessary */
+ try {
+ if (!conn.getAutoCommit()) {
+ conn.rollback();
+ }
+ } catch (SQLException e) {
+ /* Roll back failed, close and discard connection */
+ try {
+ conn.close();
+ } catch (SQLException e1) { // NOPMD
+ /* Nothing needs to be done */
+ }
+ reservedConnections.remove(conn);
+ return;
+ }
+ reservedConnections.remove(conn);
+ availableConnections.add(conn);
+ }
+
+ private Connection createConnection() throws SQLException {
+ Connection c = DriverManager.getConnection(connectionUri, userName,
+ password);
+ c.setAutoCommit(false);
+ if (driverName.toLowerCase().contains("mysql")) {
+ try {
+ Statement s = c.createStatement();
+ s.execute("SET SESSION sql_mode = 'ANSI'");
+ s.close();
+ } catch (Exception e) { // NOPMD
+ // Failed to set ansi mode; continue
+ }
+ }
+ return c;
+ }
+
+ @Override
+ public void destroy() {
+ for (Connection c : availableConnections) {
+ try {
+ c.close();
+ } catch (SQLException e) { // NOPMD
+ // No need to do anything
+ }
+ }
+ for (Connection c : reservedConnections) {
+ try {
+ c.close();
+ } catch (SQLException e) { // NOPMD
+ // No need to do anything
+ }
+ }
+
+ }
+
+ private void writeObject(java.io.ObjectOutputStream out) throws IOException {
+ initialized = false;
+ out.defaultWriteObject();
+ }
+
+ private final boolean isValid(final Connection con) throws SQLException {
+ final String bogusQuery = "SELECT 1";
+
+ try (Statement st = con.createStatement(); ResultSet res = st.executeQuery(bogusQuery)) {
+ return true;
+ } catch (final SQLException sqlx) {
+ return false;
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "XacmlJDBCConnectionPool [initialConnections="
+ + initialConnections + ", maxConnections=" + maxConnections
+ + ", driverName=" + driverName + ", connectionUri="
+ + connectionUri + ", userName=" + userName + ", password="
+ + password + ", initialized=" + initialized + "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/AttributeDictionary.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/AttributeDictionary.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/AttributeDictionary.java
new file mode 100644
index 0000000..f0069a7
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/components/AttributeDictionary.java
@@ -0,0 +1,503 @@
+/*
+ * 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.xacml.admin.components;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.XacmlAdminAuthorization;
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.jpa.Attribute;
+import org.apache.openaz.xacml.admin.jpa.Category;
+import org.apache.openaz.xacml.admin.jpa.Datatype;
+import org.apache.openaz.xacml.admin.view.windows.AttributeEditorWindow;
+import com.vaadin.addon.jpacontainer.EntityItem;
+import com.vaadin.addon.jpacontainer.JPAContainer;
+import com.vaadin.addon.jpacontainer.provider.CachingLocalEntityProvider;
+import com.vaadin.addon.jpacontainer.provider.CachingMutableLocalEntityProvider;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Container.Filter;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.util.filter.Compare;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.AbstractSelect.ItemCaptionMode;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window.CloseEvent;
+import com.vaadin.ui.Window.CloseListener;
+
+public class AttributeDictionary extends CustomComponent {
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Table table;
+ @AutoGenerated
+ private HorizontalLayout horizontalLayoutToolbar;
+ @AutoGenerated
+ private ComboBox comboBoxFilterDatatype;
+ @AutoGenerated
+ private ComboBox comboBoxFilterCategory;
+ @AutoGenerated
+ private Button buttonClone;
+ @AutoGenerated
+ private Button buttonRemove;
+ @AutoGenerated
+ private Button buttonNew;
+ private static final long serialVersionUID = 4553719412188869190L;
+ private static final Log logger = LogFactory.getLog(AttributeDictionary.class);
+ private static final Object[] visibleColumns = new Object[] { "xacmlId", "description", "categoryBean", "datatypeBean", "constraintType", "modifiedBy", "modifiedDate", "createdBy", "createdDate"};
+ private static final String[] columnHeaders = new String[] { "Attribute ID", "Description", "Category", "DataType", "Constraint", "Modified By", "Modified Date", "Created By", "Created Date"};
+
+ private AttributeDictionary self = this;
+
+ private final JPAContainer<Attribute> attributes = new JPAContainer<Attribute>(Attribute.class);
+ private final JPAContainer<Category> categories = new JPAContainer<Category>(Category.class);
+ private final JPAContainer<Datatype> datatypes = new JPAContainer<Datatype>(Datatype.class);
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public AttributeDictionary() {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+ //
+ // Finish initializing the container
+ //
+ boolean isReadOnly;
+ if (((XacmlAdminUI)UI.getCurrent()).isAuthorized(
+ XacmlAdminAuthorization.AdminAction.ACTION_WRITE,
+ XacmlAdminAuthorization.AdminResource.RESOURCE_DICTIONARIES)) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("write access");
+ }
+ //
+ // Make it mutable
+ //
+ isReadOnly = false;
+ this.attributes.setEntityProvider(new CachingMutableLocalEntityProvider<Attribute>(Attribute.class, ((XacmlAdminUI)UI.getCurrent()).getEntityManager()));
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("read access");
+ }
+ //
+ // Make it read-only
+ //
+ isReadOnly = true;
+ this.attributes.setEntityProvider(new CachingLocalEntityProvider<Attribute>(Attribute.class, ((XacmlAdminUI)UI.getCurrent()).getEntityManager()));
+ }
+ this.categories.setEntityProvider(new CachingLocalEntityProvider<Category>(Category.class, ((XacmlAdminUI)UI.getCurrent()).getEntityManager()));
+ this.categories.sort(new String[]{"xacmlId"}, new boolean[]{true});
+ this.datatypes.setEntityProvider(new CachingLocalEntityProvider<Datatype>(Datatype.class, ((XacmlAdminUI)UI.getCurrent()).getEntityManager()));
+ this.datatypes.sort(new String[]{"xacmlId"}, new boolean[]{true});
+ //
+ // Initialize
+ //
+ this.initializeTable(isReadOnly);
+ this.initializeButtons(isReadOnly);
+ this.initializeCategoryComboFilter();
+ this.initializeDatatypeComboFilter();
+ }
+
+ protected void initializeTable(boolean isReadOnly) {
+ //
+ // This is the data source
+ //
+ this.table.setContainerDataSource(this.attributes);
+ //
+ // Setup table
+ //
+ this.table.setVisibleColumns(visibleColumns);
+ this.table.setColumnHeaders(columnHeaders);
+ this.table.setImmediate(true);
+ this.table.setColumnCollapsingAllowed(true);
+ //
+ // Read only?
+ //
+ if (isReadOnly) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("read only table");
+ }
+ return;
+ }
+ this.table.setSelectable(true);
+ //
+ // Respond to clicks
+ //
+ this.table.addItemClickListener(new ItemClickListener() {
+ private static final long serialVersionUID = 1L;
+ @Override
+ public void itemClick(ItemClickEvent event) {
+ if (event.isDoubleClick()) {
+ //
+ // Create our editor window
+ //
+ final AttributeEditorWindow attributeEditor = new AttributeEditorWindow(self.attributes.getItem(event.getItemId()));
+ attributeEditor.setCaption("Edit Attribute");
+ attributeEditor.setModal(true);
+ attributeEditor.center();
+ UI.getCurrent().addWindow(attributeEditor);
+ }
+ }
+ });
+ //
+ // Respond to selections
+ //
+ this.table.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ Object value = self.table.getValue();
+ if (value == null) {
+ self.buttonRemove.setEnabled(false);
+ self.buttonClone.setEnabled(false);
+ } else {
+ self.buttonRemove.setEnabled(true);
+ self.buttonClone.setEnabled(true);
+ }
+ }
+ });
+ }
+
+ protected void initializeButtons(boolean isReadOnly) {
+ if (isReadOnly) {
+ this.buttonNew.setVisible(false);
+ this.buttonRemove.setVisible(false);
+ this.buttonClone.setVisible(false);
+ return;
+ }
+ this.buttonNew.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ AttributeDictionary.createNewAttributeWindow();
+ }
+
+ });
+
+ this.buttonRemove.setEnabled(false);
+ this.buttonRemove.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ //
+ // Get the selected item
+ //
+ Object id = self.table.getValue();
+ //
+ // Sanity check
+ //
+ if (id == null) {
+ return;
+ }
+ //
+ // Remove the attribute
+ //
+ self.attributes.removeItem(id);
+ //
+ // Unfortunately, removing the item does NOT result
+ // in a ValueChange event being generated. So we must
+ // trigger it ourselves.
+ //
+ self.table.select(self.table.getNullSelectionItemId());
+ }
+ });
+
+ this.buttonClone.setEnabled(false);
+ this.buttonClone.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ Object id = self.table.getValue();
+ if (id == null) {
+ return;
+ }
+ Item item = self.table.getItem(id);
+ if (item instanceof EntityItem) {
+ @SuppressWarnings("unchecked")
+ //
+ // Get the entity
+ //
+ EntityItem<Attribute> entityItem = (EntityItem<Attribute>) item;
+ //
+ // Clone it
+ //
+ Attribute newAttribute = new Attribute(entityItem.getEntity(), ((XacmlAdminUI)UI.getCurrent()).getUserid());
+ //
+ // Add it to the database
+ //
+ id = self.attributes.addEntity(newAttribute);
+ //
+ // Now select it
+ //
+ self.table.select(id);
+ //
+ // Refresh it to get the latest modified date
+ //
+ self.attributes.refreshItem(id);
+ }
+ }
+ });
+ }
+
+ protected void initializeCategoryComboFilter() {
+ //
+ // Set data source
+ //
+ this.comboBoxFilterCategory.setContainerDataSource(self.categories);
+ this.comboBoxFilterCategory.setItemCaptionMode(ItemCaptionMode.PROPERTY);
+ this.comboBoxFilterCategory.setItemCaptionPropertyId("xacmlId");
+ //
+ // Initialize GUI properties
+ //
+ this.comboBoxFilterCategory.setNullSelectionAllowed(true);
+ this.comboBoxFilterCategory.setImmediate(true);
+ //
+ // Respond to value changes
+ //
+ this.comboBoxFilterCategory.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+ Filter currentFilter = null;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ //
+ // Remove filter
+ //
+ if (currentFilter != null) {
+ self.attributes.removeContainerFilter(this.currentFilter);
+ this.currentFilter = null;
+ }
+ //
+ // Set the new one
+ //
+ Object id = self.comboBoxFilterCategory.getValue();
+ if (id == null) {
+ return;
+ }
+ Category cat = self.categories.getItem(id).getEntity();
+ this.currentFilter = new Compare.Equal("categoryBean", cat);
+ self.attributes.addContainerFilter(this.currentFilter);
+ }
+ });
+ }
+
+ protected void initializeDatatypeComboFilter() {
+ //
+ // Set data source
+ //
+ this.comboBoxFilterDatatype.setContainerDataSource(self.datatypes);
+ this.comboBoxFilterDatatype.setItemCaptionMode(ItemCaptionMode.PROPERTY);
+ this.comboBoxFilterDatatype.setItemCaptionPropertyId("xacmlId");
+ //
+ // Initialize GUI properties
+ //
+ this.comboBoxFilterDatatype.setNullSelectionAllowed(true);
+ this.comboBoxFilterDatatype.setImmediate(true);
+ //
+ // Respond to value changes
+ //
+ this.comboBoxFilterDatatype.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+ Filter currentFilter = null;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ //
+ // Remove filter
+ //
+ if (currentFilter != null) {
+ self.attributes.removeContainerFilter(this.currentFilter);
+ this.currentFilter = null;
+ }
+ //
+ // Set the new one
+ //
+ Object id = self.comboBoxFilterDatatype.getValue();
+ if (id == null) {
+ return;
+ }
+ Datatype cat = self.datatypes.getItem(id).getEntity();
+ this.currentFilter = new Compare.Equal("datatypeBean", cat);
+ self.attributes.addContainerFilter(this.currentFilter);
+ }
+ });
+ }
+
+ public void refreshContainer() {
+ this.attributes.refresh();
+ this.categories.refresh();
+ this.datatypes.refresh();
+ }
+
+ public static void createNewAttributeWindow() {
+ //
+ // Create our new attribute
+ //
+ String domain = XacmlAdminUI.getDomain();
+ String userid = ((XacmlAdminUI)UI.getCurrent()).getUserid();
+ final Attribute newAttribute = new Attribute(domain, userid);
+ try {
+ newAttribute.setCategoryBean(((XacmlAdminUI)UI.getCurrent()).getDefaultCategory());
+ newAttribute.setDatatypeBean(((XacmlAdminUI)UI.getCurrent()).getDefaultDatatype());
+ } catch (Exception e) {
+ logger.error(e);
+ return;
+ }
+ //
+ // Create our editor window
+ //
+ final AttributeEditorWindow attributeEditor = new AttributeEditorWindow(((XacmlAdminUI)UI.getCurrent()).getAttributes().createEntityItem(newAttribute));
+ attributeEditor.setCaption("Add New Attribute");
+ attributeEditor.setModal(true);
+ attributeEditor.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Did the user hit save?
+ //
+ if (attributeEditor.isSaved()) {
+ //
+ // Add the new attribute
+ //
+ ((XacmlAdminUI)UI.getCurrent()).getAttributes().addEntity(newAttribute);
+ ((XacmlAdminUI)UI.getCurrent()).refreshAttributes();
+ }
+ }
+
+ });
+ attributeEditor.center();
+ UI.getCurrent().addWindow(attributeEditor);
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // horizontalLayoutToolbar
+ horizontalLayoutToolbar = buildHorizontalLayoutToolbar();
+ mainLayout.addComponent(horizontalLayoutToolbar);
+
+ // table
+ table = new Table();
+ table.setImmediate(false);
+ table.setWidth("100.0%");
+ table.setHeight("-1px");
+ mainLayout.addComponent(table);
+
+ return mainLayout;
+ }
+
+ @AutoGenerated
+ private HorizontalLayout buildHorizontalLayoutToolbar() {
+ // common part: create layout
+ horizontalLayoutToolbar = new HorizontalLayout();
+ horizontalLayoutToolbar.setImmediate(false);
+ horizontalLayoutToolbar.setWidth("-1px");
+ horizontalLayoutToolbar.setHeight("-1px");
+ horizontalLayoutToolbar.setMargin(false);
+ horizontalLayoutToolbar.setSpacing(true);
+
+ // buttonNew
+ buttonNew = new Button();
+ buttonNew.setCaption("New");
+ buttonNew.setImmediate(true);
+ buttonNew.setDescription("Create a new attribute");
+ buttonNew.setWidth("70px");
+ buttonNew.setHeight("-1px");
+ horizontalLayoutToolbar.addComponent(buttonNew);
+ horizontalLayoutToolbar.setComponentAlignment(buttonNew, new Alignment(
+ 9));
+
+ // buttonRemove
+ buttonRemove = new Button();
+ buttonRemove.setCaption("Remove");
+ buttonRemove.setImmediate(true);
+ buttonRemove.setDescription("Remove the selected attribute(s)");
+ buttonRemove.setWidth("-1px");
+ buttonRemove.setHeight("-1px");
+ horizontalLayoutToolbar.addComponent(buttonRemove);
+ horizontalLayoutToolbar.setComponentAlignment(buttonRemove,
+ new Alignment(9));
+
+ // buttonClone
+ buttonClone = new Button();
+ buttonClone.setCaption("Clone");
+ buttonClone.setImmediate(true);
+ buttonClone.setDescription("Clone an attribute.");
+ buttonClone.setWidth("-1px");
+ buttonClone.setHeight("-1px");
+ horizontalLayoutToolbar.addComponent(buttonClone);
+ horizontalLayoutToolbar.setComponentAlignment(buttonClone,
+ new Alignment(9));
+
+ // comboBoxFilterCategory
+ comboBoxFilterCategory = new ComboBox();
+ comboBoxFilterCategory.setCaption("Filter By Category");
+ comboBoxFilterCategory.setImmediate(false);
+ comboBoxFilterCategory.setWidth("-1px");
+ comboBoxFilterCategory.setHeight("-1px");
+ horizontalLayoutToolbar.addComponent(comboBoxFilterCategory);
+
+ // comboBoxFilterDatatype
+ comboBoxFilterDatatype = new ComboBox();
+ comboBoxFilterDatatype.setCaption("Filter By Data Type");
+ comboBoxFilterDatatype.setImmediate(false);
+ comboBoxFilterDatatype.setWidth("-1px");
+ comboBoxFilterDatatype.setHeight("-1px");
+ horizontalLayoutToolbar.addComponent(comboBoxFilterDatatype);
+
+ return horizontalLayoutToolbar;
+ }
+
+}
[08/23] incubator-openaz git commit: Ported original att source to
openaz
Posted by pd...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/SQLPIPConfigurationComponent.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/SQLPIPConfigurationComponent.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/SQLPIPConfigurationComponent.java
new file mode 100644
index 0000000..7b2b501
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/SQLPIPConfigurationComponent.java
@@ -0,0 +1,763 @@
+/*
+ * 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.xacml.admin.view.components;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.jpa.PIPConfigParam;
+import org.apache.openaz.xacml.admin.jpa.PIPConfiguration;
+import org.apache.openaz.xacml.admin.view.events.FormChangedEventListener;
+import org.apache.openaz.xacml.admin.view.events.FormChangedEventNotifier;
+import com.vaadin.addon.jpacontainer.EntityItem;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Buffered.SourceException;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.server.Page;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Notification;
+import com.vaadin.ui.Notification.Type;
+import com.vaadin.ui.PasswordField;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+public class SQLPIPConfigurationComponent extends CustomComponent implements FormChangedEventNotifier {
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+
+ @AutoGenerated
+ private Button buttonTest;
+
+ @AutoGenerated
+ private PasswordField textFieldPassword;
+
+ @AutoGenerated
+ private TextField textFieldUser;
+
+ @AutoGenerated
+ private TextField textFieldConnectionURL;
+
+ @AutoGenerated
+ private ComboBox comboBoxSQLDriver;
+
+ @AutoGenerated
+ private TextField textFieldDataSource;
+
+ @AutoGenerated
+ private ComboBox comboBoxConnectionType;
+
+ public static final String CLASSNAME = "org.apache.openaz.xacml.std.pip.engines.jdbc.JDBCEngine";
+
+ public static final String SQL_TYPE = "type";
+ public static final String SQL_TYPE_JDBC = "jdbc";
+ public static final String SQL_TYPE_JNDI = "jndi";
+ public static final String SQL_DATASOURCE = "datasource";
+ public static final String SQL_DRIVER = "jdbc.driver";
+ public static final String SQL_URL = "jdbc.url";
+ public static final String SQL_USER = "jdbc.conn.user";
+ public static final String SQL_PASSWORD = "jdbc.conn.password";
+
+ //
+ // These are the drivers that we are initially supporting and testing.
+ // Other JDBC drivers may work fine, but we will wait until we test
+ // with those drivers before adding them to this list.
+ //
+ public static final String SQL_DRIVER_MYSQL = "com.mysql.jdbc.Driver";
+ public static final String SQL_DRIVER_POSTGRESQL = "org.postgresql.Driver";
+ public static final String SQL_DRIVER_H2 = "org.h2.Driver";
+ public static final String SQL_DRIVER_HYPER = "org.hsqldb.jdbc.JDBCDriver";
+ public static final String SQL_DRIVER_SQL_SERVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
+ public static String[] SQL_DRIVERS = new String[] {SQL_DRIVER_MYSQL, SQL_DRIVER_POSTGRESQL, SQL_DRIVER_H2, SQL_DRIVER_HYPER, SQL_DRIVER_SQL_SERVER};
+
+ public static final String SQL_DRIVER_MYSQL_URL = "jdbc:mysql://localhost:3306/";
+ public static final String SQL_DRIVER_POSTGRESQL_URL = "jdbc:postgresql://localhost:5432/";
+ public static final String SQL_DRIVER_H2_URL = "jdbc:h2:file:/";
+ public static final String SQL_DRIVER_HYPER_URL = "jdbc:hsqldb:file:/";
+ public static final String SQL_DRIVER_SQL_SERVER_URL = "jdbc:sqlserver://localhost:1433/";
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static final Log logger = LogFactory.getLog(SQLPIPConfigurationComponent.class);
+
+ private final SQLPIPConfigurationComponent self = this;
+ private final BasicNotifier notifier = new BasicNotifier();
+ private final EntityItem<PIPConfiguration> entity;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ * @param configParamField
+ */
+ public SQLPIPConfigurationComponent(EntityItem<PIPConfiguration> entity) {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+ //
+ // Save
+ //
+ this.entity = entity;
+ //
+ // Initialize
+ //
+ this.initialize();
+ //
+ // Finish
+ //
+ this.reset();
+ }
+
+ protected void initialize() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("initializing " + this.entity.getEntity().toString());
+ }
+ //
+ // Iterate any existing values, save them in the data field for each
+ // GUI object.
+ //
+ Set<PIPConfigParam> unneeded = new HashSet<PIPConfigParam>();
+ for (PIPConfigParam param : this.entity.getEntity().getPipconfigParams()) {
+ //
+ // Sanity check
+ //
+ if (param.getParamName() == null) {
+ logger.warn("Null parameter name found.");
+ unneeded.add(param);
+ continue;
+ }
+ if (param.getParamName().equals(SQL_TYPE)) {
+ this.comboBoxConnectionType.setData(param);
+ } else if (param.getParamName().equals(SQL_DATASOURCE)) {
+ this.textFieldDataSource.setData(param);
+ } else if (param.getParamName().equals(SQL_DRIVER)) {
+ this.comboBoxSQLDriver.setData(param);
+ } else if (param.getParamName().equals(SQL_URL)) {
+ this.textFieldConnectionURL.setData(param);
+ } else if (param.getParamName().equals(SQL_USER)) {
+ this.textFieldUser.setData(param);
+ } else if (param.getParamName().equals(SQL_PASSWORD)) {
+ this.textFieldPassword.setData(param);
+ } else {
+ unneeded.add(param);
+ }
+ }
+ //
+ // Get rid of parameters that are not needed
+ //
+ if (unneeded.isEmpty() == false) {
+ this.entity.getEntity().getPipconfigParams().removeAll(unneeded);
+ }
+ //
+ // Now finish initializing the GUI objects
+ //
+ this.initializeEntity();
+ this.initializeTypeCombo();
+ this.initializeSQLDriverCombo();
+ this.initializeText();
+ this.initializeButtons();
+ }
+
+ protected void initializeEntity() {
+ //
+ // Initialize the entity
+ //
+ this.entity.getEntity().setClassname(CLASSNAME);
+ this.entity.getEntity().setRequiresResolvers(true);
+ }
+
+ protected void initializeTypeCombo() {
+ //
+ // Setup GUI properties
+ //
+ this.comboBoxConnectionType.setImmediate(true);
+ this.comboBoxConnectionType.setNullSelectionAllowed(false);
+ this.comboBoxConnectionType.setRequired(true);
+ this.comboBoxConnectionType.setRequiredError("You must select a connection type.");
+ //
+ // Add the possible items
+ //
+ this.comboBoxConnectionType.addItem(SQL_TYPE_JDBC);
+ this.comboBoxConnectionType.addItem(SQL_TYPE_JNDI);
+ //
+ // Respond to events
+ //
+ this.comboBoxConnectionType.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.comboBoxConnectionType.getData();
+ if (param == null) {
+ param = new PIPConfigParam(SQL_TYPE);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.comboBoxConnectionType.setData(param);
+ }
+ param.setParamValue(self.comboBoxConnectionType.getValue().toString());
+ self.reset();
+ self.fireFormChangedEvent();
+ }
+ });
+ //
+ // Set its default selection. If there isn't one, then we default to JDBC.
+ //
+ PIPConfigParam param = (PIPConfigParam) this.comboBoxConnectionType.getData();
+ if (param == null) {
+ param = new PIPConfigParam(SQL_TYPE, SQL_TYPE_JDBC);
+ this.entity.getEntity().addPipconfigParam(param);
+ this.comboBoxConnectionType.setData(param);
+ }
+ this.comboBoxConnectionType.select(param.getParamValue());
+ }
+
+ protected void initializeSQLDriverCombo() {
+ //
+ // GUI properties
+ //
+ this.comboBoxSQLDriver.setImmediate(true);
+ this.comboBoxSQLDriver.setRequired(true);
+ this.comboBoxConnectionType.setRequiredError("You must select a JDBC Driver");
+ this.comboBoxSQLDriver.setInputPrompt("Eg. com.mysql.jdbc.Driver");
+ //
+ // Add some common driver values. These are the drivers we have tested with so far.
+ //
+ for (String driver : SQL_DRIVERS) {
+ this.comboBoxSQLDriver.addItem(driver);
+ }
+ //
+ // Setup the default selection
+ //
+ PIPConfigParam param = (PIPConfigParam) this.comboBoxSQLDriver.getData();
+ if (param != null) {
+ this.comboBoxSQLDriver.setValue(param.getParamValue());
+ //
+ // Check if its there (the value could be something other than what we
+ // have setup in our list of defaults.)
+ //
+ boolean bFound = false;
+ for (Object id : this.comboBoxSQLDriver.getItemIds()) {
+ Item item = this.comboBoxSQLDriver.getItem(id);
+ if (item.toString().equals(param.getParamValue())) {
+ bFound = true;
+ break;
+ }
+ }
+ if (! bFound) {
+ //
+ // It's not one of our defaults, no problem. Add it in.
+ //
+ this.comboBoxSQLDriver.addItem(param.getParamValue());
+ this.comboBoxSQLDriver.setValue(param.getParamValue());
+ }
+ }
+ //
+ // Allow new items
+ //
+ this.comboBoxSQLDriver.setNewItemsAllowed(true);
+ //
+ // Respond to selection changes
+ //
+ this.comboBoxSQLDriver.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.comboBoxSQLDriver.getData();
+ if (param == null) {
+ param = new PIPConfigParam(SQL_DRIVER, self.comboBoxSQLDriver.getValue().toString());
+ self.entity.getEntity().addPipconfigParam(param);
+ self.comboBoxSQLDriver.setData(param);
+ }
+ //
+ // Was something unselected?
+ //
+ if (self.comboBoxSQLDriver.getValue() == null) {
+ param.setParamValue(null);
+ } else {
+ param.setParamValue(self.comboBoxSQLDriver.getValue().toString());
+ //
+ // See if we should pre-populate the driver URL
+ //
+ self.setupDriverURL(self.comboBoxSQLDriver.getValue().toString());
+ }
+ //
+ // Fire
+ //
+ self.fireFormChangedEvent();
+ }
+ });
+ }
+
+ protected void initializeText() {
+ //
+ // GUI properties
+ //
+ this.textFieldDataSource.setImmediate(true);
+ this.textFieldDataSource.setNullRepresentation("");
+ this.textFieldDataSource.setRequired(true);
+ this.textFieldDataSource.setRequiredError("The name of the JNDI Resource is needed.");
+ //
+ // Get its initial value
+ //
+ PIPConfigParam param = (PIPConfigParam) this.textFieldDataSource.getData();
+ if (param != null) {
+ this.textFieldDataSource.setValue(param.getParamValue());
+ }
+ //
+ // Respond to value changes
+ //
+ this.textFieldDataSource.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldDataSource.getData();
+ if (param == null) {
+ param = new PIPConfigParam(SQL_DATASOURCE, self.textFieldDataSource.getValue());
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldDataSource.setData(param);
+ }
+ param.setParamValue(self.textFieldDataSource.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ //
+ // Setup GUI properties
+ //
+ this.textFieldConnectionURL.setImmediate(true);
+ this.textFieldConnectionURL.setNullRepresentation("");
+ this.textFieldConnectionURL.setRequired(true);
+ this.textFieldConnectionURL.setRequiredError("A URL is needed to connect to the database.");
+ //
+ // Set its default value
+ //
+ param = (PIPConfigParam) this.textFieldConnectionURL.getData();
+ if (param != null) {
+ this.textFieldConnectionURL.setValue(param.getParamValue());
+ }
+ //
+ // Respond to value changes
+ //
+ this.textFieldConnectionURL.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldConnectionURL.getData();
+ if (param == null) {
+ param = new PIPConfigParam(SQL_URL);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldConnectionURL.setData(param);
+ }
+ param.setParamValue(self.textFieldConnectionURL.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ //
+ // Set GUI properties
+ //
+ this.textFieldUser.setImmediate(true);
+ this.textFieldUser.setNullRepresentation("");
+ this.textFieldUser.setRequired(true);
+ this.textFieldUser.setRequiredError("User name is required.");
+ //
+ // Setup its default value
+ //
+ param = (PIPConfigParam) self.textFieldUser.getData();
+ if (param != null) {
+ this.textFieldUser.setValue(param.getParamValue());
+ }
+ //
+ // Respond to value changes
+ //
+ this.textFieldUser.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldUser.getData();
+ if (param == null) {
+ param = new PIPConfigParam(SQL_USER);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldUser.setData(param);
+ }
+ param.setParamValue(self.textFieldUser.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ //
+ // Initialize GUI properties
+ //
+ this.textFieldPassword.setImmediate(true);
+ this.textFieldPassword.setNullRepresentation("");
+ //
+ // Set its default value
+ //
+ param = (PIPConfigParam) self.textFieldPassword.getData();
+ if (param != null) {
+ this.textFieldPassword.setValue(param.getParamValue());
+ }
+ //
+ // Respond to value change events
+ //
+ this.textFieldPassword.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldPassword.getData();
+ if (param == null) {
+ param = new PIPConfigParam(SQL_PASSWORD);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldPassword.setData(param);
+ }
+ param.setParamValue(self.textFieldPassword.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ }
+
+ protected void initializeButtons() {
+ this.buttonTest.setImmediate(true);
+ this.buttonTest.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ Object id = self.comboBoxConnectionType.getValue();
+ if (id == null) {
+ logger.warn("No combo box selection");
+ return;
+ }
+ if (id.toString().equals(SQL_TYPE_JDBC)) {
+ self.testJDBCConnection();
+ } else if (id.toString().equals(SQL_TYPE_JNDI)) {
+ self.testJNDIConnection();
+ }
+ }
+ });
+ }
+
+ protected void setupDriverURL(String value) {
+ if (value.equals(SQL_DRIVER_MYSQL)) {
+ this.textFieldConnectionURL.setValue(SQL_DRIVER_MYSQL_URL);
+ } else if (value.equals(SQL_DRIVER_POSTGRESQL)) {
+ this.textFieldConnectionURL.setValue(SQL_DRIVER_POSTGRESQL_URL);
+ } else if (value.equals(SQL_DRIVER_H2)) {
+ this.textFieldConnectionURL.setValue(SQL_DRIVER_H2_URL);
+ } else if (value.equals(SQL_DRIVER_HYPER)) {
+ this.textFieldConnectionURL.setValue(SQL_DRIVER_HYPER_URL);
+ } else if (value.equals(SQL_DRIVER_SQL_SERVER)) {
+ this.textFieldConnectionURL.setValue(SQL_DRIVER_SQL_SERVER_URL);
+ }
+ }
+
+ protected void testJNDIConnection() {
+ try {
+ Context initialContext = new InitialContext();
+ DataSource dataSource = (DataSource) initialContext.lookup(this.textFieldDataSource.getValue());
+ try (Connection connection = dataSource.getConnection()) {
+ new Notification("Success!",
+ "Connection Established!",
+ Type.HUMANIZED_MESSAGE, true)
+ .show(Page.getCurrent());
+ }
+ } catch (NamingException e) {
+ logger.error(e);
+ new Notification("JNDI Naming Exception",
+ "<br/>" + e.getLocalizedMessage() + "<br/>Is the context defined in this J2EE Container instance?",
+ Type.ERROR_MESSAGE, true)
+ .show(Page.getCurrent());
+ } catch (SQLException e) {
+ logger.error(e);
+ new Notification("SQL Exception",
+ "<br/>" + e.getLocalizedMessage() + "<br/>Are the configuration parameters correct?",
+ Type.ERROR_MESSAGE, true)
+ .show(Page.getCurrent());
+ }
+ }
+
+ protected void testJDBCConnection() {
+ try {
+ if (this.comboBoxSQLDriver.getValue() != null) {
+ Class.forName(this.comboBoxSQLDriver.getValue().toString());
+ } else {
+ throw new ClassNotFoundException("Please select a JDBC driver to load.");
+ }
+ } catch (ClassNotFoundException e) {
+ logger.error(e);
+ new Notification("Driver Exception",
+ "<br/>" + e.getLocalizedMessage() + "<br/>Is the JDBC driver's jar in the J2EE container path?",
+ Type.ERROR_MESSAGE, true)
+ .show(Page.getCurrent());
+ return;
+ }
+ Connection connection = null;
+ try {
+ connection = DriverManager.getConnection(this.textFieldConnectionURL.getValue(), this.textFieldUser.getValue(), this.textFieldPassword.getValue());
+ new Notification("Success!",
+ "Connection Established!",
+ Type.HUMANIZED_MESSAGE, true)
+ .show(Page.getCurrent());
+ } catch (SQLException e) {
+ logger.error(e);
+ new Notification("SQL Exception",
+ "<br/>" + e.getLocalizedMessage() + "<br/>Are the configuration parameters correct?",
+ Type.ERROR_MESSAGE, true)
+ .show(Page.getCurrent());
+ } finally {
+ if (connection != null) {
+ try {
+ connection.close();
+ } catch (SQLException idontcare) { //NOPMD
+ }
+ }
+ }
+ }
+
+ protected void reset() {
+ Object id = this.comboBoxConnectionType.getValue();
+ if (id == null) {
+ logger.warn("Can't reset combo hasn't selected anything.");
+ return;
+ }
+ if (id.toString().equals(SQL_TYPE_JDBC)) {
+ //
+ //
+ //
+ this.textFieldDataSource.setVisible(false);
+ this.textFieldDataSource.setRequired(false);
+ //
+ //
+ //
+ this.textFieldConnectionURL.setVisible(true);
+ this.textFieldConnectionURL.setRequired(true);
+ this.comboBoxSQLDriver.setVisible(true);
+ this.comboBoxSQLDriver.setRequired(true);
+ this.textFieldUser.setVisible(true);
+ this.textFieldUser.setRequired(true);
+ this.textFieldPassword.setVisible(true);
+ } else if (id.toString().equals(SQL_TYPE_JNDI)) {
+ //
+ //
+ //
+ this.textFieldDataSource.setVisible(true);
+ this.textFieldDataSource.setRequired(true);
+ //
+ //
+ //
+ this.textFieldConnectionURL.setVisible(false);
+ this.textFieldConnectionURL.setRequired(false);
+ this.comboBoxSQLDriver.setVisible(false);
+ this.comboBoxSQLDriver.setRequired(false);
+ this.textFieldUser.setVisible(false);
+ this.textFieldUser.setRequired(false);
+ this.textFieldPassword.setVisible(false);
+ } else {
+ logger.warn("Unknown SQL type selection: " + id);
+ }
+ }
+
+ public void validate() throws InvalidValueException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("validate");
+ }
+ this.comboBoxConnectionType.validate();
+ this.textFieldDataSource.validate();
+ this.textFieldConnectionURL.validate();
+ this.comboBoxSQLDriver.validate();
+ this.textFieldPassword.validate();
+ this.textFieldUser.validate();
+ }
+
+ public void commit() throws SourceException, InvalidValueException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("commit");
+ }
+ this.comboBoxConnectionType.commit();
+
+ Object id = this.comboBoxConnectionType.getValue();
+ if (id == null) {
+ logger.warn("Can't reset combo hasn't selected anything.");
+ return;
+ }
+ if (id.toString().equals(SQL_TYPE_JDBC)) {
+ this.textFieldConnectionURL.commit();
+ this.comboBoxSQLDriver.commit();
+ this.textFieldPassword.commit();
+ this.textFieldUser.commit();
+
+ this.textFieldDataSource.setData(null);
+ this.entity.getEntity().getPipconfigParams().remove(SQL_DATASOURCE);
+
+ } else if (id.toString().equals(SQL_TYPE_JNDI)) {
+
+ this.textFieldDataSource.commit();
+
+ this.textFieldConnectionURL.setData(null);
+ this.comboBoxSQLDriver.setData(null);
+ this.textFieldPassword.setData(null);
+ this.textFieldUser.setData(null);
+ /* ???
+ this.entity.getEntity().getPipconfigParams().remove(SQL_TYPE);
+ this.entity.getEntity().getPipconfigParams().remove(SQL_DRIVER);
+ this.entity.getEntity().getPipconfigParams().remove(SQL_URL);
+ this.entity.getEntity().getPipconfigParams().remove(SQL_USER);
+ this.entity.getEntity().getPipconfigParams().remove(SQL_PASSWORD);
+ */
+ }
+ }
+
+ public void discard() throws SourceException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("discard");
+ }
+ this.textFieldDataSource.setData(null);
+ this.textFieldConnectionURL.setData(null);
+ this.comboBoxSQLDriver.setData(null);
+ this.textFieldPassword.setData(null);
+ this.textFieldUser.setData(null);
+
+ this.entity.getEntity().getPipconfigParams().remove(SQL_TYPE);
+ this.entity.getEntity().getPipconfigParams().remove(SQL_DATASOURCE);
+ this.entity.getEntity().getPipconfigParams().remove(SQL_DRIVER);
+ this.entity.getEntity().getPipconfigParams().remove(SQL_URL);
+ this.entity.getEntity().getPipconfigParams().remove(SQL_USER);
+ this.entity.getEntity().getPipconfigParams().remove(SQL_PASSWORD);
+ }
+
+ @Override
+ public boolean addListener(FormChangedEventListener listener) {
+ return this.notifier.addListener(listener);
+ }
+
+ @Override
+ public boolean removeListener(FormChangedEventListener listener) {
+ return this.notifier.removeListener(listener);
+ }
+
+ @Override
+ public void fireFormChangedEvent() {
+ this.notifier.fireFormChangedEvent();
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(false);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // comboBoxConnectionType
+ comboBoxConnectionType = new ComboBox();
+ comboBoxConnectionType.setCaption("Type of SQL Connection");
+ comboBoxConnectionType.setImmediate(false);
+ comboBoxConnectionType.setWidth("-1px");
+ comboBoxConnectionType.setHeight("-1px");
+ mainLayout.addComponent(comboBoxConnectionType);
+
+ // textFieldDataSource
+ textFieldDataSource = new TextField();
+ textFieldDataSource.setCaption("Data Source");
+ textFieldDataSource.setImmediate(false);
+ textFieldDataSource.setWidth("-1px");
+ textFieldDataSource.setHeight("-1px");
+ mainLayout.addComponent(textFieldDataSource);
+ mainLayout.setExpandRatio(textFieldDataSource, 1.0f);
+
+ // comboBoxSQLDriver
+ comboBoxSQLDriver = new ComboBox();
+ comboBoxSQLDriver.setCaption("JDBC Driver");
+ comboBoxSQLDriver.setImmediate(false);
+ comboBoxSQLDriver.setWidth("-1px");
+ comboBoxSQLDriver.setHeight("-1px");
+ mainLayout.addComponent(comboBoxSQLDriver);
+ mainLayout.setExpandRatio(comboBoxSQLDriver, 1.0f);
+
+ // textFieldConnectionURL
+ textFieldConnectionURL = new TextField();
+ textFieldConnectionURL.setCaption("Connection URL");
+ textFieldConnectionURL.setImmediate(false);
+ textFieldConnectionURL.setWidth("-1px");
+ textFieldConnectionURL.setHeight("-1px");
+ mainLayout.addComponent(textFieldConnectionURL);
+ mainLayout.setExpandRatio(textFieldConnectionURL, 1.0f);
+
+ // textFieldUser
+ textFieldUser = new TextField();
+ textFieldUser.setCaption("User");
+ textFieldUser.setImmediate(false);
+ textFieldUser.setWidth("-1px");
+ textFieldUser.setHeight("-1px");
+ mainLayout.addComponent(textFieldUser);
+ mainLayout.setExpandRatio(textFieldUser, 1.0f);
+
+ // textFieldPassword
+ textFieldPassword = new PasswordField();
+ textFieldPassword.setCaption("Password");
+ textFieldPassword.setImmediate(false);
+ textFieldPassword.setWidth("-1px");
+ textFieldPassword.setHeight("-1px");
+ mainLayout.addComponent(textFieldPassword);
+ mainLayout.setExpandRatio(textFieldPassword, 1.0f);
+
+ // buttonTest
+ buttonTest = new Button();
+ buttonTest.setCaption("Test Connection");
+ buttonTest.setImmediate(true);
+ buttonTest.setWidth("-1px");
+ buttonTest.setHeight("-1px");
+ mainLayout.addComponent(buttonTest);
+ mainLayout.setComponentAlignment(buttonTest, new Alignment(48));
+
+ return mainLayout;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/ApplyParametersChangedListener.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/ApplyParametersChangedListener.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/ApplyParametersChangedListener.java
new file mode 100644
index 0000000..da86e03
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/ApplyParametersChangedListener.java
@@ -0,0 +1,31 @@
+/*
+ * 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.xacml.admin.view.events;
+
+import org.apache.openaz.xacml.admin.jpa.FunctionArgument;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType;
+
+public interface ApplyParametersChangedListener {
+
+ void applyParameterChanged(ApplyType apply, ApplyType parent, FunctionArgument argument, Object container);
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/ApplyParametersChangedNotifier.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/ApplyParametersChangedNotifier.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/ApplyParametersChangedNotifier.java
new file mode 100644
index 0000000..2491e18
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/ApplyParametersChangedNotifier.java
@@ -0,0 +1,69 @@
+/*
+ * 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.xacml.admin.view.events;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.openaz.xacml.admin.jpa.FunctionArgument;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType;
+
+public interface ApplyParametersChangedNotifier {
+
+ boolean addListener(ApplyParametersChangedListener listener);
+
+ boolean removeListener(ApplyParametersChangedListener listener);
+
+ void fireEvent(ApplyType apply, ApplyType parent, FunctionArgument argument, Object container);
+
+ class BasicNotifier implements ApplyParametersChangedNotifier {
+ Collection<ApplyParametersChangedListener> listeners = null;
+
+ @Override
+ public boolean addListener(ApplyParametersChangedListener listener) {
+ if (this.listeners == null) {
+ this.listeners = new ArrayList<ApplyParametersChangedListener>();
+ }
+ return this.listeners.add(listener);
+ }
+
+ @Override
+ public boolean removeListener(ApplyParametersChangedListener listener) {
+ if (this.listeners == null) {
+ return false;
+ }
+ return this.listeners.remove(listener);
+ }
+
+ @Override
+ public void fireEvent(ApplyType apply, ApplyType parent, FunctionArgument argument, Object container) {
+ if (this.listeners == null) {
+ return;
+ }
+ for (ApplyParametersChangedListener listener : this.listeners) {
+ listener.applyParameterChanged(apply, parent, argument, container);
+ }
+ }
+
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/AttributeChangedEventListener.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/AttributeChangedEventListener.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/AttributeChangedEventListener.java
new file mode 100644
index 0000000..10fb9a2
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/AttributeChangedEventListener.java
@@ -0,0 +1,27 @@
+/*
+ * 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.xacml.admin.view.events;
+
+import org.apache.openaz.xacml.admin.jpa.Attribute;
+
+public interface AttributeChangedEventListener {
+ void attributeChanged(Attribute attribute);
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/AttributeChangedEventNotifier.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/AttributeChangedEventNotifier.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/AttributeChangedEventNotifier.java
new file mode 100644
index 0000000..da7606f
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/AttributeChangedEventNotifier.java
@@ -0,0 +1,78 @@
+/*
+ * 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.xacml.admin.view.events;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.openaz.xacml.admin.jpa.Attribute;
+
+public interface AttributeChangedEventNotifier {
+
+ boolean addListener(AttributeChangedEventListener listener);
+
+ boolean removeListener(AttributeChangedEventListener listener);
+
+ void fireAttributeChanged(Attribute attribute);
+
+ void commit();
+
+ Attribute getAttribute();
+
+ class BasicNotifier implements AttributeChangedEventNotifier {
+ Collection<AttributeChangedEventListener> listeners = null;
+
+ @Override
+ public boolean addListener(AttributeChangedEventListener listener) {
+ if (this.listeners == null) {
+ this.listeners = new ArrayList<AttributeChangedEventListener>();
+ }
+ return this.listeners.add(listener);
+ }
+
+ @Override
+ public boolean removeListener(AttributeChangedEventListener listener) {
+ if (this.listeners == null) {
+ return false;
+ }
+ return this.listeners.remove(listener);
+ }
+
+ @Override
+ public void fireAttributeChanged(Attribute attribute) {
+ if (this.listeners == null) {
+ return;
+ }
+ for (AttributeChangedEventListener listener : this.listeners) {
+ listener.attributeChanged(attribute);
+ }
+ }
+
+ public void commit() {
+
+ }
+
+ public Attribute getAttribute() {
+ return null;
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/FormChangedEventListener.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/FormChangedEventListener.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/FormChangedEventListener.java
new file mode 100644
index 0000000..4637ee7
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/FormChangedEventListener.java
@@ -0,0 +1,25 @@
+/*
+ * 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.xacml.admin.view.events;
+
+public interface FormChangedEventListener {
+ void onFormChanged();
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/FormChangedEventNotifier.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/FormChangedEventNotifier.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/FormChangedEventNotifier.java
new file mode 100644
index 0000000..1b8ba9d
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/events/FormChangedEventNotifier.java
@@ -0,0 +1,61 @@
+/*
+ * 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.xacml.admin.view.events;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+public interface FormChangedEventNotifier {
+ boolean addListener(FormChangedEventListener listener);
+ boolean removeListener(FormChangedEventListener listener);
+ void fireFormChangedEvent();
+
+ class BasicNotifier implements FormChangedEventNotifier {
+ Collection<FormChangedEventListener> listeners = null;
+
+ @Override
+ public boolean addListener(FormChangedEventListener listener) {
+ if (this.listeners == null) {
+ this.listeners = new ArrayList<FormChangedEventListener>();
+ }
+ return this.listeners.add(listener);
+ }
+
+ @Override
+ public boolean removeListener(FormChangedEventListener listener) {
+ if (this.listeners == null) {
+ this.listeners = new ArrayList<FormChangedEventListener>();
+ }
+ return this.listeners.remove(listener);
+ }
+
+ @Override
+ public void fireFormChangedEvent() {
+ if (this.listeners == null) {
+ return;
+ }
+ for (FormChangedEventListener listener : this.listeners) {
+ listener.onFormChanged();
+ }
+ }
+
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/ConfigParamField.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/ConfigParamField.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/ConfigParamField.java
new file mode 100644
index 0000000..c91a192
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/ConfigParamField.java
@@ -0,0 +1,158 @@
+/*
+ * 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.xacml.admin.view.fields;
+
+import java.util.Collection;
+
+import org.apache.openaz.xacml.admin.jpa.PIPConfiguration;
+import org.apache.openaz.xacml.admin.jpa.PIPType;
+import org.apache.openaz.xacml.admin.view.components.CSVPIPConfigurationComponent;
+import org.apache.openaz.xacml.admin.view.components.CustomPIPConfigurationComponent;
+import org.apache.openaz.xacml.admin.view.components.HyperCSVPIPConfigurationComponent;
+import org.apache.openaz.xacml.admin.view.components.LDAPPIPConfigurationComponent;
+import org.apache.openaz.xacml.admin.view.components.SQLPIPConfigurationComponent;
+import org.apache.openaz.xacml.admin.view.events.FormChangedEventListener;
+import com.vaadin.addon.jpacontainer.EntityItem;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.CustomField;
+import com.vaadin.ui.VerticalLayout;
+
+public class ConfigParamField extends CustomField<Object> implements FormChangedEventListener {
+ private static final long serialVersionUID = 1L;
+ private final EntityItem<PIPConfiguration> entityConfig;
+ private VerticalLayout mainLayout = new VerticalLayout();
+
+ public ConfigParamField(EntityItem<PIPConfiguration> config) {
+ //
+ // Save
+ //
+ this.entityConfig = config;
+ //
+ // Make sure we can auto-fit
+ //
+ this.setWidth("-1px");
+ this.mainLayout.setWidth("-1px");
+ }
+
+ public Component resetContent(PIPType pipType) {
+ //
+ // Remove all the layout
+ //
+ this.mainLayout.removeAllComponents();
+ this.mainLayout.setDescription("Custom Field Layout");
+ //
+ // Is there a type?
+ //
+ if (pipType == null) {
+ return this.mainLayout;
+ }
+ //
+ // Setup the layout based on the type
+ //
+ Component c = null;
+ String type = pipType.getType();
+ if (type.equals(PIPType.TYPE_SQL)) {
+ SQLPIPConfigurationComponent comp = new SQLPIPConfigurationComponent(this.entityConfig);
+ comp.addListener(this);
+ c = comp;
+ } else if (type.equals(PIPType.TYPE_LDAP)) {
+ LDAPPIPConfigurationComponent comp = new LDAPPIPConfigurationComponent(this.entityConfig);
+ comp.addListener(this);
+ c = comp;
+ } else if (type.equals(PIPType.TYPE_CSV)) {
+ CSVPIPConfigurationComponent comp = new CSVPIPConfigurationComponent(this.entityConfig);
+ comp.addListener(this);
+ c = comp;
+ } else if (type.equals(PIPType.TYPE_HYPERCSV)) {
+ HyperCSVPIPConfigurationComponent comp = new HyperCSVPIPConfigurationComponent(this.entityConfig);
+ comp.addListener(this);
+ c = comp;
+ } else if (type.equals(PIPType.TYPE_CUSTOM)) {
+ CustomPIPConfigurationComponent comp = new CustomPIPConfigurationComponent(this.entityConfig);
+ comp.addListener(this);
+ c = comp;
+ }
+ if (c != null) {
+ this.mainLayout.addComponent(c);
+ }
+ //
+ // Done
+ //
+ return this.mainLayout;
+ }
+
+ @Override
+ protected Component initContent() {
+ return this.resetContent(this.entityConfig.getEntity().getPiptype());
+ }
+
+ @Override
+ public void validate() throws InvalidValueException {
+ if (this.mainLayout.getComponentCount() == 0) {
+ return;
+ }
+ Component c = this.mainLayout.getComponent(0);
+ if (c instanceof SQLPIPConfigurationComponent) {
+ ((SQLPIPConfigurationComponent)c).validate();
+ } else if (c instanceof LDAPPIPConfigurationComponent) {
+ ((LDAPPIPConfigurationComponent)c).validate();
+ } else if (c instanceof CSVPIPConfigurationComponent) {
+ ((CSVPIPConfigurationComponent)c).validate();
+ } else if (c instanceof HyperCSVPIPConfigurationComponent) {
+ ((HyperCSVPIPConfigurationComponent)c).validate();
+ } else if (c instanceof CustomPIPConfigurationComponent) {
+ ((CustomPIPConfigurationComponent)c).validate();
+ }
+ super.validate();
+ }
+
+ @Override
+ public void commit() throws SourceException, InvalidValueException {
+ if (this.mainLayout.getComponentCount() == 0) {
+ return;
+ }
+ Component c = this.mainLayout.getComponent(0);
+ if (c instanceof SQLPIPConfigurationComponent) {
+ ((SQLPIPConfigurationComponent)c).commit();
+ } else if (c instanceof LDAPPIPConfigurationComponent) {
+ ((LDAPPIPConfigurationComponent)c).commit();
+ } else if (c instanceof CSVPIPConfigurationComponent) {
+ ((CSVPIPConfigurationComponent)c).commit();
+ } else if (c instanceof HyperCSVPIPConfigurationComponent) {
+ ((HyperCSVPIPConfigurationComponent)c).commit();
+ } else if (c instanceof CustomPIPConfigurationComponent) {
+ ((CustomPIPConfigurationComponent)c).commit();
+ }
+ super.commit();
+ }
+
+ @Override
+ public Class<?> getType() {
+ return Collection.class;
+ }
+
+ @Override
+ public void onFormChanged() {
+ this.fireEvent(new com.vaadin.ui.Field.ValueChangeEvent(this));
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/ConstraintField.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/ConstraintField.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/ConstraintField.java
new file mode 100644
index 0000000..2004510
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/ConstraintField.java
@@ -0,0 +1,111 @@
+/*
+ * 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.xacml.admin.view.fields;
+
+import java.util.Collection;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.jpa.Attribute;
+import org.apache.openaz.xacml.admin.jpa.ConstraintType;
+import org.apache.openaz.xacml.admin.view.components.EnumerationEditorComponent;
+import org.apache.openaz.xacml.admin.view.components.RangeEditorComponent;
+import org.apache.openaz.xacml.admin.view.components.RegexpEditorComponent;
+import org.apache.openaz.xacml.api.Identifier;
+import com.vaadin.addon.jpacontainer.EntityItem;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.CustomField;
+import com.vaadin.ui.VerticalLayout;
+
+public class ConstraintField extends CustomField<Object> {
+ private static final long serialVersionUID = 1L;
+ private static final Log logger = LogFactory.getLog(ConstraintField.class);
+
+ private VerticalLayout mainLayout = new VerticalLayout();
+ private EntityItem<Attribute> attributeEntity;
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public ConstraintField(EntityItem<Attribute> entityItem) {
+ //
+ // Save our Attribute that we are editing
+ //
+ this.attributeEntity = entityItem;
+ }
+
+ public void resetDatatype(Identifier id) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("resetDatatype " + id);
+ }
+ if (this.mainLayout.getComponentCount() == 0) {
+ return;
+ }
+ Component component = this.mainLayout.getComponent(0);
+ if (component != null && component instanceof RangeEditorComponent) {
+ ((RangeEditorComponent) component).setupDatatype(id);
+ }
+ if (component != null && component instanceof EnumerationEditorComponent) {
+ ((EnumerationEditorComponent) component).setupDatatype(id);
+ }
+ }
+
+ public Component resetContent(ConstraintType type, Identifier datatype) {
+ //
+ // Remove all existing components
+ //
+ this.mainLayout.removeAllComponents();
+ //
+ // What are we constrained to?
+ //
+ if (type == null || type.getConstraintType() == null) {
+ //
+ // No constraint defined
+ //
+ this.attributeEntity.getEntity().removeAllConstraintValues();
+ return mainLayout;
+ }
+ if (type.getConstraintType().equals("Enumeration")) {
+ mainLayout.addComponent(new EnumerationEditorComponent(this.attributeEntity.getEntity(), datatype));
+ } else if (type.getConstraintType().equals("Range")) {
+ mainLayout.addComponent(new RangeEditorComponent(this.attributeEntity.getEntity(), datatype));
+ } else if (type.getConstraintType().equals("Regular Expression")) {
+ mainLayout.addComponent(new RegexpEditorComponent(this.attributeEntity.getEntity()));
+ }
+ return mainLayout;
+ }
+
+ @Override
+ protected Component initContent() {
+ return this.resetContent(this.attributeEntity.getEntity().getConstraintType(), this.attributeEntity.getEntity().getDatatypeBean().getIdentifer());
+ }
+
+ @Override
+ public Class<?> getType() {
+ return Collection.class;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/DesignatorSelectorField.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/DesignatorSelectorField.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/DesignatorSelectorField.java
new file mode 100644
index 0000000..62c7ffa
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/DesignatorSelectorField.java
@@ -0,0 +1,74 @@
+/*
+ * 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.xacml.admin.view.fields;
+
+import org.apache.openaz.xacml.admin.jpa.Attribute;
+import com.vaadin.addon.jpacontainer.EntityItem;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.CustomField;
+import com.vaadin.ui.OptionGroup;
+
+public class DesignatorSelectorField extends CustomField<Object> {
+ private static final long serialVersionUID = 1L;
+ private final DesignatorSelectorField self = this;
+ private final OptionGroup selectDesignator = new OptionGroup("Type of attribute");
+
+ public DesignatorSelectorField(EntityItem<Attribute> attributeEntity) {
+ this.selectDesignator.setImmediate(true);
+ this.selectDesignator.addItem(Attribute.ATTRIBUTE_DESIGNATOR);
+ this.selectDesignator.addItem(Attribute.ATTRIBUTE_SELECTOR);
+ if (attributeEntity.getEntity().isDesignator()) {
+ this.selectDesignator.select(Attribute.ATTRIBUTE_DESIGNATOR);
+ } else {
+ this.selectDesignator.select(Attribute.ATTRIBUTE_SELECTOR);
+ }
+ //
+ // Listen when designator vs selector changes
+ //
+ this.selectDesignator.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(
+ com.vaadin.data.Property.ValueChangeEvent event) {
+ Object value = self.selectDesignator.getValue();
+ if (value != null) {
+ if (value.toString().equals(Attribute.ATTRIBUTE_DESIGNATOR)) {
+ self.setValue('1');
+ } else if (value.toString().equals(Attribute.ATTRIBUTE_SELECTOR)) {
+ self.setValue('0');
+ }
+ }
+ }
+ });
+ }
+
+ @Override
+ protected Component initContent() {
+ return this.selectDesignator;
+ }
+
+ @Override
+ public Class<? extends Object> getType() {
+ return Character.class;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/ExpressionField.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/ExpressionField.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/ExpressionField.java
new file mode 100644
index 0000000..d1f250b
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/ExpressionField.java
@@ -0,0 +1,47 @@
+/*
+ * 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.xacml.admin.view.fields;
+
+import java.util.Collection;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.vaadin.ui.Component;
+import com.vaadin.ui.CustomField;
+
+
+public class ExpressionField extends CustomField<Object> {
+ private static final long serialVersionUID = 1L;
+ private static final Log logger = LogFactory.getLog(ExpressionField.class); //NOPMD
+
+ @Override
+ protected Component initContent() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Class<? extends Object> getType() {
+ return Collection.class;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/OaExpressionsField.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/OaExpressionsField.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/OaExpressionsField.java
new file mode 100644
index 0000000..f5ca9fd
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/OaExpressionsField.java
@@ -0,0 +1,51 @@
+/*
+ * 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.xacml.admin.view.fields;
+
+import java.util.Collection;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.jpa.Obadvice;
+import org.apache.openaz.xacml.admin.view.components.OaExpressionsEditorComponent;
+import com.vaadin.addon.jpacontainer.EntityItem;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.CustomField;
+import com.vaadin.ui.UI;
+
+public class OaExpressionsField extends CustomField<Object> {
+ private static final long serialVersionUID = 1L;
+ private final EntityItem<Obadvice> obad;
+
+ public OaExpressionsField(EntityItem<Obadvice> obad) {
+ this.obad = obad;
+ }
+
+ @Override
+ protected Component initContent() {
+ return new OaExpressionsEditorComponent(this.obad, ((XacmlAdminUI)UI.getCurrent()).getObadviceExpressions());
+ }
+
+ @Override
+ public Class<? extends Object> getType() {
+ return Collection.class;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/ResolverParamField.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/ResolverParamField.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/ResolverParamField.java
new file mode 100644
index 0000000..9986dc7
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/fields/ResolverParamField.java
@@ -0,0 +1,123 @@
+/*
+ * 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.xacml.admin.view.fields;
+
+import java.util.Collection;
+
+import org.apache.openaz.xacml.admin.jpa.PIPResolver;
+import org.apache.openaz.xacml.admin.view.components.PIPParameterComponent;
+import org.apache.openaz.xacml.admin.view.events.FormChangedEventListener;
+import org.apache.openaz.xacml.admin.view.windows.PIPSQLResolverEditorWindow;
+import com.vaadin.addon.jpacontainer.EntityItem;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.ui.Component;
+import com.vaadin.ui.CustomField;
+import com.vaadin.ui.VerticalLayout;
+
+public class ResolverParamField extends CustomField<Object> implements FormChangedEventListener {
+ private static final long serialVersionUID = 1L;
+ private final EntityItem<PIPResolver> entity;
+ private VerticalLayout mainLayout = new VerticalLayout();
+
+ public ResolverParamField(EntityItem<PIPResolver> entity) {
+ this.entity = entity;
+ //
+ // Make sure we can auto-fit
+ //
+ this.setWidth("-1px");
+ this.mainLayout.setWidth("-1px");
+ }
+
+ @Override
+ public void onFormChanged() {
+ this.fireEvent(new com.vaadin.ui.Field.ValueChangeEvent(this));
+ }
+
+ @Override
+ protected Component initContent() {
+ Component c = null;
+ if (this.entity.getEntity().getPipconfiguration().getPiptype().isSQL() ||
+ this.entity.getEntity().getPipconfiguration().getPiptype().isHyperCSV() ||
+ this.entity.getEntity().getPipconfiguration().getPiptype().isLDAP() ||
+ this.entity.getEntity().getPipconfiguration().getPiptype().isCSV() ) {
+ //
+ //
+ //
+ PIPSQLResolverEditorWindow comp = new PIPSQLResolverEditorWindow(this.entity);
+ comp.addListener(this);
+ c = comp;
+ } else {
+ //
+ //
+ //
+ PIPParameterComponent comp = new PIPParameterComponent(this.entity.getEntity());
+ comp.addListener(this);
+ c = comp;
+ }
+ if (c != null) {
+ this.mainLayout.addComponent(c);
+ }
+ return this.mainLayout;
+ }
+
+
+ @Override
+ public void discard() throws SourceException {
+ if (this.mainLayout.getComponentCount() == 0) {
+ return;
+ }
+ Component c = this.mainLayout.getComponent(0);
+ if (c instanceof PIPSQLResolverEditorWindow) {
+ ((PIPSQLResolverEditorWindow)c).discard();
+ }
+ super.discard();
+ }
+
+ @Override
+ public void validate() throws InvalidValueException {
+ if (this.mainLayout.getComponentCount() == 0) {
+ return;
+ }
+ Component c = this.mainLayout.getComponent(0);
+ if (c instanceof PIPSQLResolverEditorWindow) {
+ ((PIPSQLResolverEditorWindow)c).validate();
+ }
+ super.validate();
+ }
+
+ @Override
+ public void commit() throws SourceException, InvalidValueException {
+ if (this.mainLayout.getComponentCount() == 0) {
+ return;
+ }
+ Component c = this.mainLayout.getComponent(0);
+ if (c instanceof PIPSQLResolverEditorWindow) {
+ ((PIPSQLResolverEditorWindow)c).commit();
+ }
+ super.commit();
+ }
+
+ @Override
+ public Class<? extends Object> getType() {
+ return Collection.class;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/AnyURIValidator.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/AnyURIValidator.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/AnyURIValidator.java
new file mode 100644
index 0000000..1101f23
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/AnyURIValidator.java
@@ -0,0 +1,45 @@
+/*
+ * 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.xacml.admin.view.validators;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import com.vaadin.data.Validator;
+
+public class AnyURIValidator implements Validator {
+ private static final long serialVersionUID = 1L;
+
+ public AnyURIValidator() {
+ }
+
+ @Override
+ public void validate(Object value) throws InvalidValueException {
+ if (value instanceof String) {
+ try {
+ new URI((String) value);
+ } catch (URISyntaxException e) {
+ throw new InvalidValueException(e.getLocalizedMessage());
+ }
+ } else
+ throw new InvalidValueException("Unrecognized URI");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/Base64BinaryValidator.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/Base64BinaryValidator.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/Base64BinaryValidator.java
new file mode 100644
index 0000000..362a5d9
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/Base64BinaryValidator.java
@@ -0,0 +1,56 @@
+/*
+ * 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.xacml.admin.view.validators;
+
+// import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.binary.Base64;
+
+import com.vaadin.data.Validator;
+
+public class Base64BinaryValidator implements Validator {
+ private static final long serialVersionUID = 1L;
+
+ public Base64BinaryValidator() {
+ }
+
+ @Override
+ public void validate(Object value) throws InvalidValueException {
+ if (value instanceof String) {
+ // try {
+ new Base64().decode((String) value);
+ // Base64().decode(String) inherited from
+ // org.apache.commons.codec.binary.BaseNCodec
+ // does not throw DecoderException in version 1.10
+ // of org.apache.commons.codec (the version we are
+ // using). This may need to be uncommented in later
+ // versions.
+ //
+ // TODO - Since this does not throw an exception under
+ // any circumstance, I question whether it is
+ // a valid method of validating the input value.
+ //
+ // } catch (DecoderException e) {
+ // throw new InvalidValueException(e.getLocalizedMessage());
+ // }
+ } else
+ throw new InvalidValueException("Unrecognized Base64 Binary");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/BooleanValidator.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/BooleanValidator.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/BooleanValidator.java
new file mode 100644
index 0000000..0e2c8c1
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/BooleanValidator.java
@@ -0,0 +1,45 @@
+/*
+ * 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.xacml.admin.view.validators;
+
+import com.vaadin.data.Validator;
+
+public class BooleanValidator implements Validator {
+ private static final long serialVersionUID = 1L;
+
+ public BooleanValidator() {
+ }
+
+ @Override
+ public void validate(Object value) throws InvalidValueException {
+ if (value instanceof Boolean) {
+ return;
+ }
+ if (value.toString().equalsIgnoreCase("true") ||
+ value.toString().equalsIgnoreCase("false") ||
+ value.toString().equalsIgnoreCase("0") ||
+ value.toString().equalsIgnoreCase("1")) {
+ return;
+ }
+ throw new InvalidValueException("Unrecognized boolean");
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/DNSNameValidator.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/DNSNameValidator.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/DNSNameValidator.java
new file mode 100644
index 0000000..3d2c8d0
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/DNSNameValidator.java
@@ -0,0 +1,45 @@
+/*
+ * 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.xacml.admin.view.validators;
+
+import java.text.ParseException;
+
+import org.apache.openaz.xacml.std.datatypes.RFC2396DomainName;
+import com.vaadin.data.Validator;
+
+public class DNSNameValidator implements Validator {
+ private static final long serialVersionUID = 1L;
+
+ public DNSNameValidator() {
+ }
+
+ @Override
+ public void validate(Object value) throws InvalidValueException {
+ if (value instanceof String) {
+ try {
+ RFC2396DomainName.newInstance((String) value);
+ } catch (ParseException e) {
+ throw new InvalidValueException(e.getLocalizedMessage());
+ }
+ } else
+ throw new InvalidValueException("Unrecognized DNS Name");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/DateTimeValidator.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/DateTimeValidator.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/DateTimeValidator.java
new file mode 100644
index 0000000..4bdea6e
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/DateTimeValidator.java
@@ -0,0 +1,45 @@
+/*
+ * 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.xacml.admin.view.validators;
+
+import java.text.ParseException;
+
+import org.apache.openaz.xacml.std.datatypes.ISO8601DateTime;
+import com.vaadin.data.Validator;
+
+public class DateTimeValidator implements Validator {
+ private static final long serialVersionUID = 1L;
+
+ public DateTimeValidator() {
+ }
+
+ @Override
+ public void validate(Object value) throws InvalidValueException {
+ if (value instanceof String) {
+ try {
+ ISO8601DateTime.fromISO8601DateTimeString((String) value);
+ } catch (ParseException e) {
+ throw new InvalidValueException(e.getLocalizedMessage());
+ }
+ } else
+ throw new InvalidValueException("Unrecognized DateTime");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/DateValidator.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/DateValidator.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/DateValidator.java
new file mode 100644
index 0000000..0d217e4
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/DateValidator.java
@@ -0,0 +1,45 @@
+/*
+ * 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.xacml.admin.view.validators;
+
+import java.text.ParseException;
+
+import org.apache.openaz.xacml.std.datatypes.ISO8601Date;
+import com.vaadin.data.Validator;
+
+public class DateValidator implements Validator {
+ private static final long serialVersionUID = 1L;
+
+ public DateValidator() {
+ }
+
+ @Override
+ public void validate(Object value) throws InvalidValueException {
+ if (value instanceof String) {
+ try {
+ ISO8601Date.fromISO8601DateString((String) value);
+ } catch (ParseException e) {
+ throw new InvalidValueException(e.getLocalizedMessage());
+ }
+ } else
+ throw new InvalidValueException("Unrecognized Date");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/DayTimeDurationValidator.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/DayTimeDurationValidator.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/DayTimeDurationValidator.java
new file mode 100644
index 0000000..f8aaa6b
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/DayTimeDurationValidator.java
@@ -0,0 +1,45 @@
+/*
+ * 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.xacml.admin.view.validators;
+
+import java.text.ParseException;
+
+import org.apache.openaz.xacml.std.datatypes.XPathDayTimeDuration;
+import com.vaadin.data.Validator;
+
+public class DayTimeDurationValidator implements Validator {
+ private static final long serialVersionUID = 1L;
+
+ public DayTimeDurationValidator() {
+ }
+
+ @Override
+ public void validate(Object value) throws InvalidValueException {
+ if (value instanceof String) {
+ try {
+ XPathDayTimeDuration.newInstance((String) value);
+ } catch (ParseException e) {
+ throw new InvalidValueException(e.getLocalizedMessage());
+ }
+ } else
+ throw new InvalidValueException("Unrecognized DayTimeDuration");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/DoubleValidator.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/DoubleValidator.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/DoubleValidator.java
new file mode 100644
index 0000000..a0fc0dd
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/DoubleValidator.java
@@ -0,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.xacml.admin.view.validators;
+
+import com.vaadin.data.Validator;
+
+public class DoubleValidator implements Validator {
+ private static final long serialVersionUID = 1L;
+
+ public DoubleValidator() {
+ }
+
+ @Override
+ public void validate(Object value) throws InvalidValueException {
+ if (value instanceof Double) {
+ return;
+ }
+ try {
+ Double.parseDouble(value.toString());
+ } catch (NumberFormatException e) {
+ throw new InvalidValueException(e.getLocalizedMessage());
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/HexBinaryValidator.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/HexBinaryValidator.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/HexBinaryValidator.java
new file mode 100644
index 0000000..e8065b1
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/HexBinaryValidator.java
@@ -0,0 +1,45 @@
+/*
+ * 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.xacml.admin.view.validators;
+
+import org.apache.commons.codec.DecoderException;
+
+import org.apache.openaz.xacml.std.datatypes.HexBinary;
+import com.vaadin.data.Validator;
+
+public class HexBinaryValidator implements Validator {
+ private static final long serialVersionUID = 1L;
+
+ public HexBinaryValidator() {
+ }
+
+ @Override
+ public void validate(Object value) throws InvalidValueException {
+ if (value instanceof String) {
+ try {
+ HexBinary.newInstance((String) value);
+ } catch (DecoderException e) {
+ throw new InvalidValueException(e.getLocalizedMessage());
+ }
+ } else
+ throw new InvalidValueException("Unrecognized HexBinary");
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/IntegerValidator.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/IntegerValidator.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/IntegerValidator.java
new file mode 100644
index 0000000..3996819
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/IntegerValidator.java
@@ -0,0 +1,42 @@
+/*
+ * 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.xacml.admin.view.validators;
+
+import com.vaadin.data.Validator;
+
+public class IntegerValidator implements Validator {
+ private static final long serialVersionUID = 1L;
+
+ public IntegerValidator() {
+ }
+
+ @Override
+ public void validate(Object value) throws InvalidValueException {
+ if (value instanceof Integer) {
+ return;
+ }
+ try {
+ Integer.parseInt(value.toString());
+ } catch (NumberFormatException e) {
+ throw new InvalidValueException(e.getLocalizedMessage());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/IpAddressValidator.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/IpAddressValidator.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/IpAddressValidator.java
new file mode 100644
index 0000000..72aa772
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/validators/IpAddressValidator.java
@@ -0,0 +1,45 @@
+/*
+ * 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.xacml.admin.view.validators;
+
+import java.text.ParseException;
+
+import org.apache.openaz.xacml.std.datatypes.IPAddress;
+import com.vaadin.data.Validator;
+
+public class IpAddressValidator implements Validator {
+ private static final long serialVersionUID = 1L;
+
+ public IpAddressValidator() {
+ }
+
+ @Override
+ public void validate(Object value) throws InvalidValueException {
+ if (value instanceof String) {
+ try {
+ IPAddress.newInstance((String) value);
+ } catch (ParseException e) {
+ throw new InvalidValueException(e.getLocalizedMessage());
+ }
+ } else
+ throw new InvalidValueException("Unrecognized IP Address");
+ }
+}
[04/23] incubator-openaz git commit: Ported original att source to
openaz
Posted by pd...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPConfigurationEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPConfigurationEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPConfigurationEditorWindow.java
new file mode 100644
index 0000000..08f9306
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPConfigurationEditorWindow.java
@@ -0,0 +1,364 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import java.util.Locale;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.jpa.PIPConfiguration;
+import org.apache.openaz.xacml.admin.jpa.PIPType;
+import org.apache.openaz.xacml.admin.util.JPAUtils;
+import org.apache.openaz.xacml.admin.view.fields.ConfigParamField;
+import com.vaadin.addon.jpacontainer.EntityItem;
+import com.vaadin.addon.jpacontainer.fieldfactory.SingleSelectConverter;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.fieldgroup.FieldGroup;
+import com.vaadin.data.fieldgroup.FieldGroup.CommitException;
+import com.vaadin.data.fieldgroup.PropertyId;
+import com.vaadin.data.util.converter.Converter;
+import com.vaadin.event.FieldEvents.TextChangeEvent;
+import com.vaadin.event.FieldEvents.TextChangeListener;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.AbstractSelect.ItemCaptionMode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.Window;
+
+public class PIPConfigurationEditorWindow extends Window {
+ private static final long serialVersionUID = 1L;
+ private static final Log logger = LogFactory.getLog(PIPConfigurationEditorWindow.class);
+ private final PIPConfigurationEditorWindow self = this;
+ private final EntityItem<PIPConfiguration> entity;
+ private FieldGroup fieldGroup;
+ private boolean isSaved = false;
+
+ private GridLayout grid = new GridLayout(2,6);
+
+ @PropertyId("piptype")
+ ComboBox comboType = new ComboBox("Type");
+
+ @PropertyId("name")
+ TextField fieldName = new TextField("Name");
+
+ @PropertyId("description")
+ TextArea areaDescription = new TextArea("Description");
+
+ @PropertyId("issuer")
+ TextField fieldIssuer = new TextField("Issuer");
+
+ @PropertyId("requiresResolvers")
+ CheckBox requiresResolvers = new CheckBox("Requires Resolvers");
+
+ @PropertyId("pipconfigParams")
+ ConfigParamField paramField = null;
+
+ Button buttonSave = new Button("Save");
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public PIPConfigurationEditorWindow(EntityItem<PIPConfiguration> entity) {
+ //
+ // Our base component
+ //
+ this.setContent(this.grid);
+ this.grid.setMargin(true);
+ this.grid.setSpacing(true);
+ //
+ // Set our shortcuts
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ // Save
+ //
+ this.entity = entity;
+ //
+ // Check if a brand new object and set the default
+ // pip type.
+ //
+ if (this.entity.getEntity().getPiptype() == null) {
+ this.entity.getEntity().setPiptype(JPAUtils.getPIPType(PIPType.TYPE_SQL));
+ }
+
+ //
+ // Initialize GUI components
+ //
+ this.initialize();
+ //
+ // Add components
+ //
+ this.grid.addComponent(this.comboType, 0, 0);
+ this.grid.addComponent(this.fieldName, 0, 1);
+ this.grid.addComponent(this.fieldIssuer, 0, 2);
+ this.grid.addComponent(this.areaDescription, 0, 3);
+ this.grid.addComponent(this.requiresResolvers, 0, 4);
+ this.grid.addComponent(this.paramField, 1, 0, 1, 4);
+ this.grid.addComponent(this.buttonSave, 0, 5, 1, 5);
+ //
+ // Bind and initialize
+ //
+ this.initializeFields();
+ //
+ // Post initialize
+ //
+ this.initializeButtons();
+ //
+ // Set focus
+ //
+ this.fieldName.focus();
+ //
+ // Initially call this to see if the entity is already
+ // saveable
+ //
+ this.formChanged();
+ }
+
+ protected void initialize() {
+ //
+ //
+ //
+ this.fieldName.setImmediate(true);
+ this.fieldName.setNullRepresentation("");
+ this.fieldName.setRequired(true);
+ this.fieldName.setRequiredError("Enter a name for the configuration");
+ this.fieldName.setInputPrompt("Eg. \"Company LDAP Server\" or \"MySQL Customer DB\"");
+
+ this.fieldIssuer.setNullRepresentation("");
+ this.fieldIssuer.setRequired(false);
+ this.fieldIssuer.setInputPrompt("Eg. urn:com:sample:hr");
+
+ this.areaDescription.setNullRepresentation("");
+ this.areaDescription.setRequired(false);
+ this.areaDescription.setInputPrompt("Optionally write a description for this configuration.");
+ this.areaDescription.setRows(3);
+ this.areaDescription.setWidth("100%");
+ //
+ //
+ //
+ this.requiresResolvers.setConverter(new Converter<Boolean, Object>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Object convertToModel(Boolean value,
+ Class<? extends Object> targetType, Locale locale)
+ throws Converter.ConversionException {
+ if (targetType.isAssignableFrom(java.lang.Character.class)) {
+ if (value) {
+ return '1';
+ } else {
+ return '0';
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Boolean convertToPresentation(Object value,
+ Class<? extends Boolean> targetType, Locale locale)
+ throws Converter.ConversionException {
+ if (value instanceof Character) {
+ return ((Character) value) == '1';
+ }
+ return null;
+ }
+
+ @Override
+ public Class<Object> getModelType() {
+ return Object.class;
+ }
+
+ @Override
+ public Class<Boolean> getPresentationType() {
+ return Boolean.class;
+ }
+ });
+ //
+ //
+ //
+ this.comboType.setContainerDataSource(((XacmlAdminUI)UI.getCurrent()).getPIPTypes());
+ this.comboType.setImmediate(true);
+ this.comboType.setConverter(new SingleSelectConverter<Object>(this.comboType));
+ this.comboType.setItemCaptionMode(ItemCaptionMode.PROPERTY);
+ this.comboType.setItemCaptionPropertyId("type");
+ this.comboType.setNullSelectionAllowed(false);
+ this.comboType.setRequired(true);
+ this.comboType.setRequiredError("You need to identify what type of configuration this is.");
+ //
+ //
+ //
+ this.paramField = new ConfigParamField(this.entity);
+ this.paramField.setValidationVisible(false);
+ }
+
+ protected void initializeFields() {
+ //
+ // Now create our field group and bind our fields.
+ // This will populate the components with the
+ // current value if we are editing an entity.
+ //
+ this.fieldGroup = new FieldGroup(this.entity);
+ this.fieldGroup.bindMemberFields(this);
+ //
+ //
+ //
+ this.fieldName.addTextChangeListener(new TextChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void textChange(TextChangeEvent event) {
+ self.formChanged();
+ }
+
+ });
+ this.fieldName.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ self.formChanged();
+ }
+ });
+ //
+ //
+ //
+ this.paramField.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ self.formChanged();
+ }
+ });
+ //
+ // Only custom PIP configurations should be allowed to
+ // check the "requires resolvers" box. We know that the
+ // SQL/LDAP/HyperSQL/CSV resolver already do require resolvers.
+ //
+ if (this.entity.getEntity().getPiptype().isCustom() == false) {
+ this.requiresResolvers.setEnabled(false);
+ }
+ //
+ // Finish GUI intialization
+ //
+ if (this.entity.isPersistent()) {
+ //
+ // The user is editing something, don't let them change
+ // the type
+ //
+ this.comboType.setReadOnly(true);
+ }
+ this.comboType.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ //
+ // Get the new value
+ //
+ Object id = self.comboType.getValue();
+ EntityItem<PIPType> type = null;
+ if (id != null) {
+ type = ((XacmlAdminUI) UI.getCurrent()).getPIPTypes().getItem(id);
+ }
+ //
+ // Have our custom field reset itself
+ //
+ self.paramField.resetContent(type != null ? type.getEntity() : null);
+ //
+ // Do we need to display the requires resolver check box?
+ //
+ if (type != null && type.getEntity().isCustom()) {
+ self.requiresResolvers.setEnabled(true);
+ self.requiresResolvers.setRequired(true);
+ self.requiresResolvers.setValue(self.entity.getEntity().requiresResolvers());
+ } else {
+ self.requiresResolvers.setEnabled(false);
+ self.requiresResolvers.setRequired(false);
+ }
+ //
+ // Re-center the form
+ //
+ self.center();
+ //
+ // Check if we can enable the save button
+ //
+ self.formChanged();
+ }
+ });
+ }
+
+ protected void formChanged() {
+ if (this.fieldGroup.isValid() || this.entity.isModified()) {
+ this.buttonSave.setEnabled(true);
+ } else {
+ this.buttonSave.setEnabled(false);
+ }
+ }
+
+ protected void initializeButtons() {
+ this.grid.setComponentAlignment(this.buttonSave, Alignment.BOTTOM_CENTER);
+ this.buttonSave.setImmediate(true);
+ this.buttonSave.setEnabled(false);
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ try {
+ //
+ // Commit changes
+ //
+ self.fieldGroup.commit();
+ //
+ // Save
+ //
+ self.isSaved = true;
+ //
+ // We can close
+ //
+ self.close();
+ } catch (CommitException e) {
+ logger.warn("Couldn't commit, the save button should NOT be enabled.");
+ }
+ }
+ });
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPCustomResolverEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPCustomResolverEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPCustomResolverEditorWindow.java
new file mode 100644
index 0000000..e024d0e
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPCustomResolverEditorWindow.java
@@ -0,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.xacml.admin.view.windows;
+
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.VerticalLayout;
+
+public class PIPCustomResolverEditorWindow extends CustomComponent {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public PIPCustomResolverEditorWindow() {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(false);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPImportWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPImportWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPImportWindow.java
new file mode 100644
index 0000000..650ed09
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPImportWindow.java
@@ -0,0 +1,116 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.ui.Upload;
+import com.vaadin.ui.Upload.Receiver;
+import com.vaadin.ui.Upload.SucceededEvent;
+import com.vaadin.ui.Upload.SucceededListener;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class PIPImportWindow extends Window implements Receiver, SucceededListener {
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+ private static final Log logger = LogFactory.getLog(PolicyUploadWindow.class);
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+
+ @AutoGenerated
+ private Upload upload;
+
+ private static final long serialVersionUID = 1L;
+ private String filename = null;
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public PIPImportWindow() {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Set ourselves up
+ //
+ this.upload.addSucceededListener(this);
+ this.upload.setReceiver(this);
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // upload_1
+ upload = new Upload();
+ upload.setImmediate(false);
+ upload.setWidth("-1px");
+ upload.setHeight("-1px");
+ mainLayout.addComponent(upload);
+
+ return mainLayout;
+ }
+
+ @Override
+ public void uploadSucceeded(SucceededEvent event) {
+ this.filename = event.getFilename();
+ this.close();
+ }
+
+ @Override
+ public OutputStream receiveUpload(String filename, String mimeType) {
+ //
+ // Try to create the output stream
+ //
+ try {
+ return new FileOutputStream(filename);
+ } catch (FileNotFoundException e) {
+ logger.error("Failed to create uploaded file", e);
+ }
+ return null;
+ }
+
+ public String getUploadedFile() {
+ return this.filename;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPParamEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPParamEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPParamEditorWindow.java
new file mode 100644
index 0000000..70942c2
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPParamEditorWindow.java
@@ -0,0 +1,261 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import org.apache.openaz.xacml.admin.jpa.PIPConfigParam;
+import org.apache.openaz.xacml.admin.jpa.PIPResolverParam;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Buffered.SourceException;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class PIPParamEditorWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSave;
+ @AutoGenerated
+ private TextField textFieldValue;
+ @AutoGenerated
+ private TextField textFieldName;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private final PIPParamEditorWindow self = this;
+ private final Object config;
+ private boolean isSaved = false;
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public PIPParamEditorWindow(Object config) {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Save parameters
+ //
+ this.config = config;
+ //
+ // Initialize
+ //
+ this.initialize();
+ //
+ // close shortcut
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ // focus
+ //
+ this.textFieldName.focus();
+ }
+
+ protected void initialize() {
+ //
+ // GUI properties
+ //
+ this.textFieldName.setImmediate(true);
+ this.textFieldName.setNullRepresentation("");
+ this.textFieldValue.setImmediate(true);
+ this.textFieldValue.setNullRepresentation("");
+ //
+ // Now setup based on the object
+ //
+ if (this.config instanceof PIPConfigParam) {
+ this.initializePIPConfiguration();
+ } else if (this.config instanceof PIPResolverParam) {
+ this.initializePIPResolver();
+ } else {
+ throw new IllegalArgumentException("Unknown object");
+ }
+ this.initializeButtons();
+ this.setupButtons();
+ }
+
+ protected void initializePIPConfiguration() {
+ final PIPConfigParam param = (PIPConfigParam) this.config;
+ //
+ // setup the name
+ //
+ this.textFieldName.setValue(param.getParamName());
+ this.textFieldName.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ param.setParamName(self.textFieldName.getValue());
+ self.setupButtons();
+ }
+ });
+ //
+ // setup the value
+ //
+ this.textFieldValue.setValue(param.getParamValue());
+ this.textFieldValue.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ param.setParamValue(self.textFieldValue.getValue());
+ self.setupButtons();
+ }
+ });
+ }
+
+ protected void initializePIPResolver() {
+ final PIPResolverParam param = (PIPResolverParam) this.config;
+ //
+ // setup the name
+ //
+ this.textFieldName.setValue(param.getParamName());
+ this.textFieldName.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ param.setParamName(self.textFieldName.getValue());
+ self.setupButtons();
+ }
+ });
+ //
+ // setup the value
+ //
+ this.textFieldValue.setValue(param.getParamValue());
+ this.textFieldValue.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ param.setParamValue(self.textFieldValue.getValue());
+ self.setupButtons();
+ }
+ });
+ }
+
+ protected void initializeButtons() {
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ try {
+ //
+ // Commit the values
+ //
+ self.textFieldName.commit();
+ self.textFieldValue.commit();
+ //
+ // Done, save
+ //
+ self.isSaved = true;
+ //
+ // Close
+ //
+ self.close();
+ } catch (SourceException | InvalidValueException e) { //NOPMD
+ //
+ // Vaadin will display error
+ //
+ }
+ }
+ });
+ }
+
+ protected void setupButtons() {
+ if (this.textFieldName.getValue() != null && this.textFieldValue.getValue() != null) {
+ this.buttonSave.setEnabled(true);
+ } else {
+ this.buttonSave.setEnabled(false);
+ }
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ public Object getParameter() {
+ return this.config;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // textFieldName
+ textFieldName = new TextField();
+ textFieldName.setCaption("Parameter Name");
+ textFieldName.setImmediate(false);
+ textFieldName.setWidth("-1px");
+ textFieldName.setHeight("-1px");
+ textFieldName.setInvalidAllowed(false);
+ textFieldName.setRequired(true);
+ mainLayout.addComponent(textFieldName);
+
+ // textFieldValue
+ textFieldValue = new TextField();
+ textFieldValue.setCaption("Parameter Value");
+ textFieldValue.setImmediate(false);
+ textFieldValue.setWidth("-1px");
+ textFieldValue.setHeight("-1px");
+ textFieldValue.setInvalidAllowed(false);
+ textFieldValue.setRequired(true);
+ mainLayout.addComponent(textFieldValue);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save");
+ buttonSave.setImmediate(true);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPResolverEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPResolverEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPResolverEditorWindow.java
new file mode 100644
index 0000000..530fddb
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPResolverEditorWindow.java
@@ -0,0 +1,226 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.jpa.PIPResolver;
+import org.apache.openaz.xacml.admin.view.fields.ResolverParamField;
+import com.vaadin.addon.jpacontainer.EntityItem;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.fieldgroup.FieldGroup;
+import com.vaadin.data.fieldgroup.FieldGroup.CommitException;
+import com.vaadin.data.fieldgroup.PropertyId;
+import com.vaadin.event.FieldEvents.TextChangeEvent;
+import com.vaadin.event.FieldEvents.TextChangeListener;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.GridLayout;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.Window;
+
+public class PIPResolverEditorWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static final Log logger = LogFactory.getLog(PIPResolverEditorWindow.class);
+ private final PIPResolverEditorWindow self = this;
+
+ private final EntityItem<PIPResolver> entity;
+ private FieldGroup fieldGroup;
+ private boolean isSaved = false;
+ private GridLayout grid = new GridLayout(2,4);
+
+ @PropertyId("name")
+ TextField fieldName = new TextField("Name");
+
+ @PropertyId("description")
+ TextArea areaDescription = new TextArea("Description");
+
+ @PropertyId("issuer")
+ TextField fieldIssuer = new TextField("Issuer");
+
+ @PropertyId("pipresolverParams")
+ ResolverParamField paramField;
+
+ Button buttonSave = new Button("Save");
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public PIPResolverEditorWindow(EntityItem<PIPResolver> entity) {
+ //
+ // Our base component
+ //
+ this.setContent(this.grid);
+ this.grid.setMargin(true);
+ this.grid.setSpacing(true);
+ //
+ // Save
+ //
+ this.entity = entity;
+ //
+ // Set our shortcuts
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ // Initialize
+ //
+ this.initialize();
+ //
+ // Add components
+ //
+ this.grid.addComponent(this.fieldName, 0, 0);
+ this.grid.addComponent(this.fieldIssuer, 0, 1);
+ this.grid.addComponent(this.areaDescription, 0, 2);
+ this.grid.addComponent(this.paramField, 1, 0, 1, 2);
+ this.grid.addComponent(this.buttonSave, 0, 3, 1, 3);
+ //
+ // Bind and initialize
+ //
+ this.initializeFields();
+ //
+ // Post initialize
+ //
+ this.initializeButtons();
+ //
+ // Set focus
+ //
+ this.fieldName.focus();
+ //
+ // Initially call this to see if the entity is already
+ // saveable
+ //
+ this.formChanged();
+ }
+
+ protected void initialize() {
+ //
+ //
+ //
+ this.fieldName.setImmediate(true);
+ this.fieldName.setNullRepresentation("");
+ this.fieldName.setRequired(true);
+ this.fieldName.setRequiredError("Enter a name for the resolver");
+ this.fieldName.setInputPrompt("Eg. \"Resolve employee type\"");
+
+ this.fieldIssuer.setNullRepresentation("");
+ this.fieldIssuer.setRequired(false);
+ this.fieldIssuer.setInputPrompt("Eg. urn:com:sample:hr");
+
+ this.areaDescription.setNullRepresentation("");
+ this.areaDescription.setRequired(false);
+ this.areaDescription.setInputPrompt("Optionally write a description for this resolver.");
+ this.areaDescription.setRows(3);
+ this.areaDescription.setWidth("100%");
+ //
+ // Create our field
+ //
+ this.paramField = new ResolverParamField(this.entity);
+ //this.paramField.setValidationVisible(false);
+ }
+
+ protected void initializeFields() {
+ //
+ // Now create our field group and bind our fields.
+ // This will populate the components with the
+ // current value if we are editing an entity.
+ //
+ this.fieldGroup = new FieldGroup(this.entity);
+ this.fieldGroup.bindMemberFields(this);
+ //
+ //
+ //
+ this.fieldName.addTextChangeListener(new TextChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void textChange(TextChangeEvent event) {
+ self.formChanged();
+ }
+ });
+ //
+ //
+ //
+ this.paramField.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ self.formChanged();
+ }
+ });
+ }
+
+ protected void formChanged() {
+ if (this.fieldGroup.isValid() || this.entity.isModified()) {
+ this.buttonSave.setEnabled(true);
+ } else {
+ this.buttonSave.setEnabled(false);
+ }
+ }
+
+ protected void initializeButtons() {
+ this.grid.setComponentAlignment(this.buttonSave, Alignment.BOTTOM_CENTER);
+ this.buttonSave.setImmediate(true);
+ this.buttonSave.setEnabled(false);
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ try {
+ //
+ // Commit changes
+ //
+ self.fieldGroup.commit();
+ //
+ // Save
+ //
+ self.isSaved = true;
+ //
+ // We can close
+ //
+ self.close();
+ } catch (CommitException e) {
+ logger.warn("Couldn't commit, the save button should NOT be enabled.");
+ }
+ }
+ });
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPSQLResolverEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPSQLResolverEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPSQLResolverEditorWindow.java
new file mode 100644
index 0000000..2fb4a25
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PIPSQLResolverEditorWindow.java
@@ -0,0 +1,1199 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.jpa.Attribute;
+import org.apache.openaz.xacml.admin.jpa.PIPResolver;
+import org.apache.openaz.xacml.admin.jpa.PIPResolverParam;
+import org.apache.openaz.xacml.admin.util.AdminNotification;
+import org.apache.openaz.xacml.admin.util.XACMLConstants;
+import org.apache.openaz.xacml.admin.view.events.FormChangedEventListener;
+import org.apache.openaz.xacml.admin.view.events.FormChangedEventNotifier;
+import org.apache.openaz.xacml.api.XACML3;
+import org.apache.openaz.xacml.std.pip.engines.csv.ConfigurableCSVResolver;
+import org.apache.openaz.xacml.std.pip.engines.jdbc.ConfigurableJDBCResolver;
+import org.apache.openaz.xacml.std.pip.engines.ldap.ConfigurableLDAPResolver;
+import com.google.common.base.Joiner;
+import com.google.common.base.Splitter;
+import com.vaadin.addon.jpacontainer.EntityItem;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Buffered.SourceException;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.data.util.BeanItem;
+import com.vaadin.data.util.BeanItemContainer;
+import com.vaadin.event.Action;
+import com.vaadin.event.Action.Handler;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window.CloseEvent;
+import com.vaadin.ui.Window.CloseListener;
+
+public class PIPSQLResolverEditorWindow extends CustomComponent implements FormChangedEventNotifier, Handler {
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+
+ @AutoGenerated
+ private Table tableAttributes;
+
+ @AutoGenerated
+ private Table tableRequiredAttributes;
+
+ @AutoGenerated
+ private CheckBox checkBoxShortIds;
+
+ @AutoGenerated
+ private TextField textFieldFilter;
+
+ @AutoGenerated
+ private TextField textFieldBase;
+
+ @AutoGenerated
+ private TextArea textAreaSelect;
+
+ private final Action ADD_ATTRIBUTE = new Action("Add Attribute");
+ private final Action EDIT_ATTRIBUTE = new Action("Edit Attribute");
+ private final Action CLONE_ATTRIBUTE = new Action("Clone Attribute");
+ private final Action REMOVE_ATTRIBUTE = new Action("Remove Attribute");
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ /**
+ *
+ */
+
+ protected class ResolverAttribute implements Serializable {
+ private static final long serialVersionUID = 1L;
+ String identifier = null;
+ String prefix = null;
+ PIPResolverParam id = null;
+ PIPResolverParam category = null;
+ PIPResolverParam datatype = null;
+ PIPResolverParam issuer = null;
+ PIPResolverParam column = null;
+
+ public ResolverAttribute(String prefix, String identifier) {
+ this.prefix = prefix;
+ this.identifier = identifier;
+ }
+
+ public ResolverAttribute(String prefix, String identifier, ResolverAttribute target) {
+ this(prefix, identifier);
+ this.setId(target.getId());
+ this.setCategory(target.getCategory());
+ this.setDatatype(target.getDatatype());
+ this.setIssuer(target.getIssuer());
+ this.setColumn(target.getColumn());
+ this.setResolver(target.id.getPipresolver());
+ }
+
+ public String getIdentifier() {
+ return this.identifier;
+ }
+
+ public String getId() {
+ if (this.id == null) {
+ return null;
+ }
+ return this.id.getParamValue();
+ }
+
+ public String getShortId() {
+ String id = this.getId();
+ if (id == null) {
+ return null;
+ }
+ return XACMLConstants.extractShortName(id);
+ }
+
+ public PIPResolverParam getIdParam() {
+ return this.id;
+ }
+
+ public void setId(String id) {
+ if (this.id == null) {
+ this.id = new PIPResolverParam();
+ this.id.setParamName(this.prefix + this.identifier + ".id");
+ }
+ this.id.setParamValue(id);
+ }
+
+ public void setId(PIPResolverParam param) {
+ this.id = param;
+ }
+
+ public String getCategory() {
+ if (this.category == null) {
+ return null;
+ }
+ return this.category.getParamValue();
+ }
+
+ public String getShortCategory() {
+ String category = this.getCategory();
+ if (category == null) {
+ return null;
+ }
+ return XACMLConstants.extractShortName(category);
+ }
+
+ public PIPResolverParam getCategoryParam() {
+ return this.category;
+ }
+
+ public void setCategory(String category) {
+ if (this.category == null) {
+ this.category = new PIPResolverParam();
+ this.category.setParamName(this.prefix + this.identifier + ".category");
+ }
+ this.category.setParamValue(category);
+ }
+
+ public void setCategory(PIPResolverParam param) {
+ this.category = param;
+ }
+
+ public String getDatatype() {
+ if (this.datatype == null) {
+ return null;
+ }
+ return this.datatype.getParamValue();
+ }
+
+ public String getShortDatatype() {
+ String dt = this.getDatatype();
+ if (dt == null) {
+ return null;
+ }
+ return XACMLConstants.extractShortName(dt);
+ }
+
+ public PIPResolverParam getDatatypeParam() {
+ return this.datatype;
+ }
+
+ public void setDatatype(String datatype) {
+ if (this.datatype == null) {
+ this.datatype = new PIPResolverParam();
+ this.datatype.setParamName(this.prefix + this.identifier + ".datatype");
+ }
+ this.datatype.setParamValue(datatype);
+ }
+
+ public void setDatatype(PIPResolverParam param) {
+ this.datatype = param;
+ }
+
+ public String getIssuer() {
+ if (this.issuer == null) {
+ return null;
+ }
+ return this.issuer.getParamValue();
+ }
+
+ public String getShortIssuer() {
+ String issuer = this.getIssuer();
+ if (issuer == null) {
+ return null;
+ }
+ return XACMLConstants.extractShortName(issuer);
+ }
+
+ public PIPResolverParam getIssuerParam() {
+ return this.issuer;
+ }
+
+ public void setIssuer(String issuer) {
+ if (this.issuer == null) {
+ this.issuer = new PIPResolverParam();
+ this.issuer.setParamName(this.prefix + this.identifier + ".issuer");
+ }
+ this.issuer.setParamValue(issuer);
+ }
+
+ public void setIssuer(PIPResolverParam param) {
+ this.issuer = param;
+ }
+
+ public Integer getColumn() {
+ if (this.column == null) {
+ return null;
+ }
+ try {
+ return Integer.parseInt(this.column.getParamValue());
+ } catch (NumberFormatException e) {
+ logger.error("Failed to set column: " + e);
+ return null;
+ }
+ }
+
+ public PIPResolverParam getColumnParam() {
+ return this.column;
+ }
+
+ public void setColumn(Integer col) {
+ if (this.column == null) {
+ this.column = new PIPResolverParam();
+ this.column.setParamName(this.prefix + this.identifier + "column");
+ }
+ this.column.setParamValue(col.toString());
+ }
+
+ public void setColumn(PIPResolverParam param) {
+ this.column = param;
+ }
+
+ public void setResolver(PIPResolver resolver) {
+ if (this.id != null) {
+ this.id.setPipresolver(resolver);
+ }
+ if (this.category != null) {
+ this.category.setPipresolver(resolver);
+ }
+ if (this.datatype != null) {
+ this.datatype.setPipresolver(resolver);
+ }
+ if (this.issuer != null) {
+ this.issuer.setPipresolver(resolver);
+ }
+ if (this.column != null) {
+ this.column.setPipresolver(resolver);
+ }
+ }
+ }
+
+ private static final long serialVersionUID = 1L;
+ private static final Log logger = LogFactory.getLog(PIPSQLResolverEditorWindow.class);
+ private final PIPSQLResolverEditorWindow self = this;
+ private final EntityItem<PIPResolver> entity;
+ private final BeanItemContainer<ResolverAttribute> fieldsContainer = new BeanItemContainer<ResolverAttribute>(ResolverAttribute.class);
+ private final BeanItemContainer<ResolverAttribute> parametersContainer = new BeanItemContainer<ResolverAttribute>(ResolverAttribute.class);
+ private final BasicNotifier notifier = new BasicNotifier();
+ boolean isSaved = false;
+ String fieldPrefix;
+ String parameterPrefix;
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public PIPSQLResolverEditorWindow(EntityItem<PIPResolver> entity) {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+ //
+ // Save
+ //
+ this.entity = entity;
+ //
+ // Initialize
+ //
+ this.initialize();
+ }
+
+ protected boolean isSQL() {
+ if (this.entity.getEntity().getPipconfiguration().getPiptype().isSQL() ||
+ this.entity.getEntity().getPipconfiguration().getPiptype().isHyperCSV()) {
+ return true;
+ }
+ return false;
+ }
+
+ protected boolean isLDAP() {
+ return this.entity.getEntity().getPipconfiguration().getPiptype().isLDAP();
+ }
+
+ protected boolean isCSV() {
+ return this.entity.getEntity().getPipconfiguration().getPiptype().isCSV();
+ }
+
+ protected void initialize() {
+ //
+ // Initialize entity
+ //
+ this.initializeEntity();
+ //
+ // Go through the parameters, save them into a
+ // properties object.
+ //
+ boolean sourceInitialized = false;
+ boolean attributeInitialized = false;
+ for (PIPResolverParam param : this.entity.getEntity().getPipresolverParams()) {
+ //
+ // Look for ones we know about
+ //
+ if (param.getParamName().equalsIgnoreCase("select")) {
+ this.textAreaSelect.setValue(param.getParamValue());
+ this.textAreaSelect.setData(param);
+ } else if (param.getParamName().equals("fields") || param.getParamName().equals("filter.view")) {
+ this.initializeSourceTable(param.getParamValue());
+ this.tableRequiredAttributes.setData(param);
+ sourceInitialized = true;
+ } else if (param.getParamName().equals("parameters") || param.getParamName().equals("filter.parameters")) {
+ this.initializeAttributeTable(param.getParamValue());
+ this.tableAttributes.setData(param);
+ attributeInitialized = true;
+ } else if (param.getParamName().equalsIgnoreCase("base")) {
+ this.textFieldBase.setValue(param.getParamValue());
+ this.textFieldBase.setData(param);
+ } else if (param.getParamName().equalsIgnoreCase("filter")) {
+ this.textFieldFilter.setValue(param.getParamValue());
+ this.textFieldFilter.setData(param);
+ }
+ }
+ //
+ // Initialize GUI
+ //
+ this.initializeText();
+ this.initializeCheckBox();
+ //
+ // Verify the tables get setup, if this is a new object
+ // then they haven't been.
+ //
+ if (sourceInitialized == false) {
+ this.initializeSourceTable("");
+ }
+ if (attributeInitialized == false) {
+ this.initializeAttributeTable("");
+ }
+ }
+
+ protected void initializeEntity() {
+ //
+ // Make sure the classname is set correctly
+ //
+ if (this.isSQL()) {
+ //
+ //
+ //
+ this.fieldPrefix = "field.";
+ this.parameterPrefix = "parameter.";
+ this.entity.getEntity().setClassname(ConfigurableJDBCResolver.class.getCanonicalName());
+ } else if (this.isLDAP()) {
+ //
+ //
+ //
+ this.fieldPrefix = "filter.view.";
+ this.parameterPrefix = "filter.parameters.";
+ this.entity.getEntity().setClassname(ConfigurableLDAPResolver.class.getCanonicalName());
+ } else if (this.isCSV()) {
+ //
+ //
+ //
+ this.fieldPrefix = "field.";
+ this.parameterPrefix = "parameter.";
+ this.entity.getEntity().setClassname(ConfigurableCSVResolver.class.getCanonicalName());
+ }
+ }
+
+ protected void initializeText() {
+ //
+ // Are we SQL or LDAP?
+ //
+ if (this.isSQL()) {
+ //
+ // Turn these off
+ //
+ this.textFieldBase.setRequired(false);
+ this.textFieldBase.setVisible(false);
+ this.textFieldFilter.setRequired(false);
+ this.textFieldFilter.setVisible(false);
+ //
+ // GUI properties
+ //
+ this.textAreaSelect.setImmediate(true);
+ //
+ // Respond to changes
+ //
+ this.textAreaSelect.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ PIPResolverParam param = (PIPResolverParam) self.textAreaSelect.getData();
+ if (param == null) {
+ param = new PIPResolverParam();
+ param.setPipresolver(self.entity.getEntity());
+ param.setParamName("select");
+ self.entity.getEntity().addPipresolverParam(param);
+ self.textAreaSelect.setData(param);
+ }
+ param.setParamValue(self.textAreaSelect.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ } else if (this.isLDAP()) {
+ //
+ // Turn these off
+ //
+ this.textAreaSelect.setRequired(false);
+ this.textAreaSelect.setVisible(false);
+ //
+ //
+ //
+ this.textFieldBase.setImmediate(true);
+ this.textFieldBase.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ PIPResolverParam param = (PIPResolverParam) self.textFieldBase.getData();
+ if (param == null) {
+ param = new PIPResolverParam();
+ param.setPipresolver(self.entity.getEntity());
+ param.setParamName("base");
+ self.entity.getEntity().addPipresolverParam(param);
+ self.textFieldBase.setData(param);
+ }
+ param.setParamValue(self.textFieldBase.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ //
+ //
+ //
+ this.textFieldFilter.setImmediate(true);
+ this.textFieldFilter.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ PIPResolverParam param = (PIPResolverParam) self.textFieldFilter.getData();
+ if (param == null) {
+ param = new PIPResolverParam();
+ param.setPipresolver(self.entity.getEntity());
+ param.setParamName("filter");
+ self.entity.getEntity().addPipresolverParam(param);
+ self.textFieldFilter.setData(param);
+ }
+ param.setParamValue(self.textFieldFilter.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ } else if (this.isCSV()) {
+ //
+ // Turn these off
+ //
+ this.textAreaSelect.setRequired(false);
+ this.textAreaSelect.setVisible(false);
+ this.textFieldBase.setRequired(false);
+ this.textFieldBase.setVisible(false);
+ this.textFieldFilter.setRequired(false);
+ this.textFieldFilter.setVisible(false);
+ }
+ }
+
+ protected void initializeCheckBox() {
+ this.checkBoxShortIds.setValue(true);
+ this.checkBoxShortIds.setImmediate(true);
+ this.checkBoxShortIds.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ if (self.checkBoxShortIds.getValue()) {
+ self.tableRequiredAttributes.setColumnCollapsed("id", true);
+ self.tableRequiredAttributes.setColumnCollapsed("category", true);
+ self.tableRequiredAttributes.setColumnCollapsed("datatype", true);
+ self.tableRequiredAttributes.setColumnCollapsed("shortId", false);
+ self.tableRequiredAttributes.setColumnCollapsed("shortCategory", false);
+ self.tableRequiredAttributes.setColumnCollapsed("shortDatatype", false);
+ } else {
+ self.tableRequiredAttributes.setColumnCollapsed("id", false);
+ self.tableRequiredAttributes.setColumnCollapsed("category", false);
+ self.tableRequiredAttributes.setColumnCollapsed("datatype", false);
+ self.tableRequiredAttributes.setColumnCollapsed("shortId", true);
+ self.tableRequiredAttributes.setColumnCollapsed("shortCategory", true);
+ self.tableRequiredAttributes.setColumnCollapsed("shortDatatype", true);
+ }
+ }
+ });
+ }
+
+ protected void initializeSourceTable(String fields) {
+ //
+ // Add data into the container
+ //
+ this.populateData(this.fieldPrefix, fields, this.fieldsContainer);
+ //
+ // Set GUI properties
+ //
+ this.tableRequiredAttributes.setContainerDataSource(this.fieldsContainer);
+ this.tableRequiredAttributes.setPageLength((this.fieldsContainer.size() == 0 ? 3 : this.fieldsContainer.size() + 1));
+ this.tableRequiredAttributes.setSizeFull();
+ this.tableRequiredAttributes.setColumnCollapsingAllowed(true);
+ this.tableRequiredAttributes.setVisibleColumns(new Object[] {"identifier", "id", "category", "datatype", "shortId", "shortCategory", "shortDatatype"});
+ this.tableRequiredAttributes.setColumnHeaders(new String[] {"Field", "Attribute Id", "Category", "Data Type", "Attribute Id", "Category", "Data Type"});
+ this.tableRequiredAttributes.setColumnCollapsed("id", true);
+ this.tableRequiredAttributes.setColumnCollapsed("category", true);
+ this.tableRequiredAttributes.setColumnCollapsed("datatype", true);
+ this.tableRequiredAttributes.setSelectable(true);
+ //
+ // Setup its handler
+ //
+ this.tableRequiredAttributes.addActionHandler(this);
+ //
+ // Respond to events
+ //
+ this.tableRequiredAttributes.addItemClickListener(new ItemClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void itemClick(ItemClickEvent event) {
+ if (event.isDoubleClick()) {
+ Object id = event.getItemId();
+ if (id == null) {
+ //
+ // Really shouldn't get here
+ //
+ return;
+ }
+ BeanItem<ResolverAttribute> beanItem = self.fieldsContainer.getItem(id);
+ if (beanItem == null) {
+ //
+ // Again, shouldn't get here
+ //
+ return;
+ }
+ self.editAttribute(self.tableRequiredAttributes, beanItem.getBean());
+ }
+ }
+ });
+ }
+
+ protected void initializeAttributeTable(String parameters) {
+ //
+ // Add data into the container
+ //
+ this.populateData(this.parameterPrefix, parameters, this.parametersContainer);
+ //
+ // setup gui properties
+ //
+ this.tableAttributes.setContainerDataSource(this.parametersContainer);
+ this.tableAttributes.setPageLength(this.parametersContainer.size() + 1);
+ this.tableAttributes.setSizeFull();
+ this.tableAttributes.setColumnCollapsingAllowed(true);
+ this.tableAttributes.setVisibleColumns(new Object[] {"identifier", "id", "category", "datatype", "shortId", "shortCategory", "shortDatatype"});
+ this.tableAttributes.setColumnHeaders(new String[] {"Position", "Attribute Id", "Category", "Data Type", "Attribute Id", "Category", "Data Type"});
+ this.tableAttributes.setColumnCollapsed("id", true);
+ this.tableAttributes.setColumnCollapsed("category", true);
+ this.tableAttributes.setColumnCollapsed("datatype", true);
+ this.tableAttributes.setSelectable(true);
+ //
+ // Setup its handler
+ //
+ this.tableAttributes.addActionHandler(this);
+ //
+ // Respond to events
+ //
+ this.tableAttributes.addItemClickListener(new ItemClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void itemClick(ItemClickEvent event) {
+ if (event.isDoubleClick()) {
+ Object id = event.getItemId();
+ if (id == null) {
+ //
+ // Really shouldn't get here
+ //
+ return;
+ }
+ BeanItem<ResolverAttribute> beanItem = self.parametersContainer.getItem(id);
+ if (beanItem == null) {
+ //
+ // Again, shouldn't get here
+ //
+ return;
+ }
+ self.editAttribute(self.tableAttributes, beanItem.getBean());
+ }
+ }
+ });
+ }
+
+ protected void populateData(String prefix, String list, BeanItemContainer<ResolverAttribute> container) {
+ for (String field : Splitter.on(',').trimResults().omitEmptyStrings().split(list)) {
+ //
+ // Create a bean for this field
+ //
+ ResolverAttribute bean = new ResolverAttribute(prefix, field);
+ //
+ // Now try to find the attribute information
+ //
+ for (PIPResolverParam param : this.entity.getEntity().getPipresolverParams()) {
+ if (param.getParamName().equals(prefix + field + ".id")) {
+ bean.setId(param);
+ } else if (param.getParamName().equals(prefix + field + ".category")) {
+ bean.setCategory(param);
+ } else if (param.getParamName().equals(prefix + field + ".datatype")) {
+ bean.setDatatype(param);
+ } else if (param.getParamName().equals(prefix + field + ".issuer")) {
+ bean.setIssuer(param);
+ } else if (param.getParamName().equals(prefix + field + ".column")) {
+ bean.setColumn(param);
+ }
+ }
+ container.addBean(bean);
+ }
+ }
+
+ @Override
+ public Action[] getActions(Object target, Object sender) {
+ if (target == null) {
+ return new Action[] {ADD_ATTRIBUTE};
+ }
+ return new Action[] {EDIT_ATTRIBUTE, CLONE_ATTRIBUTE, REMOVE_ATTRIBUTE};
+ }
+
+ @Override
+ public void handleAction(Action action, Object sender, Object target) {
+ if (action == ADD_ATTRIBUTE) {
+ if (sender.equals(this.tableRequiredAttributes)) {
+ this.editAttribute(self.tableRequiredAttributes, null);
+ } else {
+ this.editAttribute(self.tableAttributes, null);
+ }
+ return;
+ }
+ if (action == EDIT_ATTRIBUTE) {
+ assert target instanceof ResolverAttribute;
+ if (sender.equals(this.tableRequiredAttributes)) {
+ this.editAttribute(self.tableRequiredAttributes, (ResolverAttribute) target);
+ } else {
+ this.editAttribute(self.tableAttributes, (ResolverAttribute) target);
+ }
+ return;
+ }
+ if (action == CLONE_ATTRIBUTE) {
+ assert target instanceof ResolverAttribute;
+ try {
+ //
+ // Which table?
+ //
+ if (sender.equals(this.tableRequiredAttributes)) {
+ //
+ // Clone the attribute giving it a new
+ // field name.
+ //
+ ResolverAttribute clone = new ResolverAttribute(this.fieldPrefix, this.getNextField(), (ResolverAttribute) target);
+ //
+ // Add it to the container
+ //
+ this.fieldsContainer.addBean(clone);
+ //
+ // Reset the page length so we can see it and have room
+ // to add another.
+ //
+ this.tableRequiredAttributes.setPageLength(this.fieldsContainer.size() + 1);
+ //
+ // Select it
+ //
+ this.tableRequiredAttributes.select(clone);
+ } else {
+ //
+ // Clone the attribute giving it a new
+ // field name.
+ //
+ ResolverAttribute clone = new ResolverAttribute(this.parameterPrefix, this.getNextParameter(), (ResolverAttribute) target);
+ //
+ // Add it to the container
+ //
+ this.parametersContainer.addBean(clone);
+ //
+ // Reset the page length so we can see it and have room
+ // to add another.
+ //
+ this.tableAttributes.setPageLength(this.parametersContainer.size() + 1);
+ //
+ // Select it
+ //
+ this.tableAttributes.select(clone);
+ }
+ //
+ // We have changed
+ //
+ this.fireFormChangedEvent();
+ } catch (Exception e) {
+ logger.error("Failed to clone: " + e);
+ }
+ return;
+ }
+ if (action == REMOVE_ATTRIBUTE) {
+ assert target instanceof ResolverAttribute;
+ //
+ // Help method to remove the attribute
+ //
+ this.removeAttribute((ResolverAttribute) target);
+ //
+ // Which table?
+ //
+ if (sender.equals(this.tableRequiredAttributes)) {
+ //
+ // Now remove it from the table
+ //
+ this.tableRequiredAttributes.removeItem(target);
+ } else {
+ //
+ // Now remove it from the table
+ //
+ this.tableAttributes.removeItem(target);
+ }
+ //
+ // we have changed
+ //
+ this.fireFormChangedEvent();
+ return;
+ }
+ }
+
+ protected void removeAttribute(ResolverAttribute target) {
+ this.entity.getEntity().removePipresolverParam(target.getIdParam());
+ this.entity.getEntity().removePipresolverParam(target.getCategoryParam());
+ this.entity.getEntity().removePipresolverParam(target.getDatatypeParam());
+ this.entity.getEntity().removePipresolverParam(target.getIssuerParam());
+ }
+
+ protected void editAttribute(final Table table, final ResolverAttribute request) {
+ if (this.isCSV()) {
+ this.editCSVAttribute(table, request);
+ } else {
+ this.editResolverAttribute(table, request, null);
+ }
+ }
+
+ protected void editCSVAttribute(final Table table, final ResolverAttribute request) {
+ assert this.isCSV();
+ //
+ // Prompt for the column
+ //
+ final ColumnSelectionWindow window = new ColumnSelectionWindow((request != null ? request.getColumn() : 0));
+ if (request == null) {
+ window.setCaption("Input the CSV Column for the new attribute");
+ } else {
+ window.setCaption("Edit the CSV Column for the attribute");
+ }
+ window.setModal(true);
+ window.center();
+ window.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Did the user save?
+ //
+ if (window.isSaved() == false) {
+ return;
+ }
+ //
+ // Save it if its not a new
+ //
+ if (request != null) {
+ request.setColumn(window.getColumn());
+ }
+ //
+ // Now we select the attribute, pass the column
+ // in case this is a brand new attribute. Yeah its messy.
+ //
+ self.editResolverAttribute(table, request, window.getColumn());
+ }
+ });
+ window.center();
+ UI.getCurrent().addWindow(window);
+ }
+
+ protected void editResolverAttribute(final Table table, final ResolverAttribute request, final Integer column) {
+ //
+ // Provide objects to the attribute selection window
+ //
+ AttributeDesignatorType designator = new AttributeDesignatorType();
+ if (request == null) {
+ designator.setAttributeId(XACML3.ID_SUBJECT_SUBJECT_ID.stringValue());
+ designator.setCategory(XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT.stringValue());
+ designator.setDataType(XACML3.ID_DATATYPE_STRING.stringValue());
+ designator.setIssuer(this.entity.getEntity().getIssuer());
+ } else {
+ designator.setAttributeId(request.getId());
+ designator.setCategory(request.getCategory());
+ designator.setDataType(request.getDatatype());
+ designator.setIssuer(request.getIssuer());
+ }
+ //
+ // Have user select an attribute
+ //
+ final AttributeSelectionWindow selection = new AttributeSelectionWindow(null, designator);
+ selection.setModal(true);
+ selection.setCaption("Select Attribute");
+ selection.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent event) {
+ //
+ // User click Save button?
+ //
+ if (selection.isSaved() == false) {
+ return;
+ }
+ //
+ // Yes - get the final attribute
+ //
+ Attribute attribute = selection.getAttribute();
+ //
+ // Is it a new one?
+ //
+ if (request == null) {
+ try {
+ //
+ // Create a new bean
+ //
+ ResolverAttribute bean = null;
+ if (table.equals(self.tableRequiredAttributes)) {
+ bean = new ResolverAttribute(self.fieldPrefix, self.getNextField());
+ } else {
+ bean = new ResolverAttribute(self.parameterPrefix, self.getNextParameter());
+ }
+ bean.setId(attribute.getXacmlId());
+ bean.setCategory(attribute.getCategoryBean().getXacmlId());
+ bean.setDatatype(attribute.getDatatypeBean().getXacmlId());
+ if (attribute.getIssuer() != null) {
+ bean.setIssuer(attribute.getIssuer());
+ }
+ if (column != null) {
+ bean.setColumn(column);
+ }
+ //
+ // Add it to the resolver
+ //
+ bean.setResolver(self.entity.getEntity());
+ self.entity.getEntity().addPipresolverParam(bean.getIdParam());
+ self.entity.getEntity().addPipresolverParam(bean.getCategoryParam());
+ self.entity.getEntity().addPipresolverParam(bean.getDatatypeParam());
+ if (bean.getIssuer() != null) {
+ self.entity.getEntity().addPipresolverParam(bean.getIssuerParam());
+ }
+ //
+ // Which table?
+ //
+ if (table.equals(self.tableRequiredAttributes)) {
+ //
+ // Add to table
+ //
+ self.fieldsContainer.addBean(bean);
+ //
+ // Reset the page length
+ //
+ self.tableRequiredAttributes.setPageLength(self.fieldsContainer.size() + 1);
+ } else if (table.equals(self.tableAttributes)) {
+ //
+ // Add to table
+ //
+ self.parametersContainer.addBean(bean);
+ //
+ // Reset the page length
+ //
+ self.tableAttributes.setPageLength(self.parametersContainer.size() + 1);
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("Added new attribute: " + bean);
+ }
+ } catch (Exception e) {
+ logger.error(e);
+ AdminNotification.error("Unable to add another required attribute field");
+ }
+ } else {
+ //
+ // Update the table entry
+ //
+ request.setId(attribute.getXacmlId());
+ request.setCategory(attribute.getCategoryBean().getXacmlId());
+ request.setDatatype(attribute.getDatatypeBean().getXacmlId());
+ request.setIssuer(attribute.getIssuer());
+ //
+ // Let the table know
+ //
+ table.refreshRowCache();
+ }
+ //
+ // we have changed
+ //
+ self.fireFormChangedEvent();
+ }
+ });
+ selection.center();
+ UI.getCurrent().addWindow(selection);
+ }
+
+ protected String getNextField() throws Exception {
+ //
+ // Start at the next index number. NOTE: The GUI needs
+ // to use numbers to index the fields.
+ //
+ int index = this.tableRequiredAttributes.size() + 1;
+ //
+ // Really if we get to 100, that's an insane number of fields
+ // needed for a SQL query.
+ //
+ while (index < 100) {
+ String field = String.format("%02d", index);
+ boolean exists = false;
+ for (Object id : this.tableRequiredAttributes.getItemIds()) {
+ @SuppressWarnings("unchecked")
+ BeanItem<ResolverAttribute> required = (BeanItem<ResolverAttribute>) this.tableRequiredAttributes.getItem(id);
+ if (required.getBean().getIdentifier().equals(field)) {
+ exists = true;
+ index++;
+ break;
+ }
+ }
+ if (exists == false) {
+ return field;
+ }
+ }
+ //
+ // Sanity check
+ //
+ throw new Exception("Unable to find a next field name. Are there too many fields?");
+ }
+
+ protected String getNextParameter() throws Exception {
+ //
+ // Start at the next index number. NOTE: The GUI needs
+ // to use numbers to index the fields.
+ //
+ int index = this.tableAttributes.size() + 1;
+ //
+ // Really if we get to 100, that's an insane number of fields
+ // needed for a SQL query.
+ //
+ while (index < 100) {
+ String field = String.format("%02d", index);
+ boolean exists = false;
+ for (Object id : this.tableAttributes.getItemIds()) {
+ @SuppressWarnings("unchecked")
+ BeanItem<ResolverAttribute> required = (BeanItem<ResolverAttribute>) this.tableAttributes.getItem(id);
+ if (required.getBean().getIdentifier().equals(field)) {
+ exists = true;
+ index++;
+ break;
+ }
+ }
+ if (exists == false) {
+ return field;
+ }
+ }
+ //
+ // Sanity check
+ //
+ throw new Exception("Unable to find a next parameter name. Are there too many parameters?");
+ }
+
+ public void discard() throws SourceException {
+ if (this.isSQL()) {
+ this.textAreaSelect.discard();
+ } else if (this.isLDAP()) {
+ this.textFieldBase.discard();
+ this.textFieldFilter.discard();
+ // } else if (this.isCSV()) {
+ }
+ }
+
+ public void validate() throws InvalidValueException {
+ if (this.isSQL()) {
+ this.textAreaSelect.validate();
+ } else if (this.isLDAP()) {
+ this.textFieldBase.validate();
+ this.textFieldFilter.validate();
+ //} else if (this.isCSV()) {
+
+ }
+ }
+
+ public void commit() throws SourceException, InvalidValueException {
+ //
+ // Commit required fields
+ //
+ if (this.isSQL()) {
+ this.textAreaSelect.commit();
+ } else if (this.isLDAP()) {
+ this.textFieldBase.commit();
+ this.textFieldFilter.commit();
+ // } else if (this.isCSV()) {
+ }
+ //
+ // Setup the fields
+ //
+ {
+ List<String> fields = new ArrayList<String>(this.fieldsContainer.size());
+ for (ResolverAttribute attribute : this.fieldsContainer.getItemIds()) {
+ fields.add(attribute.getIdentifier());
+ }
+ PIPResolverParam param = (PIPResolverParam) this.tableRequiredAttributes.getData();
+ if (param == null) {
+ param = new PIPResolverParam();
+ if (this.isSQL()) {
+ param.setParamName("fields");
+ } else if (this.isLDAP()) {
+ param.setParamName("filter.view");
+ } else if (this.isCSV()) {
+ param.setParamName("fields");
+ }
+ this.entity.getEntity().addPipresolverParam(param);
+ this.tableRequiredAttributes.setData(param);
+ }
+ param.setParamValue(Joiner.on(',').join(fields));
+ }
+ //
+ // Setup the parameters
+ //
+ {
+ List<String> parameters = new ArrayList<String>(this.parametersContainer.size());
+ for (ResolverAttribute attribute : this.parametersContainer.getItemIds()) {
+ parameters.add(attribute.getIdentifier());
+ }
+ PIPResolverParam param = (PIPResolverParam) this.tableAttributes.getData();
+ if (param == null) {
+ param = new PIPResolverParam();
+ if (this.isSQL()) {
+ param.setParamName("parameters");
+ } else if (this.isLDAP()) {
+ param.setParamName("filter.parameters");
+ } else if (this.isCSV()) {
+ param.setParamName("parameters");
+ }
+ this.entity.getEntity().addPipresolverParam(param);
+ this.tableAttributes.setData(param);
+ }
+ param.setParamValue(Joiner.on(',').join(parameters));
+ }
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ @Override
+ public boolean addListener(FormChangedEventListener listener) {
+ return this.notifier.addListener(listener);
+ }
+
+ @Override
+ public boolean removeListener(FormChangedEventListener listener) {
+ return this.notifier.removeListener(listener);
+ }
+
+ @Override
+ public void fireFormChangedEvent() {
+ this.notifier.fireFormChangedEvent();
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // textAreaSelect
+ textAreaSelect = new TextArea();
+ textAreaSelect.setCaption("SQL Select Statement");
+ textAreaSelect.setImmediate(false);
+ textAreaSelect.setWidth("100.0%");
+ textAreaSelect.setHeight("-1px");
+ textAreaSelect.setInvalidAllowed(false);
+ textAreaSelect.setRequired(true);
+ mainLayout.addComponent(textAreaSelect);
+ mainLayout.setExpandRatio(textAreaSelect, 1.0f);
+
+ // textFieldBase
+ textFieldBase = new TextField();
+ textFieldBase.setCaption("Base DN");
+ textFieldBase.setImmediate(false);
+ textFieldBase.setWidth("-1px");
+ textFieldBase.setHeight("-1px");
+ mainLayout.addComponent(textFieldBase);
+
+ // textFieldFilter
+ textFieldFilter = new TextField();
+ textFieldFilter.setCaption("Filter");
+ textFieldFilter.setImmediate(false);
+ textFieldFilter.setWidth("-1px");
+ textFieldFilter.setHeight("-1px");
+ mainLayout.addComponent(textFieldFilter);
+
+ // checkBoxShortIds
+ checkBoxShortIds = new CheckBox();
+ checkBoxShortIds.setCaption("Display short id’s.");
+ checkBoxShortIds.setImmediate(false);
+ checkBoxShortIds.setWidth("-1px");
+ checkBoxShortIds.setHeight("-1px");
+ mainLayout.addComponent(checkBoxShortIds);
+
+ // tableRequiredAttributes
+ tableRequiredAttributes = new Table();
+ tableRequiredAttributes.setCaption("Attributes Returned");
+ tableRequiredAttributes.setImmediate(false);
+ tableRequiredAttributes.setWidth("-1px");
+ tableRequiredAttributes.setHeight("-1px");
+ mainLayout.addComponent(tableRequiredAttributes);
+
+ // tableAttributes
+ tableAttributes = new Table();
+ tableAttributes.setCaption("Parameters - Attributes Needed (i.e. ?)");
+ tableAttributes.setImmediate(false);
+ tableAttributes.setWidth("-1px");
+ tableAttributes.setHeight("-1px");
+ tableAttributes.setInvalidAllowed(false);
+ tableAttributes.setRequired(true);
+ mainLayout.addComponent(tableAttributes);
+
+ return mainLayout;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PolicyEditorWindow.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PolicyEditorWindow.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PolicyEditorWindow.java
new file mode 100644
index 0000000..f9d70c8
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/windows/PolicyEditorWindow.java
@@ -0,0 +1,252 @@
+/*
+ * 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.xacml.admin.view.windows;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.jpa.RuleAlgorithms;
+import org.apache.openaz.xacml.admin.util.JPAUtils;
+import org.apache.openaz.xacml.api.XACML3;
+import com.vaadin.addon.jpacontainer.JPAContainer;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Buffered.SourceException;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.data.validator.RegexpValidator;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.AbstractSelect.ItemCaptionMode;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Label;
+import com.vaadin.ui.ListSelect;
+import com.vaadin.ui.TextArea;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window;
+
+public class PolicyEditorWindow extends Window {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Button buttonSave;
+ @AutoGenerated
+ private TextArea textAreaDescription;
+ @AutoGenerated
+ private ListSelect listSelectAlgorithm;
+ @AutoGenerated
+ private TextField textFieldVersion;
+ @AutoGenerated
+ private Label labelID;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private final PolicyEditorWindow self = this;
+ private final PolicyType policy;
+ private JPAContainer<RuleAlgorithms> algorithms = ((XacmlAdminUI)UI.getCurrent()).getRuleAlgorithms();
+ private boolean isSaved = false;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public PolicyEditorWindow(PolicyType policy) {
+ buildMainLayout();
+ //setCompositionRoot(mainLayout);
+ setContent(mainLayout);
+ //
+ // Save
+ //
+ this.policy = policy;
+ //
+ // Close shortcut
+ //
+ this.setCloseShortcut(KeyCode.ESCAPE);
+ //
+ // Initialize GUI
+ //
+ this.initializeLabel();
+ this.initializeText();
+ this.initializeSelect();
+ this.initializeButton();
+ //
+ // Focus
+ //
+ this.textAreaDescription.focus();
+ }
+
+ protected void initializeLabel() {
+ if (this.policy.getPolicyId() == null) {
+ this.policy.setPolicyId(((XacmlAdminUI)UI.getCurrent()).newPolicyID());
+ }
+ this.labelID.setValue(this.policy.getPolicyId());
+ }
+
+ protected void initializeText() {
+ //
+ //
+ //
+ this.textAreaDescription.setNullRepresentation("");
+ this.textAreaDescription.setValue(this.policy.getDescription());
+ //
+ //
+ //
+ if (this.policy.getVersion() == null) {
+ this.policy.setVersion("1");
+ }
+ this.textFieldVersion.setRequiredError("The exact format is: ((\\d+|\\*)\\.)*(\\d+|\\*|\\+)");
+ this.textFieldVersion.addValidator(new RegexpValidator("((\\d+|\\*)\\.)*(\\d+|\\*|\\+)", true, "The version MUST a number optionally separated by '.' eg. 1 or 1.0 or 1.1.1 etc."));
+ this.textFieldVersion.setValue(this.policy.getVersion());
+ }
+
+ protected void initializeSelect() {
+ this.listSelectAlgorithm.setContainerDataSource(this.algorithms);
+ this.listSelectAlgorithm.setItemCaptionMode(ItemCaptionMode.PROPERTY);
+ this.listSelectAlgorithm.setItemCaptionPropertyId("xacmlId");
+ this.listSelectAlgorithm.setNullSelectionAllowed(false);
+
+ if (this.policy.getRuleCombiningAlgId() == null) {
+ this.policy.setRuleCombiningAlgId(XACML3.ID_RULE_FIRST_APPLICABLE.stringValue());
+ }
+ this.listSelectAlgorithm.setValue(JPAUtils.findRuleAlgorithm(this.policy.getRuleCombiningAlgId()).getId());
+ }
+
+ protected void initializeButton() {
+ this.buttonSave.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ try {
+ //
+ // Commit
+ //
+ self.listSelectAlgorithm.commit();
+ self.textFieldVersion.commit();
+ self.textAreaDescription.commit();
+ //
+ // Save everything
+ //
+ self.policy.setDescription(self.textAreaDescription.getValue());
+ self.policy.setVersion(self.textFieldVersion.getValue());
+ Object id = self.listSelectAlgorithm.getValue();
+ self.policy.setRuleCombiningAlgId(algorithms.getItem(id).getEntity().getXacmlId());
+ //
+ // Mark ourselves as saved
+ //
+ self.isSaved = true;
+ //
+ // Close window
+ //
+ self.close();
+ } catch (SourceException | InvalidValueException e) { //NOPMD
+ //
+ // VAADIN will show the required error message to the user
+ //
+ }
+ }
+ });
+ }
+
+ public boolean isSaved() {
+ return this.isSaved;
+ }
+
+ public PolicyType getPolicySet() {
+ return this.policy;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // labelID
+ labelID = new Label();
+ labelID.setCaption("Policy Set ID");
+ labelID.setImmediate(false);
+ labelID.setWidth("100.0%");
+ labelID.setHeight("-1px");
+ labelID.setValue("Label");
+ mainLayout.addComponent(labelID);
+
+ // textFieldVersion
+ textFieldVersion = new TextField();
+ textFieldVersion.setCaption("Version");
+ textFieldVersion.setImmediate(false);
+ textFieldVersion
+ .setDescription("The format is numbers only separated by decimal point.");
+ textFieldVersion.setWidth("-1px");
+ textFieldVersion.setHeight("-1px");
+ textFieldVersion.setInvalidAllowed(false);
+ textFieldVersion.setRequired(true);
+ textFieldVersion.setInputPrompt("Eg. 1 or 1.0 or 1.0.0 etc.");
+ mainLayout.addComponent(textFieldVersion);
+
+ // listSelectAlgorithm
+ listSelectAlgorithm = new ListSelect();
+ listSelectAlgorithm.setCaption("Policy Combining Algorithm");
+ listSelectAlgorithm.setImmediate(false);
+ listSelectAlgorithm.setWidth("100.0%");
+ listSelectAlgorithm.setHeight("-1px");
+ listSelectAlgorithm.setInvalidAllowed(false);
+ listSelectAlgorithm.setRequired(true);
+ mainLayout.addComponent(listSelectAlgorithm);
+
+ // textAreaDescription
+ textAreaDescription = new TextArea();
+ textAreaDescription.setCaption("Description");
+ textAreaDescription.setImmediate(false);
+ textAreaDescription.setWidth("100.0%");
+ textAreaDescription.setHeight("-1px");
+ mainLayout.addComponent(textAreaDescription);
+ mainLayout.setExpandRatio(textAreaDescription, 1.0f);
+
+ // buttonSave
+ buttonSave = new Button();
+ buttonSave.setCaption("Save");
+ buttonSave.setImmediate(true);
+ buttonSave.setWidth("-1px");
+ buttonSave.setHeight("-1px");
+ mainLayout.addComponent(buttonSave);
+ mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
+
+ return mainLayout;
+ }
+
+}
[09/23] incubator-openaz git commit: Ported original att source to
openaz
Posted by pd...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/LDAPPIPConfigurationComponent.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/LDAPPIPConfigurationComponent.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/LDAPPIPConfigurationComponent.java
new file mode 100644
index 0000000..608b0ac
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/LDAPPIPConfigurationComponent.java
@@ -0,0 +1,644 @@
+/*
+ * 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.xacml.admin.view.components;
+
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Set;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.directory.DirContext;
+import javax.naming.directory.InitialDirContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.jpa.PIPConfigParam;
+import org.apache.openaz.xacml.admin.jpa.PIPConfiguration;
+import org.apache.openaz.xacml.admin.view.events.FormChangedEventListener;
+import org.apache.openaz.xacml.admin.view.events.FormChangedEventNotifier;
+import com.vaadin.addon.jpacontainer.EntityItem;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Buffered.SourceException;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.event.FieldEvents.TextChangeEvent;
+import com.vaadin.event.FieldEvents.TextChangeListener;
+import com.vaadin.server.Page;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Notification;
+import com.vaadin.ui.Notification.Type;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+public class LDAPPIPConfigurationComponent extends CustomComponent implements FormChangedEventNotifier {
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+
+ @AutoGenerated
+ private Button buttonTest;
+
+ @AutoGenerated
+ private TextField textFieldScope;
+
+ @AutoGenerated
+ private TextField textFieldCredentials;
+
+ @AutoGenerated
+ private TextField textFieldPrincipal;
+
+ @AutoGenerated
+ private ComboBox comboBoxAuthentication;
+
+ @AutoGenerated
+ private TextField textFieldProviderURL;
+
+ @AutoGenerated
+ private TextField textFieldFactory;
+
+ public static String CLASSNAME = "org.apache.openaz.xacml.std.pip.engines.ldap.LDAPEngine";
+
+ public static String LDAP_CONTEXT = Context.INITIAL_CONTEXT_FACTORY;
+ public static String LDAP_URL = Context.PROVIDER_URL;
+ public static String LDAP_AUTH = "authentication";
+ public static String LDAP_PRINCIPAL = "principal";
+ public static String LDAP_CREDENTIALS = "credentials";
+ public static String LDAP_SCOPE = "scope";
+
+ public static String LDAP_DEFAULT_CONTEXT = "com.sun.jndi.ldap.LdapCtxFactory";
+
+ public static String LDAP_AUTH_ANONYMOUS = "anonymous";
+ public static String LDAP_AUTH_SIMPLE = "simple";
+ public static String LDAP_AUTH_SASL = "SASL"; //????
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static final Log logger = LogFactory.getLog(LDAPPIPConfigurationComponent.class);
+ private final LDAPPIPConfigurationComponent self = this;
+ private final BasicNotifier notifier = new BasicNotifier();
+ private final EntityItem<PIPConfiguration> entity;
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ * @param configParamField
+ */
+ public LDAPPIPConfigurationComponent(EntityItem<PIPConfiguration> entity) {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+ //
+ // Save
+ //
+ this.entity = entity;
+ //
+ // Initialize
+ //
+ this.initialize();
+ }
+
+ protected void initialize() {
+ if (logger.isDebugEnabled()) {
+ logger.debug("initializing " + this.entity.getEntity().toString());
+ }
+ //
+ // Iterate any existing values
+ //
+ Set<PIPConfigParam> unneeded = new HashSet<PIPConfigParam>();
+ for (PIPConfigParam param : this.entity.getEntity().getPipconfigParams()) {
+ if (param.getParamName().equals(LDAP_CONTEXT)) {
+ this.textFieldFactory.setData(param);
+ } else if (param.getParamName().equals(LDAP_URL)) {
+ this.textFieldProviderURL.setData(param);
+ } else if (param.getParamName().equals(LDAP_AUTH)) {
+ this.comboBoxAuthentication.setData(param);
+ } else if (param.getParamName().equals(LDAP_PRINCIPAL)) {
+ this.textFieldPrincipal.setData(param);
+ } else if (param.getParamName().equals(LDAP_CREDENTIALS)) {
+ this.textFieldCredentials.setData(param);
+ } else if (param.getParamName().equals(LDAP_SCOPE)) {
+ this.textFieldScope.setData(param);
+ } else {
+ unneeded.add(param);
+ }
+ }
+ //
+ // Get rid of unneeded parameters
+ //
+ if (unneeded.isEmpty() == false) {
+ this.entity.getEntity().getPipconfigParams().removeAll(unneeded);
+ }
+ //
+ // Initialize GUI
+ //
+ this.initializeEntity();
+ this.initializeCombo();
+ this.initializeText();
+ this.initializeButtons();
+ }
+
+ protected void initializeEntity() {
+ //
+ // Initialize the entity
+ //
+ this.entity.getEntity().setClassname(CLASSNAME);
+ this.entity.getEntity().setRequiresResolvers(true);
+ }
+
+ protected void initializeCombo() {
+ //
+ // GUI properties
+ //
+ this.comboBoxAuthentication.setImmediate(true);
+ this.comboBoxAuthentication.setNullSelectionAllowed(false);
+ this.comboBoxAuthentication.setRequired(true);
+ this.comboBoxAuthentication.setRequiredError("You must select an authentication mechanism");
+ //
+ // Initial set of items
+ //
+ this.comboBoxAuthentication.addItem(LDAP_AUTH_ANONYMOUS);
+ this.comboBoxAuthentication.addItem(LDAP_AUTH_SIMPLE);
+ this.comboBoxAuthentication.addItem(LDAP_AUTH_SASL);
+ //
+ // Ensure the authentication combo is selected to something.
+ //
+ PIPConfigParam param = (PIPConfigParam) this.comboBoxAuthentication.getData();
+ if (param == null) {
+ param = new PIPConfigParam(LDAP_AUTH, LDAP_AUTH_ANONYMOUS);
+ this.entity.getEntity().addPipconfigParam(param);
+ this.comboBoxAuthentication.setData(param);
+ this.comboBoxAuthentication.select(param.getParamValue());
+ } else {
+ //
+ // Is this custom?
+ //
+ this.comboBoxAuthentication.select(param.getParamValue());
+ if (this.comboBoxAuthentication.getValue().equals(param.getParamValue()) == false) {
+ this.comboBoxAuthentication.addItem(param.getParamValue());
+ this.comboBoxAuthentication.select(param.getParamValue());
+ }
+ }
+ //
+ // Respond to events
+ //
+ this.comboBoxAuthentication.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.comboBoxAuthentication.getData();
+ if (param == null) {
+ param = new PIPConfigParam(LDAP_AUTH, self.comboBoxAuthentication.getValue().toString());
+ self.entity.getEntity().addPipconfigParam(param);
+ self.comboBoxAuthentication.setData(param);
+ }
+ param.setParamValue(self.comboBoxAuthentication.getValue().toString());
+ self.fireFormChangedEvent();
+ }
+ });
+ }
+
+ protected void initializeText() {
+ //
+ //
+ //
+ this.textFieldFactory.setImmediate(true);
+ this.textFieldFactory.setNullRepresentation("");
+ //
+ // We can initialize this if there is no value
+ //
+ PIPConfigParam param = (PIPConfigParam) this.textFieldFactory.getData();
+ if (param == null) {
+ param = new PIPConfigParam(LDAP_CONTEXT, LDAP_DEFAULT_CONTEXT);
+ this.entity.getEntity().addPipconfigParam(param);
+ this.textFieldFactory.setData(param);
+ }
+ this.textFieldFactory.setValue(param.getParamValue());
+ this.textFieldFactory.addTextChangeListener(new TextChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void textChange(TextChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldFactory.getData();
+ if (param == null) {
+ param = new PIPConfigParam(LDAP_CONTEXT);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldFactory.setData(param);
+ }
+ param.setParamValue(self.textFieldFactory.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ this.textFieldFactory.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldFactory.getData();
+ if (param == null) {
+ param = new PIPConfigParam(LDAP_CONTEXT);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldFactory.setData(param);
+ }
+ param.setParamValue(self.textFieldFactory.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ //
+ //
+ //
+ this.textFieldProviderURL.setImmediate(true);
+ this.textFieldProviderURL.setNullRepresentation("");
+ param = (PIPConfigParam) this.textFieldProviderURL.getData();
+ if (param != null) {
+ this.textFieldProviderURL.setValue(param.getParamValue());
+ }
+ this.textFieldProviderURL.addTextChangeListener(new TextChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void textChange(TextChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldProviderURL.getData();
+ if (param == null) {
+ param = new PIPConfigParam(LDAP_URL);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldProviderURL.setData(param);
+ }
+ param.setParamValue(self.textFieldProviderURL.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ this.textFieldProviderURL.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldProviderURL.getData();
+ if (param == null) {
+ param = new PIPConfigParam(LDAP_URL);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldProviderURL.setData(param);
+ }
+ param.setParamValue(self.textFieldProviderURL.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ //
+ //
+ //
+ this.textFieldPrincipal.setImmediate(true);
+ this.textFieldPrincipal.setNullRepresentation("");
+ param = (PIPConfigParam) this.textFieldPrincipal.getData();
+ if (param != null) {
+ this.textFieldPrincipal.setValue(param.getParamValue());
+ }
+ this.textFieldPrincipal.addTextChangeListener(new TextChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void textChange(TextChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldPrincipal.getData();
+ if (param == null) {
+ param = new PIPConfigParam(LDAP_PRINCIPAL);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldPrincipal.setData(param);
+ }
+ param.setParamValue(self.textFieldPrincipal.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ this.textFieldPrincipal.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldPrincipal.getData();
+ if (param == null) {
+ param = new PIPConfigParam(LDAP_PRINCIPAL);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldPrincipal.setData(param);
+ }
+ param.setParamValue(self.textFieldPrincipal.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ //
+ //
+ //
+ this.textFieldCredentials.setNullRepresentation("");
+ param = (PIPConfigParam) this.textFieldCredentials.getData();
+ if (param != null) {
+ this.textFieldCredentials.setValue(param.getParamValue());
+ }
+ this.textFieldCredentials.addTextChangeListener(new TextChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void textChange(TextChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldCredentials.getData();
+ if (param == null) {
+ param = new PIPConfigParam(LDAP_CREDENTIALS);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldCredentials.setData(param);
+ }
+ param.setParamValue(self.textFieldCredentials.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ this.textFieldCredentials.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldCredentials.getData();
+ if (param == null) {
+ param = new PIPConfigParam(LDAP_CREDENTIALS);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldCredentials.setData(param);
+ }
+ param.setParamValue(self.textFieldCredentials.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ //
+ //
+ //
+ this.textFieldScope.setNullRepresentation("");
+ param = (PIPConfigParam) this.textFieldScope.getData();
+ if (param == null) {
+ param = new PIPConfigParam(LDAP_SCOPE, "subtree");
+ this.entity.getEntity().addPipconfigParam(param);
+ this.textFieldScope.setData(param);
+ }
+ this.textFieldScope.setValue(param.getParamValue());
+ this.textFieldScope.addTextChangeListener(new TextChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void textChange(TextChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldScope.getData();
+ if (param == null) {
+ param = new PIPConfigParam(LDAP_SCOPE);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldScope.setData(param);
+ }
+ param.setParamValue(self.textFieldScope.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ this.textFieldScope.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ PIPConfigParam param = (PIPConfigParam) self.textFieldScope.getData();
+ if (param == null) {
+ param = new PIPConfigParam(LDAP_SCOPE);
+ self.entity.getEntity().addPipconfigParam(param);
+ self.textFieldScope.setData(param);
+ }
+ param.setParamValue(self.textFieldScope.getValue());
+ self.fireFormChangedEvent();
+ }
+ });
+ }
+
+ protected void initializeButtons() {
+ this.buttonTest.setImmediate(true);
+ this.buttonTest.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ self.testLDAPConnection();
+ }
+ });
+ }
+
+ protected void testLDAPConnection() {
+ Hashtable<String, String> env = new Hashtable<String, String>();
+ env.put(Context.INITIAL_CONTEXT_FACTORY, this.textFieldFactory.getValue());
+ env.put(Context.PROVIDER_URL, this.textFieldProviderURL.getValue());
+ env.put(Context.SECURITY_PRINCIPAL, this.textFieldPrincipal.getValue());
+ env.put(Context.SECURITY_CREDENTIALS, this.textFieldCredentials.getValue());
+
+ String auth = this.comboBoxAuthentication.getValue().toString();
+ env.put(Context.SECURITY_AUTHENTICATION, auth);
+ //
+ // Do we need to do anything?
+ //
+ /*
+ if (auth.equals(LDAP_AUTH_ANONYMOUS)) {
+
+ } else if (auth.equals(LDAP_AUTH_SIMPLE)) {
+
+ } else if (auth.equals(LDAP_AUTH_SASL)) {
+
+ }
+ */
+
+ DirContext ctx = null;
+ try {
+ ctx = new InitialDirContext(env);
+ new Notification("Success!",
+ "Connection Established!",
+ Type.HUMANIZED_MESSAGE, true)
+ .show(Page.getCurrent());
+ } catch (NamingException e) {
+ logger.error(e);
+ new Notification("Connection Failed",
+ "<br/>" + e.getLocalizedMessage(),
+ Type.ERROR_MESSAGE, true)
+ .show(Page.getCurrent());
+ } finally {
+ try {
+ if (ctx != null) {
+ ctx.close();
+ }
+ } catch (NamingException idontcare) { //NOPMD
+ }
+ }
+ }
+
+ public void validate() throws InvalidValueException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("validate");
+ }
+ this.comboBoxAuthentication.validate();
+ this.textFieldFactory.validate();
+ this.textFieldProviderURL.validate();
+ this.textFieldPrincipal.validate();
+ this.textFieldCredentials.validate();
+ this.textFieldScope.validate();
+ }
+
+ public void commit() throws SourceException, InvalidValueException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("commit");
+ }
+ this.comboBoxAuthentication.commit();
+ this.textFieldFactory.commit();
+ this.textFieldProviderURL.commit();
+ this.textFieldPrincipal.commit();
+ this.textFieldCredentials.commit();
+ this.textFieldScope.commit();
+ }
+
+ public void discard() throws SourceException {
+ if (logger.isDebugEnabled()) {
+ logger.debug("discard");
+ }
+
+ this.textFieldFactory.discard();
+ this.textFieldProviderURL.discard();
+ this.textFieldPrincipal.discard();
+ this.textFieldCredentials.discard();
+ this.textFieldScope.discard();
+ /*
+ this.entity.getEntity().getPipconfigParams().remove(LDAP_CONTEXT);
+ this.entity.getEntity().getPipconfigParams().remove(LDAP_URL);
+ this.entity.getEntity().getPipconfigParams().remove(LDAP_AUTH);
+ this.entity.getEntity().getPipconfigParams().remove(LDAP_PRINCIPAL);
+ this.entity.getEntity().getPipconfigParams().remove(LDAP_CREDENTIALS);
+ this.entity.getEntity().getPipconfigParams().remove(LDAP_SCOPE);
+ */
+ }
+
+ @Override
+ public boolean addListener(FormChangedEventListener listener) {
+ return this.notifier.addListener(listener);
+ }
+
+ @Override
+ public boolean removeListener(FormChangedEventListener listener) {
+ return this.notifier.removeListener(listener);
+ }
+
+ @Override
+ public void fireFormChangedEvent() {
+ this.notifier.fireFormChangedEvent();
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // textFieldFactory
+ textFieldFactory = new TextField();
+ textFieldFactory.setCaption("Initial Context Factory");
+ textFieldFactory.setImmediate(false);
+ textFieldFactory.setWidth("-1px");
+ textFieldFactory.setHeight("-1px");
+ textFieldFactory.setInvalidAllowed(false);
+ textFieldFactory.setRequired(true);
+ textFieldFactory.setInputPrompt("com.sun.jndi.ldap.LdapCtxFactory");
+ mainLayout.addComponent(textFieldFactory);
+ mainLayout.setExpandRatio(textFieldFactory, 1.0f);
+
+ // textFieldProviderURL
+ textFieldProviderURL = new TextField();
+ textFieldProviderURL.setCaption("Provider URL");
+ textFieldProviderURL.setImmediate(false);
+ textFieldProviderURL.setWidth("-1px");
+ textFieldProviderURL.setHeight("-1px");
+ textFieldProviderURL.setInvalidAllowed(false);
+ textFieldProviderURL.setRequired(true);
+ textFieldProviderURL
+ .setInputPrompt("Eg. ldap://localhost:389/o=JNDITutorial");
+ mainLayout.addComponent(textFieldProviderURL);
+ mainLayout.setExpandRatio(textFieldProviderURL, 1.0f);
+
+ // comboBoxAuthentication
+ comboBoxAuthentication = new ComboBox();
+ comboBoxAuthentication.setCaption("Authentication");
+ comboBoxAuthentication.setImmediate(false);
+ comboBoxAuthentication.setWidth("-1px");
+ comboBoxAuthentication.setHeight("-1px");
+ comboBoxAuthentication.setRequired(true);
+ mainLayout.addComponent(comboBoxAuthentication);
+ mainLayout.setExpandRatio(comboBoxAuthentication, 1.0f);
+
+ // textFieldPrincipal
+ textFieldPrincipal = new TextField();
+ textFieldPrincipal.setCaption("Principal");
+ textFieldPrincipal.setImmediate(false);
+ textFieldPrincipal.setWidth("-1px");
+ textFieldPrincipal.setHeight("-1px");
+ textFieldPrincipal.setNullSettingAllowed(true);
+ mainLayout.addComponent(textFieldPrincipal);
+ mainLayout.setExpandRatio(textFieldPrincipal, 1.0f);
+
+ // textFieldCredentials
+ textFieldCredentials = new TextField();
+ textFieldCredentials.setCaption("Credentials");
+ textFieldCredentials.setImmediate(false);
+ textFieldCredentials.setWidth("-1px");
+ textFieldCredentials.setHeight("-1px");
+ textFieldCredentials.setNullSettingAllowed(true);
+ mainLayout.addComponent(textFieldCredentials);
+ mainLayout.setExpandRatio(textFieldCredentials, 1.0f);
+
+ // textFieldScope
+ textFieldScope = new TextField();
+ textFieldScope.setCaption("Scope");
+ textFieldScope.setImmediate(false);
+ textFieldScope.setWidth("-1px");
+ textFieldScope.setHeight("-1px");
+ textFieldScope.setInvalidAllowed(false);
+ textFieldScope.setRequired(true);
+ textFieldScope.setInputPrompt("Eg. subtree");
+ mainLayout.addComponent(textFieldScope);
+
+ // buttonTest
+ buttonTest = new Button();
+ buttonTest.setCaption("Test Connection");
+ buttonTest.setImmediate(true);
+ buttonTest.setWidth("-1px");
+ buttonTest.setHeight("-1px");
+ mainLayout.addComponent(buttonTest);
+ mainLayout.setComponentAlignment(buttonTest, new Alignment(48));
+
+ return mainLayout;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/OaExpressionsEditorComponent.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/OaExpressionsEditorComponent.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/OaExpressionsEditorComponent.java
new file mode 100644
index 0000000..bcbeca8
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/OaExpressionsEditorComponent.java
@@ -0,0 +1,186 @@
+/*
+ * 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.xacml.admin.view.components;
+
+import org.apache.openaz.xacml.admin.jpa.Obadvice;
+import org.apache.openaz.xacml.admin.jpa.ObadviceExpression;
+import org.apache.openaz.xacml.admin.view.windows.ExpressionEditorWindow;
+import com.vaadin.addon.jpacontainer.EntityItem;
+import com.vaadin.addon.jpacontainer.JPAContainer;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.util.filter.Compare;
+import com.vaadin.event.ShortcutAction.KeyCode;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+
+public class OaExpressionsEditorComponent extends CustomComponent {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private HorizontalLayout horizontalLayout_1;
+ @AutoGenerated
+ private Button buttonRemove;
+ @AutoGenerated
+ private Button buttonadd;
+ @AutoGenerated
+ private Table tableExpressions;
+ private static final long serialVersionUID = 1L;
+ private final OaExpressionsEditorComponent self = this;
+ private final JPAContainer<ObadviceExpression> container;
+ private final EntityItem<Obadvice> oa;
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public OaExpressionsEditorComponent(EntityItem<Obadvice> oa, JPAContainer<ObadviceExpression> container) {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+ //
+ // Save
+ //
+ this.container = container;
+ this.oa = oa;
+ //
+ // Filter the container
+ //
+ this.container.removeAllContainerFilters();
+ this.container.addContainerFilter(new Compare.Equal("obadvice", this.oa.getEntity()));
+ //
+ // Initialize components
+ //
+ this.initializeTable();
+ this.initializeButtons();
+ }
+
+ private void initializeTable() {
+ this.tableExpressions.setContainerDataSource(this.container);
+ this.tableExpressions.setVisibleColumns(new Object[] {"type"});
+ this.tableExpressions.setColumnHeaders(new String[] {"Expression Type"});
+ this.tableExpressions.setPageLength(this.container.size() + 1);
+ }
+
+ private void initializeButtons() {
+ this.buttonadd.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ ObadviceExpression expression = new ObadviceExpression();
+ // TODO - EntityItem is not used - does container.createEntityItem even need to be called?
+ // final EntityItem<ObadviceExpression> entity = self.container.createEntityItem(expression);
+ self.container.createEntityItem(expression); // See TODO
+
+ final ExpressionEditorWindow editor = new ExpressionEditorWindow();
+ editor.setCaption("Edit Attribute");
+ editor.setCloseShortcut(KeyCode.ESCAPE);
+ editor.setModal(true);
+ editor.center();
+ UI.getCurrent().addWindow(editor);
+ }
+
+ });
+ this.buttonRemove.setEnabled(false);
+ this.buttonRemove.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ self.tableExpressions.removeItem(self.tableExpressions.getValue());
+ }
+
+ });
+
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(false);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // tableExpressions
+ tableExpressions = new Table();
+ tableExpressions.setCaption("Expressions");
+ tableExpressions.setImmediate(false);
+ tableExpressions
+ .setDescription("The list of expressions for the obligation/advice object.");
+ tableExpressions.setWidth("-1px");
+ tableExpressions.setHeight("-1px");
+ mainLayout.addComponent(tableExpressions);
+
+ // horizontalLayout_1
+ horizontalLayout_1 = buildHorizontalLayout_1();
+ mainLayout.addComponent(horizontalLayout_1);
+
+ return mainLayout;
+ }
+
+ @AutoGenerated
+ private HorizontalLayout buildHorizontalLayout_1() {
+ // common part: create layout
+ horizontalLayout_1 = new HorizontalLayout();
+ horizontalLayout_1.setImmediate(false);
+ horizontalLayout_1.setWidth("-1px");
+ horizontalLayout_1.setHeight("-1px");
+ horizontalLayout_1.setMargin(false);
+ horizontalLayout_1.setSpacing(true);
+
+ // buttonadd
+ buttonadd = new Button();
+ buttonadd.setCaption("Add");
+ buttonadd.setImmediate(true);
+ buttonadd.setWidth("-1px");
+ buttonadd.setHeight("-1px");
+ horizontalLayout_1.addComponent(buttonadd);
+
+ // buttonRemove
+ buttonRemove = new Button();
+ buttonRemove.setCaption("Remove");
+ buttonRemove.setImmediate(true);
+ buttonRemove.setDescription("Remove selected expression(s).");
+ buttonRemove.setWidth("-1px");
+ buttonRemove.setHeight("-1px");
+ horizontalLayout_1.addComponent(buttonRemove);
+
+ return horizontalLayout_1;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/PIPParameterComponent.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/PIPParameterComponent.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/PIPParameterComponent.java
new file mode 100644
index 0000000..5a91ff2
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/PIPParameterComponent.java
@@ -0,0 +1,453 @@
+/*
+ * 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.xacml.admin.view.components;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.jpa.PIPConfigParam;
+import org.apache.openaz.xacml.admin.jpa.PIPConfiguration;
+import org.apache.openaz.xacml.admin.jpa.PIPResolver;
+import org.apache.openaz.xacml.admin.jpa.PIPResolverParam;
+import org.apache.openaz.xacml.admin.view.events.FormChangedEventListener;
+import org.apache.openaz.xacml.admin.view.events.FormChangedEventNotifier;
+import org.apache.openaz.xacml.admin.view.windows.PIPParamEditorWindow;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.util.BeanItem;
+import com.vaadin.data.util.BeanItemContainer;
+import com.vaadin.event.Action;
+import com.vaadin.event.Action.Handler;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window.CloseEvent;
+import com.vaadin.ui.Window.CloseListener;
+
+public class PIPParameterComponent extends CustomComponent implements FormChangedEventNotifier {
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Table tableParameters;
+ @AutoGenerated
+ private HorizontalLayout horizontalLayout_1;
+ @AutoGenerated
+ private Button buttonClear;
+ @AutoGenerated
+ private Button buttonClone;
+ @AutoGenerated
+ private Button buttonRemove;
+ @AutoGenerated
+ private Button buttonAdd;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static final Log logger = LogFactory.getLog(PIPParameterComponent.class);
+ private final PIPParameterComponent self = this;
+ private final Object config;
+ private final BasicNotifier notifier = new BasicNotifier();
+
+ private static final Action ADD_PARAM = new Action ("Add Parameter");
+ private static final Action EDIT_PARAM = new Action ("Edit Parameter");
+ private static final Action REMOVE_PARAM = new Action ("Remove Parameter");
+ private static final Action CLONE_PARAM = new Action ("Clone Parameter");
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public PIPParameterComponent(Object config) {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+ //
+ // Save
+ //
+ this.config = config;
+ //
+ // Initialize
+ //
+ this.initializeTable();
+ this.initializeButtons();
+ //
+ // Initial button setup
+ //
+ this.setupButtons();
+ }
+
+ protected void initializeTable() {
+ //
+ // Initialize GUI properties
+ //
+ this.tableParameters.setImmediate(true);
+ this.tableParameters.setSelectable(true);
+ //
+ // Add in the data
+ //
+ if (this.config instanceof PIPConfiguration) {
+ BeanItemContainer<PIPConfigParam> container = new BeanItemContainer<PIPConfigParam>(PIPConfigParam.class);
+ PIPConfiguration config = (PIPConfiguration) this.config;
+ for (PIPConfigParam param : config.getPipconfigParams()) {
+ container.addBean(param);
+ }
+ this.tableParameters.setContainerDataSource(container);
+ } else if (this.config instanceof PIPResolver) {
+ BeanItemContainer<PIPResolverParam> container = new BeanItemContainer<PIPResolverParam>(PIPResolverParam.class);
+ PIPResolver resolver = (PIPResolver) this.config;
+ for (PIPResolverParam param : resolver.getPipresolverParams()) {
+ container.addBean(param);
+ }
+ this.tableParameters.setContainerDataSource(container);
+ } else {
+ throw new IllegalArgumentException("Unsupported object");
+ }
+ //
+ // Finish more gui initialization
+ //
+ this.tableParameters.setPageLength(5);//this.tableParameters.getContainerDataSource().size() + 1);
+ this.tableParameters.setVisibleColumns(new Object[] {"paramName", "paramValue"});
+ this.tableParameters.setColumnHeaders(new String[] {"Name", "Value"});
+ this.tableParameters.setSizeFull();
+ //
+ // Action Handler
+ //
+ this.tableParameters.addActionHandler(new Handler() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Action[] getActions(Object target, Object sender) {
+ if (target == null) {
+ return new Action[] {ADD_PARAM};
+ }
+ return new Action[] {EDIT_PARAM, REMOVE_PARAM, CLONE_PARAM};
+ }
+
+ @Override
+ public void handleAction(Action action, Object sender, Object target) {
+ if (action == ADD_PARAM) {
+ self.editParameter(null);
+ return;
+ }
+ if (action == EDIT_PARAM) {
+ self.editParameter(target);
+ return;
+ }
+ if (action == REMOVE_PARAM) {
+ self.removeParameter(target);
+ return;
+ }
+ if (action == CLONE_PARAM) {
+ self.cloneParameter(target);
+ return;
+ }
+ }
+ });
+ //
+ // Respond to events
+ //
+ this.tableParameters.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ self.setupButtons();
+ }
+ });
+ //
+ // Double click
+ //
+ this.tableParameters.addItemClickListener(new ItemClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void itemClick(ItemClickEvent event) {
+ if (event.isDoubleClick()) {
+ self.editParameter(event.getItemId());
+ }
+ }
+ });
+ }
+
+ protected void initializeButtons() {
+ this.buttonAdd.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ self.editParameter(null);
+ }
+ });
+ this.buttonClone.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ self.cloneParameter(self.tableParameters.getValue());
+ }
+ });
+ this.buttonRemove.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ self.removeParameter(self.tableParameters.getValue());
+ }
+ });
+ this.buttonClear.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ self.clearParameters();
+ }
+ });
+ }
+
+ protected void setupButtons() {
+ if (this.tableParameters.getValue() != null) {
+ this.buttonClone.setEnabled(true);
+ this.buttonRemove.setEnabled(true);
+ } else {
+ this.buttonClone.setEnabled(false);
+ this.buttonRemove.setEnabled(false);
+ }
+ }
+
+ protected void editParameter(final Object source) {
+ //
+ // Make a copy
+ //
+ final Object target = source != null ? source : this.config instanceof PIPConfiguration ? new PIPConfigParam() : new PIPResolverParam();
+ final PIPParamEditorWindow window = new PIPParamEditorWindow(target);
+ window.setModal(true);
+ window.setCaption((source == null ? "Create New Parameter" : "Edit Parameter"));
+ window.center();
+ window.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Did user save?
+ //
+ if (window.isSaved() == false) {
+ return;
+ }
+ //
+ // Yes - was it a brand new object?
+ //
+ if (source == null) {
+ //
+ // yes add it to the parent object
+ //
+ if (self.config instanceof PIPConfiguration) {
+ ((PIPConfiguration) self.config).addPipconfigParam((PIPConfigParam) target);
+ } else {
+ ((PIPResolver) self.config).addPipresolverParam((PIPResolverParam) target);
+ }
+ //
+ // add it to the table
+ //
+ Item item = self.tableParameters.addItem(target);
+ if (item == null) {
+ logger.error("Failed to add parameter: " + target);
+ } else {
+ self.tableParameters.select(target);
+ }
+ } else {
+ //
+ // Copy the parameters over
+ //
+ if (source instanceof PIPConfigParam) {
+ ((PIPConfigParam) source).setParamName(((PIPConfigParam) target).getParamName());
+ ((PIPConfigParam) source).setParamValue(((PIPConfigParam) target).getParamValue());
+ } else {
+ ((PIPResolverParam) source).setParamName(((PIPResolverParam) target).getParamName());
+ ((PIPResolverParam) source).setParamValue(((PIPResolverParam) target).getParamValue());
+ }
+ //
+ // Update the table
+ //
+ self.tableParameters.refreshRowCache();
+ }
+ }
+ });
+ UI.getCurrent().addWindow(window);
+ }
+
+ protected void cloneParameter(Object target) {
+ if (target == null) {
+ logger.error("null target sent to clone method");
+ return;
+ }
+ Item item;
+ if (target instanceof PIPConfigParam && this.config instanceof PIPConfiguration) {
+ PIPConfigParam param = new PIPConfigParam((PIPConfigParam) target);
+ ((PIPConfiguration) this.config).addPipconfigParam(param);
+ item = this.tableParameters.addItem(new BeanItem<PIPConfigParam>(param));
+ } else if (target instanceof PIPResolverParam && this.config instanceof PIPResolver) {
+ PIPResolverParam param = new PIPResolverParam((PIPResolverParam) target);
+ ((PIPResolver) this.config).addPipresolverParam(param);
+ item = this.tableParameters.addItem(new BeanItem<PIPResolverParam>(param));
+ } else {
+ throw new IllegalArgumentException("Unsupported param and config combination.");
+ }
+ if (item == null) {
+ logger.error("Failed to add parameter to table: " + target);
+ } else {
+ this.tableParameters.select(target);
+ }
+ }
+
+ protected void removeParameter(Object target) {
+ if (target == null) {
+ logger.error("null target sent to remove method");
+ return;
+ }
+ if (this.config instanceof PIPConfiguration) {
+ if (((PIPConfiguration)this.config).removePipconfigParam((PIPConfigParam) target) == null) {
+ logger.error("Failed to remove parameter from pip configuration");
+ return;
+ }
+ } else {
+ if (((PIPResolver) this.config).removePipresolverParam((PIPResolverParam) target) == null) {
+ logger.error("Failed to remove parameter from pip resolver");
+ return;
+ }
+ }
+ if (this.tableParameters.removeItem(target) == false) {
+ logger.error("Failed to remove parameter from table");
+ }
+ }
+
+ protected void clearParameters() {
+ this.tableParameters.removeAllItems();
+ if (this.config instanceof PIPConfiguration) {
+ ((PIPConfiguration) this.config).clearConfigParams();
+ } else {
+ ((PIPResolver) this.config).clearParams();
+ }
+ }
+
+ @Override
+ public boolean addListener(FormChangedEventListener listener) {
+ return this.notifier.addListener(listener);
+ }
+
+ @Override
+ public boolean removeListener(FormChangedEventListener listener) {
+ return this.notifier.removeListener(listener);
+ }
+
+ @Override
+ public void fireFormChangedEvent() {
+ this.notifier.fireFormChangedEvent();
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(false);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // horizontalLayout_1
+ horizontalLayout_1 = buildHorizontalLayout_1();
+ mainLayout.addComponent(horizontalLayout_1);
+
+ // tableParameters
+ tableParameters = new Table();
+ tableParameters.setCaption("Configuration Parameters");
+ tableParameters.setImmediate(false);
+ tableParameters.setWidth("-1px");
+ tableParameters.setHeight("-1px");
+ mainLayout.addComponent(tableParameters);
+
+ return mainLayout;
+ }
+
+ @AutoGenerated
+ private HorizontalLayout buildHorizontalLayout_1() {
+ // common part: create layout
+ horizontalLayout_1 = new HorizontalLayout();
+ horizontalLayout_1.setImmediate(false);
+ horizontalLayout_1.setWidth("-1px");
+ horizontalLayout_1.setHeight("-1px");
+ horizontalLayout_1.setMargin(false);
+ horizontalLayout_1.setSpacing(true);
+
+ // buttonAdd
+ buttonAdd = new Button();
+ buttonAdd.setCaption("Add");
+ buttonAdd.setImmediate(false);
+ buttonAdd.setWidth("-1px");
+ buttonAdd.setHeight("-1px");
+ horizontalLayout_1.addComponent(buttonAdd);
+
+ // buttonRemove
+ buttonRemove = new Button();
+ buttonRemove.setCaption("Remove");
+ buttonRemove.setImmediate(false);
+ buttonRemove.setWidth("-1px");
+ buttonRemove.setHeight("-1px");
+ horizontalLayout_1.addComponent(buttonRemove);
+
+ // buttonClone
+ buttonClone = new Button();
+ buttonClone.setCaption("Clone");
+ buttonClone.setImmediate(false);
+ buttonClone.setWidth("-1px");
+ buttonClone.setHeight("-1px");
+ horizontalLayout_1.addComponent(buttonClone);
+
+ // buttonClear
+ buttonClear = new Button();
+ buttonClear.setCaption("Clear All");
+ buttonClear.setImmediate(false);
+ buttonClear.setWidth("-1px");
+ buttonClear.setHeight("-1px");
+ horizontalLayout_1.addComponent(buttonClear);
+
+ return horizontalLayout_1;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/PIPResolverComponent.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/PIPResolverComponent.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/PIPResolverComponent.java
new file mode 100644
index 0000000..7529e70
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/PIPResolverComponent.java
@@ -0,0 +1,275 @@
+/*
+ * 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.xacml.admin.view.components;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.XacmlAdminUI;
+import org.apache.openaz.xacml.admin.jpa.PIPConfiguration;
+import org.apache.openaz.xacml.admin.jpa.PIPResolver;
+import org.apache.openaz.xacml.admin.view.windows.PIPResolverEditorWindow;
+import org.apache.openaz.xacml.std.pip.engines.csv.ConfigurableCSVResolver;
+import org.apache.openaz.xacml.std.pip.engines.jdbc.ConfigurableJDBCResolver;
+import org.apache.openaz.xacml.std.pip.engines.ldap.ConfigurableLDAPResolver;
+import com.vaadin.addon.jpacontainer.EntityItem;
+import com.vaadin.addon.jpacontainer.JPAContainer;
+import com.vaadin.addon.jpacontainer.provider.CachingMutableLocalEntityProvider;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.util.filter.Compare;
+import com.vaadin.event.Action;
+import com.vaadin.event.Action.Handler;
+import com.vaadin.event.ItemClickEvent;
+import com.vaadin.event.ItemClickEvent.ItemClickListener;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Table;
+import com.vaadin.ui.UI;
+import com.vaadin.ui.VerticalLayout;
+import com.vaadin.ui.Window.CloseEvent;
+import com.vaadin.ui.Window.CloseListener;
+
+public class PIPResolverComponent extends CustomComponent {
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Table tableResolvers;
+
+ private final Action ADD_RESOLVER = new Action("Add Resolver");
+ private final Action EDIT_RESOLVER = new Action("Edit Resolver");
+ private final Action CLONE_RESOLVER = new Action("Clone Resolver");
+ private final Action REMOVE_RESOLVER = new Action("Remove Resolver");
+
+ private static final long serialVersionUID = 1L;
+ private static final Log logger = LogFactory.getLog(PIPResolverComponent.class);
+
+ private final PIPResolverComponent self = this;
+ private final PIPConfiguration config;
+
+ private final JPAContainer<PIPResolver> resolverContainer = new JPAContainer<PIPResolver>(PIPResolver.class);
+
+ /**
+ * The constructor should first build the main layout, set the
+ * composition root and then do any custom initialization.
+ *
+ * The constructor will not be automatically regenerated by the
+ * visual editor.
+ */
+ public PIPResolverComponent(PIPConfiguration configuration) {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+ //
+ // Save
+ //
+ this.config = configuration;
+ this.resolverContainer.setEntityProvider(new CachingMutableLocalEntityProvider<PIPResolver>(PIPResolver.class, ((XacmlAdminUI)UI.getCurrent()).getEntityManager()));
+ this.resolverContainer.addContainerFilter(new Compare.Equal("pipconfiguration", this.config));
+ //
+ // Initialize GUI
+ //
+ this.initializeTable();
+ }
+
+ protected void initializeTable() {
+ //
+ // Setup the container datasource
+ //
+ this.tableResolvers.setContainerDataSource(this.resolverContainer);
+ //
+ // Set GUI properties
+ //
+ this.tableResolvers.setImmediate(true);
+ this.tableResolvers.setVisibleColumns(new Object[] {"name", "description", "issuer"});
+ this.tableResolvers.setColumnHeaders(new String[] {"Name", "Description", "Issuer"});
+ this.tableResolvers.setPageLength(this.config.getPipresolvers().size() + 1);
+ this.tableResolvers.setSizeFull();
+ this.tableResolvers.setSelectable(true);
+ //
+ // Add the actions
+ //
+ this.tableResolvers.addActionHandler(new Handler() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Action[] getActions(Object target, Object sender) {
+ if (target == null) {
+ return new Action[] {ADD_RESOLVER};
+ }
+ return new Action[] {EDIT_RESOLVER, CLONE_RESOLVER, REMOVE_RESOLVER};
+ }
+
+ @Override
+ public void handleAction(Action action, Object sender, Object target) {
+ if (action == ADD_RESOLVER) {
+ PIPResolverComponent.addResolver(self.config, null);
+ return;
+ }
+ if (action == EDIT_RESOLVER) {
+ PIPResolverComponent.editResolver(self.resolverContainer.getItem(target));
+ return;
+ }
+ if (action == CLONE_RESOLVER) {
+ PIPResolverComponent.addResolver(self.config, self.resolverContainer.getItem(target).getEntity());
+ return;
+ }
+ if (action == REMOVE_RESOLVER) {
+ self.removeResolver(self.config, self.resolverContainer.getItem(target).getEntity());
+ return;
+ }
+ }
+ });
+ //
+ // Respond to events
+ //
+ this.tableResolvers.addItemClickListener(new ItemClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void itemClick(ItemClickEvent event) {
+ if (event.isDoubleClick()) {
+ Object id = event.getItemId();
+ if (id == null) {
+ return;
+ }
+ PIPResolverComponent.editResolver(self.resolverContainer.getItem(id));
+ }
+ }
+ });
+ }
+
+ protected void removeResolver(PIPConfiguration config, PIPResolver resolver) {
+ config.removePipresolver(resolver);
+ this.tableResolvers.removeItem(resolver.getId());
+ }
+
+ public static void addResolver(PIPConfiguration config, PIPResolver pipResolver) {
+ //
+ // Create the entity
+ //
+ PIPResolver resolver = null;
+ if (pipResolver != null) {
+ resolver = new PIPResolver(pipResolver);
+ } else {
+ resolver = new PIPResolver();
+ }
+ resolver.setCreatedBy(((XacmlAdminUI)UI.getCurrent()).getUserid());
+ resolver.setModifiedBy(((XacmlAdminUI)UI.getCurrent()).getUserid());
+ resolver.setPipconfiguration(config);
+ //
+ // Set its default class
+ //
+ if (config.getPiptype().isSQL()) {
+ resolver.setClassname(ConfigurableJDBCResolver.class.getCanonicalName());
+ } else if (config.getPiptype().isLDAP()) {
+ resolver.setClassname(ConfigurableLDAPResolver.class.getCanonicalName());
+ } else if (config.getPiptype().isCSV()) {
+ resolver.setClassname(ConfigurableCSVResolver.class.getCanonicalName());
+ } else if (config.getPiptype().isHyperCSV()) {
+ resolver.setClassname(ConfigurableJDBCResolver.class.getCanonicalName());
+ }
+ //
+ // Bring up the editor window
+ //
+ PIPResolverComponent.editResolver(((XacmlAdminUI)UI.getCurrent()).getPIPResolvers().createEntityItem(resolver));
+
+ }
+
+ public static void editResolver(final EntityItem<PIPResolver> entity) {
+
+ final PIPResolverEditorWindow window = new PIPResolverEditorWindow(entity);
+ window.setModal(true);
+ window.center();
+ if (entity.isPersistent()) {
+ window.setCaption("Edit Resolver");
+ } else {
+ window.setCaption("Create Resolver");
+ }
+ window.addCloseListener(new CloseListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void windowClose(CloseEvent e) {
+ //
+ // Did the user click "save"?
+ //
+ if (window.isSaved() == false) {
+ return;
+ }
+ //
+ // Adding a new entity?
+ //
+ if (entity.isPersistent() == false) {
+ //
+ // Yes - let's official add it
+ //
+ ((XacmlAdminUI)UI.getCurrent()).getPIPResolvers().addEntity(entity.getEntity());
+ ((XacmlAdminUI)UI.getCurrent()).refreshPIPConfiguration();
+ }
+ }
+ });
+ UI.getCurrent().addWindow(window);
+ }
+
+ public static void publishConfiguration(EntityItem<PIPConfiguration> config) {
+ Properties properties = config.getEntity().generateProperties(Integer.toString(config.getEntity().getId()));
+
+ try {
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ properties.store(os, "");
+ if (logger.isDebugEnabled()) {
+ logger.debug(os.toString());
+ }
+ } catch (IOException e) { //NOPMD
+ // TODO - Handle, Log or NOPMD
+ // TODO - Will vaadin display error?
+ }
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(false);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // tableResolvers
+ tableResolvers = new Table();
+ tableResolvers.setCaption("Resolvers");
+ tableResolvers.setImmediate(false);
+ tableResolvers.setWidth("-1px");
+ tableResolvers.setHeight("-1px");
+ mainLayout.addComponent(tableResolvers);
+
+ return mainLayout;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/RangeEditorComponent.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/RangeEditorComponent.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/RangeEditorComponent.java
new file mode 100644
index 0000000..d07aa34
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/RangeEditorComponent.java
@@ -0,0 +1,599 @@
+/*
+ * 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.xacml.admin.view.components;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.jpa.Attribute;
+import org.apache.openaz.xacml.admin.jpa.ConstraintValue;
+import org.apache.openaz.xacml.admin.util.AdminNotification;
+import org.apache.openaz.xacml.api.Identifier;
+import org.apache.openaz.xacml.api.XACML3;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.Validator;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.data.validator.DoubleRangeValidator;
+import com.vaadin.data.validator.IntegerRangeValidator;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.ComboBox;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.HorizontalLayout;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+public class RangeEditorComponent extends CustomComponent {
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+ @AutoGenerated
+ private Panel panelTester;
+ @AutoGenerated
+ private VerticalLayout verticalLayout_2;
+ @AutoGenerated
+ private Button buttonValidate;
+ @AutoGenerated
+ private TextField textFieldTestInput;
+ @AutoGenerated
+ private HorizontalLayout horizontalLayout_2;
+ @AutoGenerated
+ private TextField textFieldMax;
+ @AutoGenerated
+ private ComboBox comboBoxMax;
+ @AutoGenerated
+ private HorizontalLayout horizontalLayout_1;
+ @AutoGenerated
+ private TextField textFieldMin;
+ @AutoGenerated
+ private ComboBox comboBoxMin;
+ private static final long serialVersionUID = -1L;
+ private static final Log logger = LogFactory.getLog(RangeEditorComponent.class);
+ private final RangeEditorComponent self = this;
+ private final Attribute attribute;
+ private Identifier datatype;
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ public RangeEditorComponent(Attribute attribute, Identifier datatype) {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+ //
+ // Save our attribute
+ //
+ this.attribute = attribute;
+ this.datatype = datatype;
+ //
+ // Finish initialization
+ //
+ this.initializeCombos();
+ this.initializeTextFields();
+ this.initializeTest();
+ this.setupDatatype(this.datatype);
+ }
+
+ private void initializeCombos() {
+ //
+ // Add the 2 possible values into each combo box
+ //
+ this.comboBoxMin.setNullSelectionAllowed(true);
+ this.comboBoxMin.addItem("minInclusive");
+ this.comboBoxMin.addItem("minExclusive");
+ this.comboBoxMax.addItem("maxInclusive");
+ this.comboBoxMax.addItem("maxExclusive");
+ //
+ // Find any current values
+ //
+ for (ConstraintValue value : this.attribute.getConstraintValues()) {
+ if (value.getProperty().equals("minInclusive") ||
+ value.getProperty().equals("minExclusive")) {
+ //
+ // If it hasn't been set yet
+ //
+ if (this.comboBoxMin.getData() == null) {
+ //
+ // Select the appropriate combo value
+ //
+ this.comboBoxMin.select(value.getProperty());
+ //
+ // Save the object
+ //
+ this.comboBoxMin.setData(value);
+ //
+ // Setup the text field
+ //
+ this.textFieldMin.setValue(value.getValue());
+ } else {
+ //
+ // Extra value in there, this shouldn't happen. But this
+ // is here just in case
+ //
+ logger.warn("Extra min value found: " + value.getProperty() + " " + value.getValue());
+ }
+ } else if (value.getProperty().equals("maxInclusive") ||
+ value.getProperty().equals("maxExclusive")) {
+ //
+ // Check if it hasn't been set yet
+ //
+ if (this.comboBoxMax.getData() == null) {
+ //
+ // Select the appropriate combo value
+ //
+ this.comboBoxMax.select(value.getProperty());
+ //
+ // Save the object
+ //
+ this.comboBoxMax.setData(value);
+ //
+ // Setup the text field
+ //
+ this.textFieldMax.setValue(value.getValue());
+ } else {
+ //
+ // Extra value in there, this shouldn't happen. But this
+ // is here just in case
+ //
+ logger.warn("Extra max value found: " + value.getProperty() + " " + value.getValue());
+ }
+ } else {
+ logger.warn("Non-range value found: " + value.getProperty() + " " + value.getValue());
+ }
+ }
+ //
+ // Were there values?
+ //
+ if (this.comboBoxMin.getData() == null) {
+ //
+ // Put a new empty value in there
+ //
+ ConstraintValue value = new ConstraintValue("minInclusive", null);
+ //
+ // Associate it with the attribute
+ //
+ value.setAttribute(this.attribute);
+ //
+ // Make sure the attribute has it in its list
+ //
+ this.attribute.addConstraintValue(value);
+ //
+ // Save it in the combo
+ //
+ this.comboBoxMin.setData(value);
+ //
+ // Disable text field
+ //
+ this.textFieldMin.setEnabled(false);
+ }
+ if (this.comboBoxMax.getData() == null) {
+ //
+ // Put a new empty value in there
+ //
+ ConstraintValue value = new ConstraintValue("maxInclusive", null);
+ //
+ // Associate it with the attribute
+ //
+ value.setAttribute(this.attribute);
+ //
+ // Make sure the attribute has it in its list
+ //
+ this.attribute.addConstraintValue(value);
+ //
+ // Save it in the combo
+ //
+ this.comboBoxMax.setData(value);
+ //
+ // Disable text field
+ //
+ this.textFieldMax.setEnabled(false);
+ }
+ //
+ // Respond to combo changes
+ //
+ this.setupComboText(this.comboBoxMin, this.textFieldMin);
+ this.setupComboText(this.comboBoxMax, this.textFieldMax);
+ }
+
+ private void setupComboText(final ComboBox box, final TextField text) {
+ //
+ // Respond to combo changes
+ //
+ box.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ //
+ // Get the new value
+ //
+ String property = (String) box.getValue();
+ //
+ // Get our constraint object
+ //
+ ConstraintValue value = (ConstraintValue) box.getData();
+ //
+ // Update our object
+ //
+ if (property == null) {
+ //
+ // Clear the text field and disable it
+ //
+ text.setEnabled(false);
+ text.setValue(null);
+ } else {
+ //
+ // Change the property name
+ //
+ value.setProperty(property);
+ //
+ // Focus to the text field and enable it
+ //
+ text.setEnabled(true);
+ text.focus();
+ }
+ }
+ });
+
+ }
+
+ private void initializeTextFields() {
+ this.textFieldMin.setNullRepresentation("");
+ this.textFieldMin.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ //
+ // Get our min object
+ //
+ ConstraintValue value = (ConstraintValue) self.comboBoxMin.getData();
+ //
+ // Save its new value
+ //
+ value.setValue(self.textFieldMin.getValue());
+ }
+ });
+ this.textFieldMax.setNullRepresentation("");
+ this.textFieldMax.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ //
+ // Get our max object
+ //
+ ConstraintValue value = (ConstraintValue) self.comboBoxMax.getData();
+ //
+ // Save its new value
+ //
+ value.setValue(self.textFieldMax.getValue());
+ }
+
+ });
+ }
+
+ private void initializeTest() {
+ this.textFieldTestInput.setNullRepresentation("");
+ this.textFieldTestInput.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ if (self.textFieldTestInput.getValue() != null && self.textFieldTestInput.getValue().length() > 0) {
+ self.buttonValidate.setEnabled(true);
+ } else {
+ self.buttonValidate.setEnabled(false);
+ }
+ }
+ });
+
+ this.buttonValidate.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ //
+ // Create our validator and add it into the text
+ //
+ Validator validator = self.setupValidator(self.datatype);
+ if (validator == null) {
+ logger.warn("Could not create a validator");
+ return;
+ }
+ self.textFieldTestInput.addValidator(validator);
+ //
+ // Initiate the validation
+ //
+ try {
+ self.textFieldTestInput.validate();
+ //
+ // If we get here, then it validated!
+ //
+ AdminNotification.info("Success! Value is in range");
+ } catch (InvalidValueException e) {
+ AdminNotification.warn("Failed, Value is NOT in range");
+ }
+ //
+ // Remove the validator
+ //
+ self.textFieldTestInput.removeValidator(validator);
+ }
+ });
+ }
+
+ private Validator setupValidator(Identifier id) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("setupValidator: " + id);
+ }
+ //
+ // Get our min/max objects
+ //
+ ConstraintValue min = (ConstraintValue) self.comboBoxMin.getData();
+ ConstraintValue max = (ConstraintValue) self.comboBoxMax.getData();
+ Object minObject = self.comboBoxMin.getConvertedValue();
+ Object maxObject = self.comboBoxMax.getConvertedValue();
+ logger.debug("Converted values: " + minObject + " " + maxObject);
+ //
+ // Get our min/max values
+ //
+ String minValue = self.textFieldMin.getValue();
+ String maxValue = self.textFieldMax.getValue();
+ //
+ // What is our datatype?
+ //
+ if (id.equals(XACML3.ID_DATATYPE_INTEGER)) {
+ Integer minimum = null;
+ Integer maximum = null;
+ boolean minInclusive = true;
+ boolean maxInclusive = true;
+ if (min.getProperty() != null) {
+ if (minValue != null && minValue.length() > 0) {
+ minimum = Integer.parseInt(minValue);
+ }
+ if (min.getProperty().equals("minInclusive")) {
+ minInclusive = true;
+ } else if (min.getProperty().equals("minExclusive")) {
+ minInclusive = false;
+ }
+ }
+ if (max.getProperty() != null) {
+ if (maxValue != null && maxValue.length() > 0) {
+ maximum = Integer.parseInt(maxValue);
+ }
+ if (max.getProperty().equals("maxInclusive")) {
+ maxInclusive = true;
+ } else if (max.getProperty().equals("maxExclusive")) {
+ maxInclusive = false;
+ }
+ }
+ IntegerRangeValidator validator = new IntegerRangeValidator("The value is NOT within the range", minimum, maximum);
+ validator.setMinValueIncluded(minInclusive);
+ validator.setMaxValueIncluded(maxInclusive);
+ return validator;
+ }
+ if (id.equals(XACML3.ID_DATATYPE_DOUBLE)) {
+ Double minimum = null;
+ Double maximum = null;
+ boolean minInclusive = true;
+ boolean maxInclusive = true;
+ if (min.getProperty() != null) {
+ if (minValue != null && minValue.length() > 0) {
+ minimum = Double.parseDouble(minValue);
+ }
+ if (min.getProperty().equals("minInclusive")) {
+ minInclusive = true;
+ } else if (min.getProperty().equals("minExclusive")) {
+ minInclusive = false;
+ }
+ }
+ if (max.getProperty() != null) {
+ if (maxValue != null && maxValue.length() > 0) {
+ maximum = Double.parseDouble(maxValue);
+ }
+ if (max.getProperty().equals("maxInclusive")) {
+ maxInclusive = true;
+ } else if (max.getProperty().equals("maxExclusive")) {
+ maxInclusive = false;
+ }
+ }
+ DoubleRangeValidator validator = new DoubleRangeValidator("The value is NOT within the range", minimum, maximum);
+ validator.setMinValueIncluded(minInclusive);
+ validator.setMaxValueIncluded(maxInclusive);
+ return validator;
+ }
+
+ return null;
+ }
+
+ public void setupDatatype(Identifier datatype) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("setupDatatype: " + datatype);
+ }
+ this.datatype = datatype;
+ if (datatype.equals(XACML3.ID_DATATYPE_INTEGER)) {
+ this.textFieldMin.setConverter(Integer.class);
+ this.textFieldMax.setConverter(Integer.class);
+ this.textFieldTestInput.setConverter(Integer.class);
+ return;
+ }
+ if (datatype.equals(XACML3.ID_DATATYPE_DOUBLE)) {
+ this.textFieldMin.setConverter(Double.class);
+ this.textFieldMax.setConverter(Double.class);
+ this.textFieldTestInput.setConverter(Double.class);
+ return;
+ }
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // horizontalLayout_1
+ horizontalLayout_1 = buildHorizontalLayout_1();
+ mainLayout.addComponent(horizontalLayout_1);
+ mainLayout.setExpandRatio(horizontalLayout_1, 1.0f);
+
+ // horizontalLayout_2
+ horizontalLayout_2 = buildHorizontalLayout_2();
+ mainLayout.addComponent(horizontalLayout_2);
+ mainLayout.setExpandRatio(horizontalLayout_2, 1.0f);
+
+ // panelTester
+ panelTester = buildPanelTester();
+ mainLayout.addComponent(panelTester);
+ mainLayout.setExpandRatio(panelTester, 1.0f);
+
+ return mainLayout;
+ }
+
+ @AutoGenerated
+ private HorizontalLayout buildHorizontalLayout_1() {
+ // common part: create layout
+ horizontalLayout_1 = new HorizontalLayout();
+ horizontalLayout_1.setImmediate(false);
+ horizontalLayout_1.setWidth("-1px");
+ horizontalLayout_1.setHeight("-1px");
+ horizontalLayout_1.setMargin(false);
+ horizontalLayout_1.setSpacing(true);
+
+ // comboBoxMin
+ comboBoxMin = new ComboBox();
+ comboBoxMin.setCaption("Minimum Type");
+ comboBoxMin.setImmediate(true);
+ comboBoxMin.setDescription("Select the type for the minimum.");
+ comboBoxMin.setWidth("-1px");
+ comboBoxMin.setHeight("-1px");
+ horizontalLayout_1.addComponent(comboBoxMin);
+
+ // textFieldMin
+ textFieldMin = new TextField();
+ textFieldMin.setCaption("Minimum Value");
+ textFieldMin.setImmediate(true);
+ textFieldMin.setDescription("Enter a value for the minimum.");
+ textFieldMin.setWidth("-1px");
+ textFieldMin.setHeight("-1px");
+ textFieldMin.setInvalidAllowed(false);
+ textFieldMin.setInputPrompt("eg. 1");
+ horizontalLayout_1.addComponent(textFieldMin);
+ horizontalLayout_1
+ .setComponentAlignment(textFieldMin, new Alignment(9));
+
+ return horizontalLayout_1;
+ }
+
+ @AutoGenerated
+ private HorizontalLayout buildHorizontalLayout_2() {
+ // common part: create layout
+ horizontalLayout_2 = new HorizontalLayout();
+ horizontalLayout_2.setImmediate(false);
+ horizontalLayout_2.setWidth("-1px");
+ horizontalLayout_2.setHeight("-1px");
+ horizontalLayout_2.setMargin(false);
+ horizontalLayout_2.setSpacing(true);
+
+ // comboBoxMax
+ comboBoxMax = new ComboBox();
+ comboBoxMax.setCaption("Maximum Type");
+ comboBoxMax.setImmediate(true);
+ comboBoxMax.setDescription("Select the type for the maximum.");
+ comboBoxMax.setWidth("-1px");
+ comboBoxMax.setHeight("-1px");
+ horizontalLayout_2.addComponent(comboBoxMax);
+
+ // textFieldMax
+ textFieldMax = new TextField();
+ textFieldMax.setCaption("Maximum Value");
+ textFieldMax.setImmediate(true);
+ textFieldMax.setDescription("Enter a value for the maxmum.");
+ textFieldMax.setWidth("-1px");
+ textFieldMax.setHeight("-1px");
+ textFieldMax.setInvalidAllowed(false);
+ textFieldMax.setInputPrompt("eg. 100");
+ horizontalLayout_2.addComponent(textFieldMax);
+
+ return horizontalLayout_2;
+ }
+
+ @AutoGenerated
+ private Panel buildPanelTester() {
+ // common part: create layout
+ panelTester = new Panel();
+ panelTester.setCaption("Test Range Values");
+ panelTester.setImmediate(true);
+ panelTester.setWidth("-1px");
+ panelTester.setHeight("-1px");
+
+ // verticalLayout_2
+ verticalLayout_2 = buildVerticalLayout_2();
+ panelTester.setContent(verticalLayout_2);
+
+ return panelTester;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildVerticalLayout_2() {
+ // common part: create layout
+ verticalLayout_2 = new VerticalLayout();
+ verticalLayout_2.setImmediate(false);
+ verticalLayout_2.setWidth("100.0%");
+ verticalLayout_2.setHeight("100.0%");
+ verticalLayout_2.setMargin(false);
+ verticalLayout_2.setSpacing(true);
+
+ // textFieldTestInput
+ textFieldTestInput = new TextField();
+ textFieldTestInput.setCaption("Value");
+ textFieldTestInput.setImmediate(true);
+ textFieldTestInput.setDescription("Enter a value to test against.");
+ textFieldTestInput.setWidth("-1px");
+ textFieldTestInput.setHeight("-1px");
+ textFieldTestInput.setInputPrompt("eg. 50");
+ verticalLayout_2.addComponent(textFieldTestInput);
+
+ // buttonValidate
+ buttonValidate = new Button();
+ buttonValidate.setCaption("Test");
+ buttonValidate.setImmediate(true);
+ buttonValidate
+ .setDescription("Click to test if value is within the range.");
+ buttonValidate.setWidth("-1px");
+ buttonValidate.setHeight("-1px");
+ verticalLayout_2.addComponent(buttonValidate);
+ verticalLayout_2.setComponentAlignment(buttonValidate,
+ new Alignment(48));
+
+ return verticalLayout_2;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/RegexpEditorComponent.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/RegexpEditorComponent.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/RegexpEditorComponent.java
new file mode 100644
index 0000000..968719a
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/view/components/RegexpEditorComponent.java
@@ -0,0 +1,246 @@
+/*
+ * 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.xacml.admin.view.components;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.admin.jpa.Attribute;
+import org.apache.openaz.xacml.admin.jpa.ConstraintType;
+import org.apache.openaz.xacml.admin.jpa.ConstraintValue;
+import org.apache.openaz.xacml.admin.util.AdminNotification;
+import com.vaadin.annotations.AutoGenerated;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.Validator;
+import com.vaadin.data.Validator.InvalidValueException;
+import com.vaadin.data.validator.RegexpValidator;
+import com.vaadin.ui.Alignment;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.CustomComponent;
+import com.vaadin.ui.Panel;
+import com.vaadin.ui.TextField;
+import com.vaadin.ui.VerticalLayout;
+
+public class RegexpEditorComponent extends CustomComponent {
+ @AutoGenerated
+ private VerticalLayout mainLayout;
+
+ @AutoGenerated
+ private Panel panelTester;
+
+ @AutoGenerated
+ private VerticalLayout verticalLayout_2;
+
+ @AutoGenerated
+ private Button buttonTest;
+
+ @AutoGenerated
+ private TextField textFieldTestValue;
+
+ @AutoGenerated
+ private TextField textFieldExpression;
+
+ private static final long serialVersionUID = -1L;
+ private static final Log logger = LogFactory.getLog(RegexpEditorComponent.class);
+ private RegexpEditorComponent self = this;
+ private final Attribute attribute;
+ private ConstraintValue value = null;
+
+ /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
+
+ public RegexpEditorComponent(Attribute attribute) {
+ buildMainLayout();
+ setCompositionRoot(mainLayout);
+
+ this.attribute = attribute;
+
+ initializeTextField();
+ initializeTestPanel();
+ }
+
+ private void initializeTextField() {
+ //
+ // Find our reg expression value if it exists
+ //
+ for (ConstraintValue value : this.attribute.getConstraintValues()) {
+ if (value.getProperty().equals(ConstraintType.REGEXP_TYPE)) {
+ if (this.value == null) {
+ this.textFieldExpression.setValue(value.getValue());
+ this.value = value;
+ } else {
+ logger.warn("Multiple regexp constraint values: " + value);
+ value.setAttribute(null);
+ this.attribute.removeConstraintValue(value);
+ }
+ } else {
+ value.setAttribute(null);
+ this.attribute.removeConstraintValue(value);
+ }
+ }
+ //
+ // Was something found?
+ //
+ if (this.value == null) {
+ ConstraintValue newValue = new ConstraintValue(ConstraintType.REGEXP_TYPE, "");
+ newValue.setAttribute(this.attribute);
+ this.attribute.addConstraintValue(newValue);
+ this.value = newValue;
+ }
+ //
+ // Save the values when they changes
+ //
+ this.textFieldExpression.addValueChangeListener(new ValueChangeListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ self.value.setValue(self.textFieldExpression.getValue());
+ }
+ });
+ }
+
+ private void initializeTestPanel() {
+ this.textFieldTestValue.setNullRepresentation("");
+
+ this.buttonTest.addClickListener(new ClickListener() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ String testValue = self.textFieldTestValue.getValue();
+ if (testValue == null || testValue.length() == 0) {
+ return;
+ }
+ String regExp = self.textFieldExpression.getValue();
+ if (regExp == null || regExp.length() == 0) {
+ return;
+ }
+ //
+ // Create a validator
+ //
+ Validator validator = new RegexpValidator(regExp, true, "Regular Expression does NOT match.");
+ //
+ // Add it
+ //
+ self.textFieldTestValue.addValidator(validator);
+ //
+ // Validate
+ //
+ try {
+ self.textFieldTestValue.validate();
+ AdminNotification.info("Success! Regular Expression Matches");
+ } catch (InvalidValueException e) {
+ AdminNotification.warn("Failed, Regular Expression does NOT match");
+ }
+ //
+ // Remove the validator
+ //
+ self.textFieldTestValue.removeValidator(validator);
+ }
+ });
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildMainLayout() {
+ // common part: create layout
+ mainLayout = new VerticalLayout();
+ mainLayout.setImmediate(false);
+ mainLayout.setWidth("-1px");
+ mainLayout.setHeight("-1px");
+ mainLayout.setMargin(true);
+ mainLayout.setSpacing(true);
+
+ // top-level component properties
+ setWidth("-1px");
+ setHeight("-1px");
+
+ // textFieldExpression
+ textFieldExpression = new TextField();
+ textFieldExpression.setCaption("Regular Expression");
+ textFieldExpression.setImmediate(true);
+ textFieldExpression
+ .setDescription("Create a regular expression used to constrain attribute values.");
+ textFieldExpression.setWidth("-1px");
+ textFieldExpression.setHeight("-1px");
+ textFieldExpression.setInvalidAllowed(false);
+ textFieldExpression.setInputPrompt("eg. [a-zA-Z0-9]");
+ mainLayout.addComponent(textFieldExpression);
+ mainLayout.setExpandRatio(textFieldExpression, 1.0f);
+
+ // panelTester
+ panelTester = buildPanelTester();
+ mainLayout.addComponent(panelTester);
+ mainLayout.setExpandRatio(panelTester, 1.0f);
+
+ return mainLayout;
+ }
+
+ @AutoGenerated
+ private Panel buildPanelTester() {
+ // common part: create layout
+ panelTester = new Panel();
+ panelTester.setCaption("Test The Expression");
+ panelTester.setImmediate(false);
+ panelTester.setWidth("-1px");
+ panelTester.setHeight("-1px");
+
+ // verticalLayout_2
+ verticalLayout_2 = buildVerticalLayout_2();
+ panelTester.setContent(verticalLayout_2);
+
+ return panelTester;
+ }
+
+ @AutoGenerated
+ private VerticalLayout buildVerticalLayout_2() {
+ // common part: create layout
+ verticalLayout_2 = new VerticalLayout();
+ verticalLayout_2.setImmediate(false);
+ verticalLayout_2.setWidth("100.0%");
+ verticalLayout_2.setHeight("100.0%");
+ verticalLayout_2.setMargin(false);
+
+ // textFieldTestValue
+ textFieldTestValue = new TextField();
+ textFieldTestValue.setCaption("Test Value");
+ textFieldTestValue.setImmediate(true);
+ textFieldTestValue
+ .setDescription("Enter a value to match against the regular expression.");
+ textFieldTestValue.setWidth("-1px");
+ textFieldTestValue.setHeight("-1px");
+ textFieldTestValue.setInputPrompt("eg. example");
+ verticalLayout_2.addComponent(textFieldTestValue);
+
+ // buttonTest
+ buttonTest = new Button();
+ buttonTest.setCaption("Test");
+ buttonTest.setImmediate(true);
+ buttonTest.setWidth("-1px");
+ buttonTest.setHeight("-1px");
+ verticalLayout_2.addComponent(buttonTest);
+ verticalLayout_2.setComponentAlignment(buttonTest, new Alignment(48));
+
+ return verticalLayout_2;
+ }
+}
[14/23] incubator-openaz git commit: Ported original att source to
openaz
Posted by pd...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/ObligationAdviceContainer.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/ObligationAdviceContainer.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/ObligationAdviceContainer.java
new file mode 100644
index 0000000..65f8a3c
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/ObligationAdviceContainer.java
@@ -0,0 +1,1385 @@
+/*
+ * 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.xacml.admin.model;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.JAXBElement;
+
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionsType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeAssignmentExpressionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeSelectorType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObjectFactory;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObligationExpressionType;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.ObligationExpressionsType;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.util.MethodProperty;
+
+public class ObligationAdviceContainer extends ItemSetChangeNotifier implements Container.Hierarchical, Container.ItemSetChangeNotifier {
+ private static final long serialVersionUID = 1L;
+ private static Log logger = LogFactory.getLog(ObligationAdviceContainer.class);
+
+ public static String PROPERTY_NAME = "Name";
+ public static String PROPERTY_ID = "Id";
+ public static String PROPERTY_ID_SHORT = "ShortId";
+ public static String PROPERTY_EFFECT = "Effect";
+ public static String PROPERTY_CATEGORY = "Category";
+ public static String PROPERTY_CATEGORY_SHORT = "ShortCategory";
+ public static String PROPERTY_DATATYPE = "Datatype";
+ public static String PROPERTY_DATATYPE_SHORT = "ShortDatatype";
+
+ /**
+ * List of the string identifiers for the available properties.
+ */
+ public static Collection<String> OBADVICE_PROPERTIES;
+
+ private final static Method OBADVICE_ITEM_NAME;
+
+ private final static Method OBADVICE_ITEM_ID;
+
+ private final static Method OBADVICE_ITEM_ID_SHORT;
+
+ private final static Method OBADVICE_ITEM_EFFECT;
+
+ private final static Method OBADVICE_ITEM_DATATYPE;
+
+ private final static Method OBADVICE_ITEM_DATATYPE_SHORT;
+
+ private final static Method OBADVICE_ITEM_CATEGORY;
+
+ private final static Method OBADVICE_ITEM_CATEGORY_SHORT;
+
+ static {
+ OBADVICE_PROPERTIES = new ArrayList<String>();
+ OBADVICE_PROPERTIES.add(PROPERTY_NAME);
+ OBADVICE_PROPERTIES.add(PROPERTY_ID);
+ OBADVICE_PROPERTIES.add(PROPERTY_ID_SHORT);
+ OBADVICE_PROPERTIES.add(PROPERTY_EFFECT);
+ OBADVICE_PROPERTIES.add(PROPERTY_CATEGORY);
+ OBADVICE_PROPERTIES.add(PROPERTY_DATATYPE_SHORT);
+ OBADVICE_PROPERTIES.add(PROPERTY_DATATYPE);
+ OBADVICE_PROPERTIES.add(PROPERTY_CATEGORY_SHORT);
+ OBADVICE_PROPERTIES = Collections.unmodifiableCollection(OBADVICE_PROPERTIES);
+ try {
+ OBADVICE_ITEM_NAME = ObAdviceItem.class.getMethod("getName", new Class[]{});
+ OBADVICE_ITEM_ID = ObAdviceItem.class.getMethod("getId", new Class[]{});
+ OBADVICE_ITEM_ID_SHORT = ObAdviceItem.class.getMethod("getIdShort", new Class[]{});
+ OBADVICE_ITEM_EFFECT = ObAdviceItem.class.getMethod("getEffect", new Class[]{});
+ OBADVICE_ITEM_DATATYPE = ObAdviceItem.class.getMethod("getDatatype", new Class[]{});
+ OBADVICE_ITEM_DATATYPE_SHORT = ObAdviceItem.class.getMethod("getDatatypeShort", new Class[]{});
+ OBADVICE_ITEM_CATEGORY = ObAdviceItem.class.getMethod("getCategory", new Class[]{});
+ OBADVICE_ITEM_CATEGORY_SHORT = ObAdviceItem.class.getMethod("getCategoryShort", new Class[]{});
+ } catch (final NoSuchMethodException e) {
+ throw new RuntimeException(
+ "Internal error finding methods in ObligationAdviceContainer");
+ }
+ }
+ //
+ // Our root object
+ //
+ private final Object root;
+ //
+ // Our helper maps to control the hierarchy
+ //
+ private List<AdviceExpressionType> rootAdvice = new ArrayList<AdviceExpressionType>();
+ private List<ObligationExpressionType> rootObligations = new ArrayList<ObligationExpressionType>();
+ private Map<AttributeAssignmentExpressionType, AdviceExpressionType> adviceExpressions = new HashMap<AttributeAssignmentExpressionType, AdviceExpressionType>();
+ private Map<AttributeAssignmentExpressionType, ObligationExpressionType> obligationExpressions = new HashMap<AttributeAssignmentExpressionType, ObligationExpressionType>();
+ private Map<AttributeValueType, AttributeAssignmentExpressionType> values = new HashMap<AttributeValueType, AttributeAssignmentExpressionType>();
+ private Map<AttributeDesignatorType, AttributeAssignmentExpressionType> designators = new HashMap<AttributeDesignatorType, AttributeAssignmentExpressionType>();
+ private Map<AttributeSelectorType, AttributeAssignmentExpressionType> selectors = new HashMap<AttributeSelectorType, AttributeAssignmentExpressionType>();
+ private Map<ApplyType, AttributeAssignmentExpressionType> applys = new HashMap<ApplyType, AttributeAssignmentExpressionType>();
+
+ public ObligationAdviceContainer(Object root) {
+ super();
+ this.setContainer(this);
+ //
+ // Save
+ //
+ this.root = root;
+ //
+ // Initialize
+ //
+ this.initialize();
+ }
+
+ protected void initialize() {
+ if (this.root instanceof AdviceExpressionsType) {
+ for (AdviceExpressionType advice : ((AdviceExpressionsType) this.root).getAdviceExpression()) {
+ this.rootAdvice.add(advice);
+ for (AttributeAssignmentExpressionType assignment : advice.getAttributeAssignmentExpression()) {
+ this.adviceExpressions.put(assignment, advice);
+ this.addExpression(assignment.getExpression(), assignment);
+ }
+ }
+ } else if (this.root instanceof ObligationExpressionsType) {
+ for (ObligationExpressionType obligation : ((ObligationExpressionsType) this.root).getObligationExpression()) {
+ this.rootObligations.add(obligation);
+ for (AttributeAssignmentExpressionType assignment : obligation.getAttributeAssignmentExpression()) {
+ this.obligationExpressions.put(assignment, obligation);
+ this.addExpression(assignment.getExpression(), assignment);
+ }
+ }
+ } else {
+ throw new IllegalArgumentException("This container supports only advice or obligation expressions.");
+ }
+ }
+
+ private void addExpression(JAXBElement<?> element, AttributeAssignmentExpressionType parent) {
+ if (element.getValue() == null) {
+ return;
+ }
+ if (element.getValue() instanceof AttributeValueType) {
+ this.values.put((AttributeValueType) element.getValue(), parent);
+ } else if (element.getValue() instanceof AttributeDesignatorType) {
+ this.designators.put((AttributeDesignatorType) element.getValue(), parent);
+ } else if (element.getValue() instanceof AttributeSelectorType) {
+ this.selectors.put((AttributeSelectorType) element.getValue(), parent);
+ } else if (element.getValue() instanceof ApplyType) {
+ this.applys.put((ApplyType) element.getValue(), parent);
+ } else {
+ //
+ // TODO
+ //
+ logger.error("Adding unknown expression type");
+ }
+ }
+
+ public boolean isObjectSupported(Object itemId) {
+ if (itemId instanceof AdviceExpressionType) {
+ return true;
+ }
+ if (itemId instanceof ObligationExpressionType) {
+ return true;
+ }
+ if (itemId instanceof AttributeAssignmentExpressionType) {
+ return true;
+ }
+ if (itemId instanceof AttributeValueType) {
+ return true;
+ }
+ if (itemId instanceof AttributeDesignatorType) {
+ return true;
+ }
+ if (itemId instanceof AttributeSelectorType) {
+ return true;
+ }
+ if (itemId instanceof ApplyType) {
+ return true;
+ }
+ return false;
+ }
+
+ public void updateItem(Object itemId) {
+ this.fireItemSetChange();
+ }
+
+ @Override
+ public Item getItem(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getItem: " + itemId);
+ }
+ if (this.isObjectSupported(itemId) == false) {
+ return null;
+ }
+ return new ObAdviceItem(itemId);
+ }
+
+ @Override
+ public Collection<?> getContainerPropertyIds() {
+ return OBADVICE_PROPERTIES;
+ }
+
+ @Override
+ public Collection<?> getItemIds() {
+ final Collection<Object> items = new ArrayList<Object>();
+ if (this.root instanceof ObligationExpressionsType) {
+ items.addAll(this.rootObligations);
+ if (this.obligationExpressions.isEmpty() == false) {
+ items.addAll(this.obligationExpressions.keySet());
+ }
+ } else if (this.root instanceof AdviceExpressionsType) {
+ items.addAll(this.rootAdvice);
+ if (this.adviceExpressions.isEmpty() == false) {
+ items.addAll(this.adviceExpressions.keySet());
+ }
+ }
+ if (this.values.isEmpty() == false) {
+ items.add(this.values.keySet());
+ }
+ if (this.designators.isEmpty() == false) {
+ items.add(this.designators.keySet());
+ }
+ if (this.selectors.isEmpty() == false) {
+ items.add(this.selectors.keySet());
+ }
+ if (this.applys.isEmpty() == false) {
+ items.add(this.applys.keySet());
+ }
+ if (logger.isTraceEnabled()) {
+ logger.trace("getItemIds (" + items.size() + "):" + items);
+ }
+ return Collections.unmodifiableCollection(items);
+ }
+
+ @Override
+ public Property<?> getContainerProperty(Object itemId, Object propertyId) {
+ if (this.isObjectSupported(itemId) == false) {
+ return null;
+ }
+ if (propertyId.equals(PROPERTY_NAME)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new ObAdviceItem(itemId), OBADVICE_ITEM_NAME, null);
+ }
+
+ if (propertyId.equals(PROPERTY_ID)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new ObAdviceItem(itemId), OBADVICE_ITEM_ID, null);
+ }
+
+ if (propertyId.equals(PROPERTY_ID_SHORT)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new ObAdviceItem(itemId), OBADVICE_ITEM_ID_SHORT, null);
+ }
+
+ if (propertyId.equals(PROPERTY_EFFECT)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new ObAdviceItem(itemId), OBADVICE_ITEM_EFFECT, null);
+ }
+
+ if (propertyId.equals(PROPERTY_DATATYPE)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new ObAdviceItem(itemId), OBADVICE_ITEM_DATATYPE, null);
+ }
+
+ if (propertyId.equals(PROPERTY_DATATYPE_SHORT)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new ObAdviceItem(itemId), OBADVICE_ITEM_DATATYPE_SHORT, null);
+ }
+
+ if (propertyId.equals(PROPERTY_CATEGORY)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new ObAdviceItem(itemId), OBADVICE_ITEM_CATEGORY, null);
+ }
+
+ if (propertyId.equals(PROPERTY_CATEGORY_SHORT)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new ObAdviceItem(itemId), OBADVICE_ITEM_CATEGORY_SHORT, null);
+ }
+
+ return null;
+ }
+
+ @Override
+ public Class<?> getType(Object propertyId) {
+ if (propertyId.equals(PROPERTY_NAME)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_ID)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_ID_SHORT)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_EFFECT)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_DATATYPE)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_DATATYPE_SHORT)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_CATEGORY)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_CATEGORY_SHORT)) {
+ return String.class;
+ }
+ return null;
+ }
+
+ @Override
+ public int size() {
+ int size = 0;
+ if (this.root instanceof ObligationExpressionsType) {
+ size += this.rootObligations.size();
+ size += this.obligationExpressions.size();
+ } else if (this.root instanceof AdviceExpressionsType) {
+ size += this.rootAdvice.size();
+ size += this.adviceExpressions.size();
+ }
+ size += this.values.size();
+ size += this.designators.size();
+ size += this.selectors.size();
+ size += this.applys.size();
+ if (logger.isTraceEnabled()) {
+ logger.trace("size: " + size);
+ }
+ return size;
+ }
+
+ @Override
+ public boolean containsId(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("containsId: " + itemId);
+ }
+ if (itemId instanceof AdviceExpressionType) {
+ return this.rootAdvice.contains(itemId);
+ }
+ if (itemId instanceof ObligationExpressionType) {
+ return this.rootObligations.contains(itemId);
+ }
+ if (itemId instanceof AttributeAssignmentExpressionType) {
+ if (this.root instanceof ObligationExpressionsType) {
+ return this.obligationExpressions.containsKey(itemId);
+ } else if (this.root instanceof AdviceExpressionsType) {
+ return this.adviceExpressions.containsKey(itemId);
+ }
+ }
+ if (itemId instanceof AttributeValueType) {
+ return this.values.containsKey(itemId);
+ }
+ if (itemId instanceof AttributeDesignatorType) {
+ return this.designators.containsKey(itemId);
+ }
+ if (itemId instanceof AttributeSelectorType) {
+ return this.selectors.containsKey(itemId);
+ }
+ if (itemId instanceof ApplyType) {
+ return this.applys.containsKey(itemId);
+ }
+ return false;
+ }
+
+ @Override
+ public Item addItem(Object itemId) throws UnsupportedOperationException {
+ if (itemId instanceof ObligationExpressionType ||
+ itemId instanceof AdviceExpressionType) {
+ return this.addItem(itemId, null);
+ }
+ throw new UnsupportedOperationException("Must be Obligation or Advice Expression Type.");
+ }
+
+ @Override
+ public Object addItem() throws UnsupportedOperationException {
+ if (this.root instanceof ObligationExpressionsType) {
+ return this.addItem(new ObligationExpressionType(), null);
+ } else if (this.root instanceof AdviceExpressionsType) {
+ return this.addItem(new AdviceExpressionType(), null);
+ }
+ //
+ // Should never get here
+ //
+ return null;
+ }
+
+ public Item addItem(Object itemId, Object parent) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("addItem: " + itemId + " " + parent);
+ }
+ //
+ // Check itemId to see if its supported
+ //
+ if (this.isObjectSupported(itemId) == false) {
+ logger.error("Unsupported itemid: " + itemId.getClass().getCanonicalName());
+ return null;
+ }
+ //
+ // Determine what they are trying to add
+ //
+ if (this.root instanceof ObligationExpressionsType) {
+ if (itemId instanceof ObligationExpressionType) {
+ //
+ // Adding a new root obligation expression, is it already in the parent.
+ //
+ if (((ObligationExpressionsType)this.root).getObligationExpression().contains(itemId) == false) {
+ //
+ // It doesn't exist in the object, add it in
+ //
+ ((ObligationExpressionsType)this.root).getObligationExpression().add((ObligationExpressionType) itemId);
+ }
+ //
+ // Track this
+ //
+ this.rootObligations.add((ObligationExpressionType) itemId);
+ //
+ // Notify
+ //
+ this.fireItemSetChange();
+ //
+ // Return the item
+ //
+ return new ObAdviceItem(itemId);
+ }
+ if (itemId instanceof AttributeAssignmentExpressionType) {
+ //
+ // Sanity check the parent
+ //
+ if (parent instanceof ObligationExpressionType == false) {
+ logger.error("Incorrect parent type: " + parent.getClass().getCanonicalName());
+ return null;
+ }
+ //
+ // Does the parent object exist?
+ //
+ if (((ObligationExpressionsType)this.root).getObligationExpression().contains(parent) == false) {
+ //
+ // This is a new obligation
+ //
+ logger.info("addItem - parent not found, adding." + ((ObligationExpressionType) parent).getObligationId());
+ ((ObligationExpressionsType)this.root).getObligationExpression().add((ObligationExpressionType) parent);
+ //
+ // track it
+ //
+ this.rootObligations.add((ObligationExpressionType) parent);
+ }
+ //
+ // Check if the item needs to be added to the parent object
+ //
+ if (((ObligationExpressionType) parent).getAttributeAssignmentExpression().contains(itemId) == false) {
+ //
+ // Put the assignment into the parent
+ //
+ ((ObligationExpressionType) parent).getAttributeAssignmentExpression().add((AttributeAssignmentExpressionType) itemId);
+ //
+ // Add the contained expression
+ //
+ this.addExpression(((AttributeAssignmentExpressionType) itemId).getExpression(), (AttributeAssignmentExpressionType) itemId);
+ }
+ //
+ // track this in our map
+ //
+ this.obligationExpressions.put((AttributeAssignmentExpressionType) itemId, (ObligationExpressionType) parent);
+ //
+ // Notify
+ //
+ this.fireItemSetChange();
+ //
+ // Return the item
+ //
+ return new ObAdviceItem(itemId);
+ }
+ if (parent instanceof AttributeAssignmentExpressionType) {
+ //
+ // Does the parent object exist?
+ //
+ if (this.obligationExpressions.containsKey(parent) == false) {
+ //
+ // No - we can't add it. Need more information.
+ //
+ logger.info("addItem - parent not found, adding." + ((AttributeAssignmentExpressionType) parent).getAttributeId());
+ return null;
+ }
+ if (itemId instanceof AttributeValueType) {
+ this.values.put((AttributeValueType) itemId, (AttributeAssignmentExpressionType) parent);
+ } else if (itemId instanceof AttributeDesignatorType) {
+ this.designators.put((AttributeDesignatorType) itemId, (AttributeAssignmentExpressionType) parent);
+ } else if (itemId instanceof AttributeSelectorType) {
+ this.selectors.put((AttributeSelectorType) itemId, (AttributeAssignmentExpressionType) parent);
+ } else if (itemId instanceof ApplyType) {
+ this.applys.put((ApplyType) itemId, (AttributeAssignmentExpressionType) parent);
+ } else {
+ logger.error("Should not get here. The object was checked in the beginning of the function. Someone removed or altered that check.");
+ assert false;
+ return null;
+ }
+ //
+ // Notify
+ //
+ this.fireItemSetChange();
+ //
+ // Return the item
+ //
+ return new ObAdviceItem(itemId);
+ }
+ } else if (this.root instanceof AdviceExpressionsType) {
+ //
+ // Are we adding new root advice expression?
+ //
+ if (itemId instanceof AdviceExpressionType) {
+ //
+ // Adding a new root obligation expression, is it already in the parent.
+ //
+ if (((AdviceExpressionsType)this.root).getAdviceExpression().contains(itemId) == false) {
+ //
+ // No - add it in
+ //
+ ((AdviceExpressionsType)this.root).getAdviceExpression().add((AdviceExpressionType) itemId);
+ }
+ //
+ // Track this object
+ //
+ this.rootAdvice.add((AdviceExpressionType) itemId);
+ //
+ // Notify
+ //
+ this.fireItemSetChange();
+ //
+ // Return the new item
+ //
+ return new ObAdviceItem(itemId);
+ }
+ if (itemId instanceof AttributeAssignmentExpressionType) {
+ //
+ // Sanity check
+ //
+ if (parent instanceof AdviceExpressionType == false) {
+ logger.error("Incorrect parent type: " + parent.getClass().getCanonicalName());
+ return null;
+ }
+ //
+ // Does the parent object exist?
+ //
+ if (((AdviceExpressionsType)this.root).getAdviceExpression().contains(parent) == false) {
+ //
+ // This is a new obligation
+ //
+ logger.info("addItem - parent not found, adding." + ((AdviceExpressionType) parent).getAdviceId());
+ ((AdviceExpressionsType)this.root).getAdviceExpression().add((AdviceExpressionType) parent);
+ //
+ // Track it
+ //
+ this.rootAdvice.add((AdviceExpressionType) parent);
+ }
+ //
+ // Check if the item needs to be added to the parent object
+ //
+ if (((AdviceExpressionType) parent).getAttributeAssignmentExpression().contains(itemId) == false) {
+ //
+ // Put the assignment into the parent
+ //
+ ((AdviceExpressionType) parent).getAttributeAssignmentExpression().add((AttributeAssignmentExpressionType) itemId);
+ //
+ // Add the contained expression
+ //
+ this.addExpression(((AttributeAssignmentExpressionType) itemId).getExpression(), (AttributeAssignmentExpressionType) itemId);
+ }
+ //
+ // track this in our map
+ //
+ this.adviceExpressions.put((AttributeAssignmentExpressionType) itemId, (AdviceExpressionType) parent);
+ //
+ // Notify
+ //
+ this.fireItemSetChange();
+ //
+ // Return the item
+ //
+ return new ObAdviceItem(itemId);
+ }
+ if (parent instanceof AttributeAssignmentExpressionType) {
+ //
+ // Does the parent object exist?
+ //
+ if (this.adviceExpressions.containsKey(parent) == false) {
+ //
+ // No - we can't add it. Need more information.
+ //
+ logger.info("addItem - parent not found, adding." + ((AttributeAssignmentExpressionType) parent).getAttributeId());
+ return null;
+ }
+ if (itemId instanceof AttributeValueType) {
+ this.values.put((AttributeValueType) itemId, (AttributeAssignmentExpressionType) parent);
+ } else if (itemId instanceof AttributeDesignatorType) {
+ this.designators.put((AttributeDesignatorType) itemId, (AttributeAssignmentExpressionType) parent);
+ } else if (itemId instanceof AttributeSelectorType) {
+ this.selectors.put((AttributeSelectorType) itemId, (AttributeAssignmentExpressionType) parent);
+ } else if (itemId instanceof ApplyType) {
+ this.applys.put((ApplyType) itemId, (AttributeAssignmentExpressionType) parent);
+ } else {
+ logger.error("Should not get here. Someone altered the object supported check or removed the code.");
+ assert false;
+ return null;
+ }
+ //
+ // Notify
+ //
+ this.fireItemSetChange();
+ //
+ // Return new item
+ //
+ return new ObAdviceItem(itemId);
+ }
+ } else {
+ //
+ // We should not ever get here.
+ //
+ logger.error("The root object is incorrect.");
+ return null;
+ }
+ logger.error("Unsupported combination of itemId and parent classes.");
+ return null;
+ }
+
+ @Override
+ public boolean addContainerProperty(Object propertyId, Class<?> type,
+ Object defaultValue) throws UnsupportedOperationException {
+ return false;
+ }
+
+ @Override
+ public boolean removeContainerProperty(Object propertyId)
+ throws UnsupportedOperationException {
+ return false;
+ }
+
+ public boolean removeAllAssignments () {
+ if (logger.isTraceEnabled()) {
+ logger.trace("removeAllAssignments:");
+ }
+ if (this.root instanceof ObligationExpressionsType) {
+ ((ObligationExpressionsType)this.root).getObligationExpression().clear();
+ this.obligationExpressions.clear();
+ } else if (this.root instanceof AdviceExpressionsType) {
+ ((AdviceExpressionsType)this.root).getAdviceExpression().clear();
+ this.adviceExpressions.clear();
+ }
+ this.values.clear();
+ this.designators.clear();
+ this.selectors.clear();
+ this.applys.clear();
+ //
+ // Notify
+ //
+ this.fireItemSetChange();
+ return true;
+ }
+
+ @Override
+ public boolean removeAllItems() throws UnsupportedOperationException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("removeAllItems:");
+ }
+ if (this.root instanceof ObligationExpressionsType) {
+ ((ObligationExpressionsType)this.root).getObligationExpression().clear();
+ this.rootObligations.clear();
+ this.obligationExpressions.clear();
+ } else if (this.root instanceof AdviceExpressionsType) {
+ ((AdviceExpressionsType)this.root).getAdviceExpression().clear();
+ this.rootAdvice.clear();
+ this.adviceExpressions.clear();
+ }
+ this.values.clear();
+ this.designators.clear();
+ this.selectors.clear();
+ this.applys.clear();
+ //
+ // Notify
+ //
+ this.fireItemSetChange();
+ return true;
+ }
+
+ @Override
+ public Collection<?> getChildren(Object itemId) {
+ final Collection<Object> items = new ArrayList<Object>();
+ if (itemId instanceof AdviceExpressionType) {
+ if (this.rootAdvice.contains(itemId)) {
+ items.addAll(((AdviceExpressionType) itemId).getAttributeAssignmentExpression());
+ } else {
+ logger.error("getChildren: itemId not in root advice expression " + ((AdviceExpressionType) itemId).getAdviceId());
+ }
+ }
+ if (itemId instanceof ObligationExpressionType) {
+ if (this.rootObligations.contains(itemId)) {
+ items.addAll(((ObligationExpressionType) itemId).getAttributeAssignmentExpression());
+ } else {
+ logger.error("getChildren: itemId not in root obligation expression " + ((ObligationExpressionType) itemId).getObligationId());
+ }
+ }
+ if (itemId instanceof AttributeAssignmentExpressionType) {
+ if (this.root instanceof ObligationExpressionsType) {
+ if (this.obligationExpressions.containsKey(itemId)) {
+ JAXBElement<?> element = ((AttributeAssignmentExpressionType) itemId).getExpression();
+ if (element != null && element.getValue() != null) {
+ items.add(element.getValue());
+ }
+ } else {
+ logger.error("getChildren: itemId not in obligation expressions " + ((AttributeAssignmentExpressionType) itemId).getAttributeId());
+ }
+ } else if (this.root instanceof AdviceExpressionsType) {
+ if (this.adviceExpressions.containsKey(itemId)) {
+ JAXBElement<?> element = ((AttributeAssignmentExpressionType) itemId).getExpression();
+ if (element != null && element.getValue() != null) {
+ items.add(element.getValue());
+ }
+ } else {
+ logger.error("getChildren: itemId not in advice expressions " + ((AttributeAssignmentExpressionType) itemId).getAttributeId());
+ }
+ }
+ }
+ if (logger.isTraceEnabled()) {
+ logger.trace("getChildren " + itemId + "(" + items.size() + "):" + items);
+ }
+ return Collections.unmodifiableCollection(items);
+ }
+
+ @Override
+ public Object getParent(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getParent: " + itemId);
+ }
+ assert itemId != null;
+ if (itemId instanceof AdviceExpressionType) {
+ if (this.root instanceof AdviceExpressionsType) {
+ return this.root;
+ }
+ return null;
+ }
+ if (itemId instanceof ObligationExpressionType) {
+ if (this.root instanceof ObligationExpressionsType) {
+ return this.root;
+ }
+ return null;
+ }
+ if (itemId instanceof AttributeAssignmentExpressionType) {
+ if (this.root instanceof ObligationExpressionsType) {
+ return this.obligationExpressions.get(itemId);
+ } else if (this.root instanceof AdviceExpressionsType) {
+ return this.adviceExpressions.get(itemId);
+ }
+ }
+ if (itemId instanceof AttributeValueType) {
+ return this.values.get(itemId);
+ }
+ if (itemId instanceof AttributeDesignatorType) {
+ return this.designators.get(itemId);
+ }
+ if (itemId instanceof AttributeSelectorType) {
+ return this.selectors.get(itemId);
+ }
+ if (itemId instanceof ApplyType) {
+ return this.applys.get(itemId);
+ }
+ return null;
+ }
+
+ @Override
+ public Collection<?> rootItemIds() {
+ final Collection<Object> items = new ArrayList<Object>();
+ if (this.root instanceof ObligationExpressionsType) {
+ items.addAll(this.rootObligations);
+ } else if (this.root instanceof AdviceExpressionsType) {
+ items.addAll(this.rootAdvice);
+ }
+ if (logger.isTraceEnabled()) {
+ logger.trace("rootItemIds (" + items.size() + "):" + items);
+ }
+ return Collections.unmodifiableCollection(items);
+ }
+
+ @Override
+ public boolean setParent(Object itemId, Object newParentId) throws UnsupportedOperationException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("setParent: " + itemId);
+ }
+ if (itemId instanceof AdviceExpressionType) {
+ return false;
+ }
+ if (itemId instanceof ObligationExpressionType) {
+ return false;
+ }
+ if (itemId instanceof AttributeAssignmentExpressionType) {
+ if (this.root instanceof ObligationExpressionsType && newParentId instanceof ObligationExpressionType) {
+ //
+ // Remove it from its parent object
+ //
+ ObligationExpressionType oldParent = this.obligationExpressions.get(itemId);
+ if (oldParent.getAttributeAssignmentExpression().remove(itemId)) {
+ //
+ // See if its in the new parent
+ //
+ if (((ObligationExpressionType) newParentId).getAttributeAssignmentExpression().contains(itemId) == false) {
+ //
+ // Nope, add it in
+ //
+ ((ObligationExpressionType) newParentId).getAttributeAssignmentExpression().add((AttributeAssignmentExpressionType) itemId);
+ }
+ //
+ // Update our tracking
+ //
+ this.obligationExpressions.put((AttributeAssignmentExpressionType) itemId, (ObligationExpressionType) newParentId);
+ //
+ // Fire
+ //
+ this.fireItemSetChange();
+ return true;
+ }
+ } else if (this.root instanceof AdviceExpressionsType) {
+ //
+ // Remove it from its parent object
+ //
+ AdviceExpressionType oldParent = this.adviceExpressions.get(itemId);
+ if (oldParent.getAttributeAssignmentExpression().remove(itemId)) {
+ //
+ // See if its in the new parent
+ //
+ if (((AdviceExpressionType) newParentId).getAttributeAssignmentExpression().contains(itemId) == false) {
+ //
+ // Nope, add it in
+ //
+ ((AdviceExpressionType) newParentId).getAttributeAssignmentExpression().add((AttributeAssignmentExpressionType) itemId);
+ }
+ //
+ // Update our tracking
+ //
+ this.adviceExpressions.put((AttributeAssignmentExpressionType) itemId, (AdviceExpressionType) newParentId);
+ //
+ // Fire
+ //
+ this.fireItemSetChange();
+ return true;
+ }
+ }
+ return false;
+ }
+ if (itemId instanceof AttributeValueType && newParentId instanceof AttributeAssignmentExpressionType) {
+ AttributeAssignmentExpressionType oldParent = this.values.get(itemId);
+ if (oldParent != null &&
+ oldParent.getExpression() != null &&
+ oldParent.getExpression().getValue() != null &&
+ oldParent.getExpression().getValue() == itemId) {
+ //
+ // Remove from old parent
+ //
+ oldParent.setExpression(null);
+ //
+ // Put in new parent
+ //
+ ((AttributeAssignmentExpressionType) newParentId).setExpression(new ObjectFactory().createAttributeValue((AttributeValueType) itemId));
+ //
+ // track it
+ //
+ this.values.put((AttributeValueType) itemId, (AttributeAssignmentExpressionType) newParentId);
+ //
+ // Fire
+ //
+ this.fireItemSetChange();
+ return true;
+ }
+ return false;
+ }
+ if (itemId instanceof AttributeDesignatorType && newParentId instanceof AttributeAssignmentExpressionType) {
+ AttributeAssignmentExpressionType oldParent = this.designators.get(itemId);
+ if (oldParent != null &&
+ oldParent.getExpression() != null &&
+ oldParent.getExpression().getValue() != null &&
+ oldParent.getExpression().getValue() == itemId) {
+ //
+ // Remove from old parent
+ //
+ oldParent.setExpression(null);
+ //
+ // Put in new parent
+ //
+ ((AttributeAssignmentExpressionType) newParentId).setExpression(new ObjectFactory().createAttributeDesignator((AttributeDesignatorType) itemId));
+ //
+ // track it
+ //
+ this.designators.put((AttributeDesignatorType) itemId, (AttributeAssignmentExpressionType) newParentId);
+ //
+ // Fire
+ //
+ this.fireItemSetChange();
+ return true;
+ }
+ return false;
+ }
+ if (itemId instanceof AttributeSelectorType && newParentId instanceof AttributeAssignmentExpressionType) {
+ AttributeAssignmentExpressionType oldParent = this.selectors.get(itemId);
+ if (oldParent != null &&
+ oldParent.getExpression() != null &&
+ oldParent.getExpression().getValue() != null &&
+ oldParent.getExpression().getValue() == itemId) {
+ //
+ // Remove from old parent
+ //
+ oldParent.setExpression(null);
+ //
+ // Put in new parent
+ //
+ ((AttributeAssignmentExpressionType) newParentId).setExpression(new ObjectFactory().createAttributeSelector((AttributeSelectorType) itemId));
+ //
+ // track it
+ //
+ this.selectors.put((AttributeSelectorType) itemId, (AttributeAssignmentExpressionType) newParentId);
+ //
+ // Fire
+ //
+ this.fireItemSetChange();
+ return true;
+ }
+ return false;
+ }
+ if (itemId instanceof ApplyType && newParentId instanceof AttributeAssignmentExpressionType) {
+ AttributeAssignmentExpressionType oldParent = this.applys.get(itemId);
+ if (oldParent != null &&
+ oldParent.getExpression() != null &&
+ oldParent.getExpression().getValue() != null &&
+ oldParent.getExpression().getValue() == itemId) {
+ //
+ // Remove from old parent
+ //
+ oldParent.setExpression(null);
+ //
+ // Put in new parent
+ //
+ ((AttributeAssignmentExpressionType) newParentId).setExpression(new ObjectFactory().createApply((ApplyType) itemId));
+ //
+ // track it
+ //
+ this.applys.put((ApplyType) itemId, (AttributeAssignmentExpressionType) newParentId);
+ //
+ // Fire
+ //
+ this.fireItemSetChange();
+ return true;
+ }
+ return false;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean areChildrenAllowed(Object itemId) {
+ if (itemId instanceof AdviceExpressionType) {
+ return true;
+ }
+ if (itemId instanceof ObligationExpressionType) {
+ return true;
+ }
+ if (itemId instanceof AttributeAssignmentExpressionType) {
+ return true;
+ }
+ if (itemId instanceof AttributeValueType) {
+ return false;
+ }
+ if (itemId instanceof AttributeDesignatorType) {
+ return false;
+ }
+ if (itemId instanceof AttributeSelectorType) {
+ return false;
+ }
+ if (itemId instanceof ApplyType) {
+ return false;
+ }
+ return false;
+ }
+
+ @Override
+ public boolean setChildrenAllowed(Object itemId, boolean areChildrenAllowed) throws UnsupportedOperationException {
+ if (itemId instanceof AdviceExpressionType) {
+ return (areChildrenAllowed ? true : false);
+ }
+ if (itemId instanceof ObligationExpressionType) {
+ return (areChildrenAllowed ? true : false);
+ }
+ if (itemId instanceof AttributeAssignmentExpressionType) {
+ return (areChildrenAllowed ? true : false);
+ }
+ if (itemId instanceof AttributeValueType) {
+ return (areChildrenAllowed == false ? true : false);
+ }
+ if (itemId instanceof AttributeDesignatorType) {
+ return (areChildrenAllowed == false ? true : false);
+ }
+ if (itemId instanceof AttributeSelectorType) {
+ return (areChildrenAllowed == false ? true : false);
+ }
+ if (itemId instanceof ApplyType) {
+ return (areChildrenAllowed == false ? true : false);
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isRoot(Object itemId) {
+ if (this.root instanceof AdviceExpressionsType) {
+ return this.rootAdvice.contains(itemId);
+ } else if (this.root instanceof ObligationExpressionsType) {
+ return this.rootObligations.contains(itemId);
+ }
+ return false;
+ }
+
+ @Override
+ public boolean hasChildren(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("hasChildren: " + itemId);
+ }
+ if (itemId instanceof AdviceExpressionType && this.root instanceof AdviceExpressionsType &&
+ this.rootAdvice.contains(itemId)) {
+ return ((AdviceExpressionType) itemId).getAttributeAssignmentExpression().size() > 0;
+ }
+ if (itemId instanceof ObligationExpressionType && this.root instanceof ObligationExpressionsType &&
+ this.rootObligations.contains(itemId)) {
+ return ((ObligationExpressionType) itemId).getAttributeAssignmentExpression().size() > 0;
+ }
+ if (itemId instanceof AttributeAssignmentExpressionType) {
+ if (this.root instanceof ObligationExpressionsType) {
+ return this.obligationExpressions.size() > 0;
+ } else if (this.root instanceof AdviceExpressionsType) {
+ return this.adviceExpressions.size() > 0;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean removeItem(Object itemId) throws UnsupportedOperationException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("removeItem: " + itemId);
+ }
+ if (this.root instanceof ObligationExpressionsType) {
+ if (itemId instanceof ObligationExpressionType) {
+ if (((ObligationExpressionsType) this.root).getObligationExpression().remove(itemId)) {
+ //
+ // Remove this
+ //
+ if (this.rootObligations.remove(itemId) == false) {
+ //
+ //
+ //
+ assert false;
+ logger.error("Removing item " + itemId + " failed to remove it from root obligation list");
+ }
+ //
+ // Notify
+ //
+ this.fireItemSetChange();
+ return true ;
+ }
+ } else if (itemId instanceof AttributeAssignmentExpressionType) {
+ ObligationExpressionType parent = this.obligationExpressions.get(itemId);
+ if (parent != null && parent.getAttributeAssignmentExpression().remove(itemId)) {
+ if (this.obligationExpressions.remove(itemId) == null) {
+ assert false;
+ logger.error("Removing item " + itemId + " failed to remove it from obligation expressions map");
+ }
+ //
+ // Notify
+ //
+ this.fireItemSetChange();
+ return true;
+ }
+ }
+ } else if (this.root instanceof AdviceExpressionsType) {
+ if (itemId instanceof AdviceExpressionType) {
+ if (((AdviceExpressionsType) this.root).getAdviceExpression().remove(itemId)) {
+ if (this.rootAdvice.remove(itemId) == false) {
+ assert false;
+ logger.error("Removing item " + itemId + " failed to remove it from root advice list");
+ }
+ //
+ // Notify
+ //
+ this.fireItemSetChange();
+ return true;
+ }
+ } else if (itemId instanceof AttributeAssignmentExpressionType) {
+ AdviceExpressionType parent = this.adviceExpressions.get(itemId);
+ if (parent != null && parent.getAttributeAssignmentExpression().remove(itemId)) {
+ if (this.adviceExpressions.remove(itemId) == null) {
+ assert false;
+ logger.error("Removing item " + itemId + " failed to remove it from advice expressions map");
+ }
+ //
+ // Notify
+ //
+ this.fireItemSetChange();
+ return true;
+ }
+ }
+ }
+ if (itemId instanceof AttributeValueType) {
+ AttributeAssignmentExpressionType parent = this.values.get(itemId);
+ if (parent != null &&
+ parent.getExpression() != null &&
+ parent.getExpression().getValue() != null &&
+ parent.getExpression().getValue().equals(itemId)) {
+ parent.setExpression(null);
+ //
+ // Notify
+ //
+ this.fireItemSetChange();
+ return this.values.remove(itemId) == null;
+ }
+ }
+ if (itemId instanceof AttributeDesignatorType) {
+ AttributeAssignmentExpressionType parent = this.designators.get(itemId);
+ if (parent != null &&
+ parent.getExpression() != null &&
+ parent.getExpression().getValue() != null &&
+ parent.getExpression().getValue().equals(itemId)) {
+ parent.setExpression(null);
+ //
+ // Notify
+ //
+ this.fireItemSetChange();
+ return this.designators.remove(itemId) == null;
+ }
+ }
+ if (itemId instanceof AttributeSelectorType) {
+ AttributeAssignmentExpressionType parent = this.selectors.get(itemId);
+ if (parent != null &&
+ parent.getExpression() != null &&
+ parent.getExpression().getValue() != null &&
+ parent.getExpression().getValue().equals(itemId)) {
+ parent.setExpression(null);
+ //
+ // Notify
+ //
+ this.fireItemSetChange();
+ return this.selectors.remove(itemId) == null;
+ }
+ }
+ if (itemId instanceof ApplyType) {
+ AttributeAssignmentExpressionType parent = this.applys.get(itemId);
+ if (parent != null &&
+ parent.getExpression() != null &&
+ parent.getExpression().getValue() != null &&
+ parent.getExpression().getValue().equals(itemId)) {
+ parent.setExpression(null);
+ //
+ // Notify
+ //
+ this.fireItemSetChange();
+ return this.applys.remove(itemId) == null;
+ }
+ }
+ return false;
+ }
+
+ public class ObAdviceItem implements Item {
+ private static final long serialVersionUID = 1L;
+ private final Object data;
+
+ public ObAdviceItem(Object data) {
+ this.data = data;
+ }
+
+ public String getName() {
+ if (this.data instanceof AdviceExpressionType) {
+ return "Advice";
+ }
+ if (this.data instanceof ObligationExpressionType) {
+ return "Obligation";
+ }
+ if (this.data instanceof AttributeAssignmentExpressionType) {
+ return "Attribute Assignment Expression";
+ }
+ if (this.data instanceof AttributeValueType) {
+ return "Attribute Value";
+ }
+ if (this.data instanceof AttributeDesignatorType) {
+ return "Attribute Designator";
+ }
+ if (this.data instanceof AttributeSelectorType) {
+ return "Attribute Selector";
+ }
+ if (this.data instanceof ApplyType) {
+ return "Apply";
+ }
+ return null;
+ }
+
+ public String getId() {
+ if (this.data instanceof AdviceExpressionType) {
+ return ((AdviceExpressionType) this.data).getAdviceId();
+ }
+ if (this.data instanceof ObligationExpressionType) {
+ return ((ObligationExpressionType) this.data).getObligationId();
+ }
+ if (this.data instanceof AttributeAssignmentExpressionType) {
+ return ((AttributeAssignmentExpressionType) this.data).getAttributeId();
+ }
+ if (this.data instanceof AttributeValueType) {
+ StringBuilder builder = new StringBuilder();
+ for (Object content : ((AttributeValueType) this.data).getContent()) {
+ builder.append(content);
+ }
+ return builder.toString();
+ }
+ if (this.data instanceof AttributeDesignatorType) {
+ return ((AttributeDesignatorType) this.data).getAttributeId();
+ }
+ if (this.data instanceof AttributeSelectorType) {
+ return ((AttributeSelectorType) this.data).getContextSelectorId();
+ }
+ if (this.data instanceof ApplyType) {
+ return ((ApplyType) this.data).getFunctionId();
+ }
+ return null;
+ }
+
+ public String getIdShort() {
+ String id = this.getId();
+ if (id == null) {
+ return id;
+ }
+ if (this.data instanceof AttributeValueType) {
+ return id;
+ }
+ //
+ // Make it short
+ //
+ String[] parts = id.split("[:]");
+
+ if (parts != null && parts.length > 0) {
+ return parts[parts.length - 1];
+ }
+ return id;
+ }
+
+ public String getEffect() {
+ if (this.data instanceof AdviceExpressionType) {
+ return ((AdviceExpressionType) this.data).getAppliesTo().toString();
+ }
+ if (this.data instanceof ObligationExpressionType) {
+ return ((ObligationExpressionType) this.data).getFulfillOn().toString();
+ }
+ return null;
+ }
+
+ public String getDatatype() {
+ /*
+ if (this.data instanceof AdviceExpressionType) {
+ }
+ if (this.data instanceof ObligationExpressionType) {
+ }
+ if (this.data instanceof AttributeAssignmentExpressionType) {
+ }
+ */
+ if (this.data instanceof AttributeValueType) {
+ return ((AttributeValueType) this.data).getDataType();
+ }
+ if (this.data instanceof AttributeDesignatorType) {
+ return ((AttributeDesignatorType) this.data).getDataType();
+ }
+ if (this.data instanceof AttributeSelectorType) {
+ return ((AttributeSelectorType) this.data).getDataType();
+ }
+ /*
+ if (this.data instanceof ApplyType) {
+
+ }
+ */
+ return null;
+ }
+
+ public String getDatatypeShort() {
+ String dt = this.getDatatype();
+ if (dt == null) {
+ return dt;
+ }
+ //
+ // Get short part
+ //
+ int index = dt.lastIndexOf('#');
+ if (index == -1) {
+ String[] parts = dt.split("[:]");
+
+ if (parts != null && parts.length > 0) {
+ return parts[parts.length - 1];
+ }
+ } else {
+ return dt.substring(index + 1);
+ }
+ return dt;
+ }
+
+ public String getCategory() {
+ /*
+ if (this.data instanceof AdviceExpressionType) {
+ }
+ if (this.data instanceof ObligationExpressionType) {
+ }
+ */
+ if (this.data instanceof AttributeAssignmentExpressionType) {
+ return ((AttributeAssignmentExpressionType) this.data).getCategory();
+ }
+ /*
+ if (this.data instanceof AttributeValueType) {
+ }
+ */
+ if (this.data instanceof AttributeDesignatorType) {
+ return ((AttributeDesignatorType) this.data).getCategory();
+ }
+ if (this.data instanceof AttributeSelectorType) {
+ return ((AttributeSelectorType) this.data).getCategory();
+ }
+ /*
+ if (this.data instanceof ApplyType) {
+
+ }
+ */
+ return null;
+ }
+
+ public String getCategoryShort() {
+ String id = this.getCategory();
+ if (id == null) {
+ return id;
+ }
+ String[] parts = id.split("[:]");
+
+ if (parts != null && parts.length > 0) {
+ return parts[parts.length - 1];
+ }
+ return id;
+ }
+
+ @Override
+ public Property<?> getItemProperty(Object id) {
+ return getContainerProperty(this.data, id);
+ }
+ @Override
+ public Collection<?> getItemPropertyIds() {
+ return getContainerPropertyIds();
+ }
+ @Override
+ public boolean addItemProperty(Object id, @SuppressWarnings("rawtypes") Property property) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Expression container does not support adding new properties");
+ }
+ @Override
+ public boolean removeItemProperty(Object id) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Expression container does not support removing properties");
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/PDPContainer.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/PDPContainer.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/PDPContainer.java
new file mode 100644
index 0000000..5b9f3f5
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/PDPContainer.java
@@ -0,0 +1,488 @@
+/*
+ * 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.xacml.admin.model;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.api.pap.PAPEngine;
+import org.apache.openaz.xacml.api.pap.PDP;
+import org.apache.openaz.xacml.api.pap.PDPGroup;
+import org.apache.openaz.xacml.api.pap.PDPPIPConfig;
+import org.apache.openaz.xacml.api.pap.PDPPolicy;
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.util.MethodProperty;
+import com.vaadin.server.Resource;
+
+public class PDPContainer extends ItemSetChangeNotifier implements Container.Indexed, Container.ItemSetChangeNotifier {
+ private static final long serialVersionUID = 1L;
+ private static Log logger = LogFactory.getLog(PDPGroupContainer.class);
+
+ /**
+ * String identifier of a file's "Id" property.
+ */
+ public static String PROPERTY_ID = "Id";
+
+ /**
+ * String identifier of a file's "name" property.
+ */
+ public static String PROPERTY_NAME = "Name";
+
+ /**
+ * String identifier of a file's "Description" property.
+ */
+ public static String PROPERTY_DESCRIPTION = "Description";
+
+ /**
+ * String identifier of a file's "Default" property.
+ */
+ public static String PROPERTY_DEFAULT = "Default";
+
+ /**
+ * String identifier of a file's "icon" property.
+ */
+ public static String PROPERTY_ICON = "Icon";
+
+ /**
+ * String identifier of a file's "Status" property.
+ */
+ public static String PROPERTY_STATUS = "Status";
+
+ /**
+ * String identifier of a file's "Status" property.
+ */
+ public static String PROPERTY_PDPS = "PDPs";
+
+ /**
+ * String identifier of a file's "Status" property.
+ */
+ public static String PROPERTY_POLICIES = "Policies";
+
+ /**
+ * String identifier of a file's "Status" property.
+ */
+ public static String PROPERTY_PIPCONFIG = "PIP Configurations";
+
+ /**
+ * List of the string identifiers for the available properties.
+ */
+ public static Collection<String> PDP_PROPERTIES;
+
+ private final static Method PDPITEM_ID;
+
+ private final static Method PDPITEM_NAME;
+
+ private final static Method PDPITEM_DESCRIPTION;
+
+ private final static Method PDPITEM_ICON;
+
+ private final static Method PDPITEM_STATUS;
+
+ private final static Method PDPITEM_POLICIES;
+
+ private final static Method PDPITEM_PIPCONFIG;
+
+
+ static {
+ PDP_PROPERTIES = new ArrayList<String>();
+ PDP_PROPERTIES.add(PROPERTY_ID);
+ PDP_PROPERTIES.add(PROPERTY_NAME);
+ PDP_PROPERTIES.add(PROPERTY_DESCRIPTION);
+ PDP_PROPERTIES.add(PROPERTY_DEFAULT);
+ PDP_PROPERTIES.add(PROPERTY_ICON);
+ PDP_PROPERTIES.add(PROPERTY_STATUS);
+ PDP_PROPERTIES.add(PROPERTY_PDPS);
+ PDP_PROPERTIES.add(PROPERTY_POLICIES);
+ PDP_PROPERTIES.add(PROPERTY_PIPCONFIG);
+ PDP_PROPERTIES = Collections.unmodifiableCollection(PDP_PROPERTIES);
+ try {
+ PDPITEM_ID = PDPItem.class.getMethod("getId", new Class[]{});
+ PDPITEM_NAME = PDPItem.class.getMethod("getName", new Class[]{});
+ PDPITEM_DESCRIPTION = PDPItem.class.getMethod("getDescription", new Class[] {});
+ PDPITEM_ICON = PDPItem.class.getMethod("getIcon", new Class[] {});
+ PDPITEM_STATUS = PDPItem.class.getMethod("getStatus", new Class[] {});
+ PDPITEM_POLICIES = PDPItem.class.getMethod("getPolicies", new Class[] {});
+ PDPITEM_PIPCONFIG = PDPItem.class.getMethod("getPipConfigs", new Class[] {});
+ } catch (final NoSuchMethodException e) {
+ throw new RuntimeException(
+ "Internal error finding methods in PDPContainer");
+ }
+ }
+
+ private PAPEngine papEngine = null; //NOPMD
+ private PDPGroup group;
+ private List<PDP> pdps = Collections.synchronizedList(new ArrayList<PDP>());
+
+ public PDPContainer(PDPGroup group) {
+ super();
+ this.setContainer(this);
+ //
+ //
+ //
+ this.group = group;
+ this.pdps.addAll(this.group.getPdps());
+ }
+
+ public synchronized void refresh(PDPGroup group) {
+ synchronized(this.group) {
+ this.group = group;
+ }
+ synchronized (this.pdps) {
+ this.pdps.clear();
+ this.pdps.addAll(this.group.getPdps());
+ }
+ }
+
+ @Override
+ public Object nextItemId(Object itemId) {
+ synchronized (this.pdps) {
+ int index = this.pdps.indexOf(itemId);
+ if (index == -1) {
+ return null;
+ }
+ if (index == this.pdps.size() - 1) {
+ return null;
+ }
+ return this.pdps.get(index + 1);
+ }
+ }
+
+ @Override
+ public Object prevItemId(Object itemId) {
+ synchronized (this.pdps) {
+ int index = this.pdps.indexOf(itemId);
+ if (index == -1) {
+ return null;
+ }
+ if (index == 0) {
+ return null;
+ }
+ return this.pdps.get(index - 1);
+ }
+ }
+
+ @Override
+ public Object firstItemId() {
+ synchronized (this.pdps) {
+ if (this.pdps.size() > 0) {
+ return this.pdps.get(0);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Object lastItemId() {
+ synchronized (this.pdps) {
+ if (this.pdps.size() > 0) {
+ return this.pdps.get(this.pdps.size() - 1);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public boolean isFirstId(Object itemId) {
+ synchronized (this.pdps) {
+ if (this.pdps.size() > 0) {
+ return this.pdps.get(0).equals(itemId);
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isLastId(Object itemId) {
+ synchronized (this.pdps) {
+ if (this.pdps.size() > 0) {
+ return this.pdps.get(this.pdps.size() - 1).equals(itemId);
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public Object addItemAfter(Object previousItemId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Use addPDP method");
+ }
+
+ @Override
+ public Item addItemAfter(Object previousItemId, Object newItemId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Use addPDP method");
+ }
+
+ @Override
+ public Item getItem(Object itemId) {
+ /*
+ if (itemId instanceof PDP) {
+ }
+ */
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Collection<?> getContainerPropertyIds() {
+ return PDP_PROPERTIES;
+ }
+
+ @Override
+ public Collection<?> getItemIds() {
+ synchronized(this.pdps) {
+ return Collections.unmodifiableList(this.pdps);
+ }
+ }
+
+ @Override
+ public Property<?> getContainerProperty(Object itemId, Object propertyId) {
+ if (propertyId.equals(PROPERTY_ID)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPItem((PDP) itemId), PDPITEM_ID, null);
+ }
+
+ if (propertyId.equals(PROPERTY_NAME)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPItem((PDP) itemId), PDPITEM_NAME, null);
+ }
+
+ if (propertyId.equals(PROPERTY_DESCRIPTION)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPItem((PDP) itemId), PDPITEM_DESCRIPTION, null);
+ }
+
+ if (propertyId.equals(PROPERTY_ICON)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPItem((PDP) itemId), PDPITEM_ICON, null);
+ }
+
+ if (propertyId.equals(PROPERTY_STATUS)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPItem((PDP) itemId), PDPITEM_STATUS, null);
+ }
+
+ if (propertyId.equals(PROPERTY_POLICIES)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPItem((PDP) itemId), PDPITEM_POLICIES, null);
+ }
+
+ if (propertyId.equals(PROPERTY_PIPCONFIG)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPItem((PDP) itemId), PDPITEM_PIPCONFIG, null);
+ }
+
+ return null;
+ }
+
+ @Override
+ public Class<?> getType(Object propertyId) {
+ if (propertyId.equals(PROPERTY_ID)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_NAME)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_DESCRIPTION)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_ICON)) {
+ return Resource.class;
+ }
+ if (propertyId.equals(PROPERTY_STATUS)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_POLICIES)) {
+ return Set.class;
+ }
+ if (propertyId.equals(PROPERTY_PIPCONFIG)) {
+ return Set.class;
+ }
+ return null;
+ }
+
+ @Override
+ public int size() {
+ return this.pdps.size();
+ }
+
+ @Override
+ public boolean containsId(Object itemId) {
+ return this.pdps.contains(itemId);
+ }
+
+ @Override
+ public Item addItem(Object itemId) throws UnsupportedOperationException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object addItem() throws UnsupportedOperationException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public boolean removeItem(Object itemId) throws UnsupportedOperationException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot add a property");
+ }
+
+ @Override
+ public boolean removeContainerProperty(Object propertyId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot remove a property");
+ }
+
+ @Override
+ public boolean removeAllItems() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot remove all items.");
+ }
+
+ @Override
+ public int indexOfId(Object itemId) {
+ return this.pdps.indexOf(itemId);
+ }
+
+ @Override
+ public Object getIdByIndex(int index) {
+ return this.pdps.get(index);
+ }
+
+ @Override
+ public List<?> getItemIds(int startIndex, int numberOfItems) {
+ synchronized (this.pdps) {
+ int endIndex = startIndex + numberOfItems;
+ if (endIndex > this.pdps.size()) {
+ endIndex = this.pdps.size() - 1;
+ }
+ return this.pdps.subList(startIndex, endIndex);
+ }
+ }
+
+ @Override
+ public Object addItemAt(int index) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot add item.");
+ }
+
+ @Override
+ public Item addItemAt(int index, Object newItemId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot add item.");
+ }
+
+ public class PDPItem implements Item {
+ private static final long serialVersionUID = 1L;
+ private final PDP pdp;
+
+ public PDPItem(PDP pdp) {
+ this.pdp = pdp;
+ }
+
+ public String getId() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getId: " + this.pdp);
+ }
+ return this.pdp.getId();
+ }
+
+ public String getName() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getName: " + this.pdp);
+ }
+ return this.pdp.getName();
+ }
+
+ public String getDescription() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getDescription: " + this.pdp);
+ }
+ return this.pdp.getDescription();
+ }
+
+ public Resource getIcon() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getIcon: " + this.pdp);
+ }
+ return null;
+ }
+
+ public String getStatus() {
+ String status = this.pdp.getStatus().getStatus().toString();
+ Set<String> errors = this.pdp.getStatus().getLoadErrors();
+ if (errors.size() > 0) {
+ status = status + String.format(" %d errors", errors.size());
+ }
+ Set<String> warnings = this.pdp.getStatus().getLoadWarnings();
+ if (warnings.size() > 0) {
+ status = status + String.format(" %d warnings", warnings.size());
+ }
+ return status;
+ }
+
+ public Set<PDPPolicy> getPolicies() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getPolicies: " + this.pdp);
+ }
+ return this.pdp.getPolicies();
+ }
+
+ public Set<PDPPIPConfig> getPipConfigs() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getPIPConfigs: " + this.pdp);
+ }
+ return this.pdp.getPipConfigs();
+ }
+
+ @Override
+ public Property<?> getItemProperty(Object id) {
+ return getContainerProperty(this.pdp, id);
+ }
+
+ @Override
+ public Collection<?> getItemPropertyIds() {
+ return getContainerPropertyIds();
+ }
+
+ @Override
+ public boolean addItemProperty(Object id, @SuppressWarnings("rawtypes") Property property) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("PDP container does not support adding new properties");
+ }
+
+ @Override
+ public boolean removeItemProperty(Object id)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException(
+ "PDP container does not support property removal");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/PDPGroupContainer.java
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/PDPGroupContainer.java b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/PDPGroupContainer.java
new file mode 100644
index 0000000..12b9852
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/main/java/org/apache/openaz/xacml/admin/model/PDPGroupContainer.java
@@ -0,0 +1,672 @@
+/*
+ * 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.xacml.admin.model;
+
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.openaz.xacml.api.pap.PAPEngine;
+import org.apache.openaz.xacml.api.pap.PAPException;
+import org.apache.openaz.xacml.api.pap.PDP;
+import org.apache.openaz.xacml.api.pap.PDPGroup;
+import org.apache.openaz.xacml.api.pap.PDPPIPConfig;
+import org.apache.openaz.xacml.api.pap.PDPPolicy;
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property;
+import com.vaadin.data.util.MethodProperty;
+import com.vaadin.server.Resource;
+
+public class PDPGroupContainer extends ItemSetChangeNotifier implements Container.Indexed, Container.ItemSetChangeNotifier {
+ private static final long serialVersionUID = 1L;
+ private static Log logger = LogFactory.getLog(PDPGroupContainer.class);
+
+ /**
+ * String identifier of a file's "Id" property.
+ */
+ public static String PROPERTY_ID = "Id";
+
+ /**
+ * String identifier of a file's "name" property.
+ */
+ public static String PROPERTY_NAME = "Name";
+
+ /**
+ * String identifier of a file's "Description" property.
+ */
+ public static String PROPERTY_DESCRIPTION = "Description";
+
+ /**
+ * String identifier of a file's "Default" property.
+ */
+ public static String PROPERTY_DEFAULT = "Default";
+
+ /**
+ * String identifier of a file's "icon" property.
+ */
+ public static String PROPERTY_ICON = "Icon";
+
+ /**
+ * String identifier of a file's "Status" property.
+ */
+ public static String PROPERTY_STATUS = "Status";
+
+ /**
+ * String identifier of a file's "Status" property.
+ */
+ public static String PROPERTY_PDPS = "PDPs";
+
+ /**
+ * String identifier of a file's "Status" property.
+ */
+ public static String PROPERTY_POLICIES = "Policies";
+
+ /**
+ * String identifier of a file's "Status" property.
+ */
+ public static String PROPERTY_PIPCONFIG = "PIP Configurations";
+
+ /**
+ * List of the string identifiers for the available properties.
+ */
+ public static Collection<String> PDP_PROPERTIES;
+
+ private final static Method PDPITEM_ID;
+
+ private final static Method PDPITEM_NAME;
+
+ private final static Method PDPITEM_DESCRIPTION;
+
+ private final static Method PDPITEM_DEFAULT;
+
+ private final static Method PDPITEM_ICON;
+
+ private final static Method PDPITEM_STATUS;
+
+ private final static Method PDPITEM_PDPS;
+
+ private final static Method PDPITEM_POLICIES;
+
+ private final static Method PDPITEM_PIPCONFIG;
+
+
+ static {
+ PDP_PROPERTIES = new ArrayList<String>();
+ PDP_PROPERTIES.add(PROPERTY_ID);
+ PDP_PROPERTIES.add(PROPERTY_NAME);
+ PDP_PROPERTIES.add(PROPERTY_DESCRIPTION);
+ PDP_PROPERTIES.add(PROPERTY_DEFAULT);
+ PDP_PROPERTIES.add(PROPERTY_ICON);
+ PDP_PROPERTIES.add(PROPERTY_STATUS);
+ PDP_PROPERTIES.add(PROPERTY_PDPS);
+ PDP_PROPERTIES.add(PROPERTY_POLICIES);
+ PDP_PROPERTIES.add(PROPERTY_PIPCONFIG);
+ PDP_PROPERTIES = Collections.unmodifiableCollection(PDP_PROPERTIES);
+ try {
+ PDPITEM_ID = PDPGroupItem.class.getMethod("getId", new Class[]{});
+ PDPITEM_NAME = PDPGroupItem.class.getMethod("getName", new Class[]{});
+ PDPITEM_DESCRIPTION = PDPGroupItem.class.getMethod("getDescription", new Class[] {});
+ PDPITEM_DEFAULT = PDPGroupItem.class.getMethod("getDefault", new Class[] {});
+ PDPITEM_ICON = PDPGroupItem.class.getMethod("getIcon", new Class[] {});
+ PDPITEM_STATUS = PDPGroupItem.class.getMethod("getStatus", new Class[] {});
+ PDPITEM_PDPS = PDPGroupItem.class.getMethod("getPDPs", new Class[] {});
+ PDPITEM_POLICIES = PDPGroupItem.class.getMethod("getPolicies", new Class[] {});
+ PDPITEM_PIPCONFIG = PDPGroupItem.class.getMethod("getPipConfigs", new Class[] {});
+ } catch (final NoSuchMethodException e) {
+ throw new RuntimeException(
+ "Internal error finding methods in PDPContainer");
+ }
+ }
+
+ private PAPEngine papEngine = null;
+ private List<PDPGroup> groups = Collections.synchronizedList(new ArrayList<PDPGroup>());
+
+ public PDPGroupContainer(PAPEngine engine) {
+ super();
+ this.setContainer(this);
+ //
+ //
+ //
+ this.papEngine = engine;
+ //
+ //
+ //
+ this.refreshGroups();
+ }
+
+ public boolean isSupported(Object itemId) {
+ if (itemId instanceof PDPGroup) {
+ return true;
+ }
+ return false;
+ }
+
+ public synchronized void refreshGroups() {
+ synchronized(this.groups) {
+ this.groups.clear();
+ try {
+ this.groups.addAll(this.papEngine.getPDPGroups());
+ } catch (PAPException e) {
+ String message = "Unable to retrieve Groups from server: " + e;
+ logger.error(message, e);
+ }
+ }
+ //
+ // Notify that we have changed
+ //
+ this.fireItemSetChange();
+ }
+
+ public List<PDPGroup> getGroups() {
+ return Collections.unmodifiableList(this.groups);
+ }
+
+ public void makeDefault(PDPGroup group) {
+ try {
+ this.papEngine.SetDefaultGroup(group);
+ } catch (PAPException e) {
+ String message = "Unable to set Default Group on server: " + e;
+ logger.error(message, e);
+ }
+ }
+
+ public void removeGroup(PDPGroup group, PDPGroup newGroup) throws PAPException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("removeGroup: " + group + " new group for PDPs: " + newGroup);
+ }
+ if (group.isDefaultGroup()) {
+ throw new UnsupportedOperationException("You can't remove the Default Group.");
+ }
+ try {
+ this.papEngine.removeGroup(group, newGroup);
+ } catch (NullPointerException | PAPException e) {
+ logger.error("Failed to removeGroup " + group.getId(), e);
+ throw new PAPException("Failed to remove group '" + group.getId()+ "'", e);
+ }
+ }
+
+ public void removePDP(PDP pdp, PDPGroup group) throws PAPException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("removePDP: " + pdp + " from group: " + group);
+ }
+ try {
+ this.papEngine.removePDP(pdp);
+ } catch (PAPException e) {
+ logger.error("Failed to removePDP " + pdp.getId(), e);
+ throw new PAPException("Failed to remove pdp '" + pdp.getId()+ "'", e);
+ }
+ }
+
+ public void updatePDP(PDP pdp) {
+ try {
+ papEngine.updatePDP(pdp);
+ } catch (PAPException e) {
+ logger.error(e);
+ }
+ }
+
+ public void updateGroup(PDPGroup group) {
+ try {
+ papEngine.updateGroup(group);
+ } catch (PAPException e) {
+ logger.error(e);
+ }
+ }
+
+ @Override
+ public Item getItem(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getItem: " + itemId);
+ }
+ if (this.isSupported(itemId)) {
+ return new PDPGroupItem((PDPGroup) itemId);
+ }
+ return null;
+ }
+
+ @Override
+ public Collection<?> getContainerPropertyIds() {
+ return PDP_PROPERTIES;
+ }
+
+ @Override
+ public Collection<?> getItemIds() {
+ final Collection<Object> items = new ArrayList<Object>();
+ items.addAll(this.groups);
+ if (logger.isTraceEnabled()) {
+ logger.trace("getItemIds: " + items);
+ }
+ return Collections.unmodifiableCollection(items);
+ }
+
+ @Override
+ public Property<?> getContainerProperty(Object itemId, Object propertyId) {
+
+ if (propertyId.equals(PROPERTY_ID)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPGroupItem((PDPGroup) itemId), PDPITEM_ID, null);
+ }
+
+ if (propertyId.equals(PROPERTY_NAME)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPGroupItem((PDPGroup) itemId), PDPITEM_NAME, null);
+ }
+
+ if (propertyId.equals(PROPERTY_DESCRIPTION)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPGroupItem((PDPGroup) itemId), PDPITEM_DESCRIPTION, null);
+ }
+
+ if (propertyId.equals(PROPERTY_DEFAULT)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPGroupItem((PDPGroup) itemId), PDPITEM_DEFAULT, null);
+ }
+
+ if (propertyId.equals(PROPERTY_ICON)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPGroupItem((PDPGroup) itemId), PDPITEM_ICON, null);
+ }
+
+ if (propertyId.equals(PROPERTY_STATUS)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPGroupItem((PDPGroup) itemId), PDPITEM_STATUS, null);
+ }
+
+ if (propertyId.equals(PROPERTY_PDPS)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPGroupItem((PDPGroup) itemId), PDPITEM_PDPS, null);
+ }
+
+ if (propertyId.equals(PROPERTY_POLICIES)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPGroupItem((PDPGroup) itemId), PDPITEM_POLICIES, null);
+ }
+
+ if (propertyId.equals(PROPERTY_PIPCONFIG)) {
+ return new MethodProperty<Object>(getType(propertyId),
+ new PDPGroupItem((PDPGroup) itemId), PDPITEM_PIPCONFIG, null);
+ }
+
+ return null;
+ }
+
+ @Override
+ public Class<?> getType(Object propertyId) {
+ if (propertyId.equals(PROPERTY_ID)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_NAME)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_DESCRIPTION)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_DEFAULT)) {
+ return Boolean.class;
+ }
+ if (propertyId.equals(PROPERTY_ICON)) {
+ return Resource.class;
+ }
+ if (propertyId.equals(PROPERTY_STATUS)) {
+ return String.class;
+ }
+ if (propertyId.equals(PROPERTY_PDPS)) {
+ return Set.class;
+ }
+ if (propertyId.equals(PROPERTY_POLICIES)) {
+ return Set.class;
+ }
+ if (propertyId.equals(PROPERTY_PIPCONFIG)) {
+ return Set.class;
+ }
+ return null;
+ }
+
+ @Override
+ public int size() {
+ return this.groups.size();
+ }
+
+ @Override
+ public boolean containsId(Object itemId) {
+ if (logger.isTraceEnabled()) {
+ logger.trace("containsId: " + itemId);
+ }
+ if (this.isSupported(itemId) == false) {
+ return false;
+ }
+ return this.groups.contains(itemId);
+ }
+
+ @Override
+ public Item addItem(Object itemId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("PDP Container cannot add a given item.");
+ }
+
+ @Override
+ public Object addItem() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("PDP Container cannot add a given item.");
+ }
+
+ public void addNewGroup(String name, String description) throws NullPointerException, PAPException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("addNewGroup " + name + " " + description);
+ }
+ this.papEngine.newGroup(name, description);
+ }
+
+ public void addNewPDP(String id, PDPGroup group, String name, String description) throws NullPointerException, PAPException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("addNewPDP " + id + " " + name + " " + description);
+ }
+ this.papEngine.newPDP(id, group, name, description);
+ }
+
+ public void movePDP(PDP pdp, PDPGroup group) {
+ try {
+ this.papEngine.movePDP(pdp, group);
+ } catch (PAPException e) {
+ String message = "Unable to move PDP to new group on server: " + e;
+ logger.error(message, e);
+ }
+ }
+
+ @Override
+ public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot add a container property.");
+ }
+
+ @Override
+ public boolean removeContainerProperty(Object propertyId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot remove a container property.");
+ }
+
+ @Override
+ public boolean removeAllItems() throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("PDP Container cannot remove all items. You must have at least the Default group.");
+ }
+
+ @Override
+ public void addItemSetChangeListener(ItemSetChangeListener listener) {
+ if (getItemSetChangeListeners() == null) {
+ setItemSetChangeListeners(new LinkedList<Container.ItemSetChangeListener>());
+ }
+ getItemSetChangeListeners().add(listener);
+ }
+
+ @Override
+ public Object nextItemId(Object itemId) {
+ if (this.isSupported(itemId) == false) {
+ return null;
+ }
+ int index = this.groups.indexOf(itemId);
+ if (index == -1) {
+ //
+ // We don't know this group
+ //
+ return null;
+ }
+ //
+ // Is it the last one?
+ //
+ if (index == this.groups.size() - 1) {
+ //
+ // Yes
+ //
+ return null;
+ }
+ //
+ // Return the next one
+ //
+ return this.groups.get(index + 1);
+ }
+
+ @Override
+ public Object prevItemId(Object itemId) {
+ if (this.isSupported(itemId) == false) {
+ return null;
+ }
+ int index = this.groups.indexOf(itemId);
+ if (index == -1) {
+ //
+ // We don't know this group
+ //
+ return null;
+ }
+ //
+ // Is it the first one?
+ //
+ if (index == 0) {
+ //
+ // Yes
+ //
+ return null;
+ }
+ //
+ // Return the previous one
+ //
+ return this.groups.get(index - 1);
+ }
+
+ @Override
+ public Object firstItemId() {
+ synchronized (this.groups) {
+ if (this.groups.size() > 0) {
+ return this.groups.get(0);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public Object lastItemId() {
+ synchronized (this.groups) {
+ if (this.groups.size() > 0) {
+ return this.groups.get(this.groups.size() - 1);
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public boolean isFirstId(Object itemId) {
+ synchronized (this.groups) {
+ if (this.groups.size() > 0) {
+ return this.groups.get(0).equals(itemId);
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean isLastId(Object itemId) {
+ synchronized (this.groups) {
+ if (this.groups.size() > 0) {
+ return this.groups.get(this.groups.size() - 1).equals(itemId);
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public Object addItemAfter(Object previousItemId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot addItemAfter, there really is no real ordering.");
+ }
+
+ @Override
+ public Item addItemAfter(Object previousItemId, Object newItemId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot addItemAfter, there really is no real ordering.");
+ }
+
+ @Override
+ public int indexOfId(Object itemId) {
+ return this.groups.indexOf(itemId);
+ }
+
+ @Override
+ public Object getIdByIndex(int index) {
+ return this.groups.get(index);
+ }
+
+ @Override
+ public List<?> getItemIds(int startIndex, int numberOfItems) {
+ synchronized (this.groups) {
+ int endIndex = startIndex + numberOfItems;
+ if (endIndex > this.groups.size()) {
+ endIndex = this.groups.size() - 1;
+ }
+ return this.groups.subList(startIndex, endIndex);
+ }
+ }
+
+ @Override
+ public Object addItemAt(int index) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot addItemAt");
+ }
+
+ @Override
+ public Item addItemAt(int index, Object newItemId) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("Cannot addItemAt");
+ }
+
+ @Override
+ public boolean removeItem(Object itemId) throws UnsupportedOperationException {
+ if (logger.isTraceEnabled()) {
+ logger.trace("removeItem: " + itemId);
+ }
+ if (this.isSupported(itemId) == false) {
+ return false;
+ }
+ //
+ // You cannot remove the default group
+ //
+ if (((PDPGroup) itemId).getId().equals("Default")) {
+ throw new UnsupportedOperationException("You can't remove the Default Group.");
+ }
+ //
+ // Remove PDPGroup and move any PDP's in it into the default group
+ //
+ try {
+ this.papEngine.removeGroup((PDPGroup) itemId, this.papEngine.getDefaultGroup());
+ return true;
+ } catch (NullPointerException | PAPException e) {
+ logger.error("Failed to remove group", e);
+ }
+ return false;
+ }
+
+ public class PDPGroupItem implements Item {
+ private static final long serialVersionUID = 1L;
+
+ private final PDPGroup group;
+
+ public PDPGroupItem(PDPGroup itemId) {
+ this.group = itemId;
+ }
+
+ public String getId() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getId: " + this.group);
+ }
+ return this.group.getId();
+ }
+
+ public String getName() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getName: " + this.group);
+ }
+ return this.group.getName();
+ }
+
+ public String getDescription() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getDescription: " + this.group);
+ }
+ return this.group.getDescription();
+ }
+
+ public Boolean getDefault() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getDefault: " + this.group);
+ }
+ return this.group.isDefaultGroup();
+ }
+
+ public Resource getIcon() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getIcon: " + this.group);
+ }
+ return null;
+ }
+
+ public String getStatus() {
+ return this.group.getStatus().getStatus().toString();
+ }
+
+ public Set<PDP> getPDPs() {
+ return Collections.unmodifiableSet(this.group.getPdps());
+ }
+
+ public Set<PDPPolicy> getPolicies() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getPolicies: " + this.group);
+ }
+ return this.group.getPolicies();
+ }
+
+ public Set<PDPPIPConfig> getPipConfigs() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("getPIPConfigs: " + this.group);
+ }
+ return this.group.getPipConfigs();
+ }
+
+ @Override
+ public Property<?> getItemProperty(Object id) {
+ return getContainerProperty(this.group, id);
+ }
+
+ @Override
+ public Collection<?> getItemPropertyIds() {
+ return getContainerPropertyIds();
+ }
+
+ @Override
+ public boolean addItemProperty(Object id, @SuppressWarnings("rawtypes") Property property) throws UnsupportedOperationException {
+ throw new UnsupportedOperationException("PDP container does not support adding new properties");
+ }
+
+ @Override
+ public boolean removeItemProperty(Object id)
+ throws UnsupportedOperationException {
+ throw new UnsupportedOperationException(
+ "PDP container does not support property removal");
+ }
+ }
+}
[22/23] incubator-openaz git commit: Ported original att source to
openaz
Posted by pd...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-openaz/blob/a1d93100/openaz-xacml-pap-admin/src/META-INF/data.sql
----------------------------------------------------------------------
diff --git a/openaz-xacml-pap-admin/src/META-INF/data.sql b/openaz-xacml-pap-admin/src/META-INF/data.sql
new file mode 100644
index 0000000..a679b4d
--- /dev/null
+++ b/openaz-xacml-pap-admin/src/META-INF/data.sql
@@ -0,0 +1,723 @@
+INSERT INTO ConstraintType (id, constraint_type, description) VALUES (1,'Range','Set a range of min and/or max integer/double values the attribute can be set to during policy creation.');
+INSERT INTO ConstraintType (id, constraint_type, description) VALUES (2,'Regular Expression','Define a regular expression the attribute must match against during policy creation.');
+INSERT INTO ConstraintType (id, constraint_type, description) VALUES (3,'Enumeration','Enumerate a set of values that the attribute may be set to during policy creation.');
+
+INSERT INTO Category (id, grouping, is_standard, xacml_id, short_name) VALUES (4,'subject','S','urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject','intermediary-subject');
+INSERT INTO Category (id, grouping, is_standard, xacml_id, short_name) VALUES (5,'resource','S','urn:oasis:names:tc:xacml:3.0:attribute-category:resource','resource');
+INSERT INTO Category (id, grouping, is_standard, xacml_id, short_name) VALUES (6,'subject','S','urn:oasis:names:tc:xacml:1.0:subject-category:codebase','codebase');
+INSERT INTO Category (id, grouping, is_standard, xacml_id, short_name) VALUES (7,'action','S','urn:oasis:names:tc:xacml:3.0:attribute-category:action','action');
+INSERT INTO Category (id, grouping, is_standard, xacml_id, short_name) VALUES (8,'subject','S','urn:oasis:names:tc:xacml:1.0:subject-category:access-subject','access-subject');
+INSERT INTO Category (id, grouping, is_standard, xacml_id, short_name) VALUES (9,'environment','S','urn:oasis:names:tc:xacml:3.0:attribute-category:environment','environment');
+INSERT INTO Category (id, grouping, is_standard, xacml_id, short_name) VALUES (10,'subject','S','urn:oasis:names:tc:xacml:1.0:subject-category:requesting-machine','requesting-machine');
+INSERT INTO Category (id, grouping, is_standard, xacml_id, short_name) VALUES (11,'subject','S','urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject','recipient-subject');
+
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (12,'S','integer','http://www.w3.org/2001/XMLSchema#integer');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (13,'S','base64Binary','http://www.w3.org/2001/XMLSchema#base64Binary');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (14,'S','x500Name','urn:oasis:names:tc:xacml:1.0:data-type:x500Name');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (15,'S','dayTimeDuration','http://www.w3.org/2001/XMLSchema#dayTimeDuration');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (16,'S','time','http://www.w3.org/2001/XMLSchema#time');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (17,'S','dnsName','urn:oasis:names:tc:xacml:2.0:data-type:dnsName');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (18,'S','boolean','http://www.w3.org/2001/XMLSchema#boolean');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (19,'S','dateTime','http://www.w3.org/2001/XMLSchema#dateTime');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (20,'S','rfc822Name','urn:oasis:names:tc:xacml:1.0:data-type:rfc822Name');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (21,'S','date','http://www.w3.org/2001/XMLSchema#date');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (22,'S','ipAddress','urn:oasis:names:tc:xacml:2.0:data-type:ipAddress');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (23,'S','yearMonthDuration','http://www.w3.org/2001/XMLSchema#yearMonthDuration');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (24,'S','hexBinary','http://www.w3.org/2001/XMLSchema#hexBinary');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (25,'S','double','http://www.w3.org/2001/XMLSchema#double');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (26,'S','string','http://www.w3.org/2001/XMLSchema#string');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (27,'S','anyURI','http://www.w3.org/2001/XMLSchema#anyURI');
+INSERT INTO Datatype (id, is_standard, short_name, xacml_id) VALUES (28,'S','xpathExpression','urn:oasis:names:tc:xacml:3.0:data-type:xpathExpression');
+
+INSERT INTO PolicyAlgorithms (id, is_standard, short_name, xacml_id) VALUES (29,'S','ordered-deny-overrides','urn:oasis:names:tc:xacml:3.0:policy-combining-algorithm:ordered-deny-overrides');
+INSERT INTO PolicyAlgorithms (id, is_standard, short_name, xacml_id) VALUES (30,'S','on-permit-apply-second','urn:oasis:names:tc:xacml:3.0:policy-combining-algorithm:on-permit-apply-second');
+INSERT INTO PolicyAlgorithms (id, is_standard, short_name, xacml_id) VALUES (31,'S','deny-overrides','urn:oasis:names:tc:xacml:3.0:policy-combining-algorithm:deny-overrides');
+INSERT INTO PolicyAlgorithms (id, is_standard, short_name, xacml_id) VALUES (32,'S','permit-unless-deny','urn:oasis:names:tc:xacml:3.0:policy-combining-algorithm:permit-unless-deny');
+INSERT INTO PolicyAlgorithms (id, is_standard, short_name, xacml_id) VALUES (33,'S','deny-unless-permit','urn:oasis:names:tc:xacml:3.0:policy-combining-algorithm:deny-unless-permit');
+INSERT INTO PolicyAlgorithms (id, is_standard, short_name, xacml_id) VALUES (34,'S','permit-overrides','urn:oasis:names:tc:xacml:3.0:policy-combining-algorithm:permit-overrides');
+INSERT INTO PolicyAlgorithms (id, is_standard, short_name, xacml_id) VALUES (35,'S','only-one-applicable','urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:only-one-applicable');
+INSERT INTO PolicyAlgorithms (id, is_standard, short_name, xacml_id) VALUES (36,'S','first-applicable','urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:first-applicable');
+INSERT INTO PolicyAlgorithms (id, is_standard, short_name, xacml_id) VALUES (37,'S','ordered-permit-overrides','urn:oasis:names:tc:xacml:3.0:policy-combining-algorithm:ordered-permit-overrides');
+
+INSERT INTO RuleAlgorithms (id, is_standard, short_name, xacml_id) VALUES (38,'S','permit-unless-deny','urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-unless-deny');
+INSERT INTO RuleAlgorithms (id, is_standard, short_name, xacml_id) VALUES (39,'S','permit-overrides','urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides');
+INSERT INTO RuleAlgorithms (id, is_standard, short_name, xacml_id) VALUES (40,'S','deny-overrides','urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-overrides');
+INSERT INTO RuleAlgorithms (id, is_standard, short_name, xacml_id) VALUES (41,'S','ordered-permit-overrides','urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:ordered-permit-overrides');
+INSERT INTO RuleAlgorithms (id, is_standard, short_name, xacml_id) VALUES (42,'S','deny-unless-permit','urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:deny-unless-permit');
+INSERT INTO RuleAlgorithms (id, is_standard, short_name, xacml_id) VALUES (43,'S','ordered-deny-overrides','urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:ordered-deny-overrides');
+INSERT INTO RuleAlgorithms (id, is_standard, short_name, xacml_id) VALUES (44,'S','only-one-applicable','urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:only-one-applicable');
+INSERT INTO RuleAlgorithms (id, is_standard, short_name, xacml_id) VALUES (45,'S','first-applicable','urn:oasis:names:tc:xacml:1.0:rule-combining-algorithm:first-applicable');
+
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (1,'integer-greater-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:integer-greater-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (2,'integer-subtract','urn:oasis:names:tc:xacml:1.0:function:integer-subtract',12,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (3,'double-to-integer','urn:oasis:names:tc:xacml:1.0:function:double-to-integer',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (4,'integer-one-and-only','urn:oasis:names:tc:xacml:1.0:function:integer-one-and-only',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (5,'double-one-and-only','urn:oasis:names:tc:xacml:1.0:function:double-one-and-only',25,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (6,'string-equal','urn:oasis:names:tc:xacml:1.0:function:string-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (7,'string-equal-ignore-case','urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (8,'string-starts-with','urn:oasis:names:tc:xacml:3.0:function:string-starts-with',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (9,'string-ends-with','urn:oasis:names:tc:xacml:3.0:function: string-ends-with',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (10,'string-concatenate','urn:oasis:names:tc:xacml:2.0:function:string-concatenate',26,0,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (11,'boolean-from-string','urn:oasis:names:tc:xacml:3.0:function:boolean-from-string',18,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (12,'string-from-boolean','urn:oasis:names:tc:xacml:3.0:function:string-from-boolean',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (13,'integer-from-string','urn:oasis:names:tc:xacml:3.0:function:integer-from-string',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (14,'string-from-integer','urn:oasis:names:tc:xacml:3.0:function:string-from-integer',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (15,'double-from-string','urn:oasis:names:tc:xacml:3.0:function:double-from-string',25,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (16,'string-from-double','urn:oasis:names:tc:xacml:3.0:function:string-from-double',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (17,'time-from-string','urn:oasis:names:tc:xacml:3.0:function:time-from-string',16,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (18,'string-from-time','urn:oasis:names:tc:xacml:3.0:function:string-from-time',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (19,'date-from-string','urn:oasis:names:tc:xacml:3.0:function:date-from-string',21,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (20,'string-from-date','urn:oasis:names:tc:xacml:3.0:function:string-from-date',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (21,'dateTime-from-string','urn:oasis:names:tc:xacml:3.0:function:dateTime-from-string',19,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (22,'string-from-dateTime','urn:oasis:names:tc:xacml:3.0:function:string-from-dateTime',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (23,'anyURI-from-string','urn:oasis:names:tc:xacml:3.0:function:anyURI-from-string',27,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (24,'string-from-anyURI','urn:oasis:names:tc:xacml:3.0:function:string-from-anyURI',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (25,'dayTimeDuration-from-string','urn:oasis:names:tc:xacml:3.0:function:dayTimeDuration-from-string',15,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (26,'string-from-dayTimeDuration','urn:oasis:names:tc:xacml:3.0:function:string-from-dayTimeDuration',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (27,'yearMonthDuration-from-string','urn:oasis:names:tc:xacml:3.0:function:yearMonthDuration-from-string',23,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (28,'string-from-yearMonthDuration','urn:oasis:names:tc:xacml:3.0:function:string-from-yearMonthDuration',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (29,'x500Name-from-string','urn:oasis:names:tc:xacml:3.0:function:x500Name-from-string',14,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (30,'string-from-x500Name','urn:oasis:names:tc:xacml:3.0:function:string-from-x500Name',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (31,'rfc822Name-from-string','urn:oasis:names:tc:xacml:3.0:function:rfc822Name-from-string',20,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (32,'string-from-rfc822Name','urn:oasis:names:tc:xacml:3.0:function:string-from-rfc822Name',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (33,'ipAddress-from-string','urn:oasis:names:tc:xacml:3.0:function:ipAddress-from-string',22,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (34,'string-from-ipAddress','urn:oasis:names:tc:xacml:3.0:function:string-from-ipAddress',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (35,'dnsName-from-string','urn:oasis:names:tc:xacml:3.0:function:dnsName-from-string',17,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (36,'string-from-dnsName','urn:oasis:names:tc:xacml:3.0:function:string-from-dnsName',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (37,'anyURI-starts-with','urn:oasis:names:tc:xacml:3.0:function:anyURI-starts-with',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (38,'anyURI-ends-with','urn:oasis:names:tc:xacml:3.0:function:anyURI-ends-with',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (39,'string-contains','urn:oasis:names:tc:xacml:3.0:function:string-contains',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (40,'anyURI-contains','urn:oasis:names:tc:xacml:3.0:function:anyURI-contains',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (41,'string-substring','urn:oasis:names:tc:xacml:3.0:function:string-substring',26,0,0,3,3,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (42,'anyURI-substring','urn:oasis:names:tc:xacml:3.0:function:anyURI-substring',26,0,0,3,3,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (43,'boolean-equal','urn:oasis:names:tc:xacml:1.0:function:boolean-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (44,'integer-equal','urn:oasis:names:tc:xacml:1.0:function:integer-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (45,'double-equal','urn:oasis:names:tc:xacml:1.0:function:double-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (46,'date-equal','urn:oasis:names:tc:xacml:1.0:function:date-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (47,'time-equal','urn:oasis:names:tc:xacml:1.0:function:time-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (48,'dateTime-equal','urn:oasis:names:tc:xacml:1.0:function:dateTime-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (49,'dayTimeDuration-equal','urn:oasis:names:tc:xacml:3.0:function:dayTimeDuration-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (50,'yearMonthDuration-equal','urn:oasis:names:tc:xacml:3.0:function:yearMonthDuration-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (51,'anyURI-equal','urn:oasis:names:tc:xacml:1.0:function:anyURI-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (52,'x500Name-equal','urn:oasis:names:tc:xacml:1.0:function:x500Name-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (53,'rfc822Name-equal','urn:oasis:names:tc:xacml:1.0:function:rfc822Name-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (54,'hexBinary-equal','urn:oasis:names:tc:xacml:1.0:function:hexBinary-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (55,'base64Binary-equal','urn:oasis:names:tc:xacml:1.0:function:base64Binary-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (56,'integer-add','urn:oasis:names:tc:xacml:1.0:function:integer-add',12,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (57,'double-add','urn:oasis:names:tc:xacml:1.0:function:double-add',25,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (58,'double-subtract','urn:oasis:names:tc:xacml:1.0:function:double-subtract',25,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (59,'integer-multiply','urn:oasis:names:tc:xacml:1.0:function:integer-multiply',12,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (60,'double-multiply','urn:oasis:names:tc:xacml:1.0:function:double-multiply',25,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (61,'integer-divide','urn:oasis:names:tc:xacml:1.0:function:integer-divide',12,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (62,'double-divide','urn:oasis:names:tc:xacml:1.0:function:double-divide',25,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (63,'integer-mod','urn:oasis:names:tc:xacml:1.0:function:integer-mod',12,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (64,'integer-abs','urn:oasis:names:tc:xacml:1.0:function:integer-abs',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (65,'double-abs','urn:oasis:names:tc:xacml:1.0:function:double-abs',25,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (66,'round','urn:oasis:names:tc:xacml:1.0:function:round',25,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (67,'floor','urn:oasis:names:tc:xacml:1.0:function:floor',25,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (68,'string-normalize-space','urn:oasis:names:tc:xacml:1.0:function:string-normalize-space',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (69,'string-normalize-to-lower-case','urn:oasis:names:tc:xacml:1.0:function:string-normalize-to-lower-case',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (70,'integer-to-double','urn:oasis:names:tc:xacml:1.0:function:integer-to-double',25,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (71,'integer-greater-than','urn:oasis:names:tc:xacml:1.0:function:integer-greater-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (72,'integer-less-than','urn:oasis:names:tc:xacml:1.0:function:integer-less-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (73,'integer-less-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:integer-less-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (74,'double-greater-than','urn:oasis:names:tc:xacml:1.0:function:double-greater-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (75,'double-greater-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:double-greater-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (76,'double-less-than','urn:oasis:names:tc:xacml:1.0:function:double-less-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (77,'double-less-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:double-less-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (78,'dateTime-add-dayTimeDuration','urn:oasis:names:tc:xacml:3.0:function:dateTime-add-dayTimeDuration',19,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (79,'dateTime-add-yearMonthDuration','urn:oasis:names:tc:xacml:3.0:function:dateTime-add-yearMonthDuration',19,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (80,'dateTime-subtract-dayTimeDuration','urn:oasis:names:tc:xacml:3.0:function:dateTime-subtract-dayTimeDuration',19,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (81,'dateTime-subtract-yearMonthDuration','urn:oasis:names:tc:xacml:3.0:function:dateTime-subtract-yearMonthDuration',19,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (82,'date-add-yearMonthDuration','urn:oasis:names:tc:xacml:3.0:function:date-add-yearMonthDuration',21,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (83,'date-subtract-yearMonthDuration','urn:oasis:names:tc:xacml:3.0:function:date-subtract-yearMonthDuration',21,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (84,'string-greater-than','urn:oasis:names:tc:xacml:1.0:function:string-greater-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (85,'string-greater-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:string-greater-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (86,'string-less-than','urn:oasis:names:tc:xacml:1.0:function:string-less-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (87,'string-less-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:string-less-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (88,'time-greater-than','urn:oasis:names:tc:xacml:1.0:function:time-greater-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (89,'time-greater-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:time-greater-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (90,'time-less-than','urn:oasis:names:tc:xacml:1.0:function:time-less-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (91,'time-less-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:time-less-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (92,'time-in-range','urn:oasis:names:tc:xacml:2.0:function:time-in-range',18,0,0,3,3,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (93,'dateTime-greater-than','urn:oasis:names:tc:xacml:1.0:function:dateTime-greater-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (94,'dateTime-greater-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:dateTime-greater-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (95,'dateTime-less-than','urn:oasis:names:tc:xacml:1.0:function:dateTime-less-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (96,'dateTime-less-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:dateTime-less-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (97,'date-greater-than','urn:oasis:names:tc:xacml:1.0:function:date-greater-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (98,'date-greater-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:date-greater-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (99,'date-less-than','urn:oasis:names:tc:xacml:1.0:function:date-less-than',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (100,'date-less-than-or-equal','urn:oasis:names:tc:xacml:1.0:function:date-less-than-or-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (101,'string-one-and-only','urn:oasis:names:tc:xacml:1.0:function:string-one-and-only',26,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (102,'string-bag-size','urn:oasis:names:tc:xacml:1.0:function:string-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (103,'string-is-in','urn:oasis:names:tc:xacml:1.0:function:string-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (104,'string-bag','urn:oasis:names:tc:xacml:1.0:function:string-bag',26,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (105,'integer-bag-size','urn:oasis:names:tc:xacml:1.0:function:integer-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (106,'integer-is-in','urn:oasis:names:tc:xacml:1.0:function:integer-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (107,'integer-bag','urn:oasis:names:tc:xacml:1.0:function:integer-bag',12,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (108,'double-bag-size','urn:oasis:names:tc:xacml:1.0:function:double-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (109,'double-is-in','urn:oasis:names:tc:xacml:1.0:function:double-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (110,'double-bag','urn:oasis:names:tc:xacml:1.0:function:double-bag',25,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (111,'boolean-one-and-only','urn:oasis:names:tc:xacml:1.0:function:boolean-one-and-only',18,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (112,'boolean-bag-size','urn:oasis:names:tc:xacml:1.0:function:boolean-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (113,'boolean-is-in','urn:oasis:names:tc:xacml:1.0:function:boolean-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (114,'boolean-bag','urn:oasis:names:tc:xacml:1.0:function:boolean-bag',18,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (115,'time-one-and-only','urn:oasis:names:tc:xacml:1.0:function:time-one-and-only',16,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (116,'time-bag-size','urn:oasis:names:tc:xacml:1.0:function:time-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (117,'time-is-in','urn:oasis:names:tc:xacml:1.0:function:time-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (118,'time-bag','urn:oasis:names:tc:xacml:1.0:function:time-bag',16,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (119,'date-one-and-only','urn:oasis:names:tc:xacml:1.0:function:date-one-and-only',21,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (120,'date-bag-size','urn:oasis:names:tc:xacml:1.0:function:date-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (121,'date-is-in','urn:oasis:names:tc:xacml:1.0:function:date-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (122,'date-bag','urn:oasis:names:tc:xacml:1.0:function:date-bag',21,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (123,'dateTime-one-and-only','urn:oasis:names:tc:xacml:1.0:function:dateTime-one-and-only',19,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (124,'dateTime-bag-size','urn:oasis:names:tc:xacml:1.0:function:dateTime-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (125,'dateTime-is-in','urn:oasis:names:tc:xacml:1.0:function:dateTime-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (126,'dateTime-bag','urn:oasis:names:tc:xacml:1.0:function:dateTime-bag',19,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (127,'anyURI-one-and-only','urn:oasis:names:tc:xacml:1.0:function:anyURI-one-and-only',27,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (128,'anyURI-bag-size','urn:oasis:names:tc:xacml:1.0:function:anyURI-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (129,'anyURI-is-in','urn:oasis:names:tc:xacml:1.0:function:anyURI-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (130,'anyURI-bag','urn:oasis:names:tc:xacml:1.0:function:anyURI-bag',27,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (131,'hexBinary-one-and-only','urn:oasis:names:tc:xacml:1.0:function:hexBinary-one-and-only',24,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (132,'hexBinary-bag-size','urn:oasis:names:tc:xacml:1.0:function:hexBinary-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (133,'hexBinary-is-in','urn:oasis:names:tc:xacml:1.0:function:hexBinary-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (134,'hexBinary-bag','urn:oasis:names:tc:xacml:1.0:function:hexBinary-bag',24,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (135,'base64Binary-one-and-only','urn:oasis:names:tc:xacml:1.0:function:base64Binary-one-and-only',13,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (136,'base64Binary-bag-size','urn:oasis:names:tc:xacml:1.0:function:base64Binary-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (137,'base64Binary-is-in','urn:oasis:names:tc:xacml:1.0:function:base64Binary-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (138,'base64Binary-bag','urn:oasis:names:tc:xacml:1.0:function:base64Binary-bag',13,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (139,'dayTimeDuration-one-and-only','urn:oasis:names:tc:xacml:3.0:function:dayTimeDuration-one-and-only',15,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (140,'dayTimeDuration-bag-size','urn:oasis:names:tc:xacml:3.0:function:dayTimeDuration-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (141,'dayTimeDuration-is-in','urn:oasis:names:tc:xacml:3.0:function:dayTimeDuration-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (142,'dayTimeDuration-bag','urn:oasis:names:tc:xacml:3.0:function:dayTimeDuration-bag',15,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (143,'yearMonthDuration-one-and-only','urn:oasis:names:tc:xacml:3.0:function:yearMonthDuration-one-and-only',23,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (144,'yearMonthDuration-bag-size','urn:oasis:names:tc:xacml:3.0:function:yearMonthDuration-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (145,'yearMonthDuration-is-in','urn:oasis:names:tc:xacml:3.0:function:yearMonthDuration-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (146,'yearMonthDuration-bag','urn:oasis:names:tc:xacml:3.0:function:yearMonthDuration-bag',23,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (147,'x500Name-one-and-only','urn:oasis:names:tc:xacml:1.0:function:x500Name-one-and-only',14,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (148,'x500Name-bag-size','urn:oasis:names:tc:xacml:1.0:function:x500Name-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (149,'x500Name-is-in','urn:oasis:names:tc:xacml:1.0:function:x500Name-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (150,'x500Name-bag','urn:oasis:names:tc:xacml:1.0:function:x500Name-bag',14,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (151,'rfc822Name-one-and-only','urn:oasis:names:tc:xacml:1.0:function:rfc822Name-one-and-only',20,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (152,'rfc822Name-bag-size','urn:oasis:names:tc:xacml:1.0:function:rfc822Name-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (153,'rfc822Name-is-in','urn:oasis:names:tc:xacml:1.0:function:rfc822Name-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (154,'rfc822Name-bag','urn:oasis:names:tc:xacml:1.0:function:rfc822Name-bag',20,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (155,'ipAddress-one-and-only','urn:oasis:names:tc:xacml:2.0:function:ipAddress-one-and-only',22,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (156,'ipAddress-bag-size','urn:oasis:names:tc:xacml:2.0:function:ipAddress-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (157,'ipAddress-is-in','urn:oasis:names:tc:xacml:2.0:function:ipAddress-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (158,'ipAddress-bag','urn:oasis:names:tc:xacml:2.0:function:ipAddress-bag',22,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (159,'dnsName-one-and-only','urn:oasis:names:tc:xacml:2.0:function:dnsName-one-and-only',17,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (160,'dnsName-bag-size','urn:oasis:names:tc:xacml:2.0:function:dnsName-bag-size',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (161,'dnsName-is-in','urn:oasis:names:tc:xacml:2.0:function:dnsName-is-in',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (162,'dnsName-bag','urn:oasis:names:tc:xacml:2.0:function:dnsName-bag',17,1,0,1,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (163,'string-regexp-match','urn:oasis:names:tc:xacml:1.0:function:string-regexp-match',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (164,'anyURI-regexp-match','urn:oasis:names:tc:xacml:2.0:function:anyURI-regexp-match',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (165,'ipAddress-regexp-match','urn:oasis:names:tc:xacml:2.0:function:ipAddress-regexp-match',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (166,'dnsName-regexp-match','urn:oasis:names:tc:xacml:2.0:function:dnsName-regexp-match',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (167,'rfc822Name-regexp-match','urn:oasis:names:tc:xacml:2.0:function:rfc822Name-regexp-match',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (168,'x500Name-regexp-match','urn:oasis:names:tc:xacml:2.0:function:x500Name-regexp-match',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (169,'string-intersection','urn:oasis:names:tc:xacml:1.0:function:string-intersection',26,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (170,'string-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:string-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (171,'string-union','urn:oasis:names:tc:xacml:1.0:function:string-union',26,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (172,'string-subset','urn:oasis:names:tc:xacml:1.0:function:string-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (173,'string-set-equals','urn:oasis:names:tc:xacml:1.0:function:string-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (174,'integer-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:integer-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (175,'integer-union','urn:oasis:names:tc:xacml:1.0:function:integer-union',12,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (176,'integer-subset','urn:oasis:names:tc:xacml:1.0:function:integer-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (177,'integer-set-equals','urn:oasis:names:tc:xacml:1.0:function:integer-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (178,'double-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:double-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (179,'double-union','urn:oasis:names:tc:xacml:1.0:function:double-union',25,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (180,'double-subset','urn:oasis:names:tc:xacml:1.0:function:double-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (181,'double-set-equals','urn:oasis:names:tc:xacml:1.0:function:double-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (182,'boolean-intersection','urn:oasis:names:tc:xacml:1.0:function:boolean-intersection',18,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (183,'boolean-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:boolean-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (184,'boolean-union','urn:oasis:names:tc:xacml:1.0:function:boolean-union',18,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (185,'boolean-subset','urn:oasis:names:tc:xacml:1.0:function:boolean-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (186,'boolean-set-equals','urn:oasis:names:tc:xacml:1.0:function:boolean-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (187,'time-intersection','urn:oasis:names:tc:xacml:1.0:function:time-intersection',16,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (188,'time-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:time-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (189,'time-union','urn:oasis:names:tc:xacml:1.0:function:time-union',16,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (190,'time-subset','urn:oasis:names:tc:xacml:1.0:function:time-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (191,'time-set-equals','urn:oasis:names:tc:xacml:1.0:function:time-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (192,'date-intersection','urn:oasis:names:tc:xacml:1.0:function:date-intersection',21,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (193,'date-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:date-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (194,'date-union','urn:oasis:names:tc:xacml:1.0:function:date-union',21,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (195,'date-subset','urn:oasis:names:tc:xacml:1.0:function:date-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (196,'date-set-equals','urn:oasis:names:tc:xacml:1.0:function:date-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (197,'dateTime-intersection','urn:oasis:names:tc:xacml:1.0:function:dateTime-intersection',19,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (198,'dateTime-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:dateTime-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (199,'dateTime-union','urn:oasis:names:tc:xacml:1.0:function:dateTime-union',19,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (200,'dateTime-subset','urn:oasis:names:tc:xacml:1.0:function:dateTime-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (201,'dateTime-set-equals','urn:oasis:names:tc:xacml:1.0:function:dateTime-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (202,'anyURI-intersection','urn:oasis:names:tc:xacml:1.0:function:anyURI-intersection',27,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (203,'anyURI-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:anyURI-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (204,'anyURI-union','urn:oasis:names:tc:xacml:1.0:function:anyURI-union',27,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (205,'anyURI-subset','urn:oasis:names:tc:xacml:1.0:function:anyURI-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (206,'anyURI-set-equals','urn:oasis:names:tc:xacml:1.0:function:anyURI-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (207,'hexBinary-intersection','urn:oasis:names:tc:xacml:1.0:function:hexBinary-intersection',24,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (208,'hexBinary-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:hexBinary-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (209,'hexBinary-union','urn:oasis:names:tc:xacml:1.0:function:hexBinary-union',24,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (210,'hexBinary-subset','urn:oasis:names:tc:xacml:1.0:function:hexBinary-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (211,'hexBinary-set-equals','urn:oasis:names:tc:xacml:1.0:function:hexBinary-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (212,'base64Binary-intersection','urn:oasis:names:tc:xacml:1.0:function:base64Binary-intersection',13,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (213,'base64Binary-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:base64Binary-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (214,'base64Binary-union','urn:oasis:names:tc:xacml:1.0:function:base64Binary-union',13,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (215,'base64Binary-subset','urn:oasis:names:tc:xacml:1.0:function:base64Binary-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (216,'base64Binary-set-equals','urn:oasis:names:tc:xacml:1.0:function:base64Binary-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (217,'dayTimeDuration-intersection','urn:oasis:names:tc:xacml:3.0:function:dayTimeDuration-intersection',15,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (218,'dayTimeDuration-at-least-one-member-of','urn:oasis:names:tc:xacml:3.0:function:dayTimeDuration-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (219,'dayTimeDuration-union','urn:oasis:names:tc:xacml:3.0:function:dayTimeDuration-union',15,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (220,'dayTimeDuration-subset','urn:oasis:names:tc:xacml:3.0:function:dayTimeDuration-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (221,'dayTimeDuration-set-equals','urn:oasis:names:tc:xacml:3.0:function:dayTimeDuration-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (222,'yearMonthDuration-intersection','urn:oasis:names:tc:xacml:3.0:function:yearMonthDuration-intersection',23,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (223,'yearMonthDuration-at-least-one-member-of','urn:oasis:names:tc:xacml:3.0:function:yearMonthDuration-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (224,'yearMonthDuration-union','urn:oasis:names:tc:xacml:3.0:function:yearMonthDuration-union',23,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (225,'yearMonthDuration-subset','urn:oasis:names:tc:xacml:3.0:function:yearMonthDuration-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (226,'yearMonthDuration-set-equals','urn:oasis:names:tc:xacml:3.0:function:yearMonthDuration-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (227,'x500Name-intersection','urn:oasis:names:tc:xacml:1.0:function:x500Name-intersection',14,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (228,'x500Name-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:x500Name-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (229,'x500Name-union','urn:oasis:names:tc:xacml:1.0:function:x500Name-union',14,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (230,'x500Name-subset','urn:oasis:names:tc:xacml:1.0:function:x500Name-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (231,'x500Name-set-equals','urn:oasis:names:tc:xacml:1.0:function:x500Name-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (232,'rfc822Name-intersection','urn:oasis:names:tc:xacml:1.0:function:rfc822Name-intersection',20,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (233,'rfc822Name-at-least-one-member-of','urn:oasis:names:tc:xacml:1.0:function:rfc822Name-at-least-one-member-of',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (234,'rfc822Name-union','urn:oasis:names:tc:xacml:1.0:function:rfc822Name-union',20,1,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (235,'rfc822Name-subset','urn:oasis:names:tc:xacml:1.0:function:rfc822Name-subset',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (236,'rfc822Name-set-equals','urn:oasis:names:tc:xacml:1.0:function:rfc822Name-set-equals',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (237,'x500Name-match','urn:oasis:names:tc:xacml:1.0:function:x500Name-match',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (238,'rfc822Name-match','urn:oasis:names:tc:xacml:1.0:function:rfc822Name-match',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (239,'integer-intersection','urn:oasis:names:tc:xacml:1.0:function:integer-intersection',12,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (240,'double-intersection','urn:oasis:names:tc:xacml:1.0:function:double-intersection',25,1,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (241,'or','urn:oasis:names:tc:xacml:1.0:function:or',18,0,0,0,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (242,'and','urn:oasis:names:tc:xacml:1.0:function:and',18,0,0,0,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (243,'n-of','urn:oasis:names:tc:xacml:1.0:function:n-of',18,0,0,2,-1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (244,'not','urn:oasis:names:tc:xacml:1.0:function:not',18,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (245,'any-of','urn:oasis:names:tc:xacml:3.0:function:any-of',18,0,1,2,-1,1,-1,1);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (246,'all-of','urn:oasis:names:tc:xacml:3.0:function:all-of',18,0,1,2,-1,1,-1,1);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (247,'any-of-any','urn:oasis:names:tc:xacml:3.0:function:any-of-any',18,0,1,2,-1,1,-1,0);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (248,'all-of-any','urn:oasis:names:tc:xacml:1.0:function:all-of-any',18,0,1,3,3,2,2,1);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (249,'any-of-all','urn:oasis:names:tc:xacml:1.0:function:any-of-all',18,0,1,3,3,2,2,1);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (250,'all-of-all','urn:oasis:names:tc:xacml:1.0:function:all-of-all',18,0,1,3,3,2,2,1);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (251,'map','urn:oasis:names:tc:xacml:3.0:function:map',NULL,1,1,2,-1,1,-1,1);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (252,'xpath-node-count','urn:oasis:names:tc:xacml:3.0:function:xpath-node-count',12,0,0,1,1,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (253,'xpath-node-equal','urn:oasis:names:tc:xacml:3.0:function:xpath-node-equal',18,0,0,2,2,NULL,NULL,NULL);
+INSERT INTO FunctionDefinition (id, short_name, xacml_id, return_datatype, is_bag_return, is_higher_order, arg_lb, arg_ub, ho_arg_lb, ho_arg_ub, ho_primitive) VALUES (254,'xpath-node-match','urn:oasis:names:tc:xacml:3.0:function:xpath-node-match',18,0,0,2,2,NULL,NULL,NULL);
+
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (1,0,1,1,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (2,0,1,2,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (3,0,2,1,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (4,0,2,2,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (5,0,3,1,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (6,1,4,1,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (7,1,5,1,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (8,0,6,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (9,0,6,2,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (10,0,7,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (11,0,7,2,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (12,0,8,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (13,0,8,2,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (14,0,9,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (15,0,9,2,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (16,0,10,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (17,0,11,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (18,0,12,1,18);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (19,0,13,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (20,0,14,1,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (21,0,15,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (22,0,16,1,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (23,0,17,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (24,0,18,1,16);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (25,0,19,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (26,0,20,1,21);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (27,0,21,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (28,0,22,1,19);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (29,0,23,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (30,0,24,1,27);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (31,0,25,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (32,0,26,1,15);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (33,0,27,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (34,0,28,1,23);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (35,0,29,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (36,0,30,1,14);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (37,0,31,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (38,0,32,1,20);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (39,0,33,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (40,0,34,1,22);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (41,0,35,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (42,0,36,1,17);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (43,0,37,2,27);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (44,0,37,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (45,0,38,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (46,0,38,2,27);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (47,0,39,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (48,0,39,2,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (49,0,40,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (50,0,40,2,27);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (51,0,41,1,26);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (52,0,41,2,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (53,0,41,3,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (54,0,42,1,27);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (55,0,42,2,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (56,0,42,3,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (57,0,43,1,18);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (58,0,43,2,18);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (59,0,44,1,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (60,0,44,2,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (61,0,45,1,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (62,0,45,2,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (63,0,46,1,21);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (64,0,46,2,21);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (65,0,47,1,16);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (66,0,47,2,16);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (67,0,48,1,19);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (68,0,48,2,19);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (69,0,49,1,15);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (70,0,49,2,15);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (71,0,50,1,23);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (72,0,50,2,23);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (73,0,51,1,27);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (74,0,51,2,27);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (75,0,52,1,14);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (76,0,52,2,14);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (77,0,53,1,20);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (78,0,53,2,20);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (79,0,54,1,24);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (80,0,54,2,24);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (81,0,55,1,13);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (82,0,55,2,13);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (83,0,56,1,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (84,0,56,2,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (85,0,57,1,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (86,0,57,2,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (89,0,58,1,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (90,0,58,2,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (91,0,59,1,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (92,0,59,2,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (93,0,60,1,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (94,0,60,2,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (95,0,61,1,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (96,0,61,2,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (97,0,62,1,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (98,0,62,2,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (99,0,63,1,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (100,0,63,2,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (101,0,64,1,12);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (102,0,65,1,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, arg_index, datatype_id) VALUES (103,0,66,1,25);
+INSERT INTO FunctionArguments (id, is_bag, function_id, ar
<TRUNCATED>