morristech
5/22/2019 - 5:41 AM

Java_decompiled_Credentials.java

// JAVA DECOMPILED
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package okhttp3;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import okio.ByteString;

public final class Credentials {
  private Credentials() {
  }

  public static String basic(String username, String password) {
    return basic(username, password, StandardCharsets.ISO_8859_1);
  }

  public static String basic(String username, String password, Charset charset) {
    String usernameAndPassword = username + ":" + password;
    String encoded = ByteString.encodeString(usernameAndPassword, charset).base64();
    return "Basic " + encoded;
  }
}
// JAVA SOURCE

/*
 * Copyright (C) 2014 Square, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package okhttp3;

import java.nio.charset.Charset;
import okio.ByteString;

import static java.nio.charset.StandardCharsets.ISO_8859_1;

/** Factory for HTTP authorization credentials. */
public final class Credentials {
  private Credentials() {
  }

  /** Returns an auth credential for the Basic scheme. */
  public static String basic(String username, String password) {
    return basic(username, password, ISO_8859_1);
  }

  public static String basic(String username, String password, Charset charset) {
    String usernameAndPassword = username + ":" + password;
    String encoded = ByteString.encodeString(usernameAndPassword, charset).base64();
    return "Basic " + encoded;
  }
}
// KOTLIN DECOMPILED
package okhttp3;

import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import kotlin.Metadata;
import kotlin.jvm.JvmOverloads;
import kotlin.jvm.JvmStatic;
import kotlin.jvm.internal.Intrinsics;
import okio.ByteString;
import org.jetbrains.annotations.NotNull;

@Metadata(
   mv = {1, 1, 15},
   bv = {1, 0, 3},
   k = 1,
   d1 = {"\u0000\u001a\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\bÆ\u0002\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\"\u0010\u0003\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u00042\u0006\u0010\u0006\u001a\u00020\u00042\b\b\u0002\u0010\u0007\u001a\u00020\bH\u0007¨\u0006\t"},
   d2 = {"Lokhttp3/Credentials;", "", "()V", "basic", "", "username", "password", "charset", "Ljava/nio/charset/Charset;", "okhttp"}
)
public final class Credentials {
   public static final Credentials INSTANCE;

   @JvmStatic
   @JvmOverloads
   @NotNull
   public static final String basic(@NotNull String username, @NotNull String password, @NotNull Charset charset) {
      Intrinsics.checkParameterIsNotNull(username, "username");
      Intrinsics.checkParameterIsNotNull(password, "password");
      Intrinsics.checkParameterIsNotNull(charset, "charset");
      String usernameAndPassword = username + ':' + password;
      String encoded = ByteString.Companion.encodeString(usernameAndPassword, charset).base64();
      return "Basic " + encoded;
   }

   // $FF: synthetic method
   @JvmStatic
   @JvmOverloads
   @NotNull
   public static String basic$default(String var0, String var1, Charset var2, int var3, Object var4) {
      if ((var3 & 4) != 0) {
         Charset var10000 = StandardCharsets.ISO_8859_1;
         Intrinsics.checkExpressionValueIsNotNull(var10000, "ISO_8859_1");
         var2 = var10000;
      }

      return basic(var0, var1, var2);
   }

   @JvmStatic
   @JvmOverloads
   @NotNull
   public static final String basic(@NotNull String username, @NotNull String password) {
      return basic$default(username, password, (Charset)null, 4, (Object)null);
   }

   private Credentials() {
   }

   static {
      Credentials var0 = new Credentials();
      INSTANCE = var0;
   }
}
// KOTLIN SOURCE

/*
 * Copyright (C) 2014 Square, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package okhttp3

import okio.ByteString.Companion.encode
import java.nio.charset.Charset
import java.nio.charset.StandardCharsets.ISO_8859_1

/** Factory for HTTP authorization credentials. */
object Credentials {
  /** Returns an auth credential for the Basic scheme. */
  @JvmStatic @JvmOverloads fun basic(
    username: String,
    password: String,
    charset: Charset = ISO_8859_1
  ): String {
    val usernameAndPassword = "$username:$password"
    val encoded = usernameAndPassword.encode(charset).base64()
    return "Basic $encoded"
  }
}