Ejb jax-rpc веб-сервисы с базовой аутентификацией, как получить имя пользователя и пароль запроса - PullRequest
0 голосов
/ 15 февраля 2011

Проблема ясна, как я уже упоминал в заголовке, любая помощь будет оценена ...

Кстати, мои сервисы работают на Jboss 4.2.2GA, и я использую MyEclipse7.5 Более того, вот что я пробовал раньше, но у меня не получилось;

@Stateless
@WebService(name = "BaseService", targetNamespace = "http://base.ws.listingapi.gg.com")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@WebContext(contextRoot = "/listingapi/ws")
public abstract class BaseService {
    ..

    MessageContext mctx = webServiceContext.getMessageContext();

    webServiceContext.getUserPrincipal(); //WITH THIS ONE I could get the username but of course not password..
    System.out.println(mctx.get("password"));

    Map http_headers = (Map) mctx.get(MessageContext.HTTP_REQUEST_HEADERS);
    List userList = (List) http_headers.get("Username");
    List passList = (List) http_headers.get("Password");

[РЕШИТЬ] Я нашел решение, вот оно;

@Context
protected HttpServletRequest request;

Или

@Context
protected WebServiceContext context;

...

    request.getUserPrincipal().getName(); 
    //OR
    context.getUserPrincipal().getName();
    //will return the username used to getting logged in

1 Ответ

0 голосов
/ 23 февраля 2011

[решено] Я нашел решение, вот оно;

@Context
protected HttpServletRequest request;

Или

@Context
protected WebServiceContext context;

...

request.getUserPrincipal().getName(); 
//OR
context.getUserPrincipal().getName();
//will return the username used to getting logged in
...