001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.security.xml;
016    
017    import com.liferay.portal.kernel.security.pacl.permission.PortalRuntimePermission;
018    
019    import javax.xml.parsers.DocumentBuilderFactory;
020    import javax.xml.stream.XMLInputFactory;
021    
022    import org.xml.sax.XMLReader;
023    
024    /**
025     * @author Tomas Polesovsky
026     */
027    public class SecureXMLFactoryProviderUtil {
028    
029            public static SecureXMLFactoryProvider getSecureXMLFactoryProvider() {
030                    PortalRuntimePermission.checkGetBeanProperty(
031                            SecureXMLFactoryProvider.class);
032    
033                    return _secureXMLFactoryProvider;
034            }
035    
036            public static DocumentBuilderFactory newDocumentBuilderFactory() {
037                    return getSecureXMLFactoryProvider().newDocumentBuilderFactory();
038            }
039    
040            public static XMLInputFactory newXMLInputFactory() {
041                    return getSecureXMLFactoryProvider().newXMLInputFactory();
042            }
043    
044            public static XMLReader newXMLReader() {
045                    return getSecureXMLFactoryProvider().newXMLReader();
046            }
047    
048            public void setSecureXMLFactoryProvider(
049                    SecureXMLFactoryProvider secureXMLFactoryProvider) {
050    
051                    PortalRuntimePermission.checkSetBeanProperty(getClass());
052    
053                    _secureXMLFactoryProvider = secureXMLFactoryProvider;
054            }
055    
056            private static SecureXMLFactoryProvider _secureXMLFactoryProvider;
057    
058    }