]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-1345 added csid to role schema as rolename is not unique in cspace
authorSanjay Dalal <sanjay.dalal@berkeley.edu>
Wed, 31 Mar 2010 22:48:16 +0000 (22:48 +0000)
committerSanjay Dalal <sanjay.dalal@berkeley.edu>
Wed, 31 Mar 2010 22:48:16 +0000 (22:48 +0000)
CSPACE-1347 replaced rolename with roleId in association relationships with permission and users, changed query in login-config.xml to reflect this change
test: mvn test at the services level

!!!requires ant clean undeploy deploy at least at services/authentication level as login-config.xml has changed
!!!requires ant create_db at authorization service level

M    services/authentication/service/src/main/resources/config/jboss-login-config.xml
M    services/authentication/service/src/main/resources/config/login-config.xml
_M   services/loanin/service
_M   services/loanin/jaxb
_M   services/loanin/3rdparty/nuxeo-platform-cs-loanin
_M   services/loanin/client
_M   services/account
M    services/authorization/service/src/test/java/org/collectionspace/services/authorization/test/AuthorizationGenTest.java
M    services/authorization/service/src/test/resources/test-data/test-permissions-roles.xml
M    services/authorization/service/src/main/java/org/collectionspace/services/authorization/AuthZ.java
M    services/authorization/jaxb/src/main/resources/roles.xsd
M    services/authorization/jaxb/src/main/resources/users_roles.xsd
M    services/authorization/jaxb/src/main/resources/permissions_roles.xsd
M    services/authorization/pstore/src/main/resources/db/mysql/authorization_index.sql
M    services/authorization/pstore/src/main/resources/db/mysql/test_authorization.sql
M    services/authorization/pstore/src/main/resources/db/mysql/authorization.sql

services/authentication/service/src/main/resources/config/jboss-login-config.xml
services/authentication/service/src/main/resources/config/login-config.xml
services/authorization/jaxb/src/main/resources/permissions_roles.xsd
services/authorization/jaxb/src/main/resources/roles.xsd
services/authorization/jaxb/src/main/resources/users_roles.xsd
services/authorization/pstore/src/main/resources/db/mysql/authorization.sql
services/authorization/pstore/src/main/resources/db/mysql/authorization_index.sql
services/authorization/pstore/src/main/resources/db/mysql/test_authorization.sql
services/authorization/service/src/main/java/org/collectionspace/services/authorization/AuthZ.java
services/authorization/service/src/test/java/org/collectionspace/services/authorization/test/AuthorizationGenTest.java
services/authorization/service/src/test/resources/test-data/test-permissions-roles.xml

index 253c2a35a197956124d2772999dd7c44814b8447..a557fd39522b7fae1f8179da314b05918ff54200 100644 (file)
@@ -28,7 +28,7 @@ copy before the "other" application-policy
                 select passwd from users where username=?
             </module-option>
             <module-option name="rolesQuery">
-                select rolename, 'Roles' from users_roles where username=?
+                select r.rolename, 'Role' from roles as r, users_roles as ur where ur.username=? and ur.role_id=r.csid
             </module-option>
             <module-option name="tenantsQuery">
                 select t.id, t.name, 'Tenants' from accounts_common as a, accounts_tenants as at, tenants as t where a.userid=? and a.csid = at.TENANTS_ACCOUNTSCOMMON_CSID and at.tenant_id = t.id
index 33d757f6111e999399a8ec893cc65c45d254f70c..823bea056f9a03f591f45a7862229159f28f9523 100644 (file)
@@ -145,7 +145,7 @@ $Revision: 64598 $
                 select passwd from users where username=?
             </module-option>
             <module-option name="rolesQuery">
-                select rolename, 'Roles' from users_roles where username=?
+                 select r.rolename, 'Role' from roles as r, users_roles as ur where ur.username=? and ur.role_id=r.csid
             </module-option>
             <module-option name="tenantsQuery">
                 select t.id, t.name, 'Tenants' from accounts_common as a, accounts_tenants as at, tenants as t where a.userid=? and a.csid = at.TENANTS_ACCOUNTSCOMMON_CSID and at.tenant_id = t.id
index c746b24979fb6864ec2676e4fb8bb464aaa1c09c..492d64d6df237e3402ef54ee241cdb3233f4f7a1 100644 (file)
@@ -58,7 +58,7 @@
                         <orm:unique-constraint>
                             <!-- combined length should be < 1000 bytes -->
                             <orm:column-name>permission_id</orm:column-name>
