如何在春季休息服务中检索基本的auth params

时间:2012-10-12 07:37:26

标签: java spring basic-authentication

我在我的项目中使用Spring rest服务。现在我想对其余服务强制执行基本身份验证。我能够进行基本身份验证,但我需要基本身份验证中的用户名。我无法从请求中提取基本的auth参数。

示例网址:

http://testusername:testpasword@localhost:7001/sampleApp/rest/test.json

在对上面的网址进行身份验证后,我的服务类中需要testusername。

我正在使用apache LDAP进行身份验证。所以在我的应用程序中,我不会使用spring security。但是我的服务类需要基本的auth params。

My Rest class api:

@RequestMapping(value="/test", method = {RequestMethod.POST,RequestMethod.GET},
        headers="Accept=application/xml, application/json")
public String getData() (String userId,HttpServletRequest request) {

    return "test";
}

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:0)