175 node.normalize();
176
177 Element element = null;
178 if (node.getNodeType() == Node.DOCUMENT_NODE) {
179 element = ((Document) node).getDocumentElement();
180 } else if (node.getNodeType() == Node.ELEMENT_NODE) {
181 element = (Element) node;
182 } else {
183 throw new MarshalException
184 ("Signature element is not a proper Node");
185 }
186
187 // check tag
188 String tag = element.getLocalName();
189 String namespace = element.getNamespaceURI();
190 if (tag == null || namespace == null) {
191 throw new MarshalException("Document implementation must " +
192 "support DOM Level 2 and be namespace aware");
193 }
194 if ("Signature".equals(tag) && XMLSignature.XMLNS.equals(namespace)) {
195 return new DOMXMLSignature(element, context, getProvider());
196 } else {
197 throw new MarshalException("invalid Signature tag: " + namespace + ":" + tag);
198 }
199 }
200
201 public boolean isFeatureSupported(String feature) {
202 if (feature == null) {
203 throw new NullPointerException();
204 } else {
205 return false;
206 }
207 }
208
209 public DigestMethod newDigestMethod(String algorithm,
210 DigestMethodParameterSpec params) throws NoSuchAlgorithmException,
211 InvalidAlgorithmParameterException {
212 if (algorithm == null) {
213 throw new NullPointerException();
214 }
215 if (algorithm.equals(DigestMethod.SHA1)) {
216 return new DOMDigestMethod.SHA1(params);
217 } else if (algorithm.equals(DOMDigestMethod.SHA224)) {
|
175 node.normalize();
176
177 Element element = null;
178 if (node.getNodeType() == Node.DOCUMENT_NODE) {
179 element = ((Document) node).getDocumentElement();
180 } else if (node.getNodeType() == Node.ELEMENT_NODE) {
181 element = (Element) node;
182 } else {
183 throw new MarshalException
184 ("Signature element is not a proper Node");
185 }
186
187 // check tag
188 String tag = element.getLocalName();
189 String namespace = element.getNamespaceURI();
190 if (tag == null || namespace == null) {
191 throw new MarshalException("Document implementation must " +
192 "support DOM Level 2 and be namespace aware");
193 }
194 if ("Signature".equals(tag) && XMLSignature.XMLNS.equals(namespace)) {
195 try {
196 return new DOMXMLSignature(element, context, getProvider());
197 } catch (MarshalException me) {
198 throw me;
199 } catch (Exception e) {
200 throw new MarshalException(e);
201 }
202 } else {
203 throw new MarshalException("Invalid Signature tag: " + namespace + ":" + tag);
204 }
205 }
206
207 public boolean isFeatureSupported(String feature) {
208 if (feature == null) {
209 throw new NullPointerException();
210 } else {
211 return false;
212 }
213 }
214
215 public DigestMethod newDigestMethod(String algorithm,
216 DigestMethodParameterSpec params) throws NoSuchAlgorithmException,
217 InvalidAlgorithmParameterException {
218 if (algorithm == null) {
219 throw new NullPointerException();
220 }
221 if (algorithm.equals(DigestMethod.SHA1)) {
222 return new DOMDigestMethod.SHA1(params);
223 } else if (algorithm.equals(DOMDigestMethod.SHA224)) {
|