new String(Base64.decodeBase64(auth), StandardCharsets.UTF_8); String username = usernameColonPassword.substring(0, usernameColonPassword.indexOf(":")); String password = usernameColonPassword.substring(usernameColonPassword.indexOf(":") + 1);
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; } }
/** * @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); }
/** * 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); }
/** * @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; }
/** 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; }
/** * 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); }
/** * @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; }
/** * @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); }
/** * 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); }
/** * 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; }
/** * @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); }
/** * 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); }
/** * 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; }
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()); }
/** * 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); }
/** * @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; }
/** * 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); }
/** * @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; }
/** * 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); }