class EndpointAuthenticationFilter implements ContainerRequestFilter {

    @Override public void filter(ContainerRequestContext containerRequestContext) throws IOException {

        ParametersChecker
            .checkParameter("VitamAuthentication failed! The service needs user authentication.",
                containerRequestContext.getHeaders().get(HttpHeaders.AUTHORIZATION));

        // decode the authentication informations
        MultivaluedMap<String, String> headers = containerRequestContext.getHeaders();
        String authorization = headers.get(HttpHeaders.AUTHORIZATION).iterator().next();
        if (!authorization.startsWith(BASIC)) {
            throw new IllegalArgumentException(
                "VitamAuthentication failed: VitamAuthentication informations are missing.");
        }
        String decodedAuthent = "";
        String[] credentials = authorization.split("\\s");

        if (credentials.length != 2) {
            throw new IllegalArgumentException(
                "VitamAuthentication failed: VitamAuthentication informations are missing.");
        }

        byte[] bytes = Base64.getDecoder().decode(credentials[1]);
        decodedAuthent = new String(bytes);

        // validate the authentication information with the Vitam configuration.
        List<String> decodedAuthentgInfos = Arrays.asList(decodedAuthent.split(":"));
        List<BasicAuthModel> basicAuthConfig = configuration.getAdminBasicAuth();
        if (decodedAuthentgInfos.isEmpty() || (basicAuthConfig != null &&
            (!basicAuthConfig.get(0).getUserName().equals(decodedAuthentgInfos.get(0)) ||
                !basicAuthConfig.get(0).getPassword()
                    .equals(decodedAuthentgInfos.get(1))))) {
            throw new IllegalArgumentException("VitamAuthentication failed: Wrong credentials.");

        }
    }

    public  EndpointAuthenticationFilter(AuthenticationLevel authentLevel,
        DefaultVitamApplicationConfiguration configuration);

}