Announcement Announcement Module
Collapse
No announcement yet.
Initializing NamespaceHandler or BeanDefinitionDecorator from Context Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Initializing NamespaceHandler or BeanDefinitionDecorator from Context

    I have a need to be able to decrypt encrypted property values and supply them to a bean definition. There is the possibility that different values could be encrypted by different keys. I have a solution currently that uses a BeanFactoryPostProcessor (or multiple ones for multiple keys) and it works pretty well.

    I wanted to see if there was a way to implement this thru a custom XML namespace and NamespaceHandler/BeanDefinitionDecorator so that I could simply add an 'encrypted="yes"' attribute (and possibly a 'encryption-id="xxx"' if there are multiple encryption keys) to property or constructor-arg elements. Example:

    Code:
    <!-- This bean uses the default prefix (TDS) with property values --> <bean id="testBean" class="sf.jra.framework.spring.context.TestBean"> <property name="name" value="someone" /> <property name="password" sfenc:encrypted="yes" value="FZOPwB4Jj+OYFlil7jLecw=="/> </bean>
    <!-- This bean uses a custom prefix --> <bean id="testBeanWithOtherPrefix" class="sf.jra.framework.spring.context.TestBean"> <property name="name" value="someone" /> <property name="password" sfenc:encrypted="yes" sfenc:encryption-id="DIFFERENT_PREFIX" value="FZOPwB4Jj+OYFlil7jLecw=="/> </bean> <!-- This bean uses indexed constructor arguments -->
    <bean id="testBeanFromConstructor" class="sf.jra.framework.spring.context.TestBean"> <constructor-arg index="0" value="someone" /> <constructor-arg index="1" sfenc:encrypted="yes" value="FZOPwB4Jj+OYFlil7jLecw=="/> </bean>
    <!-- This bean uses 'generic' constructor arguments, ones that have no index --> <bean id="testBeanFromPasswordConstructor" class="sf.jra.framework.spring.context.TestBean"> <constructor-arg encrypted="yes" sfenc:encryption-id="DIFFERENT_PREFIX" value="FZOPwB4Jj+OYFlil7jLecw=="/> <property name="name" value="someone" /> </bean>
    The only issue I have is that the encryption key(s) need to be passed to the BeanDefinitionDecorator. Right now I pass the key to the BeanFactoryPostProcessor in the context config file. Is there any way I can do this using a namespace?
    Last edited by bdavisx; Jun 6th, 2007, 04:01 PM. Reason: Added some other bean def examples.
Working...
X