2012-03-03 3 views
1

내 웹 응용 프로그램에서 https connector를 사용하여 특정 요청을해야합니다. 내 CustomerController에 두 가지 방법이 있습니다. 또한 민감한 정보를 보내야합니다. 또한 controllers.Secure.Security의 하위 클래스를 인증에 사용합니다. (authenticate(..)를 구현하여, 로그인 정보는 SSL을 통해 갈 필요가 있도록.play1.2.4 응용 프로그램에서 ssl 사용

을 내가 게시물 그래서 documentation on configuring ssl 피하여 통해 갔다, 나는 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(...){ 
     ... 
    } 
} 

클래스 수준 장식 나는 잘못된 길을 가고있다. 누군가 조언 해 줄 수 있는가?

답변

2

이에 대한 자신의 주석을 만들 수 있습니다

package utils; 

@Retention(RetentionPolicy.RUNTIME) 
@Target(ElementType.METHOD) 
public @interface RequiresSSL { 
} 

지금과 같은 컨트롤러 방법 작성 :

@With(EnsureSSL.class) 
class CustomerController extends Controller{ 
    @RequiresSSL 
    public static void sensitiveMethod1(...){ 
     ... 
    } 
    @RequiresSSL 
    public static void sensitiveMethod2(...){ 
     ... 
    } 
    public static void freeForAllToSee(...){ 
     ... 
    } 
} 

을 그리고 체크 befoe 당신의 EnsureSSL을 수정

class EnsureSSL extends Controller { 
    @Before 
    static void verifySSL() { 
     if((!request.secure) 
      && (request.invokedMethod.getAnnotation(RequiresSSL.class) != null)) { 
     redirect("https://" + request.host + request.url); 
     } 
    } 
} 
+0

나는 생각한다 , https : // 9443을 추가하도록 해당 리디렉션 URL을 수정해야합니다. SSL 및 일반 앱 실행을위한 포트가 다르기 때문입니다. NT –

관련 문제