OK, so my example might look like this for you (again, I'm going to use 
concrete code here).  First, define the class that will "wrap" the call to 
your actual target method:

----
public class CustomerReportQuartzAuthenticator
{
  private CustomerReport customerReport;
  pricate SecurityFacade securityFacade;

  public void authenticatedGeneratePerformance() {
    securityFacade.authenticateUser("subsystemUserName", 
"subsystemCredentials"); 
    try {
      customerReport.generatePerformance();
    } finally {
      securityFacade.unauthenticateUser();
    }
  }

  public CustomerReport getCustomeReport() {
    return customerReport;
  }
  public void setCustomerReport(CustomerReport cr) {
    customerReport = cr;
  }
  public SecurityFacade getSecurityFacade() {
    return securityFacade;
  }
  public void setSecurityFacade(SecurityFacade sf) {
    securityFacade = sf;
  }
}
----

Declare it in your spring config (note, I'm not familiar with commons 
attributes, so I'm showing you what this would look like in XML):

----

<bean id="quartzAuthenticatedCustomerReport" 
class="...CustomerReportQuartzAuthenticator">
  <property name="customeReport" ref="customerReport"/>
  <property name="securityFacade" ref="securityFacade"/>
</bean>

----

Note that it references your "customerReport" bean, which I'm assuming you've 
already declared in your Spring config (along with securityFacade) - in other 
words, you shouldn't need to change your current configuration of 
"customerReport" at all.  In fact, you should now remove any authentication 
code you may have put into customerReport.  Now, change your 
"MethodInvokingJobDetailFactoryBean" to call 
"quartzAuthenticatedCustomerReport" instead.  Something like this:

----
<bean id="quartzCustomerReportJob" 
class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
  <property name="targetObject" ref="quartzAuthenticatedCustomerReport"/>
  <property name="targetMethod" value="authenticatedGeneratePerformance"/>
</bean>
----

  - Andy

On Friday 16 September 2005 02:17 pm, Achmad Arif Rachim wrote:
> Actually the architecture was like this
>
> First i create target class called CostumerReport which has method named
> generatePerformance. So generatePerformance will be called as
> "targetMethod" by acegi, becouse its the method that will be invoked daily.
> Then i declare CostumerReport as costumerReport bean in
> applicationContexta.xml and i also inject SecurityFacade and other Service
> object.
>
> Then costumerReport is wrapped inside MethodInvokingJobDetailFactoryBean by
> declaring targetMethod that will be invoked (obviously it is
> costumerReport.generateSalesPerformance), basically this is the easiest way
> to declare quartz job detail bean.
>
> My last step is creating quartz trigger using simple trigger bean, and set
> the interval periode.
>
> Im using commons-attributest to make easy configuration (rather than
> editing the xml). I belive this attributeSource (commons-attributes) couse
> inspection every time method being called, any kind of method which
> registered in applicationContext.xml.
>
> Thats why every time quartz MethodInvokingJobDetailFactoryBean executed,
> security concern will check if theres any Authentication in SecureContext.
>
> So the case was like this, CostumerReport automatically becoming secured
> object becouse MethodInvocationInterceptor using attributes
> commons-attributes. Even if i dont declare
>
> @@net.sf.acegisecurity.SecurityConfig("ROLE_USER")
>
> still acegi check if theres any AuthenticationObject every method
> invocation in every bean thats registered in applicationContext.xml


-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. 
Download it for free - -and be entered to win a 42" plasma tv or your very
own Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Home: http://acegisecurity.sourceforge.net
Acegisecurity-developer mailing list
Acegisecurity-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/acegisecurity-developer

Reply via email to