home *** CD-ROM | disk | FTP | other *** search
- package sun.net.www.protocol.http;
-
- import java.net.PasswordAuthentication;
- import java.net.URL;
- import java.util.Arrays;
- import sun.misc.BASE64Encoder;
-
- class BasicAuthentication extends AuthenticationInfo {
- String auth;
-
- public BasicAuthentication(boolean var1, String var2, int var3, String var4, PasswordAuthentication var5) {
- super((char)(var1 ? 'p' : 's'), var2, var3, var4);
- String var6 = var5.getUserName() + ":";
- byte[] var7 = var6.getBytes();
- char[] var8 = var5.getPassword();
- byte[] var9 = new byte[var8.length];
-
- for(int var10 = 0; var10 < var8.length; ++var10) {
- var9[var10] = (byte)var8[var10];
- }
-
- byte[] var11 = new byte[var7.length + var9.length];
- System.arraycopy(var7, 0, var11, 0, var7.length);
- System.arraycopy(var9, 0, var11, var7.length, var9.length);
- this.auth = "Basic " + (new BASE64Encoder()).encode(var11);
- Arrays.fill(var8, ' ');
- Arrays.fill(var9, (byte)0);
- Arrays.fill(var11, (byte)0);
- }
-
- public BasicAuthentication(boolean var1, String var2, int var3, String var4, String var5) {
- super((char)(var1 ? 'p' : 's'), var2, var3, var4);
- this.auth = "Basic " + var5;
- }
-
- public BasicAuthentication(boolean var1, URL var2, String var3, PasswordAuthentication var4) {
- super((char)(var1 ? 'p' : 's'), var2, var3);
- String var5 = var4.getUserName() + ":";
- byte[] var6 = var5.getBytes();
- char[] var7 = var4.getPassword();
- byte[] var8 = new byte[var7.length];
-
- for(int var9 = 0; var9 < var7.length; ++var9) {
- var8[var9] = (byte)var7[var9];
- }
-
- byte[] var10 = new byte[var6.length + var8.length];
- System.arraycopy(var6, 0, var10, 0, var6.length);
- System.arraycopy(var8, 0, var10, var6.length, var8.length);
- this.auth = "Basic " + (new BASE64Encoder()).encode(var10);
- Arrays.fill(var7, ' ');
- Arrays.fill(var8, (byte)0);
- Arrays.fill(var10, (byte)0);
- }
-
- public BasicAuthentication(boolean var1, URL var2, String var3, String var4) {
- super((char)(var1 ? 'p' : 's'), var2, var3);
- this.auth = "Basic " + var4;
- }
-
- boolean supportsPreemptiveAuthorization() {
- return true;
- }
-
- String getHeaderName() {
- return super.type == 's' ? "Authorization" : "Proxy-authorization";
- }
-
- String getHeaderValue() {
- return this.auth;
- }
- }
-