Changeset 27074

Show
Ignore:
Timestamp:
13.03.2013 14:12:37 (7 years ago)
Author:
sjm84
Message:

The top level usercontext now includes the groups that the user is in

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/LibraryServlet.java

    r27073 r27074  
    452452        userContext.setUserID(uid); 
    453453 
     454        if (request.getAuthType() != null) 
     455        { 
     456            //Get the groups for the user 
     457            Element acquireGroupMessage = this.doc.createElement(GSXML.MESSAGE_ELEM); 
     458            Element acquireGroupRequest = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, "GetUserInformation", userContext); 
     459            acquireGroupMessage.appendChild(acquireGroupRequest); 
     460 
     461            Element paramList = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
     462            acquireGroupRequest.appendChild(paramList); 
     463            paramList.appendChild(GSXML.createParameter(this.doc, "username", request.getUserPrincipal().getName())); 
     464 
     465            Element aquireGroupsResponseMessage = (Element) this.recept.process(acquireGroupMessage); 
     466            Element aquireGroupsResponse = (Element) GSXML.getChildByTagName(aquireGroupsResponseMessage, GSXML.RESPONSE_ELEM); 
     467            Element param_list = (Element) GSXML.getChildByTagName(aquireGroupsResponse, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER); 
     468 
     469            if (param_list != null) 
     470            { 
     471                HashMap<String, Serializable> params = GSXML.extractParams(param_list, false); 
     472                String groups = (String) params.get("groups"); 
     473                userContext.setGroups(groups.split(",")); 
     474            } 
     475        } 
     476 
    454477        // set the lang in the session 
    455478        session.setAttribute(GSParams.LANGUAGE, lang);