package com.commercetools.sunrise.common.httpauth.basic;

import com.commercetools.sunrise.common.httpauth.HttpAuthentication;
import io.sphere.sdk.models.Base;

import javax.annotation.Nullable;
import java.util.Base64;

/**
 * Enables HTTP Basic Access Authentication.
 */
final class BasicHttpAuthentication extends Base implements HttpAuthentication {

    @Nullable
    private final String realm;
    @Nullable
    private final String encodedCredentials;

    BasicHttpAuthentication() {
        System.err.println("!!!!! CREATE EMPTY INSTANCE !!!!!!");
        this.realm = null;
        this.encodedCredentials = null;
    }

    BasicHttpAuthentication(final String realm, final String credentials) {
        System.err.println("!!!!! CREATE INSTANCE !!!!!!");
        this.realm = realm;
        this.encodedCredentials = Base64.getEncoder().encodeToString(credentials.getBytes());
    }

    @Override
    public boolean isEnabled() {
        return encodedCredentials != null;
    }

    @Override
    public String getWwwAuthenticateHeader() {
        return "Basic realm=\"" + realm + "\"";
    }

    /**
     * Decides whether the HTTP Authorization complies with a Basic HTTP Authorization Header and contains the correct
     * credentials, i.e. it is equal to "Basic username:password", where "username:password" is encoded in Base64 scheme.
     * @param rawAuthorizationHttpHeader the contents of the HTTP Authorization header
     * @return true if the HTTP Authorization Header is valid and contains the correct credentials, false otherwise
     */
    @Override
    public boolean isAuthorized(final String rawAuthorizationHttpHeader) {
        if (isEnabled()) {
            final String expectedAuthorizationHttpHeader = "Basic " + encodedCredentials;
            return expectedAuthorizationHttpHeader.equals(rawAuthorizationHttpHeader);
        } else {
            return true;
        }
    }
}

@@ -492,74 +492,8 @@
 ) %7B%0A
-        System.err.println(%22!!!!! CREATE EMPTY INSTANCE !!!!!!%22);%0A
     
@@ -642,68 +642,8 @@
 ) %7B%0A
-        System.err.println(%22!!!!! CREATE INSTANCE !!!!!!%22);%0A
     

Remove prints