- Timestamp:
- 2020-05-20T14:44:53+12:00 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/util/ServletRealmCheck.java
r32429 r34116 39 39 * to see if any of these allow the user to edit that collection. 40 40 * 41 * Run as java org.greenstone.gsdl3.util.ServletRealmCheck <GS 3SRCHOME> <un> <pwd> [colname]41 * Run as java org.greenstone.gsdl3.util.ServletRealmCheck <GSDL3HOME> <un> <pwd> [colname] 42 42 * 43 * GS3\src\java>"C:\Program Files\Java\jdk1.6.0_22\bin\java" 44 * -classpath "GS3\web\WEB-INF\lib\gsdl3.jar;GS3\web\WEB-INF\lib\derby.jar" 45 * org.greenstone.gsdl3.util.ServletRealmCheck "GS3" admin <pw> 2>&1 43 * >java -classpath "greenstone3\web\WEB-INF\lib\gsdl3.jar;greenstone3\web\WEB-INF\lib\gutil.jar" 44 * org.greenstone.gsdl3.util.ServletRealmCheck "greenstone3\web" <un> <pw> [colname] 2>&1 46 45 * 47 * Tries URL: http://hostname: 8383/greenstone3/library?a=s&sa=authenticated-ping&excerptid=gs_content&un=admin&pw=<pw>[&col=demo]46 * Tries URL: http://hostname:port/context/library?a=s&sa=authenticated-ping&excerptid=gs_content&un=<un>&pw=<pw>[&col=colname] 48 47 * The &excerptid=gs_content in the URL will return just the <div id="gs_content" /> part of the 49 48 * page that we're interested in. … … 51 50 * Result: either prints out an error message ("Authentication failed...") or a positive result, 52 51 * which is the user's groups. For the admin user example: administrator,all-collections-editor. 52 * If no collection is specified, will print the user groups. 53 * If a collection is specified, will only print user groups if the user has access to the collection. 53 54 * 54 55 */ … … 58 59 59 60 if (args.length < 3 || args.length > 4){ 60 System.out.println("Run with: <GSDL3 SRCHOME> <un> <pwd> [collection-name]");61 System.out.println("Run with: <GSDL3HOME> <un> <pwd> [collection-name]"); 61 62 System.exit(0); 62 63 } 63 64 64 String gsdl3 srchome = args[0];65 String gsdl3home = args[0]; 65 66 String username = args[1]; 66 67 String password = args[2]; … … 73 74 74 75 75 // Load the build.properties file, get the GS3 server URL and send authenticated-ping and print the return result76 // Load the global.properties file, get the GS3 server URL and send authenticated-ping and print the return result 76 77 77 78 //http://www.mkyong.com/java/java-properties-file-examples/ 78 Properties buildProps = new Properties();79 Properties globalProps = new Properties(); 79 80 InputStream input = null; 80 81 81 82 try { 82 File buildPropsFile = new File(gsdl3srchome, "build.properties");83 input = new FileInputStream( buildPropsFile);83 File globalPropsFile = new File(gsdl3home, "WEB-INF" +File.separatorChar+ "classes"+ File.separatorChar+"global.properties"); 84 input = new FileInputStream(globalPropsFile); 84 85 85 86 // load a properties file 86 buildProps.load(input);87 globalProps.load(input); 87 88 88 89 // get the property value and print it out 89 String servername = buildProps.getProperty("tomcat.server");90 ProtocolPortProperties protocolPortProps = new ProtocolPortProperties( buildProps); // can throw Exception90 String servername = globalProps.getProperty("tomcat.server"); 91 ProtocolPortProperties protocolPortProps = new ProtocolPortProperties(globalProps); // can throw Exception 91 92 String protocol = protocolPortProps.getProtocol(); 92 93 String port = protocolPortProps.getPort(); 93 94 int portNum = Integer.parseInt(port); 94 95 96 String context = globalProps.getProperty("tomcat.context"); 95 97 // Appending &excerptid=gs_content will get just the <div ... id="gs_content"/> from the final web page: 96 String urlSuffix = "/greenstone3/library?a=s&sa=authenticated-ping&excerptid=gs_content&un="+username+"&pw="+password; 98 // TODO dynamically get library name 99 String urlSuffix = "/"+context+"/library?a=s&sa=authenticated-ping&excerptid=gs_content&un="+username+"&pw="+password; 97 100 if(collection != null) { 98 101 urlSuffix = urlSuffix + "&col="+collection; … … 122 125 123 126 // Now we finally have what we actually want to print out for the caller to use 124 System.out.print(result ); // don't add newline to end127 System.out.print(result + ","); // don't add newline to end 125 128 126 129 } catch (Exception ex) { 127 System.err.println(" Got exception" + ex.getMessage());128 130 System.err.println("Authentication failed: Java error: " + ex.getMessage()); 131 ex.printStackTrace(); 129 132 } finally { 130 133 if (input != null) {
Note:
See TracChangeset
for help on using the changeset viewer.