01: /*
02: * $Id: AttachmentSignatureInput.java,v 1.5 2007/01/08 16:06:09 shyam_rao Exp $
03: */
04:
05: /*
06: * The contents of this file are subject to the terms
07: * of the Common Development and Distribution License
08: * (the License). You may not use this file except in
09: * compliance with the License.
10: *
11: * You can obtain a copy of the license at
12: * https://glassfish.dev.java.net/public/CDDLv1.0.html.
13: * See the License for the specific language governing
14: * permissions and limitations under the License.
15: *
16: * When distributing Covered Code, include this CDDL
17: * Header Notice in each file and include the License file
18: * at https://glassfish.dev.java.net/public/CDDLv1.0.html.
19: * If applicable, add the following below the CDDL Header,
20: * with the fields enclosed by brackets [] replaced by
21: * you own identifying information:
22: * "Portions Copyrighted [year] [name of copyright owner]"
23: *
24: * Copyright 2006 Sun Microsystems Inc. All Rights Reserved
25: */
26:
27: package com.sun.xml.wss.impl.resolver;
28:
29: import java.util.Vector;
30: import java.util.Iterator;
31: import java.io.IOException;
32: import java.io.OutputStream;
33: import java.io.ByteArrayOutputStream;
34:
35: import javax.xml.soap.SOAPException;
36: import javax.xml.soap.AttachmentPart;
37:
38: import com.sun.org.apache.xml.internal.security.signature.XMLSignatureInput;
39:
40: public class AttachmentSignatureInput extends XMLSignatureInput {
41: private String _cType = null;
42: private Vector _mhs = new Vector();
43:
44: public AttachmentSignatureInput(byte[] input) {
45: super (input);
46: }
47:
48: public void setMimeHeaders(Vector mimeHeaders) {
49: _mhs = mimeHeaders;
50: }
51:
52: public Vector getMimeHeaders() {
53: return _mhs;
54: }
55:
56: public void setContentType(String _cType) {
57: this ._cType = _cType;
58: }
59:
60: public String getContentType() {
61: return _cType;
62: }
63:
64: public static final Object[] _getSignatureInput(AttachmentPart _part)
65: throws SOAPException, IOException {
66: Iterator mhItr = _part.getAllMimeHeaders();
67:
68: Vector mhs = new Vector();
69: while (mhItr.hasNext())
70: mhs.add(mhItr.next());
71:
72: // extract Content
73: //Object content = _part.getContent();
74: OutputStream baos = new ByteArrayOutputStream();
75: _part.getDataHandler().writeTo(baos);
76:
77: return new Object[] { mhs,
78: ((ByteArrayOutputStream) baos).toByteArray() };
79: }
80: }
|