@Override
    public Optional<Credentials> extract(final CallContext ctx) {
        val optCredentials = this.extractor.extract(ctx);
        return optCredentials.map(cred -> {

            val credentials = (TokenCredentials) cred;
            final byte[] decoded;
            try {
                decoded = Base64.getDecoder().decode(credentials.getToken());
            } catch (IllegalArgumentException e) {
                throw new CredentialsException("Bad format of the basic auth header");
            }
            val token = new String(decoded, StandardCharsets.UTF_8);

            val delim = token.indexOf(':');
            if (delim < 0) {
                throw new CredentialsException("Bad format of the basic auth header");
            }
            val upc = new UsernamePasswordCredentials(token.substring(0, delim), token.substring(delim + 1));
            upc.setSource(CredentialSource.HEADER.name());
            return upc;
        });
    }
To extract basic auth header.

@author Jerome Leleu
@since 1.8.0
pac4j-core/src/main/java/org/pac4j/core/credentials/extractor/BasicAuthExtractor.java