Source Code Cross Referenced for DirectReference.java in  » 6.0-JDK-Modules-com.sun » xws-security » com » sun » xml » ws » security » opt » impl » reference » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules com.sun » xws security » com.sun.xml.ws.security.opt.impl.reference 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DirectReference.java
003:         *
004:         * Created on August 7, 2006, 1:46 PM
005:         *
006:         * The contents of this file are subject to the terms
007:         * of the Common Development and Distribution License
008:         * (the License).  You may not use this file except in
009:         * compliance with the License.
010:         *
011:         * You can obtain a copy of the license at
012:         * https://glassfish.dev.java.net/public/CDDLv1.0.html.
013:         * See the License for the specific language governing
014:         * permissions and limitations under the License.
015:         *
016:         * When distributing Covered Code, include this CDDL
017:         * Header Notice in each file and include the License file
018:         * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
019:         * If applicable, add the following below the CDDL Header,
020:         * with the fields enclosed by brackets [] replaced by
021:         * you own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
025:         */
026:
027:        package com.sun.xml.ws.security.opt.impl.reference;
028:
029:        import com.sun.istack.NotNull;
030:        import com.sun.xml.ws.security.opt.api.SecurityElementWriter;
031:        import com.sun.xml.ws.security.opt.api.SecurityHeaderElement;
032:        import java.util.Collections;
033:        import java.util.HashMap;
034:        import java.util.Iterator;
035:        import java.util.List;
036:        import javax.xml.bind.JAXBException;
037:        import javax.xml.bind.Marshaller;
038:        import javax.xml.bind.JAXBElement;
039:        import javax.xml.namespace.QName;
040:        import javax.xml.stream.XMLStreamException;
041:        import javax.xml.stream.XMLStreamReader;
042:        import javax.xml.stream.XMLStreamWriter;
043:
044:        import com.sun.xml.ws.security.secext10.ReferenceType;
045:        import com.sun.xml.ws.security.secext10.ObjectFactory;
046:        import com.sun.xml.stream.buffer.XMLStreamBufferResult;
047:        import com.sun.xml.ws.security.opt.impl.util.JAXBUtil;
048:        import com.sun.xml.wss.impl.MessageConstants;
049:
050:        import java.util.Map;
051:        import java.io.OutputStream;
052:        import com.sun.xml.ws.api.SOAPVersion;
053:
054:        /**
055:         * Class for DirectReference reference type inside a STR
056:         * @author Ashutosh.Shahi@sun.com
057:         */
058:        public class DirectReference extends ReferenceType implements 
059:                com.sun.xml.ws.security.opt.api.reference.DirectReference,
060:                SecurityHeaderElement, SecurityElementWriter {
061:
062:            private SOAPVersion soapVersion = SOAPVersion.SOAP_11;
063:
064:            /** Creates a new instance of DirectReference */
065:            public DirectReference(SOAPVersion sv) {
066:                this .soapVersion = sv;
067:            }
068:
069:            /**
070:             * 
071:             * @return the valueType attribute of direct reference
072:             */
073:            public String getValueType() {
074:                return super .getValueType();
075:            }
076:
077:            /**
078:             * 
079:             * @param valueType sets the valueType attribute
080:             */
081:            public void setValueType(final String valueType) {
082:                super .setValueType(valueType);
083:            }
084:
085:            /**
086:             * 
087:             * @return the URI attribute
088:             */
089:            public String getURI() {
090:                return super .getURI();
091:            }
092:
093:            /**
094:             * 
095:             * @param uri sets the uri attribute
096:             */
097:            public void setURI(final String uri) {
098:                super .setURI(uri);
099:            }
100:
101:            /**
102:             * 
103:             * @return the reference type used
104:             */
105:            public String getType() {
106:                return MessageConstants.DIRECT_REFERENCE_TYPE;
107:            }
108:
109:            public String getId() {
110:                QName qname = new QName(MessageConstants.WSU_NS, "Id",
111:                        MessageConstants.WSU_PREFIX);
112:                Map<QName, String> otherAttributes = this .getOtherAttributes();
113:                return otherAttributes.get(qname);
114:            }
115:
116:            public void setId(final String id) {
117:                QName qname = new QName(MessageConstants.WSU_NS, "Id",
118:                        MessageConstants.WSU_PREFIX);
119:                Map<QName, String> otherAttributes = this .getOtherAttributes();
120:                otherAttributes.put(qname, id);
121:            }
122:
123:            public String getNamespaceURI() {
124:                return MessageConstants.WSSE_NS;
125:            }
126:
127:            public String getLocalPart() {
128:                return "Reference";
129:            }
130:
131:            public String getAttribute(@NotNull
132:            String nsUri, @NotNull
133:            String localName) {
134:                QName qname = new QName(nsUri, localName);
135:                Map<QName, String> otherAttributes = this .getOtherAttributes();
136:                return otherAttributes.get(qname);
137:            }
138:
139:            public String getAttribute(@NotNull
140:            QName name) {
141:                Map<QName, String> otherAttributes = this .getOtherAttributes();
142:                return otherAttributes.get(name);
143:            }
144:
145:            public XMLStreamReader readHeader() throws XMLStreamException {
146:                XMLStreamBufferResult xbr = new XMLStreamBufferResult();
147:                JAXBElement<ReferenceType> deirectRefElem = new ObjectFactory()
148:                        .createReference(this );
149:                try {
150:                    getMarshaller().marshal(deirectRefElem, xbr);
151:
152:                } catch (JAXBException je) {
153:                    throw new XMLStreamException(je);
154:                }
155:                return xbr.getXMLStreamBuffer().readAsXMLStreamReader();
156:            }
157:
158:            /**
159:             * Writes out the header.
160:             *
161:             * @throws XMLStreamException
162:             *      if the operation fails for some reason. This leaves the
163:             *      writer to an undefined state.
164:             */
165:            public void writeTo(XMLStreamWriter streamWriter)
166:                    throws XMLStreamException {
167:                JAXBElement<ReferenceType> deirectRefElem = new ObjectFactory()
168:                        .createReference(this );
169:                try {
170:                    // If writing to Zephyr, get output stream and use JAXB UTF-8 writer
171:                    if (streamWriter instanceof  Map) {
172:                        OutputStream os = (OutputStream) ((Map) streamWriter)
173:                                .get("sjsxp-outputstream");
174:                        if (os != null) {
175:                            streamWriter.writeCharacters(""); // Force completion of open elems
176:                            getMarshaller().marshal(deirectRefElem, os);
177:                            return;
178:                        }
179:                    }
180:
181:                    getMarshaller().marshal(deirectRefElem, streamWriter);
182:                } catch (JAXBException e) {
183:                    throw new XMLStreamException(e);
184:                }
185:            }
186:
187:            /**
188:             * 
189:             * @param streamWriter 
190:             * @param props 
191:             * @throws javax.xml.stream.XMLStreamException 
192:             */
193:            public void writeTo(javax.xml.stream.XMLStreamWriter streamWriter,
194:                    HashMap props) throws javax.xml.stream.XMLStreamException {
195:                try {
196:                    Marshaller marshaller = getMarshaller();
197:                    Iterator<Map.Entry<Object, Object>> itr = props.entrySet()
198:                            .iterator();
199:                    while (itr.hasNext()) {
200:                        Map.Entry<Object, Object> entry = itr.next();
201:                        marshaller.setProperty((String) entry.getKey(), entry
202:                                .getValue());
203:                    }
204:                    writeTo(streamWriter);
205:                } catch (JAXBException jbe) {
206:                    throw new XMLStreamException(jbe);
207:                }
208:            }
209:
210:            private Marshaller getMarshaller() throws JAXBException {
211:                return JAXBUtil.createMarshaller(soapVersion);
212:            }
213:
214:            /**
215:             * 
216:             * @param os 
217:             */
218:            public void writeTo(OutputStream os) {
219:            }
220:
221:            public List<String> getReferencedSecHeaderElements() {
222:                return Collections.emptyList();
223:            }
224:
225:            public void addReferencedSecHeaderElement(String id) {
226:            }
227:
228:            /**
229:             * 
230:             * @param id 
231:             * @return 
232:             */
233:            public boolean refersToSecHdrWithId(String id) {
234:                return false;
235:            }
236:
237:        }
w__ww.__j_a___v_a_2_s.___c_o___m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.