public boolean hasSession() { return !StringUtils.isNullOrEmpty(sessionId); }
public boolean hasSessionId() { return !StringUtils.isNullOrEmpty(sessionId); }
public ApptentiveNotification(String name, Map<String, Object> userInfo) { if (StringUtils.isNullOrEmpty(name)) { throw new IllegalArgumentException("Name is null or empty"); } this.name = name; this.userInfo = userInfo; }
public ConversationDispatchTask setDescription(String description) { if (isNullOrEmpty(description)) { throw new IllegalArgumentException("Description is null or empty"); } this.description = description; return this; }
KeyInfo(String alias, int versionCode) { if (StringUtils.isNullOrEmpty(alias)) { throw new IllegalArgumentException("Key alias name is null or empty"); } if (versionCode < 1) { throw new IllegalArgumentException("Invalid SDK version code"); } this.alias = alias; this.versionCode = versionCode; }
@Override protected void handleResponse(String response) throws IOException { try { if (!StringUtils.isNullOrEmpty(response)) { responseObject = new JSONObject(response); } } catch (JSONException e) { throw new IOException(e); } }
public static boolean isEmailValid(String email) { return !StringUtils.isNullOrEmpty(email) && Patterns.EMAIL_ADDRESS.matcher(email).matches(); }
public EncryptionKey(@NonNull Key key, @NonNull String transformation) { if (key == null) { throw new IllegalArgumentException("Key is null"); } if (StringUtils.isNullOrEmpty(transformation)) { throw new IllegalArgumentException("Cipher transformation is null or empty"); } this.key = key; this.transformation = transformation; this.hexKey = null; }
public ApptentiveConfiguration(@NonNull String apptentiveKey, @NonNull String apptentiveSignature) { if (StringUtils.isNullOrEmpty(apptentiveKey)) { throw new IllegalArgumentException("Apptentive key is null or empty"); } if (StringUtils.isNullOrEmpty(apptentiveSignature)) { throw new IllegalArgumentException("Apptentive signature is null or empty"); } this.apptentiveKey = apptentiveKey.trim(); this.apptentiveSignature = apptentiveSignature.trim(); this.logLevel = ApptentiveLog.Level.INFO; this.shouldEncryptStorage = false; this.shouldSanitizeLogMessages = true; this.troubleshootingModeEnabled = true; }
public ApptentiveHttpClient(String apptentiveKey, String apptentiveSignature, String serverURL) { if (StringUtils.isNullOrEmpty(apptentiveKey)) { throw new IllegalArgumentException("Illegal Apptentive Key: '" + apptentiveKey + "'"); } if (StringUtils.isNullOrEmpty(apptentiveSignature)) { throw new IllegalArgumentException("Illegal Apptentive Signature: '" + apptentiveSignature + "'"); } if (StringUtils.isNullOrEmpty(serverURL)) { throw new IllegalArgumentException("Illegal server URL: '" + serverURL + "'"); } this.apptentiveKey = apptentiveKey; this.apptentiveSignature = apptentiveSignature; this.serverURL = serverURL; this.userAgentString = String.format(USER_AGENT_STRING, Constants.getApptentiveSdkVersion()); }
public static Level parse(String level) { if (!StringUtils.isNullOrEmpty(level)) { try { return Level.valueOf(level); } catch (Exception ignored) { } } return UNKNOWN; }
public EncryptionKey(@NonNull String hexKey) { if (StringUtils.isNullOrEmpty(hexKey)) { throw new IllegalArgumentException("Hex key is null or empty"); } this.key = new SecretKeySpec(StringUtils.hexToBytes(hexKey), ALGORITHM); this.transformation = DEFAULT_TRANSFORMATION; this.hexKey = hexKey; }
/** * Attempts to read access token from the clipboard */ private static @Nullable String readAccessTokenFromClipboard(Context context) { String text = Util.getClipboardText(context); if (StringUtils.isNullOrEmpty(text)) { return null; } //Since the token string should never contain spaces, attempt to repair line breaks introduced in the copying process. text = text.replaceAll("\\s+", ""); if (!text.startsWith(DEBUG_TEXT_HEADER)) { return null; } // Remove the header return text.substring(DEBUG_TEXT_HEADER.length()); }
public HttpJsonRequest createFetchMessagesRequest(String conversationToken, String conversationId, String afterId, String beforeId, Integer count, HttpRequest.Listener<HttpJsonRequest> listener) { if (StringUtils.isNullOrEmpty(conversationToken)) { throw new IllegalArgumentException("Conversation token is null or empty"); } if (StringUtils.isNullOrEmpty(conversationId)) { throw new IllegalArgumentException("Conversation id is null or empty"); } final String endPoint = String.format(ENDPOINT_MESSAGES, conversationId, count == null ? "" : count.toString(), afterId == null ? "" : afterId, beforeId == null ? "" : beforeId); HttpJsonRequest request = createJsonRequest(endPoint, new JSONObject(), HttpRequestMethod.GET); request.setRequestProperty("Authorization", "Bearer " + conversationToken); request.addListener(listener); return request; }
public HttpJsonRequest createAppConfigurationRequest(String conversationId, String token, HttpRequest.Listener<HttpJsonRequest> listener) { if (StringUtils.isNullOrEmpty(conversationId)) { throw new IllegalArgumentException("Conversation id is null or empty"); } if (StringUtils.isNullOrEmpty(token)) { throw new IllegalArgumentException("Conversation token is null or empty"); } String endPoint = StringUtils.format(ENDPOINT_CONFIGURATION, conversationId); HttpJsonRequest request = createJsonRequest(endPoint, new JSONObject(), HttpRequestMethod.GET); request.setRequestProperty("Authorization", "Bearer " + token); request.addListener(listener); return request; }
public HttpJsonRequest createFetchInteractionsRequest(String conversationToken, String conversationId, HttpRequest.Listener<HttpJsonRequest> listener) { if (StringUtils.isNullOrEmpty(conversationToken)) { throw new IllegalArgumentException("Conversation token is null or empty"); } if (StringUtils.isNullOrEmpty(conversationId)) { throw new IllegalArgumentException("Conversation id is null or empty"); } final String endPoint = StringUtils.format(ENDPOINT_INTERACTIONS, conversationId); HttpJsonRequest request = createJsonRequest(endPoint, new JSONObject(), HttpRequestMethod.GET); request.setRequestProperty("Authorization", "Bearer " + conversationToken); request.addListener(listener); return request; }
/** * Attempts to load an existing symmetric key or return <code>null</code> if failed. * Multistep process: * 1. Load and encrypted symmetric key data from the shared preferences. * 2. Unwraps the key using <code>wrapperKey</code> */ private static @Nullable SecretKey loadSymmetricKey(Context context, KeyPair wrapperKey) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException { String encryptedSymmetricKey = getKeyPrefs(context).getString(PREFS_KEY_SYMMETRIC_KEY, null); if (StringUtils.isNullOrEmpty(encryptedSymmetricKey)) { return null; } return unwrapSymmetricKey(wrapperKey, encryptedSymmetricKey); }
public HttpJsonRequest createLegacyConversationIdRequest(String conversationToken, HttpRequest.Listener<HttpJsonRequest> listener) { if (StringUtils.isNullOrEmpty(conversationToken)) { throw new IllegalArgumentException("Conversation token is null or empty"); } HttpJsonRequest request = createJsonRequest(ENDPOINT_LEGACY_CONVERSATION, new JSONObject(), HttpRequestMethod.GET); request.setRequestProperty("Authorization", "OAuth " + conversationToken); request.addListener(listener); return request; }
public static boolean isNotificationChannelEnabled(Context context, @NonNull String channelId){ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (!StringUtils.isNullOrEmpty(channelId)) { NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); NotificationChannel channel = manager.getNotificationChannel(channelId); return channel == null || channel.getImportance() != NotificationManager.IMPORTANCE_NONE; } return false; } return NotificationManagerCompat.from(context).areNotificationsEnabled(); } }
private HttpRequest createPayloadRequest(PayloadData payload) { final String authToken = payload.getAuthToken(); final String httpPath = notNull(payload.getHttpRequestPath()); final HttpRequestMethod requestMethod = notNull(payload.getHttpRequestMethod()); final String contentType = notNull(payload.getContentType()); HttpRequest request = createRawRequest(httpPath, payload.getData(), requestMethod, contentType); // Encrypted requests don't use an Auth token on the request. It's stored in the encrypted body. if (!StringUtils.isNullOrEmpty(authToken)) { request.setRequestProperty("Authorization", "Bearer " + authToken); } if (payload.isAuthenticated()) { request.setRequestProperty("APPTENTIVE-ENCRYPTED", Boolean.TRUE); } return request; }