From: Vance K. <va...@us...> - 2006-07-10 05:39:27
|
User: vancek Date: 06/07/09 22:39:27 Modified: andromda-ejb3/src/main/resources/META-INF/andromda namespace.xml cartridge.xml andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades EJB3ManageableEntityFacadeLogicImpl.java andromda-ejb3/src/main/resources/templates/ejb3/crud ManageableServiceBase.vsl andromda-ejb3/src/changes changes.xml andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3 EJB3Globals.java andromda-ejb3/src/main/uml EJB3MetafacadeModel.xml.zip Log: added new namespace property manageableRolesAllowed to new property group new getManageableRolesAllowed in EJB3ManageableEntityFacade Revision Changes Path 1.26 +30 -9 cartridges/andromda-ejb3/src/main/resources/META-INF/andromda/namespace.xml Index: namespace.xml =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/main/resources/META-INF/andromda/namespace.xml,v retrieving revision 1.25 retrieving revision 1.26 diff -u -w -r1.25 -r1.26 --- namespace.xml 26 Jun 2006 06:56:51 -0000 1.25 +++ namespace.xml 10 Jul 2006 05:39:26 -0000 1.26 @@ -936,6 +936,36 @@ </documentation> </property> </propertyGroup> + <propertyGroup name="Security Properties"> + <property name="securityRealm" required="false"> + <documentation> + Specifies the security domain to use + for role based authorization. Use the + security realm to match allowed roles. + This is only applicable for session beans + and MDBs. + </documentation> + </property> + <property name="manageableRolesAllowed"> + <default>Admin</default> + <documentation> + A comma separated list of roles added to the DAO + base <code>RolesAllowed</code> annotation. + This requires <code>securityRealm</code> be + enabled. + This exists because in some cases it is + incorrect to model an actor dependency on the + manageable entity and expect that actor to + define the authorised role on + ManageableServiceBeans. + This property separates + the roles for manageable session beans and + the remaining components. + It is expected that the list of roles + secure all manageable session beans. + </documentation> + </property> + </propertyGroup> <propertyGroup name="Other Properties"> <property name="persistenceContainerName"> <default>jboss</default> @@ -1033,15 +1063,6 @@ and aggregate associations define lazy loading. </documentation> </property> - <property name="securityRealm" required="false"> - <documentation> - Specifies the security domain to use - for role based authorization. Use the - security realm to match allowed roles. - This is only applicable for session beans - and MDBs. - </documentation> - </property> <property name="queryUseNamedParameters"> <default>true</default> <documentation> 1.28 +1 -0 cartridges/andromda-ejb3/src/main/resources/META-INF/andromda/cartridge.xml Index: cartridge.xml =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/main/resources/META-INF/andromda/cartridge.xml,v retrieving revision 1.27 retrieving revision 1.28 diff -u -w -r1.27 -r1.28 --- cartridge.xml 27 Jun 2006 11:13:18 -0000 1.27 +++ cartridge.xml 10 Jul 2006 05:39:26 -0000 1.28 @@ -41,6 +41,7 @@ <property reference="enableTemplating"/> <property reference="jndiNamePrefix"/> <property reference="securityRealm"/> + <property reference="manageableRolesAllowed"/> <property reference="enableClustering"/> <property reference="webServiceContextRoot"/> <property reference="webServiceUrlPattern"/> 1.5 +28 -0 cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3ManageableEntityFacadeLogicImpl.java Index: EJB3ManageableEntityFacadeLogicImpl.java =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/metafacades/EJB3ManageableEntityFacadeLogicImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -w -r1.4 -r1.5 --- EJB3ManageableEntityFacadeLogicImpl.java 26 Jun 2006 06:53:32 -0000 1.4 +++ EJB3ManageableEntityFacadeLogicImpl.java 10 Jul 2006 05:39:26 -0000 1.5 @@ -14,6 +14,7 @@ import org.andromda.metafacades.uml.Entity; import org.andromda.metafacades.uml.EntityAttribute; import org.andromda.metafacades.uml.ManageableEntityAttribute; +import org.andromda.metafacades.uml.Role; import org.andromda.metafacades.uml.UMLProfile; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.Predicate; @@ -285,4 +286,31 @@ return displayAttribute; } + + /** + * @see org.andromda.cartridges.ejb3.metafacades.EJB3ManageableEntityFacadeLogic#handleGetManageableRolesAllowed() + */ + protected String handleGetManageableRolesAllowed() + { + StringBuffer rolesAllowed = null; + String[] roles = StringUtils.split( + StringUtils.trimToEmpty( + ObjectUtils.toString(this.getConfiguredProperty(EJB3Globals.MANAGEABLE_ROLES_ALLOWED))), + ','); + String separator = ""; + + for (int i = 0; i < roles.length; i++) + { + if (rolesAllowed == null) + { + rolesAllowed = new StringBuffer(); + } + rolesAllowed.append(separator); + rolesAllowed.append('"'); + rolesAllowed.append(roles[i]); + rolesAllowed.append('"'); + separator = ", "; + } + return rolesAllowed != null ? rolesAllowed.toString() : null; + } } \ No newline at end of file 1.6 +6 -1 cartridges/andromda-ejb3/src/main/resources/templates/ejb3/crud/ManageableServiceBase.vsl Index: ManageableServiceBase.vsl =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/main/resources/templates/ejb3/crud/ManageableServiceBase.vsl,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -r1.5 -r1.6 --- ManageableServiceBase.vsl 26 Jun 2006 06:45:12 -0000 1.5 +++ ManageableServiceBase.vsl 10 Jul 2006 05:39:26 -0000 1.6 @@ -25,6 +25,11 @@ */ @javax.ejb.TransactionAttribute(javax.ejb.TransactionAttributeType.REQUIRED) @javax.ejb.Remote({${manageable.fullyQualifiedManageableServiceName}.class}) +#if ($manageable.securityEnabled) +#**##if ($stringUtils.isNotBlank(${manageable.manageableRolesAllowed})) +...@ja...lesAllowed({${manageable.manageableRolesAllowed}}) +#**##end +#end public final class $manageable.manageableServiceBaseName implements $manageable.manageableServiceName { @@ -405,7 +410,7 @@ #* *##else query.setParameter("$identifier.name", $identifier.name); #* *##end - return query.getSingleResult(); + return ($member.type.fullyQualifiedName)query.getSingleResult(); } catch (Exception ex) { 1.19 +10 -0 cartridges/andromda-ejb3/src/changes/changes.xml Index: changes.xml =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/changes/changes.xml,v retrieving revision 1.18 retrieving revision 1.19 diff -u -w -r1.18 -r1.19 --- changes.xml 10 Jul 2006 05:29:37 -0000 1.18 +++ changes.xml 10 Jul 2006 05:39:26 -0000 1.19 @@ -223,6 +223,16 @@ This resulted in getTemporalType being refactored in EJB3EntityAttributeFacade and the overriding instance in EJB3ManageableEntityAttributeFacade to be removed. </action> + <action dev="vancek" type="fix"> + The getter (for BLOB type manageable attributes) in the manageable service base implementation must cast + the single result to appropriate type before returning. + </action> + <action dev="vancek" type="add"> + Add @RolesAllowed annotation with permitted roles authorised to access the manageable service. This was + achieved by introducing a new namespace property called <b>manageableRolesAllowed</b> rather than defined + by actors with dependencies on the manageable entity. A corresponding getManageableRolesAllowed + is available through EJB3ManageableEntityFacade to retrieve the formatted comma separated list of roles. + </action> </release> </body> </document> \ No newline at end of file 1.14 +30 -24 cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/EJB3Globals.java Index: EJB3Globals.java =================================================================== RCS file: /cvsroot/andromdaplugins/cartridges/andromda-ejb3/src/main/java/org/andromda/cartridges/ejb3/EJB3Globals.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -w -r1.13 -r1.14 --- EJB3Globals.java 26 Jun 2006 06:53:32 -0000 1.13 +++ EJB3Globals.java 10 Jul 2006 05:39:26 -0000 1.14 @@ -30,6 +30,35 @@ */ public static final String LABEL_SINGLE_NAME_PATTERN = "labelSingleNamePattern"; + /** + * The pattern used to construct the DAO name. + */ + public static final String DAO_PATTERN = "daoNamePattern"; + + /** + * The property which stores the persistence context unit name associated with the default + * Entity Manager. + */ + public static final String PERSISTENCE_CONTEXT_UNIT_NAME = "persistenceContextUnitName"; + + /** + * The property used to specify the implementation operation name pattern + * on service and entity beans. + */ + public static final String IMPLEMENTATION_OPERATION_NAME_PATTERN = + "implementationOperationNamePattern"; + + /** + * The property used to specify whether to enable query cache. + */ + public static final String HIBERNATE_USER_QUERY_CACHE = "hibernateUseQueryCache"; + + /** + * The property that stores the comma separated list of roles for manageable + * service beans. + */ + public static final String MANAGEABLE_ROLES_ALLOWED = "manageableRolesAllowed"; + // --------------- Constants --------------------- /** @@ -225,29 +254,6 @@ public static final String TRANSFORMATION_TO_COLLECTION_METHOD_SUFFIX = "Collection"; /** - * The pattern used to construct the DAO name. - */ - public static final String DAO_PATTERN = "daoNamePattern"; - - /** - * The property which stores the persistence context unit name associated with the default - * Entity Manager. - */ - public static final String PERSISTENCE_CONTEXT_UNIT_NAME = "persistenceContextUnitName"; - - /** - * The property used to specify the implementation operation name pattern - * on service and entity beans. - */ - public static final String IMPLEMENTATION_OPERATION_NAME_PATTERN = - "implementationOperationNamePattern"; - - /** - * The property used to specify whether to enable query cache. - */ - public static final String HIBERNATE_USER_QUERY_CACHE = "hibernateUseQueryCache"; - - /** * Seam component scope type STATELESS */ public static final String SEAM_COMPONENT_SCOPE_STATELESS = "STATELESS"; 1.44 +228 -222 cartridges/andromda-ejb3/src/main/uml/EJB3MetafacadeModel.xml.zip <<Binary file>> |