Source Code Cross Referenced for ACTransform.java in  » 6.0-JDK-Modules-com.sun » xws-security » com » sun » xml » wss » impl » transform » 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.impl.transform 
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:         * ACTranform.java
025:         *
026:         * Created on March 16, 2005, 2:14 PM
027:         */
028:
029:        package com.sun.xml.wss.impl.transform;
030:
031:        import com.sun.xml.wss.impl.misc.UnsyncByteArrayOutputStream;
032:        import com.sun.xml.wss.logging.LogDomainConstants;
033:        import java.util.logging.Level;
034:        import java.util.logging.Logger;
035:        import javax.xml.crypto.dsig.TransformService;
036:
037:        import com.sun.xml.wss.impl.c14n.Canonicalizer;
038:        import com.sun.xml.wss.impl.c14n.CanonicalizerFactory;
039:        import com.sun.xml.wss.impl.c14n.MimeHeaderCanonicalizer;
040:        import com.sun.xml.wss.impl.dsig.AttachmentData;
041:        import java.io.ByteArrayInputStream;
042:        import java.io.ByteArrayOutputStream;
043:        import java.io.InputStream;
044:        import java.io.OutputStream;
045:        import java.util.Iterator;
046:
047:        import javax.xml.crypto.Data;
048:        import javax.xml.crypto.OctetStreamData;
049:        import javax.xml.soap.AttachmentPart;
050:
051:        /**
052:         *
053:         * @author  K.Venugopal@sun.com
054:         */
055:        public class ACTransform extends TransformService {
056:            private static Logger logger = Logger.getLogger(
057:                    LogDomainConstants.IMPL_SIGNATURE_DOMAIN,
058:                    LogDomainConstants.IMPL_SIGNATURE_DOMAIN_BUNDLE);
059:
060:            /** Creates a new instance of ACTranform */
061:            public ACTransform() {
062:            }
063:
064:            public void init(
065:                    javax.xml.crypto.dsig.spec.TransformParameterSpec transformParameterSpec)
066:                    throws java.security.InvalidAlgorithmParameterException {
067:            }
068:
069:            public void init(javax.xml.crypto.XMLStructure xMLStructure,
070:                    javax.xml.crypto.XMLCryptoContext xMLCryptoContext)
071:                    throws java.security.InvalidAlgorithmParameterException {
072:            }
073:
074:            public java.security.spec.AlgorithmParameterSpec getParameterSpec() {
075:                return null;
076:            }
077:
078:            public void marshalParams(
079:                    javax.xml.crypto.XMLStructure xMLStructure,
080:                    javax.xml.crypto.XMLCryptoContext xMLCryptoContext)
081:                    throws javax.xml.crypto.MarshalException {
082:            }
083:
084:            /*
085:            private Data canonicalize(OctetStreamData octetData,javax.xml.crypto.XMLCryptoContext xMLCryptoContext) throws Exception {
086:               Vector mimeHeaders = (Vector)xMLCryptoContext.getProperty(MessageConstants.ATTACHMENT_MIME_HEADERS);
087:                InputStream os = octetData.getOctetStream();
088:                //Revisit ::
089:                // rf. RFC822
090:                MimeHeaderCanonicalizer mHCanonicalizer = CanonicalizerFactory.getMimeHeaderCanonicalizer("US-ASCII");
091:                byte[] outputHeaderBytes = mHCanonicalizer._canonicalize(mimeHeaders);
092:                Canonicalizer canonicalizer =  CanonicalizerFactory.getCanonicalizer(octetData.getMimeType());
093:                InputStream is = canonicalizer.canonicalize(os);
094:                ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
095:                byteStream.write(outputHeaderBytes);
096:                int len=0;
097:                byte [] data= null;
098:                try{
099:                    len = is.read(data);
100:                } catch (IOException e) {
101:                    // log me
102:                    throw new XWSSecurityException(e);
103:                }
104:             
105:                while(len > 0){
106:                    try {
107:                        byteStream.write(data);
108:                        len = is.read(data);
109:                    } catch (IOException e) {
110:                        // log me
111:                        throw new XWSSecurityException(e);
112:                    }
113:                }
114:                return new OctetStreamData(new ByteArrayInputStream(byteStream.toByteArray()));
115:            }
116:             */
117:
118:            private Data canonicalize(AttachmentData attachmentData,
119:                    OutputStream outputStream)
120:                    throws javax.xml.crypto.dsig.TransformException {
121:                try {
122:                    AttachmentPart attachment = attachmentData
123:                            .getAttachmentPart();
124:                    Iterator mimeHeaders = attachment.getAllMimeHeaders();
125:                    //Revisit ::
126:                    // rf. RFC822
127:                    MimeHeaderCanonicalizer mHCanonicalizer = CanonicalizerFactory
128:                            .getMimeHeaderCanonicalizer("US-ASCII");
129:                    byte[] outputHeaderBytes = mHCanonicalizer
130:                            ._canonicalize(mimeHeaders);
131:                    OutputStream byteStream = new UnsyncByteArrayOutputStream();
132:                    attachment.getDataHandler().writeTo(byteStream);
133:                    ByteArrayInputStream byteInputStream = new ByteArrayInputStream(
134:                            ((ByteArrayOutputStream) byteStream).toByteArray());
135:                    byteStream.close();
136:                    if (outputStream == null) {
137:                        byteStream = new ByteArrayOutputStream();
138:                    } else {
139:                        byteStream = outputStream;
140:                    }
141:                    byteStream.write(outputHeaderBytes);
142:                    Canonicalizer canonicalizer = CanonicalizerFactory
143:                            .getCanonicalizer(attachment.getContentType());
144:                    InputStream is = canonicalizer.canonicalize(
145:                            byteInputStream, byteStream);
146:                    if (is != null)
147:                        return new OctetStreamData(is);
148:                    return null;
149:                } catch (javax.xml.crypto.dsig.TransformException te) {
150:                    logger.log(Level.SEVERE, "WSS1319.aco.transform.error", te);
151:                    throw te;
152:                } catch (Exception ex) {
153:                    logger.log(Level.SEVERE, "WSS1319.aco.transform.error", ex);
154:                    throw new javax.xml.crypto.dsig.TransformException(ex
155:                            .getMessage());
156:                }
157:            }
158:
159:            public boolean isFeatureSupported(String str) {
160:                return false;
161:            }
162:
163:            public javax.xml.crypto.Data transform(javax.xml.crypto.Data data,
164:                    javax.xml.crypto.XMLCryptoContext xMLCryptoContext)
165:                    throws javax.xml.crypto.dsig.TransformException {
166:                if (data instanceof  AttachmentData) {
167:                    try {
168:                        return canonicalize((AttachmentData) data, null);
169:                    } catch (javax.xml.crypto.dsig.TransformException tex) {
170:                        logger.log(Level.SEVERE, "WSS1319.aco.transform.error",
171:                                tex);
172:                        throw tex;
173:                    } catch (Exception ex) {
174:                        logger.log(Level.SEVERE, "WSS1319.aco.transform.error",
175:                                ex);
176:                        throw new RuntimeException(ex);
177:                    }
178:                } else {
179:                    //TODO::
180:                    throw new UnsupportedOperationException();
181:                }
182:            }
183:
184:            public javax.xml.crypto.Data transform(javax.xml.crypto.Data data,
185:                    javax.xml.crypto.XMLCryptoContext xMLCryptoContext,
186:                    java.io.OutputStream outputStream)
187:                    throws javax.xml.crypto.dsig.TransformException {
188:                if (data instanceof  AttachmentData) {
189:                    return canonicalize((AttachmentData) data, outputStream);
190:                } else {
191:                    //TODO::
192:                    throw new UnsupportedOperationException();
193:                }
194:            }
195:
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.