code: private String[] extractAndDecodeHeader(String header) throws IOException {
  
          byte[] base64Token = header.substring(6).getBytes(CREDENTIALS_CHARSET);
          byte[] decoded;
          try {
              decoded = Base64.decode(base64Token);
          } catch (IllegalArgumentException e) {
              throw new BadCredentialsException("Failed to decode basic authentication token");
          }
  
          String token = new String(decoded, CREDENTIALS_CHARSET);
  
          int delim = token.indexOf(":");
  
          if (delim == -1) {
              throw new BadCredentialsException("Invalid basic authentication token");
          }
          return new String[] {token.substring(0, delim), token.substring(delim + 1)};
      }
docs: Decodes the header into a username and password.
  
  @throws BadCredentialsException if the Basic header is not present or is not valid Base64