Changeset 37390
- Timestamp:
- 2023-03-02T23:05:36+13:00 (3 weeks ago)
- Location:
- main/trunk/greenstone3/src/java/org/greenstone/gsdl3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/GoogleSigninJDBCRealm.java
r36023 r37390 169 169 170 170 //containerLog.debug("**** GoogleSigninJDBCRealm::initGoogleIdTokenVerifier():" + googlesignin_client_id); 171 System.err.println("**** GoogleSigninJDBCRealm::initGoogleIdTokenVerifier() googlesignin_client_id=" + googlesignin_client_id);171 //System.err.println("**** GoogleSigninJDBCRealm::initGoogleIdTokenVerifier() googlesignin_client_id=" + googlesignin_client_id); 172 172 //GoogleSigninJDBCRealm.googlesignin_client_id = googlesignin_client_id; 173 173 … … 326 326 public String getGreenstoneUsernameFromGoogleTokenId(String googlesignin_id_token) 327 327 { 328 System.err.println("**** GoogleSigninJDBCRealm::getGreenstoneUsernameFromGoogleTokenId():" + googlesignin_id_token);328 //System.err.println("**** GoogleSigninJDBCRealm::getGreenstoneUsernameFromGoogleTokenId():" + googlesignin_id_token); 329 329 330 330 String greenstone_username = null; … … 371 371 } 372 372 else { 373 System.err.println(" *****No googlesignin_id_token detected. No Google Signin check to do");373 System.err.println("No googlesignin_id_token detected. No Google Signin check to do"); 374 374 } 375 375 376 System.err.println("***** End of getGoogleSinginInfo()");376 //System.err.println("***** End of getGoogleSinginInfo()"); 377 377 378 378 return greenstone_username; … … 384 384 public Principal authenticate(String username, String credentials) 385 385 { 386 //System.err.println("**** in GogleSigninJDBCRealm::authenticte()"); 387 //System.err.println(" username = " + username); 388 //System.err.println(" credentials = " + credentials); 389 386 390 Principal principal = null; 387 391 -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/LibraryServlet.java
r37136 r37390 552 552 userContext.setUserID(uid); 553 553 554 // If GoogleSignin is operational (due to googlesignin_client_id specified in servlet.xml) 555 // AND a Google Client ID Token is provided via googlesignin_id_token then 556 // initiate authentication via Google Signin, which is then tied into Greenstone3 through 557 // the customized Realm written for Greenstone3. 558 // 559 // This customized Realm, GoogleSigninJDBCRealm, works by overriding 'authenticate()' 560 // in Realm. 561 562 // 1. If the username 'googlesign' is provided, then the credentials 563 // passed in needs to be a valid verifyable Google Client Id Token. 564 // 1a. From this verified token, the email address that is registered with 565 // Google for that user account is then used to find a match in the 566 // Greenstone3 JDBC-specified Username table. 567 // 1b. Assuming that an email address match is found, then the customized Realm 568 // completes the authentication process by making the found username, the 569 // one that is autheticated. 570 // 2. If the username is anything but 'googlesignin' then the authentication process 571 // continues as with the regular JDBCRealm process 572 573 //String googlesignin_id_token = getFirstParam("googlesignin_id_token",queryMap); 574 //if ((googlesignin_id_token != null) && (!googlesignin_id_token.equals(""))) { 575 576 String googleidentity_signin = getFirstParam(GSParams.GOOGLE_SIGNIN,queryMap); 577 if ((googleidentity_signin != null) && (googleidentity_signin.equals("1"))) { 578 queryMap.put(GSParams.USERNAME, new String[] { GoogleSigninJDBCRealm.GOOGLESIGNIN_USERNAME_BRIDGE }); 579 580 String googlesignin_credential = getFirstParam("credential",queryMap); 581 queryMap.put(GSParams.PASSWORD, new String[] { googlesignin_credential }); 582 // logger.info("**** googlesignin_credenital (aka id_token) = '" + googlesignin_credential +"'"); 583 } 584 585 554 586 if (!processLoginChanges(request, userContext, out, baseURL, queryMap, lang, output)) { 555 587 // any invalid login attempt will redirect to a new login page and return false … … 813 845 else 814 846 { 815 Element param = msg_doc.createElement(GSXML.PARAM_ELEM); 816 param.setAttribute(GSXML.NAME_ATT, name); 817 param.setAttribute(GSXML.VALUE_ATT, GSXML.xmlSafe(value)); 818 if (this.gs_params.isSensitive(name)) { 819 param.setAttribute(GSXML.SENSITIVE_ATT, "true"); 820 } 821 xml_param_list.appendChild(param); 847 // If logging out as the very next step after logging in, then 848 // the 'password' param was found to be null 849 // 850 // This then causes GSXML.xsmSafe(value) to throw an exception 851 // For now, the coding decision is to test for null, and skip 852 // adding the param if it is null 853 // 854 // Could be that it is more meaningful to store the values as 855 // the empty string. In which case updating GSXML.xsmlSafe to 856 // test for null and treat it as an empty string would be 857 // a better way to go 858 859 if (value != null) { 860 Element param = msg_doc.createElement(GSXML.PARAM_ELEM); 861 param.setAttribute(GSXML.NAME_ATT, name); 862 param.setAttribute(GSXML.VALUE_ATT, GSXML.xmlSafe(value)); 863 if (this.gs_params.isSensitive(name)) { 864 param.setAttribute(GSXML.SENSITIVE_ATT, "true"); 865 } 866 xml_param_list.appendChild(param); 867 } 822 868 823 869 } … … 896 942 xml_request.setAttribute("baseURL", baseURL); 897 943 898 //logger.error("about to process this message");899 // 944 // logger.error("about to process this message"); 945 // logger.error(XMLConverter.getPrettyString(xml_message)); 900 946 Node xml_result = this.recept.process(xml_message); 901 947 encodeURLs(xml_result, response); … … 1031 1077 1032 1078 private boolean processLoginChanges(HttpServletRequest request, UserContext userContext, PrintWriter out, String baseURL, Map<String, String[]> queryMap, String lang, String output) throws ServletException { 1033 1079 1080 //logger.info("Start of LibraryServlet::processLoginChanges()"); 1081 1034 1082 //Check if we need to login or logout 1035 1083 String username = getFirstParam(GSParams.USERNAME, queryMap); … … 1039 1087 if (logout != null) 1040 1088 { 1089 //logger.info("LibraryServlet::processLoginChanges() logging out (logout cgi param non-null)"); 1041 1090 request.logout(); 1042 1091 } … … 1044 1093 if (username != null && password != null) 1045 1094 { 1095 //logger.info("LibrarySerlvet::processLoginChagnes(): username and password not null"); 1096 1046 1097 //We are changing to another user, so log out first 1047 1098 if (request.getAuthType() != null) 1048 1099 { 1100 //logger.info("Logging out (preparing to change to another user) "); 1049 1101 request.logout(); 1050 1102 } … … 1053 1105 try 1054 1106 { 1055 //Try a global login first 1056 password = Authentication.hashPassword(password); 1107 //Try a global login first, and then go on to site-login if throws exception 1108 if (!username.equals(GoogleSigninJDBCRealm.GOOGLESIGNIN_USERNAME_BRIDGE)) { 1109 // Hashing password used by a direct to Greenstone3 authentication text, 1110 // but not when a Google Signin 1111 password = Authentication.hashPassword(password); 1112 } 1113 1057 1114 request.login(username, password); 1115 //logger.info("Global Login successful"); 1058 1116 } 1059 1117 catch (Exception ex) … … 1063 1121 //If the global login fails then try a site-level login 1064 1122 String siteName = (String) this.recept.getConfigParams().get(GSConstants.SITE_NAME); 1065 request.login(siteName + "-" + username, password); 1066 1123 String siteUserName = siteName + "-" + username; 1124 //logger.info("Global login unsuccessful, trying site-level login with: " + siteUserName); 1125 request.login(siteUserName, password); 1126 //logger.info("Site-wide login successful"); 1067 1127 } 1068 1128 catch (Exception exc) 1069 1129 { 1130 //logger.info("Site-wide login unsuccessful => generating login page"); 1131 1070 1132 //The user entered in either the wrong username or the wrong password 1071 1133 … … 1091 1153 private void updateUserContextWithAuthenticatedInfo(HttpServletRequest request, UserContext userContext) 1092 1154 { 1155 //logger.info("Start of updateUserContextWithAutenticatedInfo"); 1093 1156 1094 1157 //Get the username 1095 1158 String user_name = request.getUserPrincipal().getName(); 1159 //logger.info(" getUserPrincipal user_name = " + user_name); 1160 1096 1161 userContext.setUsername(user_name); 1097 1162 … … 1242 1307 private boolean runCollectionSecurityCheck(HttpServletRequest request, UserContext userContext, PrintWriter out, String baseURL, String collection, String document, String lang, String output) { 1243 1308 1309 // logger.info("LibraryServlet::runCollectionSecurityCheck(): start of check for collection:"+collection); 1310 1244 1311 //Get the security info for this collection 1245 1312 Document msg_doc = XMLConverter.newDOM(); -
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/GSParams.java
r37097 r37390 75 75 76 76 //Administration 77 public static final String PASSWORD = "password"; 78 public static final String USERNAME = "username"; 79 public static final String LOGOUT = "logout"; 80 public static final String VERIFIED = "hmvf"; 77 public static final String PASSWORD = "password"; 78 public static final String USERNAME = "username"; 79 public static final String GOOGLE_SIGNIN = "googleidentity-signin"; 80 public static final String LOGOUT = "logout"; 81 public static final String VERIFIED = "hmvf"; 81 82 82 83 // some standard arg values
Note:
See TracChangeset
for help on using the changeset viewer.