1 23 package com.sun.enterprise.deployment.node.runtime.common; 24 25 import com.sun.enterprise.deployment.node.runtime.RuntimeDescriptorNode; 26 import com.sun.enterprise.deployment.node.XMLElement; 27 import com.sun.enterprise.deployment.runtime.common.PrincipalNameDescriptor; 28 import com.sun.enterprise.deployment.runtime.common.SecurityRoleMapping; 29 import com.sun.enterprise.deployment.xml.RuntimeTagNames; 30 import java.util.List ; 31 import java.util.Map ; 32 import org.w3c.dom.Node ; 33 34 40 public class SecurityRoleMappingNode extends RuntimeDescriptorNode { 41 42 public SecurityRoleMappingNode() { 43 registerElementHandler( 44 new XMLElement(RuntimeTagNames.PRINCIPAL_NAME), 45 PrincipalNameNode.class, "addPrincipalName"); 46 } 47 48 54 public void setElementValue(XMLElement element, String value) { 55 SecurityRoleMapping srm = (SecurityRoleMapping) getDescriptor(); 56 if (RuntimeTagNames.ROLE_NAME.equals(element.getQName())) { 57 srm.setRoleName(value); 58 } else if (RuntimeTagNames.GROUP_NAME.equals(element.getQName())) { 59 srm.addGroupName(value); 60 } else super.setElementValue(element, value); 61 } 62 63 71 public Node writeDescriptor(Node parent, String nodeName, SecurityRoleMapping descriptor) { 72 Node roleMapping = appendChild(parent, nodeName); 73 74 appendTextChild(roleMapping, RuntimeTagNames.ROLE_NAME, descriptor.getRoleName()); 76 77 PrincipalNameNode principal = new PrincipalNameNode(); 79 List <PrincipalNameDescriptor> principals = descriptor.getPrincipalNames(); 80 for (int i = 0; i < principals.size(); i++) { 81 principal.writeDescriptor( 82 roleMapping, RuntimeTagNames.PRINCIPAL_NAME, principals.get(i)); 83 } 84 85 List <String > groups = descriptor.getGroupNames(); 87 for (int i = 0; i < groups.size(); i++) { 88 appendTextChild(roleMapping, RuntimeTagNames.GROUP_NAME, groups.get(i)); 89 } 90 return roleMapping; 91 } 92 } 93 | Popular Tags |