2
* Copyright 2005 The Apache Software Foundation.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
18
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
21
* $Id: XMLSignatureFactory.java 375655 2006-02-07 18:35:54 +0000 (Tue, 07 Feb 2006) mullan $
23
package javax.xml.crypto.dsig;
25
import javax.xml.crypto.Data;
26
import javax.xml.crypto.MarshalException;
27
import javax.xml.crypto.NoSuchMechanismException;
28
import javax.xml.crypto.URIDereferencer;
29
import javax.xml.crypto.XMLStructure;
30
import javax.xml.crypto.dom.DOMStructure;
31
import javax.xml.crypto.dsig.keyinfo.KeyInfo;
32
import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory;
33
import javax.xml.crypto.dsig.spec.*;
34
import javax.xml.crypto.dsig.dom.DOMValidateContext;
35
import javax.xml.crypto.dsig.dom.DOMSignContext;
37
import java.security.InvalidAlgorithmParameterException;
38
import java.security.NoSuchAlgorithmException;
39
import java.security.NoSuchProviderException;
40
import java.security.Provider;
41
import java.security.Security;
42
import java.util.List;
45
* A factory for creating {@link XMLSignature} objects from scratch or
46
* for unmarshalling an <code>XMLSignature</code> object from a corresponding
49
* <h2>XMLSignatureFactory Type</h2>
51
* <p>Each instance of <code>XMLSignatureFactory</code> supports a specific
52
* XML mechanism type. To create an <code>XMLSignatureFactory</code>, call one
53
* of the static {@link #getInstance getInstance} methods, passing in the XML
54
* mechanism type desired, for example:
57
* XMLSignatureFactory factory = XMLSignatureFactory.getInstance("DOM");
58
* </code></blockquote>
60
* <p>The objects that this factory produces will be based
61
* on DOM and abide by the DOM interoperability requirements as defined in the
62
* <a href="../../../../overview-summary.html#DOM Mechanism Requirements">DOM
63
* Mechanism Requirements</a> section of the API overview. See the
64
* <a href="../../../../overview-summary.html#Service Provider">Service
65
* Providers</a> section of the API overview for a list of standard mechanism
68
* <p><code>XMLSignatureFactory</code> implementations are registered and loaded
69
* using the {@link java.security.Provider} mechanism.
70
* For example, a service provider that supports the
71
* DOM mechanism would be specified in the <code>Provider</code> subclass as:
73
* put("XMLSignatureFactory.DOM", "org.example.DOMXMLSignatureFactory");
76
* <p>An implementation MUST minimally support the default mechanism type: DOM.
78
* <p>Note that a caller must use the same <code>XMLSignatureFactory</code>
79
* instance to create the <code>XMLStructure</code>s of a particular
80
* <code>XMLSignature</code> that is to be generated. The behavior is
81
* undefined if <code>XMLStructure</code>s from different providers or
82
* different mechanism types are used together.
84
* <p>Also, the <code>XMLStructure</code>s that are created by this factory
85
* may contain state specific to the <code>XMLSignature</code> and are not
86
* intended to be reusable.
88
* <h2>Creating XMLSignatures from scratch</h2>
90
* <p>Once the <code>XMLSignatureFactory</code> has been created, objects
91
* can be instantiated by calling the appropriate method. For example, a
92
* {@link Reference} instance may be created by invoking one of the
93
* {@link #newReference newReference} methods.
95
* <h2>Unmarshalling XMLSignatures from XML</h2>
97
* <p>Alternatively, an <code>XMLSignature</code> may be created from an
98
* existing XML representation by invoking the {@link #unmarshalXMLSignature
99
* unmarshalXMLSignature} method and passing it a mechanism-specific
100
* {@link XMLValidateContext} instance containing the XML content:
103
* DOMValidateContext context = new DOMValidateContext(key, signatureElement);
104
* XMLSignature signature = factory.unmarshalXMLSignature(context);
107
* Each <code>XMLSignatureFactory</code> must support the required
108
* <code>XMLValidateContext</code> types for that factory type, but may support
109
* others. A DOM <code>XMLSignatureFactory</code> must support {@link
110
* DOMValidateContext} objects.
112
* <h2>Signing and marshalling XMLSignatures to XML</h2>
114
* Each <code>XMLSignature</code> created by the factory can also be
115
* marshalled to an XML representation and signed, by invoking the
116
* {@link XMLSignature#sign sign} method of the
117
* {@link XMLSignature} object and passing it a mechanism-specific
118
* {@link XMLSignContext} object containing the signing key and
119
* marshalling parameters (see {@link DOMSignContext}).
123
* DOMSignContext context = new DOMSignContext(privateKey, document);
124
* signature.sign(context);
127
* <b>Concurrent Access</b>
128
* <p>The static methods of this class are guaranteed to be thread-safe.
129
* Multiple threads may concurrently invoke the static methods defined in this
130
* class with no ill effects.
132
* <p>However, this is not true for the non-static methods defined by this
133
* class. Unless otherwise documented by a specific provider, threads that
134
* need to access a single <code>XMLSignatureFactory</code> instance
135
* concurrently should synchronize amongst themselves and provide the
136
* necessary locking. Multiple threads each manipulating a different
137
* <code>XMLSignatureFactory</code> instance need not synchronize.
139
* @author Sean Mullan
140
* @author JSR 105 Expert Group
142
public abstract class XMLSignatureFactory {
144
private String mechanismType;
145
private Provider provider;
148
* Default constructor, for invocation by subclasses.
150
protected XMLSignatureFactory() {}
153
* Returns an <code>XMLSignatureFactory</code> that supports the
154
* specified XML processing mechanism and representation type (ex: "DOM").
156
* <p>This method uses the standard JCA provider lookup mechanism to
157
* locate and instantiate an <code>XMLSignatureFactory</code>
158
* implementation of the desired mechanism type. It traverses the list of
159
* registered security <code>Provider</code>s, starting with the most
160
* preferred <code>Provider</code>. A new <code>XMLSignatureFactory</code>
161
* object from the first <code>Provider</code> that supports the specified
162
* mechanism is returned.
164
* <p>Note that the list of registered providers may be retrieved via
165
* the {@link Security#getProviders() Security.getProviders()} method.
167
* @param mechanismType the type of the XML processing mechanism and
168
* representation. See the <a
169
* href="../../../../overview-summary.html#Service Provider">Service
170
* Providers</a> section of the API overview for a list of standard
172
* @return a new <code>XMLSignatureFactory</code>
173
* @throws NullPointerException if <code>mechanismType</code> is
175
* @throws NoSuchMechanismException if no <code>Provider</code> supports an
176
* <code>XMLSignatureFactory</code> implementation for the specified
180
public static XMLSignatureFactory getInstance(String mechanismType) {
181
if (mechanismType == null) {
182
throw new NullPointerException("mechanismType cannot be null");
185
return findInstance(mechanismType, null);
188
private static XMLSignatureFactory findInstance(String mechanismType,
191
Object[] objs = null;
193
objs = (Object[]) XMLDSigSecurity.getImpl
194
(mechanismType, "XMLSignatureFactory", provider);
195
} catch (NoSuchAlgorithmException nsae) {
196
throw new NoSuchMechanismException
197
("Cannot find " + mechanismType + " mechanism type", nsae);
200
XMLSignatureFactory factory = (XMLSignatureFactory) objs[0];
201
factory.mechanismType = mechanismType;
202
factory.provider = (Provider) objs[1];
207
* Returns an <code>XMLSignatureFactory</code> that supports the
208
* requested XML processing mechanism and representation type (ex: "DOM"),
209
* as supplied by the specified provider. Note that the specified
210
* <code>Provider</code> object does not have to be registered in the
213
* @param mechanismType the type of the XML processing mechanism and
214
* representation. See the <a
215
* href="../../../../overview-summary.html#Service Provider">Service
216
* Providers</a> section of the API overview for a list of standard
218
* @param provider the <code>Provider</code> object
219
* @return a new <code>XMLSignatureFactory</code>
220
* @throws NullPointerException if <code>provider</code> or
221
* <code>mechanismType</code> is <code>null</code>
222
* @throws NoSuchMechanismException if an <code>XMLSignatureFactory</code>
223
* implementation for the specified mechanism is not available
224
* from the specified <code>Provider</code> object
227
public static XMLSignatureFactory getInstance(String mechanismType,
229
if (mechanismType == null) {
230
throw new NullPointerException("mechanismType cannot be null");
231
} else if (provider == null) {
232
throw new NullPointerException("provider cannot be null");
235
return findInstance(mechanismType, provider);
239
* Returns an <code>XMLSignatureFactory</code> that supports the
240
* requested XML processing mechanism and representation type (ex: "DOM"),
241
* as supplied by the specified provider. The specified provider must be
242
* registered in the security provider list.
244
* <p>Note that the list of registered providers may be retrieved via
245
* the {@link Security#getProviders() Security.getProviders()} method.
247
* @param mechanismType the type of the XML processing mechanism and
248
* representation. See the <a
249
* href="../../../../overview-summary.html#Service Provider">Service
250
* Providers</a> section of the API overview for a list of standard
252
* @param provider the string name of the provider
253
* @return a new <code>XMLSignatureFactory</code>
254
* @throws NoSuchProviderException if the specified provider is not
255
* registered in the security provider list
256
* @throws NullPointerException if <code>provider</code> or
257
* <code>mechanismType</code> is <code>null</code>
258
* @throws NoSuchMechanismException if an <code>XMLSignatureFactory</code>
259
* implementation for the specified mechanism is not
260
* available from the specified provider
263
public static XMLSignatureFactory getInstance(String mechanismType,
264
String provider) throws NoSuchProviderException {
265
if (mechanismType == null) {
266
throw new NullPointerException("mechanismType cannot be null");
267
} else if (provider == null) {
268
throw new NullPointerException("provider cannot be null");
271
Provider prov = Security.getProvider(provider);
273
throw new NoSuchProviderException("cannot find provider named "
277
return findInstance(mechanismType, prov);
281
* Returns an <code>XMLSignatureFactory</code> that supports the
282
* default XML processing mechanism and representation type ("DOM").
284
* <p>This method uses the standard JCA provider lookup mechanism to
285
* locate and instantiate an <code>XMLSignatureFactory</code>
286
* implementation of the default mechanism type. It traverses the list of
287
* registered security <code>Provider</code>s, starting with the most
288
* preferred <code>Provider</code>. A new <code>XMLSignatureFactory</code>
289
* object from the first <code>Provider</code> that supports the DOM
290
* mechanism is returned.
292
* <p>Note that the list of registered providers may be retrieved via
293
* the {@link Security#getProviders() Security.getProviders()} method.
295
* @return a new <code>XMLSignatureFactory</code>
296
* @throws NoSuchMechanismException if no <code>Provider</code> supports an
297
* <code>XMLSignatureFactory</code> implementation for the DOM
301
public static XMLSignatureFactory getInstance() {
302
return getInstance("DOM");
306
* Returns the type of the XML processing mechanism and representation
307
* supported by this <code>XMLSignatureFactory</code> (ex: "DOM").
309
* @return the XML processing mechanism type supported by this
310
* <code>XMLSignatureFactory</code>
312
public final String getMechanismType() {
313
return mechanismType;
317
* Returns the provider of this <code>XMLSignatureFactory</code>.
319
* @return the provider of this <code>XMLSignatureFactory</code>
321
public final Provider getProvider() {
326
* Creates an <code>XMLSignature</code> and initializes it with the contents
327
* of the specified <code>SignedInfo</code> and <code>KeyInfo</code>
330
* @param si the signed info
331
* @param ki the key info (may be <code>null</code>)
332
* @return an <code>XMLSignature</code>
333
* @throws NullPointerException if <code>si</code> is <code>null</code>
335
public abstract XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki);
338
* Creates an <code>XMLSignature</code> and initializes it with the
339
* specified parameters.
341
* @param si the signed info
342
* @param ki the key info (may be <code>null</code>)
343
* @param objects a list of {@link XMLObject}s (may be empty or
345
* @param id the Id (may be <code>null</code>)
346
* @param signatureValueId the SignatureValue Id (may be <code>null</code>)
347
* @return an <code>XMLSignature</code>
348
* @throws NullPointerException if <code>si</code> is <code>null</code>
349
* @throws ClassCastException if any of the <code>objects</code> are not of
350
* type <code>XMLObject</code>
352
public abstract XMLSignature newXMLSignature(SignedInfo si, KeyInfo ki,
353
List objects, String id, String signatureValueId);
356
* Creates a <code>Reference</code> with the specified URI and digest
359
* @param uri the reference URI (may be <code>null</code>)
360
* @param dm the digest method
361
* @return a <code>Reference</code>
362
* @throws IllegalArgumentException if <code>uri</code> is not RFC 2396
364
* @throws NullPointerException if <code>dm</code> is <code>null</code>
366
public abstract Reference newReference(String uri, DigestMethod dm);
369
* Creates a <code>Reference</code> with the specified parameters.
371
* @param uri the reference URI (may be <code>null</code>)
372
* @param dm the digest method
373
* @param transforms a list of {@link Transform}s. The list is defensively
374
* copied to protect against subsequent modification. May be
375
* <code>null</code> or empty.
376
* @param type the reference type, as a URI (may be <code>null</code>)
377
* @param id the reference ID (may be <code>null</code>)
378
* @return a <code>Reference</code>
379
* @throws ClassCastException if any of the <code>transforms</code> are
380
* not of type <code>Transform</code>
381
* @throws IllegalArgumentException if <code>uri</code> is not RFC 2396
383
* @throws NullPointerException if <code>dm</code> is <code>null</code>
385
public abstract Reference newReference(String uri, DigestMethod dm,
386
List transforms, String type, String id);
389
* Creates a <code>Reference</code> with the specified parameters and
390
* pre-calculated digest value.
392
* <p>This method is useful when the digest value of a
393
* <code>Reference</code> has been previously computed. See for example,
395
* <a href="http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=dss">
396
* OASIS-DSS (Digital Signature Services)</a> specification.
398
* @param uri the reference URI (may be <code>null</code>)
399
* @param dm the digest method
400
* @param transforms a list of {@link Transform}s. The list is defensively
401
* copied to protect against subsequent modification. May be
402
* <code>null</code> or empty.
403
* @param type the reference type, as a URI (may be <code>null</code>)
404
* @param id the reference ID (may be <code>null</code>)
405
* @param digestValue the digest value. The array is cloned to protect
406
* against subsequent modification.
407
* @return a <code>Reference</code>
408
* @throws ClassCastException if any of the <code>transforms</code> are
409
* not of type <code>Transform</code>
410
* @throws IllegalArgumentException if <code>uri</code> is not RFC 2396
412
* @throws NullPointerException if <code>dm</code> or
413
* <code>digestValue</code> is <code>null</code>
415
public abstract Reference newReference(String uri, DigestMethod dm,
416
List transforms, String type, String id, byte[] digestValue);
419
* Creates a <code>Reference</code> with the specified parameters.
421
* <p>This method is useful when a list of transforms have already been
422
* applied to the <code>Reference</code>. See for example,
424
* <a href="http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=dss">
425
* OASIS-DSS (Digital Signature Services)</a> specification.
427
* <p>When an <code>XMLSignature</code> containing this reference is
428
* generated, the specified <code>transforms</code> (if non-null) are
429
* applied to the specified <code>result</code>. The
430
* <code>Transforms</code> element of the resulting <code>Reference</code>
431
* element is set to the concatenation of the
432
* <code>appliedTransforms</code> and <code>transforms</code>.
434
* @param uri the reference URI (may be <code>null</code>)
435
* @param dm the digest method
436
* @param appliedTransforms a list of {@link Transform}s that have
437
* already been applied. The list is defensively
438
* copied to protect against subsequent modification. The list must
439
* contain at least one entry.
440
* @param result the result of processing the sequence of
441
* <code>appliedTransforms</code>
442
* @param transforms a list of {@link Transform}s that are to be applied
443
* when generating the signature. The list is defensively copied to
444
* protect against subsequent modification. May be <code>null</code>
446
* @param type the reference type, as a URI (may be <code>null</code>)
447
* @param id the reference ID (may be <code>null</code>)
448
* @return a <code>Reference</code>
449
* @throws ClassCastException if any of the transforms (in either list)
450
* are not of type <code>Transform</code>
451
* @throws IllegalArgumentException if <code>uri</code> is not RFC 2396
452
* compliant or <code>appliedTransforms</code> is empty
453
* @throws NullPointerException if <code>dm</code>,
454
* <code>appliedTransforms</code> or <code>result</code> is
457
public abstract Reference newReference(String uri, DigestMethod dm,
458
List appliedTransforms, Data result, List transforms, String type,
462
* Creates a <code>SignedInfo</code> with the specified canonicalization
463
* and signature methods, and list of one or more references.
465
* @param cm the canonicalization method
466
* @param sm the signature method
467
* @param references a list of one or more {@link Reference}s. The list is
468
* defensively copied to protect against subsequent modification.
469
* @return a <code>SignedInfo</code>
470
* @throws ClassCastException if any of the references are not of
471
* type <code>Reference</code>
472
* @throws IllegalArgumentException if <code>references</code> is empty
473
* @throws NullPointerException if any of the parameters
474
* are <code>null</code>
476
public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm,
477
SignatureMethod sm, List references);
480
* Creates a <code>SignedInfo</code> with the specified parameters.
482
* @param cm the canonicalization method
483
* @param sm the signature method
484
* @param references a list of one or more {@link Reference}s. The list is
485
* defensively copied to protect against subsequent modification.
486
* @param id the id (may be <code>null</code>)
487
* @return a <code>SignedInfo</code>
488
* @throws ClassCastException if any of the references are not of
489
* type <code>Reference</code>
490
* @throws IllegalArgumentException if <code>references</code> is empty
491
* @throws NullPointerException if <code>cm</code>, <code>sm</code>, or
492
* <code>references</code> are <code>null</code>
494
public abstract SignedInfo newSignedInfo(CanonicalizationMethod cm,
495
SignatureMethod sm, List references, String id);
497
// Object factory methods
499
* Creates an <code>XMLObject</code> from the specified parameters.
501
* @param content a list of {@link XMLStructure}s. The list
502
* is defensively copied to protect against subsequent modification.
503
* May be <code>null</code> or empty.
504
* @param id the Id (may be <code>null</code>)
505
* @param mimeType the mime type (may be <code>null</code>)
506
* @param encoding the encoding (may be <code>null</code>)
507
* @return an <code>XMLObject</code>
508
* @throws ClassCastException if <code>content</code> contains any
509
* entries that are not of type {@link XMLStructure}
511
public abstract XMLObject newXMLObject(List content, String id,
512
String mimeType, String encoding);
515
* Creates a <code>Manifest</code> containing the specified
516
* list of {@link Reference}s.
518
* @param references a list of one or more <code>Reference</code>s. The list
519
* is defensively copied to protect against subsequent modification.
520
* @return a <code>Manifest</code>
521
* @throws NullPointerException if <code>references</code> is
523
* @throws IllegalArgumentException if <code>references</code> is empty
524
* @throws ClassCastException if <code>references</code> contains any
525
* entries that are not of type {@link Reference}
527
public abstract Manifest newManifest(List references);
530
* Creates a <code>Manifest</code> containing the specified
531
* list of {@link Reference}s and optional id.
533
* @param references a list of one or more <code>Reference</code>s. The list
534
* is defensively copied to protect against subsequent modification.
535
* @param id the id (may be <code>null</code>)
536
* @return a <code>Manifest</code>
537
* @throws NullPointerException if <code>references</code> is
539
* @throws IllegalArgumentException if <code>references</code> is empty
540
* @throws ClassCastException if <code>references</code> contains any
541
* entries that are not of type {@link Reference}
543
public abstract Manifest newManifest(List references, String id);
546
* Creates a <code>SignatureProperty</code> containing the specified
547
* list of {@link XMLStructure}s, target URI and optional id.
549
* @param content a list of one or more <code>XMLStructure</code>s. The list
550
* is defensively copied to protect against subsequent modification.
551
* @param target the target URI of the Signature that this property applies
553
* @param id the id (may be <code>null</code>)
554
* @return a <code>SignatureProperty</code>
555
* @throws NullPointerException if <code>content</code> or
556
* <code>target</code> is <code>null</code>
557
* @throws IllegalArgumentException if <code>content</code> is empty
558
* @throws ClassCastException if <code>content</code> contains any
559
* entries that are not of type {@link XMLStructure}
561
public abstract SignatureProperty newSignatureProperty
562
(List content, String target, String id);
565
* Creates a <code>SignatureProperties</code> containing the specified
566
* list of {@link SignatureProperty}s and optional id.
568
* @param properties a list of one or more <code>SignatureProperty</code>s.
569
* The list is defensively copied to protect against subsequent
571
* @param id the id (may be <code>null</code>)
572
* @return a <code>SignatureProperties</code>
573
* @throws NullPointerException if <code>properties</code>
574
* is <code>null</code>
575
* @throws IllegalArgumentException if <code>properties</code> is empty
576
* @throws ClassCastException if <code>properties</code> contains any
577
* entries that are not of type {@link SignatureProperty}
579
public abstract SignatureProperties newSignatureProperties
580
(List properties, String id);
582
// Algorithm factory methods
584
* Creates a <code>DigestMethod</code> for the specified algorithm URI
587
* @param algorithm the URI identifying the digest algorithm
588
* @param params algorithm-specific digest parameters (may be
590
* @return the <code>DigestMethod</code>
591
* @throws InvalidAlgorithmParameterException if the specified parameters
592
* are inappropriate for the requested algorithm
593
* @throws NoSuchAlgorithmException if an implementation of the
594
* specified algorithm cannot be found
595
* @throws NullPointerException if <code>algorithm</code> is
598
public abstract DigestMethod newDigestMethod(String algorithm,
599
DigestMethodParameterSpec params) throws NoSuchAlgorithmException,
600
InvalidAlgorithmParameterException;
603
* Creates a <code>SignatureMethod</code> for the specified algorithm URI
606
* @param algorithm the URI identifying the signature algorithm
607
* @param params algorithm-specific signature parameters (may be
609
* @return the <code>SignatureMethod</code>
610
* @throws InvalidAlgorithmParameterException if the specified parameters
611
* are inappropriate for the requested algorithm
612
* @throws NoSuchAlgorithmException if an implementation of the
613
* specified algorithm cannot be found
614
* @throws NullPointerException if <code>algorithm</code> is
617
public abstract SignatureMethod newSignatureMethod(String algorithm,
618
SignatureMethodParameterSpec params) throws NoSuchAlgorithmException,
619
InvalidAlgorithmParameterException;
622
* Creates a <code>Transform</code> for the specified algorithm URI
625
* @param algorithm the URI identifying the transform algorithm
626
* @param params algorithm-specific transform parameters (may be
628
* @return the <code>Transform</code>
629
* @throws InvalidAlgorithmParameterException if the specified parameters
630
* are inappropriate for the requested algorithm
631
* @throws NoSuchAlgorithmException if an implementation of the
632
* specified algorithm cannot be found
633
* @throws NullPointerException if <code>algorithm</code> is
636
public abstract Transform newTransform(String algorithm,
637
TransformParameterSpec params) throws NoSuchAlgorithmException,
638
InvalidAlgorithmParameterException;
641
* Creates a <code>Transform</code> for the specified algorithm URI
642
* and parameters. The parameters are specified as a mechanism-specific
643
* <code>XMLStructure</code> (ex: {@link DOMStructure}). This method is
644
* useful when the parameters are in XML form or there is no standard
645
* class for specifying the parameters.
647
* @param algorithm the URI identifying the transform algorithm
648
* @param params a mechanism-specific XML structure from which to
649
* unmarshal the parameters from (may be <code>null</code> if
650
* not required or optional)
651
* @return the <code>Transform</code>
652
* @throws ClassCastException if the type of <code>params</code> is
653
* inappropriate for this <code>XMLSignatureFactory</code>
654
* @throws InvalidAlgorithmParameterException if the specified parameters
655
* are inappropriate for the requested algorithm
656
* @throws NoSuchAlgorithmException if an implementation of the
657
* specified algorithm cannot be found
658
* @throws NullPointerException if <code>algorithm</code> is
661
public abstract Transform newTransform(String algorithm,
662
XMLStructure params) throws NoSuchAlgorithmException,
663
InvalidAlgorithmParameterException;
666
* Creates a <code>CanonicalizationMethod</code> for the specified
667
* algorithm URI and parameters.
669
* @param algorithm the URI identifying the canonicalization algorithm
670
* @param params algorithm-specific canonicalization parameters (may be
672
* @return the <code>CanonicalizationMethod</code>
673
* @throws InvalidAlgorithmParameterException if the specified parameters
674
* are inappropriate for the requested algorithm
675
* @throws NoSuchAlgorithmException if an implementation of the
676
* specified algorithm cannot be found
677
* @throws NullPointerException if <code>algorithm</code> is
680
public abstract CanonicalizationMethod newCanonicalizationMethod(
681
String algorithm, C14NMethodParameterSpec params)
682
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException;
685
* Creates a <code>CanonicalizationMethod</code> for the specified
686
* algorithm URI and parameters. The parameters are specified as a
687
* mechanism-specific <code>XMLStructure</code> (ex: {@link DOMStructure}).
688
* This method is useful when the parameters are in XML form or there is
689
* no standard class for specifying the parameters.
691
* @param algorithm the URI identifying the canonicalization algorithm
692
* @param params a mechanism-specific XML structure from which to
693
* unmarshal the parameters from (may be <code>null</code> if
694
* not required or optional)
695
* @return the <code>CanonicalizationMethod</code>
696
* @throws ClassCastException if the type of <code>params</code> is
697
* inappropriate for this <code>XMLSignatureFactory</code>
698
* @throws InvalidAlgorithmParameterException if the specified parameters
699
* are inappropriate for the requested algorithm
700
* @throws NoSuchAlgorithmException if an implementation of the
701
* specified algorithm cannot be found
702
* @throws NullPointerException if <code>algorithm</code> is
705
public abstract CanonicalizationMethod newCanonicalizationMethod(
706
String algorithm, XMLStructure params)
707
throws NoSuchAlgorithmException, InvalidAlgorithmParameterException;
710
* Returns a <code>KeyInfoFactory</code> that creates <code>KeyInfo</code>
711
* objects. The returned <code>KeyInfoFactory</code> has the same
712
* mechanism type and provider as this <code>XMLSignatureFactory</code>.
714
* @return a <code>KeyInfoFactory</code>
715
* @throws NoSuchMechanismException if a <code>KeyFactory</code>
716
* implementation with the same mechanism type and provider
719
public final KeyInfoFactory getKeyInfoFactory() {
720
return KeyInfoFactory.getInstance(getMechanismType(), getProvider());
724
* Unmarshals a new <code>XMLSignature</code> instance from a
725
* mechanism-specific <code>XMLValidateContext</code> instance.
727
* @param context a mechanism-specific context from which to unmarshal the
729
* @return the <code>XMLSignature</code>
730
* @throws NullPointerException if <code>context</code> is
732
* @throws ClassCastException if the type of <code>context</code> is
733
* inappropriate for this factory
734
* @throws MarshalException if an unrecoverable exception occurs
735
* during unmarshalling
737
public abstract XMLSignature unmarshalXMLSignature
738
(XMLValidateContext context) throws MarshalException;
741
* Unmarshals a new <code>XMLSignature</code> instance from a
742
* mechanism-specific <code>XMLStructure</code> instance.
743
* This method is useful if you only want to unmarshal (and not
744
* validate) an <code>XMLSignature</code>.
746
* @param xmlStructure a mechanism-specific XML structure from which to
747
* unmarshal the signature from
748
* @return the <code>XMLSignature</code>
749
* @throws NullPointerException if <code>xmlStructure</code> is
751
* @throws ClassCastException if the type of <code>xmlStructure</code> is
752
* inappropriate for this factory
753
* @throws MarshalException if an unrecoverable exception occurs
754
* during unmarshalling
756
public abstract XMLSignature unmarshalXMLSignature
757
(XMLStructure xmlStructure) throws MarshalException;
760
* Indicates whether a specified feature is supported.
762
* @param feature the feature name (as an absolute URI)
763
* @return <code>true</code> if the specified feature is supported,
764
* <code>false</code> otherwise
765
* @throws NullPointerException if <code>feature</code> is <code>null</code>
767
public abstract boolean isFeatureSupported(String feature);
770
* Returns a reference to the <code>URIDereferencer</code> that is used by
771
* default to dereference URIs in {@link Reference} objects.
773
* @return a reference to the default <code>URIDereferencer</code> (never
776
public abstract URIDereferencer getURIDereferencer();