CXF JAX-RS 웹 서비스를 실행하는 스프링 보안 (폼 기반 인증) 웹 앱이 있고 사용자 단위로 인증 할 수있는 Android 앱에서이 웹 서비스에 연결하려고합니다. 현재 웹 서비스 메서드에 @Secured 주석을 추가하면이 메서드에 대한 모든 요청이 거부됩니다. 유효한 사용자/암호 (현재 스프링 보안 기반 웹 응용 프로그램에 존재하며 웹 응용 프로그램에 성공적으로 로그인 할 수 있음)에 대한 자격 증명을 안드로이드 호출에서 전달하려고 시도했지만 요청이 여전히 @ 보안 된 주석이 있습니다. SecurityContext 매개 변수는 getUserPrincipal()을 호출 할 때 null을 반환합니다.스프링 보안 보안 웹 서비스 메소드를 입력 할 수있는 Android 앱에서 요청하는 방법은 무엇입니까?
스프링 보안 보안 웹 서비스 메소드를 입력 할 수있는 Android 앱에서 어떻게 요청할 수 있습니까?
안드로이드 전화 :
httpclient.getCredentialsProvider().setCredentials(
//new AuthScope("192.168.1.101", 80),
new AuthScope(null, -1),
new UsernamePasswordCredentials("joeuser", "mypassword"));
String userAgent = "Android/" + getVersion();
HttpGet httpget = new HttpGet(MY_URI);
httpget.setHeader("User-Agent", userAgent);
httpget.setHeader("Content-Type", "application/xml");
HttpResponse response;
try {
response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
... parse xml
Webservice를 방법 :
@GET
@Path("/payload")
@Produces("application/XML")
@Secured({"ROLE_USER","ROLE_ADMIN","ROLE_GUEST"})
public Response makePayload(@Context Request request, @Context SecurityContext securityContext){
Payload payload = new Payload();
payload.setUsersOnline(new Long(200));
if (payload == null) {
return Response.noContent().build();
}
else{
return Response.ok().entity(payload).build();
}
}
다른 고객으로부터이 서비스에 액세스 할 수 있습니까? SoapUI? 나는. 서버의 보안이 올바르게 설정되어 있습니까? – Tomas