0

I am newbie to Spring .I built a spring MVC application which is XML based and I used JAR files using Spring Framework MVC application step-by-step.

Now I have to integrate spring security in it. I found many tutorials for spring security, but all are made using annotations. And in the MVC tutorial it uses Ant and XML. I am just lost in this part. Should I have to convert my whole application using annotations or what to do?

Is there any way using spring security without annotations? May be this question is not logical. But guide me and help me solve my confusion.

Or is there any tutorial help me in this regard, please let me know. Thank you

4
  • 1
    What's wrong with using annotations? Commented Feb 14, 2012 at 9:59
  • What I am asking that ok I will use annotations, but should I have to change my application to annotation base or Spring security have no concern in which type your application is made? Commented Feb 14, 2012 at 10:18
  • You don't need to use annotations to use Spring Security, but it's far easier to do it that way. Commented Feb 14, 2012 at 16:02
  • @DonalFellows Thanks. But can you tell me how to do it or is there any tutoriall or link that might help me in this regard, kindly share. Commented Feb 15, 2012 at 7:31

1 Answer 1

1

I'm not sure what you mean with "change my application to annotation base", but you will have to add some anotations above your methods like this:

@Secured("isAuthenticated() and hasRole('PERMISSION_BUY_ITEMS')")
public void buyItem(int itemId, int userId) {
   // you buy stuff login
}

This way in order to access your method the user should be logged in (authenticated) and have the permission BUY_ITEMS.

You don't have to do this for all your methods.

If you do not need permission/role based authorization you can just use authentication based expressions like isAuthenticated(), isAnonymous() and permitAll out of the box without any custom implementation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.