bundles/org.eclipse.packagedrone.web/src/org/eclipse/packagedrone/web/util/BasicAuthentication.java
public static String[] parseAuthorization ( final HttpServletRequest request )
    {
        final String auth = request.getHeader ( "Authorization" );
        logger.debug ( "Auth header: {}", auth );

        if ( auth == null || auth.isEmpty () )
        {
            return null;
        }

        final String[] toks = auth.split ( "\\s" );
        if ( toks.length < 2 )
        {
            return null;
        }

        if ( !"Basic".equalsIgnoreCase ( toks[0] ) )
        {
            return null;
        }

        final byte[] authData = Base64.getDecoder ().decode ( toks[1] );
        final String authStr = StandardCharsets.ISO_8859_1.decode ( ByteBuffer.wrap ( authData ) ).toString ();

        logger.debug ( "Auth String: {}", authStr );

        final String[] authToks = authStr.split ( ":", 2 );

        logger.debug ( "Auth tokens: {}", new Object[] { authToks } );

        if ( authToks.length != 2 )
        {
            return null;
        }

        return authToks;
    }
public static String[] parseAuthorization ( final HttpServletRequest request )
    {
        final String auth = request.getHeader ( "Authorization" );
        logger.debug ( "Auth header: {}", auth );

        if ( auth == null || auth.isEmpty () )
        {
            return null;
        }

        final String[] toks = auth.split ( "\\s" );
        if ( toks.length < 2 )
        {
            return null;
        }

        if ( !"Basic".equalsIgnoreCase ( toks[0] ) )
        {
            return null;
        }

        final byte[] authData = Base64.getDecoder ().decode ( toks[1] );
        final String authStr = StandardCharsets.ISO_8859_1.decode ( ByteBuffer.wrap ( authData ) ).toString ();

        logger.debug ( "Auth String: {}", authStr );

        final String[] authToks = authStr.split ( ":", 2 );

        logger.debug ( "Auth tokens: {}", new Object[] { authToks } );

        if ( authToks.length != 2 )
        {
            return null;
        }

        return authToks;
    }
Parse the basic authentication header

@param request
the request to fetch the header from
@return either <code>null</code> if no valid header entry was found, or a
string array with exactly two entries (username, password)