Results 1 to 3 of 3

Thread: A very simple silly question....Must be a bean before @PreAuthorize to work?

  1. #1
    Join Date
    Dec 2012
    Posts
    1

    Question A very simple silly question....Must be a bean before @PreAuthorize to work?

    Hi,
    Do I have to have my class initialized via an applicationContext in order for @PreAuthorize(...) to work>??? I can get access to the authenticated Principle by doing a ServletContextHolder.getContext()..... but can't get my method security to work.....because the bean is that i am using is not wired up in the applicationContext....

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    Yes... Only beans in the spring context will be secured...

    You can however use AspectJ with loadtime or compile time weaving to apply security but this requires your setup to change.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Dec 2009
    Location
    India
    Posts
    108

    Default

    If you use configurable annotation on the corresponding object, then you can even if you create the instance with a new operator and don't initialize from within spring config at all.

Tags for this Thread

Posting Permissions

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