使用Java在Play框架中的动作组合

时间:2013-02-01 15:39:23

标签: json security playframework-2.0

我正在为Play的安全实现开发一系列操作。

出于安全原因,在JSON请求有效负载中发送了访问令牌,而不是在请求的标头中。 我所做的是,在一个动作(SecureAction)中提取令牌并继续下一个动作......可以在Http.Context中修改请求吗? 一些代码..

@With(SecureAction.class)
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
@Inherited
@Documented
public @interface Secured {
    //TODO ver parametros de acceso ..... al metodo

}

public class SecureAction extends Action.Simple {

    @Override
    public Result call(Http.Context ctx) throws Throwable {
        //TODO extract token of request "ctx.request().body()"
        //TODO change request with new body witout token and delegate to the next action
        return delegate.call(ctx);
    }
 }

 @actions.security.Secured
 public static Result addAccount() {

     Form<Account> f = form(Account.class).bindFromRequest();
        if (f.hasErrors()) {
            return badRequest();
        }

        .....
 }

问候!!!!

0 个答案:

没有答案
相关问题