Update of /cvsroot/xdoclet/xdoclet/modules/ejb/src/xdoclet/modules/ejb/dd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20897/xdoclet/modules/ejb/src/xdoclet/modules/ejb/dd
Modified Files: SecurityTagsHandler.java Log Message: XDT-1358: moved security-roles handling to SecurityTagsHandler, added description if present in security-identity Index: SecurityTagsHandler.java =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/modules/ejb/src/xdoclet/modules/ejb/dd/SecurityTagsHandler.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** SecurityTagsHandler.java 29 Apr 2003 19:14:40 -0000 1.7 --- SecurityTagsHandler.java 22 Apr 2005 13:02:30 -0000 1.8 *************** *** 14,17 **** --- 14,18 ---- import xdoclet.modules.ejb.intf.InterfaceTagsHandler; import xdoclet.util.DocletUtil; + import xdoclet.util.Translator; /** *************** *** 33,36 **** --- 34,42 ---- /** + * The description of the current security role name. + */ + protected transient String currentSecurityRoleDescription; + + /** * Returns current security role name set by the containing forAllSecurityRoles. * *************** *** 46,49 **** --- 52,68 ---- /** + * Returns description of current security role name set by the containing forAllSecurityRoles. + * + * @return description of current security role name + * @exception XDocletException + * @see #forAllSecurityRoles(java.lang.String) + * @doc.tag type="content" + */ + public String securityRoleDesciption() throws XDocletException + { + return currentSecurityRoleDescription; + } + + /** * Evaluates the body block for each ejb:permission defined in class level or method level. * *************** *** 59,62 **** --- 78,83 ---- Set roleSet = new HashSet(); + Map descriptions = new HashMap(); + String defaultDescription = Translator.getString("xdoclet.modules.ejb.XDocletModulesEjbMessagesMessages", "description_not_supported", null); for (Iterator i = classes.iterator(); i.hasNext(); ) { *************** *** 103,106 **** --- 124,157 ---- } + // Get roles from security-identity class level tags: + Collection identities = getCurrentClass().getDoc().getTags("ejb:security-identity"); + + for (Iterator k = identities.iterator(); k.hasNext(); ) { + XTag tag = (XTag) k.next(); + String runAsRoleName = tag.getAttributeValue("run-as"); + String description = tag.getAttributeValue("description"); + + // Add roles to set + if (runAsRoleName != null) { + roleSet.add(runAsRoleName); + if (description != null && description.trim().length() > 0) { + descriptions.put(runAsRoleName, description); + } + } + } + + // Get roles from security-roles class level tags (formerly inside asm-descriptor.xdt): + Collection additionalRoles = getCurrentClass().getDoc().getTags("ejb:security-roles"); + + for (Iterator k = additionalRoles.iterator(); k.hasNext(); ) { + XTag tag = (XTag) k.next(); + String roleNames = tag.getAttributeValue("role-names"); + + // Add roles to set + if (roleNames != null) { + roleSet.addAll(Arrays.asList(DocletUtil.tokenizeDelimitedToArray(roleNames, ","))); + } + } + // get roles from finders Collection finders = getCurrentClass().getDoc().getTags("ejb:finder"); *************** *** 108,115 **** for (Iterator j = finders.iterator(); j.hasNext(); ) { XTag tag = (XTag) j.next(); ! String roleName = tag.getAttributeValue("role-name"); ! if (roleName != null) { ! roleSet.addAll(Arrays.asList(DocletUtil.tokenizeDelimitedToArray(roleName, ","))); } } --- 159,166 ---- for (Iterator j = finders.iterator(); j.hasNext(); ) { XTag tag = (XTag) j.next(); ! String roleNames = tag.getAttributeValue("role-name"); ! if (roleNames != null) { ! roleSet.addAll(Arrays.asList(DocletUtil.tokenizeDelimitedToArray(roleNames, ","))); } } *************** *** 133,136 **** --- 184,191 ---- while (roleEnum.hasNext()) { currentSecurityRoleName = (String) roleEnum.next(); + currentSecurityRoleDescription = (String) descriptions.get(currentSecurityRoleName); + if (currentSecurityRoleDescription == null || currentSecurityRoleDescription.trim().length() == 0) { + currentSecurityRoleDescription = defaultDescription; + } generate(template); ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ xdoclet-devel mailing list xdoclet-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xdoclet-devel