01: /*
02: * The contents of this file are subject to the terms
03: * of the Common Development and Distribution License
04: * (the License). You may not use this file except in
05: * compliance with the License.
06: *
07: * You can obtain a copy of the license at
08: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
09: * See the License for the specific language governing
10: * permissions and limitations under the License.
11: *
12: * When distributing Covered Code, include this CDDL
13: * Header Notice in each file and include the License file
14: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
15: * If applicable, add the following below the CDDL Header,
16: * with the fields enclosed by brackets [] replaced by
17: * you own identifying information:
18: * "Portions Copyrighted [year] [name of copyright owner]"
19: *
20: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
21: */
22:
23: package com.sun.xml.ws.security.opt.impl.crypto;
24:
25: import com.sun.xml.ws.api.message.Header;
26: import com.sun.xml.ws.security.opt.impl.util.XMLStreamFilter;
27: import com.sun.xml.ws.security.opt.crypto.StreamWriterData;
28: import javax.xml.stream.XMLStreamWriter;
29: import org.jvnet.staxex.NamespaceContextEx;
30:
31: /**
32: *
33: * @author K.Venugopal@sun.com
34: */
35: public class StreamHeaderData implements StreamWriterData {
36: private NamespaceContextEx nsContext;
37: private boolean contentOnly;
38: private Header data;
39:
40: /** Creates a new instance of HeaderData */
41: public StreamHeaderData(Header header, boolean contentOnly,
42: NamespaceContextEx ns) {
43: this .data = header;
44: nsContext = ns;
45: this .contentOnly = contentOnly;
46: }
47:
48: public NamespaceContextEx getNamespaceContext() {
49: return nsContext;
50: }
51:
52: public void write(javax.xml.stream.XMLStreamWriter writer)
53: throws javax.xml.stream.XMLStreamException {
54: if (contentOnly) {
55: XMLStreamWriter fw;
56: fw = new XMLStreamFilter(
57: writer,
58: (com.sun.xml.ws.security.opt.impl.util.NamespaceContextEx) nsContext);
59: data.writeTo(fw);
60: } else {
61: data.writeTo(writer);
62: }
63: }
64: }
|