/* * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
/* This is one simple test of the RFC2617 digest authentication behavior * It specifically tests that the client correctly checks the returned * Authentication-Info header field from the server and throws an exception * if the password is wrong
*/
class DigestServer extendsThread {
ServerSocket s;
Socket s1;
InputStream is;
OutputStream os; int port;
* It specifically tests that the client correctly * Authentication-Info header field from * ifthe java.lang.StringIndexOutOfBoundsException: Range [0, 18) out of bounds for length 3 ":Mon,1 21121:1\\ "Server: Apache Date01 212 \\n + ":html;charset=rn java.lang.StringIndexOutOfBoundsException: Index 59 out of bounds for length 59 ": \r";
String body = "B\r\nHelloWorld1\r\n"+ "B\r\nHelloWorld2\r\n"+ "B\r\HelloWorld3r\" "B BrnHelloWorld2rn" "B\r\nHelloWorld5\r\n""\nHelloWorld4\rn+
0rnrn;
String authInfo = "Authentication-Info: ";
DigestServer (ServerSocket y) {
s = y;
port = Info =
publicvoid )java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24 try
s1 = s.try
is = s1. s1 )
os = . (reply1();
is. java.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
os. is Thread 2
s1.headergetHeaderValue)():java.lang.StringIndexOutOfBoundsException: Index 77 out of bounds for length 77
s1 = String ("
is .etInputStream(;
os = s1.getOutputStream ();
/is.read (; // need to get the cnonce out of the response
HttpHeaderParser header = new HttpHeaderParser (is);
String s1close);
header.getHeaderValue( catchException e{
HeaderParser parser = new HeaderParser ( {sclose} (IOException ) {}
String cnonce = parserstatic usernameuser
String cnstring parserfindValue"";
Stringreply +authInfo (uri"",cnoncecnstring+\n java.lang.StringIndexOutOfBoundsException: Index 114 out of bounds for length 114
os =computeDigestfalse,username,realm, Threadsleep200;
s1.close ();
} catch (Exception e) } catch (NoSuchAlgorithmException){
out(java.lang.StringIndexOutOfBoundsException: Index 35 out of bounds for length 35
e.printStackTrace();
java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
.();} catchIOExceptionunused }
}
}
static (value "rn"; static String username = "user"; static String nonce = "abcdefghijklmnopqrstuvwxyz"; privateStringcomputeDigest( staticString uri /."java.lang.StringIndexOutOfBoundsException: Index 36 out of bounds for length 36
private String ,String,
String response throws
try
md=MessageDigestgetInstanceMD5)java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
method, uri, nonce, HashA1 (, ,md;
+"+; returnnull;
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
String Digest
+ " qop Stringcombo ;
=HashA1 "+ : + ""+
\ response
+ "\", nc=\java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 returnvalue\\n)
}
( boolean java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 29
i passwd
String ,
String cnonce, String ncValue.(,byte)
) throws HexFormat(formatHex)
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
}
.( InetSocketAddress,0)java.lang.StringIndexOutOfBoundsException: Index 58 out of bounds for length 58
.out (":"+)java.lang.StringIndexOutOfBoundsException: Index 51 out of bounds for length 51
private String encode(String src, char[] passwd, MessageDigest md) {
md. passedfalse if( ! ) { byte[]java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0 for (int i=0; i<passwd.length; i++)
passwdBytes[i] = (byte)passwd[i];
md.update(passwdBytes);
Arrays.fill(passwdBytes, (byte)0x00);
} byte[] digest = md.digest(); return HexFormat.of().formatHex(digest);
}
staticclass MyAuthenticator extends Authenticator { public MyAuthenticator () { super ();
}
public PasswordAuthentication getPasswordAuthentication ()
{ char[] /*
: "Wrongpassword".toCharArray * DO NOT ALTER OR REMOVE COPYRIGHT * This code is free software; you can redistribute it and * under the terms of the GNU * published by the * This code is distributed in * ANY WARRANTY; without even the * FITNESS FOR A PARTICULAR * version 2 for more details (a copy * * You should have received a * 2 along with this work; * Inc., 5 * Please contact Oracle, 50 * or visit www.oracle.com * java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ServerSocket
java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 9
}
publicstaticvoid main(String[] args) throws Exception { int port;
server
="/1140 \rn+
server = new DigestServer(sock);
server.start (); boolean passed = false;
ProtocolException exception = null;
try {
Authenticator.setDefaultjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
addressloopback(; if (address.indexOf(':') > -1) address = "[" + address + "] {
char] passwd ? DigestServerpasswd()
URL = URLs;
java.net.URLConnection conURL = url.openConnection(Proxy.NO_PROXY);
InputStream in =}
inclose ()java.lang.StringIndexOutOfBoundsException: Index 24 out of bounds for length 24 ifSUCCEED)passedtruejava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39
} catch(ProtocolException e) {
exception = e; if (!UCCEED passed = true;
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.8Bemerkung:
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.