Spring Security
  1. Spring Security
  2. SEC-781

remove @deprecated on org.springframework.security.intercept.web.FilterInvocationDefinitionSourceEditor

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Won't Fix
    • Affects Version/s: 2.0.0
    • Fix Version/s: 3.0.0 M1
    • Component/s: Core
    • Labels:
      None

      Description

      some developer need to convert string to FilterInvocationDefinitionSource in java code.

        Activity

        Hide
        Luke Taylor added a comment -

        This class was intended to provide support for property editor based configuration, which is now deprecated, so in future this class will have no purpose within the framework and it would be better if it was removed in the interests of keeping the codebase as clean as possible and minimising maintenance overhead.

        What exactly is your requirement? You will of course still be able to make use of the code yourself if it is removed from future versions.

        Show
        Luke Taylor added a comment - This class was intended to provide support for property editor based configuration, which is now deprecated, so in future this class will have no purpose within the framework and it would be better if it was removed in the interests of keeping the codebase as clean as possible and minimising maintenance overhead. What exactly is your requirement? You will of course still be able to make use of the code yourself if it is removed from future versions.
        Hide
        zhouyanming added a comment -

        I would like to use classic acegi configuration rather than new spring2.0 schema,I can refresh FilterInvocationDefinitionSource at runtime using spring aop.

        <bean id="filterInvocationInterceptorObjectDefinitionSource" class="test.RefreshableFilterInvocationDefinitionSource" />
        <bean id="filterInvocationInterceptor"
        class="org.springframework.security.intercept.web.FilterSecurityInterceptor">
        <property name="objectDefinitionSource">
        <bean class="org.springframework.aop.framework.ProxyFactoryBean">
        <property name="targetSource" ref="filterInvocationInterceptorObjectDefinitionSource" />
        </bean>
        </property>
        </bean>

        public class RefreshableFilterInvocationDefinitionSource extends
        AbstractRefreshableTargetSource implements ResourceLoaderAware,
        BeanNameAware, InitializingBean {

        protected Log logger = LogFactory.getLog(getClass());

        private Resource definitionResource;

        private String beanName;

        private String directory = "/WEB-INF/conf/";

        private ResourceLoader resourceLoader;

        public String getDirectory()

        { return directory.endsWith("/") ? directory : directory + "/"; }

        public void setDirectory(String directory)

        { this.directory = directory; }

        public void setBeanName(String beanName)

        { this.beanName = beanName; }

        public void setResourceLoader(ResourceLoader resourceLoader)

        { this.resourceLoader = resourceLoader; }

        public void afterPropertiesSet() throws Exception

        { Assert.hasLength(directory); definitionResource = resourceLoader.getResource(getDirectory() + beanName + ".conf"); }

        public void setDefinitionAsText(String definition) {
        try

        { FileUtils.writeStringToFile(resourceLoader.getResource( getDirectory() + beanName + ".conf").getFile(), definition, "UTF-8"); }

        catch (IOException e)

        { logger.error(e.getMessage(), e); }

        }

        public String getDefinitionAsText() {
        try

        { return FileUtils.readFileToString(definitionResource.getFile(), "UTF-8"); }

        catch (IOException e)

        { logger.error(e.getMessage(), e); return ""; }

        }

        protected Object freshTarget() {
        StringBuilder sb = new StringBuilder();
        LineIterator it = null;
        try {
        it = FileUtils.lineIterator(definitionResource.getFile(), "UTF-8");
        while (it.hasNext())

        { String line = it.nextLine(); if (!line.startsWith("#")) sb.append(line + "\n"); }

        logger.info("loaded Acegi FilterInvocationDefinition config file["
        + definitionResource.getURL() + "]");
        } catch (IOException e) {
        } finally

        { LineIterator.closeQuietly(it); }

        FilterInvocationDefinitionSourceEditor configEditor = new FilterInvocationDefinitionSourceEditor();
        configEditor.setAsText(sb.toString());
        return configEditor.getValue();
        }

        }

        Show
        zhouyanming added a comment - I would like to use classic acegi configuration rather than new spring2.0 schema,I can refresh FilterInvocationDefinitionSource at runtime using spring aop. <bean id="filterInvocationInterceptorObjectDefinitionSource" class="test.RefreshableFilterInvocationDefinitionSource" /> <bean id="filterInvocationInterceptor" class="org.springframework.security.intercept.web.FilterSecurityInterceptor"> <property name="objectDefinitionSource"> <bean class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="targetSource" ref="filterInvocationInterceptorObjectDefinitionSource" /> </bean> </property> </bean> public class RefreshableFilterInvocationDefinitionSource extends AbstractRefreshableTargetSource implements ResourceLoaderAware, BeanNameAware, InitializingBean { protected Log logger = LogFactory.getLog(getClass()); private Resource definitionResource; private String beanName; private String directory = "/WEB-INF/conf/"; private ResourceLoader resourceLoader; public String getDirectory() { return directory.endsWith("/") ? directory : directory + "/"; } public void setDirectory(String directory) { this.directory = directory; } public void setBeanName(String beanName) { this.beanName = beanName; } public void setResourceLoader(ResourceLoader resourceLoader) { this.resourceLoader = resourceLoader; } public void afterPropertiesSet() throws Exception { Assert.hasLength(directory); definitionResource = resourceLoader.getResource(getDirectory() + beanName + ".conf"); } public void setDefinitionAsText(String definition) { try { FileUtils.writeStringToFile(resourceLoader.getResource( getDirectory() + beanName + ".conf").getFile(), definition, "UTF-8"); } catch (IOException e) { logger.error(e.getMessage(), e); } } public String getDefinitionAsText() { try { return FileUtils.readFileToString(definitionResource.getFile(), "UTF-8"); } catch (IOException e) { logger.error(e.getMessage(), e); return ""; } } protected Object freshTarget() { StringBuilder sb = new StringBuilder(); LineIterator it = null; try { it = FileUtils.lineIterator(definitionResource.getFile(), "UTF-8"); while (it.hasNext()) { String line = it.nextLine(); if (!line.startsWith("#")) sb.append(line + "\n"); } logger.info("loaded Acegi FilterInvocationDefinition config file[" + definitionResource.getURL() + "]"); } catch (IOException e) { } finally { LineIterator.closeQuietly(it); } FilterInvocationDefinitionSourceEditor configEditor = new FilterInvocationDefinitionSourceEditor(); configEditor.setAsText(sb.toString()); return configEditor.getValue(); } }
        Hide
        Luke Taylor added a comment -

        I'm afraid this class will probably be removed in 2.5, making this issue a "won't fix". We need to refactor the standard FilterInvocationDefinitionSource implementation to accomodate new configuration attributes for expressions. Trying to retain backwards compatibility with the property-editor support is too much of a maintenance headache and will lead to inferior code.

        Show
        Luke Taylor added a comment - I'm afraid this class will probably be removed in 2.5, making this issue a "won't fix". We need to refactor the standard FilterInvocationDefinitionSource implementation to accomodate new configuration attributes for expressions. Trying to retain backwards compatibility with the property-editor support is too much of a maintenance headache and will lead to inferior code.

          People

          • Assignee:
            Luke Taylor
            Reporter:
            zhouyanming
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: