봄에 사용자 정의 인증이 필요합니다. 사용자가 제공 한 사용자 이름과 암호를 사용하고 일부 값과 비교하여 인증해야하는 간단한 클래스 여야합니다. .봄에 간단한 사용자 정의 인증이 필요합니다.
로그인 양식 GWT로 작성된 시스템을 사용하면 새 창에서 다른 페이지가 열립니다. (OK 버튼을 클릭에)
...
<http auto-config="true">
<intercept-url pattern='/*Login.html' access="IS_AUTHENTICATED_ANONYMOUSLY"/>
<intercept-url pattern='/**/*MainScreen.html' access="ROLE_ADMIN"/>
<form-login login-page="/Login.html"/><!-- This is the default login page -->
</http>
<authentication-provider>
<user-service>
<user name="test1" password="abc" authorities="ROLE_ADMIN" />
<user name="test2" password="test" authorities="ROLE_ADMIN" />
</user-service>
</authentication-provider>
...
사용자 정의 로그인 코드 : 파일 : 응용 문맥 보안을
이
내가 지금까지 시도한 것입니다 RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.POST,"j_spring_security_check");
requestBuilder.setHeader("Content-Type", "application/x-www-form-urlencoded");
//-- sending the username and the password in designated fields.
//Hard coding values for testing reasons:
requestBuilder.setRequestData("j_username=test1" +
"&j_password=abc");
requestBuilder.setCallback(new RequestCallback() {
public void onError(Request request, Throwable exception)
{
Window.alert("ERROR !!!"+exception.getMessage());
}
public void onResponseReceived(Request request, Response response)
{
if (response.getStatusCode() != Response.SC_UNAUTHORIZED && response.getStatusCode() != Response.SC_OK)
{
onError(request, new RequestException(response.getStatusText() + ":\n" + response.getText()));
return;
}
if (response.getStatusCode() == Response.SC_UNAUTHORIZED)
{
//This code is never encountered !! :((
Window.alert("You have entered an incorrect username or password. Please try again.");
}
else
{
String height = 800+"";
String width = 600+"";
Window.alert("Authorisation succeeded, you may enter....");
Window.open("MainScreen.html", "Main screen!!", "height=" + height + ",width=" + width
+ ",scrollbars=yes,resizable=yes,titlebar=no,toolbar=no,status=yes,close=no,left=0,top=0");
}
}
});
requestBuilder.send();
문제 :
- 잘못된 로그인 : 성공을 표시하고 로그인 화면이 포함 된 팝업을 엽니 다 !! (물론 로그인이 성공하지 못했지만 로그인 화면에서이를 감지 할 수 없음)
- 인증 공급자의 값을 하드 코딩하고 싶지 않습니다. 내 자신의 클래스를 제공하는 다른 방법이 있습니까? 몇 가지 튜토리얼을 시도했지만 헛된 것은 모두 스프링이 데이터베이스 나 다른 종류의 파일을 통해 비교 작업을 할 수있게 해주는 것을 가리키는 것 같습니다. 직접 할 수는 없나요?
클라이언트 로그인 코드는 다음을 기반으로합니다. http://raibledesigns.com/rd/entry/integrating_gwt_with_spring_security –
또한 사용자 이름과 암호 외에도 더 많은 데이터를 전달해야하므로 가능합니까? –