├── .gitignore
├── README.md
├── docs
├── vpp
│ ├── ecommerce-rbac.vpp
│ ├── ecommerce-rbac.vpp~34
│ └── ecommerce-rbac.vpp~35
└── wiki
│ ├── core-rbac-reqs-1.png
│ ├── core-rbac-reqs-2.png
│ ├── core-rbac.png
│ ├── dsd-mathematical-definition.png
│ ├── dsd-overview.png
│ ├── rbac-erd.png
│ ├── rbac-general-role-inheritance-overview.png
│ ├── rbac-general-role-inheritance-reqs.png
│ ├── rbac-general-role-inheritance.gif
│ ├── ssd-inheritance-mathematical-definition.png
│ ├── ssd-simple-mathematical-definition.png
│ ├── ssd-with-role-inheritance-overview.png
│ └── use_case_1_ecommerce_small_business
│ ├── create_script_mysql.sql
│ ├── operations_objects_permissions.png
│ └── roles.png
├── java
├── ecommerce-rbac-api
│ ├── .classpath
│ ├── .project
│ ├── .settings
│ │ ├── org.eclipse.jdt.core.prefs
│ │ ├── org.eclipse.wst.common.component
│ │ ├── org.eclipse.wst.common.project.facet.core.xml
│ │ └── org.maven.ide.eclipse.prefs
│ ├── META-INF
│ │ └── MANIFEST.MF
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ ├── java
│ │ ├── META-INF
│ │ │ └── MANIFEST.MF
│ │ └── org
│ │ │ └── ecommerce
│ │ │ └── rbac
│ │ │ ├── api
│ │ │ ├── Rbac.java
│ │ │ ├── RbacManager.java
│ │ │ └── management
│ │ │ │ ├── RbacDsdManager.java
│ │ │ │ ├── RbacInheritanceManager.java
│ │ │ │ ├── RbacObjectsManager.java
│ │ │ │ ├── RbacOperationsManager.java
│ │ │ │ ├── RbacPermissionsManager.java
│ │ │ │ ├── RbacRolesManager.java
│ │ │ │ ├── RbacSessionsManager.java
│ │ │ │ └── RbacUsersManager.java
│ │ │ └── dto
│ │ │ ├── DynamicSeparationRule.java
│ │ │ ├── DynamicSeparationRules.java
│ │ │ ├── Identifiers.java
│ │ │ ├── Operation.java
│ │ │ ├── Operations.java
│ │ │ ├── Permission.java
│ │ │ ├── Permissions.java
│ │ │ ├── Role.java
│ │ │ ├── Roles.java
│ │ │ ├── SecurityObject.java
│ │ │ ├── SecurityObjects.java
│ │ │ ├── Session.java
│ │ │ ├── Sessions.java
│ │ │ ├── User.java
│ │ │ └── Users.java
│ │ └── resources
│ │ └── META-INF
│ │ └── MANIFEST.MF
├── ecommerce-rbac-dao
│ ├── .classpath
│ ├── .project
│ ├── .settings
│ │ ├── org.eclipse.jdt.core.prefs
│ │ ├── org.eclipse.wst.common.component
│ │ ├── org.eclipse.wst.common.project.facet.core.xml
│ │ └── org.maven.ide.eclipse.prefs
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ ├── META-INF
│ │ └── MANIFEST.MF
│ │ └── org
│ │ └── ecommerce
│ │ └── rbac
│ │ └── dao
│ │ ├── DynamicSeparationDutyDao.java
│ │ ├── OperationsDao.java
│ │ ├── PermissionsDao.java
│ │ ├── RolesDao.java
│ │ ├── RolesInheritanceDao.java
│ │ ├── SecurityObjectsDao.java
│ │ ├── SessionsDao.java
│ │ ├── UsersDao.java
│ │ └── impl
│ │ ├── DynamicSeparationDutyDaoImpl.java
│ │ ├── OperationsDaoImpl.java
│ │ ├── PermissionsDaoImpl.java
│ │ ├── RolesDaoImpl.java
│ │ ├── RolesInheritanceDaoImpl.java
│ │ ├── SecurityObjectsDaoImpl.java
│ │ ├── SessionsDaoImpl.java
│ │ └── UsersDaoImpl.java
├── ecommerce-rbac-entities
│ ├── .classpath
│ ├── .project
│ ├── .settings
│ │ ├── org.eclipse.jdt.core.prefs
│ │ ├── org.eclipse.wst.common.component
│ │ ├── org.eclipse.wst.common.project.facet.core.xml
│ │ └── org.maven.ide.eclipse.prefs
│ ├── .springBeans
│ ├── pom.xml
│ └── src
│ │ ├── main
│ │ ├── java
│ │ │ ├── META-INF
│ │ │ │ └── MANIFEST.MF
│ │ │ └── org
│ │ │ │ └── ecommerce
│ │ │ │ └── rbac
│ │ │ │ └── persistence
│ │ │ │ └── entities
│ │ │ │ ├── DynamicSeparationDuty.java
│ │ │ │ ├── Operation.java
│ │ │ │ ├── Permission.java
│ │ │ │ ├── Role.java
│ │ │ │ ├── SecurityObject.java
│ │ │ │ ├── Session.java
│ │ │ │ └── User.java
│ │ └── resources
│ │ │ └── org
│ │ │ └── ecommerce
│ │ │ └── rbac
│ │ │ └── persistence
│ │ │ └── persistence.xml
│ │ └── test
│ │ ├── java
│ │ └── org
│ │ │ └── ecommerce
│ │ │ └── rbac
│ │ │ └── persistence
│ │ │ └── TestEntities.java
│ │ └── resources
│ │ └── META-INF
│ │ └── persistence.xml
├── ecommerce-rbac-project
│ ├── .classpath
│ ├── .project
│ ├── .settings
│ │ ├── org.eclipse.jdt.core.prefs
│ │ └── org.maven.ide.eclipse.prefs
│ └── pom.xml
├── ecommerce-rbac-rest-impl
│ ├── .classpath
│ ├── .project
│ ├── .settings
│ │ ├── .jsdtscope
│ │ ├── org.eclipse.jdt.core.prefs
│ │ ├── org.eclipse.wst.common.component
│ │ ├── org.eclipse.wst.common.project.facet.core.xml
│ │ ├── org.eclipse.wst.jsdt.ui.superType.container
│ │ ├── org.eclipse.wst.jsdt.ui.superType.name
│ │ └── org.maven.ide.eclipse.prefs
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ ├── java
│ │ └── org
│ │ │ └── ecommerce
│ │ │ └── rbac
│ │ │ └── impl
│ │ │ └── rest
│ │ │ ├── RbacDsdManagerImpl.java
│ │ │ ├── RbacInheritanceManagerImpl.java
│ │ │ ├── RbacObjectsManagerImpl.java
│ │ │ ├── RbacOperationsManagerImpl.java
│ │ │ ├── RbacPermissionsManagerImpl.java
│ │ │ ├── RbacRolesManagerImpl.java
│ │ │ ├── RbacSessionManagerImpl.java
│ │ │ ├── RbacUsersManagerImpl.java
│ │ │ └── exceptions
│ │ │ ├── EmptyResultDataAccessExceptionMapper.java
│ │ │ ├── JpaSystemExceptionMapper.java
│ │ │ └── NoResultExceptionMapper.java
│ │ └── webapp
│ │ ├── META-INF
│ │ └── MANIFEST.MF
│ │ ├── WEB-INF
│ │ ├── web.xml
│ │ ├── webservices-context.xml
│ │ ├── webservices-dao-context.xml
│ │ └── webservices-ds-context.xml
│ │ └── index.jsp
└── integration
│ └── rbac-rest-springdm-client
│ ├── .classpath
│ ├── .project
│ ├── .settings
│ ├── org.eclipse.jdt.core.prefs
│ └── org.maven.ide.eclipse.prefs
│ ├── META-INF
│ ├── MANIFEST.MF
│ └── spring
│ │ ├── rbac-client-context-osgi.xml
│ │ └── rbac-client-context.xml
│ ├── build.properties
│ ├── pom.xml
│ ├── src
│ ├── main
│ │ ├── java
│ │ │ └── org
│ │ │ │ └── ecommerce
│ │ │ │ └── rbac
│ │ │ │ └── integration
│ │ │ │ └── springdm
│ │ │ │ └── rest
│ │ │ │ ├── RbacImpl.java
│ │ │ │ ├── RbacManagerImpl.java
│ │ │ │ └── RbacTestIntegration.java
│ │ └── resources
│ │ │ └── META-INF
│ │ │ ├── MANIFEST.MF
│ │ │ └── spring
│ │ │ ├── rbac-client-context-osgi.xml
│ │ │ └── rbac-client-context.xml
│ └── test
│ │ └── java
│ │ └── com
│ │ └── dmsmart
│ │ └── ws
│ │ └── rest
│ │ └── portal
│ │ └── security
│ │ └── dmsmart
│ │ └── readme.txt
│ └── template.mf
└── utils
└── mysql
└── create_schema.sql
/.gitignore:
--------------------------------------------------------------------------------
1 | #java specific
2 | *.class
3 |
4 | #netbeans ignore personal stuff
5 | nbproject/private/
6 |
7 |
8 | ## generic files to ignore
9 | *~
10 | *.lock
11 | *.DS_Store
12 | *.swp
13 | *.out
14 | target
15 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ECommerce RBAC
2 |
3 | This project intend to implement a reusable security system for ecommerce applications that is compliant with RBAC standard.
4 | RBAC standard current version is widely use by many companies but the goal of this project is to provide an implementation
5 | that can be easily used by ecommerce application. Because many ecommerce applications are web oriented this implementation
6 | will use technologies easily to use in web environments.
7 |
8 | # What RBAC features will be supported
9 |
10 | RBAC standard current version describe four major components.
11 |
12 | * Core components (as defined by standard)
13 | * Roles hierarchy (as defined by standard)
14 | * Services that allows integration over http / https
15 | * API that allows native integration with java applications
16 | * Common security templates that can be used for different size ecommerce applications
17 | * Persistence layer for RBAC security features
18 | * Database scripts for different RDBMS systems (MySQL and Postgres are supported)
19 |
20 | ## Optional features that will be supported
21 |
22 | * Static separation of duty relations (SSD as defined by standard)
23 | * Dynamic separation of dutiy relations (DSOD as defined by standard)
24 |
25 | # Technology used
26 |
27 | * Java 1.6 SE
28 | * Spring 3.0.5
29 | * Apache CXF JAXRS
30 | * Apache CXF WS
31 | * JPA 2.0
32 | * MySql 5 / Postgres 8
33 |
--------------------------------------------------------------------------------
/docs/vpp/ecommerce-rbac.vpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcosnita/eCommerce-RBAC/291f54c5abd8fe7213c1226c0f4aa084446d1ca1/docs/vpp/ecommerce-rbac.vpp
--------------------------------------------------------------------------------
/docs/vpp/ecommerce-rbac.vpp~34:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcosnita/eCommerce-RBAC/291f54c5abd8fe7213c1226c0f4aa084446d1ca1/docs/vpp/ecommerce-rbac.vpp~34
--------------------------------------------------------------------------------
/docs/vpp/ecommerce-rbac.vpp~35:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcosnita/eCommerce-RBAC/291f54c5abd8fe7213c1226c0f4aa084446d1ca1/docs/vpp/ecommerce-rbac.vpp~35
--------------------------------------------------------------------------------
/docs/wiki/core-rbac-reqs-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcosnita/eCommerce-RBAC/291f54c5abd8fe7213c1226c0f4aa084446d1ca1/docs/wiki/core-rbac-reqs-1.png
--------------------------------------------------------------------------------
/docs/wiki/core-rbac-reqs-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcosnita/eCommerce-RBAC/291f54c5abd8fe7213c1226c0f4aa084446d1ca1/docs/wiki/core-rbac-reqs-2.png
--------------------------------------------------------------------------------
/docs/wiki/core-rbac.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcosnita/eCommerce-RBAC/291f54c5abd8fe7213c1226c0f4aa084446d1ca1/docs/wiki/core-rbac.png
--------------------------------------------------------------------------------
/docs/wiki/dsd-mathematical-definition.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcosnita/eCommerce-RBAC/291f54c5abd8fe7213c1226c0f4aa084446d1ca1/docs/wiki/dsd-mathematical-definition.png
--------------------------------------------------------------------------------
/docs/wiki/dsd-overview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcosnita/eCommerce-RBAC/291f54c5abd8fe7213c1226c0f4aa084446d1ca1/docs/wiki/dsd-overview.png
--------------------------------------------------------------------------------
/docs/wiki/rbac-erd.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcosnita/eCommerce-RBAC/291f54c5abd8fe7213c1226c0f4aa084446d1ca1/docs/wiki/rbac-erd.png
--------------------------------------------------------------------------------
/docs/wiki/rbac-general-role-inheritance-overview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcosnita/eCommerce-RBAC/291f54c5abd8fe7213c1226c0f4aa084446d1ca1/docs/wiki/rbac-general-role-inheritance-overview.png
--------------------------------------------------------------------------------
/docs/wiki/rbac-general-role-inheritance-reqs.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcosnita/eCommerce-RBAC/291f54c5abd8fe7213c1226c0f4aa084446d1ca1/docs/wiki/rbac-general-role-inheritance-reqs.png
--------------------------------------------------------------------------------
/docs/wiki/rbac-general-role-inheritance.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcosnita/eCommerce-RBAC/291f54c5abd8fe7213c1226c0f4aa084446d1ca1/docs/wiki/rbac-general-role-inheritance.gif
--------------------------------------------------------------------------------
/docs/wiki/ssd-inheritance-mathematical-definition.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcosnita/eCommerce-RBAC/291f54c5abd8fe7213c1226c0f4aa084446d1ca1/docs/wiki/ssd-inheritance-mathematical-definition.png
--------------------------------------------------------------------------------
/docs/wiki/ssd-simple-mathematical-definition.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcosnita/eCommerce-RBAC/291f54c5abd8fe7213c1226c0f4aa084446d1ca1/docs/wiki/ssd-simple-mathematical-definition.png
--------------------------------------------------------------------------------
/docs/wiki/ssd-with-role-inheritance-overview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcosnita/eCommerce-RBAC/291f54c5abd8fe7213c1226c0f4aa084446d1ca1/docs/wiki/ssd-with-role-inheritance-overview.png
--------------------------------------------------------------------------------
/docs/wiki/use_case_1_ecommerce_small_business/operations_objects_permissions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcosnita/eCommerce-RBAC/291f54c5abd8fe7213c1226c0f4aa084446d1ca1/docs/wiki/use_case_1_ecommerce_small_business/operations_objects_permissions.png
--------------------------------------------------------------------------------
/docs/wiki/use_case_1_ecommerce_small_business/roles.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/rcosnita/eCommerce-RBAC/291f54c5abd8fe7213c1226c0f4aa084446d1ca1/docs/wiki/use_case_1_ecommerce_small_business/roles.png
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | ecommerce-rbac-api
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.wst.common.project.facet.core.builder
10 |
11 |
12 |
13 |
14 | org.eclipse.jdt.core.javabuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.wst.validation.validationbuilder
20 |
21 |
22 |
23 |
24 | org.eclipse.m2e.core.maven2Builder
25 |
26 |
27 |
28 |
29 | org.springframework.ide.eclipse.core.springbuilder
30 |
31 |
32 |
33 |
34 |
35 | org.springframework.ide.eclipse.core.springnature
36 | org.eclipse.pde.PluginNature
37 | org.eclipse.jem.workbench.JavaEMFNature
38 | org.eclipse.wst.common.modulecore.ModuleCoreNature
39 | org.eclipse.jdt.core.javanature
40 | org.eclipse.wst.common.project.facet.core.nature
41 | org.eclipse.m2e.core.maven2Nature
42 |
43 |
44 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | #Wed Oct 05 23:03:12 EEST 2011
2 | eclipse.preferences.version=1
3 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
5 | org.eclipse.jdt.core.compiler.compliance=1.6
6 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
9 | org.eclipse.jdt.core.compiler.source=1.6
10 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/.settings/org.eclipse.wst.common.component:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/.settings/org.eclipse.wst.common.project.facet.core.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/.settings/org.maven.ide.eclipse.prefs:
--------------------------------------------------------------------------------
1 | #Sat Oct 01 12:02:53 EEST 2011
2 | activeProfiles=
3 | eclipse.preferences.version=1
4 | fullBuildGoals=process-test-resources
5 | resolveWorkspaceProjects=true
6 | resourceFilterGoals=process-resources resources\:testResources
7 | skipCompilerPlugin=true
8 | version=1
9 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Export-Package: org.ecommerce.rbac.api.management;uses:="javax.ws.rs,o
3 | rg.ecommerce.rbac.dto",org.ecommerce.rbac.api;uses:="org.ecommerce.rb
4 | ac.api.management",org.ecommerce.rbac.dto;uses:="javax.xml.bind.annot
5 | ation"
6 | Built-By: rcosnita
7 | Tool: Bnd-0.0.238
8 | Bundle-Name: ecommerce-rbac-api
9 | Created-By: Apache Maven Bundle Plugin
10 | Build-Jdk: 1.7.0_09
11 | Bundle-Version: 1.0.0.SNAPSHOT
12 | Bnd-LastModified: 1353019811333
13 | Bundle-ManifestVersion: 2
14 | Bundle-Description: This is the api for ecommerce rbac. You can find t
15 | he api and the transferable objects used within ecommerce role base
16 | d access control solution.
17 | Import-Package: javax.ws.rs,javax.xml.bind.annotation,org.ecommerce.rb
18 | ac.api,org.ecommerce.rbac.api.management,org.ecommerce.rbac.dto
19 | Bundle-SymbolicName: org.ecommerce.rbac.api.ecommerce-rbac-api
20 | Originally-Created-By: Apache Maven Bundle Plugin
21 |
22 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | org.ecommerce.rbac.api
6 | ecommerce-rbac-api
7 | 1.0-SNAPSHOT
8 | This is the api for ecommerce rbac. You can find the api and the transferable objects used within
9 | ecommerce role based access control solution.
10 | bundle
11 |
12 | ecommerce-rbac-api
13 | https://github.com/rcosnita/eCommerce-RBAC/wiki/Rest-api
14 |
15 |
16 | org.ecommerce.rbac.project
17 | ecommerce-rbac-project
18 | 1.0-SNAPSHOT
19 |
20 |
21 |
22 | UTF-8
23 |
24 |
25 |
26 |
27 | rcosnita
28 | Cosnita Radu Viorel
29 | radu.cosnita@gmail.com
30 |
31 | Architect
32 | Developer
33 | Analyst
34 |
35 |
36 |
37 |
38 |
39 |
40 | org.apache.cxf
41 | cxf-bundle-jaxrs
42 | 2.2.9
43 |
44 |
45 |
46 | junit
47 | junit
48 |
49 |
50 |
51 |
52 |
53 |
54 | org.apache.felix
55 | maven-bundle-plugin
56 | 1.4.0
57 | true
58 |
59 | NONE
60 | src/main/resources/META-INF
61 |
62 | org.ecommerce.rbac.api,
63 | org.ecommerce.rbac.api.management,
64 | org.ecommerce.rbac.dto
65 | *
66 |
67 | src/main/resources
68 |
69 |
70 |
71 |
72 | org.apache.felix
73 | maven-bundle-plugin
74 |
75 |
76 | bundle-manifest
77 | package
78 |
79 | bundle
80 |
81 |
82 |
83 |
84 |
85 | org.apache.maven.plugins
86 | maven-antrun-plugin
87 |
88 |
89 | bundle-ant
90 | install
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 | run
102 |
103 |
104 |
105 |
106 |
107 |
108 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/java/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Class-Path:
3 |
4 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/java/org/ecommerce/rbac/api/Rbac.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.api;
2 |
3 | import org.ecommerce.rbac.api.management.RbacDsdManager;
4 | import org.ecommerce.rbac.api.management.RbacInheritanceManager;
5 |
6 | /**
7 | Copyright (C) 2011 by Radu Viorel Cosnita
8 |
9 | Permission is hereby granted, free of charge, to any person obtaining a copy
10 | of this software and associated documentation files (the "Software"), to deal
11 | in the Software without restriction, including without limitation the rights
12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | copies of the Software, and to permit persons to whom the Software is
14 | furnished to do so, subject to the following conditions:
15 |
16 | The above copyright notice and this permission notice shall be included in
17 | all copies or substantial portions of the Software.
18 |
19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | THE SOFTWARE.*/
26 |
27 | /**
28 | * This is the main entry point of ecommerce rbac project. This provides
29 | * all methods to interact with the rbac implementation in a uniform way.
30 | *
31 | * @author Radu Viorel Cosnita
32 | * @version 1.0
33 | * @since 01.10.2011
34 | * @see https://github.com/rcosnita/eCommerce-RBAC/wiki
35 | */
36 |
37 | public interface Rbac {
38 | /**
39 | * Method used to an instance of rbac core features manager.
40 | *
41 | * @return
42 | */
43 | public RbacManager getRbacManager();
44 |
45 | /**
46 | * Method used to obtain a dynamic separation of duty manager.
47 | *
48 | * @return
49 | */
50 | public RbacDsdManager getDsdManager();
51 |
52 | /**
53 | * Method used to obtain an rbac inheritance manager..
54 | *
55 | * @return
56 | */
57 | public RbacInheritanceManager getInheritanceManager();
58 | }
59 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/java/org/ecommerce/rbac/api/RbacManager.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.api;
2 |
3 | import org.ecommerce.rbac.api.management.RbacObjectsManager;
4 | import org.ecommerce.rbac.api.management.RbacOperationsManager;
5 | import org.ecommerce.rbac.api.management.RbacPermissionsManager;
6 | import org.ecommerce.rbac.api.management.RbacRolesManager;
7 | import org.ecommerce.rbac.api.management.RbacSessionsManager;
8 | import org.ecommerce.rbac.api.management.RbacUsersManager;
9 |
10 | /**
11 | Copyright (C) 2011 by Radu Viorel Cosnita
12 |
13 | Permission is hereby granted, free of charge, to any person obtaining a copy
14 | of this software and associated documentation files (the "Software"), to deal
15 | in the Software without restriction, including without limitation the rights
16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 | copies of the Software, and to permit persons to whom the Software is
18 | furnished to do so, subject to the following conditions:
19 |
20 | The above copyright notice and this permission notice shall be included in
21 | all copies or substantial portions of the Software.
22 |
23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 | THE SOFTWARE.*/
30 |
31 | /**
32 | * This is the rbac core features manager. Here you can find all required methods
33 | * that make this implementation fully compliant with RBAC 2.0 standard (from core
34 | * components perspective).
35 | *
36 | * @author Radu Viorel Cosnita
37 | * @version 1.0
38 | * @since 01.10.2011
39 | * @see https://github.com/rcosnita/eCommerce-RBAC/wiki
40 | */
41 |
42 | public interface RbacManager {
43 | /**
44 | * Method used to return an instance of RbacUserManager object. Using
45 | * this object you can interact with users from rbac system.
46 | *
47 | * @return
48 | */
49 | public RbacUsersManager getRbacUsersManager();
50 |
51 | /**
52 | * Method used to return an instance of RbacRolesManager object. Using this
53 | * object you can interact with roles from rbac system.
54 | *
55 | * @return
56 | */
57 | public RbacRolesManager getRbacRolesManager();
58 |
59 | /**
60 | * Method used to return an instance of RbacObjectsManager object. Using
61 | * this object you can interact with objects from rbac system.
62 | *
63 | * @return
64 | */
65 | public RbacObjectsManager getRbacObjectsManager();
66 |
67 | /**
68 | * Method used to return an instance of RbacOperationsManager object. Using
69 | * this object you can interact with operations from RBAC system.
70 | *
71 | * @return
72 | */
73 | public RbacOperationsManager getRbacOperationsManager();
74 |
75 | /**
76 | * Method used to return an instance of RbacPermissionsManager object. Using
77 | * this object you can interact with permissions from rbac system.
78 | *
79 | * @return
80 | */
81 | public RbacPermissionsManager getRbacPermissionsManager();
82 |
83 | /**
84 | * Method used to return an instance of RbacSessionsManager object. Using
85 | * this object you can interact with sessions from RBAC system.
86 | * @return
87 | */
88 | public RbacSessionsManager getRbacSessionsManager();
89 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/java/org/ecommerce/rbac/api/management/RbacDsdManager.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.api.management;
2 |
3 | import java.util.List;
4 |
5 | import javax.ws.rs.Consumes;
6 | import javax.ws.rs.DELETE;
7 | import javax.ws.rs.GET;
8 | import javax.ws.rs.POST;
9 | import javax.ws.rs.PUT;
10 | import javax.ws.rs.Path;
11 | import javax.ws.rs.PathParam;
12 | import javax.ws.rs.Produces;
13 | import javax.ws.rs.QueryParam;
14 | import javax.ws.rs.core.MediaType;
15 |
16 | import org.ecommerce.rbac.dto.DynamicSeparationRule;
17 | import org.ecommerce.rbac.dto.DynamicSeparationRules;
18 | import org.ecommerce.rbac.dto.Identifiers;
19 | import org.ecommerce.rbac.dto.Roles;
20 |
21 | /**
22 | Copyright (C) 2011 by Radu Viorel Cosnita
23 |
24 | Permission is hereby granted, free of charge, to any person obtaining a copy
25 | of this software and associated documentation files (the "Software"), to deal
26 | in the Software without restriction, including without limitation the rights
27 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
28 | copies of the Software, and to permit persons to whom the Software is
29 | furnished to do so, subject to the following conditions:
30 |
31 | The above copyright notice and this permission notice shall be included in
32 | all copies or substantial portions of the Software.
33 |
34 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
40 | THE SOFTWARE.*/
41 |
42 | /**
43 | * This is the rbac Dynamic Separation of Duty manager. Here you can find all required methods
44 | * that make this implementation fully compliant with RBAC 2.0 standard (from dynamic
45 | * separation of duty perspective).
46 | *
47 | * @author Radu Viorel Cosnita
48 | * @version 1.0
49 | * @since 01.10.2011
50 | * @see https://github.com/rcosnita/eCommerce-RBAC/wiki
51 | */
52 |
53 | @Path("/")
54 | @Produces(MediaType.APPLICATION_JSON)
55 | @Consumes(MediaType.APPLICATION_JSON)
56 | public interface RbacDsdManager {
57 | /**
58 | * Method used to load all defined dynamic separation of duty rules.
59 | *
60 | * @return
61 | */
62 | @Path("/")
63 | @GET
64 | public DynamicSeparationRules loadAllDsd();
65 |
66 | /**
67 | * Method used to load a dynamic separation of duty rule by id.
68 | *
69 | * @param dsdId DSD unique identifier.
70 | * @return
71 | */
72 | @Path("/{dsdId}")
73 | @GET
74 | public DynamicSeparationRule loadDsdById(@PathParam("dsdId") Integer dsdId);
75 |
76 | /**
77 | * Method used to load all roles belonging to a dsd.
78 | *
79 | * @param dsdId
80 | * @return
81 | */
82 | @Path("/{dsdId}/roles")
83 | @GET
84 | public Roles loadDsdRoles(@PathParam("dsdId") Integer dsdId);
85 |
86 | /**
87 | * Method used to create a new dsd rule.
88 | *
89 | * @param dsdName DSD name.
90 | * @param cardinality DSD allowed cardinality. >= 2.
91 | * @param roles A list of roles identifiers we want to assign to dsd.
92 | */
93 | @Path("/{dsdName}/{cardinality}")
94 | @POST
95 | public void createNewDsd(
96 | @PathParam("dsdName") String dsdName,
97 | @PathParam("cardinality") Integer cardinality,
98 | Identifiers roles
99 | );
100 |
101 | /**
102 | * Method used to add new roles into the current DSD.
103 | *
104 | * @param dsdId DSD unique identifier.
105 | * @param A list of roles identifier.
106 | */
107 | @Path("/{dsdId}/roles")
108 | @POST
109 | public void includeRolesInDsd(
110 | @PathParam("dsdId") Integer dsdId,
111 | List roles);
112 |
113 | /**
114 | * Method used to update an existing DSD.
115 | *
116 | * @param dsdId DSD unique identifier.
117 | * @param dsd DSD instance.
118 | */
119 | @Path("/{dsdId}")
120 | @PUT
121 | public void updateExistingDsd(
122 | @PathParam("dsdId") Integer dsdId,
123 | DynamicSeparationRule dsd);
124 |
125 | /**
126 | * Method used to exclude a list of roles from the specified DSD.
127 | *
128 | * @param dsdId DSD unique identifier.
129 | * @param roles A list of roles id we want to exclude.
130 | */
131 | @Path("/{dsdId}/roles")
132 | @DELETE
133 | public void excludeRolesFromDsd(
134 | @PathParam("dsdId") Integer dsdId,
135 | @QueryParam("roleId") List roles
136 | );
137 |
138 | /**
139 | * Method used to delete an existing DSD.
140 | *
141 | * @param dsdId DSD unique identifier.
142 | */
143 | @Path("/{dsdId}")
144 | @DELETE
145 | public void removeDsd(@PathParam("dsdId") Integer dsdId);
146 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/java/org/ecommerce/rbac/api/management/RbacInheritanceManager.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.api.management;
2 |
3 | import javax.ws.rs.Consumes;
4 | import javax.ws.rs.DELETE;
5 | import javax.ws.rs.POST;
6 | import javax.ws.rs.Path;
7 | import javax.ws.rs.PathParam;
8 | import javax.ws.rs.Produces;
9 | import javax.ws.rs.core.MediaType;
10 |
11 | /**
12 | Copyright (C) 2011 by Radu Viorel Cosnita
13 |
14 | Permission is hereby granted, free of charge, to any person obtaining a copy
15 | of this software and associated documentation files (the "Software"), to deal
16 | in the Software without restriction, including without limitation the rights
17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18 | copies of the Software, and to permit persons to whom the Software is
19 | furnished to do so, subject to the following conditions:
20 |
21 | The above copyright notice and this permission notice shall be included in
22 | all copies or substantial portions of the Software.
23 |
24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30 | THE SOFTWARE.*/
31 |
32 | /**
33 | * This is the rbac inhertiance manager. Here you can find all required methods
34 | * that make this implementation fully compliant with RBAC 2.0 standard (from roles
35 | * general inheritance perspective).
36 | *
37 | * @author Radu Viorel Cosnita
38 | * @version 1.0
39 | * @since 02.10.2011
40 | * @see https://github.com/rcosnita/eCommerce-RBAC/wiki
41 | * @see https://github.com/rcosnita/eCommerce-RBAC/wiki/Rest-api
42 | * @see https://github.com/rcosnita/eCommerce-RBAC/wiki/Roles-hierarchy-rbac-support
43 | */
44 |
45 | @Path("/")
46 | @Produces(MediaType.APPLICATION_JSON)
47 | @Consumes(MediaType.APPLICATION_JSON)
48 | public interface RbacInheritanceManager {
49 | /**
50 | * Method used to add an inheritance relation between roleId and childId.
51 | *
52 | * @param roleId Role unique identifier. From here the permissions are inherited.
53 | * @param childId Child role unique identifier. Role specified by roleId
54 | * inherits all users from child role.
55 | */
56 | @Path("/{roleId}/{childId}")
57 | @POST
58 | public void addInheritance(
59 | @PathParam("roleId") Integer roleId,
60 | @PathParam("childId") Integer childId
61 | );
62 |
63 | /**
64 | * Method used to delete an inheritance relation.
65 | *
66 | * @param roleId Role unique identifier.
67 | * @param childId Child role unique identifier.
68 | */
69 | @Path("/{roleId}/{childId}")
70 | @DELETE
71 | public void deleteInheritance(
72 | @PathParam("roleId") Integer roleId,
73 | @PathParam("childId") Integer childId
74 | );
75 |
76 | /**
77 | * Method used to add a first level ascendant to the specified role.
78 | * All inheritance relations are rebuilt if necessary. This is fully compliant
79 | * with RBAC 2.0 standard.
80 | *
81 | * @param roleId Role unique identifier.
82 | * @param ascendantId Ascendant role unique identifier.
83 | */
84 | @Path("/{roleId}/ascendant/{ascendantId}")
85 | @POST
86 | public void addAscendant(
87 | @PathParam("roleId") Integer roleId,
88 | @PathParam("childId") Integer ascendantId
89 | );
90 |
91 | /**
92 | * Method used to add a first level descendant to the specified role.
93 | * All inheritance relations are rebuilt if necessary. This is fully compliant
94 | * with RBAC 2.0 standard.
95 | *
96 | * @param roleId
97 | * @param descendantId
98 | */
99 | @Path("/{roleId}/descendant/{descendantId}")
100 | @POST
101 | public void addDescendant(
102 | @PathParam("roleId") Integer roleId,
103 | @PathParam("descendantId") Integer descendantId
104 | );
105 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/java/org/ecommerce/rbac/api/management/RbacObjectsManager.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.api.management;
2 |
3 | import javax.ws.rs.Consumes;
4 | import javax.ws.rs.DELETE;
5 | import javax.ws.rs.GET;
6 | import javax.ws.rs.POST;
7 | import javax.ws.rs.PUT;
8 | import javax.ws.rs.Path;
9 | import javax.ws.rs.PathParam;
10 | import javax.ws.rs.Produces;
11 | import javax.ws.rs.QueryParam;
12 | import javax.ws.rs.core.MediaType;
13 |
14 | import org.ecommerce.rbac.dto.SecurityObject;
15 | import org.ecommerce.rbac.dto.SecurityObjects;
16 |
17 | /**
18 | Copyright (C) 2011 by Radu Viorel Cosnita
19 |
20 | Permission is hereby granted, free of charge, to any person obtaining a copy
21 | of this software and associated documentation files (the "Software"), to deal
22 | in the Software without restriction, including without limitation the rights
23 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
24 | copies of the Software, and to permit persons to whom the Software is
25 | furnished to do so, subject to the following conditions:
26 |
27 | The above copyright notice and this permission notice shall be included in
28 | all copies or substantial portions of the Software.
29 |
30 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
31 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
32 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
33 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
34 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
35 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
36 | THE SOFTWARE.*/
37 |
38 | /**
39 | * This is the rbac objects manager. Here you can find all required methods
40 | * that make this implementation fully compliant with RBAC 2.0 standard (from objects
41 | * perspective). Based on this interface you can generate a rest client really easy.
42 | *
43 | * @author Radu Viorel Cosnita
44 | * @version 1.0
45 | * @since 01.10.2011
46 | * @see https://github.com/rcosnita/eCommerce-RBAC/wiki/Rest-api
47 | */
48 |
49 | @Path("/")
50 | @Produces(MediaType.APPLICATION_JSON)
51 | @Consumes(MediaType.APPLICATION_JSON)
52 | public interface RbacObjectsManager {
53 | /**
54 | * Method used to obtain all objects defined in RBAC system.
55 | *
56 | * @return
57 | */
58 | @Path("/")
59 | @GET
60 | public SecurityObjects loadAllObjects();
61 |
62 | /**
63 | * Method used to obtain all objects defined in the RBAC system.
64 | *
65 | * @param startRecord the record from which we want to start retrieving objects.
66 | * @param pageSize the number of objects we want to retrieve.
67 | * @return
68 | */
69 | @Path("/{startRecord}/{pageSize}/")
70 | @GET
71 | public SecurityObjects loadAllObjects(
72 | @PathParam("startRecord") int startRecord,
73 | @PathParam("pageSize") int pageSize,
74 | @QueryParam("searchQuery") String searchCriteria);
75 |
76 | /**
77 | * Method used to load a specified object from RBAC.
78 | *
79 | * @param objectId Object unique identifier.
80 | * @return
81 | */
82 | @Path("/{objectId}")
83 | @GET
84 | public SecurityObject loadObjectById(@PathParam("objectId") Integer objectId);
85 |
86 | /**
87 | * Method used to create a new RBAC object.
88 | *
89 | * @param object An instance of SecurityObject.
90 | * @return The newly created object identifier.
91 | */
92 | @Path("/")
93 | @POST
94 | public int createNewObject(SecurityObject object);
95 |
96 | /**
97 | * Method used to update an existing RBAC object.
98 | *
99 | * @param objectId
100 | * @param object
101 | */
102 | @Path("/{objectId}")
103 | @PUT
104 | public void updateExistingObject(
105 | @PathParam("objectId") Integer objectId,
106 | SecurityObject object);
107 |
108 | /**
109 | * Method used to remove an object from the RBAC system.
110 | *
111 | * @param objectId Object unique identifier.
112 | */
113 | @Path("/{objectId}")
114 | @DELETE
115 | public void removeObject(@PathParam("objectId") Integer objectId);
116 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/java/org/ecommerce/rbac/api/management/RbacOperationsManager.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.api.management;
2 |
3 | import javax.ws.rs.Consumes;
4 | import javax.ws.rs.DELETE;
5 | import javax.ws.rs.GET;
6 | import javax.ws.rs.POST;
7 | import javax.ws.rs.PUT;
8 | import javax.ws.rs.Path;
9 | import javax.ws.rs.PathParam;
10 | import javax.ws.rs.Produces;
11 | import javax.ws.rs.core.MediaType;
12 |
13 | import org.ecommerce.rbac.dto.Operation;
14 | import org.ecommerce.rbac.dto.Operations;
15 |
16 | /**
17 | Copyright (C) 2011 by Radu Viorel Cosnita
18 |
19 | Permission is hereby granted, free of charge, to any person obtaining a copy
20 | of this software and associated documentation files (the "Software"), to deal
21 | in the Software without restriction, including without limitation the rights
22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23 | copies of the Software, and to permit persons to whom the Software is
24 | furnished to do so, subject to the following conditions:
25 |
26 | The above copyright notice and this permission notice shall be included in
27 | all copies or substantial portions of the Software.
28 |
29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
35 | THE SOFTWARE.*/
36 |
37 | /**
38 | * This is the rbac operations manager. Here you can find all required methods
39 | * that make this implementation fully compliant with RBAC 2.0 standard (from operations
40 | * perspective). Based on this interface you can generate a rest client really easy.
41 | *
42 | * @author Radu Viorel Cosnita
43 | * @version 1.0
44 | * @since 01.10.2011
45 | * @see https://github.com/rcosnita/eCommerce-RBAC/wiki/Rest-api
46 | */
47 |
48 | @Path("/")
49 | @Produces(MediaType.APPLICATION_JSON)
50 | @Consumes(MediaType.APPLICATION_JSON)
51 | public interface RbacOperationsManager {
52 | /**
53 | * Method used to load all defined operations.
54 | *
55 | * @return
56 | */
57 | @Path("/")
58 | @GET
59 | public Operations loadAllOperations();
60 |
61 | /**
62 | * Method used to load a specified operation.
63 | *
64 | * @param operationId Operation unique identifier.
65 | * @return
66 | */
67 | @Path("/{operationId}")
68 | @GET
69 | public Operation loadOperationById(
70 | @PathParam("operationId") Integer operationId);
71 |
72 | /**
73 | * Method used to create a new operation.
74 | *
75 | * @param operation An instance of Operation.
76 | */
77 | @Path("/")
78 | @POST
79 | public void createNewOperation(Operation operation);
80 |
81 | /**
82 | * Method used to update an existing operation.
83 | *
84 | * @param operationId Operation unique identifier.
85 | * @param operation Operation instance.
86 | */
87 | @Path("/{operationId}")
88 | @PUT
89 | public void updateExistingOperation(
90 | @PathParam("operationId") Integer operationId,
91 | Operation operation);
92 |
93 | /**
94 | * Method used to remove an existing operation.
95 | *
96 | * @param operationId
97 | */
98 | @Path("/{operationId}")
99 | @DELETE
100 | public void removeOperation(
101 | @PathParam("operationId") Integer operationId);
102 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/java/org/ecommerce/rbac/api/management/RbacPermissionsManager.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.api.management;
2 |
3 | import javax.ws.rs.Consumes;
4 | import javax.ws.rs.DELETE;
5 | import javax.ws.rs.GET;
6 | import javax.ws.rs.POST;
7 | import javax.ws.rs.PUT;
8 | import javax.ws.rs.Path;
9 | import javax.ws.rs.PathParam;
10 | import javax.ws.rs.Produces;
11 | import javax.ws.rs.core.MediaType;
12 |
13 | import org.ecommerce.rbac.dto.Operation;
14 | import org.ecommerce.rbac.dto.Permission;
15 | import org.ecommerce.rbac.dto.Permissions;
16 | import org.ecommerce.rbac.dto.Roles;
17 | import org.ecommerce.rbac.dto.SecurityObject;
18 |
19 | /**
20 | Copyright (C) 2011 by Radu Viorel Cosnita
21 |
22 | Permission is hereby granted, free of charge, to any person obtaining a copy
23 | of this software and associated documentation files (the "Software"), to deal
24 | in the Software without restriction, including without limitation the rights
25 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
26 | copies of the Software, and to permit persons to whom the Software is
27 | furnished to do so, subject to the following conditions:
28 |
29 | The above copyright notice and this permission notice shall be included in
30 | all copies or substantial portions of the Software.
31 |
32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
38 | THE SOFTWARE.*/
39 |
40 | /**
41 | * This is the rbac operations manager. Here you can find all required methods
42 | * that make this implementation fully compliant with RBAC 2.0 standard (from permissions
43 | * perspective). Based on this interface you can generate a rest client really easy.
44 | *
45 | * @author Radu Viorel Cosnita
46 | * @version 1.0
47 | * @since 01.10.2011
48 | * @see https://github.com/rcosnita/eCommerce-RBAC/wiki/Rest-api
49 | */
50 |
51 | @Path("/")
52 | @Produces(MediaType.APPLICATION_JSON)
53 | @Consumes(MediaType.APPLICATION_JSON)
54 | public interface RbacPermissionsManager {
55 | /**
56 | * Method used to load all permissions currently defined in RBAC system.
57 | *
58 | * @return
59 | */
60 | @Path("/")
61 | @GET
62 | public Permissions loadAllPermissions();
63 |
64 | /**
65 | * Method used to load a specified permission.
66 | *
67 | * @param permissionId Permission unique identifier.
68 | * @return
69 | */
70 | @Path("/{permissionId}")
71 | @GET
72 | public Permission loadPermissionById(@PathParam("permissionId") Integer permissionId);
73 |
74 | /**
75 | * Method used to load all roles that are granted with the specified permission.
76 | *
77 | * @param permissionId Permission unique identifier.
78 | * @return
79 | */
80 | @Path("/{permissionId}/roles")
81 | @GET
82 | public Roles loadRolesForPermission(@PathParam("permissionId") Integer permissionId);
83 |
84 | /**
85 | * Method used to load operation belonging to a permission.
86 | *
87 | * @param permissionId
88 | * @return
89 | */
90 | @Path("/{permissionId}/operation")
91 | @GET
92 | public Operation loadPermissionOperation(@PathParam("permissionId") Integer permissionId);
93 |
94 | /**
95 | * Method used to load object belonging to a permission.
96 | *
97 | * @param permissionId
98 | * @return
99 | */
100 | @Path("/{permissionId}/object")
101 | @GET
102 | public SecurityObject loadPermissionObject(@PathParam("permissionId") Integer permissionId);
103 |
104 | /**
105 | * Method used to create a new permission from a specified operation
106 | * and a specified object.
107 | *
108 | * @param operationId Operation unique identifier.
109 | * @param objectId Object unique identifier.
110 | * @param permission Permission instance.
111 | */
112 | @Path("{operationId}/{objectId}")
113 | @POST
114 | public int createNewPermissions(
115 | @PathParam("operationId") Integer operationId,
116 | @PathParam("objectId") Integer objectId,
117 | Permission permission);
118 |
119 | /**
120 | * Method used to update a specified permission.
121 | *
122 | * @param permissionId Permission unique identifier.
123 | * @param permission Permission instance.
124 | */
125 | @Path("/{permissionId}")
126 | @PUT
127 | public void updateExistingPermission(
128 | @PathParam("permissionId") Integer permissionId,
129 | Permission permission);
130 |
131 | /**
132 | * Method used to remove the specified permission.
133 | *
134 | * @param permissionId Permission unique identifier.
135 | */
136 | @Path("/{permissionId}")
137 | @DELETE
138 | public void removePermission(@PathParam("permissionId") Integer permissionId);
139 |
140 | /**
141 | * Method used to remove a given permission from all roles which are granted to use it.
142 | *
143 | * @param permissionId Permission unique identifier.
144 | */
145 | @Path("/{permissionId}/roles")
146 | @DELETE
147 | public void removePermissionFromRoles(@PathParam("permissionId") Integer permissionId);
148 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/java/org/ecommerce/rbac/dto/DynamicSeparationRule.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dto;
2 |
3 | import java.io.Serializable;
4 |
5 | import javax.xml.bind.annotation.XmlRootElement;
6 |
7 | /**
8 | Copyright (C) 2011 by Radu Viorel Cosnita
9 |
10 | Permission is hereby granted, free of charge, to any person obtaining a copy
11 | of this software and associated documentation files (the "Software"), to deal
12 | in the Software without restriction, including without limitation the rights
13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the Software is
15 | furnished to do so, subject to the following conditions:
16 |
17 | The above copyright notice and this permission notice shall be included in
18 | all copies or substantial portions of the Software.
19 |
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 | THE SOFTWARE.*/
27 |
28 | /**
29 | * This class is used to model a dynamic separation rule. This
30 | * class is fully compliant with RBAC 2.0 definition of DSD rules.
31 | *
32 | * @author Radu Viorel Cosnita
33 | * @version 1.0
34 | * @since 02.10.2011
35 | */
36 |
37 | @XmlRootElement(name="dynamic-separation-rule")
38 | public class DynamicSeparationRule implements Serializable {
39 | private Integer id;
40 | private String name;
41 | private Integer cardinality;
42 |
43 | public Integer getId() {
44 | return id;
45 | }
46 | public void setId(Integer id) {
47 | this.id = id;
48 | }
49 | public String getName() {
50 | return name;
51 | }
52 | public void setName(String name) {
53 | this.name = name;
54 | }
55 | public Integer getCardinality() {
56 | return cardinality;
57 | }
58 | public void setCardinality(Integer cardinality) {
59 | this.cardinality = cardinality;
60 | }
61 |
62 | @Override
63 | public String toString() {
64 | return String.format("DSD %s:%s with cardinality %s.",
65 | this.getId(), this.getName(), this.getCardinality());
66 | }
67 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/java/org/ecommerce/rbac/dto/DynamicSeparationRules.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dto;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | import javax.xml.bind.annotation.XmlElement;
8 | import javax.xml.bind.annotation.XmlElementWrapper;
9 | import javax.xml.bind.annotation.XmlRootElement;
10 |
11 | /**
12 | Copyright (C) 2011 by Radu Viorel Cosnita
13 |
14 | Permission is hereby granted, free of charge, to any person obtaining a copy
15 | of this software and associated documentation files (the "Software"), to deal
16 | in the Software without restriction, including without limitation the rights
17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18 | copies of the Software, and to permit persons to whom the Software is
19 | furnished to do so, subject to the following conditions:
20 |
21 | The above copyright notice and this permission notice shall be included in
22 | all copies or substantial portions of the Software.
23 |
24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30 | THE SOFTWARE.*/
31 |
32 | /**
33 | * Resource used to handle a list of DSD rules.
34 | *
35 | * @author Radu Viorel Cosnita
36 | * @version 1.0
37 | * @since 02.10.2011
38 | */
39 |
40 | @XmlRootElement(name="dynamic-separation-rules-array")
41 | public class DynamicSeparationRules implements Serializable {
42 | private List dsdRules = new ArrayList();
43 |
44 | @XmlElementWrapper(name="dynamic-separation-rules")
45 | @XmlElement(name="dynamic-separation-rule")
46 | public List getDsdRules() {
47 | return dsdRules;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/java/org/ecommerce/rbac/dto/Identifiers.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dto;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | import javax.xml.bind.annotation.XmlElement;
8 | import javax.xml.bind.annotation.XmlElementWrapper;
9 | import javax.xml.bind.annotation.XmlRootElement;
10 |
11 | @XmlRootElement(name="identifiers-array")
12 | public class Identifiers implements Serializable {
13 | private List identifiers = new ArrayList();
14 |
15 | @XmlElement(name="id")
16 | public List getIdentifiers() {
17 | return this.identifiers;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/java/org/ecommerce/rbac/dto/Operation.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dto;
2 |
3 | import java.io.Serializable;
4 |
5 | import javax.xml.bind.annotation.XmlRootElement;
6 |
7 | /**
8 | Copyright (C) 2011 by Radu Viorel Cosnita
9 |
10 | Permission is hereby granted, free of charge, to any person obtaining a copy
11 | of this software and associated documentation files (the "Software"), to deal
12 | in the Software without restriction, including without limitation the rights
13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the Software is
15 | furnished to do so, subject to the following conditions:
16 |
17 | The above copyright notice and this permission notice shall be included in
18 | all copies or substantial portions of the Software.
19 |
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 | THE SOFTWARE.*/
27 |
28 | /**
29 | * This is the operation resource as defined by RBAC standard.
30 | *
31 | * @author Radu Viorel Cosnita
32 | * @version 1.0
33 | * @since 01.11.2011
34 | */
35 | @XmlRootElement(name="operation")
36 | public class Operation implements Serializable {
37 | private Integer id;
38 | private String name;
39 |
40 | public Integer getId() {
41 | return id;
42 | }
43 | public void setId(Integer id) {
44 | this.id = id;
45 | }
46 | public String getName() {
47 | return name;
48 | }
49 | public void setName(String name) {
50 | this.name = name;
51 | }
52 |
53 | @Override
54 | public String toString() {
55 | return String.format("RBAC object %s:%s.", this.getId(), this.getName());
56 | }
57 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/java/org/ecommerce/rbac/dto/Operations.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dto;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | import javax.xml.bind.annotation.XmlElement;
8 | import javax.xml.bind.annotation.XmlElementWrapper;
9 | import javax.xml.bind.annotation.XmlRootElement;
10 |
11 | /**
12 | Copyright (C) 2011 by Radu Viorel Cosnita
13 |
14 | Permission is hereby granted, free of charge, to any person obtaining a copy
15 | of this software and associated documentation files (the "Software"), to deal
16 | in the Software without restriction, including without limitation the rights
17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18 | copies of the Software, and to permit persons to whom the Software is
19 | furnished to do so, subject to the following conditions:
20 |
21 | The above copyright notice and this permission notice shall be included in
22 | all copies or substantial portions of the Software.
23 |
24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30 | THE SOFTWARE.*/
31 |
32 | /**
33 | * This is the operations resource used for handling multiple operations
34 | * in the same time.
35 | *
36 | * @author Radu Viorel Cosnita
37 | * @version 1.0
38 | * @since 01.11.2011
39 | */
40 |
41 | @XmlRootElement(name="operations-array")
42 | public class Operations implements Serializable {
43 | private List operations = new ArrayList();
44 |
45 | @XmlElementWrapper(name="operations")
46 | @XmlElement(name="operation")
47 | public List getOperations() {
48 | return this.operations;
49 | }
50 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/java/org/ecommerce/rbac/dto/Permission.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dto;
2 |
3 | import java.io.Serializable;
4 |
5 | import javax.xml.bind.annotation.XmlRootElement;
6 |
7 | /**
8 | Copyright (C) 2011 by Radu Viorel Cosnita
9 |
10 | Permission is hereby granted, free of charge, to any person obtaining a copy
11 | of this software and associated documentation files (the "Software"), to deal
12 | in the Software without restriction, including without limitation the rights
13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the Software is
15 | furnished to do so, subject to the following conditions:
16 |
17 | The above copyright notice and this permission notice shall be included in
18 | all copies or substantial portions of the Software.
19 |
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 | THE SOFTWARE.*/
27 |
28 | /**
29 | * This is the permission entity as defined by RBAC standard.
30 | *
31 | * @author Radu Viorel Cosnita
32 | * @version 1.0
33 | * @since 01.11.2011
34 | */
35 |
36 | @XmlRootElement(name="permission")
37 | public class Permission implements Serializable {
38 | private Integer id;
39 | private String name;
40 | private SecurityObject object;
41 | private Operation operation;
42 |
43 | public Integer getId() {
44 | return id;
45 | }
46 | public void setId(Integer id) {
47 | this.id = id;
48 | }
49 | public String getName() {
50 | return name;
51 | }
52 | public void setName(String name) {
53 | this.name = name;
54 | }
55 | public SecurityObject getObject() {
56 | return object;
57 | }
58 | public void setObject(SecurityObject object) {
59 | this.object = object;
60 | }
61 | public Operation getOperation() {
62 | return operation;
63 | }
64 | public void setOperation(Operation operation) {
65 | this.operation = operation;
66 | }
67 |
68 | @Override
69 | public String toString() {
70 | return String.format("RBAC permission %s:%s.", this.getId(), this.getName());
71 | }
72 |
73 | @Override
74 | public boolean equals(Object obj) {
75 | if(obj instanceof Integer) {
76 | return this.getId() == Integer.class.cast(obj);
77 | }
78 | else if(obj instanceof String) {
79 | return this.getName().equalsIgnoreCase(obj.toString());
80 | }
81 | else if(obj instanceof Permission) {
82 | Permission perm = Permission.class.cast(obj);
83 |
84 | return perm.getId() == this.getId() ||
85 | this.getName().equalsIgnoreCase(perm.getName());
86 | }
87 |
88 | return super.equals(obj);
89 | }
90 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/java/org/ecommerce/rbac/dto/Permissions.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dto;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | import javax.xml.bind.annotation.XmlElement;
8 | import javax.xml.bind.annotation.XmlElementWrapper;
9 | import javax.xml.bind.annotation.XmlRootElement;
10 |
11 | /**
12 | Copyright (C) 2011 by Radu Viorel Cosnita
13 |
14 | Permission is hereby granted, free of charge, to any person obtaining a copy
15 | of this software and associated documentation files (the "Software"), to deal
16 | in the Software without restriction, including without limitation the rights
17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18 | copies of the Software, and to permit persons to whom the Software is
19 | furnished to do so, subject to the following conditions:
20 |
21 | The above copyright notice and this permission notice shall be included in
22 | all copies or substantial portions of the Software.
23 |
24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30 | THE SOFTWARE.*/
31 |
32 | /**
33 | * This is the permissions resource. It provides support for handling
34 | * multiple permissions simultaneously.
35 | *
36 | * @author Radu Viorel Cosnita
37 | * @version 1.0
38 | * @since 01.11.2011
39 | */
40 |
41 | @XmlRootElement(name="permissions-array")
42 | public class Permissions implements Serializable {
43 | private List permissions = new ArrayList();
44 |
45 | @XmlElementWrapper(name="permissions")
46 | @XmlElement(name="permission")
47 | public List getPermissions() {
48 | return this.permissions;
49 | }
50 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/java/org/ecommerce/rbac/dto/Role.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dto;
2 |
3 | import java.io.Serializable;
4 |
5 | import javax.xml.bind.annotation.XmlRootElement;
6 |
7 | /**
8 | Copyright (C) 2011 by Radu Viorel Cosnita
9 |
10 | Permission is hereby granted, free of charge, to any person obtaining a copy
11 | of this software and associated documentation files (the "Software"), to deal
12 | in the Software without restriction, including without limitation the rights
13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the Software is
15 | furnished to do so, subject to the following conditions:
16 |
17 | The above copyright notice and this permission notice shall be included in
18 | all copies or substantial portions of the Software.
19 |
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 | THE SOFTWARE.*/
27 |
28 | /**
29 | * This class is used to define role resource as defined by RBAC standard.
30 | *
31 | * @author Radu Viorel Cosnita
32 | * @version 1.0
33 | * @since 01.11.2011
34 | */
35 |
36 | @XmlRootElement(name="role")
37 | public class Role implements Serializable {
38 | private Integer id;
39 |
40 | /**
41 | * This attribute is not part of standard RBAC. We support it
42 | * for facilitating frontend development for this system.
43 | */
44 | private String name;
45 |
46 | public Integer getId() {
47 | return id;
48 | }
49 |
50 | public void setId(Integer id) {
51 | this.id = id;
52 | }
53 |
54 | public String getName() {
55 | return name;
56 | }
57 |
58 | public void setName(String name) {
59 | this.name = name;
60 | }
61 |
62 | @Override
63 | public String toString() {
64 | return String.format("Role %s:%s.", this.getId(), this.getName());
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/java/org/ecommerce/rbac/dto/Roles.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dto;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | import javax.xml.bind.annotation.XmlElement;
8 | import javax.xml.bind.annotation.XmlElementWrapper;
9 | import javax.xml.bind.annotation.XmlRootElement;
10 |
11 | /**
12 | Copyright (C) 2011 by Radu Viorel Cosnita
13 |
14 | Permission is hereby granted, free of charge, to any person obtaining a copy
15 | of this software and associated documentation files (the "Software"), to deal
16 | in the Software without restriction, including without limitation the rights
17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18 | copies of the Software, and to permit persons to whom the Software is
19 | furnished to do so, subject to the following conditions:
20 |
21 | The above copyright notice and this permission notice shall be included in
22 | all copies or substantial portions of the Software.
23 |
24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30 | THE SOFTWARE.*/
31 |
32 | /**
33 | * This class is used to define roles resource. It facilitate
34 | * sending lists of roles.
35 | *
36 | * @author Radu Viorel Cosnita
37 | * @version 1.0
38 | * @since 01.11.2011
39 | */
40 |
41 | @XmlRootElement(name="roles-array")
42 | public class Roles implements Serializable {
43 | private List roles = new ArrayList();
44 |
45 | @XmlElementWrapper(name="roles")
46 | @XmlElement(name="role")
47 | public List getRoles() {
48 | return this.roles;
49 | }
50 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/java/org/ecommerce/rbac/dto/SecurityObject.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dto;
2 |
3 | import java.io.Serializable;
4 |
5 | import javax.xml.bind.annotation.XmlRootElement;
6 |
7 | /**
8 | Copyright (C) 2011 by Radu Viorel Cosnita
9 |
10 | Permission is hereby granted, free of charge, to any person obtaining a copy
11 | of this software and associated documentation files (the "Software"), to deal
12 | in the Software without restriction, including without limitation the rights
13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the Software is
15 | furnished to do so, subject to the following conditions:
16 |
17 | The above copyright notice and this permission notice shall be included in
18 | all copies or substantial portions of the Software.
19 |
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 | THE SOFTWARE.*/
27 |
28 | /**
29 | * This is the object resource from RBAC standard.
30 | *
31 | * @author Radu Viorel Cosnita
32 | * @version 1.0
33 | * @since 01.11.2011
34 | */
35 |
36 | @XmlRootElement(name="security-object")
37 | public class SecurityObject implements Serializable {
38 | private Integer id;
39 | private String name;
40 | public Integer getId() {
41 | return id;
42 | }
43 | public void setId(Integer id) {
44 | this.id = id;
45 | }
46 | public String getName() {
47 | return name;
48 | }
49 | public void setName(String name) {
50 | this.name = name;
51 | }
52 |
53 | @Override
54 | public String toString() {
55 | return String.format("RBAC object %s:%s.", this.getId(), this.getName());
56 | }
57 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/java/org/ecommerce/rbac/dto/SecurityObjects.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dto;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | import javax.xml.bind.annotation.XmlElement;
8 | import javax.xml.bind.annotation.XmlElementWrapper;
9 | import javax.xml.bind.annotation.XmlRootElement;
10 |
11 | /**
12 | Copyright (C) 2011 by Radu Viorel Cosnita
13 |
14 | Permission is hereby granted, free of charge, to any person obtaining a copy
15 | of this software and associated documentation files (the "Software"), to deal
16 | in the Software without restriction, including without limitation the rights
17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18 | copies of the Software, and to permit persons to whom the Software is
19 | furnished to do so, subject to the following conditions:
20 |
21 | The above copyright notice and this permission notice shall be included in
22 | all copies or substantial portions of the Software.
23 |
24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30 | THE SOFTWARE.*/
31 |
32 | /**
33 | * This is the securityobjects resource. It provide support for handling
34 | * a list of RBAC objects in the same time.
35 | *
36 | * @author Radu Viorel Cosnita
37 | * @version 1.0
38 | * @since 01.11.2011
39 | */
40 |
41 | @XmlRootElement(name="security-objects-array")
42 | public class SecurityObjects implements Serializable {
43 | private List objects = new ArrayList();
44 |
45 | @XmlElementWrapper(name="security-objects")
46 | @XmlElement(name="security-object")
47 | public List getObjects() {
48 | return this.objects;
49 | }
50 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/java/org/ecommerce/rbac/dto/Session.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dto;
2 |
3 | import java.io.Serializable;
4 | import java.util.Date;
5 |
6 | import javax.xml.bind.annotation.XmlRootElement;
7 |
8 | /**
9 | Copyright (C) 2011 by Radu Viorel Cosnita
10 |
11 | Permission is hereby granted, free of charge, to any person obtaining a copy
12 | of this software and associated documentation files (the "Software"), to deal
13 | in the Software without restriction, including without limitation the rights
14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | copies of the Software, and to permit persons to whom the Software is
16 | furnished to do so, subject to the following conditions:
17 |
18 | The above copyright notice and this permission notice shall be included in
19 | all copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 | THE SOFTWARE.*/
28 |
29 | /**
30 | * This is the session resource from RBAC standard. In here we also support
31 | * some basic audit properties like: active session, start time, end time.
32 | *
33 | * @author Radu Viorel Cosnita
34 | * @version 1.0
35 | * @since 01.11.2011
36 | */
37 |
38 | @XmlRootElement(name="session")
39 | public class Session implements Serializable {
40 | private Integer id;
41 | private boolean active;
42 | private Date startTime;
43 | private Date endTime;
44 |
45 | /**
46 | * This attribute is nowhere mentioned in RBAC standard. It is used
47 | * for integrating with web frameworks that supports server side
48 | * session management.
49 | */
50 | private String remoteSession;
51 |
52 | public Integer getId() {
53 | return id;
54 | }
55 | public void setId(Integer id) {
56 | this.id = id;
57 | }
58 | public boolean isActive() {
59 | return active;
60 | }
61 | public void setActive(boolean active) {
62 | this.active = active;
63 | }
64 | public Date getStartTime() {
65 | return startTime;
66 | }
67 | public void setStartTime(Date startTime) {
68 | this.startTime = startTime;
69 | }
70 | public Date getEndTime() {
71 | return endTime;
72 | }
73 | public void setEndTime(Date endTime) {
74 | this.endTime = endTime;
75 | }
76 |
77 | public String getRemoteSession() {
78 | return remoteSession;
79 | }
80 | public void setRemoteSession(String remoteSession) {
81 | this.remoteSession = remoteSession;
82 | }
83 | @Override
84 | public String toString() {
85 | return String.format("Session %s started on %s.", this.getId(), this.getStartTime());
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/java/org/ecommerce/rbac/dto/Sessions.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dto;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | import javax.xml.bind.annotation.XmlElement;
8 | import javax.xml.bind.annotation.XmlElementWrapper;
9 | import javax.xml.bind.annotation.XmlRootElement;
10 |
11 | /**
12 | Copyright (C) 2011 by Radu Viorel Cosnita
13 |
14 | Permission is hereby granted, free of charge, to any person obtaining a copy
15 | of this software and associated documentation files (the "Software"), to deal
16 | in the Software without restriction, including without limitation the rights
17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18 | copies of the Software, and to permit persons to whom the Software is
19 | furnished to do so, subject to the following conditions:
20 |
21 | The above copyright notice and this permission notice shall be included in
22 | all copies or substantial portions of the Software.
23 |
24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30 | THE SOFTWARE.*/
31 |
32 | /**
33 | * This is the sessions resource. Used for handling multiple sessions in the
34 | * same time.
35 | *
36 | * @author Radu Viorel Cosnita
37 | * @version 1.0
38 | * @since 01.11.2011
39 | */
40 |
41 | @XmlRootElement(name="sessions-array")
42 | public class Sessions implements Serializable {
43 | private List sessions = new ArrayList();
44 |
45 | @XmlElementWrapper(name="sessions")
46 | @XmlElement(name="session")
47 | public List getSessions() {
48 | return this.sessions;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/java/org/ecommerce/rbac/dto/User.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dto;
2 |
3 | import java.io.Serializable;
4 |
5 | import javax.xml.bind.annotation.XmlRootElement;
6 |
7 | /**
8 | Copyright (C) 2011 by Radu Viorel Cosnita
9 |
10 | Permission is hereby granted, free of charge, to any person obtaining a copy
11 | of this software and associated documentation files (the "Software"), to deal
12 | in the Software without restriction, including without limitation the rights
13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the Software is
15 | furnished to do so, subject to the following conditions:
16 |
17 | The above copyright notice and this permission notice shall be included in
18 | all copies or substantial portions of the Software.
19 |
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 | THE SOFTWARE.*/
27 |
28 | /**
29 | * This is the user entity as used by clients of rbac system. It is possible
30 | * to support more attributes of an user in future releases.
31 | *
32 | * @author Radu Viorel Cosnita
33 | * @version 1.0
34 | * @since 01.11.2011
35 | */
36 |
37 | @XmlRootElement(name="user")
38 | public class User implements Serializable {
39 | private Integer id;
40 |
41 | public Integer getId() {
42 | return id;
43 | }
44 |
45 | public void setId(Integer id) {
46 | this.id = id;
47 | }
48 |
49 | @Override
50 | public String toString() {
51 | return String.format("User %s.", this.getId());
52 | }
53 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/java/org/ecommerce/rbac/dto/Users.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dto;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | import javax.xml.bind.annotation.XmlElement;
8 | import javax.xml.bind.annotation.XmlElementWrapper;
9 | import javax.xml.bind.annotation.XmlRootElement;
10 |
11 | /**
12 | Copyright (C) 2011 by Radu Viorel Cosnita
13 |
14 | Permission is hereby granted, free of charge, to any person obtaining a copy
15 | of this software and associated documentation files (the "Software"), to deal
16 | in the Software without restriction, including without limitation the rights
17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18 | copies of the Software, and to permit persons to whom the Software is
19 | furnished to do so, subject to the following conditions:
20 |
21 | The above copyright notice and this permission notice shall be included in
22 | all copies or substantial portions of the Software.
23 |
24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30 | THE SOFTWARE.*/
31 |
32 | /**
33 | * This class is used to define multiple users resource.
34 | *
35 | * @author Radu Viorel Cosnita
36 | * @version 1.0
37 | * @since 01.11.2011
38 | */
39 |
40 | @XmlRootElement(name="users-array")
41 | public class Users implements Serializable {
42 | private List users = new ArrayList();
43 |
44 | @XmlElementWrapper(name="users")
45 | @XmlElement(name="user")
46 | public List getUsers() {
47 | return users;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-api/src/main/resources/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Export-Package: org.ecommerce.rbac.api.management;uses:="javax.ws.rs,o
3 | rg.ecommerce.rbac.dto",org.ecommerce.rbac.api;uses:="org.ecommerce.rb
4 | ac.api.management",org.ecommerce.rbac.dto;uses:="javax.xml.bind.annot
5 | ation"
6 | Built-By: rcosnita
7 | Tool: Bnd-0.0.238
8 | Bundle-Name: ecommerce-rbac-api
9 | Created-By: Apache Maven Bundle Plugin
10 | Build-Jdk: 1.7.0_09
11 | Bundle-Version: 1.0.0.SNAPSHOT
12 | Bnd-LastModified: 1353019811333
13 | Bundle-ManifestVersion: 2
14 | Bundle-Description: This is the api for ecommerce rbac. You can find t
15 | he api and the transferable objects used within ecommerce role base
16 | d access control solution.
17 | Import-Package: javax.ws.rs,javax.xml.bind.annotation,org.ecommerce.rb
18 | ac.api,org.ecommerce.rbac.api.management,org.ecommerce.rbac.dto
19 | Bundle-SymbolicName: org.ecommerce.rbac.api.ecommerce-rbac-api
20 | Originally-Created-By: Apache Maven Bundle Plugin
21 |
22 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-dao/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-dao/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | ecommerce-rbac-dao
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.wst.common.project.facet.core.builder
10 |
11 |
12 |
13 |
14 | org.eclipse.jdt.core.javabuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.wst.validation.validationbuilder
20 |
21 |
22 |
23 |
24 | org.eclipse.m2e.core.maven2Builder
25 |
26 |
27 |
28 |
29 | org.springframework.ide.eclipse.core.springbuilder
30 |
31 |
32 |
33 |
34 |
35 | org.springframework.ide.eclipse.core.springnature
36 | org.eclipse.jem.workbench.JavaEMFNature
37 | org.eclipse.wst.common.modulecore.ModuleCoreNature
38 | org.eclipse.jdt.core.javanature
39 | org.eclipse.wst.common.project.facet.core.nature
40 | org.eclipse.m2e.core.maven2Nature
41 |
42 |
43 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-dao/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | #Wed Oct 05 23:03:13 EEST 2011
2 | eclipse.preferences.version=1
3 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
5 | org.eclipse.jdt.core.compiler.compliance=1.6
6 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
9 | org.eclipse.jdt.core.compiler.source=1.6
10 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-dao/.settings/org.eclipse.wst.common.component:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-dao/.settings/org.eclipse.wst.common.project.facet.core.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-dao/.settings/org.maven.ide.eclipse.prefs:
--------------------------------------------------------------------------------
1 | #Sun Oct 02 22:36:26 EEST 2011
2 | activeProfiles=
3 | eclipse.preferences.version=1
4 | fullBuildGoals=process-test-resources
5 | resolveWorkspaceProjects=true
6 | resourceFilterGoals=process-resources resources\:testResources
7 | skipCompilerPlugin=true
8 | version=1
9 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-dao/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | org.ecommerce.rbac.dao
6 | ecommerce-rbac-dao
7 | 1.0-SNAPSHOT
8 | jar
9 |
10 | ecommerce-rbac-dao
11 | This project holds DAO layer for this rbac implementation.
12 | https://github.com/rcosnita/eCommerce-RBAC/wiki/Core-rbac-support
13 |
14 |
15 | org.ecommerce.rbac.project
16 | ecommerce-rbac-project
17 | 1.0-SNAPSHOT
18 |
19 |
20 |
21 | UTF-8
22 |
23 |
24 |
25 |
26 | org.springframework
27 | spring-asm
28 |
29 |
30 | org.springframework
31 | spring-beans
32 |
33 |
34 | org.springframework
35 | spring-expression
36 |
37 |
38 | org.springframework
39 | spring-context
40 |
41 |
42 | org.springframework
43 | spring-context-support
44 |
45 |
46 | org.springframework
47 | spring-tx
48 | ${spring.framework.version}
49 | provided
50 |
51 |
52 |
53 | org.hibernate
54 | hibernate-entitymanager
55 |
56 |
57 |
58 | org.ecommerce.rbac.persistence
59 | ecommerce-rbac-entities
60 |
61 |
62 |
63 |
64 |
65 |
66 | org.apache.maven.plugins
67 | maven-compiler-plugin
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-dao/src/main/java/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Class-Path:
3 |
4 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-dao/src/main/java/org/ecommerce/rbac/dao/DynamicSeparationDutyDao.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dao;
2 |
3 | import java.util.List;
4 |
5 | import org.ecommerce.rbac.persistence.entities.DynamicSeparationDuty;
6 |
7 | /**
8 | Copyright (C) 2011 by Radu Viorel Cosnita
9 |
10 | Permission is hereby granted, free of charge, to any person obtaining a copy
11 | of this software and associated documentation files (the "Software"), to deal
12 | in the Software without restriction, including without limitation the rights
13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the Software is
15 | furnished to do so, subject to the following conditions:
16 |
17 | The above copyright notice and this permission notice shall be included in
18 | all copies or substantial portions of the Software.
19 |
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 | THE SOFTWARE.*/
27 |
28 | /**
29 | * Data access layer API for dynamic separation of duty (dsd).
30 | *
31 | * @author Radu Viorel Cosnita
32 | * @version 1.0
33 | * @since 08.10.2011
34 | */
35 |
36 | public interface DynamicSeparationDutyDao {
37 | /**
38 | * Method used to load all defined dsds.
39 | *
40 | * @return
41 | */
42 | public List loadAllDsd();
43 |
44 | /**
45 | * Method used to obtain a specified dsd.
46 | *
47 | * @param dsdId DSD unique identifier.
48 | * @return
49 | */
50 | public DynamicSeparationDuty loadDsdById(Integer dsdId);
51 |
52 | /**
53 | * Method used to create a new dynamic separation of duty from the
54 | * specified roles.
55 | *
56 | * @param dsd DSD instance.
57 | * @param roles A list of roles unique identifiers.
58 | */
59 | public void createNewDsd(DynamicSeparationDuty dsd, List roles);
60 |
61 | /**
62 | * Method used to assign new roles to a specified dsd.
63 | *
64 | * @param dsdId DSD unique identifier.
65 | * @param roles A list of roles to add.
66 | */
67 | public void assignNewRolesToDsd(Integer dsdId, List roles);
68 |
69 | /**
70 | * Method used to update an existing dsd.
71 | *
72 | * @param dsd DSD instance.
73 | */
74 | public void updateDsd(DynamicSeparationDuty dsd);
75 |
76 | /**
77 | * Method used to remove a specified dsd.
78 | *
79 | * @param dsdId DSD unique identifier.
80 | */
81 | public void removeDsd(Integer dsdId);
82 |
83 | /**
84 | * Method used to remove roles from a dsd.
85 | *
86 | * @param dsdId DSD unique identifier.
87 | * @param roles A list of roles to remove.
88 | */
89 | public void removeRolesFromDsd(Integer dsdId, List roles);
90 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-dao/src/main/java/org/ecommerce/rbac/dao/OperationsDao.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dao;
2 |
3 | import java.util.List;
4 |
5 | import org.ecommerce.rbac.persistence.entities.Operation;
6 |
7 | /**
8 | Copyright (C) 2011 by Radu Viorel Cosnita
9 |
10 | Permission is hereby granted, free of charge, to any person obtaining a copy
11 | of this software and associated documentation files (the "Software"), to deal
12 | in the Software without restriction, including without limitation the rights
13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the Software is
15 | furnished to do so, subject to the following conditions:
16 |
17 | The above copyright notice and this permission notice shall be included in
18 | all copies or substantial portions of the Software.
19 |
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 | THE SOFTWARE.*/
27 |
28 | /**
29 | * API for operations data access object layer.
30 | *
31 | * @author Radu Viorel Cosnita
32 | * @version 1.0
33 | * @since 1.0
34 | */
35 | public interface OperationsDao {
36 | /**
37 | * Method used to load all defined operations.
38 | *
39 | * @return
40 | */
41 | public List loadAllOperations();
42 |
43 | /**
44 | * Method used to load a specified operation.
45 | *
46 | * @param operationId Operation unique identifier.
47 | * @return
48 | */
49 | public Operation loadOperationById(Integer operationId);
50 |
51 | /**
52 | * Method used to create a new operation.
53 | *
54 | * @param operation Operation instance we want to add to database.
55 | */
56 | public void createNewOperation(Operation operation);
57 |
58 | /**
59 | * Method used to update an existing operation.
60 | *
61 | * @param operation Operation instance.
62 | */
63 | public void updateOperation(Operation operation);
64 |
65 | /**
66 | * Method used to remove a specified operation.
67 | *
68 | * @param operationId Operation unique identifier.
69 | */
70 | public void removeOperation(Integer operationId);
71 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-dao/src/main/java/org/ecommerce/rbac/dao/PermissionsDao.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dao;
2 |
3 | import java.util.List;
4 |
5 | import org.ecommerce.rbac.persistence.entities.Permission;
6 | import org.ecommerce.rbac.persistence.entities.Role;
7 |
8 | /**
9 | Copyright (C) 2011 by Radu Viorel Cosnita
10 |
11 | Permission is hereby granted, free of charge, to any person obtaining a copy
12 | of this software and associated documentation files (the "Software"), to deal
13 | in the Software without restriction, including without limitation the rights
14 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 | copies of the Software, and to permit persons to whom the Software is
16 | furnished to do so, subject to the following conditions:
17 |
18 | The above copyright notice and this permission notice shall be included in
19 | all copies or substantial portions of the Software.
20 |
21 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
24 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
25 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
26 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 | THE SOFTWARE.*/
28 |
29 | /**
30 | * API for permissions data access object layer.
31 | *
32 | * @author Radu Viorel Cosnita
33 | * @version 1.0
34 | * @since 03.10.2011
35 | */
36 | public interface PermissionsDao {
37 | /**
38 | * Method used to load all defined permissions.
39 | *
40 | * @return
41 | */
42 | public List loadAllPermissions();
43 |
44 | /**
45 | * Method used to load specified permission.
46 | *
47 | * @param permissionId Permission unique identifier.
48 | * @return
49 | */
50 | public Permission loadPermissionById(Integer permissionId);
51 |
52 | /**
53 | * Method used to load all roles that hold a given permission.
54 | *
55 | * @param permissionId Permission unique identifier.
56 | * @return
57 | */
58 | public List loadRolesForPermission(Integer permissionId);
59 |
60 | /**
61 | * Method used to create a new permission.
62 | *
63 | * @param operationId Operation unique identifier.
64 | * @param objectId Object unique identifier.
65 | * @param permission Permission instance.
66 | */
67 | public int createNewPermission(
68 | Integer operationId,
69 | Integer objectId,
70 | Permission permission);
71 |
72 | /**
73 | * Update an existing permission.
74 | *
75 | * @param permission A permission instance.
76 | */
77 | public void updatePermission(Permission permission);
78 |
79 | /**
80 | * Remove an existing permission.
81 | *
82 | * @param permissionId Permission unique identifier.
83 | */
84 | public void removePermission(Integer permissionId);
85 |
86 | /**
87 | * Removes a given permission from all roles who are granted to use it.
88 | *
89 | * @param permissionId Permission unique identifier.
90 | */
91 | public void removePermissionFromRoles(Integer permissionId);
92 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-dao/src/main/java/org/ecommerce/rbac/dao/RolesDao.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dao;
2 |
3 | import java.util.List;
4 | import java.util.Set;
5 |
6 | import javax.persistence.EntityExistsException;
7 | import javax.persistence.NoResultException;
8 |
9 | import org.ecommerce.rbac.persistence.entities.Operation;
10 | import org.ecommerce.rbac.persistence.entities.Role;
11 |
12 | /**
13 | Copyright (C) 2011 by Radu Viorel Cosnita
14 |
15 | Permission is hereby granted, free of charge, to any person obtaining a copy
16 | of this software and associated documentation files (the "Software"), to deal
17 | in the Software without restriction, including without limitation the rights
18 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19 | copies of the Software, and to permit persons to whom the Software is
20 | furnished to do so, subject to the following conditions:
21 |
22 | The above copyright notice and this permission notice shall be included in
23 | all copies or substantial portions of the Software.
24 |
25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
31 | THE SOFTWARE.*/
32 |
33 | /**
34 | * API for roles data access object layer.
35 | *
36 | * @author Radu Viorel Cosnita
37 | * @version 1.0
38 | * @since 02.10.2011
39 | */
40 | public interface RolesDao {
41 | /**
42 | * Method used to load all defined roles from database.
43 | *
44 | * @return
45 | */
46 | public List loadAllRoles();
47 |
48 | /**
49 | * Method used to load a specified role.
50 | *
51 | * @param roleId Role unique identiier.
52 | * @return
53 | * @throws NoResultException Thrown when role does not exist.
54 | */
55 | public Role loadRoleById(Integer roleId);
56 |
57 | /**
58 | * Method used to load a role by name.
59 | *
60 | * @param roleName Role name.
61 | * @return
62 | */
63 | public Role loadRoleByName(String roleName);
64 |
65 | /**
66 | * Method used to load all roles operations allowed for a specified
67 | * object.
68 | *
69 | * @param roleId Role unique identifier.
70 | * @param objectId RBAC object unique identifier.
71 | * @return
72 | */
73 | public List loadRoleOperationsAllowedForObject(Integer roleId,
74 | Integer objectId);
75 |
76 | /**
77 | * Method used to create a new role.
78 | *
79 | * @param role Role instance.
80 | * @return The newly created role unique identifier.
81 | *
82 | * @throws EntityExistsException Thrown when the role already exist.
83 | */
84 | public Integer createNewRole(Role role);
85 |
86 | /**
87 | * Method used to update an existing role.
88 | *
89 | * @param role Role instance.
90 | *
91 | * @throws NoResultException Thrown when role does not exist.
92 | */
93 | public void updateRole(Role role);
94 |
95 | /**
96 | * Method used to assign a list of users to a specified role.
97 | *
98 | * @param roleId Role unique identifier.
99 | * @param users A list of users.
100 | */
101 | public void assignUsersToRole(Integer roleId, List users);
102 |
103 | /**
104 | * Method used to assign a list of permissions to a specified role.
105 | *
106 | * @param roleId Role unique identifier.
107 | * @param permissions A list of permissions.
108 | */
109 | public void assignPermissionsToRole(Integer roleId, List permissions);
110 |
111 | /**
112 | * Method used to delete a role from database.
113 | *
114 | * @param roleId Role unique identifier.
115 | */
116 | public void removeRole(Integer roleId);
117 |
118 | /**
119 | * Method used to remove users from a role.
120 | *
121 | * @param roleId Role unique identifier.
122 | * @param users A list of users.
123 | */
124 | public void removeUsersFromRole(Integer roleId, List users);
125 |
126 | /**
127 | * Method used to remove permissions from a role.
128 | *
129 | * @param roleId Role unique identifier.
130 | * @param permissions A list of permissions.
131 | */
132 | public void removePermissionsFromRole(Integer roleId, List permissions);
133 | }
134 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-dao/src/main/java/org/ecommerce/rbac/dao/RolesInheritanceDao.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dao;
2 |
3 | /**
4 | Copyright (C) 2011 by Radu Viorel Cosnita
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files (the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included in
14 | all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 | THE SOFTWARE.*/
23 |
24 | /**
25 | * API for roles inheritance data access object. This DAO is managing
26 | * the inheritance relations between roles. Keep in mind that inheritance
27 | * from RBAC 2.0 standard is done on multiple levels.
28 | *
29 | * @author Radu Viorel Cosnita
30 | * @version 1.0
31 | * @since 10.10.2011
32 | */
33 |
34 | public interface RolesInheritanceDao {
35 | /**
36 | * Method used to create an inheritance relation.
37 | *
38 | * @param roleId Role unique identifier.
39 | * @param childId Child role unique identifier.
40 | */
41 | public void createInheritance(Integer roleId, Integer childId);
42 |
43 | /**
44 | * Method used to remove the inheritance relation between the roles specified.
45 | *
46 | * @param roleId Role unique identifier.
47 | * @param childId Child role unique identifier.
48 | */
49 | public void removeInheritance(Integer roleId, Integer childId);
50 |
51 | /**
52 | * Method used to add a direct ascendant of the specified role.
53 | *
54 | * @param roleId Role unique identifier.
55 | * @param ascendantId Ascendant role unique identifier.
56 | */
57 | public void addAscendant(Integer roleId, Integer ascendantId);
58 |
59 | /**
60 | * Method used to add a direct descendant for the specified role.
61 | *
62 | * @param roleId Role unique identifier.
63 | * @param descendantId Descendant unique identifier.
64 | */
65 | public void addDescendant(Integer roleId, Integer descendantId);
66 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-dao/src/main/java/org/ecommerce/rbac/dao/SecurityObjectsDao.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dao;
2 |
3 | import java.util.List;
4 |
5 | import org.ecommerce.rbac.persistence.entities.SecurityObject;
6 |
7 | /**
8 | Copyright (C) 2011 by Radu Viorel Cosnita
9 |
10 | Permission is hereby granted, free of charge, to any person obtaining a copy
11 | of this software and associated documentation files (the "Software"), to deal
12 | in the Software without restriction, including without limitation the rights
13 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 | copies of the Software, and to permit persons to whom the Software is
15 | furnished to do so, subject to the following conditions:
16 |
17 | The above copyright notice and this permission notice shall be included in
18 | all copies or substantial portions of the Software.
19 |
20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 | THE SOFTWARE.*/
27 |
28 | /**
29 | * API for security objects data access object layer.
30 | *
31 | * @author Radu Viorel Cosnita
32 | * @version 1.0
33 | * @since 02.10.2011
34 | */
35 | public interface SecurityObjectsDao {
36 | /**
37 | * Method used to retrieve all security objects from database.
38 | *
39 | * @return
40 | */
41 | public List loadAllObjects();
42 |
43 | /**
44 | * Method used to retrieve a slice of objects from database.
45 | *
46 | * @param startRecord The record from which we start retrieving objects.
47 | * @param pageSize The number of objects we want to retrieve.
48 | * @param searchQuery The text used for matching object name against.
49 | *
50 | * @return
51 | */
52 | public List loadAllObjects(int startRecord, int pageSize, String searchQuery);
53 |
54 | /**
55 | * Method used to load a specified object.
56 | *
57 | * @param objectId Object unique identifier.
58 | * @return
59 | */
60 | public SecurityObject loadObjectById(Integer objectId);
61 |
62 | /**
63 | * Method used to create a new security object.
64 | *
65 | * @param object SecurityObject instance.
66 | * @return The newly created object identifier.
67 | */
68 | public int createNewObject(SecurityObject object);
69 |
70 | /**
71 | * Method used to update a security object.
72 | *
73 | * @param object SecurityObject instance.
74 | */
75 | public void updateObject(SecurityObject object);
76 |
77 | /**
78 | * Method used to remove a specified security object.
79 | *
80 | * @param objectId SecurityObject unique identifier.
81 | */
82 | public void removeObject(Integer objectId);
83 | }
84 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-dao/src/main/java/org/ecommerce/rbac/dao/SessionsDao.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dao;
2 |
3 | import java.util.List;
4 | import java.util.Set;
5 |
6 | import org.ecommerce.rbac.persistence.entities.Permission;
7 | import org.ecommerce.rbac.persistence.entities.Role;
8 | import org.ecommerce.rbac.persistence.entities.Session;
9 |
10 | /**
11 | Copyright (C) 2011 by Radu Viorel Cosnita
12 |
13 | Permission is hereby granted, free of charge, to any person obtaining a copy
14 | of this software and associated documentation files (the "Software"), to deal
15 | in the Software without restriction, including without limitation the rights
16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 | copies of the Software, and to permit persons to whom the Software is
18 | furnished to do so, subject to the following conditions:
19 |
20 | The above copyright notice and this permission notice shall be included in
21 | all copies or substantial portions of the Software.
22 |
23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 | THE SOFTWARE.*/
30 |
31 | /**
32 | * API for sessions data access object layer.
33 | *
34 | * @author Radu Viorel Cosnita
35 | * @version 1.0
36 | * @since 1.0
37 | */
38 | public interface SessionsDao {
39 | /**
40 | * Load all sessions belonging to a specified user.
41 | *
42 | * @param userId User unique identifier.
43 | * @param onlyActive Only active flag.
44 | * @return
45 | */
46 | public List loadSessionsByUser(Integer userId, Boolean onlyActive);
47 |
48 | /**
49 | * Method used to load all roles belonging to a specified session.
50 | *
51 | * @param sessionId Session unique identifier.
52 | * @param onlyActive Only active flag.
53 | * @return
54 | */
55 | public Set loadSessionRoles(Integer sessionId, Boolean onlyActive);
56 |
57 | /**
58 | * Method used to load all permissions belonging to a session.
59 | *
60 | * @param sessionId Session unique identifier.
61 | * @param onlyActive Only active flag.
62 | * @return
63 | */
64 | public List loadSessionPermissions(Integer sessionId, Boolean onlyActive);
65 |
66 | /**
67 | * Method used to check if a permission is enabled within a session.
68 | *
69 | * @param sessionId Session unique identifier.
70 | * @param permissionId Permission unique identifier.
71 | * @param onlyActive
72 | * @return
73 | */
74 | public Boolean checkSessionPermissionEnabled(
75 | Integer sessionId,
76 | Integer permissionId,
77 | boolean onlyActive);
78 |
79 | /**
80 | * Method used to create a new user session. It enables all non conflicting roles
81 | * if flag activateRoles is enabled.
82 | *
83 | * @param userId User unique identifier.
84 | * @param activateRoles Flag that signal activation of non conflicting roles.
85 | * @param remoteSession This is a remote session unique identifier (jsessionid possibly).
86 | * @return
87 | */
88 | public Integer createUserSession(Integer userId, Boolean activateRoles,
89 | String remoteSession);
90 |
91 | /**
92 | * Method used to activate a new role within the current session.
93 | *
94 | * @param sessionId Session unique identifier.
95 | * @param roleId Role unique identifier.
96 | * @param useInheritance Flag used to determine if activation of descendants is desired
97 | * or not.
98 | */
99 | public void activateSessionRole(Integer sessionId, Integer roleId,
100 | boolean useInheritance);
101 |
102 | /**
103 | * Method used to stop a specified session.
104 | *
105 | * @param sessionId Session unique identifier.
106 | */
107 | public void stopSession(Integer sessionId);
108 |
109 | /**
110 | * Method used to deactivate a specified role from a session.
111 | *
112 | * @param sessionId Session unique identifier.
113 | * @param roleId Role unique identifier.
114 | */
115 | public void deactivateSessionRole(Integer sessionId, Integer roleId);
116 | }
117 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-dao/src/main/java/org/ecommerce/rbac/dao/UsersDao.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dao;
2 |
3 | import java.util.List;
4 |
5 | import javax.persistence.NoResultException;
6 |
7 | import org.ecommerce.rbac.persistence.entities.Operation;
8 | import org.ecommerce.rbac.persistence.entities.Permission;
9 | import org.ecommerce.rbac.persistence.entities.User;
10 |
11 | /**
12 | Copyright (C) 2011 by Radu Viorel Cosnita
13 |
14 | Permission is hereby granted, free of charge, to any person obtaining a copy
15 | of this software and associated documentation files (the "Software"), to deal
16 | in the Software without restriction, including without limitation the rights
17 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18 | copies of the Software, and to permit persons to whom the Software is
19 | furnished to do so, subject to the following conditions:
20 |
21 | The above copyright notice and this permission notice shall be included in
22 | all copies or substantial portions of the Software.
23 |
24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30 | THE SOFTWARE.*/
31 |
32 | /**
33 | * API for data access object that allows users management.
34 | *
35 | * @author Radu Viorel Cosnita
36 | * @version 1.0
37 | * @since 02.10.2011
38 | */
39 | public interface UsersDao {
40 | /**
41 | * Method used to load all users from database.
42 | *
43 | * @return
44 | */
45 | public List loadAllUsers();
46 |
47 | /**
48 | * Method used to obtain from database a slice of users.
49 | *
50 | * @param pageSize
51 | * @param startRecord
52 | * @return
53 | */
54 | public List loadAllUsers(int pageSize, int startRecord);
55 |
56 | /**
57 | * Method used to load a specified user.
58 | *
59 | * @param id User unique identifier.
60 | * @return
61 | */
62 | public User loadUserById(Integer id);
63 |
64 | /**
65 | * Method used to load all permissions for a specified user.
66 | *
67 | * @param userId User unique identifier.
68 | * @return
69 | */
70 | public List loadUserPermissions(Integer userId);
71 |
72 | /**
73 | * Method used to load all operations for an object assigned to an user.
74 | *
75 | * @param userId User unique identifier.
76 | * @param objectId Object unique identifier.
77 | * @return
78 | */
79 | public List loadUserOperationForObject(Integer userId, Integer objectId);
80 |
81 | /**
82 | * Method used to create a new user.
83 | *
84 | * @param user An user instance.
85 | *
86 | * @throws UnsupportedOperationException if user id is not specified.
87 | */
88 | public void createNewUser(User user);
89 |
90 | /**
91 | * Method used to update an existing user.
92 | *
93 | * @param user An user instance.
94 | *
95 | * @throws NoResultException if user can not be found.
96 | */
97 | public void updateUser(User user);
98 |
99 | /**
100 | * Method used to remove an existing user.
101 | *
102 | * @param userId User unique identifier.
103 | */
104 | public void deleteUser(Integer userId);
105 |
106 | /**
107 | * Method used to remove all roles from a given user.
108 | *
109 | * @param userId User unique identifier.
110 | */
111 | public void clearUserRoles(Integer userId);
112 |
113 | /**
114 | * Method used to stop all user active sessions using a single transaction.
115 | *
116 | * @param id User unique identifier.
117 | *
118 | * @throws NoResultException if user can not be found.
119 | */
120 | public void stopUserSessions(Integer id);
121 | }
122 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-dao/src/main/java/org/ecommerce/rbac/dao/impl/OperationsDaoImpl.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dao.impl;
2 |
3 | import java.util.List;
4 | import java.util.logging.Logger;
5 |
6 | import javax.persistence.EntityManager;
7 | import javax.persistence.NoResultException;
8 | import javax.persistence.PersistenceContext;
9 | import javax.persistence.Query;
10 | import javax.persistence.TypedQuery;
11 |
12 | import org.ecommerce.rbac.dao.OperationsDao;
13 | import org.ecommerce.rbac.persistence.entities.Operation;
14 | import org.ecommerce.rbac.persistence.entities.Role;
15 | import org.springframework.stereotype.Repository;
16 | import org.springframework.transaction.annotation.Transactional;
17 |
18 | /**
19 | Copyright (C) 2011 by Radu Viorel Cosnita
20 |
21 | Permission is hereby granted, free of charge, to any person obtaining a copy
22 | of this software and associated documentation files (the "Software"), to deal
23 | in the Software without restriction, including without limitation the rights
24 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
25 | copies of the Software, and to permit persons to whom the Software is
26 | furnished to do so, subject to the following conditions:
27 |
28 | The above copyright notice and this permission notice shall be included in
29 | all copies or substantial portions of the Software.
30 |
31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
32 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
33 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
34 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
35 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
36 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
37 | THE SOFTWARE.*/
38 |
39 | /**
40 | * Operations DAO implementation.
41 | *
42 | * @author Radu Viorel Cosnita
43 | * @version 1.0
44 | * @since 05.10.2011
45 | */
46 |
47 | @Repository("operationsDaoBean")
48 | public class OperationsDaoImpl implements OperationsDao {
49 | private final static Logger logger = Logger.getLogger(OperationsDaoImpl.class.getName());
50 |
51 | private EntityManager entityManager;
52 |
53 | public EntityManager getEntityManager() {
54 | return entityManager;
55 | }
56 |
57 | @PersistenceContext
58 | public void setEntityManager(EntityManager entityManager) {
59 | this.entityManager = entityManager;
60 | }
61 |
62 | /**
63 | * {@inheritDoc}
64 | */
65 | @Override
66 | public List loadAllOperations() {
67 | logger.info("JPA loading all operations.");
68 |
69 | TypedQuery query = getEntityManager().createNamedQuery("Operations.loadAll",
70 | Operation.class);
71 |
72 | return query.getResultList();
73 | }
74 |
75 | /**
76 | * {@inheritDoc}
77 | */
78 | @Override
79 | public Operation loadOperationById(Integer operationId) {
80 | logger.info(String.format("JPA Loading operation %s.", operationId));
81 |
82 | Operation operation = getEntityManager().find(Operation.class, operationId);
83 |
84 | if(operation == null) {
85 | throw new NoResultException(String.format("Operation %s does not exist.", operationId));
86 | }
87 |
88 | return operation;
89 | }
90 |
91 | /**
92 | * {@inheritDoc}
93 | */
94 | @Override
95 | @Transactional
96 | public void createNewOperation(Operation operation) {
97 | logger.info(String.format("JPA creating operation %s.", operation.getName()));
98 |
99 | if(operation.getId() != null) {
100 | throw new UnsupportedOperationException("You must not specify operation id.");
101 | }
102 |
103 | getEntityManager().persist(operation);
104 | }
105 |
106 | /**
107 | * {@inheritDoc}
108 | */
109 | @Override
110 | @Transactional
111 | public void updateOperation(Operation operation) {
112 | logger.info(String.format("JPA updating operation %s.", operation.getName()));
113 |
114 | if(operation.getId() == null) {
115 | throw new UnsupportedOperationException("You must specify operation id.");
116 | }
117 |
118 | Operation operationEntity = this.loadOperationById(operation.getId());
119 | operationEntity.setName(operation.getName());
120 |
121 | getEntityManager().merge(operationEntity);
122 | }
123 |
124 | /**
125 | * {@inheritDoc}
126 | */
127 | @Override
128 | @Transactional
129 | public void removeOperation(Integer operationId) {
130 | logger.info(String.format("JPA deleting operation %s.", operationId));
131 |
132 | Operation operation = getEntityManager().find(Operation.class, operationId);
133 |
134 | if(operation == null) {
135 | throw new NoResultException(String.format("Operation %s does not exist."));
136 | }
137 |
138 | getEntityManager().remove(operation);
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-dao/src/main/java/org/ecommerce/rbac/dao/impl/SecurityObjectsDaoImpl.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.dao.impl;
2 |
3 | import java.util.List;
4 | import java.util.logging.Logger;
5 |
6 | import javax.persistence.EntityManager;
7 | import javax.persistence.NoResultException;
8 | import javax.persistence.PersistenceContext;
9 | import javax.persistence.TypedQuery;
10 |
11 | import org.ecommerce.rbac.dao.SecurityObjectsDao;
12 | import org.ecommerce.rbac.persistence.entities.SecurityObject;
13 | import org.springframework.stereotype.Repository;
14 | import org.springframework.transaction.annotation.Transactional;
15 |
16 | /**
17 | Copyright (C) 2011 by Radu Viorel Cosnita
18 |
19 | Permission is hereby granted, free of charge, to any person obtaining a copy
20 | of this software and associated documentation files (the "Software"), to deal
21 | in the Software without restriction, including without limitation the rights
22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23 | copies of the Software, and to permit persons to whom the Software is
24 | furnished to do so, subject to the following conditions:
25 |
26 | The above copyright notice and this permission notice shall be included in
27 | all copies or substantial portions of the Software.
28 |
29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
35 | THE SOFTWARE.*/
36 |
37 | /**
38 | * SecurityObjects DAO implementation.
39 | *
40 | * @author Radu Viorel Cosnita
41 | * @version 1.0
42 | * @since 05.10.2011
43 | */
44 |
45 | @Repository("securityObjectsDaoBean")
46 | public class SecurityObjectsDaoImpl implements SecurityObjectsDao {
47 | private final static Logger logger = Logger.getLogger(SecurityObjectsDaoImpl.class.getName());
48 |
49 | private EntityManager entityManager;
50 |
51 | public EntityManager getEntityManager() {
52 | return entityManager;
53 | }
54 |
55 | @PersistenceContext
56 | public void setEntityManager(EntityManager entityManager) {
57 | this.entityManager = entityManager;
58 | }
59 |
60 | /**
61 | * {@inheritDoc}
62 | */
63 | @Override
64 | public List loadAllObjects() {
65 | logger.info("JPA loading all security objects.");
66 |
67 | TypedQuery query =
68 | getEntityManager().createNamedQuery("SecurityObject.loadAll", SecurityObject.class);
69 |
70 | return query.getResultList();
71 | }
72 |
73 | /**
74 | * {@inheritDoc}
75 | */
76 | @Override
77 | public List loadAllObjects(int startRecord, int pageSize, String searchQuery) {
78 | logger.info(String.format("JPA loading %s security objects starting from %s.", pageSize, startRecord, searchQuery));
79 |
80 | TypedQuery query =
81 | getEntityManager().createNamedQuery("SecurityObject.loadAllPaginated", SecurityObject.class);
82 | query.setParameter("searchQuery", searchQuery);
83 | query.setFirstResult(startRecord);
84 | query.setMaxResults(pageSize);
85 |
86 | return query.getResultList();
87 | }
88 |
89 |
90 | /**
91 | * {@inheritDoc}
92 | */
93 | @Override
94 | public SecurityObject loadObjectById(Integer objectId) {
95 | logger.info(String.format("JPA loading object %s.", objectId));
96 |
97 | SecurityObject object = getEntityManager().find(SecurityObject.class, objectId);
98 |
99 | if(object == null) {
100 | throw new NoResultException(String.format("Object %s not found.", objectId));
101 | }
102 |
103 | return object;
104 | }
105 |
106 | /**
107 | * {@inheritDoc}
108 | */
109 | @Override
110 | @Transactional
111 | public int createNewObject(SecurityObject object) {
112 | logger.info(String.format("JPA creating new object %s.", object.getName()));
113 |
114 | if(object.getId() != null) {
115 | throw new UnsupportedOperationException("You must not specify object id.");
116 | }
117 |
118 | getEntityManager().persist(object);
119 |
120 | return object.getId();
121 | }
122 |
123 | /**
124 | * {@inheritDoc}
125 | */
126 | @Override
127 | @Transactional
128 | public void updateObject(SecurityObject object) {
129 | logger.info(String.format("JPA creating new object %s.", object.getName()));
130 |
131 | if(object.getId() == null) {
132 | throw new UnsupportedOperationException("You must specify object id.");
133 | }
134 |
135 | SecurityObject objEntity = this.loadObjectById(object.getId());
136 | objEntity.setName(object.getName());
137 |
138 | getEntityManager().merge(objEntity);
139 | }
140 |
141 | /**
142 | * {@inheritDoc}
143 | */
144 | @Override
145 | @Transactional
146 | public void removeObject(Integer objectId) {
147 | logger.info(String.format("JPA removing object %s.", objectId));
148 |
149 | SecurityObject object = getEntityManager().find(SecurityObject.class, objectId);
150 |
151 | if(object == null) {
152 | throw new NoResultException(String.format("Object %s not found.", object));
153 | }
154 |
155 | getEntityManager().remove(object);
156 | }
157 |
158 |
159 | }
160 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-entities/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-entities/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | ecommerce-rbac-entities
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.wst.common.project.facet.core.builder
10 |
11 |
12 |
13 |
14 | org.eclipse.jdt.core.javabuilder
15 |
16 |
17 |
18 |
19 | org.eclipse.wst.validation.validationbuilder
20 |
21 |
22 |
23 |
24 | org.eclipse.m2e.core.maven2Builder
25 |
26 |
27 |
28 |
29 |
30 | org.eclipse.jem.workbench.JavaEMFNature
31 | org.eclipse.wst.common.modulecore.ModuleCoreNature
32 | org.eclipse.jdt.core.javanature
33 | org.eclipse.wst.common.project.facet.core.nature
34 | org.eclipse.m2e.core.maven2Nature
35 |
36 |
37 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-entities/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | #Wed Feb 22 22:15:29 EET 2012
2 | eclipse.preferences.version=1
3 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
5 | org.eclipse.jdt.core.compiler.compliance=1.6
6 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
9 | org.eclipse.jdt.core.compiler.source=1.6
10 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-entities/.settings/org.eclipse.wst.common.component:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-entities/.settings/org.eclipse.wst.common.project.facet.core.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-entities/.settings/org.maven.ide.eclipse.prefs:
--------------------------------------------------------------------------------
1 | #Sun Oct 02 12:17:44 EEST 2011
2 | activeProfiles=
3 | eclipse.preferences.version=1
4 | fullBuildGoals=process-test-resources
5 | resolveWorkspaceProjects=true
6 | resourceFilterGoals=process-resources resources\:testResources
7 | skipCompilerPlugin=true
8 | version=1
9 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-entities/.springBeans:
--------------------------------------------------------------------------------
1 |
2 |
3 | 1
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-entities/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | org.ecommerce.rbac.persistence
6 | ecommerce-rbac-entities
7 | 1.0-SNAPSHOT
8 | jar
9 |
10 | ecommerce-rbac-entities
11 | This project holds all entities required to build the persistence layer for rbac system.
12 | https://github.com/rcosnita/eCommerce-RBAC/wiki
13 |
14 |
15 | org.ecommerce.rbac.project
16 | ecommerce-rbac-project
17 | 1.0-SNAPSHOT
18 |
19 |
20 |
21 | UTF-8
22 |
23 |
24 |
25 |
26 | rcosnita
27 | Cosnita Radu Viorel
28 | radu.cosnita@gmail.com
29 |
30 | Architect
31 | Developer
32 | Analyst
33 |
34 |
35 |
36 |
37 |
38 |
39 | org.ecommerce.rbac.api
40 | ecommerce-rbac-api
41 |
42 |
43 |
44 | org.hibernate
45 | hibernate-entitymanager
46 |
47 |
48 |
49 | org.slf4j
50 | slf4j-simple
51 |
52 |
53 |
54 | org.slf4j
55 | slf4j-api
56 |
57 |
58 |
59 | junit
60 | junit
61 |
62 |
63 |
64 | mysql
65 | mysql-connector-java
66 |
67 |
68 |
69 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-entities/src/main/java/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Class-Path:
3 |
4 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-entities/src/main/java/org/ecommerce/rbac/persistence/entities/DynamicSeparationDuty.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.persistence.entities;
2 |
3 | import java.util.Set;
4 |
5 | import javax.persistence.Column;
6 | import javax.persistence.Entity;
7 | import javax.persistence.GeneratedValue;
8 | import javax.persistence.GenerationType;
9 | import javax.persistence.Id;
10 | import javax.persistence.JoinColumn;
11 | import javax.persistence.JoinTable;
12 | import javax.persistence.ManyToMany;
13 | import javax.persistence.NamedQueries;
14 | import javax.persistence.NamedQuery;
15 | import javax.persistence.Table;
16 |
17 | import org.ecommerce.rbac.dto.DynamicSeparationRule;
18 |
19 | /**
20 | Copyright (C) 2011 by Radu Viorel Cosnita
21 |
22 | Permission is hereby granted, free of charge, to any person obtaining a copy
23 | of this software and associated documentation files (the "Software"), to deal
24 | in the Software without restriction, including without limitation the rights
25 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
26 | copies of the Software, and to permit persons to whom the Software is
27 | furnished to do so, subject to the following conditions:
28 |
29 | The above copyright notice and this permission notice shall be included in
30 | all copies or substantial portions of the Software.
31 |
32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
38 | THE SOFTWARE.*/
39 |
40 | /**
41 | * Class used to model dynamic separation of duty data model.
42 | *
43 | * @author Radu Viorel Cosnita
44 | * @version 1.0
45 | * @since 02.10.2011
46 | */
47 |
48 | @Entity
49 | @Table(name="DynamicSeparationDutySet")
50 | @NamedQueries({
51 | @NamedQuery(name="DSD.loadAll",
52 | query="SELECT obj FROM DynamicSeparationDuty obj ORDER BY obj.name")
53 | })
54 | public class DynamicSeparationDuty {
55 | @Id
56 | @GeneratedValue(strategy=GenerationType.AUTO)
57 | @Column(name="id")
58 | private Integer id;
59 |
60 | @Column(name="name")
61 | private String name;
62 |
63 | @Column(name="cardinality")
64 | private int cardinality;
65 |
66 | /**
67 | * These are the roles included into this dynamic separation of duty
68 | * rule.
69 | */
70 | @ManyToMany
71 | @JoinTable(name="DynamicSeparationDutySetRoles",
72 | joinColumns={@JoinColumn(name="dsd_id", referencedColumnName="id")},
73 | inverseJoinColumns={@JoinColumn(name="role_id", referencedColumnName="id")})
74 | private Set roles;
75 |
76 | public Integer getId() {
77 | return id;
78 | }
79 |
80 | public void setId(Integer id) {
81 | this.id = id;
82 | }
83 |
84 | public String getName() {
85 | return name;
86 | }
87 |
88 | public void setName(String name) {
89 | this.name = name;
90 | }
91 |
92 | public int getCardinality() {
93 | return cardinality;
94 | }
95 |
96 | public void setCardinality(int cardinality) {
97 | this.cardinality = cardinality;
98 | }
99 |
100 | public Set getRoles() {
101 | return roles;
102 | }
103 |
104 | public void setRoles(Set roles) {
105 | this.roles = roles;
106 | }
107 |
108 | /**
109 | * Method used to transform this entity to a transferable object.
110 | *
111 | * @return
112 | */
113 | public DynamicSeparationRule toDynamicSeparationDTO() {
114 | DynamicSeparationRule rule = new DynamicSeparationRule();
115 |
116 | rule.setId(this.getId());
117 | rule.setName(this.getName());
118 | rule.setCardinality(this.getCardinality());
119 |
120 | return rule;
121 | }
122 |
123 | /**
124 | * Method used to obtain an entity from a DTO object.
125 | *
126 | * @param rule
127 | * @return
128 | */
129 | public static DynamicSeparationDuty valueOf(DynamicSeparationRule rule) {
130 | DynamicSeparationDuty ret = new DynamicSeparationDuty();
131 |
132 | ret.setId(rule.getId());
133 | ret.setName(rule.getName());
134 | ret.setCardinality(rule.getCardinality());
135 |
136 | return ret;
137 | }
138 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-entities/src/main/java/org/ecommerce/rbac/persistence/entities/Operation.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.persistence.entities;
2 |
3 | import java.util.List;
4 |
5 | import javax.persistence.Column;
6 | import javax.persistence.Entity;
7 | import javax.persistence.GeneratedValue;
8 | import javax.persistence.GenerationType;
9 | import javax.persistence.Id;
10 | import javax.persistence.NamedQueries;
11 | import javax.persistence.NamedQuery;
12 | import javax.persistence.OneToMany;
13 | import javax.persistence.Table;
14 |
15 | /**
16 | Copyright (C) 2011 by Radu Viorel Cosnita
17 |
18 | Permission is hereby granted, free of charge, to any person obtaining a copy
19 | of this software and associated documentation files (the "Software"), to deal
20 | in the Software without restriction, including without limitation the rights
21 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22 | copies of the Software, and to permit persons to whom the Software is
23 | furnished to do so, subject to the following conditions:
24 |
25 | The above copyright notice and this permission notice shall be included in
26 | all copies or substantial portions of the Software.
27 |
28 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
34 | THE SOFTWARE.*/
35 |
36 | /**
37 | * Class that defines the data model for a RBAC operation.
38 | *
39 | * @author Radu Viorel Cosnita
40 | * @version 1.0
41 | * @since 02.10.2011
42 | */
43 |
44 | @Entity
45 | @Table(name="Operations")
46 | @NamedQueries({
47 | @NamedQuery(name="Operations.loadAll", query="SELECT obj FROM Operation obj ORDER BY obj.name"),
48 | @NamedQuery(name="Operations.loadAllowedForRoleObject",
49 | query="SELECT oper FROM Operation oper " +
50 | "INNER JOIN oper.permissions perm " +
51 | "INNER JOIN perm.roles role " +
52 | "INNER JOIN perm.object obj " +
53 | "WHERE obj.id = :objectId and role.id = :roleId"),
54 | @NamedQuery(name="Operations.loadUserOperationsForObject",
55 | query="SELECT oper FROM Operation oper " +
56 | "INNER JOIN oper.permissions perm " +
57 | "INNER JOIN perm.object obj " +
58 | "INNER JOIN perm.roles role " +
59 | "INNER JOIN role.assignedUsers user " +
60 | "WHERE user.id = :userId AND obj.id = :objectId")
61 | })
62 | public class Operation {
63 | @Id
64 | @GeneratedValue(strategy=GenerationType.AUTO)
65 | @Column(name="id")
66 | private Integer id;
67 |
68 | @Column(name="name")
69 | private String name;
70 |
71 | @OneToMany(mappedBy="operation")
72 | private List permissions;
73 |
74 | public Integer getId() {
75 | return id;
76 | }
77 |
78 | public void setId(Integer id) {
79 | this.id = id;
80 | }
81 |
82 | public String getName() {
83 | return name;
84 | }
85 |
86 | public void setName(String name) {
87 | this.name = name;
88 | }
89 |
90 | public List getPermissions() {
91 | return permissions;
92 | }
93 |
94 | public void setPermissions(List permissions) {
95 | this.permissions = permissions;
96 | }
97 |
98 | /**
99 | * Method used to transform the current object into a transferable one.
100 | *
101 | * @return
102 | */
103 | public org.ecommerce.rbac.dto.Operation toOperationDTO() {
104 | org.ecommerce.rbac.dto.Operation ret = new org.ecommerce.rbac.dto.Operation();
105 |
106 | ret.setId(this.getId());
107 | ret.setName(this.getName());
108 |
109 | return ret;
110 | }
111 |
112 | /**
113 | * Method used to format a transferable object to an entity.
114 | * @param operation An operation instance.
115 | * @return
116 | */
117 | public static Operation valueOf(org.ecommerce.rbac.dto.Operation operation) {
118 | Operation ret = new Operation();
119 |
120 | ret.setId(operation.getId());
121 | ret.setName(operation.getName());
122 |
123 | return ret;
124 | }
125 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-entities/src/main/java/org/ecommerce/rbac/persistence/entities/SecurityObject.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.persistence.entities;
2 |
3 | import javax.persistence.Column;
4 | import javax.persistence.Entity;
5 | import javax.persistence.GeneratedValue;
6 | import javax.persistence.GenerationType;
7 | import javax.persistence.Id;
8 | import javax.persistence.NamedQueries;
9 | import javax.persistence.NamedQuery;
10 | import javax.persistence.Table;
11 |
12 | /**
13 | Copyright (C) 2011 by Radu Viorel Cosnita
14 |
15 | Permission is hereby granted, free of charge, to any person obtaining a copy
16 | of this software and associated documentation files (the "Software"), to deal
17 | in the Software without restriction, including without limitation the rights
18 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19 | copies of the Software, and to permit persons to whom the Software is
20 | furnished to do so, subject to the following conditions:
21 |
22 | The above copyright notice and this permission notice shall be included in
23 | all copies or substantial portions of the Software.
24 |
25 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
31 | THE SOFTWARE.*/
32 |
33 | /**
34 | * Class that defines the data model for a RBAC object.
35 | *
36 | * @author Radu Viorel Cosnita
37 | * @version 1.0
38 | * @since 02.10.2011
39 | */
40 |
41 | @Entity
42 | @Table(name="Objects")
43 | @NamedQueries({
44 | @NamedQuery(name="SecurityObject.loadAll",
45 | query="SELECT obj FROM SecurityObject obj ORDER BY obj.name"),
46 | @NamedQuery(name="SecurityObject.loadAllPaginated",
47 | query="SELECT obj FROM SecurityObject obj WHERE obj.name LIKE CONCAT('%', :searchQuery, '%') ORDER BY obj.name")
48 | })
49 | public class SecurityObject {
50 | @Id
51 | @GeneratedValue(strategy=GenerationType.AUTO)
52 | @Column(name="id")
53 | private Integer id;
54 |
55 | @Column(name="name")
56 | private String name;
57 |
58 | public Integer getId() {
59 | return id;
60 | }
61 |
62 | public void setId(Integer id) {
63 | this.id = id;
64 | }
65 |
66 | public String getName() {
67 | return name;
68 | }
69 |
70 | public void setName(String name) {
71 | this.name = name;
72 | }
73 |
74 | /**
75 | * Method used to transform this entity to a transferable object.
76 | *
77 | * @return
78 | */
79 | public org.ecommerce.rbac.dto.SecurityObject toSecurityObjectDTO() {
80 | org.ecommerce.rbac.dto.SecurityObject ret = new org.ecommerce.rbac.dto.SecurityObject();
81 |
82 | ret.setId(this.getId());
83 | ret.setName(this.getName());
84 |
85 | return ret;
86 | }
87 |
88 | /**
89 | * Method used to transform a transferable object into an entity.
90 | *
91 | * @param object SecurityObject dto instance.
92 | * @return
93 | */
94 | public static SecurityObject valueOf(org.ecommerce.rbac.dto.SecurityObject object) {
95 | SecurityObject ret = new SecurityObject();
96 |
97 | ret.setId(object.getId());
98 | ret.setName(object.getName());
99 |
100 | return ret;
101 | }
102 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-entities/src/main/java/org/ecommerce/rbac/persistence/entities/Session.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.persistence.entities;
2 |
3 | import java.util.Date;
4 | import java.util.List;
5 | import java.util.Set;
6 |
7 | import javax.persistence.CascadeType;
8 | import javax.persistence.Column;
9 | import javax.persistence.Entity;
10 | import javax.persistence.GeneratedValue;
11 | import javax.persistence.GenerationType;
12 | import javax.persistence.Id;
13 | import javax.persistence.JoinColumn;
14 | import javax.persistence.JoinTable;
15 | import javax.persistence.ManyToMany;
16 | import javax.persistence.ManyToOne;
17 | import javax.persistence.NamedQueries;
18 | import javax.persistence.NamedQuery;
19 | import javax.persistence.Table;
20 |
21 | /**
22 | Copyright (C) 2011 by Radu Viorel Cosnita
23 |
24 | Permission is hereby granted, free of charge, to any person obtaining a copy
25 | of this software and associated documentation files (the "Software"), to deal
26 | in the Software without restriction, including without limitation the rights
27 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
28 | copies of the Software, and to permit persons to whom the Software is
29 | furnished to do so, subject to the following conditions:
30 |
31 | The above copyright notice and this permission notice shall be included in
32 | all copies or substantial portions of the Software.
33 |
34 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
35 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
37 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
38 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
39 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
40 | THE SOFTWARE.*/
41 |
42 | /**
43 | * Class used to model a RBAC session component.
44 | *
45 | * @author Radu Viorel Cosnita
46 | * @version 1.0
47 | * @since 02.10.2011
48 | */
49 |
50 | @Entity
51 | @Table(name="Sessions")
52 | @NamedQueries({
53 | @NamedQuery(name="Sessions.loadActiveSessionsByUser",
54 | query="SELECT obj FROM Session obj " +
55 | "WHERE obj.active = 1 AND obj.user.id = :userId"),
56 | @NamedQuery(name="Sessions.loadSessionsByUser",
57 | query="SELECT obj FROM Session obj " +
58 | "WHERE obj.user.id = :userId AND (obj.active = :active OR :active IS NULL)")
59 | })
60 | public class Session {
61 | @Id
62 | @GeneratedValue(strategy=GenerationType.AUTO)
63 | @Column(name="id")
64 | private Integer id;
65 |
66 | @ManyToOne
67 | @JoinColumn(name="user_id", referencedColumnName="id")
68 | private User user;
69 |
70 | @Column(name="active")
71 | private boolean active;
72 |
73 | @Column(name="start_date")
74 | private Date startDate;
75 |
76 | @Column(name="end_date")
77 | private Date endDate;
78 |
79 | @Column(name="remote_session")
80 | private String remoteSession;
81 |
82 | /**
83 | * These are all roles activated within the current session.
84 | */
85 | @ManyToMany(cascade={CascadeType.ALL})
86 | @JoinTable(name="SessionRoles",
87 | joinColumns={@JoinColumn(name="session_id", referencedColumnName="id")},
88 | inverseJoinColumns={@JoinColumn(name="role_id", referencedColumnName="id")}
89 | )
90 | private Set sessionRoles;
91 |
92 | public Integer getId() {
93 | return id;
94 | }
95 |
96 | public void setId(Integer id) {
97 | this.id = id;
98 | }
99 |
100 | public User getUser() {
101 | return user;
102 | }
103 |
104 | public void setUser(User user) {
105 | this.user = user;
106 | }
107 |
108 | public boolean isActive() {
109 | return active;
110 | }
111 |
112 | public void setActive(boolean active) {
113 | this.active = active;
114 | }
115 |
116 | public Date getStartDate() {
117 | return startDate;
118 | }
119 |
120 | public void setStartDate(Date startDate) {
121 | this.startDate = startDate;
122 | }
123 |
124 | public Date getEndDate() {
125 | return endDate;
126 | }
127 |
128 | public void setEndDate(Date endDate) {
129 | this.endDate = endDate;
130 | }
131 |
132 | public String getRemoteSession() {
133 | return remoteSession;
134 | }
135 |
136 | public void setRemoteSession(String remoteSession) {
137 | this.remoteSession = remoteSession;
138 | }
139 |
140 | public Set getSessionRoles() {
141 | return sessionRoles;
142 | }
143 |
144 | public void setSessionRoles(Set sessionRoles) {
145 | this.sessionRoles = sessionRoles;
146 | }
147 |
148 | /**
149 | * Method used to transform the entity to a transferable object.
150 | * @return
151 | */
152 | public org.ecommerce.rbac.dto.Session toSessionDTO() {
153 | org.ecommerce.rbac.dto.Session session = new org.ecommerce.rbac.dto.Session();
154 | session.setId(this.getId());
155 | session.setStartTime(this.getStartDate());
156 | session.setEndTime(this.getEndDate());
157 | session.setActive(this.isActive());
158 | session.setRemoteSession(this.getRemoteSession());
159 |
160 | return session;
161 | }
162 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-entities/src/main/java/org/ecommerce/rbac/persistence/entities/User.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.persistence.entities;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import javax.persistence.Column;
7 | import javax.persistence.Entity;
8 | import javax.persistence.Id;
9 | import javax.persistence.ManyToMany;
10 | import javax.persistence.NamedNativeQueries;
11 | import javax.persistence.NamedNativeQuery;
12 | import javax.persistence.NamedQueries;
13 | import javax.persistence.NamedQuery;
14 | import javax.persistence.Table;
15 |
16 | /**
17 | Copyright (C) 2011 by Radu Viorel Cosnita
18 |
19 | Permission is hereby granted, free of charge, to any person obtaining a copy
20 | of this software and associated documentation files (the "Software"), to deal
21 | in the Software without restriction, including without limitation the rights
22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
23 | copies of the Software, and to permit persons to whom the Software is
24 | furnished to do so, subject to the following conditions:
25 |
26 | The above copyright notice and this permission notice shall be included in
27 | all copies or substantial portions of the Software.
28 |
29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
35 | THE SOFTWARE.*/
36 |
37 |
38 | /**
39 | * Class used to implement a RBAC user. Currently we hold only the
40 | * unique identifier of the user. This unique identifier will not
41 | * be even set by the RBAC system but instead by the system that integrates
42 | * with this RBAC implementation.
43 | *
44 | * @author Radu Viorel Cosnita
45 | * @version 1.0
46 | * @since 02.10.2011
47 | */
48 |
49 | @Entity
50 | @Table(name="Users")
51 | @NamedQueries({
52 | @NamedQuery(name="Users.loadAll", query="SELECT obj FROM User obj")
53 | })
54 | @NamedNativeQueries({
55 | @NamedNativeQuery(name="Users.removeFromAllRoles", query="DELETE FROM AssignedUsers WHERE user_id = ?1", resultClass=User.class)
56 | })
57 | public class User {
58 | @Id
59 | @Column(name="id")
60 | private Integer id;
61 |
62 | @ManyToMany(mappedBy="assignedUsers")
63 | private List roles = new ArrayList();
64 |
65 | public Integer getId() {
66 | return id;
67 | }
68 |
69 | public void setId(Integer id) {
70 | this.id = id;
71 | }
72 |
73 | public List getRoles() {
74 | return roles;
75 | }
76 |
77 | public void setRoles(List roles) {
78 | this.roles = roles;
79 | }
80 |
81 | /**
82 | * Method used to transform the current entity to a transferable
83 | * object.
84 | *
85 | * @return
86 | */
87 | public org.ecommerce.rbac.dto.User toUserDTO() {
88 | org.ecommerce.rbac.dto.User user = new org.ecommerce.rbac.dto.User();
89 |
90 | user.setId(this.getId());
91 |
92 | return user;
93 | }
94 |
95 | /**
96 | * Method used to transform a transferable user to an entity.
97 | *
98 | * @param user A dto user instance.
99 | * @return
100 | */
101 | public static User valueOf(org.ecommerce.rbac.dto.User user) {
102 | User ret = new User();
103 |
104 | ret.setId(user.getId());
105 |
106 | return ret;
107 | }
108 |
109 | /**
110 | * Users equality is determined based on primary key.
111 | */
112 | @Override
113 | public boolean equals(Object obj) {
114 | if(obj instanceof User) {
115 | User usr = User.class.cast(obj);
116 | return usr.getId() == this.getId();
117 | }
118 |
119 | return super.equals(obj);
120 | }
121 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-entities/src/main/resources/org/ecommerce/rbac/persistence/persistence.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | org.hibernate.ejb.HibernatePersistence
7 | org.ecommerce.rbac.persistence.entities.User
8 | org.ecommerce.rbac.persistence.entities.Role
9 | org.ecommerce.rbac.persistence.entities.Session
10 | org.ecommerce.rbac.persistence.entities.SecurityObject
11 | org.ecommerce.rbac.persistence.entities.Operation
12 | org.ecommerce.rbac.persistence.entities.Permission
13 | org.ecommerce.rbac.persistence.entities.DynamicSeparationDuty
14 | NONE
15 | NONE
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-entities/src/test/java/org/ecommerce/rbac/persistence/TestEntities.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.persistence;
2 |
3 | import javax.persistence.EntityManager;
4 | import javax.persistence.EntityManagerFactory;
5 | import javax.persistence.Persistence;
6 |
7 | import org.ecommerce.rbac.persistence.entities.User;
8 | import org.junit.Test;
9 |
10 | /**
11 | Copyright (C) 2011 by Radu Viorel Cosnita
12 |
13 | Permission is hereby granted, free of charge, to any person obtaining a copy
14 | of this software and associated documentation files (the "Software"), to deal
15 | in the Software without restriction, including without limitation the rights
16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 | copies of the Software, and to permit persons to whom the Software is
18 | furnished to do so, subject to the following conditions:
19 |
20 | The above copyright notice and this permission notice shall be included in
21 | all copies or substantial portions of the Software.
22 |
23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 | THE SOFTWARE.*/
30 |
31 | /**
32 | * This class ensure that mapping of jpa entities is correct. It is executed
33 | * as a JUnit test suie.
34 | *
35 | * @author Radu Viorel Cosnita
36 | * @version 1.0
37 | * @since 02.10.2011
38 | */
39 | public class TestEntities {
40 | /**
41 | * Method executed for testing JPA initialization.
42 | */
43 | @Test
44 | public void testJPAInit() {
45 | EntityManagerFactory emf = Persistence.createEntityManagerFactory("rbac-pu-test");
46 | EntityManager em = emf.createEntityManager();
47 |
48 | User user = em.find(User.class, 1);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-entities/src/test/resources/META-INF/persistence.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | org.hibernate.ejb.HibernatePersistence
7 | org.ecommerce.rbac.persistence.entities.User
8 | org.ecommerce.rbac.persistence.entities.Role
9 | org.ecommerce.rbac.persistence.entities.Session
10 | org.ecommerce.rbac.persistence.entities.SecurityObject
11 | org.ecommerce.rbac.persistence.entities.Operation
12 | org.ecommerce.rbac.persistence.entities.Permission
13 | org.ecommerce.rbac.persistence.entities.DynamicSeparationDuty
14 | NONE
15 | NONE
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-project/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-project/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | ecommerce-rbac-project
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.m2e.core.maven2Nature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-project/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | #Sat Oct 01 18:06:13 EEST 2011
2 | eclipse.preferences.version=1
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
4 | org.eclipse.jdt.core.compiler.compliance=1.5
5 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
6 | org.eclipse.jdt.core.compiler.source=1.5
7 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-project/.settings/org.maven.ide.eclipse.prefs:
--------------------------------------------------------------------------------
1 | #Sat Oct 01 18:06:12 EEST 2011
2 | activeProfiles=
3 | eclipse.preferences.version=1
4 | fullBuildGoals=process-test-resources
5 | resolveWorkspaceProjects=true
6 | resourceFilterGoals=process-resources resources\:testResources
7 | skipCompilerPlugin=true
8 | version=1
9 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-rest-impl/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-rest-impl/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | ecommerce-rbac-rest-impl
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.wst.jsdt.core.javascriptValidator
10 |
11 |
12 |
13 |
14 | org.eclipse.wst.common.project.facet.core.builder
15 |
16 |
17 |
18 |
19 | org.eclipse.jdt.core.javabuilder
20 |
21 |
22 |
23 |
24 | org.eclipse.wst.validation.validationbuilder
25 |
26 |
27 |
28 |
29 | org.eclipse.m2e.core.maven2Builder
30 |
31 |
32 |
33 |
34 | org.springframework.ide.eclipse.core.springbuilder
35 |
36 |
37 |
38 |
39 |
40 | org.springframework.ide.eclipse.core.springnature
41 | org.eclipse.jem.workbench.JavaEMFNature
42 | org.eclipse.wst.common.modulecore.ModuleCoreNature
43 | org.eclipse.jdt.core.javanature
44 | org.eclipse.wst.common.project.facet.core.nature
45 | org.eclipse.wst.jsdt.core.jsNature
46 | org.eclipse.m2e.core.maven2Nature
47 |
48 |
49 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-rest-impl/.settings/.jsdtscope:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-rest-impl/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | #Wed Oct 05 23:10:28 EEST 2011
2 | eclipse.preferences.version=1
3 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
4 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
5 | org.eclipse.jdt.core.compiler.compliance=1.6
6 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
7 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
8 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
9 | org.eclipse.jdt.core.compiler.source=1.6
10 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-rest-impl/.settings/org.eclipse.wst.common.component:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | uses
9 |
10 |
11 | uses
12 |
13 |
14 | uses
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-rest-impl/.settings/org.eclipse.wst.common.project.facet.core.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-rest-impl/.settings/org.eclipse.wst.jsdt.ui.superType.container:
--------------------------------------------------------------------------------
1 | org.eclipse.wst.jsdt.launching.baseBrowserLibrary
--------------------------------------------------------------------------------
/java/ecommerce-rbac-rest-impl/.settings/org.eclipse.wst.jsdt.ui.superType.name:
--------------------------------------------------------------------------------
1 | Window
--------------------------------------------------------------------------------
/java/ecommerce-rbac-rest-impl/.settings/org.maven.ide.eclipse.prefs:
--------------------------------------------------------------------------------
1 | #Wed Oct 05 22:58:40 EEST 2011
2 | activeProfiles=
3 | eclipse.preferences.version=1
4 | fullBuildGoals=process-test-resources
5 | resolveWorkspaceProjects=true
6 | resourceFilterGoals=process-resources resources\:testResources
7 | skipCompilerPlugin=true
8 | version=1
9 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-rest-impl/src/main/java/org/ecommerce/rbac/impl/rest/RbacDsdManagerImpl.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.impl.rest;
2 |
3 | import java.util.HashSet;
4 | import java.util.List;
5 | import java.util.logging.Logger;
6 |
7 | import org.ecommerce.rbac.api.management.RbacDsdManager;
8 | import org.ecommerce.rbac.dao.DynamicSeparationDutyDao;
9 | import org.ecommerce.rbac.dto.DynamicSeparationRule;
10 | import org.ecommerce.rbac.dto.DynamicSeparationRules;
11 | import org.ecommerce.rbac.dto.Identifiers;
12 | import org.ecommerce.rbac.dto.Roles;
13 | import org.ecommerce.rbac.persistence.entities.DynamicSeparationDuty;
14 | import org.ecommerce.rbac.persistence.entities.Role;
15 | import org.springframework.beans.factory.annotation.Autowired;
16 | import org.springframework.stereotype.Service;
17 | import org.springframework.transaction.annotation.Transactional;
18 |
19 | /**
20 | Copyright (C) 2011 by Radu Viorel Cosnita
21 |
22 | Permission is hereby granted, free of charge, to any person obtaining a copy
23 | of this software and associated documentation files (the "Software"), to deal
24 | in the Software without restriction, including without limitation the rights
25 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
26 | copies of the Software, and to permit persons to whom the Software is
27 | furnished to do so, subject to the following conditions:
28 |
29 | The above copyright notice and this permission notice shall be included in
30 | all copies or substantial portions of the Software.
31 |
32 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
33 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
34 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
35 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
36 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
37 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
38 | THE SOFTWARE.*/
39 |
40 | /**
41 | * Dynamic Separation of Duty official service implementation.
42 | *
43 | * @author Radu Viorel Cosnita
44 | * @version 1.0
45 | * @since 08.10.2011
46 | */
47 |
48 | @Service("rbacDsdService")
49 | public class RbacDsdManagerImpl implements RbacDsdManager {
50 | private final static Logger logger = Logger.getLogger(RbacDsdManagerImpl.class.getName());
51 |
52 | private DynamicSeparationDutyDao dsdDAO;
53 |
54 | @Autowired
55 | public RbacDsdManagerImpl(DynamicSeparationDutyDao dsdDAO) {
56 | this.dsdDAO = dsdDAO;
57 | }
58 |
59 | /**
60 | * {@inheritDoc}
61 | */
62 | @Override
63 | public DynamicSeparationRules loadAllDsd() {
64 | logger.info("REST load all RBAC dsd.");
65 |
66 | List dsds =
67 | dsdDAO.loadAllDsd();
68 |
69 | DynamicSeparationRules rules = new DynamicSeparationRules();
70 |
71 | for(org.ecommerce.rbac.persistence.entities.DynamicSeparationDuty dsd : dsds) {
72 | rules.getDsdRules().add(dsd.toDynamicSeparationDTO());
73 | }
74 |
75 | return rules;
76 | }
77 |
78 | /**
79 | * {@inheritDoc}
80 | */
81 | @Override
82 | public DynamicSeparationRule loadDsdById(Integer dsdId) {
83 | logger.info(String.format("REST load dsd by id %s.", dsdId));
84 |
85 | return dsdDAO.loadDsdById(dsdId).toDynamicSeparationDTO();
86 | }
87 |
88 | /**
89 | * {@inheritDoc}
90 | */
91 | @Override
92 | @Transactional
93 | public Roles loadDsdRoles(Integer dsdId) {
94 | logger.info(String.format("REST load RBAC dsd %s roles.", dsdId));
95 |
96 | Roles roles = new Roles();
97 |
98 | org.ecommerce.rbac.persistence.entities.DynamicSeparationDuty dsd =
99 | dsdDAO.loadDsdById(dsdId);
100 |
101 | for(org.ecommerce.rbac.persistence.entities.Role role : dsd.getRoles()) {
102 | roles.getRoles().add(role.toRoleDTO());
103 | }
104 |
105 | return roles;
106 | }
107 |
108 | /**
109 | * {@inheritDoc}
110 | */
111 | @Override
112 | public void createNewDsd(String dsdName, Integer cardinality, Identifiers roles) {
113 | logger.info(String.format("REST creating new dsd %s.", dsdName));
114 |
115 | DynamicSeparationDuty dsd = new DynamicSeparationDuty();
116 | dsd.setName(dsdName);
117 | dsd.setCardinality(cardinality);
118 | dsd.setRoles(new HashSet());
119 |
120 | dsdDAO.createNewDsd(dsd, roles.getIdentifiers());
121 | }
122 |
123 | /**
124 | * {@inheritDoc}
125 | */
126 | @Override
127 | public void includeRolesInDsd(Integer dsdId, List roles) {
128 | logger.info(String.format("REST assign %s roles to dsd.", roles.size()));
129 |
130 | dsdDAO.assignNewRolesToDsd(dsdId, roles);
131 | }
132 |
133 | /**
134 | * {@inheritDoc}
135 | */
136 | @Override
137 | public void updateExistingDsd(Integer dsdId, DynamicSeparationRule dsd) {
138 | logger.info(String.format("REST updating dsd %s.", dsdId));
139 |
140 | dsd.setId(dsdId);
141 |
142 | dsdDAO.updateDsd(DynamicSeparationDuty.valueOf(dsd));
143 | }
144 |
145 | /**
146 | * {@inheritDoc}
147 | */
148 | @Override
149 | public void excludeRolesFromDsd(Integer dsdId, List roles) {
150 | logger.info(String.format("REST removing %s roles from dsd %s.",
151 | roles.size(), dsdId));
152 |
153 | dsdDAO.removeRolesFromDsd(dsdId, roles);
154 | }
155 |
156 | /**
157 | * {@inheritDoc}
158 | */
159 | @Override
160 | public void removeDsd(Integer dsdId) {
161 | logger.info(String.format("REST removing dsd %s.", dsdId));
162 |
163 | dsdDAO.removeDsd(dsdId);
164 | }
165 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-rest-impl/src/main/java/org/ecommerce/rbac/impl/rest/RbacInheritanceManagerImpl.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.impl.rest;
2 |
3 | import java.util.logging.Logger;
4 |
5 | import org.ecommerce.rbac.api.management.RbacInheritanceManager;
6 | import org.ecommerce.rbac.dao.RolesInheritanceDao;
7 | import org.springframework.beans.factory.annotation.Autowired;
8 | import org.springframework.stereotype.Service;
9 |
10 | /**
11 | Copyright (C) 2011 by Radu Viorel Cosnita
12 |
13 | Permission is hereby granted, free of charge, to any person obtaining a copy
14 | of this software and associated documentation files (the "Software"), to deal
15 | in the Software without restriction, including without limitation the rights
16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 | copies of the Software, and to permit persons to whom the Software is
18 | furnished to do so, subject to the following conditions:
19 |
20 | The above copyright notice and this permission notice shall be included in
21 | all copies or substantial portions of the Software.
22 |
23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 | THE SOFTWARE.*/
30 |
31 | /**
32 | * Inheritance manager official implementation.
33 | *
34 | * @author Radu Viorel Cosnita
35 | * @version 1.0
36 | * @since 10.10.2011
37 | */
38 |
39 | @Service("rbacInheritanceService")
40 | public class RbacInheritanceManagerImpl implements RbacInheritanceManager {
41 | private final static Logger logger = Logger.getLogger(RbacInheritanceManagerImpl.class.getName());
42 |
43 | private RolesInheritanceDao inheritanceDAO;
44 |
45 | @Autowired
46 | public RbacInheritanceManagerImpl(RolesInheritanceDao inheritanceDAO) {
47 | this.inheritanceDAO = inheritanceDAO;
48 | }
49 |
50 | /**
51 | * {@inheritDoc}
52 | */
53 | @Override
54 | public void addInheritance(Integer roleId, Integer childId) {
55 | logger.info(String.format("REST RBAC role %s inherits permissions from role %s.",
56 | roleId, childId));
57 |
58 | inheritanceDAO.createInheritance(roleId, childId);
59 | }
60 |
61 | /**
62 | * {@inheritDoc}
63 | */
64 | @Override
65 | public void deleteInheritance(Integer roleId, Integer childId) {
66 | logger.info(String.format("REST RBAC remove inheritance between %s and %s.",
67 | roleId, childId));
68 |
69 | inheritanceDAO.removeInheritance(roleId, childId);
70 | }
71 |
72 | /**
73 | * {@inheritDoc}
74 | */
75 | @Override
76 | public void addAscendant(Integer roleId, Integer ascendantId) {
77 | logger.info(String.format("REST RBAC add %s role as direct ascendant of %s.",
78 | ascendantId, roleId));
79 |
80 | inheritanceDAO.addAscendant(roleId, ascendantId);
81 | }
82 |
83 | /**
84 | * {@inheritDoc}
85 | */
86 | @Override
87 | public void addDescendant(Integer roleId, Integer descendantId) {
88 | logger.info(String.format("REST RBAC add %s role as direct descendant of %s.",
89 | descendantId, roleId));
90 |
91 | inheritanceDAO.addDescendant(roleId, descendantId);
92 | }
93 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-rest-impl/src/main/java/org/ecommerce/rbac/impl/rest/RbacObjectsManagerImpl.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.impl.rest;
2 |
3 | import java.util.List;
4 | import java.util.logging.Logger;
5 |
6 | import org.ecommerce.rbac.api.management.RbacObjectsManager;
7 | import org.ecommerce.rbac.dao.SecurityObjectsDao;
8 | import org.ecommerce.rbac.dto.SecurityObject;
9 | import org.ecommerce.rbac.dto.SecurityObjects;
10 | import org.springframework.beans.factory.annotation.Autowired;
11 | import org.springframework.stereotype.Service;
12 | import org.springframework.transaction.annotation.Transactional;
13 |
14 |
15 | /**
16 | Copyright (C) 2011 by Radu Viorel Cosnita
17 |
18 | Permission is hereby granted, free of charge, to any person obtaining a copy
19 | of this software and associated documentation files (the "Software"), to deal
20 | in the Software without restriction, including without limitation the rights
21 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
22 | copies of the Software, and to permit persons to whom the Software is
23 | furnished to do so, subject to the following conditions:
24 |
25 | The above copyright notice and this permission notice shall be included in
26 | all copies or substantial portions of the Software.
27 |
28 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
29 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
30 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
31 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
32 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
33 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
34 | THE SOFTWARE.*/
35 |
36 | /**
37 | * Rbac objects manager implementation.
38 | *
39 | * @author Radu Viorel Cosnita
40 | * @version 1.0
41 | * @since 06.10.2011
42 | */
43 | @Service("rbacObjectsService")
44 | public class RbacObjectsManagerImpl implements RbacObjectsManager {
45 | private final static Logger logger = Logger.getLogger(RbacObjectsManagerImpl.class.getName());
46 |
47 | private SecurityObjectsDao objectsDAO;
48 |
49 | @Autowired
50 | public RbacObjectsManagerImpl(SecurityObjectsDao objectsDAO) {
51 | this.objectsDAO = objectsDAO;
52 | }
53 |
54 | /**
55 | * {@inheritDoc}
56 | */
57 | @Override
58 | public SecurityObjects loadAllObjects() {
59 | logger.info("REST loading all defined RBAC objects.");
60 |
61 | List objects =
62 | objectsDAO.loadAllObjects();
63 |
64 | SecurityObjects ret = new SecurityObjects();
65 |
66 | for(org.ecommerce.rbac.persistence.entities.SecurityObject object : objects) {
67 | ret.getObjects().add(object.toSecurityObjectDTO());
68 | }
69 |
70 | return ret;
71 | }
72 |
73 | /**
74 | * {@inheritDoc}
75 | */
76 | @Override
77 | public SecurityObjects loadAllObjects(int startRecord, int pageSize, String searchQuery) {
78 | logger.info(String.format("REST loading %s RBAC objects starting from %s", pageSize, startRecord));
79 |
80 | List objects =
81 | objectsDAO.loadAllObjects(startRecord, pageSize, searchQuery);
82 |
83 | SecurityObjects ret = new SecurityObjects();
84 |
85 | for(org.ecommerce.rbac.persistence.entities.SecurityObject object : objects) {
86 | ret.getObjects().add(object.toSecurityObjectDTO());
87 | }
88 |
89 | return ret;
90 | }
91 |
92 | /**
93 | * {@inheritDoc}
94 | */
95 | @Override
96 | public SecurityObject loadObjectById(Integer objectId) {
97 | logger.info(String.format("REST loading RBAC object %s.", objectId));
98 |
99 | return objectsDAO.loadObjectById(objectId).toSecurityObjectDTO();
100 | }
101 |
102 | /**
103 | * {@inheritDoc}
104 | */
105 | @Override
106 | @Transactional
107 | public int createNewObject(SecurityObject object) {
108 | logger.info(String.format("REST creating RBAC object %s.", object.getName()));
109 |
110 | return objectsDAO.createNewObject(org.ecommerce.rbac.persistence.entities.SecurityObject.valueOf(object));
111 | }
112 |
113 | /**
114 | * {@inheritDoc}
115 | */
116 | @Override
117 | @Transactional
118 | public void updateExistingObject(Integer objectId, SecurityObject object) {
119 | logger.info(String.format("REST updating RBAC object %s.", object.getName()));
120 |
121 | object.setId(objectId);
122 | objectsDAO.updateObject(org.ecommerce.rbac.persistence.entities.SecurityObject.valueOf(object));
123 | }
124 |
125 | /**
126 | * {@inheritDoc}
127 | */
128 | @Override
129 | @Transactional
130 | public void removeObject(Integer objectId) {
131 | logger.info(String.format("REST removing RBAC object %s.", objectId));
132 |
133 | objectsDAO.removeObject(objectId);
134 | }
135 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-rest-impl/src/main/java/org/ecommerce/rbac/impl/rest/RbacOperationsManagerImpl.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.impl.rest;
2 |
3 | import java.util.List;
4 | import java.util.logging.Logger;
5 |
6 | import org.ecommerce.rbac.api.management.RbacOperationsManager;
7 | import org.ecommerce.rbac.dao.OperationsDao;
8 | import org.ecommerce.rbac.dto.Operation;
9 | import org.ecommerce.rbac.dto.Operations;
10 | import org.springframework.beans.factory.annotation.Autowired;
11 | import org.springframework.stereotype.Service;
12 |
13 | /**
14 | Copyright (C) 2011 by Radu Viorel Cosnita
15 |
16 | Permission is hereby granted, free of charge, to any person obtaining a copy
17 | of this software and associated documentation files (the "Software"), to deal
18 | in the Software without restriction, including without limitation the rights
19 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20 | copies of the Software, and to permit persons to whom the Software is
21 | furnished to do so, subject to the following conditions:
22 |
23 | The above copyright notice and this permission notice shall be included in
24 | all copies or substantial portions of the Software.
25 |
26 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
32 | THE SOFTWARE.*/
33 |
34 | /**
35 | * Rbac REST operations service implementation.
36 | *
37 | * @author Radu Viorel Cosnita
38 | * @version 1.0
39 | * @since 05.10.2011
40 | */
41 |
42 | @Service("rbacOperationsService")
43 | public class RbacOperationsManagerImpl implements RbacOperationsManager {
44 | private final static Logger logger = Logger.getLogger(RbacOperationsManagerImpl.class.getName());
45 |
46 | private OperationsDao operationsDAO;
47 |
48 | /**
49 | * Constructor that initialize all required dependencies.
50 | *
51 | * @param operationsDao
52 | */
53 | @Autowired
54 | public RbacOperationsManagerImpl(OperationsDao operationsDao) {
55 | this.operationsDAO = operationsDao;
56 | }
57 |
58 | /**
59 | * {@inheritDoc}
60 | */
61 | @Override
62 | public Operations loadAllOperations() {
63 | logger.info("REST loading all RBAC operations.");
64 |
65 | List operations =
66 | operationsDAO.loadAllOperations();
67 |
68 | Operations ret = new Operations();
69 |
70 | for(org.ecommerce.rbac.persistence.entities.Operation operation : operations) {
71 | ret.getOperations().add(operation.toOperationDTO());
72 | }
73 |
74 | return ret;
75 | }
76 |
77 | /**
78 | * {@inheritDoc}
79 | */
80 | @Override
81 | public Operation loadOperationById(Integer operationId) {
82 | logger.info(String.format("JPA loading RBAC operation %s.", operationId));
83 |
84 | org.ecommerce.rbac.persistence.entities.Operation operation =
85 | operationsDAO.loadOperationById(operationId);
86 |
87 | return operation.toOperationDTO();
88 | }
89 |
90 | /**
91 | * {@inheritDoc}
92 | */
93 | @Override
94 | public void createNewOperation(Operation operation) {
95 | logger.info(String.format("Creating operation %s.", operation.getName()));
96 |
97 | operationsDAO.createNewOperation(
98 | org.ecommerce.rbac.persistence.entities.Operation.valueOf(operation));
99 | }
100 |
101 | /**
102 | * {@inheritDoc}
103 | */
104 | @Override
105 | public void updateExistingOperation(Integer operationId, Operation operation) {
106 | logger.info(String.format("Updating operation %s.", operationId));
107 |
108 | operation.setId(operationId);
109 |
110 | operationsDAO.createNewOperation(
111 | org.ecommerce.rbac.persistence.entities.Operation.valueOf(operation));
112 | }
113 |
114 | /**
115 | * {@inheritDoc}
116 | */
117 | @Override
118 | public void removeOperation(Integer operationId) {
119 | logger.info(String.format("Removing operation %s.", operationId));
120 |
121 | operationsDAO.removeOperation(operationId);
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-rest-impl/src/main/java/org/ecommerce/rbac/impl/rest/RbacSessionManagerImpl.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.impl.rest;
2 |
3 | import java.util.List;
4 | import java.util.Set;
5 | import java.util.logging.Logger;
6 |
7 | import org.ecommerce.rbac.api.management.RbacSessionsManager;
8 | import org.ecommerce.rbac.dao.SessionsDao;
9 | import org.ecommerce.rbac.dto.Permissions;
10 | import org.ecommerce.rbac.dto.Roles;
11 | import org.ecommerce.rbac.dto.Sessions;
12 | import org.springframework.beans.factory.annotation.Autowired;
13 | import org.springframework.stereotype.Service;
14 |
15 | /**
16 | * Session manager official implementation.
17 | *
18 | * @author Radu Viorel Cosnita
19 | * @version 1.0
20 | * @since 12.10.2011
21 | */
22 |
23 | @Service("rbacSessionsService")
24 | public class RbacSessionManagerImpl implements RbacSessionsManager {
25 | private final static Logger logger = Logger.getLogger(RbacSessionManagerImpl.class.getName());
26 |
27 | private SessionsDao sessionsDAO;
28 |
29 | @Autowired
30 | public RbacSessionManagerImpl(SessionsDao sessionsDAO) {
31 | this.sessionsDAO = sessionsDAO;
32 | }
33 |
34 | /**
35 | * {@inheritDoc}
36 | */
37 | @Override
38 | public Sessions loadAllSessionsByUser(Integer userId, boolean onlyActive) {
39 | logger.info(String.format("REST load sessions for user %s. Only active: %s",
40 | userId, onlyActive));
41 |
42 | List sessions =
43 | sessionsDAO.loadSessionsByUser(userId, onlyActive);
44 |
45 | Sessions sessionsDTO = new Sessions();
46 |
47 | for(org.ecommerce.rbac.persistence.entities.Session session : sessions) {
48 | sessionsDTO.getSessions().add(session.toSessionDTO());
49 | }
50 |
51 | return sessionsDTO;
52 | }
53 |
54 | /**
55 | * {@inheritDoc}
56 | */
57 | @Override
58 | public Roles loadSessionRoles(Integer sessionId, boolean onlyActive) {
59 | logger.info(String.format("REST load session %s. Only active: %s.",
60 | sessionId, onlyActive));
61 |
62 | Roles roles = new Roles();
63 |
64 | Set roleEntities =
65 | sessionsDAO.loadSessionRoles(sessionId, onlyActive);
66 |
67 | for(org.ecommerce.rbac.persistence.entities.Role role : roleEntities) {
68 | roles.getRoles().add(role.toRoleDTO());
69 | }
70 |
71 | return roles;
72 | }
73 |
74 | /**
75 | * {@inheritDoc}
76 | */
77 | @Override
78 | public Permissions loadSessionPermissions(Integer sessionId,
79 | boolean onlyActive) {
80 | logger.info(String.format("REST loading session permission %s. Only active: %s.",
81 | sessionId, onlyActive));
82 |
83 | List perms =
84 | sessionsDAO.loadSessionPermissions(sessionId, onlyActive);
85 |
86 | Permissions permsDTO = new Permissions();
87 |
88 | for(org.ecommerce.rbac.persistence.entities.Permission perm : perms) {
89 | permsDTO.getPermissions().add(perm.toPermissionDTO());
90 | }
91 |
92 | return permsDTO;
93 | }
94 |
95 | /**
96 | * {@inheritDoc}
97 | */
98 | @Override
99 | public Boolean checkSessionPermissionEnabled(Integer sessionId,
100 | Integer permissionId, boolean onlyActive) {
101 | logger.info(String.format("REST checking permission %s in session %s. Only active: %s.",
102 | sessionId, permissionId, onlyActive));
103 |
104 | return sessionsDAO.checkSessionPermissionEnabled(sessionId, permissionId, onlyActive);
105 | }
106 |
107 | /**
108 | * {@inheritDoc}
109 | */
110 | @Override
111 | public Integer startUserSession(Integer userId, boolean activateRoles,
112 | String remoteSession) {
113 | logger.info(String.format("REST start user %s session with remote session %s. Only active: %s.",
114 | userId, remoteSession, activateRoles));
115 |
116 | return sessionsDAO.createUserSession(userId, activateRoles, remoteSession);
117 | }
118 |
119 | /**
120 | * {@inheritDoc}
121 | */
122 | @Override
123 | public void activateSessionRole(Integer sessionId, Integer roleId,
124 | boolean useInheritance) {
125 | logger.info(String.format("REST activate role %s in session %s. Activate descendant roles: ",
126 | roleId, sessionId, useInheritance));
127 |
128 | sessionsDAO.activateSessionRole(sessionId, roleId, useInheritance);
129 | }
130 |
131 | /**
132 | * {@inheritDoc}
133 | */
134 | @Override
135 | public void stopSession(Integer sessionId) {
136 | logger.info(String.format("REST stop session %s.", sessionId));
137 |
138 | sessionsDAO.stopSession(sessionId);
139 | }
140 |
141 | /**
142 | * {@inheritDoc}
143 | */
144 | @Override
145 | public void deactivateSessionRole(Integer sessionId, Integer roleId) {
146 | logger.info(String.format("REST deactivate role %s from session %s.",
147 | sessionId, roleId));
148 |
149 | sessionsDAO.deactivateSessionRole(sessionId, roleId);
150 | }
151 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-rest-impl/src/main/java/org/ecommerce/rbac/impl/rest/exceptions/EmptyResultDataAccessExceptionMapper.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.impl.rest.exceptions;
2 |
3 | /**Copyright (C) 2011 by Radu Viorel Cosnita
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.*/
22 |
23 | import javax.ws.rs.core.Response;
24 | import javax.ws.rs.core.Response.Status;
25 | import javax.ws.rs.ext.ExceptionMapper;
26 | import javax.ws.rs.ext.Provider;
27 |
28 | import org.springframework.dao.EmptyResultDataAccessException;
29 | import org.springframework.stereotype.Component;
30 |
31 | /**
32 | * This is an apache cxf exception mapper that gracefully handles EmptyResultDataAccessException to 404 HTTP error code.
33 | *
34 | * @author Radu Viorel Cosnita
35 | * @version 1.0
36 | */
37 | @Component("emptyResultDataAccessExceptionMapperBean")
38 | @Provider
39 | public class EmptyResultDataAccessExceptionMapper implements ExceptionMapper {
40 | @Override
41 | public Response toResponse(EmptyResultDataAccessException exception) {
42 | Response response =
43 | Response.status(Status.NOT_FOUND).entity(exception.getMessage()).build();
44 |
45 | return response;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-rest-impl/src/main/java/org/ecommerce/rbac/impl/rest/exceptions/JpaSystemExceptionMapper.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.impl.rest.exceptions;
2 |
3 | import java.sql.SQLException;
4 |
5 | import javax.ws.rs.core.Response;
6 | import javax.ws.rs.core.Response.Status;
7 | import javax.ws.rs.ext.ExceptionMapper;
8 | import javax.ws.rs.ext.Provider;
9 |
10 | import org.hibernate.exception.ConstraintViolationException;
11 | import org.springframework.orm.jpa.JpaSystemException;
12 | import org.springframework.stereotype.Component;
13 |
14 | /**
15 | Copyright (C) 2011 by Radu Viorel Cosnita
16 |
17 | Permission is hereby granted, free of charge, to any person obtaining a copy
18 | of this software and associated documentation files (the "Software"), to deal
19 | in the Software without restriction, including without limitation the rights
20 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21 | copies of the Software, and to permit persons to whom the Software is
22 | furnished to do so, subject to the following conditions:
23 |
24 | The above copyright notice and this permission notice shall be included in
25 | all copies or substantial portions of the Software.
26 |
27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
33 | THE SOFTWARE.*/
34 |
35 | /**
36 | * Class used to map a ConstraintViolationException to the correct http error code.
37 | * Currently this is implemented only for supporting MySql error codes.
38 | * Unfortunately spring does not support jpa exception handling in a such
39 | * granular way as it does for hibernate.
40 | *
41 | * @author Radu Viorel Cosnita
42 | * @version 1.0
43 | * @since 08.10.2011
44 | */
45 |
46 | @Provider
47 | @Component("constraintViolationExceptionBean")
48 | public class JpaSystemExceptionMapper implements ExceptionMapper {
49 | /**
50 | * Here comes an ugly part were we determine what kind of error is it:
51 | * - duplicate entry
52 | * - foreign key violation
53 | * - other case might come.
54 | */
55 | @Override
56 | public Response toResponse(JpaSystemException exception) {
57 | SQLException rootCause = SQLException.class.cast(exception.getMostSpecificCause());
58 |
59 | Status status = Status.INTERNAL_SERVER_ERROR;
60 |
61 | switch(rootCause.getErrorCode()) {
62 | case 1062:
63 | case 1452:
64 | status = Status.FORBIDDEN;
65 | break;
66 | }
67 |
68 | return Response.status(status).entity(rootCause.getMessage()).build();
69 | }
70 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-rest-impl/src/main/java/org/ecommerce/rbac/impl/rest/exceptions/NoResultExceptionMapper.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.impl.rest.exceptions;
2 |
3 | /**Copyright (C) 2011 by Radu Viorel Cosnita
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.*/
22 |
23 | import javax.persistence.NoResultException;
24 | import javax.ws.rs.core.Response;
25 | import javax.ws.rs.core.Response.Status;
26 | import javax.ws.rs.ext.ExceptionMapper;
27 | import javax.ws.rs.ext.Provider;
28 |
29 | import org.springframework.stereotype.Component;
30 |
31 | /**
32 | * Class used to implement a mechanism that transform NoResultException
33 | * into a rest exception.
34 | *
35 | * @author Radu Viorel Cosnita
36 | * @version 1.0
37 | */
38 | @Component("noResultExceptionMapperBean")
39 | @Provider
40 | public class NoResultExceptionMapper implements ExceptionMapper {
41 | /**
42 | * {@inheritDoc}
43 | */
44 | @Override
45 | public Response toResponse(NoResultException exception) {
46 | Response response =
47 | Response.status(Status.NOT_FOUND).entity(exception.getMessage()).build();
48 |
49 | return response;
50 | }
51 | }
--------------------------------------------------------------------------------
/java/ecommerce-rbac-rest-impl/src/main/webapp/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Class-Path:
3 |
4 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-rest-impl/src/main/webapp/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 | ecommerce-rbac-rest
7 | This is the rest implementation of RBAC standard suited
8 | for ecommerce application.
9 |
10 |
11 | contextConfigLocation
12 | classpath:META-INF/cxf/cxf.xml,
13 | /WEB-INF/webservices-ds-context.xml,
14 | /WEB-INF/webservices-dao-context.xml,
15 | /WEB-INF/webservices-context.xml
16 |
17 |
18 |
19 | org.springframework.web.context.ContextLoaderListener
20 |
21 |
22 |
23 | CXFServlet
24 | org.apache.cxf.transport.servlet.CXFServlet
25 | 1
26 |
27 |
28 |
29 | CXFServlet
30 | /rest/*
31 |
32 |
33 |
34 |
35 | 30
36 |
37 |
38 |
39 | index.jsp
40 |
41 |
42 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-rest-impl/src/main/webapp/WEB-INF/webservices-context.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 |
15 |
16 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-rest-impl/src/main/webapp/WEB-INF/webservices-dao-context.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-rest-impl/src/main/webapp/WEB-INF/webservices-ds-context.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/java/ecommerce-rbac-rest-impl/src/main/webapp/index.jsp:
--------------------------------------------------------------------------------
1 |
2 |
3 | RBAC Rest successfully deployed!
4 |
5 |
6 |
--------------------------------------------------------------------------------
/java/integration/rbac-rest-springdm-client/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/java/integration/rbac-rest-springdm-client/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | dmsmart-rbac-client
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.m2e.core.maven2Builder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.pde.PluginNature
21 | org.eclipse.jdt.core.javanature
22 | org.eclipse.m2e.core.maven2Nature
23 |
24 |
25 |
--------------------------------------------------------------------------------
/java/integration/rbac-rest-springdm-client/.settings/org.eclipse.jdt.core.prefs:
--------------------------------------------------------------------------------
1 | #Mon Oct 17 21:24:26 EEST 2011
2 | eclipse.preferences.version=1
3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
4 | org.eclipse.jdt.core.compiler.compliance=1.6
5 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
6 | org.eclipse.jdt.core.compiler.source=1.6
7 |
--------------------------------------------------------------------------------
/java/integration/rbac-rest-springdm-client/.settings/org.maven.ide.eclipse.prefs:
--------------------------------------------------------------------------------
1 | #Mon Oct 17 21:24:25 EEST 2011
2 | activeProfiles=
3 | eclipse.preferences.version=1
4 | fullBuildGoals=process-test-resources
5 | resolveWorkspaceProjects=true
6 | resourceFilterGoals=process-resources resources\:testResources
7 | skipCompilerPlugin=true
8 | version=1
9 |
--------------------------------------------------------------------------------
/java/integration/rbac-rest-springdm-client/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Private-Package: org.ecommerce.rbac.integration.springdm.rest
3 | Built-By: rcosnita
4 | Tool: Bnd-0.0.238
5 | Bundle-Name: rbac-rest-springdm-client
6 | Created-By: Apache Maven Bundle Plugin
7 | Build-Jdk: 1.6.0_26
8 | Bundle-Version: 1.0.0.SNAPSHOT
9 | Bnd-LastModified: 1349009031351
10 | Bundle-ManifestVersion: 2
11 | Bundle-Description: This is the rbac integration layer compatible with
12 | osgi spring dm environment.
13 | Import-Package: javax.annotation,javax.ws.rs.core,org.apache.cxf.jaxrs
14 | .client,org.apache.cxf.jaxrs.utils,org.ecommerce.rbac.api,org.ecommer
15 | ce.rbac.api.management,org.ecommerce.rbac.dto,org.springframework.bea
16 | ns.factory.annotation,org.springframework.context.support,org.springf
17 | ramework.stereotype
18 | Bundle-SymbolicName: ecommerce-rbac-rest-springdm
19 | Originally-Created-By: Apache Maven Bundle Plugin
20 |
21 |
--------------------------------------------------------------------------------
/java/integration/rbac-rest-springdm-client/META-INF/spring/rbac-client-context-osgi.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
--------------------------------------------------------------------------------
/java/integration/rbac-rest-springdm-client/build.properties:
--------------------------------------------------------------------------------
1 | source.. = src/main/java/,src/main/resources/,src/test/java,src/test/resources
2 | output.. = target/classes/,target/test-classes
3 | bin.includes = META-INF/,\
4 | .,\
5 | target/classes/
6 | src.includes = src/main/java/,\
7 | src/main/resources/,\
8 | src/test/java/,\
9 | src/test/resources/
10 |
--------------------------------------------------------------------------------
/java/integration/rbac-rest-springdm-client/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | org.ecommerce.rbac.integration.springdm
5 | ecommerce-rbac-rest-springdm
6 | bundle
7 | rbac-rest-springdm-client
8 | 1.0-SNAPSHOT
9 | http://www.springframework.org/osgi
10 | This is the rbac integration layer compatible with osgi spring dm environment.
11 |
12 |
13 | 2.2.9
14 |
15 |
16 |
17 |
18 | org.apache.cxf
19 | cxf-bundle-minimal
20 | ${apache.cxf.version}
21 | provided
22 |
23 |
24 |
25 | org.ecommerce.rbac.api
26 | ecommerce-rbac-api
27 | 1.0-SNAPSHOT
28 | provided
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 | src/main/resources
37 |
38 |
39 |
40 | .
41 |
42 | plugin.xml
43 | META-INF/*
44 |
45 |
46 |
47 |
48 |
49 |
50 | org.apache.felix
51 | maven-bundle-plugin
52 | 1.4.0
53 | true
54 |
55 | NONE
56 | src/main/resources/META-INF
57 |
58 | ${project.artifactId}
59 |
60 | org.apache.cxf.jaxrs.client,
61 | javax.ws.rs.core,
62 | org.apache.cxf.jaxrs.utils,
63 | org.ecommerce.rbac.api,
64 | org.ecommerce.rbac.api.management,
65 | org.ecommerce.rbac.dto, *
66 | org.ecommerce.rbac.integration.springdm.rest
67 | src/main/resources
68 |
69 |
70 |
71 |
72 | org.apache.felix
73 | maven-bundle-plugin
74 |
75 |
76 | bundle-manifest
77 | package
78 |
79 | bundle
80 |
81 |
82 |
83 |
84 |
85 | org.apache.maven.plugins
86 | maven-compiler-plugin
87 | 2.3.2
88 |
89 | 1.6
90 | 1.6
91 |
92 |
93 |
94 | org.apache.maven.plugins
95 | maven-antrun-plugin
96 |
97 |
98 | bundle-ant
99 | install
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 | run
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/java/integration/rbac-rest-springdm-client/src/main/java/org/ecommerce/rbac/integration/springdm/rest/RbacImpl.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.integration.springdm.rest;
2 |
3 | import java.util.logging.Logger;
4 |
5 | import javax.annotation.PostConstruct;
6 | import javax.annotation.PreDestroy;
7 |
8 | import org.ecommerce.rbac.api.Rbac;
9 | import org.ecommerce.rbac.api.RbacManager;
10 | import org.ecommerce.rbac.api.management.RbacDsdManager;
11 | import org.ecommerce.rbac.api.management.RbacInheritanceManager;
12 | import org.springframework.beans.factory.annotation.Autowired;
13 | import org.springframework.stereotype.Component;
14 |
15 | /**
16 | * Rbac implementation for integrating REST api to an application.
17 | *
18 | * @author Radu Viorel Cosnita
19 | * @version 1.0
20 | * @since 17.10.2011
21 | */
22 |
23 | @Component("rbacClient")
24 | public class RbacImpl implements Rbac {
25 | private final static Logger logger = Logger.getLogger(RbacImpl.class.getName());
26 |
27 | private RbacManager rbacManager;
28 | private RbacDsdManager dsdManager;
29 | private RbacInheritanceManager inheritanceManager;
30 |
31 | @Autowired
32 | public RbacImpl(RbacManager rbacManager, RbacDsdManager dsdManager,
33 | RbacInheritanceManager inheritanceManager) {
34 | this.rbacManager = rbacManager;
35 | this.dsdManager = dsdManager;
36 | this.inheritanceManager = inheritanceManager;
37 | }
38 |
39 | /**
40 | * {@inheritDoc}
41 | */
42 | @Override
43 | public RbacManager getRbacManager() {
44 | return this.rbacManager;
45 | }
46 |
47 | @Override
48 | public RbacDsdManager getDsdManager() {
49 | return dsdManager;
50 | }
51 |
52 | @Override
53 | public RbacInheritanceManager getInheritanceManager() {
54 | return inheritanceManager;
55 | }
56 |
57 | @PostConstruct
58 | private void start() {
59 | logger.info("RBAC Client started");
60 | }
61 |
62 | @PreDestroy
63 | private void stop() {
64 | logger.info("RBAC Client stopped");
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/java/integration/rbac-rest-springdm-client/src/main/java/org/ecommerce/rbac/integration/springdm/rest/RbacManagerImpl.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.integration.springdm.rest;
2 |
3 | import java.util.logging.Logger;
4 |
5 | import javax.annotation.PostConstruct;
6 | import javax.annotation.PreDestroy;
7 |
8 | import org.ecommerce.rbac.api.RbacManager;
9 | import org.ecommerce.rbac.api.management.RbacObjectsManager;
10 | import org.ecommerce.rbac.api.management.RbacOperationsManager;
11 | import org.ecommerce.rbac.api.management.RbacPermissionsManager;
12 | import org.ecommerce.rbac.api.management.RbacRolesManager;
13 | import org.ecommerce.rbac.api.management.RbacSessionsManager;
14 | import org.ecommerce.rbac.api.management.RbacUsersManager;
15 | import org.springframework.beans.factory.annotation.Autowired;
16 | import org.springframework.stereotype.Component;
17 |
18 | /**
19 | * RBAC Manager bean that integrates with rest api.
20 | *
21 | * @author Radu Viorel Cosnita
22 | * @version 1.0
23 | * @since 17.10.2011
24 | */
25 |
26 | @Component("rbacManagerImpl")
27 | public class RbacManagerImpl implements RbacManager {
28 | private final static Logger logger = Logger.getLogger(RbacManagerImpl.class.getName());
29 |
30 | private RbacUsersManager usersManager;
31 | private RbacRolesManager rolesManager;
32 | private RbacObjectsManager objectsManager;
33 | private RbacOperationsManager operationsManager;
34 | private RbacPermissionsManager permissionsManager;
35 | private RbacSessionsManager sessionsManager;
36 |
37 | @Autowired
38 | public RbacManagerImpl(RbacUsersManager usersManager, RbacRolesManager rolesManager,
39 | RbacObjectsManager objectsManager, RbacOperationsManager operationsManager,
40 | RbacPermissionsManager permissionsManager, RbacSessionsManager sessionsManager) {
41 | this.usersManager = usersManager;
42 | this.rolesManager = rolesManager;
43 | this.objectsManager = objectsManager;
44 | this.operationsManager = operationsManager;
45 | this.permissionsManager = permissionsManager;
46 | this.sessionsManager = sessionsManager;
47 | }
48 |
49 | /**
50 | * {@inheritDoc}
51 | */
52 | @Override
53 | public RbacUsersManager getRbacUsersManager() {
54 | return this.usersManager;
55 | }
56 |
57 | /**
58 | * {@inheritDoc}
59 | */
60 | @Override
61 | public RbacRolesManager getRbacRolesManager() {
62 | return this.rolesManager;
63 | }
64 |
65 | /**
66 | * {@inheritDoc}
67 | */
68 | @Override
69 | public RbacObjectsManager getRbacObjectsManager() {
70 | return this.objectsManager;
71 | }
72 |
73 | /**
74 | * {@inheritDoc}
75 | */
76 | @Override
77 | public RbacOperationsManager getRbacOperationsManager() {
78 | return this.operationsManager;
79 | }
80 |
81 | /**
82 | * {@inheritDoc}
83 | */
84 | @Override
85 | public RbacPermissionsManager getRbacPermissionsManager() {
86 | return this.permissionsManager;
87 | }
88 |
89 | /**
90 | * {@inheritDoc}
91 | */
92 | @Override
93 | public RbacSessionsManager getRbacSessionsManager() {
94 | return this.sessionsManager;
95 | }
96 |
97 | @PostConstruct
98 | private void start() {
99 | logger.info("RBAC Manager Client started");
100 | }
101 |
102 | @PreDestroy
103 | private void stop() {
104 | logger.info("RBAC Manager Client stopped");
105 | }
106 | }
--------------------------------------------------------------------------------
/java/integration/rbac-rest-springdm-client/src/main/java/org/ecommerce/rbac/integration/springdm/rest/RbacTestIntegration.java:
--------------------------------------------------------------------------------
1 | package org.ecommerce.rbac.integration.springdm.rest;
2 |
3 | import org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean;
4 | import org.springframework.context.support.ClassPathXmlApplicationContext;
5 |
6 | public class RbacTestIntegration {
7 | public static void main(String[] args) throws Exception {
8 | ClassPathXmlApplicationContext context =
9 | new ClassPathXmlApplicationContext("/META-INF/spring/rbac-client-context.xml");
10 |
11 | JAXRSClientFactoryBean bean = null;
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/java/integration/rbac-rest-springdm-client/src/main/resources/META-INF/MANIFEST.MF:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Private-Package: org.ecommerce.rbac.integration.springdm.rest
3 | Built-By: rcosnita
4 | Tool: Bnd-0.0.238
5 | Bundle-Name: rbac-rest-springdm-client
6 | Created-By: Apache Maven Bundle Plugin
7 | Build-Jdk: 1.6.0_26
8 | Bundle-Version: 1.0.0.SNAPSHOT
9 | Bnd-LastModified: 1349009031351
10 | Bundle-ManifestVersion: 2
11 | Bundle-Description: This is the rbac integration layer compatible with
12 | osgi spring dm environment.
13 | Import-Package: javax.annotation,javax.ws.rs.core,org.apache.cxf.jaxrs
14 | .client,org.apache.cxf.jaxrs.utils,org.ecommerce.rbac.api,org.ecommer
15 | ce.rbac.api.management,org.ecommerce.rbac.dto,org.springframework.bea
16 | ns.factory.annotation,org.springframework.context.support,org.springf
17 | ramework.stereotype
18 | Bundle-SymbolicName: ecommerce-rbac-rest-springdm
19 | Originally-Created-By: Apache Maven Bundle Plugin
20 |
21 |
--------------------------------------------------------------------------------
/java/integration/rbac-rest-springdm-client/src/main/resources/META-INF/spring/rbac-client-context-osgi.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
13 |
14 |
--------------------------------------------------------------------------------
/java/integration/rbac-rest-springdm-client/src/test/java/com/dmsmart/ws/rest/portal/security/dmsmart/readme.txt:
--------------------------------------------------------------------------------
1 | Since Archetype "create" can not create empty directories this file was created. It is safe to delete
--------------------------------------------------------------------------------
/java/integration/rbac-rest-springdm-client/template.mf:
--------------------------------------------------------------------------------
1 | Excluded-Exports:
2 | *.internal*
3 | Unversioned-Imports:
4 | *
5 |
--------------------------------------------------------------------------------