Java Code Examples for org.whispersystems.libsignal.logging.Log#i()
The following examples show how to use
org.whispersystems.libsignal.logging.Log#i() .
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: SignalServiceMessageSender.java From mollyim-android with GNU General Public License v3.0 | 6 votes |
private List<AttachmentPointer> createAttachmentPointers(Optional<List<SignalServiceAttachment>> attachments) throws IOException { List<AttachmentPointer> pointers = new LinkedList<>(); if (!attachments.isPresent() || attachments.get().isEmpty()) { Log.w(TAG, "No attachments present..."); return pointers; } for (SignalServiceAttachment attachment : attachments.get()) { if (attachment.isStream()) { Log.i(TAG, "Found attachment, creating pointer..."); pointers.add(createAttachmentPointer(attachment.asStream())); } else if (attachment.isPointer()) { Log.i(TAG, "Including existing attachment pointer..."); pointers.add(createAttachmentPointer(attachment.asPointer())); } } return pointers; }
Example 2
Source File: WebSocketConnection.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
public synchronized void disconnect() { Log.i(TAG, "disconnect()"); if (client != null) { client.close(1000, "OK"); client = null; connected = false; } if (keepAliveSender != null) { keepAliveSender.shutdown(); keepAliveSender = null; } }
Example 3
Source File: WebSocketConnection.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@Override public synchronized void onOpen(WebSocket webSocket, Response response) { if (client != null && keepAliveSender == null) { Log.i(TAG, "onOpen() connected"); attempts = 0; connected = true; keepAliveSender = new KeepAliveSender(); keepAliveSender.start(); if (listener != null) listener.onConnected(); } }
Example 4
Source File: WebSocketConnection.java From mollyim-android with GNU General Public License v3.0 | 5 votes |
@Override public synchronized void onClosed(WebSocket webSocket, int code, String reason) { Log.i(TAG, "onClose()"); this.connected = false; Iterator<Map.Entry<Long, OutgoingRequest>> iterator = outgoingRequests.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<Long, OutgoingRequest> entry = iterator.next(); entry.getValue().getResponseFuture().setException(new IOException("Closed: " + code + ", " + reason)); iterator.remove(); } if (keepAliveSender != null) { keepAliveSender.shutdown(); keepAliveSender = null; } if (listener != null) { listener.onDisconnected(); } Util.wait(this, Math.min(++attempts * 200, TimeUnit.SECONDS.toMillis(15))); if (client != null) { client.close(1000, "OK"); client = null; connected = false; connect(); } notifyAll(); }
Example 5
Source File: AccountAttributesV2.java From bcm-android with GNU General Public License v3.0 | 5 votes |
public AccountAttributesV2(String signalingKey, int registrationId, boolean fetchesMessages, String pubKey, String privateKey) { this.signalingKey = signalingKey; this.registrationId = registrationId; this.voice = true; this.video = true; this.fetchesMessages = fetchesMessages; this.pubKey = pubKey; this.privateKey = privateKey; Log.i("bindOpenId public V2:", pubKey); Log.i("bindOpenId private V2:", privateKey); }
Example 6
Source File: AccountAttributesV3.java From bcm-android with GNU General Public License v3.0 | 5 votes |
public AccountAttributesV3(String openId, String privateKey, String pubKey) { this.voice = false; this.video = false; this.fetchesMessages = true; this.openId = openId; this.privateKey = privateKey; this.pubKey = pubKey; Log.i("bindOpenId public V3:", pubKey); Log.i("bindOpenId private V3:", privateKey); }
Example 7
Source File: KeyBackupService.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
private KbsPinData restorePin(HashedPin hashedPin, TokenResponse token) throws UnauthenticatedResponseException, IOException, TokenException, KeyBackupSystemNoDataException { try { final int remainingTries = token.getTries(); final RemoteAttestation remoteAttestation = getAndVerifyRemoteAttestation(); final KeyBackupRequest request = KeyBackupCipher.createKeyRestoreRequest(hashedPin.getKbsAccessKey(), token, remoteAttestation, Hex.fromStringCondensed(enclaveName)); final KeyBackupResponse response = pushServiceSocket.putKbsData(authorization, request, remoteAttestation.getCookies(), enclaveName); final RestoreResponse status = KeyBackupCipher.getKeyRestoreResponse(response, remoteAttestation); TokenResponse nextToken = status.hasToken() ? new TokenResponse(token.getBackupId(), status.getToken().toByteArray(), status.getTries()) : token; Log.i(TAG, "Restore " + status.getStatus()); switch (status.getStatus()) { case OK: KbsData kbsData = hashedPin.decryptKbsDataIVCipherText(status.getData().toByteArray()); MasterKey masterKey = kbsData.getMasterKey(); return new KbsPinData(masterKey, nextToken); case PIN_MISMATCH: Log.i(TAG, "Restore PIN_MISMATCH"); throw new KeyBackupServicePinException(nextToken); case TOKEN_MISMATCH: Log.i(TAG, "Restore TOKEN_MISMATCH"); // if the number of tries has not fallen, the pin is correct we're just using an out of date token boolean canRetry = remainingTries == status.getTries(); Log.i(TAG, String.format(Locale.US, "Token MISMATCH %d %d", remainingTries, status.getTries())); throw new TokenException(nextToken, canRetry); case MISSING: Log.i(TAG, "Restore OK! No data though"); throw new KeyBackupSystemNoDataException(); case NOT_YET_VALID: throw new UnauthenticatedResponseException("Key is not valid yet, clock mismatch"); default: throw new AssertionError("Unexpected case"); } } catch (InvalidCiphertextException e) { throw new UnauthenticatedResponseException(e); } }
Example 8
Source File: PushServiceSocket.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
private void downloadFromCdn(OutputStream outputStream, long offset, int cdnNumber, String path, long maxSizeBytes, ProgressListener listener) throws PushNetworkException, NonSuccessfulResponseCodeException, MissingConfigurationException { ConnectionHolder[] cdnNumberClients = cdnClientsMap.get(cdnNumber); if (cdnNumberClients == null) { throw new MissingConfigurationException("Attempted to download from unsupported CDN number: " + cdnNumber + ", Our configuration supports: " + cdnClientsMap.keySet()); } ConnectionHolder connectionHolder = getRandom(cdnNumberClients, 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).get(); if (connectionHolder.getHostHeader().isPresent()) { request.addHeader("Host", connectionHolder.getHostHeader().get()); } if (offset > 0) { Log.i(TAG, "Starting download from CDN with offset " + offset); request.addHeader("Range", "bytes=" + offset + "-"); } Call call = okHttpClient.newCall(request.build()); synchronized (connections) { connections.add(call); } Response response = null; ResponseBody body = null; try { response = call.execute(); if (response.isSuccessful()) { body = response.body(); if (body == null) throw new PushNetworkException("No response body!"); if (body.contentLength() > maxSizeBytes) throw new PushNetworkException("Response exceeds max size!"); InputStream in = body.byteStream(); byte[] buffer = new byte[32768]; int read = 0; long totalRead = offset; while ((read = in.read(buffer, 0, buffer.length)) != -1) { outputStream.write(buffer, 0, read); if ((totalRead += read) > maxSizeBytes) throw new PushNetworkException("Response exceeded max size!"); if (listener != null) { listener.onAttachmentProgress(body.contentLength() + offset, totalRead); } } return; } } catch (IOException e) { if (body != null) { body.close(); } throw new PushNetworkException(e); } finally { synchronized (connections) { connections.remove(call); } } throw new NonSuccessfulResponseCodeException("Response: " + response); }
Example 9
Source File: WebSocketConnection.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
public synchronized void connect() { Log.i(TAG, "connect()"); if (client == null) { String filledUri; if (credentialsProvider.isPresent()) { String identifier = credentialsProvider.get().getUuid() != null ? credentialsProvider.get().getUuid().toString() : credentialsProvider.get().getE164(); filledUri = String.format(wsUri, identifier, credentialsProvider.get().getPassword()); } else { filledUri = wsUri; } Pair<SSLSocketFactory, X509TrustManager> socketFactory = createTlsSocketFactory(trustStore); OkHttpClient.Builder clientBuilder = new OkHttpClient.Builder() .sslSocketFactory(new Tls12SocketFactory(socketFactory.first()), socketFactory.second()) .connectionSpecs(Util.immutableList(ConnectionSpec.RESTRICTED_TLS)) .readTimeout(KEEPALIVE_TIMEOUT_SECONDS + 10, TimeUnit.SECONDS) .dns(dns.or(Dns.SYSTEM)) .connectTimeout(KEEPALIVE_TIMEOUT_SECONDS + 10, TimeUnit.SECONDS); for (Interceptor interceptor : interceptors) { clientBuilder.addInterceptor(interceptor); } OkHttpClient okHttpClient = clientBuilder.build(); Request.Builder requestBuilder = new Request.Builder().url(filledUri); if (signalAgent != null) { requestBuilder.addHeader("X-Signal-Agent", signalAgent); } if (listener != null) { listener.onConnecting(); } this.connected = false; this.client = okHttpClient.newWebSocket(requestBuilder.build(), this); } }
Example 10
Source File: WebSocketConnection.java From mollyim-android with GNU General Public License v3.0 | 4 votes |
@Override public synchronized void onClosing(WebSocket webSocket, int code, String reason) { Log.i(TAG, "onClosing()"); webSocket.close(1000, "OK"); }