public aspect Checker {

  before(): get(* *) && !withincode(* get*(..)){ 
System.out.println(“checking…”);}

}

That is checking field-get join points not within getters. Other alternatives 
would include cflow() or if() clauses using thisJoinPoint - but those would 
both leave runtime checks in the code where the test above can be completely 
statically determined.

(It isn’t verifying the field name matches the getter name - that’s where you 
might be able to add an if() test or a check to your advice that compares 
thisJoinPointStaticPart with thisEnclosingJoinPointStaticPart)

cheers,
Andy


> On Feb 20, 2015, at 7:03 AM, Tim Milstead <tmilst...@datagraphic.co.uk> wrote:
> 
> I have some java beans I would like to secure using AspectJ. Like all beans 
> the class has fields with matching setters and getters, e.g.
>  
> public class Bean
> {
>                 private String value;
>  
>                 public void setValue(String value)
>                 {
>                                 this.value = value;
>                 }
>  
>                 public String getValue(String value)
>                 {
>                                 return value;
>                 }
> }
>  
> I need to secure all read and write operations, e.g. for read I need to 
> secure getValue() using an aspect, but I also need to secure the 'value' 
> field directly. Is there away to avoid doing two checks on the get method 
> aspect, i.e. one for the method call and one for the (nested) field mutation? 
>  
> Thanks for any help,
>  
> Tim,
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@eclipse.org <mailto:aspectj-users@eclipse.org>
> To change your delivery options, retrieve your password, or unsubscribe from 
> this list, visit
> https://dev.eclipse.org/mailman/listinfo/aspectj-users 
> <https://dev.eclipse.org/mailman/listinfo/aspectj-users>
_______________________________________________
aspectj-users mailing list
aspectj-users@eclipse.org
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to