类org.apache.http.auth.MalformedChallengeException源码实例Demo

下面列出了怎么用org.apache.http.auth.MalformedChallengeException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: ats-framework   文件: GGSSchemeBase.java
@Override
protected void parseChallenge(
                               final CharArrayBuffer buffer,
                               int beginIndex,
                               int endIndex ) throws MalformedChallengeException {

    String challenge = buffer.substringTrimmed(beginIndex, endIndex);
    if (log.isDebugEnabled()) {
        log.debug("Received challenge '" + challenge + "' from the auth server");
    }
    if (state == State.UNINITIATED) {
        token = base64codec.decode(challenge.getBytes());
        state = State.CHALLENGE_RECEIVED;
    } else {
        log.debug("Authentication already attempted");
        state = State.FAILED;
    }
}
 
@Override
public Map<String, Header> getChallenges(
    final HttpHost authhost, final HttpResponse response, final HttpContext context)
    throws MalformedChallengeException
{
  HttpRequest request = (HttpRequest) context.getAttribute(REQUEST_ATTRIBUTE);
  if (request != null) {
    Optional<Header> bearerTokenRequestOpt = getBearerHeader(request, HttpHeaders.AUTHORIZATION);
    Optional<Header> bearerTokenResponseOpt = getBearerHeader(response, HttpHeaders.WWW_AUTHENTICATE);

    /*
      Add necessary bearer token from request to response if it's absent, it's required for avoid infinite loop in docker
      (see NEXUS-23360)
     */
    if (bearerTokenRequestOpt.isPresent() && !bearerTokenResponseOpt.isPresent()) {
      response.addHeader(HttpHeaders.WWW_AUTHENTICATE, bearerTokenRequestOpt.get().getValue());
    }
  }
  return super.getChallenges(authhost, response, context);
}
 
源代码3 项目: YiBo   文件: LibRequestDirector.java
private void processChallenges(
        final Map<String, Header> challenges,
        final AuthState authState,
        final AuthenticationHandler authHandler,
        final HttpResponse response,
        final HttpContext context)
            throws MalformedChallengeException, AuthenticationException {

    AuthScheme authScheme = authState.getAuthScheme();
    if (authScheme == null) {
        // Authentication not attempted before
        authScheme = authHandler.selectScheme(challenges, response, context);
        authState.setAuthScheme(authScheme);
    }
    String id = authScheme.getSchemeName();

    Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
    if (challenge == null) {
        throw new AuthenticationException(id +
            " authorization challenge expected, but not found");
    }
    authScheme.processChallenge(challenge);
    if (DEBUG) {
    	Logger.debug("Authorization challenge processed");
    }
}
 
源代码4 项目: httpsig-java   文件: Http4SignatureAuthScheme.java
@Override
protected void parseChallenge(CharArrayBuffer buffer, int pos, int len) throws MalformedChallengeException {
    super.parseChallenge(buffer, pos, len);
    this.rotate = true;
}
 
 类所在包
 类方法
 同包方法