Results 1 to 2 of 2

Thread: Code Obfuscation

Hybrid View

  1. #1
    Join Date
    Oct 2007
    Posts
    26

    Default Code Obfuscation

    My PM is asking for Code Obfuscation to stop reverse engineering.

    If I obfuscate my code then class names would be changed and I would have to re write my spring applicationcontext file. Is there any support or easy ideas to achieve that ?

    Thanks,

  2. #2
    Join Date
    Apr 2007
    Posts
    307

    Default

    It sounds like you're currently using XML to configure your application, but you've posted in the right place - the Spring JavaConfig project is a perfect solution for those that need obfuscation. Essentially, you'll drop using XML and start writing your configurations in pure java.

    Before:
    Code:
    <beans>
        <bean id="foo" class="com.myco.Foo"/>
    </beans>
    and you would access that bean as follows:
    Code:
    ApplicationContext ctx = new ClassPathXmlApplicationContext("beans.xml");
    Foo foo = (Foo) ctx.getBean("foo");
    In this situation, you're quite right - obfuscation would render the beans.xml file inaccurate and the configuration would not work.

    Here's the same configuration using JavaConfig:
    Code:
    @Configuration
    public class AppConfig {
        public @Bean Foo foo() {
            return new Foo();
        }
    }
    And bootstrapping goes as follows:
    Code:
    JavaConfigApplicationContext ctx = new JavaConfigApplicationContext(Foo.class);
    Foo foo = ctx.getBean(Foo.class);
    As you can see, with JavaConfig it's 100% Java - no XML, no string identifiers, so everything will obfuscate together and work perfectly.

    Hope this gives you what you're looking for!
    Chris Beams
    Spring Framework committer, VMware
    http://github.com/cbeams

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •