Skip to main content

Create a custom realm

6 replies [Last post]
olivierJ
Offline
Joined: 2012-11-10

Hi,

I want to develop a custom realm for Glassfish V3 which is basically an extending of jdbcRealm. This realm should access many databases so it's necessary to get in addition to username and password the number of database to make some String DataSource name with (ie: jdbc/datasources/db1, jdbc/datasources/db2, ..., jdbc/datasources/dbn).

But I wonder how to pass the number 1, 2, ..., n to my custom LoginModule/realm to authenticate user ?

I want to login user inside JSF context. Is form-login can realize it ?

Thanks you for your help.

Olivier

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Kumar Jayanti Guest
Offline
Joined: 2011-04-02

On Nov 10, 2012, at 8:49 PM, forums@java.net wrote:

> Hi, I want to develop a custom realm for Glassfish V3 which is basically an
> extending of jdbcRealm. This realm should access many databases so it's
> necessary to get in addition to username and password the number of database
> to make some String DataSource name with (ie: jdbc/datasources/db1,
> jdbc/datasources/db2, ..., jdbc/datasources/dbn)
Do you need to pass this string to the realm at Runtime or can you make it a configuration property for your realm ?
> . But I wonder how to pass
> the number 1, 2, ..., n to my custom LoginModule/realm to authenticate user ?
> I want to login user inside JSF context. Is form-login can realize it ?
> Thanks you for your help. Olivier
>
> --
>
> [Message sent by forum member 'olivierJ']
>
> View Post: http://forums.java.net/node/892193
>
>

olivierJ
Offline
Joined: 2012-11-10

Kumar Jayanti Guest wrote:
On Nov 10, 2012, at 8:49 PM, forums@java.net wrote:

Do you need to pass this string to the realm at Runtime or can you make it a configuration property for your realm ?
>

I need to pass this string at runtime via some JSF selectOneMenu component for example otherwise, I would store this inside Realm as property but I can't.

Kumar Jayanti Guest
Offline
Joined: 2011-04-02

On Nov 11, 2012, at 9:49 PM, forums@java.net wrote:

>

Kumar Jayanti Guest wrote:
On Nov 10, 2012, at 8:49 PM, forums@java.net
> wrote: Do you need to pass this string to the realm at Runtime or can you
> make it a configuration property for your realm ? >
I need to pass
> this string at runtime via some JSF selectOneMenu component for example
> otherwise, I would store this inside Realm as property but I can't.

https://blogs.oracle.com/enterprisetechtips/entry/adding_authentication_...

see if this helps.
>
> --
>
> [Message sent by forum member 'olivierJ']
>
> View Post: http://forums.java.net/node/892193
>
>

olivierJ
Offline
Joined: 2012-11-10

I already read this but I don't understand very well the goal of SAMs ?

Is it to collect infos on HTTP request before real login process occurs ?

If true, I don't see how to pass info between SAM and realm/LoginModule ?

Thanks for clarification

EDIT: should I populate Subject inside setAuthenticationResult() function with username, password ans string Principal ?

olivierJ
Offline
Joined: 2012-11-10

Should I use ProgrammaticLogin class to login with

public java.lang.Boolean login(String user, String password,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)

and pass previously inside HttpServletRequest.setAttribute() some attribute about dataBase to make DataSource name ?

Thanks a lot

olivierJ
Offline
Joined: 2012-11-10

No idea for my problem ?

To summarize I want implement a realm which authenticate users upon username/password AND some string.

How to do this please ?