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.incoming;
024:
025: import com.sun.xml.ws.security.opt.api.PolicyBuilder;
026: import com.sun.xml.ws.security.opt.api.SecurityElementWriter;
027: import com.sun.xml.ws.security.opt.api.SecurityHeaderElement;
028: import com.sun.xml.ws.security.opt.impl.JAXBFilterProcessingContext;
029: import com.sun.xml.ws.security.opt.impl.incoming.processor.ReferenceListProcessor;
030: import com.sun.xml.wss.impl.policy.mls.EncryptionPolicy;
031: import com.sun.xml.wss.impl.policy.mls.WSSPolicy;
032: import java.io.OutputStream;
033: import java.util.ArrayList;
034: import java.util.HashMap;
035: import java.util.List;
036: import javax.xml.stream.XMLStreamException;
037: import javax.xml.stream.XMLStreamReader;
038: import javax.xml.stream.XMLStreamWriter;
039:
040: /**
041: *
042: * @author Ashutosh.Shahi@sun.com
043: */
044: public class ReferenceListHeader implements SecurityHeaderElement,
045: SecurityElementWriter, PolicyBuilder {
046:
047: //private static String DATA_REFERENCE = "DataReference".intern();
048: private static final int DATA_REFERENCE_ELEMENT = 1;
049:
050: private String id = "";
051: private String namespaceURI = "";
052: private String localName = "";
053: private JAXBFilterProcessingContext pc = null;
054: private ArrayList<String> referenceList = null;
055: private ArrayList<String> pendingRefList = null;
056:
057: private EncryptionPolicy encPolicy = null;
058:
059: /** Creates a new instance of ReferenceListHeader */
060: public ReferenceListHeader(XMLStreamReader reader,
061: JAXBFilterProcessingContext pc) throws XMLStreamException {
062: this .pc = pc;
063: encPolicy = new EncryptionPolicy();
064: encPolicy
065: .setFeatureBinding(new EncryptionPolicy.FeatureBinding());
066: process(reader);
067: }
068:
069: public boolean refersToSecHdrWithId(String id) {
070: throw new UnsupportedOperationException();
071: }
072:
073: public String getId() {
074: return id;
075: }
076:
077: public void setId(final String id) {
078: throw new UnsupportedOperationException();
079: }
080:
081: public String getNamespaceURI() {
082: return namespaceURI;
083: }
084:
085: public String getLocalPart() {
086: return localName;
087: }
088:
089: public XMLStreamReader readHeader() throws XMLStreamException {
090: throw new UnsupportedOperationException();
091: }
092:
093: public void writeTo(OutputStream os) {
094: throw new UnsupportedOperationException();
095: }
096:
097: public void writeTo(XMLStreamWriter streamWriter)
098: throws XMLStreamException {
099: throw new UnsupportedOperationException();
100: }
101:
102: public List<String> getReferenceList() {
103: return referenceList;
104: }
105:
106: public List<String> getPendingReferenceList() {
107: return pendingRefList;
108: }
109:
110: private void process(XMLStreamReader reader)
111: throws XMLStreamException {
112: id = reader.getAttributeValue(null, "Id");
113: namespaceURI = reader.getNamespaceURI();
114: localName = reader.getLocalName();
115:
116: ReferenceListProcessor rlp = new ReferenceListProcessor(
117: encPolicy);
118: rlp.process(reader);
119: referenceList = rlp.getReferences();
120: pendingRefList = (ArrayList<String>) referenceList.clone();
121: }
122:
123: public void writeTo(javax.xml.stream.XMLStreamWriter streamWriter,
124: HashMap props) throws javax.xml.stream.XMLStreamException {
125: throw new UnsupportedOperationException();
126: }
127:
128: public WSSPolicy getPolicy() {
129: return encPolicy;
130: }
131:
132: }
|