playframework-2.0

Creating a very secure login with cookies and java

倾然丶 夕夏残阳落幕 提交于 2020-01-04 02:20:07
问题 I'm designing a very secure login mechanism using play framework2. Since Play does not have a notion of sessions and keep things in the cookies (which I like) I was wondering what are the security measures I need to think about. We obviously going to use SSL to communicate the login credentials and also the cookie is going to be encrypted value of some of user's information like their email or userid. Is it possible that someone can sniff that cookie or get a hold of it from another user's

“bash: play: command not found” when trying heroku for the first time

孤街醉人 提交于 2020-01-03 17:44:59
问题 I'm trying out Play! with heroku and was going through the guide in the heroku site (https://devcenter.heroku.com/articles/play). After deploying my sample app, I noticed the dyno crashed. I checked the heroku logs and found out that heroku couldn't find the play command. Anyone know how to install the Play! framework on heroku? I searched the dev center but couldn't find any info. 回答1: Heroku will automatically detect Play! applications and install the Play! runtime for you when you push

Playframework 2.0 define function in View Template

萝らか妹 提交于 2020-01-03 17:29:18
问题 I am working on a project using PlayFramework 2.0. After reading a bit of scala I would like to embed some dynamic code in the View template. So, I did the following: @{ def getMystring(sequence:Int) = { if(patternForm != null && patternForm.get().windowTreatments != null && patternForm.get().windowTreatments.size() >= sequence + 1) sequence+"" else "" } } <input type = "text" value = @getMystring(1)></input> ... I was quite sure it was going to work but instead I got a "not found: value

Play 2 - Scala - Forms Validators and radio buttons

倾然丶 夕夏残阳落幕 提交于 2020-01-03 16:37:01
问题 I'm need render a Form with validators for this model: Model: case class Service ( name: String, description: String, unitcost: Long, typo: Char, isactive: Char, modifiedby: String) Controller: import play.api.data.Form import play.api.data._ import play.api.data.format.Formats._ import play.api.data.Forms._ object Services extends Controller { .... .... private val servicesForm[Service] = Form( mapping( "name" -> nonEmptyText.verifying( "validation.name.duplicate", Service.findByName(_)

Dynamic SQL Parameters with Anorm and Scala Play Framework

最后都变了- 提交于 2020-01-03 07:26:22
问题 Is it possible to dynamically create a list for anorm's "on" method? I have a form with optional inputs and currently I check each Option and create a list with the defined Options and am trying to pass this through to anorm. Currently I get this compilation error type mismatch; found : List[java.io.Serializable] required: (Any, anorm.ParameterValue[_]) I'm not sure how I would go about creating this list. Current code : val onList = List( 'school_id = input.school, if(input.rooms isDefined)

Play Framework - Set URL for Assets

流过昼夜 提交于 2020-01-03 04:53:08
问题 In production, I want to use nginx for serving statics. How to set a URL for assets in Play framework that we can use in both development and production. I like the way Django set STATIC_URL in settings. EDIT: In Django, you can set STATIC_URL = 'https://static.domain.com/' in settings.py . In templates, you can call the value for: <script src='{{ STATIC_URL }}js/jquery.js'></script> 回答1: You can add anything you need to the application.conf, so for an instance it can be the static domain

How to use Play Framework's request and session scope in Google Guice?

梦想的初衷 提交于 2020-01-03 01:49:08
问题 I am using Guice for Dependency Injection in my Play (Java) Framework project, and struggling to understand how the concept of "session" is best used with Guice and Play? I know that Play is stateless and there really is no concept of a session, other than that you can store values in a cookie. My understanding with Guice and Play is that, while Guice documentation describes supporting different scopes (singleton, session, request, no scope), because we are instantiating a new injector with

Play framework 2.2: How to get current controller and action in java

心不动则不痛 提交于 2020-01-02 22:34:19
问题 In my application authentication scheme is based on user and role. users with particular role have access to particular action method. To implement this I have done following 1.Write custom action public class Authorization extends play.mvc.Action.Simple { public Promise<Result> call(Context ctx) throws Throwable { //check access return delegate.call(ctx); } } 2.Annotate controller with action @With(actions.Authorization.class) public class Upload extends Controller { .... } In my action I

Playframework: override BadRequest

浪子不回头ぞ 提交于 2020-01-02 10:37:29
问题 I'm using Playframework 2.0 (scala version) and I want to override "BadRequest" method in one of my controllers. My controller extends a trait: package controllers import play.api._ import play.api.mvc._ import play.api.libs.json.JsValue import play.api.libs.json.JsObject /* * Simple trait to factor common code used by all controllers... */ trait AbstractController extends Controller { // Personal useful methods // ... // Implementation of an override of BadRequest ? } My controller: package

How to make a synchronous WS call with Play Framework 2.2 (Java)

心已入冬 提交于 2020-01-02 10:25:09
问题 I'm looking for an example like this but with a synchronous call. My program needs data from external source and should wait until response returns (or until timeout). 回答1: All you can do is just block the call wait until get response with timeout if you want. WS.Response response = WS.url(url) .setHeader("Authorization","BASIC base64str") .setContentType("application/json") .post(requestJsonNode) .get(20000); //20 sec JsonNode resNode = response.asJson(); 回答2: The Play WS library is meant