Cryptographic utilities.
Cryptographic utilities.
These utilities are intended as a convenience, however it is important to read each methods documentation and understand the concepts behind encryption to use this class properly. Safe encryption is hard, and there is no substitute for an adequate understanding of cryptography. These methods will not be suitable for all encryption needs.
For more information about cryptography, we recommend reading the OWASP Cryptographic Storage Cheatsheet:
https://www.owasp.org/index.php/Cryptographic_Storage_Cheat_Sheet
Configuration for Crypto
Configuration for Crypto
The application secret
The crypto provider to use
The AES transformation to use
JSONP helper.
JSONP helper.
Example of use, provided the following route definition:
GET /my-service Application.myService(callback: String)
The following action definition:
def myService(callback: String) = Action { val json = ... Ok(Jsonp(callback, json)) }
And the following request:
GET /my-service?callback=foo
The response will have content type “text/javascript” and will look like the following:
foo({...});
Another example, showing how to serve either JSON or JSONP from the same action, according to the presence of a “callback” parameter in the query string:
def myService = Action { implicit request => val json = ... request.queryString.get("callback").flatMap(_.headOption) match { case Some(callback) => Ok(Jsonp(callback, json)) case None => Ok(json) } }
Utilities for Codecs operations.
Utilities functions for Collections
Helper function to produce a Comet Enumeratee.
Helper function to produce a Comet Enumeratee.
Example:
val cometStream = Enumerator("A", "B", "C") &> Comet(callback = "console.log")
Cryptographic utilities.
Cryptographic utilities.
These utilities are intended as a convenience, however it is important to read each methods documentation and understand the concepts behind encryption to use this class properly. Safe encryption is hard, and there is no substitute for an adequate understanding of cryptography. These methods will not be suitable for all encryption needs.
For more information about cryptography, we recommend reading the OWASP Cryptographic Storage Cheatsheet:
https://www.owasp.org/index.php/Cryptographic_Storage_Cheat_Sheet
Helps you format Server-Sent Events
Helps you format Server-Sent Events
FileSystem utilities.
JNDI Helpers.
MIME type utilities.
The Iteratee monad provides strict, safe, and functional I/O.
Json API For example:
Json API For example:
import play.api.libs.json._ import play.api.libs.functional.syntax._ case class User(id: Long, name: String, friends: Seq[User] = Seq.empty) object User { // In this format, an undefined friends property is mapped to an empty list implicit val format: Format[User] = ( (__ \ "id").format[Long] and (__ \ "name").format[String] and (__ \ "friends").lazyFormatNullable(implicitly[Format[Seq[User]]]) .inmap[Seq[User]](_ getOrElse Seq.empty, Some(_)) )(User.apply, unlift(User.unapply)) } //then in a controller: object MyController extends Controller { def displayUserAsJson(id: String) = Action { Ok(Json.toJson(User(id.toLong, "myName"))) } def saveUser(jsonString: String)= Action { val user = Json.parse(jsonString).as[User] myDataStore.save(user) Ok } }
OAuth integration helpers.
Asynchronous API to to query web services, as an http client.
Contains various APIs that are useful while developing web applications.