@Nullable
  public static BasicAuthClientCredentials getBasicAuthClientCredentials (@Nullable final String sAuthHeader)
  {
    final String sRealHeader = StringHelper.trim (sAuthHeader);
    if (StringHelper.hasNoText (sRealHeader))
      return null;

    final String [] aElements = RegExHelper.getSplitToArray (sRealHeader, "\\s+", 2);
    if (aElements.length != 2)
    {
      if (LOGGER.isErrorEnabled ())
        LOGGER.error ("String is not Basic Auth: " + sRealHeader);
      return null;
    }

    if (!aElements[0].equals (HEADER_VALUE_PREFIX_BASIC))
    {
      if (LOGGER.isErrorEnabled ())
        LOGGER.error ("String does not start with 'Basic': " + sRealHeader);
      return null;
    }

    // Apply Base64 decoding
    final String sEncodedCredentials = aElements[1];
    final String sUsernamePassword = Base64.safeDecodeAsString (sEncodedCredentials, CHARSET);
    if (sUsernamePassword == null)
    {
      if (LOGGER.isErrorEnabled ())
        LOGGER.error ("Illegal Base64 encoded value '" + sEncodedCredentials + "'");
      return null;
    }

    // Do we have a username/password separator?
    final int nIndex = sUsernamePassword.indexOf (USERNAME_PASSWORD_SEPARATOR);
    if (nIndex >= 0)
      return new BasicAuthClientCredentials (sUsernamePassword.substring (0, nIndex),
                                             sUsernamePassword.substring (nIndex + 1));
    return new BasicAuthClientCredentials (sUsernamePassword);
  }
@ Nullable public static BasicAuthClientCredentials getBasicAuthClientCredentials ( @ Nullable final String sAuthHeader ) { final String sRealHeader = StringHelper . trim ( sAuthHeader ) ; if ( StringHelper . hasNoText ( sRealHeader ) ) return null ; final String [ ] aElements = RegExHelper . getSplitToArray ( sRealHeader , "\\s+" , 2 ) ; if ( aElements . length != 2 ) { if ( LOGGER . isErrorEnabled ( ) ) LOGGER . error ( "String is not Basic Auth: " + sRealHeader ) ; return null ; } if ( ! aElements [ 0 ] . equals ( HEADER_VALUE_PREFIX_BASIC ) ) { if ( LOGGER . isErrorEnabled ( ) ) LOGGER . error ( "String does not start with 'Basic': " + sRealHeader ) ; return null ; } final String sEncodedCredentials = aElements [ 1 ] ; final String sUsernamePassword = Base64 . safeDecodeAsString ( sEncodedCredentials , CHARSET ) ; if ( sUsernamePassword == null ) { if ( LOGGER . isErrorEnabled ( ) ) LOGGER . error ( "Illegal Base64 encoded value '" + sEncodedCredentials + "'" ) ; return null ; } final int nIndex = sUsernamePassword . indexOf ( USERNAME_PASSWORD_SEPARATOR ) ; if ( nIndex >= 0 ) return new BasicAuthClientCredentials ( sUsernamePassword . substring ( 0 , nIndex ) , sUsernamePassword . substring ( nIndex + 1 ) ) ; return new BasicAuthClientCredentials ( sUsernamePassword ) ; }
Get the Basic authentication credentials from the passed HTTP header value.

@param sAuthHeader
The HTTP header value to be interpreted. May be <code>null</code>.
@return <code>null</code> if the passed value is not a correct HTTP Basic
Authentication header value.