ASF Bugzilla – Attachment 19077 Details for
Bug 40880
Ability to override DocumentBuilderFactory.newInstance in XMLCipher
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Services API approach to fix Bug 40880
40880.patch (text/plain), 5.35 KB, created by
Ruchith Fernando
on 2006-11-03 05:10:36 UTC
(
hide
)
Description:
Services API approach to fix Bug 40880
Filename:
MIME Type:
Creator:
Ruchith Fernando
Created:
2006-11-03 05:10:36 UTC
Size:
5.35 KB
patch
obsolete
>Index: src/org/apache/xml/security/encryption/FragmentParserFactory.java >=================================================================== >--- src/org/apache/xml/security/encryption/FragmentParserFactory.java (revision 0) >+++ src/org/apache/xml/security/encryption/FragmentParserFactory.java (revision 0) >@@ -0,0 +1,58 @@ >+/* >+ * Copyright 2004,2005 The Apache Software Foundation. >+ * >+ * Licensed under the Apache License, Version 2.0 (the "License"); >+ * you may not use this file except in compliance with the License. >+ * You may obtain a copy of the License at >+ * >+ * http://www.apache.org/licenses/LICENSE-2.0 >+ * >+ * Unless required by applicable law or agreed to in writing, software >+ * distributed under the License is distributed on an "AS IS" BASIS, >+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. >+ * See the License for the specific language governing permissions and >+ * limitations under the License. >+ */ >+ >+package org.apache.xml.security.encryption; >+ >+import org.w3c.dom.Document; >+import org.xml.sax.InputSource; >+import org.xml.sax.SAXException; >+ >+import javax.xml.parsers.DocumentBuilder; >+import javax.xml.parsers.DocumentBuilderFactory; >+import javax.xml.parsers.ParserConfigurationException; >+ >+import sun.misc.Service; >+ >+import java.io.IOException; >+import java.io.StringReader; >+import java.util.Iterator; >+ >+/** >+ * >+ * @author Ruchith Fernando (ruchith.fernando@gmail.com) >+ */ >+public class FragmentParserFactory { >+ >+ public static FragmentParser getFragmentParser() { >+ >+ for (Iterator providers = Service.providers(FragmentParser.class); providers.hasNext();) { >+ return (FragmentParser)providers.next(); >+ } >+ >+ return new FragmentParser() { >+ public Document parseFragment(String fragment) throws ParserConfigurationException, SAXException, IOException { >+ DocumentBuilderFactory dbf = >+ DocumentBuilderFactory.newInstance(); >+ dbf.setNamespaceAware(true); >+ dbf.setAttribute("http://xml.org/sax/features/namespaces", Boolean.TRUE); >+ DocumentBuilder db = dbf.newDocumentBuilder(); >+ Document d = db.parse( >+ new InputSource(new StringReader(fragment))); >+ return d; >+ } >+ }; >+ } >+} >Index: src/org/apache/xml/security/encryption/FragmentParser.java >=================================================================== >--- src/org/apache/xml/security/encryption/FragmentParser.java (revision 0) >+++ src/org/apache/xml/security/encryption/FragmentParser.java (revision 0) >@@ -0,0 +1,33 @@ >+/* >+ * Copyright 2004,2005 The Apache Software Foundation. >+ * >+ * Licensed under the Apache License, Version 2.0 (the "License"); >+ * you may not use this file except in compliance with the License. >+ * You may obtain a copy of the License at >+ * >+ * http://www.apache.org/licenses/LICENSE-2.0 >+ * >+ * Unless required by applicable law or agreed to in writing, software >+ * distributed under the License is distributed on an "AS IS" BASIS, >+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. >+ * See the License for the specific language governing permissions and >+ * limitations under the License. >+ */ >+ >+package org.apache.xml.security.encryption; >+ >+import org.w3c.dom.Document; >+import org.xml.sax.SAXException; >+ >+import javax.xml.parsers.ParserConfigurationException; >+ >+import java.io.IOException; >+ >+/** >+ * >+ * @author Ruchith Fernando (ruchith.fernando@gmail.com) >+ */ >+public interface FragmentParser { >+ >+ Document parseFragment(String fragment) throws ParserConfigurationException, SAXException, IOException; >+} >Index: src/org/apache/xml/security/encryption/XMLCipher.java >=================================================================== >--- src/org/apache/xml/security/encryption/XMLCipher.java (revision 470756) >+++ src/org/apache/xml/security/encryption/XMLCipher.java (working copy) >@@ -37,8 +37,6 @@ > import javax.crypto.IllegalBlockSizeException; > import javax.crypto.NoSuchPaddingException; > import javax.crypto.spec.IvParameterSpec; >-import javax.xml.parsers.DocumentBuilder; >-import javax.xml.parsers.DocumentBuilderFactory; > import javax.xml.parsers.ParserConfigurationException; > > import org.apache.xml.security.algorithms.JCEMapper; >@@ -1939,7 +1937,9 @@ > String fragment = sb.toString(); > > try { >- Document d = parseFragment(fragment); >+ Document d = FragmentParserFactory.getFragmentParser() >+ .parseFragment(fragment); >+ > Element fragElt = (Element) _contextDocument.importNode( > d.getDocumentElement(), true); > result = _contextDocument.createDocumentFragment(); >@@ -1960,19 +1960,9 @@ > return (result); > } > >- protected Document parseFragment(String fragment) throws ParserConfigurationException, SAXException, IOException { >- DocumentBuilderFactory dbf = >- DocumentBuilderFactory.newInstance(); >- dbf.setNamespaceAware(true); >- dbf.setAttribute("http://xml.org/sax/features/namespaces", Boolean.TRUE); >- DocumentBuilder db = dbf.newDocumentBuilder(); >- Document d = db.parse( >- new InputSource(new StringReader(fragment))); >- return d; >- } > } >+ > >- > /** > * > * @author Axl Mattheus
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 40880
: 19077