-                            <orm:column-name>rolename</orm:column-name>
+                            <orm:column-name>role_id</orm:column-name>
                         </orm:unique-constraint>
                     </orm:table>
                 </hj:entity>
                     </xs:appinfo>
                 </xs:annotation>
             </xs:element>
-            <xs:element name="roleName" type="xs:string" minOccurs="1" maxOccurs="1">
+            <xs:element name="roleId" type="xs:string" minOccurs="1" maxOccurs="1">
                 <xs:annotation>
                     <xs:appinfo>
                         <hj:basic>
-                            <orm:column name="rolename" length="200" nullable="false"/>
+                            <orm:column name="role_id" length="128" nullable="false"/>
                         </hj:basic>
                     </xs:appinfo>
                 </xs:annotation>
         </xs:sequence>
     </xs:complexType>
 
-
 </xs:schema>
 
index 5408db980ad2f75514ab22a1bbc311fde53122e7..b29c53b0fc025f010c860163035f9d61e9281aaa 100644 (file)
             <xs:documentation>Role definition in CollectionSpace</xs:documentation>
             <xs:appinfo>
                 <hj:entity>
-                    <orm:table name="roles"/>
+                    <orm:table name="roles">
+                        <orm:unique-constraint>
+                            <orm:column-name>rolename</orm:column-name>
+                        </orm:unique-constraint>
+                    </orm:table>
                 </hj:entity>
             </xs:appinfo>
         </xs:annotation>
@@ -62,9 +66,9 @@
             <xs:element name="roleName" type="xs:string" minOccurs="1" maxOccurs="1">
                 <xs:annotation>
                     <xs:appinfo>
-                        <hj:id>
+                        <hj:basic>
                             <orm:column name="rolename" length="200" nullable="false"/>
-                        </hj:id>
+                        </hj:basic>
                     </xs:appinfo>
                 </xs:annotation>
             </xs:element>
                 </xs:annotation>
             </xs:element>
         </xs:sequence>
+        <xs:attribute name="csid" type="xs:string">
+            <xs:annotation>
+                <xs:appinfo>
+                    <hj:id>
+                        <orm:column name="csid" length="128" nullable="false"/>
+                    </hj:id>
+                </xs:appinfo>
+            </xs:annotation>
+        </xs:attribute>
     </xs:complexType>
 
 
index 3715aebda5a8463e66d3e35b57248111e674f2d1..745d139b364fe261d3dc3abc37d463117063643b 100644 (file)
@@ -58,7 +58,7 @@
                         <orm:unique-constraint>
                             <!-- combined length should be < 1000 bytes -->
                             <orm:column-name>username</orm:column-name>
-                            <orm:column-name>rolename</orm:column-name>
+                            <orm:column-name>role_id</orm:column-name>
                         </orm:unique-constraint>
                     </orm:table>
                 </hj:entity>
                     </xs:appinfo>
                 </xs:annotation>
             </xs:element>
-            <xs:element name="roleName" type="xs:string" minOccurs="1" maxOccurs="1">
+            <xs:element name="roleId" type="xs:string" minOccurs="1" maxOccurs="1">
                 <xs:annotation>
                     <xs:appinfo>
                         <hj:basic>
-                            <orm:column name="rolename" length="200" nullable="false"/>
+                            <orm:column name="role_id" length="128" nullable="false"/>
                         </hj:basic>
                     </xs:appinfo>
                 </xs:annotation>
index e26f9bb13a75aa120d35b426b371c9d4e06fa112..e3d6a60aeced8031ea40f1e45250449a845d8778 100644 (file)
@@ -6,7 +6,7 @@ drop table if exists roles;
 drop table if exists users_roles;
 create table permissions (csid varchar(128) not null, attribute_name varchar(128), created_at datetime not null, description varchar(255), effect varchar(32) not null, resource_name varchar(128) not null, updated_at datetime, primary key (csid));
 create table permissions_actions (HJID bigint not null auto_increment, name varchar(128) not null, ACTION__PERMISSION_CSID varchar(128), primary key (HJID));
