001: /*
002: * The contents of this file are subject to the terms
003: * of the Common Development and Distribution License
004: * (the License). You may not use this file except in
005: * compliance with the License.
006: *
007: * You can obtain a copy of the license at
008: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
009: * See the License for the specific language governing
010: * permissions and limitations under the License.
011: *
012: * When distributing Covered Code, include this CDDL
013: * Header Notice in each file and include the License file
014: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
015: * If applicable, add the following below the CDDL Header,
016: * with the fields enclosed by brackets [] replaced by
017: * you own identifying information:
018: * "Portions Copyrighted [year] [name of copyright owner]"
019: *
020: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
021: */
022:
023: package com.sun.xml.ws.security.opt.impl.crypto;
024:
025: import com.sun.xml.ws.security.opt.api.SecurityElement;
026: import com.sun.xml.ws.security.opt.api.SecurityElementWriter;
027: import com.sun.xml.ws.security.opt.impl.util.XMLStreamFilter;
028: import com.sun.xml.ws.security.opt.crypto.StreamWriterData;
029: import java.util.HashMap;
030: import javax.xml.stream.XMLStreamWriter;
031: import org.jvnet.staxex.NamespaceContextEx;
032: import com.sun.xml.stream.buffer.XMLStreamBuffer;
033:
034: /**
035: *
036: * @author K.Venugopal@sun.com
037: */
038: public class SSEData implements StreamWriterData {
039:
040: private NamespaceContextEx nsContext;
041: private boolean contentOnly;
042: private SecurityElement data;
043: private XMLStreamBuffer buffer = null;
044: private HashMap props = new HashMap();
045:
046: /** Creates a new instance of SSEData */
047: public SSEData(SecurityElement se, boolean contentOnly,
048: NamespaceContextEx ns) {
049: this .data = se;
050: this .nsContext = ns;
051: this .contentOnly = contentOnly;
052: //props.put("com.sun.xml.bind.namespacePrefixMapper", new WSSNSPrefixWrapper(JAXBUtil.prefixMapper11));
053: }
054:
055: public SSEData(SecurityElement se, boolean contentOnly,
056: NamespaceContextEx ns, HashMap props) {
057: this .data = se;
058: this .nsContext = ns;
059: this .contentOnly = contentOnly;
060: this .props = props;
061: }
062:
063: public SSEData(XMLStreamBuffer buffer) {
064: this .buffer = buffer;
065: }
066:
067: public NamespaceContextEx getNamespaceContext() {
068: return nsContext;
069: }
070:
071: public SecurityElement getSecurityElement() {
072: return data;
073: }
074:
075: public void write(javax.xml.stream.XMLStreamWriter writer)
076: throws javax.xml.stream.XMLStreamException {
077: if (buffer != null) {
078: buffer.writeToXMLStreamWriter(writer);
079: }
080:
081: if (contentOnly) {
082: XMLStreamWriter fw;
083: fw = new XMLStreamFilter(
084: writer,
085: (com.sun.xml.ws.security.opt.impl.util.NamespaceContextEx) nsContext);
086: if (props != null) {
087: ((SecurityElementWriter) data).writeTo(fw, props);
088: } else {
089: ((SecurityElementWriter) data).writeTo(fw);
090: }
091: } else {
092: if (props != null) {
093: ((SecurityElementWriter) data).writeTo(writer, props);
094: } else {
095: ((SecurityElementWriter) data).writeTo(writer);
096: }
097: }
098: }
099:
100: }
|