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: /**
058: * @param document the document to set
059: */
060: public void setDocument(Document document) {
061: this .document = document;
062: }
063:
064: /**
065: * @return the subject
066: */
067: public Subject getSubject() {
068: return subject;
069: }
070:
071: /**
072: * @param subject the subject to set
073: */
074: public void setSubject(Subject subject) {
075: this .subject = subject;
076: }
077:
078: public Map getAttachments() {
079: return attachments;
080: }
081:
082: public void setAttachments(Map attachments) {
083: this .attachments = attachments;
084: }
085:
086: public void addAttachment(String name, DataHandler handler) {
087: if (this .attachments == null) {
088: this .attachments = new HashMap();
089: }
090: this .attachments.put(name, handler);
091: }
092:
093: public boolean hasAttachments() {
094: return attachments != null && attachments.size() > 0;
095: }
096:
097: public Map getHeaders() {
098: return headers;
099: }
100:
101: public void setHeaders(Map headers) {
102: this .headers = headers;
103: }
104:
105: public void addHeader(QName name, DocumentFragment header) {
106: if (this .headers == null) {
107: this .headers = new HashMap();
108: }
109: this .headers.put(name, header);
110: }
111:
112: public boolean hasHeaders() {
113: return headers != null && headers.size() > 0;
114: }
115:
116: public Source getSource() {
117: return source;
118: }
119:
120: public void setSource(Source source) {
121: this .source = source;
122: }
123:
124: public QName getEnvelopeName() {
125: return envelopeName;
126: }
127:
128: public void setEnvelopeName(QName envelopeName) {
129: this .envelopeName = envelopeName;
130: }
131:
132: public QName getBodyName() {
133: return bodyName;
134: }
135:
136: public void setBodyName(QName bodyName) {
137: this .bodyName = bodyName;
138: }
139:
140: public SoapFault getFault() {
141: return fault;
142: }
143:
144: public void setFault(SoapFault fault) {
145: this .fault = fault;
146: }
147:
148: public void addPrincipal(Principal principal) {
149: if (subject == null) {
150: subject = new Subject();
151: }
152: subject.getPrincipals().add(principal);
153: }
154:
155: }
|