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:
case class User(id: Long, name: String, friends: List[User]) implicit object UserFormat extends Format[User] { def reads(json: JsValue): User = User( (json \ "id").as[Long], (json \ "name").as[String], (json \ "friends").asOpt[List[User]].getOrElse(List())) def writes(u: User): JsValue = JsObject(List( "id" -> JsNumber(u.id), "name" -> JsString(u.name), "friends" -> JsArray(u.friends.map(fr => JsObject(List("id" -> JsNumber(fr.id), "name" -> JsString(fr.name))))))) } //then in a controller: object MyController extends Controller { def displayUserAsJson(id: String) = Action { Ok(toJson( User(id.toLong, "myName", friends: List()))) } def saveUser(jsonString: String)= Action { val user = play.api.libs.json.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.