Skip to main content

Custom realm - why twice group object ?

Please note these forums are being decommissioned and use the new and improved forums at
No replies
Joined: 2013-08-21

Hello !

I am testing custom realm in glassfish and i am following "application -development-guide.pdf" from:
On page 48, the document explain that we must create 2 classes (derivated of AppservRealm and AppservPasswordLoginModule).

I don't understand why both in AppservPasswordLoginModule and AppservRealm we link user with group :


public class CustomLoginModule extends AppservPasswordLoginModule {

     * Perform actual authentication
    protected void authenticateUser() throws LoginException {
      "Passing in authenticateUser of CustomLoginModule");
        _logger.log(Level.INFO, "user: {0}", _username);
        _logger.log(Level.INFO, "password: {0}", _passwd); 
        // .......some other code

        // Final step
        String[] grpList = {"userGroup"};
        // populate grpList with the set of groups to which
        // _username belongs in this realm, if any

In the last part we populate group for current user, but in this case what are the use of : public Enumeration getGroupNames(String string) in AppservRealm class ?

public class CustomRealm extends AppservRealm {
     * This method returns an Enumeration (of String objects) enumerating the groups
     * (if any) to which the given username belongs in this realm.
    public Enumeration getGroupNames(String string) throws InvalidOperationException, NoSuchUserException {       
        List groupNames = new LinkedList();
        return (Enumeration) groupNames;       

Some code over internet have put "List groupNames = new LinkedList();" but i don't understand why..
Can someone can explain me the link between these two class (in terms of groups) ?