📄 xmlsignaturefactory.java
字号:
throw new NoSuchProviderException(); } Instance instance; try { instance = GetInstance.getInstance ("XMLSignatureFactory", null, mechanismType, provider); } catch (NoSuchAlgorithmException nsae) { throw new NoSuchMechanismException(nsae); } XMLSignatureFactory factory = (XMLSignatureFactory) instance.impl; factory.mechanismType = mechanismType; factory.provider = instance.provider; return factory; } /** * Returns an <code>XMLSignatureFactory</code> that supports the * default XML processing mechanism and representation type ("DOM"). * * <p>This method uses the standard JCA provider lookup mechanism to * locate and instantiate an <code>XMLSignatureFactory</code> * implementation of the default mechanism type. It traverses the list of * registered security <code>Provider</code>s, starting with the most * preferred <code>Provider</code>. A new <code>XMLSignatureFactory</code> * object from the first <code>Provider</code> that supports the DOM * mechanism is returned. * * <p>Note that the list of registered providers may be retrieved via * the {@link Security#getProviders() Security.getProviders()} method. * * @return a new <code>XMLSignatureFactory</code> * @throws NoSuchMechanismException if no <code>Provider</code> supports an * <code>XMLSignatureFactory</code> implementation for the DOM * mechanism * @see Provider */ public static XMLSignatureFactory getInstance() { return getInstance("DOM"); } /** * Returns the type of the XML processing mechanism and representation * supported by this <code>XMLSignatureFactory</code> (ex: "DOM"). * * @return the XML processing mechanism type supported by this * <code>XMLSignatureFactory</code> */ public final String getMechanismType() { return mechanismType; } /** * Returns the provider of this <code>XMLSignatureFactory</code>. * * @return the provider of this <code>XMLSignatureFactory</code> */ public final Provider getProvider() { return provider; } /** * Creates an <code>XMLSignature</code> and initializes it with the contents * of the specified <code>SignedInfo</code> and <code>KeyInfo</code> * objects. * * @param si the signed info * @param ki the key info (may be <code>null</code>) * @return an <code>XMLSignature</code> * @throws NullPointerException if <code>si</code> is <code>null</code> */ public abstract XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki); /** * Creates an <code>XMLSignature</code> and initializes it with the * specified parameters. * * @param si the signed info * @param ki the key info (may be <code>null</code>) * @param objects a list of {@link XMLObject}s (may be empty or * <code>null</code>) * @param id the Id (may be <code>null</code>) * @param signatureValueId the SignatureValue Id (may be <code>null</code>) * @return an <code>XMLSignature</code> * @throws NullPointerException if <code>si</code> is <code>null</code> * @throws ClassCastException if any of the <code>objects</code> are not of * type <code>XMLObject</code> */ public abstract XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki, List objects, String id, String signatureValueId); /** * Creates a <code>Reference</code> with the specified URI and digest * method. * * @param uri the reference URI (may be <code>null</code>) * @param dm the digest method * @return a <code>Reference</code> * @throws IllegalArgumentException if <code>uri</code> is not RFC 2396 * compliant * @throws NullPointerException if <code>dm</code> is <code>null</code> */ public abstract Reference newReference(String uri, DigestMethod dm); /** * Creates a <code>Reference</code> with the specified parameters. * * @param uri the reference URI (may be <code>null</code>) * @param dm the digest method * @param transforms a list of {@link Transform}s. The list is defensively * copied to protect against subsequent modification. May be * <code>null</code> or empty. * @param type the reference type, as a URI (may be <code>null</code>) * @param id the reference ID (may be <code>null</code>) * @return a <code>Reference</code> * @throws ClassCastException if any of the <code>transforms</code> are * not of type <code>Transform</code> * @throws IllegalArgumentException if <code>uri</code> is not RFC 2396 * compliant * @throws NullPointerException if <code>dm</code> is <code>null</code> */ public abstract Reference newReference(String uri, DigestMethod dm, List transforms, String type, String id); /** * Creates a <code>Reference</code> with the specified parameters and * pre-calculated digest value. * * <p>This method is useful when the digest value of a * <code>Reference</code> has been previously computed. See for example, * the * <a href="http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=dss"> * OASIS-DSS (Digital Signature Services)</a> specification. * * @param uri the reference URI (may be <code>null</code>) * @param dm the digest method * @param transforms a list of {@link Transform}s. The list is defensively * copied to protect against subsequent modification. May be * <code>null</code> or empty. * @param type the reference type, as a URI (may be <code>null</code>) * @param id the reference ID (may be <code>null</code>) * @param digestValue the digest value. The array is cloned to protect * against subsequent modification. * @return a <code>Reference</code> * @throws ClassCastException if any of the <code>transforms</code> are * not of type <code>Transform</code> * @throws IllegalArgumentException if <code>uri</code> is not RFC 2396 * compliant * @throws NullPointerException if <code>dm</code> or * <code>digestValue</code> is <code>null</code> */ public abstract Reference newReference(String uri, DigestMethod dm, List transforms, String type, String id, byte[] digestValue); /** * Creates a <code>Reference</code> with the specified parameters. * * <p>This method is useful when a list of transforms have already been * applied to the <code>Reference</code>. See for example, * the * <a href="http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=dss"> * OASIS-DSS (Digital Signature Services)</a> specification. * * <p>When an <code>XMLSignature</code> containing this reference is * generated, the specified <code>transforms</code> (if non-null) are * applied to the specified <code>result</code>. The * <code>Transforms</code> element of the resulting <code>Reference</code> * element is set to the concatenation of the * <code>appliedTransforms</code> and <code>transforms</code>. * * @param uri the reference URI (may be <code>null</code>) * @param dm the digest method * @param appliedTransforms a list of {@link Transform}s that have * already been applied. The list is defensively * copied to protect against subsequent modification. The list must * contain at least one entry. * @param result the result of processing the sequence of * <code>appliedTransforms</code> * @param transforms a list of {@link Transform}s that are to be applied * when generating the signature. The list is defensively copied to * protect against subsequent modification. May be <code>null</code> * or empty. * @param type the reference type, as a URI (may be <code>null</code>) * @param id the reference ID (may be <code>null</code>) * @return a <code>Reference</code> * @throws ClassCastException if any of the transforms (in either list) * are not of type <code>Transform</code> * @throws IllegalArgumentException if <code>uri</code> is not RFC 2396 * compliant or <code>appliedTransforms</code> is empty * @throws NullPointerException if <code>dm</code>, * <code>appliedTransforms</code> or <code>result</code> is * <code>null</code> */ public abstract Reference newReference(String uri, DigestMethod dm, List appliedTransforms, Data result, List transforms, String type, String id); /** * Creates a <code>SignedInfo</code> with the specified canonicalization * and signature methods, and list of one or more references. * * @param cm the canonicalization method * @param sm the signature method * @param references a list of one or more {@link Reference}s. The list is * defensively copied to protect against subsequent modification. * @return a <code>SignedInfo</code> * @throws ClassCastException if any of the references are not of * type <code>Reference</code> * @throws IllegalArgumentException if <code>references</code> is empty * @throws NullPointerException if any of the parameters * are <code>null</code> */ public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm, SignatureMethod sm, List references); /** * Creates a <code>SignedInfo</code> with the specified parameters. * * @param cm the canonicalization method * @param sm the signature method * @param references a list of one or more {@link Reference}s. The list is * defensively copied to protect against subsequent modification. * @param id the id (may be <code>null</code>) * @return a <code>SignedInfo</code> * @throws ClassCastException if any of the references are not of * type <code>Reference</code> * @throws IllegalArgumentException if <code>references</code> is empty * @throws NullPointerException if <code>cm</code>, <code>sm</code>, or * <code>references</code> are <code>null</code> */ public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm, SignatureMethod sm, List references, String id); // Object factory methods /** * Creates an <code>XMLObject</code> from the specified parameters. * * @param content a list of {@link XMLStructure}s. The list * is defensively copied to protect against subsequent modification. * May be <code>null</code> or empty. * @param id the Id (may be <code>null</code>) * @param mimeType the mime type (may be <code>null</code>) * @param encoding the encoding (may be <code>null</code>) * @return an <code>XMLObject</code> * @throws ClassCastException if <code>content</code> contains any * entries that are not of type {@link XMLStructure} */ public abstract XMLObject newXMLObject(List content, String id, String mimeType, String encoding); /** * Creates a <code>Manifest</code> containing the specified * list of {@link Reference}s. * * @param references a list of one or more <code>Reference</code>s. The list * is defensively copied to protect against subsequent modification. * @return a <code>Manifest</code> * @throws NullPointerException if <code>references</code> is
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -