code: public static BasicCredentials parse(String input)
      {
          if (input == null)
          {
              return null;
          }
  
          Matcher matcher = CHALLENGE_PATTERN.matcher(input);
  
          if (matcher.matches() == false)
          {
              return new BasicCredentials(null, null);
          }
  
          // "userid:password" encoded in Base64.
          String encoded = matcher.group(1);
  
          // Decode the base64 string.
          byte[] decoded = Base64.decodeBase64(encoded);
  
          // Convert the byte array to String.
          String value = createString(decoded);
  
          // Split "userid:password" into "userid" and "password".
          String[] credentials = value.split(":", 2);
  
          // User ID and Password.
          String userId   = null;
          String password = null;
  
          switch (credentials.length)
          {
              case 2:
                  // Password
                  password = credentials[1];
                  // FALLTHROUGH
  
              case 1:
                  // User ID
                  userId = credentials[0];
          }
  
          return new BasicCredentials(userId, password);
      }
docs: Parse {@code Authorization} header for Basic authentication.
  
  @param input
  The value of {@code Authorization} header. Expected inputs
  are either <code>"Basic <i>{Base64-Encoded-UserID-and-Password}</i>"</code>,
  or <code>"<i>{Base64-Encoded-UserID-and-Password}</i>"</code>.
  
  @return
  Parsed credentials. If {@code input} is {@code null} is returned.