01: /*
02: * SCVAdapter.java
03: *
04: * Created on August 9, 2006, 2:47 PM
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.security.core.xenc;
28:
29: import com.sun.xml.ws.security.opt.impl.util.CVDataContentHandlerFactory;
30: import com.sun.xml.ws.security.opt.impl.enc.CryptoProcessor;
31: import javax.activation.CommandMap;
32: import javax.activation.MailcapCommandMap;
33: import javax.xml.bind.annotation.adapters.XmlAdapter;
34: import javax.activation.DataHandler;
35:
36: /**
37: *
38: * @author K.Venugopal@sun.com
39: */
40: public class CVAdapter extends XmlAdapter<DataHandler, byte[]> {
41:
42: static {
43: // DataHandler.setDataContentHandlerFactory(new CVDataContentHandlerFactory());
44:
45: CommandMap map = CommandMap.getDefaultCommandMap();
46: if (map instanceof MailcapCommandMap) {
47: MailcapCommandMap mailMap = (MailcapCommandMap) map;
48: mailMap
49: .addMailcap("application/ciphervalue"
50: + ";;x-java-content-handler="
51: + "com.sun.xml.ws.security.opt.impl.util.CVDataHandler");
52: }
53: }
54:
55: private CryptoProcessor cp;
56:
57: public CVAdapter() {
58: }
59:
60: public CVAdapter(CryptoProcessor cp) {
61: this .cp = cp;
62: }
63:
64: public DataHandler marshal(byte[] value) {
65: return new DataHandler(cp, "application/ciphervalue");
66: }
67:
68: public byte[] unmarshal(DataHandler dh) {
69: throw new UnsupportedOperationException();
70: }
71:
72: }
|