/** * Converts the given data to be safe for use in signed URLs for a private * distribution by using specialized Base64 encoding. */ public static String makeBytesUrlSafe(byte[] bytes) { byte[] encoded = Base64.encode(bytes); for (int i=0; i < encoded.length; i++) { switch(encoded[i]) { case '+': encoded[i] = '-'; continue; case '=': encoded[i] = '_'; continue; case '/': encoded[i] = '~'; continue; default: continue; } } return new String(encoded, UTF8); }
meta.setContentMD5(new String(Base64.encode(mHash.digest())));
/** * Generates SRP verification parameters for device verification. * * @param deviceKey REQUIRED: Username this device belongs to. * @param deviceGroup REQUIRED: This is the device group id returned by the service. * @return srp verification details for this device, as a {@link Map}. */ public static Map<String, String> generateVerificationParameters(String deviceKey, String deviceGroup) { final Map<String, String> devVerfPars = new HashMap<String, String>(); final String deviceSecret = generateRandomString(); srpCalculator = new deviceSRP(deviceGroup, deviceKey, deviceSecret); final byte[] salt = srpCalculator.getSalt().toByteArray(); final byte[] srpVerifier = srpCalculator.getVerifier().toByteArray(); devVerfPars.put("salt", new String(Base64.encode(salt))); devVerfPars.put("verifier", new String(Base64.encode(srpVerifier))); devVerfPars.put("secret", deviceSecret); return devVerfPars; }
mac.update(userId.getBytes(StringUtils.UTF8)); final byte[] rawHmac = mac.doFinal(clientId.getBytes(StringUtils.UTF8)); return new String(Base64.encode(rawHmac)); } catch (final Exception e) { throw new CognitoInternalErrorException("errors in HMAC calculation");
.get(CognitoServiceConstants.CHLG_PARAM_SECRET_BLOCK)); srpAuthResponses.put(CognitoServiceConstants.CHLG_RESP_PASSWORD_CLAIM_SIGNATURE, new String(Base64.encode(hmac), StringUtils.UTF8)); srpAuthResponses.put(CognitoServiceConstants.CHLG_RESP_TIMESTAMP, dateString); srpAuthResponses.put(CognitoServiceConstants.CHLG_RESP_USERNAME, usernameInternal);
.get(CognitoServiceConstants.CHLG_PARAM_SECRET_BLOCK)); srpAuthResponses.put(CognitoServiceConstants.CHLG_RESP_PASSWORD_CLAIM_SIGNATURE, new String(Base64.encode(hmac), StringUtils.UTF8)); srpAuthResponses.put(CognitoServiceConstants.CHLG_RESP_TIMESTAMP, dateString); srpAuthResponses.put(CognitoServiceConstants.CHLG_RESP_USERNAME, usernameInternal);
@Test public void testToBytes() { assertEquals("dGVzdA==", new String(Base64.encode(ServiceUtils.toByteArray("test")))); }
public static byte[] encodeSortableBase64(final byte[] original) { final byte[] bytes = Base64.encode(original); for (int i = 0; i < bytes.length; i++) { bytes[i] = defaultToSortable[bytes[i]]; } return bytes; }
/** * Converts the given data to be safe for use in signed URLs for a private * distribution by using specialized Base64 encoding. */ public static String makeBytesUrlSafe(byte[] bytes) { byte[] encoded = Base64.encode(bytes); for (int i=0; i < encoded.length; i++) { switch(encoded[i]) { case '+': encoded[i] = '-'; continue; case '=': encoded[i] = '_'; continue; case '/': encoded[i] = '~'; continue; default: continue; } } return new String(encoded, UTF8); }
/** * Generates SRP verification parameters for device verification. * * @param deviceKey REQUIRED: Username this device belongs to. * @param deviceGroup REQUIRED: This is the device group id returned by the service. * @return srp verification details for this device, as a {@link Map}. */ public static Map<String, String> generateVerificationParameters(String deviceKey, String deviceGroup) { final Map<String, String> devVerfPars = new HashMap<String, String>(); final String deviceSecret = generateRandomString(); srpCalculator = new deviceSRP(deviceGroup, deviceKey, deviceSecret); final byte[] salt = srpCalculator.getSalt().toByteArray(); final byte[] srpVerifier = srpCalculator.getVerifier().toByteArray(); devVerfPars.put("salt", new String(Base64.encode(salt))); devVerfPars.put("verifier", new String(Base64.encode(srpVerifier))); devVerfPars.put("secret", deviceSecret); return devVerfPars; }
return new String(Base64.encode(compressedData),"UTF-8");
mac.update(userId.getBytes(StringUtils.UTF8)); final byte[] rawHmac = mac.doFinal(clientId.getBytes(StringUtils.UTF8)); return new String(Base64.encode(rawHmac)); } catch (final Exception e) { throw new CognitoInternalErrorException("errors in HMAC calculation");
.get(CognitoServiceConstants.CHLG_PARAM_SECRET_BLOCK)); srpAuthResponses.put(CognitoServiceConstants.CHLG_RESP_PASSWORD_CLAIM_SIGNATURE, new String(Base64.encode(hmac), StringUtils.UTF8)); srpAuthResponses.put(CognitoServiceConstants.CHLG_RESP_TIMESTAMP, dateString); srpAuthResponses.put(CognitoServiceConstants.CHLG_RESP_USERNAME, usernameInternal);
.get(CognitoServiceConstants.CHLG_PARAM_SECRET_BLOCK)); srpAuthResponses.put(CognitoServiceConstants.CHLG_RESP_PASSWORD_CLAIM_SIGNATURE, new String(Base64.encode(hmac), StringUtils.UTF8)); srpAuthResponses.put(CognitoServiceConstants.CHLG_RESP_TIMESTAMP, dateString); srpAuthResponses.put(CognitoServiceConstants.CHLG_RESP_USERNAME, usernameInternal);