You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jspwiki.apache.org by "David Vittor (JIRA)" <ji...@apache.org> on 2015/02/14 08:05:11 UTC

[jira] [Commented] (JSPWIKI-877) Allow jspwiki.properties filterConfig and policy.file to have fully qualified paths

    [ https://issues.apache.org/jira/browse/JSPWIKI-877?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14321278#comment-14321278 ] 

David Vittor commented on JSPWIKI-877:
--------------------------------------

4 configurations values:
* jspwiki.policy.file=C:/temp/jspwiki-custom.policy
* jspwiki.filterConfig=C:/temp/jspwiki-filters.xml
* jspwiki.xmlGroupDatabaseFile=C:/temp/groupdatabase.xml
* jspwiki.xmlUserDatabaseFile=C:/temp/userdatabase.xml

4 implementations:
*XmlUserDatabase.java and XmlGroupDatabase.java* uses:
{noformat}
        File defaultFile = null;
        if( engine.getRootPath() == null )
        {
            log.warn( "Cannot identify JSPWiki root path"  );
            defaultFile = new File( "WEB-INF/" + DEFAULT_USERDATABASE ).getAbsoluteFile();
        }
        else
        {
            defaultFile = new File( engine.getRootPath() + "/WEB-INF/" + DEFAULT_USERDATABASE );
        }

        // Get database file location
        String file = props.getProperty( PROP_USERDATABASE );
        if( file == null )
        {
            log.warn( "XML user database property " + PROP_USERDATABASE + " not found; trying " + defaultFile  );
            c_file = defaultFile;
        }
        else 
        {
            c_file = new File( file );
        }
{noformat}

*AuthorisationManager.java* uses:
{noformat}
            String policyFileName = properties.getProperty( POLICY, DEFAULT_POLICY );
            URL policyURL = AuthenticationManager.findConfigFile( engine, policyFileName );
{noformat}

*DefaultFilterManager.xml* uses:
{noformat}
        InputStream xmlStream = null;
        String      xmlFile   = props.getProperty( PROP_FILTERXML );

        try {
            registerFilters();
            
            if( m_engine.getServletContext() != null ) {
                log.debug( "Attempting to locate " + DEFAULT_XMLFILE + " from servlet context." );
                if( xmlFile == null ) {
                    xmlStream = m_engine.getServletContext().getResourceAsStream( DEFAULT_XMLFILE );
                } else {
                    xmlStream = m_engine.getServletContext().getResourceAsStream( xmlFile );
                }
            }

            if( xmlStream == null ) {
                // just a fallback element to the old behaviour prior to 2.5.8
                log.debug( "Attempting to locate filters.xml from class path." );

                if( xmlFile == null ) {
                    xmlStream = getClass().getResourceAsStream( "/filters.xml" );
                } else {
                    xmlStream = getClass().getResourceAsStream( xmlFile );
                }
            }

            if( (xmlStream == null) && (xmlFile != null) ) {
                log.debug("Attempting to load property file "+xmlFile);
                xmlStream = new FileInputStream( new File(xmlFile) );
            }

            if( xmlStream == null ) {
                log.info( "Cannot find property file for filters (this is okay, expected to find it as: '" + 
                           ( xmlFile == null ? DEFAULT_XMLFILE : xmlFile ) + 
                          "')" );
                return;
            }
{noformat}

*PropertyReader.java* uses:
{noformat}
        String propertyFile = getInitParameter( context, PARAM_CUSTOMCONFIG );
        InputStream propertyStream = null;

        try {
            //
            //  Figure out where our properties lie.
            //
            if( propertyFile == null ) {
                LOG.info( "No " + PARAM_CUSTOMCONFIG + " defined for this context, " +
                             "looking for custom properties file with default name of: " + CUSTOM_JSPWIKI_CONFIG );
                //  Use the custom property file at the default location
                propertyStream =  locateClassPathResource(context, CUSTOM_JSPWIKI_CONFIG);
            } else {
                LOG.info(PARAM_CUSTOMCONFIG + " defined, using " + propertyFile + " as the custom properties file.");
                propertyStream = new FileInputStream( new File(propertyFile) );
            }

            Properties props = getDefaultProperties();
            if( propertyStream == null ) {
                LOG.info("No custom property file found, relying on JSPWiki defaults.");
            } else {
                props.load( propertyStream );
            }

            //this will add additional properties to the default ones:
            LOG.debug( "Loading cascading properties..." );

            //now load the cascade (new in 2.5)
            loadWebAppPropsCascade( context, props );

            //finally expand the variables (new in 2.5)
            expandVars( props );

            return props;
{noformat}

> Allow jspwiki.properties filterConfig and policy.file to have fully qualified paths
> -----------------------------------------------------------------------------------
>
>                 Key: JSPWIKI-877
>                 URL: https://issues.apache.org/jira/browse/JSPWIKI-877
>             Project: JSPWiki
>          Issue Type: Bug
>          Components: Core & storage
>    Affects Versions: 2.10.1
>            Reporter: David Vittor
>
> Currently adding the following properties does not work:
> * jspwiki.policy.file=C:/temp/jspwiki-custom.policy
> * jspwiki.filterConfig=C:/temp/jspwiki-filters.xml
> The policy file only checks certain locations, and not fully qualified paths.
> The filterConfig has the same problem, but does work in linux, but not in windows as this expects a URL, e.g. file:/C:/temp/... but this causes a SEVERE filterStart error in tomcat.
> Note: These seem to be inconsistant with UserDatabase and GroupDatabase



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)