1 8 9 package mx4j.tools.remote.soap.axis.ser; 10 11 import java.io.IOException ; 12 import javax.security.auth.Subject ; 13 import javax.xml.namespace.QName ; 14 15 import org.apache.axis.encoding.SerializationContext; 16 import org.apache.axis.encoding.XMLType; 17 import org.apache.axis.wsdl.fromJava.Types; 18 import org.w3c.dom.Element ; 19 import org.xml.sax.Attributes ; 20 21 24 public class SubjectSer extends AxisSerializer 25 { 26 static final String TYPE = "Subject"; 27 static final String READ_ONLY = "readOnly"; 28 static final String PRINCIPALS = "principals"; 29 static final String PUBLIC_CREDENTIALS = "publicCredentials"; 30 static final String PRIVATE_CREDENTIALS = "privateCredentials"; 31 private static final QName READ_ONLY_QNAME = new QName ("", READ_ONLY); 32 private static final QName PRINCIPALS_QNAME = new QName ("", PRINCIPALS); 33 private static final QName PUBLIC_CREDENTIALS_QNAME = new QName ("", PUBLIC_CREDENTIALS); 34 private static final QName PRIVATE_CREDENTIALS_QNAME = new QName ("", PRIVATE_CREDENTIALS); 35 36 public void serialize(QName name, Attributes attributes, Object value, SerializationContext context) throws IOException 37 { 38 Subject subject = (Subject )value; 39 context.startElement(name, attributes); 40 context.serialize(READ_ONLY_QNAME, null, new Boolean (subject.isReadOnly())); 41 context.serialize(PRINCIPALS_QNAME, null, subject.getPrincipals()); 42 context.serialize(PUBLIC_CREDENTIALS_QNAME, null, subject.getPublicCredentials()); 43 context.serialize(PRIVATE_CREDENTIALS_QNAME, null, subject.getPrivateCredentials()); 44 context.endElement(); 45 } 46 47 public Element writeSchema(Class aClass, Types types) throws Exception 48 { 49 Element complexType = types.createElement(SCHEMA_COMPLEX_TYPE); 50 complexType.setAttribute("name", TYPE); 51 Element allElement = types.createElement(SCHEMA_ALL); 52 complexType.appendChild(allElement); 53 54 Element readOnlyElement = types.createElement(SCHEMA_ELEMENT); 55 readOnlyElement.setAttribute("name", READ_ONLY); 56 readOnlyElement.setAttribute("type", XMLType.XSD_BOOLEAN.getLocalPart()); 57 allElement.appendChild(readOnlyElement); 58 59 Element principalsElement = types.createElement(SCHEMA_ELEMENT); 60 principalsElement.setAttribute("name", PRINCIPALS); 61 principalsElement.setAttribute("type", SetSer.TYPE); 62 allElement.appendChild(principalsElement); 63 64 Element publicCredentialsElement = types.createElement(SCHEMA_ELEMENT); 65 publicCredentialsElement.setAttribute("name", PUBLIC_CREDENTIALS); 66 publicCredentialsElement.setAttribute("type", SetSer.TYPE); 67 allElement.appendChild(publicCredentialsElement); 68 69 Element privateCredentialsElement = types.createElement(SCHEMA_ELEMENT); 70 privateCredentialsElement.setAttribute("name", PRIVATE_CREDENTIALS); 71 privateCredentialsElement.setAttribute("type", SetSer.TYPE); 72 allElement.appendChild(privateCredentialsElement); 73 74 return complexType; 75 } 76 } 77 | Popular Tags |