Skip to main content

Get JAAS Principal from custom DataSource implementation

2 replies [Last post]
drfranknfurter
Offline
Joined: 2008-08-13
Points: 0

Hi

I have implemented a custom DataSource and configured Glassfish to use it for my connection pool. This was done by setting Resources>JDBC>Connection Pool>myPool>Datasource classname and dropping the jar containing the class in glassfish/lib. This all works fine, but I have a few questions that I am hoping someone can help me with.

1. Do I have to drop the jar file in the glassfish/lib folder or is there a better place?
2. How do I access the authenticated JAAS principal in this file?

For question 2 I would have normally used @Resources to get my hands on SessionContext and get the principal from there, but this will only work if the class resides in a ejb-jar in a deployed ear, or at least as far as I know.

Thanks in advance.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
drfranknfurter
Offline
Joined: 2008-08-13
Points: 0

And it seems glassfish/lib is the correct location for the jar.

Message was edited by: drfranknfurter

drfranknfurter
Offline
Joined: 2008-08-13
Points: 0

I was able to retrieve the principal by looking up the SessionContext using "java:comp/EJBContext".