private void setResponseHeader ( final RequestContext context ) { val credential = WebUtils . getCredential ( context ) ; if ( credential == null ) { LOGGER . debug ( "No credential was provided. No response header set." ) ; return ; } val response = WebUtils . getHttpServletResponseFromExternalWebflowContext ( context ) ; val spnegoCredentials = ( SpnegoCredential ) credential ; val nextToken = spnegoCredentials . getNextToken ( ) ; if ( nextToken != null ) { LOGGER . debug ( "Obtained output token: [{}]" , new String ( nextToken , Charset . defaultCharset ( ) ) ) ; response . setHeader ( SpnegoConstants . HEADER_AUTHENTICATE , ( this . ntlm ? SpnegoConstants . NTLM : SpnegoConstants . NEGOTIATE ) + ' ' + EncodingUtils . encodeBase64 ( nextToken ) ) ; } else { LOGGER . debug ( "Unable to obtain the output token required." ) ; } if ( spnegoCredentials . getPrincipal ( ) == null && this . send401OnAuthenticationFailure ) { LOGGER . debug ( "Setting HTTP Status to 401" ) ; response . setStatus ( HttpServletResponse . SC_UNAUTHORIZED ) ; } }
Sets the response header based on the retrieved token .