Results 1 to 4 of 4

Thread: Refresh access policy at runtime

  1. #1
    Join Date
    Aug 2004
    Posts
    6

    Default Refresh access policy at runtime

    I want to give the customer a ui interface so that they can make their own administration policy (i.e. They can change the right of a user, allow or disallow him to do sth). But how can I change the settings at runtime if they are predefined in xml.

    Thanks,
    Peng

  2. #2
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    All attributes you'd probably want to define at runtime come from interfaces (eg ObjectDefinitionSource). So you can provide a concrete implementation that uses any backend you like (XML, memory, JDBC etc). Just use <ref bean="myBean"/> instead of Strings in XML which are processed by the PropertyEditors.

    If you run into difficulty, post back to the forum which bean and property you're trying to modify at runtime, and I'll be pleased take a look.

  3. #3
    Join Date
    Aug 2004
    Posts
    6

    Default

    Quote Originally Posted by benalex
    All attributes you'd probably want to define at runtime come from interfaces (eg ObjectDefinitionSource). So you can provide a concrete implementation that uses any backend you like (XML, memory, JDBC etc). Just use <ref bean="myBean"/> instead of Strings in XML which are processed by the PropertyEditors.

    If you run into difficulty, post back to the forum which bean and property you're trying to modify at runtime, and I'll be pleased take a look.
    Thanks, maybe I didn't state the question clearly. I mean if I make the following rule as the contact sample shows, how can I change authority of a role at runtime, e.g. ROLE_TELLER can execute method sample.contact.ContactManager.getById, but customer want to disallow him to do that by click a button on our web page

    Code:
    <bean id="publicContactManagerSecurity" class="net.sf.acegisecurity.intercept.method.MethodSecurityInterceptor">
        	<property name="authenticationManager"><ref bean="authenticationManager"/></property>
        	<property name="accessDecisionManager"><ref bean="businessAccessDecisionManager"/></property>
        	<property name="runAsManager"><ref bean="runAsManager"/></property>
     		<property name="objectDefinitionSource">
    			<value>
    				sample.contact.ContactManager.delete=ROLE_SUPERVISOR,RUN_AS_SERVER
    				sample.contact.ContactManager.getAllByOwner=CONTACT_OWNED_BY_CURRENT_USER,RUN_AS_SERVER
    				sample.contact.ContactManager.save=CONTACT_OWNED_BY_CURRENT_USER,RUN_AS_SERVER
    				sample.contact.ContactManager.getById=ROLE_TELLER,RUN_AS_SERVER
    			</value>
    		</property>
    	</bean>

  4. #4
    Join Date
    Aug 2004
    Location
    Sydney, Australia
    Posts
    2,768

    Default

    As I said in my orignal post, instead of defining the MethodSecurityInterceptor.ObjectDefinitionSource property via Spring XML, you'd have a <ref bean="myObjectDefinitionSource"/>. This is the same as the included "attributes sample" applicationContext.xml, which uses <ref bean> for referring to the MethodDefinitionAttributes bean.

    Your MyObjectDefinitionSource would implement MethodDefinitionSource. This interface provides the necessary getters for the MethodSecurityInterceptor to determine the configuration attributes that apply to a give method signature.

    Your MyObjectDefinitionSource would probably front a database which stores the method name pattern against the allowed GrantedAuthoritys.

    Hope this helps.

Similar Threads

  1. Replies: 9
    Last Post: Oct 14th, 2005, 09:38 AM
  2. Injecting runtime constructor-arg properties
    By james.estes in forum Container
    Replies: 4
    Last Post: Oct 5th, 2005, 07:37 AM
  3. Replies: 13
    Last Post: Jun 14th, 2005, 06:28 PM
  4. Replies: 0
    Last Post: Jun 10th, 2005, 05:44 AM
  5. Refresh PropertyPlaceholder data at runtime
    By rebornspirt in forum Container
    Replies: 2
    Last Post: Oct 28th, 2004, 10:21 AM

Posting Permissions

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