Path: blob/master/src/java.xml.crypto/share/classes/javax/xml/crypto/dsig/package-info.java
41161 views
/*1* Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425/**26* Classes for generating and validating XML digital27* signatures. This package includes classes that represent the core elements28* defined in the W3C XML digital signature specification:29* {@link javax.xml.crypto.dsig.XMLSignature XMLSignature},30* {@link javax.xml.crypto.dsig.SignedInfo SignedInfo},31* {@link javax.xml.crypto.dsig.CanonicalizationMethod CanonicalizationMethod},32* {@link javax.xml.crypto.dsig.SignatureMethod SignatureMethod},33* {@link javax.xml.crypto.dsig.Reference Reference},34* {@link javax.xml.crypto.dsig.DigestMethod DigestMethod},35* {@link javax.xml.crypto.dsig.XMLObject XMLObject},36* {@link javax.xml.crypto.dsig.Manifest Manifest},37* {@link javax.xml.crypto.dsig.SignatureProperties SignatureProperties}, and38* {@link javax.xml.crypto.dsig.SignatureProperty SignatureProperty}.39* {@code KeyInfo} types are defined in the40* {@link javax.xml.crypto.dsig.keyinfo} subpackage.41* {@link javax.xml.crypto.dsig.XMLSignatureFactory XMLSignatureFactory}42* is an abstract factory that creates43* {@link javax.xml.crypto.dsig.XMLSignature XMLSignature} objects from scratch44* or from a pre-existing XML representation, such as a DOM node.45* {@link javax.xml.crypto.dsig.TransformService} is a service provider46* interface for creating and plugging in implementations of47* transform and canonicalization algorithms.48*49* <p>Of primary significance in this package is the50* {@link javax.xml.crypto.dsig.XMLSignature XMLSignature} class,51* which allows you to sign and validate an XML digital signature.52*53* <h2><a id="service_providers"></a>Service Providers</h2>54* A service provider is a concrete implementation of the abstract55* {@link javax.xml.crypto.dsig.XMLSignatureFactory XMLSignatureFactory} and56* {@link javax.xml.crypto.dsig.keyinfo.KeyInfoFactory KeyInfoFactory} classes57* and is responsible for creating objects and algorithms that parse, generate58* and validate XML Signatures and KeyInfo structures. A concrete implementation59* of {@code XMLSignatureFactory} MUST provide support for each of the REQUIRED60* algorithms as specified by the W3C recommendation for XML Signatures. It MAY61* support other algorithms as defined by the W3C recommendation or other62* specifications.63*64* <p>The API leverages the JCA provider model (see65* {@link java.security.Provider the Provider class}) for registering and66* loading {@code XMLSignatureFactory} and {@code KeyInfoFactory}67* implementations.68*69* <p>Each concrete {@code XMLSignatureFactory} or {@code KeyInfoFactory}70* implementation supports a specific XML mechanism type that identifies the XML71* processing mechanism that an implementation uses internally to parse and72* generate XML signature and KeyInfo structures.73*74* <p>A service provider implementation SHOULD use underlying JCA engine75* classes, such as {@link java.security.Signature} and76* {@link java.security.MessageDigest} to perform cryptographic operations.77*78* <p>In addition to the {@code XMLSignatureFactory} and {@code KeyInfoFactory}79* classes, the API supports a service provider interface for transform and80* canonicalization algorithms. The {@link81* javax.xml.crypto.dsig.TransformService TransformService} class allows you to82* develop and plug in an implementation of a specific transform or83* canonicalization algorithm for a particular XML mechanism type. The {@code84* TransformService} class uses the standard JCA provider model for registering85* and loading implementations. Each service provider implementation SHOULD use86* the {@code TransformService} class to find a provider that supports transform87* and canonicalization algorithms in XML Signatures that it is generating or88* validating.89*90* <h3><a id="dom_req"></a>DOM Mechanism Requirements</h3>91* The following requirements MUST be abided by when implementing a DOM-based92* {@code XMLSignatureFactory}, {@code KeyInfoFactory} or {@code93* TransformService} in order to minimize interoperability problems:94* <ol>95* <li>The {@code unmarshalXMLSignature} method of {@code XMLSignatureFactory}96* MUST support {@code DOMValidateContext} types. If the type is97* {@code DOMValidateContext}, it SHOULD contain an {@code Element} of type98* Signature. Additionally, the {@code unmarshalXMLSignature} method MAY99* populate the Id/Element mappings of the passed-in {@code DOMValidateContext}.100* </li>101*102* <li>The {@code sign} method of {@code XMLSignature}s produced by103* {@code XMLSignatureFactory} MUST support {@code DOMSignContext} types and the104* {@code validate} method MUST support {@code DOMValidateContext} types. This105* requirement also applies to the {@code validate} method of {@code106* SignatureValue} and the {@code validate} method of {@code Reference}.</li>107*108* <li>The implementation MUST support {@code DOMStructure}s as the mechanism109* for the application to specify extensible content (any elements or mixed110* content).</li>111*112* <li>If the {@code dereference} method of user-specified {@code113* URIDereferencer}s returns {@code NodeSetData} objects, the {@code iterator}114* method MUST return an iteration over objects of type {@code115* org.w3c.dom.Node}.</li>116*117* <li>{@code URIReference} objects passed to the {@code dereference} method of118* user-specified {@code URIDereferencer}s MUST be of type {@code119* DOMURIReference} and {@code XMLCryptoContext} objects MUST implement {@code120* DOMCryptoContext}.</li>121*122* <li>The previous 2 requirements also apply to {@code URIDereferencer}s123* returned by the {@code getURIDereferencer} method of {@code124* XMLSignatureFactory} and {@code KeyInfoFactory}.</li>125*126* <li>The {@code unmarshalKeyInfo} method of {@code KeyInfoFactory} MUST127* support {@code DOMStructure} types. If the type is {@code DOMStructure}, it128* SHOULD contain an {@code Element} of type {@code KeyInfo}.</li>129*130* <li>The {@code transform} method of {@code Transform} MUST support131* {@code DOMCryptoContext} context parameter types.</li>132*133* <li>The {@code newtransform} and {@code newCanonicalizationMethod} methods of134* {@code XMLSignatureFactory} MUST support {@code DOMStructure} parameter135* types.</li>136*137* <li>The {@code init}, and {@code marshalParams} methods of138* {@code TransformService} MUST support {@code DOMStructure} and139* {@code DOMCryptoContext} types.</li>140*141* <li>The {@code unmarshalXMLSignature} method of {@code XMLSignatureFactory}142* MUST support {@code DOMStructure} types. If the type is {@code DOMStructure},143* it SHOULD contain an {@code Element} of type {@code Signature}.</li>144*145* <li>The {@code marshal} method of {@code KeyInfo} MUST support146* {@code DOMStructure} and {@code DOMCryptoContext} parameter types.</li>147* </ol>148*149* <p>Note that a DOM implementation MAY internally use other XML parsing APIs150* other than DOM as long as it doesn't affect interoperability. For example, a151* DOM implementation of {@code XMLSignatureFactory} might use a SAX parser152* internally to canonicalize data.153*154* <h2>Package Specification</h2>155*156* <ul>157* <li>158* <a href="http://www.w3.org/TR/xmldsig-core/">159* XML-Signature Syntax and Processing: W3C Recommendation</a>160* <li>161* <a href="http://www.ietf.org/rfc/rfc3275.txt">162* RFC 3275: XML-Signature Syntax and Processing</a>163* </ul>164*165* @since 1.6166*/167168package javax.xml.crypto.dsig;169170171