{@inheritDoc}
<p>
Called using the challenge text parsed from the header that is associated with this scheme's name.
May advance the authentication process across multiple calls.
</p>
342110
@Override
    public void processChallenge(String challenge) throws MalformedChallengeException {
        // Parse Challenge Data
        // Challenge is base64 string to be given to gss context
        if (StringUtils.hasText(challenge)) {
            // Remove leading auth scheme name and trim data
            this.challenge = challenge.substring(EsHadoopAuthPolicies.NEGOTIATE.length()).trim();
        }
    }
37180
public static byte[] getNTLMResponse(String password, byte[] challenge)
            throws Exception {
        byte[] ntlmHash = ntlmHash(password);
        return lmResponse(ntlmHash, challenge);
    }
140873
def parse_challenge_message(self, msg2):
        
        msg2 = base64.b64decode(msg2)
        self.challenge_message = ChallengeMessage(msg2)
1136907
public void parse() throws AuthHeaderParsingException {

		String[] parts = headerValue.trim().split("\\s+", 2);
		if (parts.length < 1) {
			throw new AuthHeaderParsingException("Unable to split scheme and other part in " + headerValue);
		}

		builder.scheme(parts[0]);
		
		if(parts.length == 1) {
			return;
		}
		
		// FIXME: handle optional, one-time token

		for (String kv : parts[1].split(",")) {
			String[] kva = kv.trim().split("=", 2);
			if (!(kva.length == 2)) {
				throw new AuthHeaderParsingException("Unable to split " + kv + " into parameter key and value in " + headerValue);
			}
			if (kva[1].startsWith("\"")) {
				kva[1] = kva[1].substring(1, kva[1].length() - 1);
			}
			builder.param(kva[0], kva[1]);
		}
	}
947160
static void validateHeaderValue(CharSequence value) {
        if (value == null) {
            throw new NullPointerException("value");
        }
        for (int i = 0; i < value.length(); i ++) {
            char c = value.charAt(i);
            if (c == 0) {
                throw new IllegalArgumentException(
                        "value contains null character: " + value);
            }
        }
    }
348692
public boolean isValid(HttpServletRequest request, String challenge, String response) {
    String remoteAddr = request.getRemoteAddr();
    log.info("Challenge Field Name = [{}]", challenge);
    log.info("Response Field Name = [{}]", response);
    if(challenge != null && response != null && challenge.trim().length() > 0) {
      return reCaptcha.checkAnswer(remoteAddr, challenge, response).isValid();
    } else {
      return false;
    }
  }
846133
protected ChallengeResponse parseCredentials(final String cookieValue)
    {
        // 1) Decode Base64 string
        final byte[] encrypted = Base64.decode(cookieValue);
        
        if(encrypted == null)
        {
            this.log.error("Cannot decode cookie credentials : {}", cookieValue);
        }
        
        // 2) Decrypt the credentials
        try
        {
            final String decrypted =
                    CryptoUtils.decrypt(this.getEncryptAlgorithm(), this.getEncryptSecretKey(), encrypted);
            
            // 3) Parse the decrypted cookie value
            final int lastSlash = decrypted.lastIndexOf('/');
            final String[] indexes = decrypted.substring(lastSlash + 1).split(",");
            final int identifierIndex = Integer.parseInt(indexes[0]);
            final int secretIndex = Integer.parseInt(indexes[1]);
            
            // 4) Create the challenge response
            final ChallengeResponse cr = new ChallengeResponse(this.getScheme());
            cr.setRawValue(cookieValue);
            cr.setTimeIssued(Long.parseLong(decrypted.substring(0, identifierIndex)));
            cr.setIdentifier(decrypted.substring(identifierIndex + 1, secretIndex));
            cr.setSecret(decrypted.substring(secretIndex + 1, lastSlash));
            return cr;
        }
        catch(final Exception e)
        {
            this.log.info("Unable to decrypt cookie credentials");
            this.log.trace("Unable to decrypt cookie credentials: Stacktrace:", e);
            return null;
        }
    }
788276
protected function _parseChallenge($challenge)
    {
        $tokens = array(
            'maxbuf' => 65536,
            'realm' => ''
        );

        preg_match_all('/([a-z-]+)=("[^"]+(?<!\\\)"|[^,]+)/i', $challenge, $matches, PREG_SET_ORDER);

        foreach ($matches as $val) {
            $tokens[$val[1]] = trim($val[2], '"');
        }

        // Required directives.
        if (!isset($tokens['nonce']) || !isset($tokens['algorithm'])) {
            throw new Horde_Imap_Client_Exception(
                Horde_Imap_Client_Translation::r("Authentication failure."),
                Horde_Imap_Client_Exception::SERVER_CONNECT
            );
        }

        return $tokens;
    }
