Source Code Cross Referenced for SecurityTokenReference.java in  » 6.0-JDK-Modules-com.sun » xws-security » com » sun » xml » ws » security » opt » impl » keyinfo » 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.keyinfo 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * SecurityTokenReference.java
003:         *
004:         * Created on August 2, 2006, 5:15 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.keyinfo;
028:
029:        import com.sun.istack.NotNull;
030:        import com.sun.xml.ws.api.SOAPVersion;
031:        import com.sun.xml.ws.security.Token;
032:        import com.sun.xml.ws.security.opt.api.SecurityElementWriter;
033:        import com.sun.xml.ws.security.opt.api.reference.Reference;
034:        import com.sun.xml.ws.security.opt.api.SecurityHeaderElement;
035:        import com.sun.xml.ws.security.opt.impl.reference.X509Data;
036:        import com.sun.xml.ws.security.opt.impl.reference.X509IssuerSerial;
037:        import com.sun.xml.wss.impl.c14n.AttributeNS;
038:
039:        import java.util.HashMap;
040:        import java.util.Iterator;
041:        import java.util.List;
042:        import javax.xml.bind.JAXBException;
043:        import javax.xml.bind.Marshaller;
044:        import javax.xml.bind.JAXBElement;
045:        import javax.xml.namespace.QName;
046:        import javax.xml.stream.XMLStreamException;
047:        import javax.xml.stream.XMLStreamReader;
048:        import javax.xml.stream.XMLStreamWriter;
049:
050:        import com.sun.xml.ws.security.opt.impl.util.JAXBUtil;
051:        import com.sun.xml.ws.security.secext10.SecurityTokenReferenceType;
052:        import com.sun.xml.stream.buffer.XMLStreamBufferResult;
053:        import com.sun.xml.wss.impl.MessageConstants;
054:        import com.sun.xml.ws.security.opt.impl.reference.DirectReference;
055:        import com.sun.xml.ws.security.opt.impl.reference.KeyIdentifier;
056:        import com.sun.xml.ws.security.secext10.ObjectFactory;
057:
058:        import java.util.Map;
059:        import java.io.OutputStream;
060:
061:        /**
062:         *
063:         * @author Ashutosh.Shahi@sun.com
064:         */
065:
066:        public class SecurityTokenReference extends SecurityTokenReferenceType
067:                implements 
068:                com.sun.xml.ws.security.opt.api.keyinfo.SecurityTokenReference,
069:                SecurityHeaderElement, SecurityElementWriter, Token {
070:
071:            //private SecurityTokenReferenceType str = null;
072:
073:            private boolean isCanonicalized = false;
074:            SOAPVersion sv = SOAPVersion.SOAP_11;
075:
076:            /** Creates a new instance of SecurityTokenReference */
077:            public SecurityTokenReference(SOAPVersion soapVersion) {
078:                this .sv = soapVersion;
079:            }
080:
081:            public void setReference(Reference ref) {
082:                JAXBElement refElem = null;
083:                String type = ref.getType();
084:                ObjectFactory objFac = new ObjectFactory();
085:                if (KEYIDENTIFIER.equals(type)) {
086:                    refElem = objFac.createKeyIdentifier((KeyIdentifier) ref);
087:                } else if (REFERENCE.equals(type)) {
088:                    refElem = objFac.createReference((DirectReference) ref);
089:                } else if (X509DATA_ISSUERSERIAL.equals(type)) {
090:                    refElem = new com.sun.xml.security.core.dsig.ObjectFactory()
091:                            .createX509Data((X509Data) ref);
092:                }
093:
094:                if (refElem != null) {
095:                    List<Object> list = this .getAny();
096:                    list.clear();
097:                    list.add(refElem);
098:                }
099:            }
100:
101:            public Reference getReference() {
102:                List<Object> list = this .getAny();
103:                JAXBElement obj = (JAXBElement) list.get(0);
104:                String local = obj.getName().getLocalPart();
105:                if (REFERENCE.equals(local)) {
106:                    return (DirectReference) obj.getValue();
107:                } else if ("KeyIdentifier".equalsIgnoreCase(local)) {
108:                    return (KeyIdentifier) obj.getValue();
109:                } else if (X509DATA_ISSUERSERIAL.equals(local)) {
110:                    return (X509Data) obj.getValue();
111:                }
112:                //anything else??
113:                return null;
114:            }
115:
116:            public void setTokenType(String tokenType) {
117:                QName qname = new QName(MessageConstants.WSSE11_NS,
118:                        MessageConstants.TOKEN_TYPE_LNAME,
119:                        MessageConstants.WSSE11_PREFIX);
120:                Map<QName, String> otherAttributes = this .getOtherAttributes();
121:                otherAttributes.put(qname, tokenType);
122:            }
123:
124:            public String getTokenType() {
125:                QName qname = new QName(MessageConstants.WSSE11_NS,
126:                        MessageConstants.TOKEN_TYPE_LNAME,
127:                        MessageConstants.WSSE11_PREFIX);
128:                Map<QName, String> otherAttributes = this .getOtherAttributes();
129:                return otherAttributes.get(qname);
130:            }
131:
132:            public String getNamespaceURI() {
133:                return MessageConstants.WSSE_NS;
134:            }
135:
136:            public String getLocalPart() {
137:                return MessageConstants.WSSE_SECURITY_TOKEN_REFERENCE_LNAME;
138:            }
139:
140:            public String getAttribute(@NotNull
141:            String nsUri, @NotNull
142:            String localName) {
143:                QName qname = new QName(nsUri, localName);
144:                Map<QName, String> otherAttributes = this .getOtherAttributes();
145:                return otherAttributes.get(qname);
146:            }
147:
148:            public String getAttribute(@NotNull
149:            QName name) {
150:                Map<QName, String> otherAttributes = this .getOtherAttributes();
151:                return otherAttributes.get(name);
152:            }
153:
154:            public XMLStreamReader readHeader() throws XMLStreamException {
155:                XMLStreamBufferResult xbr = new XMLStreamBufferResult();
156:                JAXBElement<SecurityTokenReferenceType> strElem = new ObjectFactory()
157:                        .createSecurityTokenReference(this );
158:                try {
159:                    getMarshaller().marshal(strElem, xbr);
160:
161:                } catch (JAXBException je) {
162:                    throw new XMLStreamException(je);
163:                }
164:                return xbr.getXMLStreamBuffer().readAsXMLStreamReader();
165:            }
166:
167:            public void writeTo(XMLStreamWriter streamWriter)
168:                    throws XMLStreamException {
169:                JAXBElement<SecurityTokenReferenceType> strElem = new ObjectFactory()
170:                        .createSecurityTokenReference(this );
171:                try {
172:                    // If writing to Zephyr, get output stream and use JAXB UTF-8 writer
173:                    if (streamWriter instanceof  Map) {
174:                        OutputStream os = (OutputStream) ((Map) streamWriter)
175:                                .get("sjsxp-outputstream");
176:                        if (os != null) {
177:                            streamWriter.writeCharacters(""); // Force completion of open elems
178:                            getMarshaller().marshal(strElem, os);
179:                            return;
180:                        }
181:                    }
182:
183:                    getMarshaller().marshal(strElem, streamWriter);
184:                } catch (JAXBException e) {
185:                    throw new XMLStreamException(e);
186:                }
187:            }
188:
189:            public byte[] canonicalize(String algorithm,
190:                    List<AttributeNS> namespaceDecls) {
191:                throw new UnsupportedOperationException();
192:            }
193:
194:            public boolean isCanonicalized() {
195:                return isCanonicalized;
196:            }
197:
198:            private Marshaller getMarshaller() throws JAXBException {
199:                return JAXBUtil.createMarshaller(sv);
200:            }
201:
202:            public void writeTo(OutputStream os) {
203:                throw new UnsupportedOperationException();
204:            }
205:
206:            public boolean refersToSecHdrWithId(String id) {
207:                List list = super .getAny();
208:                if (list.size() > 0) {
209:                    JAXBElement je = (JAXBElement) list.get(0);
210:                    Object obj = je.getValue();
211:                    if (obj instanceof  DirectReference) {
212:                        StringBuffer sb = new StringBuffer();
213:                        sb.append("#");
214:                        sb.append(id);
215:                        return ((DirectReference) obj).getURI().equals(
216:                                sb.toString());
217:                    } else if (obj instanceof  KeyIdentifier) {
218:                        return ((KeyIdentifier) obj).refersToSecHdrWithId(id);
219:                    }
220:                }
221:                return false;
222:            }
223:
224:            public void writeTo(javax.xml.stream.XMLStreamWriter streamWriter,
225:                    HashMap props) throws javax.xml.stream.XMLStreamException {
226:                try {
227:                    Marshaller marshaller = getMarshaller();
228:                    Iterator<Map.Entry<Object, Object>> itr = props.entrySet()
229:                            .iterator();
230:                    while (itr.hasNext()) {
231:                        Map.Entry<Object, Object> entry = itr.next();
232:                        marshaller.setProperty((String) entry.getKey(), entry
233:                                .getValue());
234:                    }
235:                    writeTo(streamWriter);
236:                } catch (JAXBException jbe) {
237:                    throw new XMLStreamException(jbe);
238:                }
239:            }
240:
241:            public String getType() {
242:                return "SecurityTokenReference";
243:            }
244:
245:            public Object getTokenValue() {
246:                return getReference();
247:            }
248:
249:        }
w__w_w.___j__av___a__2s_.___c__o__m_ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.