com.google.api.client.util.Base64类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(308)

本文整理了Java中com.google.api.client.util.Base64类的一些代码示例,展示了Base64类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Base64类的具体详情如下:
包路径:com.google.api.client.util.Base64
类名称:Base64

Base64介绍

暂无

代码示例

代码示例来源:origin: GoogleContainerTools/jib

new String(Base64.decodeBase64(auth), StandardCharsets.UTF_8);
String username = usernameColonPassword.substring(0, usernameColonPassword.indexOf(":"));
String password = usernameColonPassword.substring(usernameColonPassword.indexOf(":") + 1);

代码示例来源:origin: magefree/mage

public static boolean sendMessage(String email, String subject, String text) {
    if (email.isEmpty()) {
      logger.info("Email is not sent because the address is empty");
      return false;
    }
    try {
      Gmail gmail = new Builder(httpTransport, JSON_FACTORY, credential).setApplicationName("XMage Server").build();

      MimeMessage mimeMessage = new MimeMessage(Session.getDefaultInstance(new Properties()));
      mimeMessage.addRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(email));
      mimeMessage.setSubject(subject);
      mimeMessage.setText(text);

      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      mimeMessage.writeTo(baos);
      Message message = new Message();
      message.setRaw(Base64.encodeBase64URLSafeString(baos.toByteArray()));

      gmail.users().messages().send(ConfigSettings.instance.getGoogleAccount()
          + (ConfigSettings.instance.getGoogleAccount().endsWith("@gmail.com") ? "" : "@gmail.com"), message).execute();
      return true;
    } catch (MessagingException | IOException ex) {
      logger.error("Error sending message", ex);
    }
    return false;
  }
}

代码示例来源:origin: GoogleContainerTools/jib

/**
 * @param username the username
 * @param secret the secret
 * @return an {@link Authorization} with a {@code Basic} credentials
 */
public static Authorization withBasicCredentials(String username, String secret) {
 String credentials = username + ":" + secret;
 String token = Base64.encodeBase64String(credentials.getBytes(StandardCharsets.UTF_8));
 return new Authorization("Basic", token);
}

代码示例来源:origin: com.google.apis/google-api-services-compute

/**
 * Fingerprint of the target pools information, which is a hash of the contents. This field is
 * used for optimistic locking when you update the target pool entries. This field is optional.
 * @see #getFingerprint()
 * @return Base64 decoded value or {@code null} for none
 *
 * @since 1.14
 */
public byte[] decodeFingerprint() {
 return com.google.api.client.util.Base64.decodeBase64(fingerprint);
}

代码示例来源:origin: com.google.apis/google-api-services-youtube

/**
 * @see #setImageBytes()
 *
 * <p>
 * The value is encoded Base64 or {@code null} for none.
 * </p>
 *
 * @since 1.14
 */
public InvideoBranding encodeImageBytes(byte[] imageBytes) {
 this.imageBytes = com.google.api.client.util.Base64.encodeBase64URLSafeString(imageBytes);
 return this;
}

代码示例来源:origin: com.google.enterprise.cloudsearch/google-cloudsearch-connector-sdk

/** 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;
}

代码示例来源:origin: com.google.apis/google-api-services-iam

/**
 * Optional. Note: `etag` is an inoperable legacy field that is only returned for backwards
 * compatibility.
 * @see #getEtag()
 * @return Base64 decoded value or {@code null} for none
 *
 * @since 1.14
 */
public byte[] decodeEtag() {
 return com.google.api.client.util.Base64.decodeBase64(etag);
}

代码示例来源:origin: org.ctoolkit.api/ctoolkit-agent-gen-lib

/**
 * @see #setData()
 *
 * <p>
 * The value is encoded Base64 or {@code null} for none.
 * </p>
 *
 * @since 1.14
 */
public ExportItem encodeData(byte[] data) {
 this.data = com.google.api.client.util.Base64.encodeBase64URLSafeString(data);
 return this;
}

代码示例来源:origin: gradle.plugin.com.google.cloud.tools/jib-gradle-plugin

/**
 * @param username the username
 * @param secret the secret
 * @return an {@link Authorization} with a {@code Basic} credentials
 */
public static Authorization withBasicCredentials(String username, String secret) {
 String credentials = username + ":" + secret;
 String token = Base64.encodeBase64String(credentials.getBytes(StandardCharsets.UTF_8));
 return new Authorization("Basic", token);
}

代码示例来源:origin: com.google.apis/google-api-services-iam