1370735
public void addAuthHeader(SipServletResponse challengeResponse,
			String username, String password, boolean cacheCredentials) {
		checkReadOnly();
		SipServletResponseImpl challengeResponseImpl =
			(SipServletResponseImpl) challengeResponse;

		Response response = (Response) challengeResponseImpl.getMessage();
		ListIterator<Header> authHeaderIterator =
			response.getHeaders(WWWAuthenticateHeader.NAME);

		// First
		while(authHeaderIterator.hasNext()) {
			WWWAuthenticateHeader wwwAuthHeader =
				(WWWAuthenticateHeader) authHeaderIterator.next();
			// Fix for Issue 1832 : http://code.google.com/p/mobicents/issues/detail?id=1832
			// Authorization header is growing when nonce become stale, don't take into account stale headers
			// in the challenge request
			removeStaleAuthHeaders(wwwAuthHeader);
//			String uri = wwwAuthHeader.getParameter("uri");
			addChallengeResponse(wwwAuthHeader, username, password, this.getRequestURI().toString());

			if(cacheCredentials) {
				getSipSession().getSipSessionSecurity().addCachedAuthInfo(wwwAuthHeader.getRealm(), new AuthInfoEntry(response.getStatusCode(), username, password));
			}
		}


		authHeaderIterator =
			response.getHeaders(ProxyAuthenticateHeader.NAME);

		while(authHeaderIterator.hasNext()) {
			ProxyAuthenticateHeader proxyAuthHeader =
				(ProxyAuthenticateHeader) authHeaderIterator.next();
			// Fix for Issue 1832 : http://code.google.com/p/mobicents/issues/detail?id=1832
			// Authorization header is growing when nonce become stale, don't take into account stale headers
			// in the challenge request
			removeStaleAuthHeaders(proxyAuthHeader);
			String uri = proxyAuthHeader.getParameter("uri");
			if(uri == null) uri = this.getRequestURI().toString();
			addChallengeResponse(proxyAuthHeader, username, password, uri);

			if(cacheCredentials) {
				getSipSession().getSipSessionSecurity().addCachedAuthInfo(proxyAuthHeader.getRealm(), new AuthInfoEntry(response.getStatusCode(), username, password));
			}
		}
	}
737499
public static void verifyToken(HttpString header) {
        int length = header.length();
        for(int i = 0; i < length; ++i) {
            byte c = header.byteAt(i);
            if(!ALLOWED_TOKEN_CHARACTERS[c]) {
                throw UndertowMessages.MESSAGES.invalidToken(c);
            }
        }
    }
1306582
public static void nailMain(NGContext context)
      throws java.security.NoSuchAlgorithmException, java.io.IOException {
    String[] args = context.getArgs();

    if (args.length == 0) {
      // display available algorithms
      Set algs = getCryptoImpls("MessageDigest");
      for (Object alg : algs) {
        context.out.println(alg);
      }
      return;
    }

    // perform the actual hash.  throw any exceptions back to the user.
    MessageDigest md = MessageDigest.getInstance(args[0]);

    byte[] b = new byte[1024];
    int bytesRead = context.in.read(b);
    while (bytesRead != -1) {
      md.update(b, 0, bytesRead);
      bytesRead = System.in.read(b);
    }
    byte[] result = md.digest();

    // convert hash result to a string of hex characters and print it to the client.
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < result.length; ++i) {
      buf.append(HEXCHARS[(result[i] >> 4) & 0x0f]);
      buf.append(HEXCHARS[result[i] & 0x0f]);
    }
    context.out.println(buf);
  }
1364661
def challenge_response(challenge, password_hash):
    """"""
    zpassword_hash = password_hash.ljust(21, '\0')

    response = ""
    des_obj = des.DES(zpassword_hash[0:7])
    response += des_obj.encrypt(challenge)

    des_obj = des.DES(zpassword_hash[7:14])
    response += des_obj.encrypt(challenge)

    des_obj = des.DES(zpassword_hash[14:21])
    response += des_obj.encrypt(challenge)
    return response
866247
protected function _setChallengeHeaders()
    {
        if ($this->isProxyAuth()) {
            $statusCode = 407;
            $headerName = 'Proxy-Authenticate';
        } else {
            $statusCode = 401;
            $headerName = 'WWW-Authenticate';
        }

        // Send a challenge in each acceptable authentication scheme
        $this->response()->setStatusCode($statusCode);

        $headers = $this->response()->headers();
        $headers->insert(FactoryHttpHeader::of(array(
                $headerName => $this->_getAuthenticateChallengeHeader())
        ));

        // $headers->insert(FactoryHttpHeader::of( array('Authorization' => 'deleted')) );
    }
754344
@Beta
  public static SSLContext trustAllSSLContext() throws GeneralSecurityException {
    TrustManager[] trustAllCerts =
        new TrustManager[] {
          new X509TrustManager() {

            public void checkClientTrusted(X509Certificate[] chain, String authType)
                throws CertificateException {}

            public void checkServerTrusted(X509Certificate[] chain, String authType)
                throws CertificateException {}

            public X509Certificate[] getAcceptedIssuers() {
              return null;
            }
          }
        };
    SSLContext context = getTlsSslContext();
    context.init(null, trustAllCerts, null);
    return context;
  }
974590
public RespondToAuthChallengeResult withChallengeParameters(java.util.Map<String, String> challengeParameters) {
        setChallengeParameters(challengeParameters);
        return this;
    }
913727
def parse_digest_challenge(authentication_header):
    '''
    
    '''
    if not is_digest_challenge(authentication_header):
        return None

    parts = parse_parts(authentication_header[7:], defaults={'algorithm': 'MD5',
                                                             'stale': 'false'})
    if not _check_required_parts(parts, _REQUIRED_DIGEST_CHALLENGE_PARTS):
        return None

    parts['stale'] = parts['stale'].lower() == 'true'

    digest_challenge = _build_object_from_parts(parts, _REQUIRED_DIGEST_CHALLENGE_PARTS)
    if ('MD5', 'auth') != (digest_challenge.algorithm, digest_challenge.qop):
        return None

    return digest_challenge
358726
@Override
    public void setHeader(String name, String value) {
        this.message.setHeader(name, value);
    }