throw new AuthenticationException( "Unable to respond to any of these challenges: " + challenges);
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); this.log.debug("Authorization challenge processed"); }
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); this.log.debug("Authorization challenge processed"); }
throw new AuthenticationException( "Unsupported qop in HTTP Digest authentication"); a1 = tmp3.toString(); } else if (!algorithm.equalsIgnoreCase("MD5")) { // android-changed: ignore case throw new AuthenticationException("Unhandled algorithm " + algorithm + " requested");
this.state = State.MSG_TYPE3_GENERATED; } else { throw new AuthenticationException("Unexpected state: " + this.state);
private boolean invokeTest(HttpUriRequest request, String username, String instanceName, String replicationType) throws IOException, AuthenticationException { HttpResponse response = client.execute(request); String body = EntityUtils.toString(response.getEntity()); if (response.getStatusLine().getStatusCode() == 401) { throw new AuthenticationException("Cannot authenticate user " + username); } else if (response.getStatusLine().getStatusCode() == 200) { @SuppressWarnings("unchecked") Map<String, String> map = GSON.fromJson(body, Map.class); String user = map.get("transportUser"); if ("admin".equals(user)) { addErrorMessage(replicationType + " transport user on [%s] is [%s]", instanceName, user); return false; } } return true; } }
default String getJsonBodyOfOsgiConfiguration(String osgiConfigurationUrl, UsernamePasswordCredentials credentials, String instanceName) throws AuthenticationException, IOException { DefaultHttpClient authorizedClient = new DefaultHttpClient(); HttpUriRequest request = new HttpGet(osgiConfigurationUrl); request.addHeader(new BasicScheme().authenticate(credentials, request, null)); HttpResponse response = authorizedClient.execute(request); int statusCode = response.getStatusLine().getStatusCode(); if (statusCode != HttpURLConnection.HTTP_OK) { throw new AuthenticationException( "Cannot authenticate user " + credentials.getUserName() + " to " + instanceName + " instance"); } return EntityUtils.toString(response.getEntity()); }
@Override public boolean doTest(String url, String instanceName) throws Exception { UsernamePasswordCredentials credentials = getUsernamePasswordCredentials(instanceName); String agentUrl = url + "/system/console/bundles.json"; HttpUriRequest request = new HttpGet(agentUrl); request.addHeader(new BasicScheme().authenticate(credentials, request, null)); DefaultHttpClient client = new DefaultHttpClient(); HttpResponse response = client.execute(request); String body = EntityUtils.toString(response.getEntity()); if (response.getStatusLine().getStatusCode() == HttpURLConnection.HTTP_UNAUTHORIZED) { throw new AuthenticationException("Cannot authenticate user " + credentials.getUserName()); } else if (response.getStatusLine().getStatusCode() == HttpURLConnection.HTTP_OK) { @SuppressWarnings("unchecked") Map<String, List<Map<String, String>>> map = GSON .fromJson(body, Map.class); String[] bundlesConfig = config.getStringList("bundles"); ArrayList<String> bundles = new ArrayList<>(Arrays.asList(bundlesConfig)); for (Map<String, String> item : map.get("data")) { if (bundles.contains(item.get("name"))) { addErrorMessage("Bundle [%s] already exists on [%s]", item.get("name"), instanceName); bundles.remove(item.get("name")); } } for (String bundle : bundles) { addInfoMessage("Bundle [%s] doesn't exists on [%s]", bundle, instanceName); } } return true; }
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); this.log.debug("Authorization challenge processed"); }
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); this.log.debug("Authorization challenge processed"); }
@Override public Header authenticate(Credentials credentials, HttpRequest request) throws AuthenticationException { final String usedToken = extractToken(request); // make sure only one refresh request gets sent out synchronized (OAuth2Scheme.class) { final Token apiToken = mApi.getToken(); if (apiToken == null || apiToken.access == null || apiToken.access.equals(usedToken)) { if (mApi.invalidateToken() == null) { // we actually need to refresh it ourselves try { mApi.refreshToken(); } catch (IOException e) { throw new AuthenticationException("Error refreshing token", e); } catch (IllegalStateException e) { throw new AuthenticationException("Error refreshing token", e); } } } return ApiWrapper.createOAuthHeader(mApi.getToken()); } }
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); this.log.debug("Authorization challenge processed"); }
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); this.log.debug("Authorization challenge processed"); }
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); this.log.debug("Authorization challenge processed"); }
public Header authenticate(Credentials credentials, HttpRequest request) throws AuthenticationException { String uri; String method; HttpUriRequest uriRequest = getHttpUriRequest(request); if (uriRequest != null) { uri = uriRequest.getURI().toString(); method = uriRequest.getMethod(); } else { // Some requests don't include the server name in the URL. RequestLine requestLine = request.getRequestLine(); uri = requestLine.getUri(); method = requestLine.getMethod(); } try { OAuthMessage message = new OAuthMessage(method, uri, null); OAuthAccessor accessor = getAccessor(credentials); message.addRequiredParameters(accessor); String authorization = message.getAuthorizationHeader(getRealm()); return new BasicHeader("Authorization", authorization); } catch (Exception e) { throw new AuthenticationException(null, e); } }
Args.notNull(request, "HTTP request"); if (getParameter("realm") == null) { throw new AuthenticationException("missing realm in challenge"); throw new AuthenticationException("missing nonce in challenge");
Args.notNull(request, "HTTP request"); if (getParameter("realm") == null) { throw new AuthenticationException("missing realm in challenge"); throw new AuthenticationException("missing nonce in challenge");
Args.notNull(request, "HTTP request"); if (getParameter("realm") == null) { throw new AuthenticationException("missing realm in challenge"); throw new AuthenticationException("missing nonce in challenge");
this.state = State.MSG_TYPE3_GENERATED; } else { throw new AuthenticationException("Unexpected state: " + this.state);