5454import org .apache .commons .codec .binary .Base64 ;
5555import org .apache .commons .codec .digest .DigestUtils ;
5656import org .apache .commons .lang3 .StringUtils ;
57- import org .apache .xml .security .encryption .CipherData ;
5857import org .apache .xml .security .encryption .EncryptedData ;
5958import org .apache .xml .security .encryption .EncryptedKey ;
6059import org .apache .xml .security .encryption .XMLCipher ;
@@ -102,6 +101,10 @@ public final class Util {
102101
103102 private static final Logger log = LoggerFactory .getLogger (Util .class );
104103
104+ private Util () {
105+ //not called
106+ }
107+
105108 /**
106109 * This function load an XML string in a save way. Prevent XEE/XXE Attacks
107110 *
@@ -144,6 +147,7 @@ public static NodeList query(Document dom, String query, Node context) throws XP
144147 XPath xpath = XPathFactory .newInstance ().newXPath ();
145148 xpath .setNamespaceContext (new NamespaceContext () {
146149
150+ @ Override
147151 public String getNamespaceURI (String prefix ) {
148152 String result = null ;
149153 if (prefix .equals ("samlp" ) || prefix .equals ("samlp2" )) {
@@ -160,11 +164,13 @@ public String getNamespaceURI(String prefix) {
160164 return result ;
161165 }
162166
167+ @ Override
163168 public String getPrefix (String namespaceURI ) {
164169 return null ;
165170 }
166171
167172 @ SuppressWarnings ("rawtypes" )
173+ @ Override
168174 public Iterator getPrefixes (String namespaceURI ) {
169175 return null ;
170176 }
@@ -262,28 +268,28 @@ public static Document convertStringToDocument(String xmlStr) throws ParserConfi
262268 try {
263269 // do not include external general entities
264270 docfactory .setAttribute ("http://xml.org/sax/features/external-general-entities" , Boolean .FALSE );
265- } catch (Throwable t ) {}
271+ } catch (Exception e ) {}
266272 try {
267273 // do not include external parameter entities or the external DTD subset
268274 docfactory .setAttribute ("http://xml.org/sax/features/external-parameter-entities" , Boolean .FALSE );
269- } catch (Throwable t ) {}
275+ } catch (Exception e ) {}
270276 try {
271277 docfactory .setAttribute ("http://apache.org/xml/features/disallow-doctype-decl" , Boolean .TRUE );
272- } catch (Throwable t ) {}
278+ } catch (Exception e ) {}
273279 try {
274280 docfactory .setAttribute ("http://javax.xml.XMLConstants/feature/secure-processing" , Boolean .TRUE );
275- } catch (Throwable t ) {}
281+ } catch (Exception e ) {}
276282 try {
277283 // ignore the external DTD completely
278284 docfactory .setAttribute ("http://apache.org/xml/features/nonvalidating/load-external-dtd" , Boolean .FALSE );
279- } catch (Throwable t ) {}
285+ } catch (Exception e ) {}
280286 try {
281287 // build the grammar but do not use the default attributes and attribute types information it contains
282288 docfactory .setAttribute ("http://apache.org/xml/features/nonvalidating/load-dtd-grammar" , Boolean .FALSE );
283- } catch (Throwable t ) {}
289+ } catch (Exception e ) {}
284290 try {
285291 docfactory .setFeature (XMLConstants .FEATURE_SECURE_PROCESSING , true );
286- } catch (Throwable t ) {}
292+ } catch (Exception e ) {}
287293
288294 DocumentBuilder builder = docfactory .newDocumentBuilder ();
289295 Document doc = builder .parse (new InputSource (new StringReader (xmlStr )));
0 commit comments