Package org.apache.http.auth

Examples of org.apache.http.auth.AuthenticationException


        if (request == null) {
            throw new IllegalArgumentException("HTTP request may not be null");
        }
        switch (state) {
        case UNINITIATED:
            throw new AuthenticationException(getSchemeName() + " authentication has not been initiated");
        case FAILED:
            throw new AuthenticationException(getSchemeName() + " authentication has failed");
        case CHALLENGE_RECEIVED:
            try {
                String key = null;
                if (isProxy()) {
                    key = ExecutionContext.HTTP_PROXY_HOST;
                } else {
                    key = ExecutionContext.HTTP_TARGET_HOST;
                }
                HttpHost host = (HttpHost) context.getAttribute(key);
                if (host == null) {
                    throw new AuthenticationException("Authentication host is not set " +
                            "in the execution context");
                }
                String authServer;
                if (!this.stripPort && host.getPort() > 0) {
                    authServer = host.toHostString();
                } else {
                    authServer = host.getHostName();
                }

                if (log.isDebugEnabled()) {
                    log.debug("init " + authServer);
                }
                token = generateToken(token, authServer);
                state = State.TOKEN_GENERATED;
            } catch (GSSException gsse) {
                state = State.FAILED;
                if (gsse.getMajor() == GSSException.DEFECTIVE_CREDENTIAL
                        || gsse.getMajor() == GSSException.CREDENTIALS_EXPIRED)
                    throw new InvalidCredentialsException(gsse.getMessage(), gsse);
                if (gsse.getMajor() == GSSException.NO_CRED )
                    throw new InvalidCredentialsException(gsse.getMessage(), gsse);
                if (gsse.getMajor() == GSSException.DEFECTIVE_TOKEN
                        || gsse.getMajor() == GSSException.DUPLICATE_TOKEN
                        || gsse.getMajor() == GSSException.OLD_TOKEN)
                    throw new AuthenticationException(gsse.getMessage(), gsse);
                // other error
                throw new AuthenticationException(gsse.getMessage());
            }
        case TOKEN_GENERATED:
            String tokenstr = new String(base64codec.encode(token));
            if (log.isDebugEnabled()) {
                log.debug("Sending response '" + tokenstr + "' back to the auth server");
View Full Code Here


    String uri = _locator.subscriptionUpdatesUri(deviceId, since);
    try {
      return _gson.fromJson(_client.GET(uri), SubscriptionChanges.class);
    } catch (HttpResponseException e) {
      if (e.getStatusCode() == 401)
        throw new AuthenticationException(
            "Unable to authenticate user with Gpodder.net", e);
      else
        throw e;
    }
View Full Code Here

      JsonObject response = (JsonObject) parser.parse(_client.POST(
          _locator.uploadEpisodeActionsUri(), data));
      return response.get("timestamp").getAsLong();
    } catch (HttpResponseException e) {
      if (e.getStatusCode() == 401)
        throw new AuthenticationException(
            "Unable to authenticate user with Gpodder.net", e);
      else
        throw e;
    }
  }
View Full Code Here

      return _gson.fromJson(_client.GET(_locator
          .downloadEpisodeActionsUri(since, podcast, deviceId)),
          EpisodeActionChanges.class);
    } catch (HttpResponseException e) {
      if (e.getStatusCode() == 401)
        throw new AuthenticationException(
            "Unable to authenticate user with Gpodder.net", e);
      else
        throw e;
    }
  }
View Full Code Here

    try {
      _client.POST(_locator.deviceSettingsUri(deviceId), data);
      return true;
    } catch (HttpResponseException e) {
      if (e.getStatusCode() == 401)
        throw new AuthenticationException(
            "Unable to authenticate user with Gpodder.net", e);
      else
        return false;
    }
  }
View Full Code Here

    }.getType();
    try {
      return _gson.fromJson(_client.GET(uri), collectionType);
    } catch (HttpResponseException e) {
      if (e.getStatusCode() == 401)
        throw new AuthenticationException(
            "Unable to authenticate user with Gpodder.net", e);
      else
        throw e;
    }
  }
View Full Code Here

    String uri = _locator.deviceSynchronizationUri();
    try {
      return _gson.fromJson(_client.GET(uri), DeviceSync.class);
    } catch (HttpResponseException e) {
      if (e.getStatusCode() == 401)
        throw new AuthenticationException(
            "Unable to authenticate user with Gpodder.net", e);
      else
        throw e;
    }
   
View Full Code Here

        if (charset == null) {
            charset = "ISO-8859-1";
        }

        if (qopVariant == QOP_AUTH_INT) {
            throw new AuthenticationException(
                "Unsupported qop in HTTP Digest authentication");  
        }

        String digAlg = algorithm;
        if (digAlg.equalsIgnoreCase("MD5-sess")) {
View Full Code Here

                }
            }
        }
        if (authScheme == null) {
            // If none selected, something is wrong
            throw new AuthenticationException(
                "Unable to respond to any of these challenges: "
                    + challenges);
        }
        return authScheme;
    }
View Full Code Here

        }
        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);
        this.log.debug("Authorization challenge processed");
    }
View Full Code Here

TOP

Related Classes of org.apache.http.auth.AuthenticationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.