List of usage examples for android.util Base64 NO_WRAP
int NO_WRAP
To view the source code for android.util Base64 NO_WRAP.
Click Source Link
From source file:eu.codeplumbers.cosi.api.tasks.DeleteFileTask.java
public DeleteFileTask(FileManagerFragment fileManagerFragment) { this.fileManagerFragment = fileManagerFragment; Device device = Device.registeredDevice(); // delete all local notes new Delete().from(Note.class).execute(); // cozy register device url this.url = device.getUrl() + "/ds-api/data/"; // concatenate username and password with colon for authentication final String credentials = device.getLogin() + ":" + device.getPassword(); authHeader = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP); dialog = new ProgressDialog(fileManagerFragment.getActivity()); dialog.setCancelable(false);/*from w ww . java2s. c o m*/ dialog.setProgress(0); dialog.setMax(100); dialog.setMessage("Please wait"); dialog.setIndeterminate(false); dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dialog.show(); }
From source file:eu.codeplumbers.cosi.api.tasks.SyncDocumentTask.java
public SyncDocumentTask(Activity activity) { this.activity = activity; result = "";/*from w w w . ja va 2 s . c om*/ Device device = Device.registeredDevice(); // cozy register device url this.url = device.getUrl() + "/ds-api/data/"; // concatenate username and password with colon for authentication final String credentials = device.getLogin() + ":" + device.getPassword(); authHeader = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP); dialog = new ProgressDialog(activity); dialog.setCancelable(false); dialog.setProgress(0); dialog.setMax(100); dialog.setMessage("Please wait"); dialog.setIndeterminate(false); dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); dialog.show(); }
From source file:eu.codeplumbers.cosi.api.tasks.GetPlacesTask.java
public GetPlacesTask(PlacesFragment placesFragment) { this.placesFragment = placesFragment; allPlaces = new ArrayList<>(); Device device = Device.registeredDevice(); // delete all local places new Delete().from(Place.class).execute(); // cozy register device url this.url = device.getUrl() + "/ds-api/request/place/all/"; // concatenate username and password with colon for authentication final String credentials = device.getLogin() + ":" + device.getPassword(); authHeader = "Basic " + Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP); dialog = new ProgressDialog(placesFragment.getActivity()); dialog.setCancelable(false);/* w w w . j ava 2 s. co m*/ dialog.setMessage("Please wait"); dialog.setIndeterminate(true); dialog.show(); }
From source file:com.auth0.util.Telemetry.java
public String asBase64() { Map<String, Object> info = new HashMap<>(); info.put("name", getName("Lock.Android")); info.put("version", getVersion(BuildConfig.VERSION_NAME)); if (isNonEmpty(this.libraryVersion)) { info.put("lib_version", this.libraryVersion); }//from w w w . ja v a 2 s. c o m if (this.extra != null) { info.putAll(this.extra); } String clientInfo = null; try { String json = new ObjectMapper().writeValueAsString(info); Log.v(TAG, "Telemetry JSON is " + json); clientInfo = Base64.encodeToString(json.getBytes(Charset.defaultCharset()), Base64.URL_SAFE | Base64.NO_WRAP); } catch (JsonProcessingException e) { Log.w(TAG, "Failed to build client info", e); } return clientInfo; }
From source file:org.jboss.aerogear.unifiedpush.quickstart.util.WebClient.java
public User authenticate(String username, String password) { try {/* w ww . j a va 2 s . c om*/ String loginURL = Constants.BASE_URL + "/rest/security/user/info"; String credentials = username + ":" + password; String base64EncodedCredentials = Base64.encodeToString(credentials.getBytes(), Base64.NO_WRAP); HttpGet get = new HttpGet(loginURL); get.setHeader("Authorization", "Basic " + base64EncodedCredentials); get.setHeader("Accept", "application/json"); get.setHeader("Content-type", "application/json"); HttpResponse response = httpClient.execute(get); if (isStatusCodeOk(response)) { String responseData = EntityUtils.toString(response.getEntity()); Gson gson = new GsonBuilder().create(); Map<String, Object> rootNode = gson.fromJson(responseData, Map.class); String innerJson = gson.toJson(rootNode.get("account")); return gson.fromJson(innerJson, User.class); } else { return null; } } catch (Exception e) { Log.e(TAG, e.getMessage()); return null; } }
From source file:com.remobile.cordova.PluginResult.java
public PluginResult(Status status, byte[] data, boolean binaryString) { this.status = status.ordinal(); this.messageType = binaryString ? MESSAGE_TYPE_BINARYSTRING : MESSAGE_TYPE_ARRAYBUFFER; this.strMessage = Base64.encodeToString(data, Base64.NO_WRAP); }
From source file:com.ferjuarez.androidthingsdemo.PhotoEntryAdapter.java
@Override protected void populateViewHolder(DoorbellEntryViewHolder viewHolder, PhotoEntry model, int position) { // Display the timestamp if (model != null && model.getTimestamp() != null) { CharSequence prettyTime = DateUtils.getRelativeDateTimeString(mApplicationContext, model.getTimestamp(), DateUtils.SECOND_IN_MILLIS, DateUtils.WEEK_IN_MILLIS, 0); viewHolder.time.setText(prettyTime); // Display the image if (model.getThumbnail() != null) { // Decode image data encoded by the Cloud Vision library byte[] imageBytes = Base64.decode(model.getThumbnail(), Base64.NO_WRAP | Base64.URL_SAFE); Bitmap bitmap = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length); if (bitmap != null) { viewHolder.image.setImageBitmap(bitmap); } else { Drawable placeholder = ContextCompat.getDrawable(mApplicationContext, R.mipmap.ic_launcher); viewHolder.image.setImageDrawable(placeholder); }/*from w ww . ja v a2 s. co m*/ } } // Display the metadata /*if (model.getAnnotations() != null) { ArrayList<String> keywords = new ArrayList<>(model.getAnnotations().keySet()); int limit = Math.min(keywords.size(), 3); viewHolder.metadata.setText(TextUtils.join("\n", keywords.subList(0, limit))); } else { viewHolder.metadata.setText("no annotations yet"); }*/ }
From source file:com.tapcentive.minimalist.JWTHelper.java
/*** * Generates a JSON Web Token. This token uses the supplied application key to sign the token * content which should uniquely identify the client's customer (e.g. a loyalty number, email * etc.) and contain any Tapcentive audience IDs assigned to this customer. This example does * not require that either parameter be present. * @param originalBody/*w ww. ja v a 2 s . co m*/ * @param audiences * @param customerId * @return */ public String createJWT(JSONObject originalBody, List<String> audiences, String customerId) { try { JSONObject header = new JSONObject(); JSONObject body = new JSONObject(originalBody.toString()); header.put("typ", "JWT"); header.put("alg", "HS256"); body.put("iss", _keyid); if ((audiences != null) && (audiences.size() > 0)) { JSONArray attrArray = new JSONArray(audiences); body.put("audiences", attrArray); } if (customerId != null) { body.put("customer_xid", customerId); } String signedContent = Base64.encodeToString(header.toString().getBytes("UTF-8"), Base64.NO_WRAP) + "." + Base64.encodeToString(body.toString().getBytes("UTF-8"), Base64.NO_WRAP); Mac sha256_HMAC = Mac.getInstance("HmacSHA256"); SecretKeySpec secret_key = new SecretKeySpec(_key.getBytes("UTF-8"), "HmacSHA256"); sha256_HMAC.init(secret_key); String signature = Base64.encodeToString(sha256_HMAC.doFinal(signedContent.getBytes("UTF-8")), Base64.NO_WRAP); return signedContent + "." + signature; } catch (JSONException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (InvalidKeyException e) { e.printStackTrace(); } return null; }
From source file:org.apache.cordova.api.PluginResult.java
public PluginResult(Status status, byte[] data, boolean binaryString) { this.status = status.ordinal(); this.messageType = binaryString ? MESSAGE_TYPE_BINARYSTRING : MESSAGE_TYPE_ARRAYBUFFER; this.encodedMessage = Base64.encodeToString(data, Base64.NO_WRAP); }
From source file:com.aegiswallet.utils.WalletUtils.java
public static void writeEncryptedKeys(@Nonnull final Writer out, @Nonnull final List<ECKey> keys, SharedPreferences prefs, String passOrNFC) throws IOException { boolean nfcEnabled = prefs.contains(Constants.SHAMIR_ENCRYPTED_KEY) ? false : true; String x1 = prefs.getString(Constants.SHAMIR_LOCAL_KEY, null); String x2 = null;/*from w ww.j av a 2s . c o m*/ String encodedEncryptedX2 = null; if (!nfcEnabled) { x2 = prefs.getString(Constants.SHAMIR_ENCRYPTED_KEY, null); String encryptedX2 = encryptString(x2, passOrNFC); encodedEncryptedX2 = Base64.encodeToString(encryptedX2.getBytes("UTF-8"), Base64.NO_WRAP); } out.write("# PRIVATE KEYS ARE ENCRYPTED WITH SHAMIR SECRET SHARING\n"); out.write("# TO DECRYPT - Import this backup and provide your password or NFC token\n"); out.write("# If password/NFC token are lost, contact Bitcoin Security Project. We may be able to help.\n"); out.write("#" + x1); out.write("\n"); if (!nfcEnabled && encodedEncryptedX2 != null) { out.write("#X2:" + encodedEncryptedX2); out.write("\n"); out.write("#ENCTYPE:PASSWORD"); } //Means NFC is enabled and we're using that for encryption else if (nfcEnabled) { out.write("#ENCTYPE:NFC"); } out.write("\n"); BigInteger mainKey = null; if (nfcEnabled) { mainKey = generateSecretFromStrings(x1, passOrNFC, null); } else if (x2 != null) { mainKey = generateSecretFromStrings(x1, x2, null); } String mainKeyHash = convertToSha256(mainKey.toString()); for (final ECKey key : keys) { String encodedKey = key.getPrivateKeyEncoded(Constants.NETWORK_PARAMETERS).toString(); String encryptedKey = encryptString(encodedKey, mainKeyHash); out.write(Base64.encodeToString(encryptedKey.getBytes(), Base64.NO_WRAP)); out.write('\n'); } }