Source Code Cross Referenced for EncryptedKeyHeaderBlock.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:         * $Id: EncryptedKeyHeaderBlock.java,v 1.3 2006/09/29 12:04:44 kumarjayanti Exp $
003:         */
004:
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.wss.core;
028:
029:        import com.sun.xml.wss.impl.MessageConstants;
030:        import com.sun.xml.wss.impl.XMLUtil;
031:        import com.sun.xml.wss.XWSSecurityException;
032:        import java.util.Iterator;
033:        import java.util.logging.Level;
034:
035:        import javax.xml.soap.SOAPElement;
036:        import javax.xml.soap.SOAPException;
037:
038:        import org.w3c.dom.Document;
039:
040:        import com.sun.xml.wss.impl.misc.SecurityHeaderBlockImpl;
041:
042:        /**
043:         * The schema definition of EncryptedKey element is as follows:
044:         * <xmp>
045:         * <element name='EncryptedKey' type='xenc:EncryptedKeyType'/>
046:         * <complexType name='EncryptedKeyType'>
047:         *     <complexContent>
048:         *         <extension base='xenc:EncryptedType'>
049:         *             <sequence>
050:         *                 <element ref='xenc:ReferenceList' minOccurs='0'/>
051:         *                 <element name='CarriedKeyName' type='string' minOccurs='0'/>
052:         *             </sequence>
053:         *             <attribute name='Recipient' type='string' use='optional'/>
054:         *         </extension>
055:         *     </complexContent>
056:         * </complexType>
057:         * </xmp>
058:         *
059:         * @author Vishal Mahajan
060:         */
061:        public class EncryptedKeyHeaderBlock extends EncryptedTypeHeaderBlock {
062:
063:            ReferenceListHeaderBlock referenceList;
064:
065:            SOAPElement carriedKeyName;
066:
067:            /**
068:             * Create an empty EncryptedKey element.
069:             *
070:             * @throws XWSSecurityException
071:             *     If there is problem creating an EncryptedKey element.
072:             */
073:            public EncryptedKeyHeaderBlock() throws XWSSecurityException {
074:                try {
075:                    setSOAPElement(getSoapFactory().createElement(
076:                            MessageConstants.XENC_ENCRYPTED_KEY_LNAME,
077:                            MessageConstants.XENC_PREFIX,
078:                            MessageConstants.XENC_NS));
079:                    addNamespaceDeclaration(MessageConstants.XENC_PREFIX,
080:                            MessageConstants.XENC_NS);
081:                } catch (SOAPException e) {
082:                    log.log(Level.SEVERE, "WSS0348.error.creating.ekhb", e
083:                            .getMessage());
084:                    throw new XWSSecurityException(e);
085:                }
086:            }
087:
088:            /**
089:             * Create an empty EncryptedKey element whose owner document is given.
090:             *
091:             * @throws XWSSecurityException
092:             *     If there is problem creating an EncryptedKey element
093:             */
094:            public EncryptedKeyHeaderBlock(Document doc)
095:                    throws XWSSecurityException {
096:                try {
097:                    setSOAPElement((SOAPElement) doc.createElementNS(
098:                            MessageConstants.XENC_NS,
099:                            MessageConstants.XENC_ENCRYPTED_KEY_QNAME));
100:                    addNamespaceDeclaration(MessageConstants.XENC_PREFIX,
101:                            MessageConstants.XENC_NS);
102:                } catch (Exception e) {
103:                    log.log(Level.SEVERE, "WSS0348.error.creating.ekhb", e
104:                            .getMessage());
105:                    throw new XWSSecurityException(e);
106:                }
107:            }
108:
109:            /**
110:             * @throws XWSSecurityException
111:             *     If there is problem in initializing EncryptedKey element.
112:             */
113:            public EncryptedKeyHeaderBlock(SOAPElement element)
114:                    throws XWSSecurityException {
115:
116:                try {
117:
118:                    setSOAPElement(element);
119:
120:                    if (!(element.getLocalName().equals(
121:                            MessageConstants.XENC_ENCRYPTED_KEY_LNAME) && XMLUtil
122:                            .inEncryptionNS(element))) {
123:                        log.log(Level.SEVERE, "WSS0349.error.creating.ekhb",
124:                                element.getTagName());
125:                        throw new XWSSecurityException(
126:                                "Invalid EncryptedKey passed");
127:                    }
128:
129:                    initializeEncryptedType(element);
130:
131:                    Iterator referenceLists = getChildElements(getSoapFactory()
132:                            .createName("ReferenceList",
133:                                    MessageConstants.XENC_PREFIX,
134:                                    MessageConstants.XENC_NS));
135:                    if (referenceLists.hasNext())
136:                        this .referenceList = new ReferenceListHeaderBlock(
137:                                (SOAPElement) referenceLists.next());
138:
139:                    Iterator carriedKeyNames = getChildElements(getSoapFactory()
140:                            .createName("CarriedKeyName",
141:                                    MessageConstants.XENC_PREFIX,
142:                                    MessageConstants.XENC_NS));
143:                    if (carriedKeyNames.hasNext())
144:                        this .carriedKeyName = (SOAPElement) carriedKeyNames
145:                                .next();
146:
147:                } catch (Exception e) {
148:                    log.log(Level.SEVERE, "WSS0348.error.creating.ekhb", e
149:                            .getMessage());
150:                    throw new XWSSecurityException(e);
151:                }
152:            }
153:
154:            public void setCipherData(SOAPElement cipherData) {
155:                this .cipherData = cipherData;
156:                updateRequired = true;
157:            }
158:
159:            public void setCipherValue(String cipherValue)
160:                    throws XWSSecurityException {
161:
162:                try {
163:                    cipherData = getSoapFactory().createElement("CipherData",
164:                            MessageConstants.XENC_PREFIX,
165:                            MessageConstants.XENC_NS);
166:                    cipherData.addNamespaceDeclaration(
167:                            MessageConstants.XENC_PREFIX,
168:                            MessageConstants.XENC_NS);
169:
170:                    cipherData.addTextNode("\n    ");
171:                    SOAPElement cipherValueElement = cipherData
172:                            .addChildElement("CipherValue",
173:                                    MessageConstants.XENC_PREFIX);
174:                    cipherData.addTextNode("\n    ");
175:
176:                    cipherValueElement.addTextNode(cipherValue);
177:
178:                    cipherData
179:                            .removeNamespaceDeclaration(MessageConstants.XENC_PREFIX);
180:                } catch (SOAPException e) {
181:                    log.log(Level.SEVERE, "WSS0350.error.setting.ciphervalue",
182:                            e.getMessage());
183:                    throw new XWSSecurityException(e);
184:                }
185:                updateRequired = true;
186:            }
187:
188:            public ReferenceListHeaderBlock getReferenceList() {
189:                return referenceList;
190:            }
191:
192:            public void setReferenceList(ReferenceListHeaderBlock referenceList) {
193:                this .referenceList = referenceList;
194:                updateRequired = true;
195:            }
196:
197:            /**
198:             * Returns null if Recipient attr is not present
199:             */
200:            public String getRecipient() {
201:                String recipient = getAttribute("Recipient");
202:                if (recipient.equals(""))
203:                    return null;
204:                return recipient;
205:            }
206:
207:            public void setRecipient(String recipient) {
208:                setAttribute("Recipient", recipient);
209:            }
210:
211:            public SOAPElement getCarriedKeyName() {
212:                return carriedKeyName;
213:            }
214:
215:            public void setCarriedKeyName(SOAPElement carriedKeyName) {
216:                this .carriedKeyName = carriedKeyName;
217:                updateRequired = true;
218:            }
219:
220:            public static SecurityHeaderBlock fromSoapElement(
221:                    SOAPElement element) throws XWSSecurityException {
222:                return SecurityHeaderBlockImpl.fromSoapElement(element,
223:                        EncryptedKeyHeaderBlock.class);
224:            }
225:
226:            public SOAPElement getAsSoapElement() throws XWSSecurityException {
227:                if (updateRequired) {
228:                    removeContents();
229:                    try {
230:                        addTextNode("\n    ");
231:                        if (encryptionMethod != null) {
232:                            addChildElement(encryptionMethod);
233:                            addTextNode("\n    ");
234:                        }
235:                        if (keyInfo != null) {
236:                            addChildElement(keyInfo.getAsSoapElement());
237:                            addTextNode("\n    ");
238:                        }
239:                        if (cipherData == null) {
240:                            log
241:                                    .log(Level.SEVERE,
242:                                            "WSS0347.missing.cipher.data");
243:                            throw new XWSSecurityException(
244:                                    "CipherData is not present inside EncryptedType");
245:                        }
246:                        addChildElement(cipherData);
247:                        addTextNode("\n    ");
248:                        if (encryptionProperties != null) {
249:                            addChildElement(encryptionProperties);
250:                            addTextNode("\n    ");
251:                        }
252:                        if (referenceList != null) {
253:                            addChildElement(referenceList.getAsSoapElement());
254:                            addTextNode("\n    ");
255:                        }
256:                        if (carriedKeyName != null) {
257:                            addChildElement(carriedKeyName);
258:                            addTextNode("\n    ");
259:                        }
260:                    } catch (SOAPException e) {
261:                        log.log(Level.SEVERE, "WSS0348.error.creating.ekhb", e
262:                                .getMessage());
263:                        throw new XWSSecurityException(e);
264:                    }
265:                }
266:                return super.getAsSoapElement();
267:            }
268:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.