2 Replies Latest reply on Feb 4, 2009 12:52 AM by kalavena surender

    How Security.drl file can be refreshed at runtime without re

    kalavena surender Newbie

      Hi,

      I have roles to be given to each user for each UI. In my application, user dynamically updates the user roles in security.drl file which is located in the JBOSS default/conf folder. I need to refresh the updated version of the security.drl file without restarting the server and application.

      How JBOSS can be refreshed at runtime without restarting?

      Please helpme.Thanks in advance.

      Surender.

        • 1. Re: How Security.drl file can be refreshed at runtime withou
          kalavena surender Newbie

          Hi...

          Write the following code in to click event Ex : .xhtml file..

          //jboss-seam.jar 2.1.1

          /*
          * Sreshtaya Softech India Pvt Ltd.
          *
          */

          /*Getting Security.drl from context which is mentioned in Component.xml Ex : <drools:rule-base name="securityRules">
          <drools:rule-files>
          security.drl
          </drools:rule-files>
          </drools:rule-base>*/

          org.jboss.seam.drools.RuleBase ruleBase= (org.jboss.seam.drools.RuleBase) Contexts.getApplicationContext().get("securityRules");

          //Getting RuleBasedPermissionResolver from context
          RuleBasedPermissionResolver ruleBasedPermissionResolver= (RuleBasedPermissionResolver) Contexts.getSessionContext().get("org.jboss.seam.security.ruleBasedPermissionResolver");


          try {
          //Applying new rules to context
          ruleBase.compileRuleBase();

          //Loading all rules to Context
          ruleBasedPermissionResolver.setSecurityContext(ruleBase.getRuleBase().newStatefulSession());

          } catch (Exception e) {

          e.printStackTrace();
          }

          Thats it without restatring the Jboss server all rules can apply at runtime..

          • 2. Re: How Security.drl file can be refreshed at runtime withou
            kalavena surender Newbie

            Hi...

            Write the following code in to click event ...

            //jboss-seam.jar 2.1.1



            AdminSystemSecurityAction.java

            /*
            * Sreshtaya Softech India Pvt Ltd.
            *
            */

            /*Getting Security.drl from context which is mentioned in Component.xml Ex : <drools:rule-base name="securityRules">
            <drools:rule-files>
            security.drl
            </drools:rule-files>
            </drools:rule-base>*/

            org.jboss.seam.drools.RuleBase ruleBase= (org.jboss.seam.drools.RuleBase) Contexts.getApplicationContext().get("securityRules");

            //Getting RuleBasedPermissionResolver from context
            RuleBasedPermissionResolver ruleBasedPermissionResolver= (RuleBasedPermissionResolver) Contexts.getSessionContext().get("org.jboss.seam.security.ruleBasedPermissionResolver");


            try {
            //Applying new rules to context
            ruleBase.compileRuleBase();

            //Loading all rules to Context
            ruleBasedPermissionResolver.setSecurityContext(ruleBase.getRuleBase().newStatefulSession());

            } catch (Exception e) {

            e.printStackTrace();
            }

            Thats it without restatring the Jboss server all rules can apply at runtime..