/usr/share/doc/libjcifs-java-doc/examples/NtlmHttpClient.java is in libjcifs-java-doc 1.3.17-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | import java.io.*;
import java.net.*;
import jcifs.*;
public class NtlmHttpClient {
public static void main(String[] args) throws Exception {
// Normally set this outside application.
// Note that as a side effect due to the way handlers are located,
// you can also achieve this by simply doing:
Config.registerSmbURLHandler();
// which we already do to register the smb handler.
//String pkgs = System.getProperty("java.protocol.handler.pkgs");
//pkgs = (pkgs != null) ? "jcifs|" + pkgs : "jcifs";
//System.setProperty("java.protocol.handler.pkgs", pkgs);
//
if (args == null || args.length < 4) {
System.out.println("NtlmHttpClient <url> <domain> <user> <password>");
System.exit(1);
}
String location = args[0];
String domain = args[1];
String user = args[2];
String password = args[3];
// can also specify these in the URL, i.e.
// http://DOMAIN%5cuser:password@host/dir/file.html
// which will override these properties
Config.setProperty("jcifs.smb.client.domain", domain);
Config.setProperty("jcifs.smb.client.username", user);
Config.setProperty("jcifs.smb.client.password", password);
try {
Config.setProperty("jcifs.netbios.hostname",
Config.getProperty("jcifs.netbios.hostname",
InetAddress.getLocalHost().getHostName()));
} catch (Exception ex) { }
URL url = new URL(location);
BufferedReader reader = new BufferedReader(
new InputStreamReader(url.openStream()));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
}
}
|