Quantcast
Channel: GlassFish Related Items on Java.net
Viewing all articles
Browse latest Browse all 1091

Custom realm - why twice group object ?

$
0
0

Hello !

I am testing custom realm in glassfish and i am following "application -development-guide.pdf" from: https://glassfish.java.net/docs/4.0/application-development-guide.pdf
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 :

Ex:

public class CustomLoginModule extends AppservPasswordLoginModule {

    /*
     * Perform actual authentication
     */
    @Override
    protected void authenticateUser() throws LoginException {
        super.authenticateUser();
       
        _logger.info("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
        commitUserAuthentication(grpList);
    }
   
}

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.
     */           
    @Override
    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) ?

Regards


Viewing all articles
Browse latest Browse all 1091

Trending Articles