List of usage examples for android.util Base64 NO_PADDING
int NO_PADDING
To view the source code for android.util Base64 NO_PADDING.
Click Source Link
From source file:org.openmidaas.library.MIDaaS.java
private static String getJWS(String body) throws JSONException, UnsupportedEncodingException { JSONObject header = new JSONObject(); header.put("alg", "none"); return (Base64.encodeToString(header.toString().getBytes("UTF-8"), Base64.NO_PADDING + Base64.NO_WRAP) + "." + Base64.encodeToString(body.getBytes("UTF-8"), Base64.NO_PADDING + Base64.NO_WRAP) + "."); }
From source file:com.ledger.android.u2f.bridge.MainActivity.java
private String createClientData(U2FContext context) { try {//from ww w. j a v a2 s .c o m JSONObject clientData = new JSONObject(); clientData.put(TAG_JSON_TYP, (context.isSign() ? SIGN_RESPONSE_TYP : REGISTER_RESPONSE_TYP)); clientData.put(TAG_JSON_CHALLENGE, Base64.encodeToString(context.getChallenge(), Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING)); clientData.put(TAG_JSON_ORIGIN, context.getAppId()); clientData.put(TAG_JSON_CID_PUBKEY, CID_UNAVAILABLE); return clientData.toString(); } catch (Exception e) { Log.e(TAG, "Error encoding client data"); return null; } }
From source file:com.ledger.android.u2f.bridge.MainActivity.java
private String createU2FResponseSign(U2FContext context, byte[] signature) { try {/* www . ja v a 2 s. c o m*/ JSONObject response = new JSONObject(); response.put(TAG_JSON_TYPE, SIGN_RESPONSE_TYPE); response.put(TAG_JSON_REQUESTID, context.getRequestId()); JSONObject responseData = new JSONObject(); responseData.put(TAG_JSON_KEYHANDLE, Base64.encodeToString(context.getChosenKeyHandle(), Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING)); responseData.put(TAG_JSON_SIGNATUREDATA, Base64.encodeToString(signature, 0, signature.length - 2, Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING)); String clientData = createClientData(context); responseData.put(TAG_JSON_CLIENTDATA, Base64.encodeToString(clientData.getBytes("UTF-8"), Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING)); response.put(TAG_JSON_RESPONSEDATA, responseData); return response.toString(); } catch (Exception e) { Log.e(TAG, "Error encoding request"); return null; } }
From source file:com.ledger.android.u2f.bridge.MainActivity.java
private String createU2FResponseRegister(U2FContext context, byte[] registerResponse) { try {/*w ww.j a v a 2 s . c o m*/ JSONObject response = new JSONObject(); response.put(TAG_JSON_TYPE, REGISTER_RESPONSE_TYPE); response.put(TAG_JSON_REQUESTID, context.getRequestId()); JSONObject responseData = new JSONObject(); responseData.put(TAG_JSON_REGISTRATIONDATA, Base64.encodeToString(registerResponse, 0, registerResponse.length - 2, Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING)); responseData.put(TAG_JSON_VERSION, VERSION_U2F_V2); String clientData = createClientData(context); responseData.put(TAG_JSON_CLIENTDATA, Base64.encodeToString(clientData.getBytes("UTF-8"), Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING)); response.put(TAG_JSON_RESPONSEDATA, responseData); return response.toString(); } catch (Exception e) { Log.e(TAG, "Error encoding request"); return null; } }
From source file:com.google.ipc.invalidation.ticl.android.AndroidChannel.java
/** Returns the web encoded version of the channel network endpoint ID for HTTP requests. */ @Override//from w ww . j a v a 2 s . co m protected String getWebEncodedEndpointId() { NetworkEndpointId networkEndpointId = getNetworkId(); return Base64.encodeToString(networkEndpointId.toByteArray(), Base64.URL_SAFE | Base64.NO_WRAP | Base64.NO_PADDING); }
From source file:com.microsoft.aad.adal.Oauth2.java
public static String decodeProtocolState(String encodedState) { if (!StringExtensions.IsNullOrBlank(encodedState)) { byte[] stateBytes = Base64.decode(encodedState, Base64.NO_PADDING | Base64.URL_SAFE); return new String(stateBytes); }//from w w w . j a v a 2 s. c o m return null; }
From source file:com.facebook.Settings.java
public static String getApplicationSignature(Context context) { if (context == null) { return null; }/*from w w w. ja v a2s . c o m*/ PackageManager packageManager = context.getPackageManager(); if (packageManager == null) { return null; } String packageName = context.getPackageName(); PackageInfo pInfo; try { pInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES); } catch (PackageManager.NameNotFoundException e) { return null; } Signature[] signatures = pInfo.signatures; if (signatures == null || signatures.length == 0) { return null; } MessageDigest md; try { md = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException e) { return null; } md.update(pInfo.signatures[0].toByteArray()); return Base64.encodeToString(md.digest(), Base64.URL_SAFE | Base64.NO_PADDING); }
From source file:com.microsoft.aad.adal.Oauth2.java
public String encodeProtocolState() { String state = String.format("a=%s&r=%s", mRequest.getAuthority(), mRequest.getResource()); return Base64.encodeToString(state.getBytes(), Base64.NO_PADDING | Base64.URL_SAFE); }
From source file:com.facebook.FacebookSdk.java
/** * Internal call please don't use directly. * @param context The application context. * @return The application signature.//from ww w . ja v a2 s.c o m */ public static String getApplicationSignature(Context context) { Validate.sdkInitialized(); if (context == null) { return null; } PackageManager packageManager = context.getPackageManager(); if (packageManager == null) { return null; } String packageName = context.getPackageName(); PackageInfo pInfo; try { pInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES); } catch (PackageManager.NameNotFoundException e) { return null; } Signature[] signatures = pInfo.signatures; if (signatures == null || signatures.length == 0) { return null; } MessageDigest md; try { md = MessageDigest.getInstance("SHA-1"); } catch (NoSuchAlgorithmException e) { return null; } md.update(pInfo.signatures[0].toByteArray()); return Base64.encodeToString(md.digest(), Base64.URL_SAFE | Base64.NO_PADDING); }
From source file:piuk.blockchain.android.MyWallet.java
public static ECKey decodeBase64PK(String base64Priv) throws Exception { byte[] privBytes = Base64.decode(base64Priv, Base64.NO_PADDING); // Prppend a zero byte to make the biginteger unsigned byte[] appendZeroByte = ArrayUtils.addAll(new byte[1], privBytes); ECKey ecKey = new ECKey(new BigInteger(appendZeroByte)); return ecKey; }