Changeset 32985 for main

Show
Ignore:
Timestamp:
05.04.2019 14:24:29 (7 months ago)
Author:
kjdon
Message:

mods to store new humanverify settings. in collectionConfig security element, set humanVerify=true to trigger the verify page. set useRecaptcha=true if you want a recaptcha on the verify page. The Authentication servicerack must be active in siteConfig, and recaptcha site and secret key elements must be present with valid keys.

Files:
1 modified

Legend:

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

    r32475 r32985  
    3333import org.apache.log4j.Logger; 
    3434import org.greenstone.gsdl3.core.ModuleInterface; 
     35import org.greenstone.gsdl3.service.Authentication; 
    3536import org.greenstone.gsdl3.util.CustomClassLoader; 
    3637import org.greenstone.gsdl3.util.Dictionary; 
     
    8081    /** Stores the scope of any security rules (either collection or document) */ 
    8182    protected boolean _securityScopeCollection = true; 
    82  
     83        protected boolean _humanVerify = false; 
     84        protected boolean _useRecaptcha = false; // for human verify 
     85        protected String _siteKey = null; // for recaptcha 
     86        protected String _secretKey = null; // for recaptcha 
     87   
    8388    protected HashMap<String, ArrayList<Element>> _documentSets = new HashMap<String, ArrayList<Element>>(); 
    8489    protected ArrayList<HashMap<String, ArrayList<String>>> _securityExceptions = new ArrayList<HashMap<String, ArrayList<String>>>(); 
    8590 
    8691    protected XMLTransformer transformer = null; 
    87     /** 
    88      * A class loader that knows about the collection resources directory can 
    89      * put properties files, dtds etc in here 
    90      */ 
    91     //CustomClassLoader class_loader = null; 
    9292 
    9393    /** same as setClusterName */ 
     
    339339        } 
    340340 
     341        String humanVerify = securityBlock.getAttribute("humanVerify"); 
     342        if (humanVerify.equals("true")) { 
     343          _humanVerify = true; 
     344        } 
     345 
     346        String useRecaptcha = securityBlock.getAttribute("useRecaptcha"); 
     347        if (useRecaptcha.equals("true")) { 
     348 
     349          Authentication authen_services =(Authentication) this.router.getModuleMap().get(Authentication.AUTHENTICATION_SERVICE); 
     350          if (authen_services != null) { 
     351            String siteKey = authen_services.getRecaptchaSiteKey(); 
     352            String secretKey = authen_services.getRecaptchaSecretKey(); 
     353 
     354            if (siteKey != null && secretKey != null) { 
     355              _useRecaptcha = true; 
     356              _siteKey = siteKey; 
     357              _secretKey = secretKey; 
     358            } 
     359          } 
     360        } 
    341361        if (scope.toLowerCase().equals("collection")) 
    342362        { 
     
    497517        response.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_SECURITY); 
    498518 
     519        if (_humanVerify) { 
     520          response.setAttribute("humanVerify", "true"); 
     521          if (_useRecaptcha) { 
     522            response.setAttribute("siteKey", _siteKey); 
     523            response.setAttribute("secretKey", _secretKey); 
     524          } 
     525        } 
    499526        String oid = request.getAttribute("oid"); 
    500527        if (oid.contains("."))