我需要在我的web应用程序中使用https连接器进行某些请求。假设我的CustomerController
中有两个方法需要发送敏感信息。另外,我使用controllers.Secure.Security
的子类进行身份验证(通过实施authenticate(..)
,所以登录信息将不得不通过SSL。在play1.2.4应用程序中使用ssl
我通过documentation on configuring ssl。从去SO帖子,发现我需要有一个控制器,以确保SSL。
class EnsureSSL extends Controller {
@Before
static void verifySSL() {
if(!request.secure) {
redirect("https://" + request.host + request.url);
}
}
}
现在,我需要在发送敏感信息的任何请求上使用它。我想使用它login /authentication requests
以及CustomerController
的两个敏感方法。
什么是这样做的正确方法?@With(..)只能用于整个类。所以我不能只在CustomerController类的某些方法使用SSL。如果我限制整个班级,会不会增加负荷?
想要的东西的方法等层面装修CustomerController.java
为Security.java@With(EnsureSSL.class)
class Security extends controllers.Secure.Security {
static boolean authenticate(String username, String password) {
...
}
}
class CustomerController extends Controller{
@With(EnsureSSL.class)//cannot do this!
public static void sensitiveMethod1(...){
...
}
@With(EnsureSSL.class)
public static void sensitiveMethod2(...){
...
}
public static void freeForAllToSee(...){
...
}
}
一流水平的装饰,我想知道,如果我在错误的轨道上。可以有人请指教?
我想,我将不得不修改该重定向url以添加https:// 9443,因为ssl和普通应用程序运行的端口是不同的NT – 2012-03-04 05:40:24