equal
deleted
inserted
replaced
27 |
27 |
28 import java.net.URL; |
28 import java.net.URL; |
29 import java.net.URI; |
29 import java.net.URI; |
30 import java.net.URISyntaxException; |
30 import java.net.URISyntaxException; |
31 import java.net.PasswordAuthentication; |
31 import java.net.PasswordAuthentication; |
|
32 import java.io.IOException; |
|
33 import java.io.OutputStream; |
32 import sun.net.www.HeaderParser; |
34 import sun.net.www.HeaderParser; |
33 |
35 import sun.misc.BASE64Encoder; |
34 |
36 |
35 /** |
37 /** |
36 * BasicAuthentication: Encapsulate an http server authentication using |
38 * BasicAuthentication: Encapsulate an http server authentication using |
37 * the "basic" scheme. |
39 * the "basic" scheme. |
38 * |
40 * |
72 // concatenate user name and password bytes and encode them |
74 // concatenate user name and password bytes and encode them |
73 byte[] concat = new byte[nameBytes.length + passwdBytes.length]; |
75 byte[] concat = new byte[nameBytes.length + passwdBytes.length]; |
74 System.arraycopy(nameBytes, 0, concat, 0, nameBytes.length); |
76 System.arraycopy(nameBytes, 0, concat, 0, nameBytes.length); |
75 System.arraycopy(passwdBytes, 0, concat, nameBytes.length, |
77 System.arraycopy(passwdBytes, 0, concat, nameBytes.length, |
76 passwdBytes.length); |
78 passwdBytes.length); |
77 this.auth = "Basic " + (new sun.misc.BASE64Encoder()).encode(concat); |
79 this.auth = "Basic " + (new BasicBASE64Encoder()).encode(concat); |
78 this.pw = pw; |
80 this.pw = pw; |
79 } |
81 } |
80 |
82 |
81 /** |
83 /** |
82 * Create a BasicAuthentication |
84 * Create a BasicAuthentication |
112 // concatenate user name and password bytes and encode them |
114 // concatenate user name and password bytes and encode them |
113 byte[] concat = new byte[nameBytes.length + passwdBytes.length]; |
115 byte[] concat = new byte[nameBytes.length + passwdBytes.length]; |
114 System.arraycopy(nameBytes, 0, concat, 0, nameBytes.length); |
116 System.arraycopy(nameBytes, 0, concat, 0, nameBytes.length); |
115 System.arraycopy(passwdBytes, 0, concat, nameBytes.length, |
117 System.arraycopy(passwdBytes, 0, concat, nameBytes.length, |
116 passwdBytes.length); |
118 passwdBytes.length); |
117 this.auth = "Basic " + (new sun.misc.BASE64Encoder()).encode(concat); |
119 this.auth = "Basic " + (new BasicBASE64Encoder()).encode(concat); |
118 this.pw = pw; |
120 this.pw = pw; |
119 } |
121 } |
120 |
122 |
121 /** |
123 /** |
122 * Create a BasicAuthentication |
124 * Create a BasicAuthentication |
198 } |
200 } |
199 /*should not reach here. If we do simply return npath*/ |
201 /*should not reach here. If we do simply return npath*/ |
200 return npath; |
202 return npath; |
201 } |
203 } |
202 |
204 |
|
205 /* It is never expected that the header value will exceed the bytesPerLine */ |
|
206 private class BasicBASE64Encoder extends BASE64Encoder { |
|
207 @Override |
|
208 protected int bytesPerLine() { |
|
209 return (10000); |
|
210 } |
|
211 } |
203 } |
212 } |