org.whispersystems.signalservice.api.push.exceptions.AuthorizationFailedException Java Examples
The following examples show how to use
org.whispersystems.signalservice.api.push.exceptions.AuthorizationFailedException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AdvancedPreferenceFragment.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
@Override protected Integer doInBackground(Void... params) { try { Context context = getActivity(); SignalServiceAccountManager accountManager = ApplicationDependencies.getSignalServiceAccountManager(); try { accountManager.setGcmId(Optional.<String>absent()); } catch (AuthorizationFailedException e) { Log.w(TAG, e); } if (!TextSecurePreferences.isFcmDisabled(context)) { FirebaseInstanceId.getInstance().deleteInstanceId(); } return SUCCESS; } catch (IOException ioe) { Log.w(TAG, ioe); return NETWORK_ERROR; } }
Example #2
Source File: PushServiceSocket.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
private Response makeRequest(ConnectionHolder connectionHolder, String authorization, List<String> cookies, String path, String method, String body) throws PushNetworkException, NonSuccessfulResponseCodeException { OkHttpClient okHttpClient = connectionHolder.getClient() .newBuilder() .connectTimeout(soTimeoutMillis, TimeUnit.MILLISECONDS) .readTimeout(soTimeoutMillis, TimeUnit.MILLISECONDS) .build(); Request.Builder request = new Request.Builder().url(connectionHolder.getUrl() + path); if (body != null) { request.method(method, RequestBody.create(MediaType.parse("application/json"), body)); } else { request.method(method, null); } if (connectionHolder.getHostHeader().isPresent()) { request.addHeader("Host", connectionHolder.getHostHeader().get()); } if (authorization != null) { request.addHeader("Authorization", authorization); } if (cookies != null && !cookies.isEmpty()) { request.addHeader("Cookie", Util.join(cookies, "; ")); } Call call = okHttpClient.newCall(request.build()); synchronized (connections) { connections.add(call); } Response response; try { response = call.execute(); if (response.isSuccessful()) { return response; } } catch (IOException e) { throw new PushNetworkException(e); } finally { synchronized (connections) { connections.remove(call); } } switch (response.code()) { case 401: case 403: throw new AuthorizationFailedException("Authorization failed!"); case 409: throw new RemoteAttestationResponseExpiredException("Remote attestation response expired"); case 429: throw new RateLimitException("Rate limit exceeded: " + response.code()); } throw new NonSuccessfulResponseCodeException("Response: " + response); }
Example #3
Source File: PushServiceSocket.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
private ResponseBody makeStorageRequest(String authorization, String path, String method, RequestBody body, ResponseCodeHandler responseCodeHandler) throws PushNetworkException, NonSuccessfulResponseCodeException { ConnectionHolder connectionHolder = getRandom(storageClients, random); OkHttpClient okHttpClient = connectionHolder.getClient() .newBuilder() .connectTimeout(soTimeoutMillis, TimeUnit.MILLISECONDS) .readTimeout(soTimeoutMillis, TimeUnit.MILLISECONDS) .build(); // Log.d(TAG, "Opening URL: " + String.format("%s%s", connectionHolder.getUrl(), path)); Log.d(TAG, "Opening URL: <REDACTED>"); Request.Builder request = new Request.Builder().url(connectionHolder.getUrl() + path); request.method(method, body); if (connectionHolder.getHostHeader().isPresent()) { request.addHeader("Host", connectionHolder.getHostHeader().get()); } if (authorization != null) { request.addHeader("Authorization", authorization); } Call call = okHttpClient.newCall(request.build()); synchronized (connections) { connections.add(call); } Response response; try { response = call.execute(); if (response.isSuccessful() && response.code() != 204) { return response.body(); } } catch (IOException e) { throw new PushNetworkException(e); } finally { synchronized (connections) { connections.remove(call); } } responseCodeHandler.handle(response.code()); switch (response.code()) { case 204: throw new NoContentException("No content!"); case 401: case 403: throw new AuthorizationFailedException("Authorization failed!"); case 404: throw new NotFoundException("Not found"); case 409: if (response.body() != null) { throw new ContactManifestMismatchException(readBodyBytes(response.body())); } else { throw new ConflictException(); } case 429: throw new RateLimitException("Rate limit exceeded: " + response.code()); } throw new NonSuccessfulResponseCodeException("Response: " + response); }
Example #4
Source File: PushServiceSocket.java From libsignal-service-java with GNU General Public License v3.0 | 4 votes |
private Response makeContactDiscoveryRequest(String authorization, List<String> cookies, String path, String method, String body) throws PushNetworkException, NonSuccessfulResponseCodeException { ConnectionHolder connectionHolder = getRandom(contactDiscoveryClients, random); OkHttpClient okHttpClient = connectionHolder.getClient() .newBuilder() .connectTimeout(soTimeoutMillis, TimeUnit.MILLISECONDS) .readTimeout(soTimeoutMillis, TimeUnit.MILLISECONDS) .build(); Request.Builder request = new Request.Builder().url(connectionHolder.getUrl() + path); if (body != null) { request.method(method, RequestBody.create(MediaType.parse("application/json"), body)); } else { request.method(method, null); } if (connectionHolder.getHostHeader().isPresent()) { request.addHeader("Host", connectionHolder.getHostHeader().get()); } if (authorization != null) { request.addHeader("Authorization", authorization); } if (cookies != null && !cookies.isEmpty()) { request.addHeader("Cookie", Util.join(cookies, "; ")); } Call call = okHttpClient.newCall(request.build()); synchronized (connections) { connections.add(call); } Response response; try { response = call.execute(); if (response.isSuccessful()) { return response; } } catch (IOException e) { throw new PushNetworkException(e); } finally { synchronized (connections) { connections.remove(call); } } switch (response.code()) { case 401: case 403: throw new AuthorizationFailedException("Authorization failed!"); case 409: throw new RemoteAttestationResponseExpiredException("Remote attestation response expired"); case 429: throw new RateLimitException("Rate limit exceeded: " + response.code()); } throw new NonSuccessfulResponseCodeException("Response: " + response); }