1 23 24 package com.sun.enterprise.deployment.node.connector; 25 26 import java.util.*; 27 import org.xml.sax.Attributes ; 28 import com.sun.enterprise.deployment.Descriptor; 29 import com.sun.enterprise.deployment.OutboundResourceAdapter; 30 import com.sun.enterprise.deployment.AuthMechanism; 31 import com.sun.enterprise.deployment.SecurityPermission; 32 import com.sun.enterprise.deployment.xml.ConnectorTagNames; 33 import com.sun.enterprise.deployment.xml.TagNames; 34 import com.sun.enterprise.deployment.EnvironmentProperty; 35 import com.sun.enterprise.deployment.node.DescriptorFactory; 36 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode; 37 import com.sun.enterprise.deployment.node.ConfigurableNode; 38 import com.sun.enterprise.deployment.node.XMLElement; 39 40 import com.sun.enterprise.deployment.ConnectorDescriptor; 41 42 import org.xml.sax.Attributes ; 43 import org.w3c.dom.Node ; 44 45 51 public class AuthMechNode extends DeploymentDescriptorNode { 52 53 private AuthMechanism auth = null; 54 55 61 62 protected Map getDispatchTable() { 63 Map table = super.getDispatchTable(); 64 table.put(ConnectorTagNames.CREDENTIAL_INTF, "setCredentialInterface"); 65 table.put(ConnectorTagNames.AUTH_MECH_TYPE, "setAuthMechVal"); 66 return table; 67 } 68 69 72 public Object getDescriptor() { 73 if (auth == null) { 74 auth = (AuthMechanism) DescriptorFactory.getDescriptor(getXMLPath()); 75 } 76 return auth; 77 } 78 79 86 public Node writeDescriptor(Node parent, Descriptor descriptor) { 87 88 if (! (descriptor instanceof OutboundResourceAdapter) && 89 ! (descriptor instanceof ConnectorDescriptor)) { 90 throw new IllegalArgumentException (getClass() + " cannot handle descriptors of type " + descriptor.getClass()); 91 } 92 93 Iterator authMechs = null; 94 95 if (descriptor instanceof ConnectorDescriptor) { 96 authMechs = ((ConnectorDescriptor)descriptor).getAuthMechanisms().iterator(); 97 } else if (descriptor instanceof OutboundResourceAdapter) { 98 authMechs = ((OutboundResourceAdapter)descriptor).getAuthMechanisms().iterator(); 99 } 100 101 for (;authMechs.hasNext();) { 103 AuthMechanism auth = (AuthMechanism) authMechs.next(); 104 Node authNode = appendChild(parent, ConnectorTagNames.AUTH_MECHANISM); 105 appendTextChild(authNode, TagNames.DESCRIPTION, auth.getDescription()); 106 appendTextChild(authNode, ConnectorTagNames.AUTH_MECH_TYPE, auth.getAuthMechType()); 107 appendTextChild(authNode, ConnectorTagNames.CREDENTIAL_INTF, auth.getCredentialInterface()); 108 } 109 return parent; 110 } 111 } 112 | Popular Tags |