001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.servicemix.soap.marshalers;
018
019 import java.security.Principal;
020 import java.util.HashMap;
021 import java.util.Map;
022
023 import javax.activation.DataHandler;
024 import javax.security.auth.Subject;
025 import javax.xml.namespace.QName;
026 import javax.xml.transform.Source;
027
028 import org.apache.servicemix.soap.SoapFault;
029 import org.w3c.dom.Document;
030 import org.w3c.dom.DocumentFragment;
031
032 /**
033 * Simple DTO to hold attachments, soap headers and main xml source.
034 *
035 * @author Guillaume Nodet
036 * @version $Revision: 359186 $
037 * @since 3.0
038 */
039 public class SoapMessage {
040
041 private QName envelopeName;
042 private QName bodyName;
043 private Source source;
044 private Map attachments;
045 private Map headers;
046 private SoapFault fault;
047 private Subject subject;
048 private Document document;
049
050 /**
051 * @return the document
052 */
053 public Document getDocument() {
054 return document;
055 }
056 /**
057 * @param document the document to set
058 */
059 public void setDocument(Document document) {
060 this.document = document;
061 }
062 /**
063 * @return the subject
064 */
065 public Subject getSubject() {
066 return subject;
067 }
068 /**
069 * @param subject the subject to set
070 */
071 public void setSubject(Subject subject) {
072 this.subject = subject;
073 }
074 public Map getAttachments() {
075 return attachments;
076 }
077 public void setAttachments(Map attachments) {
078 this.attachments = attachments;
079 }
080 public void addAttachment(String name, DataHandler handler) {
081 if (this.attachments == null) {
082 this.attachments = new HashMap();
083 }
084 this.attachments.put(name, handler);
085 }
086 public boolean hasAttachments() {
087 return attachments != null && attachments.size() > 0;
088 }
089
090 public Map getHeaders() {
091 return headers;
092 }
093 public void setHeaders(Map headers) {
094 this.headers = headers;
095 }
096 public void addHeader(QName name, DocumentFragment header) {
097 if (this.headers == null) {
098 this.headers = new HashMap();
099 }
100 this.headers.put(name, header);
101 }
102 public boolean hasHeaders() {
103 return headers != null && headers.size() > 0;
104 }
105
106 public Source getSource() {
107 return source;
108 }
109 public void setSource(Source source) {
110 this.source = source;
111 }
112
113 public QName getEnvelopeName() {
114 return envelopeName;
115 }
116 public void setEnvelopeName(QName envelopeName) {
117 this.envelopeName = envelopeName;
118 }
119 public QName getBodyName() {
120 return bodyName;
121 }
122 public void setBodyName(QName bodyName) {
123 this.bodyName = bodyName;
124 }
125
126 public SoapFault getFault() {
127 return fault;
128 }
129 public void setFault(SoapFault fault) {
130 this.fault = fault;
131 }
132
133 public void addPrincipal(Principal principal) {
134 if (subject == null) {
135 subject = new Subject();
136 }
137 subject.getPrincipals().add(principal);
138 }
139
140 }