protected void sendAuthFailure ( IPolicyContext context , IPolicyChain < ? > chain , BasicAuthenticationConfig config , int reason ) { IPolicyFailureFactoryComponent pff = context . getComponent ( IPolicyFailureFactoryComponent . class ) ; PolicyFailure failure = pff . createFailure ( PolicyFailureType . Authentication , reason , Messages . i18n . format ( "BasicAuthenticationPolicy.AuthenticationFailed" ) ) ; //$NON-NLS-1$ String realm = config . getRealm ( ) ; if ( realm == null || realm . trim ( ) . isEmpty ( ) ) { realm = "Apiman" ; //$NON-NLS-1$ } failure . getHeaders ( ) . put ( "WWW-Authenticate" , String . format ( "Basic realm=\"%1$s\"" , realm ) ) ; //$NON-NLS-1$ //$NON-NLS-2$ chain . doFailure ( failure ) ; }
Sends the unauthenticated response as a policy failure .