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; } }
/** * 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; }
/** * 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; }
/** * @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; }
/** * @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; }
/** * @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; }
/** * Fingerprint of the previous set of labels for this resource, used to prevent conflicts. Provide * the latest fingerprint value when making a request to add or change labels. * @see #setLabelFingerprint() * * <p> * The value is encoded Base64 or {@code null} for none. * </p> * * @since 1.14 */ public InstancesSetLabelsRequest encodeLabelFingerprint(byte[] labelFingerprint) { this.labelFingerprint = com.google.api.client.util.Base64.encodeBase64URLSafeString(labelFingerprint); return this; }
/** * The entire email message in an RFC 2822 formatted and base64url encoded string. Returned in * messages.get and drafts.get responses when the format=RAW parameter is supplied. * @see #setRaw() * * <p> * The value is encoded Base64 or {@code null} for none. * </p> * * @since 1.14 */ public Message encodeRaw(byte[] raw) { this.raw = com.google.api.client.util.Base64.encodeBase64URLSafeString(raw); return this; }
/** * A message digest produced with the SHA-256 algorithm. * @see #setSha256() * * <p> * The value is encoded Base64 or {@code null} for none. * </p> * * @since 1.14 */ public Digest encodeSha256(byte[] sha256) { this.sha256 = com.google.api.client.util.Base64.encodeBase64URLSafeString(sha256); return this; }
/** * @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; }
/** * Base64 encoded photo data * @see #setPhotoData() * * <p> * The value is encoded Base64 or {@code null} for none. * </p> * * @since 1.14 */ public UserPhoto encodePhotoData(byte[] photoData) { this.photoData = com.google.api.client.util.Base64.encodeBase64URLSafeString(photoData); return this; }
/** * The bytes to sign. * @see #setBytesToSign() * * <p> * The value is encoded Base64 or {@code null} for none. * </p> * * @since 1.14 */ public SignBlobRequest encodeBytesToSign(byte[] bytesToSign) { this.bytesToSign = com.google.api.client.util.Base64.encodeBase64URLSafeString(bytesToSign); return this; }
/** * The signed blob. * @see #setSignature() * * <p> * The value is encoded Base64 or {@code null} for none. * </p> * * @since 1.14 */ public SignBlobResponse encodeSignature(byte[] signature) { this.signature = com.google.api.client.util.Base64.encodeBase64URLSafeString(signature); return this; }
/** * A message digest produced with the SHA-384 algorithm. * @see #setSha384() * * <p> * The value is encoded Base64 or {@code null} for none. * </p> * * @since 1.14 */ public Digest encodeSha384(byte[] sha384) { this.sha384 = com.google.api.client.util.Base64.encodeBase64URLSafeString(sha384); return this; }
/** * @see #setData() * * <p> * The value is encoded Base64 or {@code null} for none. * </p> * * @since 1.14 */ public MigrationItem encodeData(byte[] data) { this.data = com.google.api.client.util.Base64.encodeBase64URLSafeString(data); return this; }
/** * Next page token. * @see #setNextPageToken() * * <p> * The value is encoded Base64 or {@code null} for none. * </p> * * @since 1.14 */ public RasterCollectionsListResponse encodeNextPageToken(byte[] nextPageToken) { this.nextPageToken = com.google.api.client.util.Base64.encodeBase64URLSafeString(nextPageToken); return this; }
/** * HTTP body binary data. * @see #setData() * * <p> * The value is encoded Base64 or {@code null} for none. * </p> * * @since 1.14 */ public GoogleApiHttpBody encodeData(byte[] data) { this.data = com.google.api.client.util.Base64.encodeBase64URLSafeString(data); return this; }
return Base64.encodeBase64URLSafeString(keyMessageBuilder.build().toByteArray());
private String signPayload(JsonWebSignature.Header header, FirebaseCustomAuthToken.Payload payload) throws IOException { String headerString = Base64.encodeBase64URLSafeString(jsonFactory.toByteArray(header)); String payloadString = Base64.encodeBase64URLSafeString(jsonFactory.toByteArray(payload)); String content = headerString + "." + payloadString; byte[] contentBytes = StringUtils.getBytesUtf8(content); String signature = Base64.encodeBase64URLSafeString(signer.sign(contentBytes)); return content + "." + signature; }
public static Message createMessageWithEmail(MimeMessage emailContent) throws MessagingException, IOException { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); emailContent.writeTo(buffer); byte[] bytes = buffer.toByteArray(); String encodedEmail = Base64.encodeBase64URLSafeString(bytes); Message message = new Message(); message.setRaw(encodedEmail); return message; }