JDBCRealm with JPA

New in Java EE6, and I'm trying to configure JDBCRealm. Many of the examples suggest making tables that contain user / group information manually in SQL.

Is there a more standard β€œJPA” way to do this? Glassfish tables are not expected to correspond to the types of table structures you will fall into if you use, for example, the OneToMany display (this is what I was hoping to use).

I read that Glassfish still uses JDBC to execute JDBCRealm, which explains why. And I came across this blog which offers a way to do this with JPA.

http://www.codeproject.com/Articles/238779/J2EE-JDBC-based-authentication-with-JPA-Entities-i

But is there an β€œofficial” way to do this with JPA? I want to make sure that I adhere to best practices to ensure a secure application.

thanks

+6
source share
1 answer

A few months ago, I wanted to create my JDBC Kingdom with glass fish, and I also had a lot of doubts. I will try to explain to you more or less how I did it using JPA.

Many of the examples suggest making tables containing user / group information manually in SQL.

I disagree if you use JPA for other persistence tasks, why are you making a security exception. Therefore, JPA is a good idea. Copying / pasting a piece of SQL into the DB console is easy, but better if you have entities that will automatically create these tables for you when you deploy your application.

The textbook you are following is fine, I think there is no such opinion as best practice.

I will give you some resources that I think will help you create a JDBC scope. Maybe you are interested in something simpler just to warm up, in this case check out this post:

http://javing.blogspot.in/2012/05/here-in-this-video-you-can-see-how-i.html

He talks about ROLE-based security in a glass planet, I think this can give you some advice.

If you want to know how to create a JDBC scope with JPA, follow this question that I made earlier, at the end you will find a solution:

Glassfish 3 Security - Form Based Authentication Using JDBC Realm

If you embed some kind of code, we can help you scream out if you're stuck.

+5
source

Source: https://habr.com/ru/post/915852/


All Articles