-create table permissions_roles (HJID bigint not null auto_increment, created_at datetime not null, permission_id varchar(128) not null, rolename varchar(200) not null, updated_at datetime, primary key (HJID), unique (permission_id, rolename));
-create table roles (rolename varchar(200) not null, created_at datetime not null, description varchar(255), rolegroup varchar(255) not null, updated_at datetime, primary key (rolename));
-create table users_roles (HJID bigint not null auto_increment, created_at datetime not null, rolename varchar(200) not null, updated_at datetime, username varchar(128) not null, primary key (HJID), unique (username, rolename));
+create table permissions_roles (HJID bigint not null auto_increment, created_at datetime not null, permission_id varchar(128) not null, role_id varchar(128) not null, updated_at datetime, primary key (HJID), unique (permission_id, role_id));
+create table roles (csid varchar(128) not null, created_at datetime not null, description varchar(255), rolegroup varchar(255) not null, rolename varchar(200) not null, updated_at datetime, primary key (csid), unique (rolename));
+create table users_roles (HJID bigint not null auto_increment, created_at datetime not null, role_id varchar(128) not null, updated_at datetime, username varchar(128) not null, primary key (HJID), unique (username, role_id));
 alter table permissions_actions add index FK85F8204295972CE9 (ACTION__PERMISSION_CSID), add constraint FK85F8204295972CE9 foreign key (ACTION__PERMISSION_CSID) references permissions (csid);
index efa5e5c8fbbc14a1ff962fd687f08e751d42dc06..ed1376783acee2470c25739970b3c5b4a57c7a49 100644 (file)
@@ -4,8 +4,9 @@
 -- You may not use this file except in compliance with this License.
 --
 use cspace;
-CREATE INDEX index_rolename ON roles (rolegroup);
+CREATE INDEX index_rolename ON roles (rolename);
+CREATE INDEX index_rolegroup ON roles (rolegroup);
 CREATE INDEX index_username ON users_roles (username);
-CREATE INDEX index_rolename ON users_roles (rolename);
+CREATE INDEX index_role_id ON users_roles (role_id);
 CREATE INDEX index_permission_id ON permissions_roles (permission_id);
-CREATE INDEX index_rolename ON permissions_roles (rolename);
+CREATE INDEX index_role_id ON permissions_roles (role_id);
index dfd0524a49e77ec4264e7909efa1282170516731..6972aa1d91566c88cc9a2f8500b34d31d047c9ba 100644 (file)
@@ -5,14 +5,14 @@
 --\r
 use cspace;\r
 \r
-insert into `roles` (`rolename`, `rolegroup`, `created_at`) values ('ROLE_KERNEL', 'kernel', '2010-02-17 16:31:48');\r
-insert into `roles` (`rolename`, `rolegroup`, `created_at`) values ('ROLE_USERS', 'collections', '2010-02-17 16:31:48');\r
-insert into `roles` (`rolename`, `rolegroup`, `created_at`) values ('ROLE_COLLECTIONS_MANAGER', 'collections', '2010-02-17 16:31:48');\r
-insert into `roles` (`rolename`, `rolegroup`, `created_at`) values ('ROLE_COLLECTIONS_REGISTRAR', 'collections', '2010-02-17 16:31:48');\r
+insert into `roles` (`csid`, `rolename`, `rolegroup`, `created_at`) values ('1', 'ROLE_ADMINISTRATOR', 'admin', '2010-02-17 16:31:48');\r
+insert into `roles` (`csid`, `rolename`, `rolegroup`, `created_at`) values ('2', 'ROLE_USERS', 'collections', '2010-02-17 16:31:48');\r
+insert into `roles` (`csid`, `rolename`, `rolegroup`, `created_at`) values ('3', 'ROLE_COLLECTIONS_MANAGER', 'collections', '2010-02-17 16:31:48');\r
+insert into `roles` (`csid`, `rolename`, `rolegroup`, `created_at`) values ('4', 'ROLE_COLLECTIONS_REGISTRAR', 'collections', '2010-02-17 16:31:48');\r
 \r
-insert into `users_roles`(`username`, `rolename`, `created_at`) values ('test', 'ROLE_ADMINISTRATOR', '2010-02-17 16:31:48');\r
-insert into `users_roles`(`username`, `rolename`, `created_at`) values ('test', 'ROLE_USERS', '2010-02-17 16:31:48');\r
-insert into `users_roles`(`username`, `rolename`, `created_at`) values ('test', 'ROLE_COLLECTIONS_MANAGER', '2010-02-17 16:31:48');\r
+insert into `users_roles`(`username`, `role_id`, `created_at`) values ('test', '1', '2010-02-17 16:31:48');\r
+insert into `users_roles`(`username`, `role_id`, `created_at`) values ('test', '2', '2010-02-17 16:31:48');\r
+insert into `users_roles`(`username`, `role_id`, `created_at`) values ('test', '3', '2010-02-17 16:31:48');\r
 \r
-insert into `users_roles`(`username`, `rolename`, `created_at`) values ('barney', 'ROLE_USERS', '2010-02-17 16:31:48');\r
-insert into `users_roles`(`username`, `rolename`, `created_at`) values ('barney', 'ROLE_COLLECTIONS_MANAGER', '2010-02-17 16:31:48');\r
+insert into `users_roles`(`username`, `role_id`, `created_at`) values ('barney', '2', '2010-02-17 16:31:48');\r
+insert into `users_roles`(`username`, `role_id`, `created_at`) values ('barney', '3', '2010-02-17 16:31:48');\r
index 21cf0528f7b9485a83db7597b1fad0d61921216d..d9caba47073c4a2ad4a091c5d6bd57caa2810c70 100644 (file)
@@ -103,17 +103,19 @@ public class AuthZ {
      * addPermissions add permissions from given permission configuration
      * @param permission configuration
      */
+    //FIXME this method should be in the restful web service resource of authz
     public void addPermissions(Permission perm,
             List<PermissionRole> permRoles) {
         List<String> principals = new ArrayList<String>();
         for (PermissionRole permRole : permRoles) {
             if (!perm.getCsid().equals(permRole.getPermissionId())) {
                 throw new IllegalArgumentException("permission ids do not"
-                        + " match role=" + permRole.getRoleName()
+                        + " match role=" + permRole.getRoleId()
                         + " permission=" + perm.getCsid());
             }
             //assuming permrole belongs to the same perm
-            principals.add(permRole.getRoleName());
+            //FIXME should use role name
+            principals.add(permRole.getRoleId());
         }
         List<PermissionAction> permActions = perm.getAction();
         for (PermissionAction permAction : permActions) {
index 16245b9f22ac838ebac0303c37308c54d757047e..50fb55ae68a3a2dc5cf35d7f204f099e54f938cc 100644 (file)
@@ -116,11 +116,13 @@ public class AuthorizationGenTest extends AbstractAuthorizationTestImpl {
         ArrayList<PermissionRole> prl = new ArrayList<PermissionRole>();
         PermissionRole pr = new PermissionRole();
         pr.setPermissionId(id);
-        pr.setRoleName("ROLE_USERS");
+        //FIXME should using role id
+        pr.setRoleId("ROLE_USERS");
         prl.add(pr);
         PermissionRole pr1 = new PermissionRole();
         pr1.setPermissionId(id);
-        pr1.setRoleName("ROLE_ADMINISTRATOR");
+        //FIXME shoudl use role id
+        pr1.setRoleId("ROLE_ADMINISTRATOR");
         prl.add(pr1);
         return prl;
     }
index b5e89cfa9f75ffa4d731cc1bece7784be0cce37b..f58460500f29cdc58a2ad3ad04bbfb0a6777b6f5 100644 (file)
@@ -2,18 +2,18 @@
 <ns2:permissions_roles_list xmlns:ns2="http://collectionspace.org/services/authorization">
     <permissionRole>
         <permissionId>1</permissionId>
-        <roleName>ROLE_USERS</roleName>
+        <roleId>ROLE_USERS</roleId>
     </permissionRole>
     <permissionRole>
         <permissionId>1</permissionId>
-        <roleName>ROLE_ADMINISTRATOR</roleName>
+        <roleId>ROLE_ADMINISTRATOR</roleId>
     </permissionRole>
     <permissionRole>
         <permissionId>2</permissionId>
-        <roleName>ROLE_USERS</roleName>
+        <roleId>ROLE_USERS</roleId>
     </permissionRole>
     <permissionRole>
         <permissionId>2</permissionId>
-        <roleName>ROLE_ADMINISTRATOR</roleName>
+        <roleId>ROLE_ADMINISTRATOR</roleId>
     </permissionRole>
 </ns2:permissions_roles_list>