Changeset 38256


Ignore:
Timestamp:
2023-09-29T20:52:00+13:00 (7 months ago)
Author:
anupama
Message:

Untested. Committing changes for bypassing webswing authentication when already logged in to greenstone.

Location:
main/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/gli/src/org/greenstone/gatherer/Gatherer.java

    r37677 r38256  
    252252            Configuration.template_config_xml = Configuration.TEMPLATE_CONFIG_PREFIX +  Configuration.CONFIG_WEBSWING_XML;
    253253            Configuration.config_xml = Configuration.CONFIG_WEBSWING_XML;
     254
     255           
     256            if(go.userJSessionID != null) {
     257            webswingAuthenticator = new WebswingAuthenticator(go.username, go.usergroups, go.userJSessionID);
     258            }
    254259        }
    255260        else {     
     
    291296        }
    292297        // we need to authenticate the user
    293         webswingAuthenticator = new WebswingAuthenticator();
     298        //if(webswingAuthenticator == null || webswingAuthenticator.getUserName() == null) {
     299        if(webswingAuthenticator == null) {
     300            webswingAuthenticator = new WebswingAuthenticator();
     301        }
    294302        if (!webswingAuthenticator.authenticate(library_url_string)) {
    295303            System.err.println("Authentication error, quitting GLI");
    296304            System.exit(0);
    297305        }
    298 
     306       
    299307        String username = webswingAuthenticator.getUsername();
    300308
     
    21152123        static protected String username;
    21162124        static protected HashSet<String> groups;
     2125        static protected String userJSessionID;
     2126        static protected String rawgroups;
    21172127
    21182128        protected void displayError(String error_message) {
     
    21242134        }
    21252135
     2136        public WebswingAuthenticator() {}
     2137
     2138        public WebswingAuthenticator(String username, String usergroups, String sessionID) {
     2139        this.username = username;
     2140        this.rawgroups = usergroups;
     2141        this.userJSessionID = sessionID;
     2142        }
     2143
    21262144        public String getUsername() {
    21272145        return username;
     
    21302148
    21312149        public boolean authenticate(String library_url_string) {
     2150          if(username == null) {
    21322151        PasswordAuthentication pa = getPasswordAuthentication();
    21332152        if (pa == null) {
     
    21712190            return false;
    21722191        }
     2192          } else {
     2193          result = rawgroups;
     2194          }
    21732195        groups = new HashSet<String>();
    21742196        String[] contents = result.split(",");
     
    21822204            System.err.println("User not in any collection editing groups");
    21832205            displayError(Dictionary.get("WebswingAuthenticationError.NoPermissions"));
    2184             return false; // user has no editing priveleges
     2206            return false; // user has no editing privileges
    21852207        }
    21862208        return true;
  • main/trunk/gli/src/org/greenstone/gatherer/GetOpt.java

    r37188 r38256  
    5959
    6060    protected FedoraInfo fedora_info = null;
     61
     62    public String userJSessionID = null;
     63    public String username = null;
     64    public String usergroups = null;
    6165   
    6266    public GetOpt(String[] args)
     
    224228            no_load = false;
    225229            }
     230            // If logged in userdata specified: -username <user> -groups <grps> -uid JSESSIONID
     231            else if(argument_name.equals(StaticStrings.USERNAME_ARGUMENT)) {
     232            username = argument_value;
     233            }
     234            else if(argument_name.equals(StaticStrings.USERGROUPS_ARGUMENT)) {
     235            usergroups = argument_value;
     236            }
     237            else if(argument_name.equals(StaticStrings.USERID_ARGUMENT)) {
     238            userJSessionID = argument_value;
     239            }
    226240            // Parse the file path of the local library server
    227241            else if (argument_name.equals(StaticStrings.LOCAL_LIBRARY_ARGUMENT)) {
  • main/trunk/gli/src/org/greenstone/gatherer/util/StaticStrings.java

    r37677 r38256  
    288288    static final public String USE_METADATA_FILES_ARGUMENT = "use_metadata_files";
    289289    static final public String USE_REMOTE_GREENSTONE_ARGUMENT = "-use_remote_greenstone";
    290     static final public String WEBSWING_ARGUMENT = "-webswing";
     290    static final public String USERNAME_ARGUMENT = "-username";
     291    static final public String USERGROUPS_ARGUMENT = "-groups";
     292    static final public String USERID_ARGUMENT = "-uid";
     293    static final public String WEBSWING_ARGUMENT = "-webswing";   
    291294    static final public String URL_SEPARATOR_CHARACTER = "/";
    292295    static final public String VALUE_ATTRIBUTE = "value";
  • main/trunk/greenstone3/web/interfaces/default/js/javascript-global-functions.js

    r38238 r38256  
    616616}
    617617
     618
     619gs.funcions.getLoggedInUser = function()
     620{
     621    var baseURL = gs.xsltParams.library_name + "?a=g&rt=r&ro=1&s=CurrentUser&";
     622}
     623
    618624// Prepare the payload (data package) to transmit to metadataserver.pl over AJAX.
    619625// These next 2 functions prepare both the URL version of the payload and the data object version
  • main/trunk/greenstone3/web/interfaces/default/transform/javascript-global-setup.xsl

    r37805 r38256  
    161161            </script>
    162162        </xsl:if>
     163        <!-- check if we have a JSessionID and fill in any user details we haven't captured in JS vars yet as well as JSessionID -->
     164        <xsl:if test="/page/pageRequest/userContext/@uid">
     165          <script type="text/javascript">
     166            <xsl:text disable-output-escaping="yes">
     167              if (typeof gs.userInformation === "undefined") {
     168                gs.userInformation={};
     169            gs.userInformation.username = "</xsl:text><xsl:value-of select="/page/pageRequest/userContext/@username"/><xsl:text disable-output-escaping="yes">";
     170            gs.userInformation.groups = "</xsl:text><xsl:value-of select="/page/pageRequest/userContext/@groups"/><xsl:text disable-output-escaping="yes">";
     171              }
     172              gs.userInformation.uid = "</xsl:text><xsl:value-of select="/page/pageRequest/userContext/@uid"/><xsl:text disable-output-escaping="yes">";             
     173            </xsl:text>
     174          </script>
     175        </xsl:if>
    163176    </xsl:template>
    164177   
     
    167180        <script type="text/javascript" src="interfaces/{$interface_name}/js/GSMetadata.js"><xsl:text> </xsl:text></script>
    168181        <script type="text/javascript" src="interfaces/{$interface_name}/js/utility_scripts.js"><xsl:text> </xsl:text></script>
    169 
    170182    </xsl:template>
    171183</xsl:stylesheet>
  • main/trunk/greenstone3/web/interfaces/default/transform/pages/webswing-gli.xsl

    r37417 r38256  
    132132       webswingInstance0.options.args = "-load " + gs.cgiParams.c + "/gli.col";
    133133       }
     134       if(gs.userInformation.uid) {
     135         webswingInstance0.options.args = " -username " + gs.userInformation.username;
     136         webswingInstance0.options.args = " -groups " + gs.userInformation.groups.replace(/\s/g, '');
     137         webswingInstance0.options.args = " -uid " + gs.userInformation.uid;
     138       }
    134139    function getParam(name) {
    135140        name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
Note: See TracChangeset for help on using the changeset viewer.