Java Code Examples for com.google.api.client.util.Base64#encodeBase64String()
The following examples show how to use
com.google.api.client.util.Base64#encodeBase64String() .
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: OAuthHmacSigner.java From google-oauth-java-client with Apache License 2.0 | 6 votes |
public String computeSignature(String signatureBaseString) throws GeneralSecurityException { // compute key StringBuilder keyBuf = new StringBuilder(); String clientSharedSecret = this.clientSharedSecret; if (clientSharedSecret != null) { keyBuf.append(OAuthParameters.escape(clientSharedSecret)); } keyBuf.append('&'); String tokenSharedSecret = this.tokenSharedSecret; if (tokenSharedSecret != null) { keyBuf.append(OAuthParameters.escape(tokenSharedSecret)); } String key = keyBuf.toString(); // sign SecretKey secretKey = new SecretKeySpec(StringUtils.getBytesUtf8(key), "HmacSHA1"); Mac mac = Mac.getInstance("HmacSHA1"); mac.init(secretKey); return Base64.encodeBase64String(mac.doFinal(StringUtils.getBytesUtf8(signatureBaseString))); }
Example 2
Source File: WorkflowManager.java From android-uiconductor with Apache License 2.0 | 5 votes |
public String takeScreenshot() throws UicdException, IOException { String deviceId = devicesDriverManager.getSelectedAndroidDeviceDriver().getDeviceId(); String screenshotTmpPath = UicdConfig.getInstance().getTestOutputFolder(); screenshotTmpPath = Paths.get(screenshotTmpPath, deviceId, "tmpScreenCapture.png").toString(); ImageUtil.saveScreenshotToLocal(deviceId, screenshotTmpPath); BufferedImage bImage = ImageIO.read(new File(screenshotTmpPath)); ByteArrayOutputStream bos = new ByteArrayOutputStream(); ImageIO.write(bImage, "png", bos); return Base64.encodeBase64String(bos.toByteArray()); }
Example 3
Source File: FakeBigQueryServices.java From beam with Apache License 2.0 | 5 votes |
public static String encodeQueryResult(Table table, List<TableRow> rows) throws IOException { KvCoder<String, List<TableRow>> coder = KvCoder.of(StringUtf8Coder.of(), ListCoder.of(TableRowJsonCoder.of())); KV<String, List<TableRow>> kv = KV.of(BigQueryHelpers.toJsonString(table), rows); ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); coder.encode(kv, outputStream); return Base64.encodeBase64String(outputStream.toByteArray()); }
Example 4
Source File: GoogleSpreadsheet.java From pdi-google-spreadsheet-plugin with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static String base64EncodePrivateKeyStore(KeyStore pks) throws GeneralSecurityException, IOException { if (pks != null && pks.containsAlias("privatekey")) { ByteArrayOutputStream privateKeyStream = new ByteArrayOutputStream(); pks.store(privateKeyStream, GoogleSpreadsheet.SECRET); return Base64.encodeBase64String(privateKeyStream.toByteArray()); } return ""; }
Example 5
Source File: WorkflowManager.java From android-uiconductor with Apache License 2.0 | 4 votes |
public String getImage(String uuid) { return Base64.encodeBase64String(imageStorageManager.getImage(uuid)); }
Example 6
Source File: GoogleProxy.java From connector-sdk with Apache License 2.0 | 4 votes |
/** Optional. Specifies a user name and password for proxy authentication. */ public Builder setUserNamePassword(String userName, String password) { this.authToken = Base64.encodeBase64String(String.format("%s:%s", userName, password).getBytes()); return this; }
Example 7
Source File: TestCertificates.java From google-http-java-client with Apache License 2.0 | 4 votes |
public String getBase64Der() throws IOException { return Base64.encodeBase64String(getDer()); }
Example 8
Source File: OAuthRsaSigner.java From google-oauth-java-client with Apache License 2.0 | 4 votes |
public String computeSignature(String signatureBaseString) throws GeneralSecurityException { Signature signer = SecurityUtils.getSha1WithRsaSignatureAlgorithm(); byte[] data = StringUtils.getBytesUtf8(signatureBaseString); return Base64.encodeBase64String(SecurityUtils.sign(signer, privateKey, data)); }
Example 9
Source File: HttpHeaders.java From google-http-java-client with Apache License 2.0 | 3 votes |
/** * Sets the {@link #authorization} header as specified in <a * href="http://tools.ietf.org/html/rfc2617#section-2">Basic Authentication Scheme</a>. * * <p>Overriding is only supported for the purpose of calling the super implementation and * changing the return type, but nothing else. * * @since 1.2 */ public HttpHeaders setBasicAuthentication(String username, String password) { String userPass = Preconditions.checkNotNull(username) + ":" + Preconditions.checkNotNull(password); String encoded = Base64.encodeBase64String(StringUtils.getBytesUtf8(userPass)); return setAuthorization("Basic " + encoded); }