📄 client.java
字号:
String k = (String)pnks.nextElement();
out.println (k+" = "+gpnr.names.get (k));
}
if (true) {
String[] n = new String[6];
n[0] = "InternetGatewayDevice.DeviceSummary";
n[1] = "InternetGatewayDevice.DeviceInfo.Manufacturer";
n[2] = "InternetGatewayDevice.DeviceInfo.ManufacturerOUI";
n[3] = "InternetGatewayDevice.IPPingDiagnostics.DiagnosticsState";
n[4] = "InternetGatewayDevice.IPPingDiagnostics.SuccessCount";
n[5] = "InternetGatewayDevice.DeviceInfo.ProductClass";
GetParameterValuesResponse values = null; //cpe.GetParameterValues(oui, sn, n);
if (values == null) {
out.println("No response .....");
}
Enumeration ve = values.values.keys();
out.println("-----------------------------------------------------------------");
while (ve.hasMoreElements()) {
String k = (String) ve.nextElement();
String v = (String) values.values.get(k);
out.println(k + "=" + v);
}
/*
Enumeration e = r.names.keys();
while (e.hasMoreElements()) {
String name = (String)e.nextElement();
out.println (name+"\t");
}
*/
out.println("-----------------------------------------------------------------");
GetRPCMethodsResponse methods = null; //cpe.GetRPCMethods(oui, sn);
if (methods == null) {
out.println("No response .....");
}
for (i = 0; i < methods.methods.length; i++) {
out.println(methods.methods[i]);
}
}
out.close();
}
private String username;
private String password;
private boolean passwordIsA1Hash;
public void postDigest(MessageDigest digest, Properties p)
{
username = "Mufasa";
password = "Circle Of Life";
username = "testuser";
password = "testpass";
passwordIsA1Hash = false;
String qop = (String) p.getProperty("qop");
String realm = (String) p.getProperty("realm");
String algorithm = (String) p.getProperty("algorithm");
String nonce = (String) p.getProperty("nonce");
String cnonce = (String) p.getProperty("cnonce");
String method = (String) p.getProperty("method");
String nc = (String) p.getProperty("nc");
String digestURI = (String) p.getProperty("uri");
/*
System.out.println ("qop "+qop);
System.out.println ("realm "+realm);
System.out.println ("nonce "+nonce);
System.out.println ("cnonce "+cnonce);
System.out.println ("method "+method);
System.out.println ("nc "+nc);
System.out.println ("uri "+digestURI);
*/
if( algorithm == null )
algorithm = digest.getAlgorithm();
digest.reset();
String hA1 = null;
// 3.2.2.2 A1
if (algorithm == null || algorithm.equals("MD5"))
{
if( passwordIsA1Hash )
hA1 = password;
else
{
String A1 = username + ":" + realm + ":" + password;
hA1 = H(A1, digest);
}
}
else if (algorithm.equals("MD5-sess"))
{
if( passwordIsA1Hash )
{
hA1 = password + ":" + nonce + ":" + cnonce;
}
else
{
String A1 = username + ":" + realm + ":" + password;
hA1 = H(A1, digest) + ":" + nonce + ":" + cnonce;
}
}
else
{
throw new IllegalArgumentException("Unsupported algorigthm: "+algorithm);
}
// 3.2.2.3 A2. First check to see if the A2 hash has been precomputed
String hA2 = null;//(String) info.getInfo(A2HASH);
if (hA2 == null)
{
// No, compute it based on qop
String A2 = null;
if (qop == null || qop.equals("auth"))
{
A2 = method + ":" + digestURI;
}
else
{
throw new IllegalArgumentException("Unsupported qop="+qop);
}
hA2 = H(A2, digest);
}
// 3.2.2.1 Request-Digest
if (qop == null)
{
String extra = nonce + ":" + hA2;
KD(hA1, extra, digest);
}
else if (qop.equals("auth"))
{
String extra = nonce +
":" + nc +
":" + cnonce +
":" + qop +
":" + hA2;
KD(hA1, extra, digest);
}
}
static private String H(String data, MessageDigest digest)
{
digest.reset();
byte[] x = digest.digest(data.getBytes());
return cvtHex(x);
}
private static char[] MD5_HEX = "0123456789abcdef".toCharArray();
static String cvtHex(byte[] data)
{
char[] hash = new char[32];
for (int i = 0; i < 16; i++)
{
int j = (data[i] >> 4) & 0xf;
hash[i * 2] = MD5_HEX[j];
j = data[i] & 0xf;
hash[i * 2 + 1] = MD5_HEX[j];
}
return new String(hash);
}
static private void KD(String secret, String data, MessageDigest digest)
{
String x = secret + ":" + data;
digest.reset();
digest.update(x.getBytes());
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/** Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/** Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/** Returns a short description of the servlet.
*/
public String getServletInfo() {
return "Short description";
}
// </editor-fold>
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -