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


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:        /*
024:         * SecurityContextTokenHeaderBlock.java
025:         *
026:         * Created on December 15, 2005, 6:41 PM
027:         *
028:         * To change this template, choose Tools | Template Manager
029:         * and open the template in the editor.
030:         */
031:
032:        package com.sun.xml.wss.core;
033:
034:        import com.sun.xml.ws.security.SecurityContextToken;
035:        import com.sun.xml.wss.XWSSecurityException;
036:        import com.sun.xml.wss.impl.MessageConstants;
037:        import com.sun.xml.wss.impl.SecurityTokenException;
038:        import com.sun.xml.wss.impl.XMLUtil;
039:        import com.sun.xml.wss.impl.misc.SecurityHeaderBlockImpl;
040:
041:        import java.util.Iterator;
042:        import java.util.List;
043:        import javax.xml.soap.SOAPElement;
044:        import javax.xml.soap.SOAPException;
045:        import org.w3c.dom.Document;
046:        import org.w3c.dom.Element;
047:        import org.w3c.dom.Node;
048:
049:        import java.net.URI;
050:
051:        /**
052:         *<wsc:SecurityContextToken wsu:Id="..." ...> 
053:         *    <wsc:Identifier>...</wsc:Identifier> 
054:         *    <wsc:Instance>...</wsc:Instance> 
055:         *    ... 
056:         *</wsc:SecurityContextToken>
057:         *
058:         */
059:        public class SecurityContextTokenImpl extends SecurityHeaderBlockImpl
060:                implements  SecurityContextToken, SecurityToken {
061:
062:            private String securityContextId = null;
063:            private String instance = null;
064:            private List extElements = null;
065:
066:            private String wsuId = null;
067:
068:            /**
069:             *
070:             * @param element
071:             * @return
072:             * @throws XWSSecurityException
073:             */
074:            public static SecurityHeaderBlock fromSoapElement(
075:                    SOAPElement element) throws XWSSecurityException {
076:                return SecurityHeaderBlockImpl.fromSoapElement(element,
077:                        SecurityContextTokenImpl.class);
078:            }
079:
080:            private Document contextDocument = null;
081:
082:            public SecurityContextTokenImpl(Document contextDocument,
083:                    String contextId, String instance, String wsuId,
084:                    List extElements) throws XWSSecurityException {
085:                securityContextId = contextId;
086:                this .instance = instance;
087:                this .wsuId = wsuId;
088:                this .extElements = extElements;
089:                this .contextDocument = contextDocument;
090:            }
091:
092:            public SecurityContextTokenImpl(SOAPElement sct)
093:                    throws XWSSecurityException {
094:
095:                setSOAPElement(sct);
096:
097:                this .contextDocument = getOwnerDocument();
098:
099:                if (!("SecurityContextToken".equals(getLocalName()) && XMLUtil
100:                        .inWsscNS(this ))) {
101:                    throw new SecurityTokenException(
102:                            "Expected wsc:SecurityContextToken Element, but Found "
103:                                    + getPrefix() + ":" + getLocalName());
104:                }
105:
106:                String wsuId = getAttributeNS(MessageConstants.WSU_NS, "Id");
107:                if (!"".equals(wsuId))
108:                    setId(wsuId);
109:
110:                Iterator children = getChildElements();
111:                Node object = null;
112:
113:                while (children.hasNext()) {
114:
115:                    object = (Node) children.next();
116:                    if (object.getNodeType() == Node.ELEMENT_NODE) {
117:
118:                        SOAPElement element = (SOAPElement) object;
119:                        if ("Identifier".equals(element.getLocalName())
120:                                && XMLUtil.inWsscNS(element)) {
121:                            securityContextId = element.getFirstChild()
122:                                    .getNodeValue();
123:                        } else if ("Instance".equals(element.getLocalName())
124:                                && XMLUtil.inWsscNS(element)) {
125:                            this .instance = element.getFirstChild()
126:                                    .getNodeValue();
127:                        } else {
128:                            extElements.add(object);
129:                        }
130:                    }
131:                }
132:
133:                if (securityContextId == null) {
134:                    throw new XWSSecurityException(
135:                            "Missing Identifier subelement in SecurityContextToken");
136:                }
137:            }
138:
139:            public SOAPElement getAsSoapElement() throws XWSSecurityException {
140:                if (delegateElement != null)
141:                    return delegateElement;
142:
143:                try {
144:                    setSOAPElement((SOAPElement) contextDocument
145:                            .createElementNS(MessageConstants.WSSC_NS,
146:                                    MessageConstants.WSSC_PREFIX
147:                                            + ":SecurityContextToken"));
148:                    /*addNamespaceDeclaration(
149:                            MessageConstants.WSSE11_PREFIX,
150:                            MessageConstants.WSS11_SPEC_NS);*/
151:                    addNamespaceDeclaration(MessageConstants.WSSC_PREFIX,
152:                            MessageConstants.WSSC_NS);
153:                    if (securityContextId == null) {
154:                        throw new XWSSecurityException(
155:                                "Missing SecurityContextToken Identifier");
156:                    } else {
157:                        addChildElement("Identifier",
158:                                MessageConstants.WSSC_PREFIX).addTextNode(
159:                                securityContextId);
160:                    }
161:
162:                    if (this .instance != null) {
163:                        addChildElement("Instance",
164:                                MessageConstants.WSSC_PREFIX).addTextNode(
165:                                this .instance);
166:                    }
167:
168:                    if (wsuId != null) {
169:                        setWsuIdAttr(this , wsuId);
170:                    }
171:
172:                    if (extElements != null) {
173:                        for (int i = 0; i < extElements.size(); i++) {
174:                            Element element = (Element) extElements.get(i);
175:                            Node newElement = delegateElement
176:                                    .getOwnerDocument().importNode(element,
177:                                            true);
178:                            appendChild(newElement);
179:                        }
180:                    }
181:
182:                } catch (SOAPException se) {
183:                    throw new SecurityTokenException(
184:                            "There was an error creating SecurityContextToken "
185:                                    + se.getMessage());
186:                }
187:
188:                return super .getAsSoapElement();
189:            }
190:
191:            public Document getContextDocument() {
192:                return contextDocument;
193:            }
194:
195:            public String getType() {
196:                return MessageConstants.SECURITY_CONTEXT_TOKEN_NS;
197:            }
198:
199:            public Object getTokenValue() {
200:                return this ;
201:            }
202:
203:            public void setId(String wsuId) {
204:                this .wsuId = wsuId;
205:            }
206:
207:            public String getWsuId() {
208:                return this .wsuId;
209:            }
210:
211:            // dont use this
212:            public URI getIdentifier() {
213:                try {
214:                    return new URI(securityContextId);
215:                } catch (Exception e) {
216:                    throw new RuntimeException(e);
217:                }
218:            }
219:
220:            public String getSCId() {
221:                return securityContextId;
222:            }
223:
224:            public String getInstance() {
225:                return instance;
226:            }
227:
228:            public List getExtElements() {
229:                return extElements;
230:            }
231:
232:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.