Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/xml/crypto/dsig/Reference.java
38918 views
/*1* Copyright (c) 2005, 2011, 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*/24/*25* $Id: Reference.java,v 1.9 2005/05/10 16:03:46 mullan Exp $26*/27package javax.xml.crypto.dsig;2829import javax.xml.crypto.Data;30import javax.xml.crypto.URIReference;31import javax.xml.crypto.XMLStructure;32import java.io.InputStream;33import java.util.List;3435/**36* A representation of the <code>Reference</code> element as defined in the37* <a href="http://www.w3.org/TR/xmldsig-core/">38* W3C Recommendation for XML-Signature Syntax and Processing</a>.39* The XML schema is defined as:40* <code><pre>41* <element name="Reference" type="ds:ReferenceType"/>42* <complexType name="ReferenceType">43* <sequence>44* <element ref="ds:Transforms" minOccurs="0"/>45* <element ref="ds:DigestMethod"/>46* <element ref="ds:DigestValue"/>47* </sequence>48* <attribute name="Id" type="ID" use="optional"/>49* <attribute name="URI" type="anyURI" use="optional"/>50* <attribute name="Type" type="anyURI" use="optional"/>51* </complexType>52*53* <element name="DigestValue" type="ds:DigestValueType"/>54* <simpleType name="DigestValueType">55* <restriction base="base64Binary"/>56* </simpleType>57* </pre></code>58*59* <p>A <code>Reference</code> instance may be created by invoking one of the60* {@link XMLSignatureFactory#newReference newReference} methods of the61* {@link XMLSignatureFactory} class; for example:62*63* <pre>64* XMLSignatureFactory factory = XMLSignatureFactory.getInstance("DOM");65* Reference ref = factory.newReference66* ("http://www.ietf.org/rfc/rfc3275.txt",67* factory.newDigestMethod(DigestMethod.SHA1, null));68* </pre>69*70* @author Sean Mullan71* @author Erwin van der Koogh72* @author JSR 105 Expert Group73* @since 1.674* @see XMLSignatureFactory#newReference(String, DigestMethod)75* @see XMLSignatureFactory#newReference(String, DigestMethod, List, String, String)76*/77public interface Reference extends URIReference, XMLStructure {7879/**80* Returns an {@link java.util.Collections#unmodifiableList unmodifiable81* list} of {@link Transform}s that are contained in this82* <code>Reference</code>.83*84* @return an unmodifiable list of <code>Transform</code>s85* (may be empty but never <code>null</code>)86*/87@SuppressWarnings("rawtypes")88List getTransforms();8990/**91* Returns the digest method of this <code>Reference</code>.92*93* @return the digest method94*/95DigestMethod getDigestMethod();9697/**98* Returns the optional <code>Id</code> attribute of this99* <code>Reference</code>, which permits this reference to be100* referenced from elsewhere.101*102* @return the <code>Id</code> attribute (may be <code>null</code> if not103* specified)104*/105String getId();106107/**108* Returns the digest value of this <code>Reference</code>.109*110* @return the raw digest value, or <code>null</code> if this reference has111* not been digested yet. Each invocation of this method returns a new112* clone to protect against subsequent modification.113*/114byte[] getDigestValue();115116/**117* Returns the calculated digest value of this <code>Reference</code>118* after a validation operation. This method is useful for debugging if119* the reference fails to validate.120*121* @return the calculated digest value, or <code>null</code> if this122* reference has not been validated yet. Each invocation of this method123* returns a new clone to protect against subsequent modification.124*/125byte[] getCalculatedDigestValue();126127/**128* Validates this reference. This method verifies the digest of this129* reference.130*131* <p>This method only validates the reference the first time it is132* invoked. On subsequent invocations, it returns a cached result.133*134* @return <code>true</code> if this reference was validated successfully;135* <code>false</code> otherwise136* @param validateContext the validating context137* @throws NullPointerException if <code>validateContext</code> is138* <code>null</code>139* @throws XMLSignatureException if an unexpected exception occurs while140* validating the reference141*/142boolean validate(XMLValidateContext validateContext)143throws XMLSignatureException;144145/**146* Returns the dereferenced data, if147* <a href="XMLSignContext.html#Supported Properties">reference caching</a>148* is enabled. This is the result of dereferencing the URI of this149* reference during a validation or generation operation.150*151* @return the dereferenced data, or <code>null</code> if reference152* caching is not enabled or this reference has not been generated or153* validated154*/155Data getDereferencedData();156157/**158* Returns the pre-digested input stream, if159* <a href="XMLSignContext.html#Supported Properties">reference caching</a>160* is enabled. This is the input to the digest operation during a161* validation or signing operation.162*163* @return an input stream containing the pre-digested input, or164* <code>null</code> if reference caching is not enabled or this165* reference has not been generated or validated166*/167InputStream getDigestInputStream();168}169170171