Path: blob/master/src/java.xml.crypto/share/classes/javax/xml/crypto/XMLCryptoContext.java
41159 views
/*1* Copyright (c) 2005, 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: XMLCryptoContext.java,v 1.6 2005/05/10 15:47:42 mullan Exp $26*/27package javax.xml.crypto;2829/**30* Contains common context information for XML cryptographic operations.31*32* <p>This interface contains methods for setting and retrieving properties33* that affect the processing of XML signatures or XML encrypted structures.34*35* <p>Note that <code>XMLCryptoContext</code> instances can contain information36* and state specific to the XML cryptographic structure it is used with.37* The results are unpredictable if an <code>XMLCryptoContext</code> is38* used with multiple structures (for example, you should not use the same39* {@link javax.xml.crypto.dsig.XMLValidateContext} instance to validate two40* different {@link javax.xml.crypto.dsig.XMLSignature} objects).41*42* @author Sean Mullan43* @author JSR 105 Expert Group44* @since 1.645*/46public interface XMLCryptoContext {4748/**49* Returns the base URI.50*51* @return the base URI, or <code>null</code> if not specified52* @see #setBaseURI(String)53*/54String getBaseURI();5556/**57* Sets the base URI.58*59* @param baseURI the base URI, or <code>null</code> to remove current60* value61* @throws IllegalArgumentException if <code>baseURI</code> is not RFC62* 2396 compliant63* @see #getBaseURI64*/65void setBaseURI(String baseURI);6667/**68* Returns the key selector for finding a key.69*70* @return the key selector, or <code>null</code> if not specified71* @see #setKeySelector(KeySelector)72*/73KeySelector getKeySelector();7475/**76* Sets the key selector for finding a key.77*78* @param ks the key selector, or <code>null</code> to remove the current79* setting80* @see #getKeySelector81*/82void setKeySelector(KeySelector ks);8384/**85* Returns a <code>URIDereferencer</code> that is used to dereference86* {@link URIReference}s.87*88* @return the <code>URIDereferencer</code>, or <code>null</code> if not89* specified90* @see #setURIDereferencer(URIDereferencer)91*/92URIDereferencer getURIDereferencer();9394/**95* Sets a <code>URIDereferencer</code> that is used to dereference96* {@link URIReference}s. The specified <code>URIDereferencer</code>97* is used in place of an implementation's default98* <code>URIDereferencer</code>.99*100* @param dereferencer the <code>URIDereferencer</code>, or101* <code>null</code> to remove any current setting102* @see #getURIDereferencer103*/104void setURIDereferencer(URIDereferencer dereferencer);105106/**107* Returns the namespace prefix that the specified namespace URI is108* associated with. Returns the specified default prefix if the specified109* namespace URI has not been bound to a prefix. To bind a namespace URI110* to a prefix, call the {@link #putNamespacePrefix putNamespacePrefix}111* method.112*113* @param namespaceURI a namespace URI114* @param defaultPrefix the prefix to be returned in the event that the115* the specified namespace URI has not been bound to a prefix.116* @return the prefix that is associated with the specified namespace URI,117* or <code>defaultPrefix</code> if the URI is not registered. If118* the namespace URI is registered but has no prefix, an empty string119* (<code>""</code>) is returned.120* @throws NullPointerException if <code>namespaceURI</code> is121* <code>null</code>122* @see #putNamespacePrefix(String, String)123*/124String getNamespacePrefix(String namespaceURI, String defaultPrefix);125126/**127* Maps the specified namespace URI to the specified prefix. If there is128* already a prefix associated with the specified namespace URI, the old129* prefix is replaced by the specified prefix.130*131* @param namespaceURI a namespace URI132* @param prefix a namespace prefix (or <code>null</code> to remove any133* existing mapping). Specifying the empty string (<code>""</code>)134* binds no prefix to the namespace URI.135* @return the previous prefix associated with the specified namespace136* URI, or <code>null</code> if there was none137* @throws NullPointerException if <code>namespaceURI</code> is138* <code>null</code>139* @see #getNamespacePrefix(String, String)140*/141String putNamespacePrefix(String namespaceURI, String prefix);142143/**144* Returns the default namespace prefix. The default namespace prefix145* is the prefix for all namespace URIs not explicitly set by the146* {@link #putNamespacePrefix putNamespacePrefix} method.147*148* @return the default namespace prefix, or <code>null</code> if none has149* been set.150* @see #setDefaultNamespacePrefix(String)151*/152String getDefaultNamespacePrefix();153154/**155* Sets the default namespace prefix. This sets the namespace prefix for156* all namespace URIs not explicitly set by the {@link #putNamespacePrefix157* putNamespacePrefix} method.158*159* @param defaultPrefix the default namespace prefix, or <code>null</code>160* to remove the current setting. Specify the empty string161* (<code>""</code>) to bind no prefix.162* @see #getDefaultNamespacePrefix163*/164void setDefaultNamespacePrefix(String defaultPrefix);165166/**167* Sets the specified property.168*169* @param name the name of the property170* @param value the value of the property to be set171* @return the previous value of the specified property, or172* <code>null</code> if it did not have a value173* @throws NullPointerException if <code>name</code> is <code>null</code>174* @see #getProperty(String)175*/176Object setProperty(String name, Object value);177178/**179* Returns the value of the specified property.180*181* @param name the name of the property182* @return the current value of the specified property, or183* <code>null</code> if it does not have a value184* @throws NullPointerException if <code>name</code> is <code>null</code>185* @see #setProperty(String, Object)186*/187Object getProperty(String name);188189/**190* Returns the value to which this context maps the specified key.191*192* <p>More formally, if this context contains a mapping from a key193* <code>k</code> to a value <code>v</code> such that194* <code>(key==null ? k==null : key.equals(k))</code>, then this method195* returns <code>v</code>; otherwise it returns <code>null</code>. (There196* can be at most one such mapping.)197*198* <p>This method is useful for retrieving arbitrary information that is199* specific to the cryptographic operation that this context is used for.200*201* @param key the key whose associated value is to be returned202* @return the value to which this context maps the specified key, or203* <code>null</code> if there is no mapping for the key204* @see #put(Object, Object)205*/206Object get(Object key);207208/**209* Associates the specified value with the specified key in this context.210* If the context previously contained a mapping for this key, the old211* value is replaced by the specified value.212*213* <p>This method is useful for storing arbitrary information that is214* specific to the cryptographic operation that this context is used for.215*216* @param key key with which the specified value is to be associated with217* @param value value to be associated with the specified key218* @return the previous value associated with the key, or <code>null</code>219* if there was no mapping for the key220* @throws IllegalArgumentException if some aspect of this key or value221* prevents it from being stored in this context222* @see #get(Object)223*/224Object put(Object key, Object value);225}226227228