• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring Security - extended user class

 
Jeferson Coli
Greenhorn
Posts: 2
Debian Netbeans IDE Postgres Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I'm developing a system using Spring Security, JPA/Hibernate, Postgres JSF and Primefaces.

There are three classes that extending user class, pilot, mechanic and staff. But if I extend it won't be neither class or table user to authenticate.

I put a OneToOne relationship between classes.

Somebody has some diferent idea to do this?
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If Pilot, Mechanic and Staff extend from User, you could still use User class for your authentication. And it depends on your inheritance strategy of these are in the same table or in different tables.

You could always use an interface as well and use this interface as a parameter in the authenticate method(s). But probably using an abstract User class (if you need to store some state, e.g. id, name,...) is a better design decision.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic