c63f8aa9e238d220f01bba74848da94f.ppt
- Количество слайдов: 46
Rest Services with Play Framework, My. SQL, Adding Security with JWT México
Community Leader JDuchess Chapter Guatemala, Devs+502 Ex-JUG Member Guatemala Java Users Group (Guate. JUG) Mercedes Wyss @itrjwyss Independent Consultor Full Stack Developer, Front-end y Back-end with Java, Mobile Development Android and i. OS CTO at Produactivity #geek #traveler #speaker
Agenda • • • Play Framework Web Services Restful JSONs Database Connection (JPA, JDBC) JWT (Json Web Tokens)
Agenda • • • Play Framework Web Services Restful JSONs Database Connection (JPA, JDBC) JWT (Json Web Tokens)
Play Framework • Makes it easy to build web applications with Java and Scala. • Is based on a lightweight, stateless, web-friendly architecture. • Built on Akka, provides predictable and minimal resources consumption (CPU, memory, threads) for • highly-scalable applications.
Servidor: 1 CPU 2 GB Ram
Play Framework • • Develop using Java or Scala Is reactive Use the architecture MVC Uses Netty as App Server, AKKA Http since 2. 6. x (Fewer configurations) • Simulates the behavior of JRebel (more code, less deploys)
JVM
Reactive
MVC
How start a Play project? We need to use SBT Create sbt new playframework/play-scala-seed. g 8 sbt new playframework/play-java-seed. g 8 Deploy sbt run
Full Project Structure
Simple Project Structure
Agenda • • • Play Framework Web Services Restful JSONs Database connection (JPA, JDBC) JWT (Json Web Tokens)
Web Services • Hyper. Text Transfer Protocol (HTTP) • Allows communication between a client and a server • Provide a standard means of interoperating between different software apps • Characterized for interoperability and extensibility • Based on XML
Linda. com (June 2017) https: //www. lynda. com/Software-Development-tutorials/What-web-service/126131/145941 -4. html
SOAP • Simple Object Access Protocol • XML-based • Use WSDL as specification description (Web Services Description Language) • Need to follow a communication protocol
Restful • Software Architecture based on HTTP method (Get, Post, Put, Delete, etc) • Typically use JSON, but can use XML, Text
Madhaiyan Muthu (June 2017) https: //www. slideshare. net/madhaiyanm/web-services-a-practical-approach
Agenda • • • Play Framework Web Services Restful JSONs Database connection (JPA, JDBC) JWT (Json Web Tokens)
JSON • • • Java. Script Object Notation Is a lightweight data-interchange format Self-describing Human-reading Is a Protocol
JSON Example
JSON Scheme
Package controllers; import play. libs. Json; import play. mvc. Controller; import play. mvc. Result; public class Home. Controller extends Controller { public Result index(){ Json. Node json = request(). body(). as. Json(); Post. Request request = Json. from. Json(json, Post. Request. class); return ok(Json. to. Json(request)); } }
Agenda • • • Play Framework Web Services Restful JSONs JWT (Json Web Tokens) Database connection (JPA, JDBC)
JWT Is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object.
Auth 0 (June 2017) https: //cdn. auth 0. com/content/jwt-diagram. png
JWT Structure
JWT Structure
JWT Structure
Agenda • • • Play Framework Web Services Restful JSONs JWT (Json Web Tokens) Database connection (JPA, JDBC)
To End Let’s Finish our Exercise México


