Print this page
Split |
Close |
Expand all |
Collapse all |
--- old/src/windows/classes/sun/net/www/protocol/http/NTLMAuthSequence.java
+++ new/src/windows/classes/sun/net/www/protocol/http/ntlm/NTLMAuthSequence.java
1 1 /*
2 2 * Copyright 2002 Sun Microsystems, Inc. All Rights Reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation. Sun designates this
8 8 * particular file as subject to the "Classpath" exception as provided
9 9 * by Sun in the LICENSE file that accompanied this code.
10 10 *
11 11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 14 * version 2 for more details (a copy is included in the LICENSE file that
15 15 * accompanied this code).
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
16 16 *
17 17 * You should have received a copy of the GNU General Public License version
18 18 * 2 along with this work; if not, write to the Free Software Foundation,
19 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 20 *
21 21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 23 * have any questions.
24 24 */
25 25
26 -package sun.net.www.protocol.http;
26 +package sun.net.www.protocol.http.ntlm;
27 27
28 28 import java.io.IOException;
29 29 import sun.misc.BASE64Encoder;
30 30 import sun.misc.BASE64Decoder;
31 31
32 32 /*
33 33 * Hooks into Windows implementation of NTLM.
34 34 * This class will be replaced if a cross-platform version of NTLM
35 35 * is implemented in the future.
36 36 */
37 37
38 38 public class NTLMAuthSequence {
39 39
40 40 private String username;
41 41 private String password;
42 42 private String ntdomain;
43 43 private int state;
44 44 private long crdHandle;
45 45 private long ctxHandle;
46 46
47 47 static {
48 48 initFirst();
49 49 }
50 50
51 51 NTLMAuthSequence (String username, String password, String ntdomain)
52 52 throws IOException
53 53 {
54 54 this.username = username;
55 55 this.password = password;
56 56 this.ntdomain = ntdomain;
57 57 state = 0;
58 58 crdHandle = getCredentialsHandle (username, ntdomain, password);
59 59 if (crdHandle == 0) {
60 60 throw new IOException ("could not get credentials handle");
61 61 }
62 62 }
63 63
64 64 public String getAuthHeader (String token) throws IOException {
65 65 byte[] input = null;
66 66 if (token != null)
67 67 input = (new BASE64Decoder()).decodeBuffer(token);
68 68 byte[] b = getNextToken (crdHandle, input);
69 69 if (b == null)
70 70 throw new IOException ("Internal authentication error");
71 71 return (new B64Encoder()).encode (b);
72 72 }
73 73
74 74 private native static void initFirst ();
75 75
76 76 private native long getCredentialsHandle (String user, String domain, String password);
77 77
78 78 private native byte[] getNextToken (long crdHandle, byte[] lastToken);
79 79 }
80 80
81 81 class B64Encoder extends BASE64Encoder {
82 82 protected int bytesPerLine () {
83 83 return 1024;
84 84 }
85 85 }
↓ open down ↓ |
49 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX