Entradas

Mostrando las entradas etiquetadas como Spring

Enviar Correo con JAVA

Imagen
pom.xml <dependency> <groupId>com.sun.mail</groupId> <artifactId>javax.mail</artifactId> <version>1.6.2</version> </dependency> Clase java private static void enviarConOutlook(Correo correo) throws IOException { try { Properties props = new Properties(); props.put("mail.smtp.host", "smtp-mail.outlook.com"); props.put("mail.smtp.port", "587"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.auth", "true"); Session session = Session.getDefaultInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(correo.getCorreoRemitente(), correo.getClaveRemitente()); } }); Message msg = new MimeMessage(session); msg.setFrom(new InternetAddress(correo.getCorreoRemitente(), "NoReply...

Consumir Servicio Spring Boot + JWT con JAVA

package com.util; import java.nio.charset.Charset; import org.apache.tomcat.util.codec.binary.Base64; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.client.RestTemplate; public class Consumidor { static final String URL_LOGIN = "http://192.168.20.64:8071/oauth/token"; public static void main(String[] args) { String usernameHeader = "angularapp";         String passwordHeader = "12345";       String usernameBody = "42596272";         String passwordBody = "12345";               postLogin(usernameHeader, passwordHeader, usernameBody, passwordBody); } private static void postLogin(String usernameHea...