/**
 * The public key data. Only provided in `GetServiceAccountKey` responses.
 * @see #getPublicKeyData()
 * @return Base64 decoded value or {@code null} for none
 *
 * @since 1.14
 */
public byte[] decodePublicKeyData() {
 return com.google.api.client.util.Base64.decodeBase64(publicKeyData);
}

代码示例来源:origin: com.google.apis/google-api-services-books

/**
 * Base64 encoded data for this annotation data.
 * @see #setEncodedData()
 *
 * <p>
 * The value is encoded Base64 or {@code null} for none.
 * </p>
 *
 * @since 1.14
 */
public Annotationdata encodeEncodedData(byte[] encodedData) {
 this.encodedData = com.google.api.client.util.Base64.encodeBase64URLSafeString(encodedData);
 return this;
}

代码示例来源:origin: com.google.cloud.tools/jib-maven-plugin

/**
 * @param username the username
 * @param secret the secret
 * @return an {@link Authorization} with a {@code Basic} credentials
 */
public static Authorization withBasicCredentials(String username, String secret) {
 String credentials = username + ":" + secret;
 String token = Base64.encodeBase64String(credentials.getBytes(StandardCharsets.UTF_8));
 return new Authorization("Basic", token);
}

代码示例来源:origin: com.google.apis/google-api-services-iam

/**
 * The signed blob.
 * @see #getSignature()
 * @return Base64 decoded value or {@code null} for none
 *
 * @since 1.14
 */
public byte[] decodeSignature() {
 return com.google.api.client.util.Base64.decodeBase64(signature);
}

代码示例来源:origin: com.google.apis/google-api-services-mapsengine

/**
 * Next page token.
 * @see #setNextPageToken()
 *
 * <p>
 * The value is encoded Base64 or {@code null} for none.
 * </p>
 *
 * @since 1.14
 */
public PublishedMapsListResponse encodeNextPageToken(byte[] nextPageToken) {
 this.nextPageToken = com.google.api.client.util.Base64.encodeBase64URLSafeString(nextPageToken);
 return this;
}

代码示例来源:origin: org.apache.beam/beam-sdks-java-io-google-cloud-platform

static String encodeQuery(List<TableRow> rows) throws IOException {
 ListCoder<TableRow> listCoder = ListCoder.of(TableRowJsonCoder.of());
 ByteArrayOutputStream output = new ByteArrayOutputStream();
 listCoder.encode(rows, output, Context.OUTER);
 return Base64.encodeBase64String(output.toByteArray());
}

代码示例来源:origin: com.google.apis/google-api-services-cloudkms

/**
 * The decrypted data originally supplied in EncryptRequest.plaintext.
 * @see #getPlaintext()
 * @return Base64 decoded value or {@code null} for none
 *
 * @since 1.14
 */
public byte[] decodePlaintext() {
 return com.google.api.client.util.Base64.decodeBase64(plaintext);
}

代码示例来源:origin: org.ctoolkit.api/ctoolkit-agent-gen-lib

/**
 * @see #setData()
 *
 * <p>
 * The value is encoded Base64 or {@code null} for none.
 * </p>
 *
 * @since 1.14
 */
public ImportItem encodeData(byte[] data) {
 this.data = com.google.api.client.util.Base64.encodeBase64URLSafeString(data);
 return this;
}

代码示例来源:origin: com.google.apis/google-api-services-cloudkms

/**
 * A message digest produced with the SHA-512 algorithm.
 * @see #getSha512()
 * @return Base64 decoded value or {@code null} for none
 *
 * @since 1.14
 */
public byte[] decodeSha512() {
 return com.google.api.client.util.Base64.decodeBase64(sha512);
}

代码示例来源:origin: com.google.apis/google-api-services-youtube

/**
 * @see #setMesh()
 *
 * <p>
 * The value is encoded Base64 or {@code null} for none.
 * </p>
 *
 * @since 1.14
 */
public LiveBroadcastContentDetails encodeMesh(byte[] mesh) {
 this.mesh = com.google.api.client.util.Base64.encodeBase64URLSafeString(mesh);
 return this;
}

代码示例来源:origin: com.google.apis/google-api-services-cloudkms

/**
 * Output only. The attestation data provided by the HSM when the key operation was performed.
 * @see #getContent()
 * @return Base64 decoded value or {@code null} for none
 *
 * @since 1.14
 */
public byte[] decodeContent() {
 return com.google.api.client.util.Base64.decodeBase64(content);
}

相关文章