1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 /*
20  * ===========================================================================
21  *
22  * (C) Copyright IBM Corp. 2003 All Rights Reserved.
23  *
24  * ===========================================================================
25  */
26 /*
27  * Portions copyright 2005 Sun Microsystems, Inc. All rights reserved.
28  */
29 /*
30  * $Id: XMLDSigRI.java 1458868 2013-03-20 15:06:08Z coheigea $
31  */
32 package org.apache.jcp.xml.dsig.internal.dom;
33 
34 import java.util.*;
35 import java.security.*;
36 
37 import javax.xml.crypto.dsig.*;
38 
39 /**
40  * The XMLDSig RI Provider.
41  *
42  * @author Joyce Leung
43  */
44 
45 /**
46  * Defines the XMLDSigRI provider.
47  */
48 
49 public final class XMLDSigRI extends Provider {
50 
51     static final long serialVersionUID = -5049765099299494554L;
52 
53     private static final String INFO = "Apache Santuario XMLDSig " +
54         "(DOM XMLSignatureFactory; DOM KeyInfoFactory; " +
55         "C14N 1.0, C14N 1.1, Exclusive C14N, Base64, Enveloped, XPath, " +
56         "XPath2, XSLT TransformServices)";
57 
XMLDSigRI()58     public XMLDSigRI() {
59         /* We are the ApacheXMLDSig provider */
60         super("ApacheXMLDSig", 1.55, INFO);
61 
62         final Map<Object, Object> map = new HashMap<Object, Object>();
63         map.put("XMLSignatureFactory.DOM",
64                 "org.apache.jcp.xml.dsig.internal.dom.DOMXMLSignatureFactory");
65         map.put("KeyInfoFactory.DOM",
66                 "org.apache.jcp.xml.dsig.internal.dom.DOMKeyInfoFactory");
67 
68 
69         // Inclusive C14N
70         map.put("TransformService." + CanonicalizationMethod.INCLUSIVE,
71                 "org.apache.jcp.xml.dsig.internal.dom.DOMCanonicalXMLC14NMethod");
72         map.put("Alg.Alias.TransformService.INCLUSIVE",
73                 CanonicalizationMethod.INCLUSIVE);
74         map.put("TransformService." + CanonicalizationMethod.INCLUSIVE +
75                 " MechanismType", "DOM");
76 
77         // InclusiveWithComments C14N
78         map.put("TransformService." +
79                 CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS,
80                 "org.apache.jcp.xml.dsig.internal.dom.DOMCanonicalXMLC14NMethod");
81         map.put("Alg.Alias.TransformService.INCLUSIVE_WITH_COMMENTS",
82                 CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS);
83         map.put("TransformService." +
84                 CanonicalizationMethod.INCLUSIVE_WITH_COMMENTS +
85                 " MechanismType", "DOM");
86 
87         // Inclusive C14N 1.1
88         map.put("TransformService.http://www.w3.org/2006/12/xml-c14n11",
89                 "org.apache.jcp.xml.dsig.internal.dom.DOMCanonicalXMLC14N11Method");
90         map.put("TransformService.http://www.w3.org/2006/12/xml-c14n11" +
91                 " MechanismType", "DOM");
92 
93         // InclusiveWithComments C14N 1.1
94         map.put("TransformService.http://www.w3.org/2006/12/xml-c14n11#WithComments",
95                 "org.apache.jcp.xml.dsig.internal.dom.DOMCanonicalXMLC14N11Method");
96         map.put("TransformService.http://www.w3.org/2006/12/xml-c14n11#WithComments" +
97                 " MechanismType", "DOM");
98 
99         // Exclusive C14N
100         map.put("TransformService." + CanonicalizationMethod.EXCLUSIVE,
101                 "org.apache.jcp.xml.dsig.internal.dom.DOMExcC14NMethod");
102         map.put("Alg.Alias.TransformService.EXCLUSIVE",
103                 CanonicalizationMethod.EXCLUSIVE);
104         map.put("TransformService." + CanonicalizationMethod.EXCLUSIVE +
105                 " MechanismType", "DOM");
106 
107         // ExclusiveWithComments C14N
108         map.put("TransformService." +
109                 CanonicalizationMethod.EXCLUSIVE_WITH_COMMENTS,
110                 "org.apache.jcp.xml.dsig.internal.dom.DOMExcC14NMethod");
111         map.put("Alg.Alias.TransformService.EXCLUSIVE_WITH_COMMENTS",
112                 CanonicalizationMethod.EXCLUSIVE_WITH_COMMENTS);
113         map.put("TransformService." +
114                 CanonicalizationMethod.EXCLUSIVE_WITH_COMMENTS +
115                 " MechanismType", "DOM");
116 
117         // Base64 Transform
118         map.put("TransformService." + Transform.BASE64,
119                 "org.apache.jcp.xml.dsig.internal.dom.DOMBase64Transform");
120         map.put("Alg.Alias.TransformService.BASE64", Transform.BASE64);
121         map.put("TransformService." + Transform.BASE64 +
122                 " MechanismType", "DOM");
123 
124         // Enveloped Transform
125         map.put("TransformService." + Transform.ENVELOPED,
126                 "org.apache.jcp.xml.dsig.internal.dom.DOMEnvelopedTransform");
127         map.put("Alg.Alias.TransformService.ENVELOPED", Transform.ENVELOPED);
128         map.put("TransformService." + Transform.ENVELOPED +
129                 " MechanismType", "DOM");
130 
131         // XPath2 Transform
132         map.put("TransformService." + Transform.XPATH2,
133                 "org.apache.jcp.xml.dsig.internal.dom.DOMXPathFilter2Transform");
134         map.put("Alg.Alias.TransformService.XPATH2", Transform.XPATH2);
135         map.put("TransformService." + Transform.XPATH2 +
136                 " MechanismType", "DOM");
137 
138         // XPath Transform
139         map.put("TransformService." + Transform.XPATH,
140                 "org.apache.jcp.xml.dsig.internal.dom.DOMXPathTransform");
141         map.put("Alg.Alias.TransformService.XPATH", Transform.XPATH);
142         map.put("TransformService." + Transform.XPATH +
143                 " MechanismType", "DOM");
144 
145         // XSLT Transform
146         map.put("TransformService." + Transform.XSLT,
147                 "org.apache.jcp.xml.dsig.internal.dom.DOMXSLTTransform");
148         map.put("Alg.Alias.TransformService.XSLT", Transform.XSLT);
149         map.put("TransformService." + Transform.XSLT + " MechanismType", "DOM");
150 
151         AccessController.doPrivileged(new PrivilegedAction<Void>() {
152             public Void run() {
153                 putAll(map);
154                 return null;
155             }
156         });
157     }
158 }
159