Ignore:
Timestamp:
2012-02-21T16:26:17+13:00 (12 years ago)
Author:
sjm84
Message:

Second round of changes adding in the login ability, also interface options are now returned whenever site metadata is returned

File:
1 edited

Legend:

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

    r25092 r25128  
    1414import javax.servlet.http.*;
    1515
    16 import java.security.Principal;
    1716import java.util.Collection;
    1817import java.util.Enumeration;
     
    9998     */
    10099    protected Hashtable session_ids_table = new Hashtable();
    101    
     100
    102101    /**
    103102     * the maximum interval that the cached info remains in session_ids_table
     
    722721            request.login(username[0], password[0]);
    723722        }
    724        
    725         if(request.getAuthType() != null)
     723
     724        if (request.getAuthType() != null)
    726725        {
    727726            Element userInformation = this.doc.createElement("userInformation");
    728727            xml_request.appendChild(userInformation);
    729728            userInformation.setAttribute("username", request.getUserPrincipal().getName());
    730         }
    731            
     729
     730            Element userInfoMessage = this.doc.createElement(GSXML.MESSAGE_ELEM);
     731            Element userInfoRequest = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_SECURITY, "GetUserInformation", userContext);
     732            userInfoMessage.appendChild(userInfoRequest);
     733
     734            Element paramList = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     735            userInfoRequest.appendChild(paramList);
     736
     737            Element param = this.doc.createElement(GSXML.PARAM_ELEM);
     738            param.setAttribute(GSXML.NAME_ATT, "username");
     739            param.setAttribute(GSXML.VALUE_ATT, request.getUserPrincipal().getName());
     740            paramList.appendChild(param);
     741
     742            Element userInformationResponse = (Element) GSXML.getChildByTagName(this.recept.process(userInfoMessage), GSXML.RESPONSE_ELEM);
     743            Element responseParamList = (Element) GSXML.getChildByTagName(userInformationResponse, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
     744            if (responseParamList == null)
     745            {
     746                logger.error("Can't get the groups for user " + request.getUserPrincipal().getName());
     747            }
     748
     749            HashMap responseParams = GSXML.extractParams(responseParamList, true);
     750            String groups = (String) responseParams.get("groups");
     751
     752            userInformation.setAttribute("groups", groups);
     753        }
    732754
    733755        //If we are in a collection-related page then make sure this user is allowed to access it
     
    771793                    Element paramList = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
    772794                    loginPageRequest.appendChild(paramList);
    773                    
     795
    774796                    Element messageParam = this.doc.createElement(GSXML.PARAM_ELEM);
    775797                    messageParam.setAttribute(GSXML.NAME_ATT, "loginMessage");
    776                     if(request.getAuthType() == null)
     798                    if (request.getAuthType() == null)
    777799                    {
    778800                        messageParam.setAttribute(GSXML.VALUE_ATT, "Please log in to view this page");
     
    780802                    else
    781803                    {
    782                         messageParam.setAttribute(GSXML.VALUE_ATT, "You are not in the correct group to view this page");
     804                        messageParam.setAttribute(GSXML.VALUE_ATT, "You are not in the correct group to view this page, would you like to log in as a different user?");
    783805                    }
    784806                    paramList.appendChild(messageParam);
    785                    
     807
    786808                    Element urlParam = this.doc.createElement(GSXML.PARAM_ELEM);
    787809                    urlParam.setAttribute(GSXML.NAME_ATT, "redirectURL");
Note: See TracChangeset for help on using the changeset viewer.